Skip to content

Commit

Permalink
feat(date-picker): make locale prop optional
Browse files Browse the repository at this point in the history
  • Loading branch information
gcornut committed Sep 28, 2023
1 parent d040e53 commit 5c393c6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `@lumx/react` no long depend on `moment` or `moment-range` to generate the date picker.
- Deprecated `@lumx/core/js/date-picker` functions that **will be removed in the next major version** along with `moment` and `moment-range`.
- DatePicker & DatePickerField: `locale` prop is now optional (uses browser locale by default)

## [3.5.3][] - 2023-08-30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getMonthCalendar } from '@lumx/react/utils/date/getMonthCalendar';
import { isSameDay } from '@lumx/react/utils/date/isSameDay';
import { formatMonthYear } from '@lumx/react/utils/date/formatMonthYear';
import { formatDayNumber } from '@lumx/react/utils/date/formatDayNumber';
import { getCurrentLocale } from '@lumx/react/utils/locale/getCurrentLocale';
import { CLASSNAME } from './constants';

/**
Expand Down Expand Up @@ -35,7 +36,7 @@ const COMPONENT_NAME = 'DatePickerControlled';
*/
export const DatePickerControlled: Comp<DatePickerControlledProps, HTMLDivElement> = forwardRef((props, ref) => {
const {
locale,
locale = getCurrentLocale(),
maxDate,
minDate,
nextButtonProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default {
component: DatePickerField,
args: {
...DatePickerField.defaultProps,
locale: 'fr',
'nextButtonProps.label': 'Next month',
'previousButtonProps.label': 'Previous month',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
import { useFocus } from '@lumx/react/hooks/useFocus';
import { Comp, GenericProps } from '@lumx/react/utils/type';
import { formatDate } from '@lumx/react/utils/date/formatDate';
import { getCurrentLocale } from '@lumx/react/utils/locale/getCurrentLocale';

/**
* Defines the props of the component.
Expand All @@ -15,7 +16,7 @@ export interface DatePickerFieldProps extends GenericProps {
/** Whether the component is disabled or not. */
isDisabled?: boolean;
/** Locale (language or region) to use. */
locale: string;
locale?: string;
/** Date after which dates can't be selected. */
maxDate?: Date;
/** Date before which dates can't be selected. */
Expand Down Expand Up @@ -50,7 +51,7 @@ export const DatePickerField: Comp<DatePickerFieldProps, HTMLDivElement> = forwa
defaultMonth,
disabled,
isDisabled = disabled,
locale,
locale = getCurrentLocale(),
maxDate,
minDate,
name,
Expand Down
2 changes: 1 addition & 1 deletion packages/lumx-react/src/components/date-picker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface DatePickerProps extends GenericProps {
/** Default month. */
defaultMonth?: Date;
/** Locale (language or region) to use. */
locale: string;
locale?: string;
/** Date after which dates can't be selected. */
maxDate?: Date;
/** Date before which dates can't be selected. */
Expand Down

0 comments on commit 5c393c6

Please sign in to comment.