@mui/x-date-pickers 6.7.0 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AdapterDayjs/AdapterDayjs.d.ts +5 -1
- package/AdapterDayjs/AdapterDayjs.js +42 -15
- package/AdapterLuxon/AdapterLuxon.d.ts +1 -0
- package/AdapterLuxon/AdapterLuxon.js +12 -5
- package/AdapterMoment/AdapterMoment.js +18 -9
- package/CHANGELOG.md +145 -5541
- package/DateCalendar/DateCalendar.js +49 -21
- package/DateCalendar/DateCalendar.types.d.ts +8 -3
- package/DateCalendar/DayCalendar.d.ts +3 -1
- package/DateCalendar/DayCalendar.js +24 -17
- package/DateCalendar/PickersCalendarHeader.js +6 -3
- package/DateCalendar/useCalendarState.d.ts +5 -3
- package/DateCalendar/useCalendarState.js +41 -17
- package/DateCalendar/useIsDateDisabled.d.ts +1 -1
- package/DateCalendar/useIsDateDisabled.js +5 -3
- package/DateField/DateField.js +9 -1
- package/DatePicker/DatePicker.js +9 -1
- package/DateTimeField/DateTimeField.js +9 -1
- package/DateTimePicker/DateTimePicker.js +9 -1
- package/DesktopDatePicker/DesktopDatePicker.js +9 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
- package/DesktopTimePicker/DesktopTimePicker.js +8 -0
- package/DigitalClock/DigitalClock.js +28 -15
- package/MobileDatePicker/MobileDatePicker.js +9 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
- package/MobileTimePicker/MobileTimePicker.js +8 -0
- package/MonthCalendar/MonthCalendar.js +57 -24
- package/MonthCalendar/MonthCalendar.types.d.ts +8 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +28 -15
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/PickersLayout/PickersLayout.js +1 -0
- package/PickersLayout/usePickerLayout.js +4 -3
- package/PickersShortcuts/PickersShortcuts.d.ts +12 -2
- package/PickersShortcuts/PickersShortcuts.js +10 -2
- package/PickersShortcuts/index.d.ts +1 -1
- package/StaticDatePicker/StaticDatePicker.js +9 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
- package/StaticTimePicker/StaticTimePicker.js +8 -0
- package/TimeClock/TimeClock.js +27 -15
- package/TimeField/TimeField.js +9 -1
- package/TimePicker/TimePicker.js +8 -0
- package/YearCalendar/YearCalendar.js +55 -22
- package/YearCalendar/YearCalendar.types.d.ts +8 -2
- package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +1 -1
- package/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
- package/dateViewRenderers/dateViewRenderers.d.ts +1 -1
- package/dateViewRenderers/dateViewRenderers.js +4 -2
- package/index.js +1 -1
- package/internals/hooks/date-helpers-hooks.d.ts +4 -2
- package/internals/hooks/date-helpers-hooks.js +8 -6
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/internals/hooks/useField/useField.d.ts +3 -1
- package/internals/hooks/useField/useField.js +23 -7
- package/internals/hooks/useField/useField.types.d.ts +6 -4
- package/internals/hooks/useField/useField.utils.d.ts +13 -11
- package/internals/hooks/useField/useField.utils.js +55 -43
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +3 -2
- package/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
- package/internals/hooks/useField/useFieldState.d.ts +1 -0
- package/internals/hooks/useField/useFieldState.js +33 -23
- package/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/internals/hooks/usePicker/usePickerValue.js +45 -9
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +22 -6
- package/internals/hooks/usePicker/usePickerViews.d.ts +2 -1
- package/internals/hooks/usePicker/usePickerViews.js +7 -2
- package/internals/hooks/useUtils.d.ts +3 -2
- package/internals/hooks/useUtils.js +5 -2
- package/internals/hooks/useValueWithTimezone.d.ts +33 -0
- package/internals/hooks/useValueWithTimezone.js +69 -0
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/internals/models/props/clock.d.ts +2 -2
- package/internals/utils/date-utils.d.ts +4 -4
- package/internals/utils/date-utils.js +4 -12
- package/internals/utils/fields.js +1 -1
- package/internals/utils/getDefaultReferenceDate.d.ts +12 -3
- package/internals/utils/getDefaultReferenceDate.js +4 -4
- package/internals/utils/validation/extractValidationProps.d.ts +1 -1
- package/internals/utils/validation/validateDate.d.ts +3 -2
- package/internals/utils/validation/validateDate.js +14 -6
- package/internals/utils/validation/validateTime.d.ts +3 -2
- package/internals/utils/validation/validateTime.js +8 -8
- package/internals/utils/valueManagers.js +2 -1
- package/legacy/AdapterDayjs/AdapterDayjs.js +45 -16
- package/legacy/AdapterLuxon/AdapterLuxon.js +13 -6
- package/legacy/AdapterMoment/AdapterMoment.js +18 -9
- package/legacy/DateCalendar/DateCalendar.js +47 -24
- package/legacy/DateCalendar/DayCalendar.js +24 -17
- package/legacy/DateCalendar/PickersCalendarHeader.js +6 -3
- package/legacy/DateCalendar/useCalendarState.js +40 -17
- package/legacy/DateCalendar/useIsDateDisabled.js +5 -3
- package/legacy/DateField/DateField.js +9 -1
- package/legacy/DatePicker/DatePicker.js +9 -1
- package/legacy/DateTimeField/DateTimeField.js +9 -1
- package/legacy/DateTimePicker/DateTimePicker.js +9 -1
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +9 -1
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +8 -0
- package/legacy/DigitalClock/DigitalClock.js +26 -16
- package/legacy/MobileDatePicker/MobileDatePicker.js +9 -1
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
- package/legacy/MobileTimePicker/MobileTimePicker.js +8 -0
- package/legacy/MonthCalendar/MonthCalendar.js +61 -32
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +27 -16
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/legacy/PickersLayout/PickersLayout.js +1 -0
- package/legacy/PickersLayout/usePickerLayout.js +3 -2
- package/legacy/PickersShortcuts/PickersShortcuts.js +10 -2
- package/legacy/StaticDatePicker/StaticDatePicker.js +9 -1
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
- package/legacy/StaticTimePicker/StaticTimePicker.js +8 -0
- package/legacy/TimeClock/TimeClock.js +25 -18
- package/legacy/TimeField/TimeField.js +9 -1
- package/legacy/TimePicker/TimePicker.js +8 -0
- package/legacy/YearCalendar/YearCalendar.js +59 -30
- package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
- package/legacy/dateViewRenderers/dateViewRenderers.js +4 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/date-helpers-hooks.js +8 -6
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/legacy/internals/hooks/useField/useField.js +22 -6
- package/legacy/internals/hooks/useField/useField.utils.js +56 -44
- package/legacy/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
- package/legacy/internals/hooks/useField/useFieldState.js +42 -33
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/legacy/internals/hooks/usePicker/usePickerValue.js +46 -9
- package/legacy/internals/hooks/usePicker/usePickerViews.js +7 -2
- package/legacy/internals/hooks/useUtils.js +5 -2
- package/legacy/internals/hooks/useValueWithTimezone.js +81 -0
- package/legacy/internals/index.js +1 -0
- package/legacy/internals/utils/date-utils.js +5 -13
- package/legacy/internals/utils/fields.js +1 -1
- package/legacy/internals/utils/getDefaultReferenceDate.js +4 -4
- package/legacy/internals/utils/validation/validateDate.js +12 -6
- package/legacy/internals/utils/validation/validateTime.js +8 -8
- package/legacy/internals/utils/valueManagers.js +3 -0
- package/legacy/locales/csCZ.js +2 -2
- package/legacy/locales/elGR.js +93 -0
- package/legacy/locales/index.js +1 -0
- package/legacy/tests/describeAdapters/describeAdapters.js +3 -1
- package/legacy/tests/describeGregorianAdapter/testCalculations.js +69 -27
- package/legacy/tests/describeJalaliAdapter/testCalculations.js +21 -0
- package/legacy/timeViewRenderers/timeViewRenderers.js +12 -6
- package/locales/csCZ.js +2 -2
- package/locales/elGR.d.ts +53 -0
- package/locales/elGR.js +57 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/models/adapters.d.ts +2 -2
- package/models/timezone.d.ts +10 -0
- package/modern/AdapterDayjs/AdapterDayjs.js +41 -15
- package/modern/AdapterLuxon/AdapterLuxon.js +12 -4
- package/modern/AdapterMoment/AdapterMoment.js +18 -9
- package/modern/DateCalendar/DateCalendar.js +49 -21
- package/modern/DateCalendar/DayCalendar.js +24 -17
- package/modern/DateCalendar/PickersCalendarHeader.js +6 -3
- package/modern/DateCalendar/useCalendarState.js +41 -16
- package/modern/DateCalendar/useIsDateDisabled.js +5 -3
- package/modern/DateField/DateField.js +9 -1
- package/modern/DatePicker/DatePicker.js +9 -1
- package/modern/DateTimeField/DateTimeField.js +9 -1
- package/modern/DateTimePicker/DateTimePicker.js +9 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +9 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
- package/modern/DesktopTimePicker/DesktopTimePicker.js +8 -0
- package/modern/DigitalClock/DigitalClock.js +28 -15
- package/modern/MobileDatePicker/MobileDatePicker.js +9 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
- package/modern/MobileTimePicker/MobileTimePicker.js +8 -0
- package/modern/MonthCalendar/MonthCalendar.js +57 -24
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +28 -15
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/modern/PickersLayout/PickersLayout.js +1 -0
- package/modern/PickersLayout/usePickerLayout.js +4 -3
- package/modern/PickersShortcuts/PickersShortcuts.js +10 -2
- package/modern/StaticDatePicker/StaticDatePicker.js +9 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
- package/modern/StaticTimePicker/StaticTimePicker.js +8 -0
- package/modern/TimeClock/TimeClock.js +27 -15
- package/modern/TimeField/TimeField.js +9 -1
- package/modern/TimePicker/TimePicker.js +8 -0
- package/modern/YearCalendar/YearCalendar.js +55 -22
- package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
- package/modern/dateViewRenderers/dateViewRenderers.js +4 -2
- package/modern/index.js +1 -1
- package/modern/internals/hooks/date-helpers-hooks.js +8 -6
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/modern/internals/hooks/useField/useField.js +23 -7
- package/modern/internals/hooks/useField/useField.utils.js +55 -43
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
- package/modern/internals/hooks/useField/useFieldState.js +33 -22
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/modern/internals/hooks/usePicker/usePickerValue.js +45 -9
- package/modern/internals/hooks/usePicker/usePickerViews.js +7 -2
- package/modern/internals/hooks/useUtils.js +5 -2
- package/modern/internals/hooks/useValueWithTimezone.js +68 -0
- package/modern/internals/index.js +1 -0
- package/modern/internals/utils/date-utils.js +4 -12
- package/modern/internals/utils/fields.js +1 -1
- package/modern/internals/utils/getDefaultReferenceDate.js +4 -4
- package/modern/internals/utils/validation/validateDate.js +14 -6
- package/modern/internals/utils/validation/validateTime.js +8 -8
- package/modern/internals/utils/valueManagers.js +2 -1
- package/modern/locales/csCZ.js +2 -2
- package/modern/locales/elGR.js +57 -0
- package/modern/locales/index.js +1 -0
- package/modern/tests/describeAdapters/describeAdapters.js +3 -1
- package/modern/tests/describeGregorianAdapter/testCalculations.js +69 -27
- package/modern/tests/describeJalaliAdapter/testCalculations.js +21 -0
- package/modern/timeViewRenderers/timeViewRenderers.js +12 -6
- package/node/AdapterDayjs/AdapterDayjs.js +41 -15
- package/node/AdapterLuxon/AdapterLuxon.js +12 -4
- package/node/AdapterMoment/AdapterMoment.js +18 -9
- package/node/DateCalendar/DateCalendar.js +48 -20
- package/node/DateCalendar/DayCalendar.js +24 -17
- package/node/DateCalendar/PickersCalendarHeader.js +6 -3
- package/node/DateCalendar/useCalendarState.js +41 -16
- package/node/DateCalendar/useIsDateDisabled.js +5 -3
- package/node/DateField/DateField.js +9 -1
- package/node/DatePicker/DatePicker.js +9 -1
- package/node/DateTimeField/DateTimeField.js +9 -1
- package/node/DateTimePicker/DateTimePicker.js +9 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +9 -1
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
- package/node/DesktopTimePicker/DesktopTimePicker.js +8 -0
- package/node/DigitalClock/DigitalClock.js +28 -15
- package/node/MobileDatePicker/MobileDatePicker.js +9 -1
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
- package/node/MobileTimePicker/MobileTimePicker.js +8 -0
- package/node/MonthCalendar/MonthCalendar.js +57 -24
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +28 -15
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/node/PickersLayout/PickersLayout.js +1 -0
- package/node/PickersLayout/usePickerLayout.js +4 -3
- package/node/PickersShortcuts/PickersShortcuts.js +10 -2
- package/node/StaticDatePicker/StaticDatePicker.js +9 -1
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
- package/node/StaticTimePicker/StaticTimePicker.js +8 -0
- package/node/TimeClock/TimeClock.js +26 -14
- package/node/TimeField/TimeField.js +9 -1
- package/node/TimePicker/TimePicker.js +8 -0
- package/node/YearCalendar/YearCalendar.js +55 -22
- package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
- package/node/dateViewRenderers/dateViewRenderers.js +4 -2
- package/node/index.js +1 -1
- package/node/internals/hooks/date-helpers-hooks.js +8 -6
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/node/internals/hooks/useField/useField.js +23 -7
- package/node/internals/hooks/useField/useField.utils.js +55 -43
- package/node/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
- package/node/internals/hooks/useField/useFieldState.js +33 -22
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/node/internals/hooks/usePicker/usePickerValue.js +44 -9
- package/node/internals/hooks/usePicker/usePickerViews.js +7 -2
- package/node/internals/hooks/useUtils.js +5 -2
- package/node/internals/hooks/useValueWithTimezone.js +79 -0
- package/node/internals/index.js +7 -0
- package/node/internals/utils/date-utils.js +5 -14
- package/node/internals/utils/fields.js +1 -1
- package/node/internals/utils/getDefaultReferenceDate.js +5 -4
- package/node/internals/utils/validation/validateDate.js +14 -6
- package/node/internals/utils/validation/validateTime.js +8 -8
- package/node/internals/utils/valueManagers.js +2 -1
- package/node/locales/csCZ.js +2 -2
- package/node/locales/elGR.js +64 -0
- package/node/locales/index.js +11 -0
- package/node/tests/describeAdapters/describeAdapters.js +3 -1
- package/node/tests/describeGregorianAdapter/testCalculations.js +69 -27
- package/node/tests/describeJalaliAdapter/testCalculations.js +21 -0
- package/node/timeViewRenderers/timeViewRenderers.js +12 -6
- package/package.json +2 -2
- package/tests/describeAdapters/describeAdapters.js +3 -1
- package/tests/describeGregorianAdapter/testCalculations.js +69 -27
- package/tests/describeJalaliAdapter/testCalculations.js +21 -0
- package/timeViewRenderers/timeViewRenderers.d.ts +3 -3
- package/timeViewRenderers/timeViewRenderers.js +12 -6
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import { AvailableAdjustKeyCode, FieldSectionsValueBoundaries, SectionOrdering, FieldSectionWithoutPosition, FieldSectionValueBoundaries } from './useField.types';
|
|
2
|
-
import { FieldSectionType, FieldValueType, FieldSection, MuiPickersAdapter, FieldSectionContentType } from '../../../models';
|
|
2
|
+
import { FieldSectionType, FieldValueType, FieldSection, MuiPickersAdapter, FieldSectionContentType, PickersTimezone } from '../../../models';
|
|
3
3
|
import { PickersLocaleText } from '../../../locales/utils/pickersLocaleTextApi';
|
|
4
4
|
export declare const getDateSectionConfigFromFormatToken: <TDate>(utils: MuiPickersAdapter<TDate, any>, formatToken: string) => Pick<FieldSection, 'type' | 'contentType'> & {
|
|
5
5
|
maxLength: number | undefined;
|
|
6
6
|
};
|
|
7
|
-
export declare const getDaysInWeekStr: <TDate>(utils: MuiPickersAdapter<TDate, any>, format: string) => string[];
|
|
8
|
-
export declare const getLetterEditingOptions: <TDate>(utils: MuiPickersAdapter<TDate, any>, sectionType: FieldSectionType, format: string) => string[];
|
|
7
|
+
export declare const getDaysInWeekStr: <TDate>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone, format: string) => string[];
|
|
8
|
+
export declare const getLetterEditingOptions: <TDate>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone, sectionType: FieldSectionType, format: string) => string[];
|
|
9
9
|
export declare const cleanLeadingZeros: <TDate>(utils: MuiPickersAdapter<TDate, any>, valueStr: string, size: number) => string;
|
|
10
|
-
export declare const cleanDigitSectionValue: <TDate>(utils: MuiPickersAdapter<TDate, any>, value: number, sectionBoundaries: FieldSectionValueBoundaries<TDate, any>, section: Pick<FieldSection, 'format' | 'type' | 'contentType' | 'hasLeadingZerosInFormat' | 'hasLeadingZerosInInput' | 'maxLength'>) => string;
|
|
11
|
-
export declare const adjustSectionValue: <TDate, TSection extends FieldSection>(utils: MuiPickersAdapter<TDate, any>, section: TSection, keyCode: AvailableAdjustKeyCode, sectionsValueBoundaries: FieldSectionsValueBoundaries<TDate>, activeDate: TDate | null
|
|
10
|
+
export declare const cleanDigitSectionValue: <TDate>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone, value: number, sectionBoundaries: FieldSectionValueBoundaries<TDate, any>, section: Pick<FieldSection, 'format' | 'type' | 'contentType' | 'hasLeadingZerosInFormat' | 'hasLeadingZerosInInput' | 'maxLength'>) => string;
|
|
11
|
+
export declare const adjustSectionValue: <TDate, TSection extends FieldSection>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone, section: TSection, keyCode: AvailableAdjustKeyCode, sectionsValueBoundaries: FieldSectionsValueBoundaries<TDate>, activeDate: TDate | null, stepsAttribues?: {
|
|
12
|
+
minutesStep?: number;
|
|
13
|
+
}) => string;
|
|
12
14
|
export declare const getSectionVisibleValue: (section: FieldSectionWithoutPosition, target: 'input-rtl' | 'input-ltr' | 'non-input') => string;
|
|
13
15
|
export declare const cleanString: (dirtyString: string) => string;
|
|
14
16
|
export declare const addPositionPropertiesToSections: <TSection extends FieldSection>(sections: FieldSectionWithoutPosition<TSection>[], isRTL: boolean) => TSection[];
|
|
15
17
|
export declare const changeSectionValueFormat: <TDate>(utils: MuiPickersAdapter<TDate, any>, valueStr: string, currentFormat: string, newFormat: string) => string;
|
|
16
|
-
export declare const doesSectionFormatHaveLeadingZeros: <TDate>(utils: MuiPickersAdapter<TDate, any>, contentType: FieldSectionContentType, sectionType: FieldSectionType, format: string) => boolean;
|
|
17
|
-
export declare const splitFormatIntoSections: <TDate>(utils: MuiPickersAdapter<TDate, any>, localeText: PickersLocaleText<TDate>, format: string, date: TDate | null, formatDensity: 'dense' | 'spacious', shouldRespectLeadingZeros: boolean, isRTL: boolean) => FieldSectionWithoutPosition[];
|
|
18
|
+
export declare const doesSectionFormatHaveLeadingZeros: <TDate>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone, contentType: FieldSectionContentType, sectionType: FieldSectionType, format: string) => boolean;
|
|
19
|
+
export declare const splitFormatIntoSections: <TDate>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone, localeText: PickersLocaleText<TDate>, format: string, date: TDate | null, formatDensity: 'dense' | 'spacious', shouldRespectLeadingZeros: boolean, isRTL: boolean) => FieldSectionWithoutPosition[];
|
|
18
20
|
/**
|
|
19
21
|
* Some date libraries like `dayjs` don't support parsing from date with escaped characters.
|
|
20
22
|
* To make sure that the parsing works, we are building a format and a date without any separator.
|
|
21
23
|
*/
|
|
22
|
-
export declare const getDateFromDateSections: <TDate>(utils: MuiPickersAdapter<TDate, any>, sections: FieldSection[]) => TDate
|
|
24
|
+
export declare const getDateFromDateSections: <TDate>(utils: MuiPickersAdapter<TDate, any>, sections: FieldSection[]) => NonNullable<TDate>;
|
|
23
25
|
export declare const createDateStrForInputFromSections: (sections: FieldSection[], isRTL: boolean) => string;
|
|
24
|
-
export declare const getSectionsBoundaries: <TDate>(utils: MuiPickersAdapter<TDate, any
|
|
26
|
+
export declare const getSectionsBoundaries: <TDate>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone) => FieldSectionsValueBoundaries<TDate>;
|
|
25
27
|
export declare const validateSections: <TSection extends FieldSection>(sections: TSection[], valueType: FieldValueType) => void;
|
|
26
|
-
export declare const mergeDateIntoReferenceDate: <TDate>(utils: MuiPickersAdapter<TDate, any>, dateToTransferFrom: TDate, sections: FieldSectionWithoutPosition[], referenceDate: TDate, shouldLimitToEditedSections: boolean) => TDate;
|
|
28
|
+
export declare const mergeDateIntoReferenceDate: <TDate>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone, dateToTransferFrom: TDate, sections: FieldSectionWithoutPosition[], referenceDate: TDate, shouldLimitToEditedSections: boolean) => TDate;
|
|
27
29
|
export declare const isAndroid: () => boolean;
|
|
28
|
-
export declare const clampDaySectionIfPossible: <TDate, TSection extends FieldSection>(utils: MuiPickersAdapter<TDate, any>, sections: TSection[], sectionsValueBoundaries: FieldSectionsValueBoundaries<TDate>) => TSection[] | null;
|
|
30
|
+
export declare const clampDaySectionIfPossible: <TDate, TSection extends FieldSection>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone, sections: TSection[], sectionsValueBoundaries: FieldSectionsValueBoundaries<TDate>) => TSection[] | null;
|
|
29
31
|
export declare const getSectionOrder: (sections: FieldSectionWithoutPosition[], isRTL: boolean) => SectionOrdering;
|
|
@@ -32,9 +32,9 @@ const getDeltaFromKeyCode = keyCode => {
|
|
|
32
32
|
return 0;
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
export const getDaysInWeekStr = (utils, format) => {
|
|
35
|
+
export const getDaysInWeekStr = (utils, timezone, format) => {
|
|
36
36
|
const elements = [];
|
|
37
|
-
const now = utils.
|
|
37
|
+
const now = utils.dateWithTimezone(undefined, timezone);
|
|
38
38
|
const startDate = utils.startOfWeek(now);
|
|
39
39
|
const endDate = utils.endOfWeek(now);
|
|
40
40
|
let current = startDate;
|
|
@@ -44,19 +44,19 @@ export const getDaysInWeekStr = (utils, format) => {
|
|
|
44
44
|
}
|
|
45
45
|
return elements.map(weekDay => utils.formatByString(weekDay, format));
|
|
46
46
|
};
|
|
47
|
-
export const getLetterEditingOptions = (utils, sectionType, format) => {
|
|
47
|
+
export const getLetterEditingOptions = (utils, timezone, sectionType, format) => {
|
|
48
48
|
switch (sectionType) {
|
|
49
49
|
case 'month':
|
|
50
50
|
{
|
|
51
|
-
return getMonthsInYear(utils, utils.
|
|
51
|
+
return getMonthsInYear(utils, utils.dateWithTimezone(undefined, timezone)).map(month => utils.formatByString(month, format));
|
|
52
52
|
}
|
|
53
53
|
case 'weekDay':
|
|
54
54
|
{
|
|
55
|
-
return getDaysInWeekStr(utils, format);
|
|
55
|
+
return getDaysInWeekStr(utils, timezone, format);
|
|
56
56
|
}
|
|
57
57
|
case 'meridiem':
|
|
58
58
|
{
|
|
59
|
-
const now = utils.
|
|
59
|
+
const now = utils.dateWithTimezone(undefined, timezone);
|
|
60
60
|
return [utils.startOfDay(now), utils.endOfDay(now)].map(date => utils.formatByString(date, format));
|
|
61
61
|
}
|
|
62
62
|
default:
|
|
@@ -77,7 +77,7 @@ export const cleanLeadingZeros = (utils, valueStr, size) => {
|
|
|
77
77
|
}
|
|
78
78
|
return cleanValueStr;
|
|
79
79
|
};
|
|
80
|
-
export const cleanDigitSectionValue = (utils, value, sectionBoundaries, section) => {
|
|
80
|
+
export const cleanDigitSectionValue = (utils, timezone, value, sectionBoundaries, section) => {
|
|
81
81
|
if (process.env.NODE_ENV !== 'production') {
|
|
82
82
|
if (section.type !== 'day' && section.contentType === 'digit-with-letter') {
|
|
83
83
|
throw new Error([`MUI: The token "${section.format}" is a digit format with letter in it.'
|
|
@@ -96,7 +96,7 @@ export const cleanDigitSectionValue = (utils, value, sectionBoundaries, section)
|
|
|
96
96
|
}
|
|
97
97
|
return valueStr;
|
|
98
98
|
};
|
|
99
|
-
export const adjustSectionValue = (utils, section, keyCode, sectionsValueBoundaries, activeDate) => {
|
|
99
|
+
export const adjustSectionValue = (utils, timezone, section, keyCode, sectionsValueBoundaries, activeDate, stepsAttribues) => {
|
|
100
100
|
const delta = getDeltaFromKeyCode(keyCode);
|
|
101
101
|
const isStart = keyCode === 'Home';
|
|
102
102
|
const isEnd = keyCode === 'End';
|
|
@@ -107,28 +107,39 @@ export const adjustSectionValue = (utils, section, keyCode, sectionsValueBoundar
|
|
|
107
107
|
format: section.format,
|
|
108
108
|
contentType: section.contentType
|
|
109
109
|
});
|
|
110
|
-
const getCleanValue = value => cleanDigitSectionValue(utils, value, sectionBoundaries, section);
|
|
110
|
+
const getCleanValue = value => cleanDigitSectionValue(utils, timezone, value, sectionBoundaries, section);
|
|
111
|
+
const step = section.type === 'minutes' && stepsAttribues != null && stepsAttribues.minutesStep ? stepsAttribues.minutesStep : 1;
|
|
112
|
+
const currentSectionValue = parseInt(section.value, 10);
|
|
113
|
+
let newSectionValueNumber = currentSectionValue + delta * step;
|
|
111
114
|
if (shouldSetAbsolute) {
|
|
112
115
|
if (section.type === 'year' && !isEnd && !isStart) {
|
|
113
|
-
return utils.formatByString(utils.
|
|
116
|
+
return utils.formatByString(utils.dateWithTimezone(undefined, timezone), section.format);
|
|
114
117
|
}
|
|
115
118
|
if (delta > 0 || isStart) {
|
|
116
|
-
|
|
119
|
+
newSectionValueNumber = sectionBoundaries.minimum;
|
|
120
|
+
} else {
|
|
121
|
+
newSectionValueNumber = sectionBoundaries.maximum;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (newSectionValueNumber % step !== 0) {
|
|
125
|
+
if (delta < 0 || isStart) {
|
|
126
|
+
newSectionValueNumber += step - (step + newSectionValueNumber) % step; // for JS -3 % 5 = -3 (should be 2)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (delta > 0 || isEnd) {
|
|
130
|
+
newSectionValueNumber -= newSectionValueNumber % step;
|
|
117
131
|
}
|
|
118
|
-
return getCleanValue(sectionBoundaries.maximum);
|
|
119
132
|
}
|
|
120
|
-
const currentSectionValue = parseInt(section.value, 10);
|
|
121
|
-
const newSectionValueNumber = currentSectionValue + delta;
|
|
122
133
|
if (newSectionValueNumber > sectionBoundaries.maximum) {
|
|
123
|
-
return getCleanValue(sectionBoundaries.minimum);
|
|
134
|
+
return getCleanValue(sectionBoundaries.minimum + (newSectionValueNumber - sectionBoundaries.maximum - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));
|
|
124
135
|
}
|
|
125
136
|
if (newSectionValueNumber < sectionBoundaries.minimum) {
|
|
126
|
-
return getCleanValue(sectionBoundaries.maximum);
|
|
137
|
+
return getCleanValue(sectionBoundaries.maximum - (sectionBoundaries.minimum - newSectionValueNumber - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));
|
|
127
138
|
}
|
|
128
139
|
return getCleanValue(newSectionValueNumber);
|
|
129
140
|
};
|
|
130
141
|
const adjustLetterSection = () => {
|
|
131
|
-
const options = getLetterEditingOptions(utils, section.type, section.format);
|
|
142
|
+
const options = getLetterEditingOptions(utils, timezone, section.type, section.format);
|
|
132
143
|
if (options.length === 0) {
|
|
133
144
|
return section.value;
|
|
134
145
|
}
|
|
@@ -196,12 +207,12 @@ export const addPositionPropertiesToSections = (sections, isRTL) => {
|
|
|
196
207
|
}
|
|
197
208
|
return newSections;
|
|
198
209
|
};
|
|
199
|
-
const getSectionPlaceholder = (utils, localeText, sectionConfig, currentTokenValue) => {
|
|
210
|
+
const getSectionPlaceholder = (utils, timezone, localeText, sectionConfig, currentTokenValue) => {
|
|
200
211
|
switch (sectionConfig.type) {
|
|
201
212
|
case 'year':
|
|
202
213
|
{
|
|
203
214
|
return localeText.fieldYearPlaceholder({
|
|
204
|
-
digitAmount: utils.formatByString(utils.
|
|
215
|
+
digitAmount: utils.formatByString(utils.dateWithTimezone(undefined, timezone), currentTokenValue).length
|
|
205
216
|
});
|
|
206
217
|
}
|
|
207
218
|
case 'month':
|
|
@@ -250,45 +261,46 @@ export const changeSectionValueFormat = (utils, valueStr, currentFormat, newForm
|
|
|
250
261
|
}
|
|
251
262
|
return utils.formatByString(utils.parse(valueStr, currentFormat), newFormat);
|
|
252
263
|
};
|
|
253
|
-
const isFourDigitYearFormat = (utils, format) => utils.formatByString(utils.
|
|
254
|
-
export const doesSectionFormatHaveLeadingZeros = (utils, contentType, sectionType, format) => {
|
|
264
|
+
const isFourDigitYearFormat = (utils, timezone, format) => utils.formatByString(utils.dateWithTimezone(undefined, timezone), format).length === 4;
|
|
265
|
+
export const doesSectionFormatHaveLeadingZeros = (utils, timezone, contentType, sectionType, format) => {
|
|
255
266
|
if (contentType !== 'digit') {
|
|
256
267
|
return false;
|
|
257
268
|
}
|
|
269
|
+
const now = utils.dateWithTimezone(undefined, timezone);
|
|
258
270
|
switch (sectionType) {
|
|
259
271
|
// We can't use `changeSectionValueFormat`, because `utils.parse('1', 'YYYY')` returns `1971` instead of `1`.
|
|
260
272
|
case 'year':
|
|
261
273
|
{
|
|
262
|
-
if (isFourDigitYearFormat(utils, format)) {
|
|
263
|
-
const formatted0001 = utils.formatByString(utils.setYear(
|
|
274
|
+
if (isFourDigitYearFormat(utils, timezone, format)) {
|
|
275
|
+
const formatted0001 = utils.formatByString(utils.setYear(now, 1), format);
|
|
264
276
|
return formatted0001 === '0001';
|
|
265
277
|
}
|
|
266
|
-
const formatted2001 = utils.formatByString(utils.setYear(
|
|
278
|
+
const formatted2001 = utils.formatByString(utils.setYear(now, 2001), format);
|
|
267
279
|
return formatted2001 === '01';
|
|
268
280
|
}
|
|
269
281
|
case 'month':
|
|
270
282
|
{
|
|
271
|
-
return utils.formatByString(utils.startOfYear(
|
|
283
|
+
return utils.formatByString(utils.startOfYear(now), format).length > 1;
|
|
272
284
|
}
|
|
273
285
|
case 'day':
|
|
274
286
|
{
|
|
275
|
-
return utils.formatByString(utils.startOfMonth(
|
|
287
|
+
return utils.formatByString(utils.startOfMonth(now), format).length > 1;
|
|
276
288
|
}
|
|
277
289
|
case 'weekDay':
|
|
278
290
|
{
|
|
279
|
-
return utils.formatByString(utils.startOfWeek(
|
|
291
|
+
return utils.formatByString(utils.startOfWeek(now), format).length > 1;
|
|
280
292
|
}
|
|
281
293
|
case 'hours':
|
|
282
294
|
{
|
|
283
|
-
return utils.formatByString(utils.setHours(
|
|
295
|
+
return utils.formatByString(utils.setHours(now, 1), format).length > 1;
|
|
284
296
|
}
|
|
285
297
|
case 'minutes':
|
|
286
298
|
{
|
|
287
|
-
return utils.formatByString(utils.setMinutes(
|
|
299
|
+
return utils.formatByString(utils.setMinutes(now, 1), format).length > 1;
|
|
288
300
|
}
|
|
289
301
|
case 'seconds':
|
|
290
302
|
{
|
|
291
|
-
return utils.formatByString(utils.setMinutes(
|
|
303
|
+
return utils.formatByString(utils.setMinutes(now, 1), format).length > 1;
|
|
292
304
|
}
|
|
293
305
|
default:
|
|
294
306
|
{
|
|
@@ -313,7 +325,7 @@ const getEscapedPartsFromFormat = (utils, format) => {
|
|
|
313
325
|
}
|
|
314
326
|
return escapedParts;
|
|
315
327
|
};
|
|
316
|
-
export const splitFormatIntoSections = (utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros, isRTL) => {
|
|
328
|
+
export const splitFormatIntoSections = (utils, timezone, localeText, format, date, formatDensity, shouldRespectLeadingZeros, isRTL) => {
|
|
317
329
|
let startSeparator = '';
|
|
318
330
|
const sections = [];
|
|
319
331
|
const now = utils.date();
|
|
@@ -322,7 +334,7 @@ export const splitFormatIntoSections = (utils, localeText, format, date, formatD
|
|
|
322
334
|
return null;
|
|
323
335
|
}
|
|
324
336
|
const sectionConfig = getDateSectionConfigFromFormatToken(utils, token);
|
|
325
|
-
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, sectionConfig.contentType, sectionConfig.type, token);
|
|
337
|
+
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, timezone, sectionConfig.contentType, sectionConfig.type, token);
|
|
326
338
|
const hasLeadingZerosInInput = shouldRespectLeadingZeros ? hasLeadingZerosInFormat : sectionConfig.contentType === 'digit';
|
|
327
339
|
const isValidDate = date != null && utils.isValid(date);
|
|
328
340
|
let sectionValue = isValidDate ? utils.formatByString(date, token) : '';
|
|
@@ -344,7 +356,7 @@ export const splitFormatIntoSections = (utils, localeText, format, date, formatD
|
|
|
344
356
|
format: token,
|
|
345
357
|
maxLength,
|
|
346
358
|
value: sectionValue,
|
|
347
|
-
placeholder: getSectionPlaceholder(utils, localeText, sectionConfig, token),
|
|
359
|
+
placeholder: getSectionPlaceholder(utils, timezone, localeText, sectionConfig, token),
|
|
348
360
|
hasLeadingZeros: hasLeadingZerosInFormat,
|
|
349
361
|
hasLeadingZerosInFormat,
|
|
350
362
|
hasLeadingZerosInInput,
|
|
@@ -455,8 +467,8 @@ export const createDateStrForInputFromSections = (sections, isRTL) => {
|
|
|
455
467
|
// wrap into an isolated group such that separators can split the string in smaller ones by adding \u2069\u2068
|
|
456
468
|
return `\u2066${dateStr}\u2069`;
|
|
457
469
|
};
|
|
458
|
-
export const getSectionsBoundaries = utils => {
|
|
459
|
-
const today = utils.
|
|
470
|
+
export const getSectionsBoundaries = (utils, timezone) => {
|
|
471
|
+
const today = utils.dateWithTimezone(undefined, timezone);
|
|
460
472
|
const endOfYear = utils.endOfYear(today);
|
|
461
473
|
const {
|
|
462
474
|
maxDaysInMonth,
|
|
@@ -479,7 +491,7 @@ export const getSectionsBoundaries = utils => {
|
|
|
479
491
|
format
|
|
480
492
|
}) => ({
|
|
481
493
|
minimum: 0,
|
|
482
|
-
maximum: isFourDigitYearFormat(utils, format) ? 9999 : 99
|
|
494
|
+
maximum: isFourDigitYearFormat(utils, timezone, format) ? 9999 : 99
|
|
483
495
|
}),
|
|
484
496
|
month: () => ({
|
|
485
497
|
minimum: 1,
|
|
@@ -498,7 +510,7 @@ export const getSectionsBoundaries = utils => {
|
|
|
498
510
|
contentType
|
|
499
511
|
}) => {
|
|
500
512
|
if (contentType === 'digit') {
|
|
501
|
-
const daysInWeek = getDaysInWeekStr(utils, format).map(Number);
|
|
513
|
+
const daysInWeek = getDaysInWeekStr(utils, timezone, format).map(Number);
|
|
502
514
|
return {
|
|
503
515
|
minimum: Math.min(...daysInWeek),
|
|
504
516
|
maximum: Math.max(...daysInWeek)
|
|
@@ -560,7 +572,7 @@ export const validateSections = (sections, valueType) => {
|
|
|
560
572
|
}
|
|
561
573
|
}
|
|
562
574
|
};
|
|
563
|
-
const transferDateSectionValue = (utils, section, dateToTransferFrom, dateToTransferTo) => {
|
|
575
|
+
const transferDateSectionValue = (utils, timezone, section, dateToTransferFrom, dateToTransferTo) => {
|
|
564
576
|
switch (section.type) {
|
|
565
577
|
case 'year':
|
|
566
578
|
{
|
|
@@ -572,7 +584,7 @@ const transferDateSectionValue = (utils, section, dateToTransferFrom, dateToTran
|
|
|
572
584
|
}
|
|
573
585
|
case 'weekDay':
|
|
574
586
|
{
|
|
575
|
-
const formattedDaysInWeek = getDaysInWeekStr(utils, section.format);
|
|
587
|
+
const formattedDaysInWeek = getDaysInWeekStr(utils, timezone, section.format);
|
|
576
588
|
const dayInWeekStrOfActiveDate = utils.formatByString(dateToTransferFrom, section.format);
|
|
577
589
|
const dayInWeekOfActiveDate = formattedDaysInWeek.indexOf(dayInWeekStrOfActiveDate);
|
|
578
590
|
const dayInWeekOfNewSectionValue = formattedDaysInWeek.indexOf(section.value);
|
|
@@ -623,16 +635,16 @@ const reliableSectionModificationOrder = {
|
|
|
623
635
|
seconds: 7,
|
|
624
636
|
meridiem: 8
|
|
625
637
|
};
|
|
626
|
-
export const mergeDateIntoReferenceDate = (utils, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) =>
|
|
638
|
+
export const mergeDateIntoReferenceDate = (utils, timezone, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) =>
|
|
627
639
|
// cloning sections before sort to avoid mutating it
|
|
628
640
|
[...sections].sort((a, b) => reliableSectionModificationOrder[a.type] - reliableSectionModificationOrder[b.type]).reduce((mergedDate, section) => {
|
|
629
641
|
if (!shouldLimitToEditedSections || section.modified) {
|
|
630
|
-
return transferDateSectionValue(utils, section, dateToTransferFrom, mergedDate);
|
|
642
|
+
return transferDateSectionValue(utils, timezone, section, dateToTransferFrom, mergedDate);
|
|
631
643
|
}
|
|
632
644
|
return mergedDate;
|
|
633
645
|
}, referenceDate);
|
|
634
646
|
export const isAndroid = () => navigator.userAgent.toLowerCase().indexOf('android') > -1;
|
|
635
|
-
export const clampDaySectionIfPossible = (utils, sections, sectionsValueBoundaries) => {
|
|
647
|
+
export const clampDaySectionIfPossible = (utils, timezone, sections, sectionsValueBoundaries) => {
|
|
636
648
|
// We can only clamp the day value if:
|
|
637
649
|
// 1. if all the sections are filled (except the week day section which can be empty)
|
|
638
650
|
// 2. there is a day section
|
|
@@ -652,7 +664,7 @@ export const clampDaySectionIfPossible = (utils, sections, sectionsValueBoundari
|
|
|
652
664
|
contentType: section.contentType
|
|
653
665
|
});
|
|
654
666
|
return _extends({}, section, {
|
|
655
|
-
value: cleanDigitSectionValue(utils, dayBoundaries.minimum, dayBoundaries, section)
|
|
667
|
+
value: cleanDigitSectionValue(utils, timezone, dayBoundaries.minimum, dayBoundaries, section)
|
|
656
668
|
});
|
|
657
669
|
});
|
|
658
670
|
const startOfMonth = getDateFromDateSections(utils, sectionsForStartOfMonth);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldSection } from '../../../models';
|
|
1
|
+
import { FieldSection, PickersTimezone } from '../../../models';
|
|
2
2
|
import { FieldSectionsValueBoundaries } from './useField.types';
|
|
3
3
|
import { UpdateSectionValueParams } from './useFieldState';
|
|
4
4
|
interface ApplyCharacterEditingParams {
|
|
@@ -10,6 +10,7 @@ interface UseFieldEditingParams<TDate, TSection extends FieldSection> {
|
|
|
10
10
|
updateSectionValue: (params: UpdateSectionValueParams<TSection>) => void;
|
|
11
11
|
sectionsValueBoundaries: FieldSectionsValueBoundaries<TDate>;
|
|
12
12
|
setTempAndroidValueStr: (newValue: string | null) => void;
|
|
13
|
+
timezone: PickersTimezone;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Update the active section value when the user pressed a key that is not a navigation key (arrow key for example).
|
|
@@ -18,7 +19,7 @@ interface UseFieldEditingParams<TDate, TSection extends FieldSection> {
|
|
|
18
19
|
* 1. The numeric editing when the user presses a digit
|
|
19
20
|
* 2. The letter editing when the user presses another key
|
|
20
21
|
*/
|
|
21
|
-
export declare const useFieldCharacterEditing: <TDate, TSection extends FieldSection>({ sections, updateSectionValue, sectionsValueBoundaries, setTempAndroidValueStr, }: UseFieldEditingParams<TDate, TSection>) => {
|
|
22
|
+
export declare const useFieldCharacterEditing: <TDate, TSection extends FieldSection>({ sections, updateSectionValue, sectionsValueBoundaries, setTempAndroidValueStr, timezone, }: UseFieldEditingParams<TDate, TSection>) => {
|
|
22
23
|
applyCharacterEditing: (params: ApplyCharacterEditingParams) => void;
|
|
23
24
|
resetCharacterQuery: () => void;
|
|
24
25
|
};
|
|
@@ -40,7 +40,8 @@ export const useFieldCharacterEditing = ({
|
|
|
40
40
|
sections,
|
|
41
41
|
updateSectionValue,
|
|
42
42
|
sectionsValueBoundaries,
|
|
43
|
-
setTempAndroidValueStr
|
|
43
|
+
setTempAndroidValueStr,
|
|
44
|
+
timezone
|
|
44
45
|
}) => {
|
|
45
46
|
const utils = useUtils();
|
|
46
47
|
const [query, setQuery] = React.useState(null);
|
|
@@ -110,7 +111,7 @@ export const useFieldCharacterEditing = ({
|
|
|
110
111
|
};
|
|
111
112
|
};
|
|
112
113
|
const testQueryOnFormatAndFallbackFormat = (queryValue, activeSection, fallbackFormat, formatFallbackValue) => {
|
|
113
|
-
const getOptions = format => getLetterEditingOptions(utils, activeSection.type, format);
|
|
114
|
+
const getOptions = format => getLetterEditingOptions(utils, timezone, activeSection.type, format);
|
|
114
115
|
if (activeSection.contentType === 'letter') {
|
|
115
116
|
return findMatchingOptions(activeSection.format, getOptions(activeSection.format), queryValue);
|
|
116
117
|
}
|
|
@@ -183,7 +184,7 @@ export const useFieldCharacterEditing = ({
|
|
|
183
184
|
};
|
|
184
185
|
}
|
|
185
186
|
const shouldGoToNextSection = Number(`${queryValue}0`) > sectionBoundaries.maximum || queryValue.length === sectionBoundaries.maximum.toString().length;
|
|
186
|
-
const newSectionValue = cleanDigitSectionValue(utils, queryValueNumber, sectionBoundaries, section);
|
|
187
|
+
const newSectionValue = cleanDigitSectionValue(utils, timezone, queryValueNumber, sectionBoundaries, section);
|
|
187
188
|
return {
|
|
188
189
|
sectionValue: newSectionValue,
|
|
189
190
|
shouldGoToNextSection
|
|
@@ -197,7 +198,7 @@ export const useFieldCharacterEditing = ({
|
|
|
197
198
|
// When editing a letter-format month and the user presses a digit,
|
|
198
199
|
// We can support the numeric editing by using the digit-format month and re-formatting the result.
|
|
199
200
|
if (activeSection.type === 'month') {
|
|
200
|
-
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, 'digit', 'month', 'MM');
|
|
201
|
+
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, timezone, 'digit', 'month', 'MM');
|
|
201
202
|
const response = getNewSectionValue(queryValue, {
|
|
202
203
|
type: activeSection.type,
|
|
203
204
|
format: 'MM',
|
|
@@ -222,7 +223,7 @@ export const useFieldCharacterEditing = ({
|
|
|
222
223
|
if (isQueryResponseWithoutValue(response)) {
|
|
223
224
|
return response;
|
|
224
225
|
}
|
|
225
|
-
const formattedValue = getDaysInWeekStr(utils, activeSection.format)[Number(response.sectionValue) - 1];
|
|
226
|
+
const formattedValue = getDaysInWeekStr(utils, timezone, activeSection.format)[Number(response.sectionValue) - 1];
|
|
226
227
|
return _extends({}, response, {
|
|
227
228
|
sectionValue: formattedValue
|
|
228
229
|
});
|
|
@@ -25,4 +25,5 @@ export declare const useFieldState: <TValue, TDate, TSection extends FieldSectio
|
|
|
25
25
|
setTempAndroidValueStr: (tempValueStrAndroid: string | null) => void;
|
|
26
26
|
sectionsValueBoundaries: import("./useField.types").FieldSectionsValueBoundaries<TDate>;
|
|
27
27
|
placeholder: string;
|
|
28
|
+
timezone: string;
|
|
28
29
|
};
|
|
@@ -4,9 +4,9 @@ import useControlled from '@mui/utils/useControlled';
|
|
|
4
4
|
import { useTheme } from '@mui/material/styles';
|
|
5
5
|
import { useUtils, useLocaleText, useLocalizationContext } from '../useUtils';
|
|
6
6
|
import { addPositionPropertiesToSections, splitFormatIntoSections, clampDaySectionIfPossible, mergeDateIntoReferenceDate, getSectionsBoundaries, validateSections, getDateFromDateSections } from './useField.utils';
|
|
7
|
+
import { useValueWithTimezone } from '../useValueWithTimezone';
|
|
7
8
|
import { getSectionTypeGranularity } from '../../utils/getDefaultReferenceDate';
|
|
8
9
|
export const useFieldState = params => {
|
|
9
|
-
var _ref;
|
|
10
10
|
const utils = useUtils();
|
|
11
11
|
const localeText = useLocaleText();
|
|
12
12
|
const adapter = useLocalizationContext();
|
|
@@ -27,13 +27,23 @@ export const useFieldState = params => {
|
|
|
27
27
|
formatDensity = 'dense',
|
|
28
28
|
selectedSections: selectedSectionsProp,
|
|
29
29
|
onSelectedSectionsChange,
|
|
30
|
-
shouldRespectLeadingZeros = false
|
|
30
|
+
shouldRespectLeadingZeros = false,
|
|
31
|
+
timezone: timezoneProp
|
|
31
32
|
}
|
|
32
33
|
} = params;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const {
|
|
35
|
+
timezone,
|
|
36
|
+
value: valueFromTheOutside,
|
|
37
|
+
handleValueChange
|
|
38
|
+
} = useValueWithTimezone({
|
|
39
|
+
timezone: timezoneProp,
|
|
40
|
+
value: valueProp,
|
|
41
|
+
defaultValue,
|
|
42
|
+
onChange,
|
|
43
|
+
valueManager
|
|
44
|
+
});
|
|
45
|
+
const sectionsValueBoundaries = React.useMemo(() => getSectionsBoundaries(utils, timezone), [utils, timezone]);
|
|
46
|
+
const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, isRTL, date => splitFormatIntoSections(utils, timezone, localeText, format, date, formatDensity, shouldRespectLeadingZeros, isRTL)), [fieldValueManager, format, localeText, isRTL, shouldRespectLeadingZeros, utils, formatDensity, timezone]);
|
|
37
47
|
const placeholder = React.useMemo(() => fieldValueManager.getValueStrFromSections(getSectionsFromValue(valueManager.emptyValue), isRTL), [fieldValueManager, getSectionsFromValue, valueManager.emptyValue, isRTL]);
|
|
38
48
|
const [state, setState] = React.useState(() => {
|
|
39
49
|
const sections = getSectionsFromValue(valueFromTheOutside);
|
|
@@ -48,10 +58,10 @@ export const useFieldState = params => {
|
|
|
48
58
|
const referenceValue = valueManager.getInitialReferenceValue({
|
|
49
59
|
referenceDate: referenceDateProp,
|
|
50
60
|
value: valueFromTheOutside,
|
|
51
|
-
valueType,
|
|
52
61
|
utils,
|
|
53
62
|
props: internalProps,
|
|
54
|
-
granularity
|
|
63
|
+
granularity,
|
|
64
|
+
timezone
|
|
55
65
|
});
|
|
56
66
|
return _extends({}, stateWithoutReferenceDate, {
|
|
57
67
|
referenceValue
|
|
@@ -107,18 +117,17 @@ export const useFieldState = params => {
|
|
|
107
117
|
referenceValue,
|
|
108
118
|
tempValueStrAndroid: null
|
|
109
119
|
}));
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
const context = {
|
|
121
|
+
validationError: validator({
|
|
122
|
+
adapter,
|
|
123
|
+
value,
|
|
124
|
+
props: _extends({}, internalProps, {
|
|
114
125
|
value,
|
|
115
|
-
|
|
116
|
-
value
|
|
117
|
-
})
|
|
126
|
+
timezone
|
|
118
127
|
})
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
})
|
|
129
|
+
};
|
|
130
|
+
handleValueChange(value, context);
|
|
122
131
|
};
|
|
123
132
|
const setSectionValue = (sectionIndex, newSectionValue) => {
|
|
124
133
|
const newSections = [...state.sections];
|
|
@@ -169,8 +178,8 @@ export const useFieldState = params => {
|
|
|
169
178
|
if (date == null || !utils.isValid(date)) {
|
|
170
179
|
return null;
|
|
171
180
|
}
|
|
172
|
-
const sections = splitFormatIntoSections(utils, localeText, format, date, formatDensity, shouldRespectLeadingZeros, isRTL);
|
|
173
|
-
return mergeDateIntoReferenceDate(utils, date, sections, referenceDate, false);
|
|
181
|
+
const sections = splitFormatIntoSections(utils, timezone, localeText, format, date, formatDensity, shouldRespectLeadingZeros, isRTL);
|
|
182
|
+
return mergeDateIntoReferenceDate(utils, timezone, date, sections, referenceDate, false);
|
|
174
183
|
};
|
|
175
184
|
const newValue = fieldValueManager.parseValueStr(valueStr, state.referenceValue, parseDateStr);
|
|
176
185
|
const newReferenceValue = fieldValueManager.updateReferenceValue(utils, newValue, state.referenceValue);
|
|
@@ -209,7 +218,7 @@ export const useFieldState = params => {
|
|
|
209
218
|
* This can be useful if the month has fewer days than the day value currently provided.
|
|
210
219
|
*/
|
|
211
220
|
if (!utils.isValid(newActiveDate)) {
|
|
212
|
-
const clampedSections = clampDaySectionIfPossible(utils, newActiveDateSections, sectionsValueBoundaries);
|
|
221
|
+
const clampedSections = clampDaySectionIfPossible(utils, timezone, newActiveDateSections, sectionsValueBoundaries);
|
|
213
222
|
if (clampedSections != null) {
|
|
214
223
|
shouldRegenSections = true;
|
|
215
224
|
newActiveDate = getDateFromDateSections(utils, clampedSections);
|
|
@@ -224,7 +233,7 @@ export const useFieldState = params => {
|
|
|
224
233
|
* This makes sure that we don't lose some information of the initial date (like the time on a date field).
|
|
225
234
|
*/
|
|
226
235
|
if (newActiveDate != null && utils.isValid(newActiveDate)) {
|
|
227
|
-
const mergedDate = mergeDateIntoReferenceDate(utils, newActiveDate, newActiveDateSections, activeDateManager.referenceDate, true);
|
|
236
|
+
const mergedDate = mergeDateIntoReferenceDate(utils, timezone, newActiveDate, newActiveDateSections, activeDateManager.referenceDate, true);
|
|
228
237
|
values = activeDateManager.getNewValuesFromNewActiveDate(mergedDate);
|
|
229
238
|
shouldPublish = true;
|
|
230
239
|
} else {
|
|
@@ -288,6 +297,7 @@ export const useFieldState = params => {
|
|
|
288
297
|
updateValueFromValueStr,
|
|
289
298
|
setTempAndroidValueStr,
|
|
290
299
|
sectionsValueBoundaries,
|
|
291
|
-
placeholder
|
|
300
|
+
placeholder,
|
|
301
|
+
timezone
|
|
292
302
|
};
|
|
293
303
|
};
|
|
@@ -33,6 +33,7 @@ export const useMobilePicker = _ref => {
|
|
|
33
33
|
sx,
|
|
34
34
|
format,
|
|
35
35
|
formatDensity,
|
|
36
|
+
timezone,
|
|
36
37
|
label,
|
|
37
38
|
inputRef,
|
|
38
39
|
readOnly,
|
|
@@ -72,6 +73,7 @@ export const useMobilePicker = _ref => {
|
|
|
72
73
|
sx,
|
|
73
74
|
format,
|
|
74
75
|
formatDensity,
|
|
76
|
+
timezone,
|
|
75
77
|
label
|
|
76
78
|
}),
|
|
77
79
|
ownerState: props
|