Skip to content

Commit 5c393c6

Browse files
committed
feat(date-picker): make locale prop optional
1 parent d040e53 commit 5c393c6

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

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

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

packages/lumx-react/src/components/date-picker/DatePickerControlled.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { getMonthCalendar } from '@lumx/react/utils/date/getMonthCalendar';
77
import { isSameDay } from '@lumx/react/utils/date/isSameDay';
88
import { formatMonthYear } from '@lumx/react/utils/date/formatMonthYear';
99
import { formatDayNumber } from '@lumx/react/utils/date/formatDayNumber';
10+
import { getCurrentLocale } from '@lumx/react/utils/locale/getCurrentLocale';
1011
import { CLASSNAME } from './constants';
1112

1213
/**
@@ -35,7 +36,7 @@ const COMPONENT_NAME = 'DatePickerControlled';
3536
*/
3637
export const DatePickerControlled: Comp<DatePickerControlledProps, HTMLDivElement> = forwardRef((props, ref) => {
3738
const {
38-
locale,
39+
locale = getCurrentLocale(),
3940
maxDate,
4041
minDate,
4142
nextButtonProps,

packages/lumx-react/src/components/date-picker/DatePickerField.stories.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export default {
88
component: DatePickerField,
99
args: {
1010
...DatePickerField.defaultProps,
11-
locale: 'fr',
1211
'nextButtonProps.label': 'Next month',
1312
'previousButtonProps.label': 'Previous month',
1413
},

packages/lumx-react/src/components/date-picker/DatePickerField.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
55
import { useFocus } from '@lumx/react/hooks/useFocus';
66
import { Comp, GenericProps } from '@lumx/react/utils/type';
77
import { formatDate } from '@lumx/react/utils/date/formatDate';
8+
import { getCurrentLocale } from '@lumx/react/utils/locale/getCurrentLocale';
89

910
/**
1011
* Defines the props of the component.
@@ -15,7 +16,7 @@ export interface DatePickerFieldProps extends GenericProps {
1516
/** Whether the component is disabled or not. */
1617
isDisabled?: boolean;
1718
/** Locale (language or region) to use. */
18-
locale: string;
19+
locale?: string;
1920
/** Date after which dates can't be selected. */
2021
maxDate?: Date;
2122
/** Date before which dates can't be selected. */
@@ -50,7 +51,7 @@ export const DatePickerField: Comp<DatePickerFieldProps, HTMLDivElement> = forwa
5051
defaultMonth,
5152
disabled,
5253
isDisabled = disabled,
53-
locale,
54+
locale = getCurrentLocale(),
5455
maxDate,
5556
minDate,
5657
name,

packages/lumx-react/src/components/date-picker/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface DatePickerProps extends GenericProps {
99
/** Default month. */
1010
defaultMonth?: Date;
1111
/** Locale (language or region) to use. */
12-
locale: string;
12+
locale?: string;
1313
/** Date after which dates can't be selected. */
1414
maxDate?: Date;
1515
/** Date before which dates can't be selected. */

0 commit comments

Comments
 (0)