@mui/x-date-pickers 7.0.0-alpha.1 → 7.0.0-alpha.3
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/AdapterDateFns/AdapterDateFns.d.ts +2 -2
- package/AdapterDateFns/AdapterDateFns.js +11 -17
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +2 -2
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +13 -19
- package/AdapterDayjs/AdapterDayjs.d.ts +2 -2
- package/AdapterDayjs/AdapterDayjs.js +13 -15
- package/AdapterLuxon/AdapterLuxon.d.ts +3 -3
- package/AdapterLuxon/AdapterLuxon.js +31 -39
- package/AdapterMoment/AdapterMoment.d.ts +3 -3
- package/AdapterMoment/AdapterMoment.js +16 -23
- package/AdapterMomentHijri/AdapterMomentHijri.d.ts +1 -3
- package/AdapterMomentHijri/AdapterMomentHijri.js +1 -27
- package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +1 -4
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +0 -29
- package/CHANGELOG.md +607 -188
- package/DateCalendar/DateCalendar.js +4 -10
- package/DateCalendar/DateCalendar.types.d.ts +0 -4
- package/DateCalendar/DayCalendar.d.ts +3 -3
- package/DateCalendar/dayCalendarClasses.d.ts +1 -1
- package/DateCalendar/dayCalendarClasses.js +1 -1
- package/DateCalendar/index.d.ts +1 -1
- package/DateCalendar/index.js +1 -1
- package/DateCalendar/useCalendarState.d.ts +1 -1
- package/DateCalendar/useCalendarState.js +1 -9
- package/DateField/DateField.js +1 -1
- package/DatePicker/DatePicker.js +3 -7
- package/DateTimeField/DateTimeField.js +1 -9
- package/DateTimePicker/DateTimePicker.js +3 -15
- package/DesktopDatePicker/DesktopDatePicker.js +3 -7
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -15
- package/DesktopTimePicker/DesktopTimePicker.js +1 -9
- package/DigitalClock/DigitalClock.js +3 -15
- package/MobileDatePicker/MobileDatePicker.js +3 -7
- package/MobileDateTimePicker/MobileDateTimePicker.js +3 -15
- package/MobileTimePicker/MobileTimePicker.js +1 -9
- package/MonthCalendar/MonthCalendar.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +5 -15
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +3 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +2 -1
- package/PickersDay/PickersDay.js +1 -1
- package/PickersShortcuts/PickersShortcuts.d.ts +1 -1
- package/PickersShortcuts/PickersShortcuts.js +1 -1
- package/README.md +0 -1
- package/StaticDatePicker/StaticDatePicker.js +3 -7
- package/StaticDateTimePicker/StaticDateTimePicker.js +3 -15
- package/StaticTimePicker/StaticTimePicker.js +1 -9
- package/TimeClock/Clock.js +1 -1
- package/TimeClock/TimeClock.js +3 -15
- package/TimeField/TimeField.js +1 -9
- package/TimePicker/TimePicker.js +1 -9
- package/YearCalendar/YearCalendar.js +1 -1
- package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +1 -1
- package/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -4
- package/dateViewRenderers/dateViewRenderers.d.ts +1 -1
- package/dateViewRenderers/dateViewRenderers.js +0 -2
- package/index.js +1 -1
- package/internals/components/PickersTextField/Outline.d.ts +2 -0
- package/internals/components/PickersTextField/Outline.js +99 -0
- package/internals/components/PickersTextField/PickersInput.d.ts +4 -0
- package/internals/components/PickersTextField/PickersInput.js +264 -0
- package/internals/components/PickersTextField/PickersInput.types.d.ts +30 -0
- package/internals/components/PickersTextField/PickersInput.types.js +1 -0
- package/internals/components/PickersTextField/PickersTextField.d.ts +3 -0
- package/internals/components/PickersTextField/PickersTextField.js +120 -0
- package/internals/components/PickersTextField/PickersTextField.types.d.ts +18 -0
- package/internals/components/PickersTextField/PickersTextField.types.js +1 -0
- package/internals/components/PickersTextField/index.d.ts +1 -0
- package/internals/components/PickersTextField/index.js +1 -0
- package/internals/components/PickersTextField/pickersTextFieldClasses.d.ts +42 -0
- package/internals/components/PickersTextField/pickersTextFieldClasses.js +9 -0
- package/internals/hooks/date-helpers-hooks.js +2 -2
- package/internals/hooks/useField/useField.utils.js +30 -17
- package/internals/hooks/useField/useFieldState.js +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +2 -6
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +3 -3
- package/internals/hooks/useUtils.js +1 -1
- package/internals/hooks/useViews.js +2 -2
- package/internals/models/validation.d.ts +0 -8
- package/internals/utils/date-utils.js +2 -2
- package/internals/utils/validation/extractValidationProps.d.ts +1 -1
- package/internals/utils/validation/extractValidationProps.js +1 -1
- package/internals/utils/validation/validateDate.js +1 -1
- package/internals/utils/validation/validateTime.js +1 -8
- package/legacy/AdapterDateFns/AdapterDateFns.js +12 -16
- package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +14 -18
- package/legacy/AdapterDayjs/AdapterDayjs.js +15 -14
- package/legacy/AdapterLuxon/AdapterLuxon.js +34 -39
- package/legacy/AdapterMoment/AdapterMoment.js +326 -324
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +4 -28
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +0 -33
- package/legacy/DateCalendar/DateCalendar.js +4 -10
- package/legacy/DateCalendar/PickersSlideTransition.js +8 -9
- package/legacy/DateCalendar/dayCalendarClasses.js +1 -1
- package/legacy/DateCalendar/index.js +1 -1
- package/legacy/DateCalendar/useCalendarState.js +1 -9
- package/legacy/DateField/DateField.js +1 -1
- package/legacy/DatePicker/DatePicker.js +3 -7
- package/legacy/DateTimeField/DateTimeField.js +1 -9
- package/legacy/DateTimePicker/DateTimePicker.js +3 -15
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +3 -7
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -15
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +1 -9
- package/legacy/DigitalClock/DigitalClock.js +3 -15
- package/legacy/MobileDatePicker/MobileDatePicker.js +3 -7
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +3 -15
- package/legacy/MobileTimePicker/MobileTimePicker.js +1 -9
- package/legacy/MonthCalendar/MonthCalendar.js +1 -1
- package/legacy/MonthCalendar/PickersMonth.js +4 -5
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +5 -15
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +2 -1
- package/legacy/PickersDay/PickersDay.js +6 -7
- package/legacy/PickersLayout/PickersLayout.js +5 -6
- package/legacy/PickersShortcuts/PickersShortcuts.js +2 -1
- package/legacy/StaticDatePicker/StaticDatePicker.js +3 -7
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +3 -15
- package/legacy/StaticTimePicker/StaticTimePicker.js +1 -9
- package/legacy/TimeClock/Clock.js +1 -1
- package/legacy/TimeClock/ClockNumber.js +4 -5
- package/legacy/TimeClock/TimeClock.js +3 -15
- package/legacy/TimeField/TimeField.js +1 -9
- package/legacy/TimePicker/TimePicker.js +1 -9
- package/legacy/TimePicker/TimePickerToolbar.js +1 -2
- package/legacy/YearCalendar/PickersYear.js +4 -5
- package/legacy/YearCalendar/YearCalendar.js +1 -1
- package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -4
- package/legacy/dateViewRenderers/dateViewRenderers.js +0 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersModalDialog.js +3 -4
- package/legacy/internals/components/PickersTextField/Outline.js +100 -0
- package/legacy/internals/components/PickersTextField/PickersInput.js +273 -0
- package/legacy/internals/components/PickersTextField/PickersInput.types.js +1 -0
- package/legacy/internals/components/PickersTextField/PickersTextField.js +129 -0
- package/legacy/internals/components/PickersTextField/PickersTextField.types.js +1 -0
- package/legacy/internals/components/PickersTextField/index.js +1 -0
- package/legacy/internals/components/PickersTextField/pickersTextFieldClasses.js +9 -0
- package/legacy/internals/hooks/date-helpers-hooks.js +2 -2
- package/legacy/internals/hooks/useField/useField.utils.js +30 -17
- package/legacy/internals/hooks/useField/useFieldState.js +1 -1
- package/legacy/internals/hooks/usePicker/usePickerValue.js +2 -6
- package/legacy/internals/hooks/useUtils.js +1 -1
- package/legacy/internals/hooks/useViews.js +2 -2
- package/legacy/internals/utils/date-utils.js +2 -2
- package/legacy/internals/utils/validation/extractValidationProps.js +1 -1
- package/legacy/internals/utils/validation/validateDate.js +1 -1
- package/legacy/internals/utils/validation/validateTime.js +1 -8
- package/legacy/locales/deDE.js +4 -3
- package/legacy/locales/index.js +1 -0
- package/legacy/locales/mk.js +91 -0
- package/legacy/timeViewRenderers/timeViewRenderers.js +0 -6
- package/locales/beBY.d.ts +18 -5
- package/locales/caES.d.ts +18 -5
- package/locales/csCZ.d.ts +18 -5
- package/locales/daDK.d.ts +18 -5
- package/locales/deDE.d.ts +18 -5
- package/locales/deDE.js +2 -3
- package/locales/elGR.d.ts +18 -5
- package/locales/enUS.d.ts +18 -5
- package/locales/esES.d.ts +18 -5
- package/locales/eu.d.ts +18 -5
- package/locales/faIR.d.ts +18 -5
- package/locales/fiFI.d.ts +18 -5
- package/locales/frFR.d.ts +18 -5
- package/locales/heIL.d.ts +18 -5
- package/locales/huHU.d.ts +18 -5
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/isIS.d.ts +18 -5
- package/locales/itIT.d.ts +18 -5
- package/locales/jaJP.d.ts +18 -5
- package/locales/koKR.d.ts +18 -5
- package/locales/kzKZ.d.ts +18 -5
- package/locales/mk.d.ts +66 -0
- package/locales/mk.js +55 -0
- package/locales/nbNO.d.ts +18 -5
- package/locales/nlNL.d.ts +18 -5
- package/locales/plPL.d.ts +18 -5
- package/locales/ptBR.d.ts +18 -5
- package/locales/roRO.d.ts +18 -5
- package/locales/ruRU.d.ts +18 -5
- package/locales/skSK.d.ts +18 -5
- package/locales/svSE.d.ts +18 -5
- package/locales/trTR.d.ts +18 -5
- package/locales/ukUA.d.ts +18 -5
- package/locales/urPK.d.ts +18 -5
- package/locales/utils/getPickersLocalization.d.ts +18 -5
- package/locales/utils/pickersLocaleTextApi.d.ts +18 -5
- package/locales/viVN.d.ts +18 -5
- package/locales/zhCN.d.ts +18 -5
- package/locales/zhHK.d.ts +18 -5
- package/models/adapters.d.ts +6 -10
- package/models/timezone.d.ts +1 -1
- package/models/validation.d.ts +1 -1
- package/modern/AdapterDateFns/AdapterDateFns.js +11 -17
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +13 -19
- package/modern/AdapterDayjs/AdapterDayjs.js +13 -15
- package/modern/AdapterLuxon/AdapterLuxon.js +30 -39
- package/modern/AdapterMoment/AdapterMoment.js +16 -23
- package/modern/AdapterMomentHijri/AdapterMomentHijri.js +1 -27
- package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +0 -29
- package/modern/DateCalendar/DateCalendar.js +4 -10
- package/modern/DateCalendar/dayCalendarClasses.js +1 -1
- package/modern/DateCalendar/index.js +1 -1
- package/modern/DateCalendar/useCalendarState.js +1 -9
- package/modern/DateField/DateField.js +1 -1
- package/modern/DatePicker/DatePicker.js +3 -7
- package/modern/DateTimeField/DateTimeField.js +1 -9
- package/modern/DateTimePicker/DateTimePicker.js +3 -15
- package/modern/DesktopDatePicker/DesktopDatePicker.js +3 -7
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -15
- package/modern/DesktopTimePicker/DesktopTimePicker.js +1 -9
- package/modern/DigitalClock/DigitalClock.js +3 -15
- package/modern/MobileDatePicker/MobileDatePicker.js +3 -7
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +3 -15
- package/modern/MobileTimePicker/MobileTimePicker.js +1 -9
- package/modern/MonthCalendar/MonthCalendar.js +1 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +5 -15
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +2 -1
- package/modern/PickersDay/PickersDay.js +1 -1
- package/modern/PickersShortcuts/PickersShortcuts.js +1 -1
- package/modern/StaticDatePicker/StaticDatePicker.js +3 -7
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +3 -15
- package/modern/StaticTimePicker/StaticTimePicker.js +1 -9
- package/modern/TimeClock/Clock.js +1 -1
- package/modern/TimeClock/TimeClock.js +3 -15
- package/modern/TimeField/TimeField.js +1 -9
- package/modern/TimePicker/TimePicker.js +1 -9
- package/modern/YearCalendar/YearCalendar.js +1 -1
- package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -4
- package/modern/dateViewRenderers/dateViewRenderers.js +0 -2
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersTextField/Outline.js +99 -0
- package/modern/internals/components/PickersTextField/PickersInput.js +264 -0
- package/modern/internals/components/PickersTextField/PickersInput.types.js +1 -0
- package/modern/internals/components/PickersTextField/PickersTextField.js +119 -0
- package/modern/internals/components/PickersTextField/PickersTextField.types.js +1 -0
- package/modern/internals/components/PickersTextField/index.js +1 -0
- package/modern/internals/components/PickersTextField/pickersTextFieldClasses.js +9 -0
- package/modern/internals/hooks/date-helpers-hooks.js +2 -2
- package/modern/internals/hooks/useField/useField.utils.js +30 -17
- package/modern/internals/hooks/useField/useFieldState.js +1 -1
- package/modern/internals/hooks/usePicker/usePickerValue.js +2 -6
- package/modern/internals/hooks/useUtils.js +1 -1
- package/modern/internals/hooks/useViews.js +2 -2
- package/modern/internals/utils/date-utils.js +2 -2
- package/modern/internals/utils/validation/extractValidationProps.js +1 -1
- package/modern/internals/utils/validation/validateDate.js +1 -1
- package/modern/internals/utils/validation/validateTime.js +1 -8
- package/modern/locales/deDE.js +2 -3
- package/modern/locales/index.js +1 -0
- package/modern/locales/mk.js +55 -0
- package/modern/timeViewRenderers/timeViewRenderers.js +0 -6
- package/node/AdapterDateFns/AdapterDateFns.js +11 -17
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +13 -19
- package/node/AdapterDayjs/AdapterDayjs.js +12 -14
- package/node/AdapterLuxon/AdapterLuxon.js +30 -39
- package/node/AdapterMoment/AdapterMoment.js +16 -23
- package/node/AdapterMomentHijri/AdapterMomentHijri.js +1 -27
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +0 -29
- package/node/DateCalendar/DateCalendar.js +4 -10
- package/node/DateCalendar/dayCalendarClasses.js +2 -2
- package/node/DateCalendar/index.js +2 -2
- package/node/DateCalendar/useCalendarState.js +1 -9
- package/node/DateField/DateField.js +1 -1
- package/node/DatePicker/DatePicker.js +3 -7
- package/node/DateTimeField/DateTimeField.js +1 -9
- package/node/DateTimePicker/DateTimePicker.js +3 -15
- package/node/DesktopDatePicker/DesktopDatePicker.js +3 -7
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -15
- package/node/DesktopTimePicker/DesktopTimePicker.js +1 -9
- package/node/DigitalClock/DigitalClock.js +3 -15
- package/node/MobileDatePicker/MobileDatePicker.js +3 -7
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +3 -15
- package/node/MobileTimePicker/MobileTimePicker.js +1 -9
- package/node/MonthCalendar/MonthCalendar.js +1 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +5 -15
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +2 -1
- package/node/PickersDay/PickersDay.js +1 -1
- package/node/PickersShortcuts/PickersShortcuts.js +1 -1
- package/node/StaticDatePicker/StaticDatePicker.js +3 -7
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +3 -15
- package/node/StaticTimePicker/StaticTimePicker.js +1 -9
- package/node/TimeClock/Clock.js +1 -1
- package/node/TimeClock/TimeClock.js +3 -15
- package/node/TimeField/TimeField.js +1 -9
- package/node/TimePicker/TimePicker.js +1 -9
- package/node/YearCalendar/YearCalendar.js +1 -1
- package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -4
- package/node/dateViewRenderers/dateViewRenderers.js +0 -2
- package/node/index.js +1 -1
- package/node/internals/components/PickersTextField/Outline.js +108 -0
- package/node/internals/components/PickersTextField/PickersInput.js +272 -0
- package/node/internals/components/PickersTextField/PickersInput.types.js +5 -0
- package/node/internals/components/PickersTextField/PickersTextField.js +127 -0
- package/node/internals/components/PickersTextField/PickersTextField.types.js +5 -0
- package/node/internals/components/PickersTextField/index.js +12 -0
- package/node/internals/components/PickersTextField/pickersTextFieldClasses.js +17 -0
- package/node/internals/hooks/date-helpers-hooks.js +2 -2
- package/node/internals/hooks/useField/useField.utils.js +30 -17
- package/node/internals/hooks/useField/useFieldState.js +1 -1
- package/node/internals/hooks/usePicker/usePickerValue.js +2 -6
- package/node/internals/hooks/useUtils.js +1 -1
- package/node/internals/hooks/useViews.js +2 -2
- package/node/internals/utils/date-utils.js +2 -2
- package/node/internals/utils/validation/extractValidationProps.js +1 -1
- package/node/internals/utils/validation/validateDate.js +1 -1
- package/node/internals/utils/validation/validateTime.js +1 -8
- package/node/locales/deDE.js +2 -3
- package/node/locales/index.js +11 -0
- package/node/locales/mk.js +60 -0
- package/node/timeViewRenderers/timeViewRenderers.js +0 -6
- package/package.json +8 -7
- package/timeViewRenderers/timeViewRenderers.d.ts +3 -3
- package/timeViewRenderers/timeViewRenderers.js +0 -6
- package/internals/components/FakeTextField/FakeTextField.d.ts +0 -22
- package/internals/components/FakeTextField/FakeTextField.js +0 -44
- package/internals/components/FakeTextField/index.d.ts +0 -1
- package/internals/components/FakeTextField/index.js +0 -1
- package/legacy/internals/components/FakeTextField/FakeTextField.js +0 -49
- package/legacy/internals/components/FakeTextField/index.js +0 -1
- package/modern/internals/components/FakeTextField/FakeTextField.js +0 -44
- package/modern/internals/components/FakeTextField/index.js +0 -1
- package/node/internals/components/FakeTextField/FakeTextField.js +0 -52
- package/node/internals/components/FakeTextField/index.js +0 -12
|
@@ -221,9 +221,7 @@ export const usePickerValue = ({
|
|
|
221
221
|
const context = {
|
|
222
222
|
validationError
|
|
223
223
|
};
|
|
224
|
-
|
|
225
|
-
// TODO v7: Remove 2nd condition
|
|
226
|
-
if (action.name === 'setValueFromShortcut' && action.shortcut != null) {
|
|
224
|
+
if (action.name === 'setValueFromShortcut') {
|
|
227
225
|
context.shortcut = action.shortcut;
|
|
228
226
|
}
|
|
229
227
|
handleValueChange(action.value, context);
|
|
@@ -288,12 +286,10 @@ export const usePickerValue = ({
|
|
|
288
286
|
value: newValue,
|
|
289
287
|
selectionState
|
|
290
288
|
}));
|
|
291
|
-
|
|
292
|
-
// TODO v7: Make changeImportance and label mandatory.
|
|
293
289
|
const handleSelectShortcut = useEventCallback((newValue, changeImportance, shortcut) => updateDate({
|
|
294
290
|
name: 'setValueFromShortcut',
|
|
295
291
|
value: newValue,
|
|
296
|
-
changeImportance
|
|
292
|
+
changeImportance,
|
|
297
293
|
shortcut
|
|
298
294
|
}));
|
|
299
295
|
const handleChangeFromField = useEventCallback((newValue, context) => updateDate({
|
|
@@ -132,7 +132,7 @@ export interface UsePickerValueState<TValue> {
|
|
|
132
132
|
* Then we might want to apply some custom logic.
|
|
133
133
|
*
|
|
134
134
|
* For example, when the component is not controlled and `defaultValue` is defined.
|
|
135
|
-
* Then clicking on "Accept", "Today" or "Clear" should fire `onAccept` with `defaultValue`, but clicking on "Cancel" or
|
|
135
|
+
* Then clicking on "Accept", "Today" or "Clear" should fire `onAccept` with `defaultValue`, but clicking on "Cancel" or dismissing the picker should not.
|
|
136
136
|
*/
|
|
137
137
|
hasBeenModifiedSinceMount: boolean;
|
|
138
138
|
}
|
|
@@ -165,7 +165,7 @@ export type PickerValueUpdateAction<TValue, TError> = {
|
|
|
165
165
|
name: 'setValueFromShortcut';
|
|
166
166
|
value: TValue;
|
|
167
167
|
changeImportance: PickerShortcutChangeImportance;
|
|
168
|
-
shortcut
|
|
168
|
+
shortcut: PickersShortcutsItemContext;
|
|
169
169
|
};
|
|
170
170
|
/**
|
|
171
171
|
* Props used to handle the value that are common to all pickers.
|
|
@@ -269,7 +269,7 @@ export interface UsePickerValueViewsResponse<TValue> {
|
|
|
269
269
|
export interface UsePickerValueLayoutResponse<TValue> extends UsePickerValueActions {
|
|
270
270
|
value: TValue;
|
|
271
271
|
onChange: (newValue: TValue) => void;
|
|
272
|
-
onSelectShortcut: (newValue: TValue, changeImportance
|
|
272
|
+
onSelectShortcut: (newValue: TValue, changeImportance: PickerShortcutChangeImportance, shortcut: PickersShortcutsItemContext) => void;
|
|
273
273
|
isValid: (value: TValue) => boolean;
|
|
274
274
|
}
|
|
275
275
|
export interface UsePickerValueResponse<TValue, TSection extends FieldSection, TError> {
|
|
@@ -22,7 +22,7 @@ export const useNow = timezone => {
|
|
|
22
22
|
const utils = useUtils();
|
|
23
23
|
const now = React.useRef();
|
|
24
24
|
if (now.current === undefined) {
|
|
25
|
-
now.current = utils.
|
|
25
|
+
now.current = utils.date(undefined, timezone);
|
|
26
26
|
}
|
|
27
27
|
return now.current;
|
|
28
28
|
};
|
|
@@ -84,7 +84,7 @@ export function useViews({
|
|
|
84
84
|
const isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
|
|
85
85
|
const hasMoreViews = selectedView ?
|
|
86
86
|
// handles case like `DateTimePicker`, where a view might return a `finish` selection state
|
|
87
|
-
// but
|
|
87
|
+
// but when it's not the final view given all `views` -> overall selection state should be `partial`.
|
|
88
88
|
views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
|
|
89
89
|
const globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? 'partial' : currentViewSelectionState;
|
|
90
90
|
onChange(value, globalSelectionState);
|
|
@@ -106,7 +106,7 @@ export function useViews({
|
|
|
106
106
|
setFocusedView: handleFocusedViewChange,
|
|
107
107
|
nextView,
|
|
108
108
|
previousView,
|
|
109
|
-
// Always return up
|
|
109
|
+
// Always return up-to-date default view instead of the initial one (i.e. defaultView.current)
|
|
110
110
|
defaultView: views.includes(openTo) ? openTo : views[0],
|
|
111
111
|
goToNextView,
|
|
112
112
|
setValueAndGoToNextView,
|
|
@@ -44,14 +44,6 @@ export interface TimeValidationProps<TDate> {
|
|
|
44
44
|
* @returns {boolean} If `true` the time will be disabled.
|
|
45
45
|
*/
|
|
46
46
|
shouldDisableTime?: (value: TDate, view: TimeView) => boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Disable specific clock time.
|
|
49
|
-
* @param {number} clockValue The value to check.
|
|
50
|
-
* @param {TimeView} view The clock type of the timeValue.
|
|
51
|
-
* @returns {boolean} If `true` the time will be disabled.
|
|
52
|
-
* @deprecated Consider using `shouldDisableTime`.
|
|
53
|
-
*/
|
|
54
|
-
shouldDisableClock?: (clockValue: number, view: TimeView) => boolean;
|
|
55
47
|
/**
|
|
56
48
|
* Do not ignore date part when validating min/max time.
|
|
57
49
|
* @default false
|
|
@@ -9,7 +9,7 @@ export const findClosestEnabledDate = ({
|
|
|
9
9
|
utils,
|
|
10
10
|
timezone
|
|
11
11
|
}) => {
|
|
12
|
-
const today = utils.startOfDay(utils.
|
|
12
|
+
const today = utils.startOfDay(utils.date(undefined, timezone));
|
|
13
13
|
if (disablePast && utils.isBefore(minDate, today)) {
|
|
14
14
|
minDate = today;
|
|
15
15
|
}
|
|
@@ -79,7 +79,7 @@ export const mergeDateAndTime = (utils, dateParam, timeParam) => {
|
|
|
79
79
|
mergedDate = utils.setSeconds(mergedDate, utils.getSeconds(timeParam));
|
|
80
80
|
return mergedDate;
|
|
81
81
|
};
|
|
82
|
-
export const getTodayDate = (utils, timezone, valueType) => valueType === 'date' ? utils.startOfDay(utils.
|
|
82
|
+
export const getTodayDate = (utils, timezone, valueType) => valueType === 'date' ? utils.startOfDay(utils.date(undefined, timezone)) : utils.date(undefined, timezone);
|
|
83
83
|
export const formatMeridiem = (utils, meridiem) => {
|
|
84
84
|
const date = utils.setHours(utils.date(), meridiem === 'am' ? 2 : 14);
|
|
85
85
|
return utils.format(date, 'meridiem');
|
|
@@ -8,4 +8,4 @@ export declare const DATE_TIME_VALIDATION_PROP_NAMES: (keyof DateTimeValidationP
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const extractValidationProps: <Props extends {
|
|
10
10
|
[key: string]: any;
|
|
11
|
-
}>(props: Props) => Pick<Props, "ampm" | "disableFuture" | "disablePast" | "maxDate" | "minDate" | "minutesStep" | "shouldDisableDate" | "shouldDisableMonth" | "shouldDisableYear" | "minTime" | "maxTime" | "shouldDisableTime" | "
|
|
11
|
+
}>(props: Props) => Pick<Props, "ampm" | "disableFuture" | "disablePast" | "maxDate" | "minDate" | "minutesStep" | "shouldDisableDate" | "shouldDisableMonth" | "shouldDisableYear" | "minTime" | "maxTime" | "shouldDisableTime" | "disableIgnoringDatePartForTimeValidation" | "minDateTime" | "maxDateTime">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const DATE_VALIDATION_PROP_NAMES = ['disablePast', 'disableFuture', 'minDate', 'maxDate', 'shouldDisableDate', 'shouldDisableMonth', 'shouldDisableYear'];
|
|
2
|
-
export const TIME_VALIDATION_PROP_NAMES = ['disablePast', 'disableFuture', 'minTime', 'maxTime', '
|
|
2
|
+
export const TIME_VALIDATION_PROP_NAMES = ['disablePast', 'disableFuture', 'minTime', 'maxTime', 'shouldDisableTime', 'minutesStep', 'ampm', 'disableIgnoringDatePartForTimeValidation'];
|
|
3
3
|
export const DATE_TIME_VALIDATION_PROP_NAMES = ['minDateTime', 'maxDateTime'];
|
|
4
4
|
const VALIDATION_PROP_NAMES = [...DATE_VALIDATION_PROP_NAMES, ...TIME_VALIDATION_PROP_NAMES, ...DATE_TIME_VALIDATION_PROP_NAMES];
|
|
5
5
|
/**
|
|
@@ -15,7 +15,7 @@ export const validateDate = ({
|
|
|
15
15
|
disableFuture,
|
|
16
16
|
timezone
|
|
17
17
|
} = props;
|
|
18
|
-
const now = adapter.utils.
|
|
18
|
+
const now = adapter.utils.date(undefined, timezone);
|
|
19
19
|
const minDate = applyDefaultDate(adapter.utils, props.minDate, adapter.defaultDates.minDate);
|
|
20
20
|
const maxDate = applyDefaultDate(adapter.utils, props.maxDate, adapter.defaultDates.maxDate);
|
|
21
21
|
switch (true) {
|
|
@@ -11,14 +11,13 @@ export const validateTime = ({
|
|
|
11
11
|
minTime,
|
|
12
12
|
maxTime,
|
|
13
13
|
minutesStep,
|
|
14
|
-
shouldDisableClock,
|
|
15
14
|
shouldDisableTime,
|
|
16
15
|
disableIgnoringDatePartForTimeValidation = false,
|
|
17
16
|
disablePast,
|
|
18
17
|
disableFuture,
|
|
19
18
|
timezone
|
|
20
19
|
} = props;
|
|
21
|
-
const now = adapter.utils.
|
|
20
|
+
const now = adapter.utils.date(undefined, timezone);
|
|
22
21
|
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, adapter.utils);
|
|
23
22
|
switch (true) {
|
|
24
23
|
case !adapter.utils.isValid(value):
|
|
@@ -37,12 +36,6 @@ export const validateTime = ({
|
|
|
37
36
|
return 'shouldDisableTime-minutes';
|
|
38
37
|
case Boolean(shouldDisableTime && shouldDisableTime(value, 'seconds')):
|
|
39
38
|
return 'shouldDisableTime-seconds';
|
|
40
|
-
case Boolean(shouldDisableClock && shouldDisableClock(adapter.utils.getHours(value), 'hours')):
|
|
41
|
-
return 'shouldDisableClock-hours';
|
|
42
|
-
case Boolean(shouldDisableClock && shouldDisableClock(adapter.utils.getMinutes(value), 'minutes')):
|
|
43
|
-
return 'shouldDisableClock-minutes';
|
|
44
|
-
case Boolean(shouldDisableClock && shouldDisableClock(adapter.utils.getSeconds(value), 'seconds')):
|
|
45
|
-
return 'shouldDisableClock-seconds';
|
|
46
39
|
case Boolean(minutesStep && adapter.utils.getMinutes(value) % minutesStep !== 0):
|
|
47
40
|
return 'minutesStep';
|
|
48
41
|
default:
|
|
@@ -288,8 +288,8 @@ export var AdapterDateFns = /*#__PURE__*/_createClass(function AdapterDateFns()
|
|
|
288
288
|
}
|
|
289
289
|
return new Date(value);
|
|
290
290
|
};
|
|
291
|
-
this.
|
|
292
|
-
return
|
|
291
|
+
this.getInvalidDate = function () {
|
|
292
|
+
return new Date('Invalid Date');
|
|
293
293
|
};
|
|
294
294
|
this.getTimezone = function () {
|
|
295
295
|
return 'default';
|
|
@@ -387,10 +387,10 @@ export var AdapterDateFns = /*#__PURE__*/_createClass(function AdapterDateFns()
|
|
|
387
387
|
return isBefore(value, comparing);
|
|
388
388
|
};
|
|
389
389
|
this.isBeforeYear = function (value, comparing) {
|
|
390
|
-
return isBefore(value, startOfYear(comparing));
|
|
390
|
+
return isBefore(value, _this.startOfYear(comparing));
|
|
391
391
|
};
|
|
392
392
|
this.isBeforeDay = function (value, comparing) {
|
|
393
|
-
return isBefore(value, startOfDay(comparing));
|
|
393
|
+
return isBefore(value, _this.startOfDay(comparing));
|
|
394
394
|
};
|
|
395
395
|
this.isWithinRange = function (value, _ref2) {
|
|
396
396
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
@@ -496,20 +496,16 @@ export var AdapterDateFns = /*#__PURE__*/_createClass(function AdapterDateFns()
|
|
|
496
496
|
return getDaysInMonth(value);
|
|
497
497
|
};
|
|
498
498
|
this.getWeekArray = function (value) {
|
|
499
|
-
var start = startOfWeek(startOfMonth(value)
|
|
500
|
-
|
|
501
|
-
});
|
|
502
|
-
var end = endOfWeek(endOfMonth(value), {
|
|
503
|
-
locale: _this.locale
|
|
504
|
-
});
|
|
499
|
+
var start = _this.startOfWeek(_this.startOfMonth(value));
|
|
500
|
+
var end = _this.endOfWeek(_this.endOfMonth(value));
|
|
505
501
|
var count = 0;
|
|
506
502
|
var current = start;
|
|
507
503
|
var nestedWeeks = [];
|
|
508
|
-
while (isBefore(current, end)) {
|
|
504
|
+
while (_this.isBefore(current, end)) {
|
|
509
505
|
var weekNumber = Math.floor(count / 7);
|
|
510
506
|
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
511
507
|
nestedWeeks[weekNumber].push(current);
|
|
512
|
-
current = addDays(current, 1);
|
|
508
|
+
current = _this.addDays(current, 1);
|
|
513
509
|
count += 1;
|
|
514
510
|
}
|
|
515
511
|
return nestedWeeks;
|
|
@@ -523,13 +519,13 @@ export var AdapterDateFns = /*#__PURE__*/_createClass(function AdapterDateFns()
|
|
|
523
519
|
var _ref5 = _slicedToArray(_ref4, 2),
|
|
524
520
|
start = _ref5[0],
|
|
525
521
|
end = _ref5[1];
|
|
526
|
-
var startDate = startOfYear(start);
|
|
527
|
-
var endDate = endOfYear(end);
|
|
522
|
+
var startDate = _this.startOfYear(start);
|
|
523
|
+
var endDate = _this.endOfYear(end);
|
|
528
524
|
var years = [];
|
|
529
525
|
var current = startDate;
|
|
530
|
-
while (isBefore(current, endDate)) {
|
|
526
|
+
while (_this.isBefore(current, endDate)) {
|
|
531
527
|
years.push(current);
|
|
532
|
-
current = addYears(current, 1);
|
|
528
|
+
current = _this.addYears(current, 1);
|
|
533
529
|
}
|
|
534
530
|
return years;
|
|
535
531
|
};
|
|
@@ -300,8 +300,8 @@ export var AdapterDateFnsJalali = /*#__PURE__*/_createClass(function AdapterDate
|
|
|
300
300
|
}
|
|
301
301
|
return new Date(value);
|
|
302
302
|
};
|
|
303
|
-
this.
|
|
304
|
-
return
|
|
303
|
+
this.getInvalidDate = function () {
|
|
304
|
+
return new Date('Invalid Date');
|
|
305
305
|
};
|
|
306
306
|
this.getTimezone = function () {
|
|
307
307
|
return 'default';
|
|
@@ -392,19 +392,19 @@ export var AdapterDateFnsJalali = /*#__PURE__*/_createClass(function AdapterDate
|
|
|
392
392
|
return isAfter(value, comparing);
|
|
393
393
|
};
|
|
394
394
|
this.isAfterYear = function (value, comparing) {
|
|
395
|
-
return isAfter(value, endOfYear(comparing));
|
|
395
|
+
return isAfter(value, _this.endOfYear(comparing));
|
|
396
396
|
};
|
|
397
397
|
this.isAfterDay = function (value, comparing) {
|
|
398
|
-
return isAfter(value, endOfDay(comparing));
|
|
398
|
+
return isAfter(value, _this.endOfDay(comparing));
|
|
399
399
|
};
|
|
400
400
|
this.isBefore = function (value, comparing) {
|
|
401
401
|
return isBefore(value, comparing);
|
|
402
402
|
};
|
|
403
403
|
this.isBeforeYear = function (value, comparing) {
|
|
404
|
-
return isBefore(value, startOfYear(comparing));
|
|
404
|
+
return isBefore(value, _this.startOfYear(comparing));
|
|
405
405
|
};
|
|
406
406
|
this.isBeforeDay = function (value, comparing) {
|
|
407
|
-
return isBefore(value, startOfDay(comparing));
|
|
407
|
+
return isBefore(value, _this.startOfDay(comparing));
|
|
408
408
|
};
|
|
409
409
|
this.isWithinRange = function (value, _ref2) {
|
|
410
410
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
@@ -510,20 +510,16 @@ export var AdapterDateFnsJalali = /*#__PURE__*/_createClass(function AdapterDate
|
|
|
510
510
|
return getDaysInMonth(value);
|
|
511
511
|
};
|
|
512
512
|
this.getWeekArray = function (value) {
|
|
513
|
-
var start = startOfWeek(startOfMonth(value)
|
|
514
|
-
|
|
515
|
-
});
|
|
516
|
-
var end = endOfWeek(endOfMonth(value), {
|
|
517
|
-
locale: _this.locale
|
|
518
|
-
});
|
|
513
|
+
var start = _this.startOfWeek(_this.startOfMonth(value));
|
|
514
|
+
var end = _this.endOfWeek(_this.endOfMonth(value));
|
|
519
515
|
var count = 0;
|
|
520
516
|
var current = start;
|
|
521
517
|
var nestedWeeks = [];
|
|
522
|
-
while (isBefore(current, end)) {
|
|
518
|
+
while (_this.isBefore(current, end)) {
|
|
523
519
|
var weekNumber = Math.floor(count / 7);
|
|
524
520
|
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
525
521
|
nestedWeeks[weekNumber].push(current);
|
|
526
|
-
current = addDays(current, 1);
|
|
522
|
+
current = _this.addDays(current, 1);
|
|
527
523
|
count += 1;
|
|
528
524
|
}
|
|
529
525
|
return nestedWeeks;
|
|
@@ -537,13 +533,13 @@ export var AdapterDateFnsJalali = /*#__PURE__*/_createClass(function AdapterDate
|
|
|
537
533
|
var _ref5 = _slicedToArray(_ref4, 2),
|
|
538
534
|
start = _ref5[0],
|
|
539
535
|
end = _ref5[1];
|
|
540
|
-
var startDate = startOfYear(start);
|
|
541
|
-
var endDate = endOfYear(end);
|
|
536
|
+
var startDate = _this.startOfYear(start);
|
|
537
|
+
var endDate = _this.endOfYear(end);
|
|
542
538
|
var years = [];
|
|
543
539
|
var current = startDate;
|
|
544
|
-
while (isBefore(current, endDate)) {
|
|
540
|
+
while (_this.isBefore(current, endDate)) {
|
|
545
541
|
years.push(current);
|
|
546
|
-
current = addYears(current, 1);
|
|
542
|
+
current = _this.addYears(current, 1);
|
|
547
543
|
}
|
|
548
544
|
return years;
|
|
549
545
|
};
|
|
@@ -4,13 +4,13 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
4
4
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
5
|
/* eslint-disable class-methods-use-this */
|
|
6
6
|
import defaultDayjs from 'dayjs';
|
|
7
|
-
import
|
|
7
|
+
import weekOfYearPlugin from 'dayjs/plugin/weekOfYear';
|
|
8
8
|
import customParseFormatPlugin from 'dayjs/plugin/customParseFormat';
|
|
9
9
|
import localizedFormatPlugin from 'dayjs/plugin/localizedFormat';
|
|
10
10
|
import isBetweenPlugin from 'dayjs/plugin/isBetween';
|
|
11
11
|
import { buildWarning } from '../internals/utils/warning';
|
|
12
|
-
defaultDayjs.extend(customParseFormatPlugin);
|
|
13
12
|
defaultDayjs.extend(localizedFormatPlugin);
|
|
13
|
+
defaultDayjs.extend(weekOfYearPlugin);
|
|
14
14
|
defaultDayjs.extend(isBetweenPlugin);
|
|
15
15
|
var localeNotFoundWarning = buildWarning(['Your locale has not been found.', 'Either the locale key is not a supported one. Locales supported by dayjs are available here: https://github.com/iamkun/dayjs/tree/dev/src/locale', "Or you forget to import the locale from 'dayjs/locale/{localeUsed}'", 'fallback on English locale']);
|
|
16
16
|
var formatTokenMap = {
|
|
@@ -272,12 +272,7 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
272
272
|
return value;
|
|
273
273
|
};
|
|
274
274
|
this.date = function (value) {
|
|
275
|
-
|
|
276
|
-
return null;
|
|
277
|
-
}
|
|
278
|
-
return _this.dayjs(value);
|
|
279
|
-
};
|
|
280
|
-
this.dateWithTimezone = function (value, timezone) {
|
|
275
|
+
var timezone = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
|
|
281
276
|
if (value === null) {
|
|
282
277
|
return null;
|
|
283
278
|
}
|
|
@@ -294,6 +289,9 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
294
289
|
}
|
|
295
290
|
return parsedValue.locale(_this.locale);
|
|
296
291
|
};
|
|
292
|
+
this.getInvalidDate = function () {
|
|
293
|
+
return defaultDayjs(new Date('Invalid date'));
|
|
294
|
+
};
|
|
297
295
|
this.getTimezone = function (value) {
|
|
298
296
|
if (_this.hasTimezonePlugin()) {
|
|
299
297
|
var _value$$x;
|
|
@@ -530,8 +528,8 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
530
528
|
};
|
|
531
529
|
this.getWeekArray = function (value) {
|
|
532
530
|
var cleanValue = _this.setLocaleToValue(value);
|
|
533
|
-
var start =
|
|
534
|
-
var end =
|
|
531
|
+
var start = _this.startOfWeek(_this.startOfMonth(cleanValue));
|
|
532
|
+
var end = _this.endOfWeek(_this.endOfMonth(cleanValue));
|
|
535
533
|
var count = 0;
|
|
536
534
|
var current = start;
|
|
537
535
|
var nestedWeeks = [];
|
|
@@ -551,11 +549,11 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
551
549
|
var _ref5 = _slicedToArray(_ref4, 2),
|
|
552
550
|
start = _ref5[0],
|
|
553
551
|
end = _ref5[1];
|
|
554
|
-
var startDate =
|
|
555
|
-
var endDate =
|
|
552
|
+
var startDate = _this.startOfYear(start);
|
|
553
|
+
var endDate = _this.endOfYear(end);
|
|
556
554
|
var years = [];
|
|
557
555
|
var current = startDate;
|
|
558
|
-
while (current
|
|
556
|
+
while (_this.isBefore(current, endDate)) {
|
|
559
557
|
years.push(current);
|
|
560
558
|
current = _this.addYears(current, 1);
|
|
561
559
|
}
|
|
@@ -564,5 +562,8 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
564
562
|
this.dayjs = withLocale(defaultDayjs, _locale);
|
|
565
563
|
this.locale = _locale;
|
|
566
564
|
this.formats = _extends({}, defaultFormats, formats);
|
|
567
|
-
|
|
565
|
+
|
|
566
|
+
// Moved plugins to the constructor to allow for users to use options on the library
|
|
567
|
+
// for reference: https://github.com/mui/mui-x/pull/11151
|
|
568
|
+
defaultDayjs.extend(customParseFormatPlugin);
|
|
568
569
|
});
|
|
@@ -184,28 +184,7 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
184
184
|
return value.setLocale(expectedLocale);
|
|
185
185
|
};
|
|
186
186
|
this.date = function (value) {
|
|
187
|
-
|
|
188
|
-
return DateTime.local();
|
|
189
|
-
}
|
|
190
|
-
if (value === null) {
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
if (typeof value === 'string') {
|
|
194
|
-
// @ts-ignore
|
|
195
|
-
return DateTime.fromJSDate(new Date(value), {
|
|
196
|
-
locale: _this.locale
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
if (DateTime.isDateTime(value)) {
|
|
200
|
-
return value;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// @ts-ignore
|
|
204
|
-
return DateTime.fromJSDate(value, {
|
|
205
|
-
locale: _this.locale
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
this.dateWithTimezone = function (value, timezone) {
|
|
187
|
+
var timezone = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
|
|
209
188
|
if (value === null) {
|
|
210
189
|
return null;
|
|
211
190
|
}
|
|
@@ -223,6 +202,9 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
223
202
|
zone: timezone
|
|
224
203
|
});
|
|
225
204
|
};
|
|
205
|
+
this.getInvalidDate = function () {
|
|
206
|
+
return DateTime.fromJSDate(new Date('Invalid Date'));
|
|
207
|
+
};
|
|
226
208
|
this.getTimezone = function (value) {
|
|
227
209
|
// When using the system zone, we want to return "system", not something like "Europe/Paris"
|
|
228
210
|
if (value.zone.type === 'system') {
|
|
@@ -333,12 +315,12 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
333
315
|
};
|
|
334
316
|
this.isAfterYear = function (value, comparing) {
|
|
335
317
|
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
336
|
-
var diff = value.diff(
|
|
318
|
+
var diff = value.diff(_this.endOfYear(comparingInValueTimezone), 'years').toObject();
|
|
337
319
|
return diff.years > 0;
|
|
338
320
|
};
|
|
339
321
|
this.isAfterDay = function (value, comparing) {
|
|
340
322
|
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
341
|
-
var diff = value.diff(
|
|
323
|
+
var diff = value.diff(_this.endOfDay(comparingInValueTimezone), 'days').toObject();
|
|
342
324
|
return diff.days > 0;
|
|
343
325
|
};
|
|
344
326
|
this.isBefore = function (value, comparing) {
|
|
@@ -346,12 +328,12 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
346
328
|
};
|
|
347
329
|
this.isBeforeYear = function (value, comparing) {
|
|
348
330
|
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
349
|
-
var diff = value.diff(
|
|
331
|
+
var diff = value.diff(_this.startOfYear(comparingInValueTimezone), 'years').toObject();
|
|
350
332
|
return diff.years < 0;
|
|
351
333
|
};
|
|
352
334
|
this.isBeforeDay = function (value, comparing) {
|
|
353
335
|
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
354
|
-
var diff = value.diff(
|
|
336
|
+
var diff = value.diff(_this.startOfDay(comparingInValueTimezone), 'days').toObject();
|
|
355
337
|
return diff.days < 0;
|
|
356
338
|
};
|
|
357
339
|
this.isWithinRange = function (value, _ref2) {
|
|
@@ -367,7 +349,12 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
367
349
|
return value.startOf('month');
|
|
368
350
|
};
|
|
369
351
|
this.startOfWeek = function (value) {
|
|
370
|
-
return value.startOf('week'
|
|
352
|
+
return value.startOf('week',
|
|
353
|
+
// TODO: remove when `@types/luxon` add support for the parameter.
|
|
354
|
+
// @ts-ignore
|
|
355
|
+
{
|
|
356
|
+
useLocaleWeeks: true
|
|
357
|
+
});
|
|
371
358
|
};
|
|
372
359
|
this.startOfDay = function (value) {
|
|
373
360
|
return value.startOf('day');
|
|
@@ -379,7 +366,12 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
379
366
|
return value.endOf('month');
|
|
380
367
|
};
|
|
381
368
|
this.endOfWeek = function (value) {
|
|
382
|
-
return value.endOf('week'
|
|
369
|
+
return value.endOf('week',
|
|
370
|
+
// TODO: remove when `@types/luxon` add support for the parameter.
|
|
371
|
+
// @ts-ignore
|
|
372
|
+
{
|
|
373
|
+
useLocaleWeeks: true
|
|
374
|
+
});
|
|
383
375
|
};
|
|
384
376
|
this.endOfDay = function (value) {
|
|
385
377
|
return value.endOf('day');
|
|
@@ -481,13 +473,15 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
481
473
|
};
|
|
482
474
|
this.getWeekArray = function (value) {
|
|
483
475
|
var cleanValue = _this.setLocaleToValue(value);
|
|
484
|
-
var
|
|
485
|
-
|
|
476
|
+
var firstDay = _this.startOfWeek(_this.startOfMonth(cleanValue));
|
|
477
|
+
var lastDay = _this.endOfWeek(_this.endOfMonth(cleanValue));
|
|
478
|
+
var _lastDay$diff$toObjec = lastDay.diff(firstDay, 'days').toObject(),
|
|
479
|
+
days = _lastDay$diff$toObjec.days;
|
|
486
480
|
var weeks = [];
|
|
487
481
|
new Array(Math.round(days)).fill(0).map(function (_, i) {
|
|
488
482
|
return i;
|
|
489
483
|
}).map(function (day) {
|
|
490
|
-
return
|
|
484
|
+
return firstDay.plus({
|
|
491
485
|
days: day
|
|
492
486
|
});
|
|
493
487
|
}).forEach(function (v, i) {
|
|
@@ -500,21 +494,22 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
500
494
|
return weeks;
|
|
501
495
|
};
|
|
502
496
|
this.getWeekNumber = function (value) {
|
|
503
|
-
|
|
497
|
+
var _value$localeWeekNumb;
|
|
498
|
+
// TODO: remove when `@types/luxon` add support for the parameter.
|
|
499
|
+
// @ts-ignore
|
|
500
|
+
return (_value$localeWeekNumb = value.localeWeekNumber) != null ? _value$localeWeekNumb : value.weekNumber;
|
|
504
501
|
};
|
|
505
502
|
this.getYearRange = function (_ref4) {
|
|
506
503
|
var _ref5 = _slicedToArray(_ref4, 2),
|
|
507
504
|
start = _ref5[0],
|
|
508
505
|
end = _ref5[1];
|
|
509
|
-
var startDate =
|
|
510
|
-
var endDate =
|
|
511
|
-
var current = startDate;
|
|
506
|
+
var startDate = _this.startOfYear(start);
|
|
507
|
+
var endDate = _this.endOfYear(end);
|
|
512
508
|
var years = [];
|
|
513
|
-
|
|
509
|
+
var current = startDate;
|
|
510
|
+
while (_this.isBefore(current, endDate)) {
|
|
514
511
|
years.push(current);
|
|
515
|
-
current =
|
|
516
|
-
year: 1
|
|
517
|
-
});
|
|
512
|
+
current = _this.addYears(current, 1);
|
|
518
513
|
}
|
|
519
514
|
return years;
|
|
520
515
|
};
|