Skip to content

Commit 7259230

Browse files
committed
feat(date-picker): make locale prop optional
1 parent f999b19 commit 7259230

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { mdiChevronLeft, mdiChevronRight } from '@lumx/icons';
55
import { Comp } from '@lumx/react/utils/type';
66
import { getMonthCalendar } from '@lumx/react/utils/date/getMonthCalendar';
77
import { isSameDay } from '@lumx/react/utils/date/isSameDay';
8+
import { getCurrentLocale } from '@lumx/react/utils/locale/getCurrentLocale';
89
import { parseLocale } from '@lumx/react/utils/locale/parseLocale';
910
import { Locale } from '@lumx/react/utils/locale/types';
1011
import { CLASSNAME } from './constants';
@@ -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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DatePicker, IconButtonProps, Placement, Popover, TextField } from '@lum
44
import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
55
import { useFocus } from '@lumx/react/hooks/useFocus';
66
import { Comp, GenericProps } from '@lumx/react/utils/type';
7+
import { getCurrentLocale } from '@lumx/react/utils/locale/getCurrentLocale';
78

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

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

Lines changed: 1 addition & 1 deletion
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)