@mui/x-date-pickers 6.5.0 → 6.6.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/AdapterDateFns/AdapterDateFns.d.ts +6 -0
- package/AdapterDateFns/AdapterDateFns.js +18 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +6 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
- package/AdapterDayjs/AdapterDayjs.d.ts +14 -1
- package/AdapterDayjs/AdapterDayjs.js +131 -14
- package/AdapterLuxon/AdapterLuxon.d.ts +7 -1
- package/AdapterLuxon/AdapterLuxon.js +58 -9
- package/AdapterMoment/AdapterMoment.d.ts +12 -1
- package/AdapterMoment/AdapterMoment.js +91 -2
- package/AdapterMomentHijri/AdapterMomentHijri.d.ts +4 -0
- package/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
- package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +4 -0
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
- package/CHANGELOG.md +78 -2
- package/DateCalendar/DateCalendar.js +2 -2
- package/DateCalendar/DayCalendar.d.ts +1 -1
- package/DateCalendar/PickersCalendarHeader.d.ts +1 -1
- package/DateCalendar/PickersCalendarHeader.js +2 -2
- package/DateCalendar/PickersFadeTransitionGroup.d.ts +1 -1
- package/DateCalendar/PickersSlideTransition.d.ts +1 -1
- package/DateField/DateField.js +6 -0
- package/DateField/DateField.types.d.ts +1 -1
- package/DateTimeField/DateTimeField.js +6 -0
- package/DateTimeField/DateTimeField.types.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.js +19 -2
- package/DateTimePicker/DateTimePicker.types.d.ts +4 -3
- package/DateTimePicker/DateTimePickerTabs.d.ts +3 -3
- package/DateTimePicker/DateTimePickerTabs.js +6 -5
- package/DateTimePicker/DateTimePickerToolbar.d.ts +5 -4
- package/DateTimePicker/DateTimePickerToolbar.js +46 -22
- package/DateTimePicker/shared.d.ts +6 -6
- package/DayCalendarSkeleton/DayCalendarSkeleton.d.ts +1 -1
- package/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +53 -10
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +10 -3
- package/DesktopTimePicker/DesktopTimePicker.js +2 -2
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +8 -7
- package/MonthCalendar/MonthCalendar.js +2 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
- package/PickersActionBar/PickersActionBar.d.ts +2 -2
- package/PickersLayout/PickersLayout.d.ts +1 -1
- package/PickersShortcuts/PickersShortcuts.d.ts +2 -2
- package/README.md +5 -5
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -1
- package/TimeClock/Clock.d.ts +1 -1
- package/TimeClock/ClockNumber.d.ts +1 -1
- package/TimeClock/ClockNumbers.d.ts +2 -2
- package/TimeClock/ClockPointer.d.ts +1 -1
- package/TimeField/TimeField.js +6 -0
- package/TimeField/TimeField.types.d.ts +1 -1
- package/TimePicker/TimePickerToolbar.d.ts +2 -2
- package/YearCalendar/YearCalendar.js +2 -2
- package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +13 -0
- package/dateTimeViewRenderers/dateTimeViewRenderers.js +148 -0
- package/dateTimeViewRenderers/index.d.ts +2 -0
- package/dateTimeViewRenderers/index.js +1 -0
- package/dateTimeViewRenderers/package.json +6 -0
- package/dateViewRenderers/dateViewRenderers.d.ts +3 -2
- package/dateViewRenderers/dateViewRenderers.js +2 -2
- package/icons/index.d.ts +42 -0
- package/{internals/components/icons → icons}/index.js +7 -7
- package/icons/package.json +6 -0
- package/index.d.ts +1 -0
- package/index.js +3 -2
- package/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.d.ts +2 -0
- package/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
- package/internals/components/DateTimeViewWrapper/index.d.ts +1 -0
- package/internals/components/DateTimeViewWrapper/index.js +1 -0
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/internals/components/PickersModalDialog.d.ts +1 -1
- package/internals/components/PickersPopper.d.ts +1 -1
- package/internals/components/PickersToolbarButton.d.ts +1 -0
- package/internals/components/PickersToolbarButton.js +8 -3
- package/internals/constants/dimensions.d.ts +1 -0
- package/internals/constants/dimensions.js +2 -1
- package/internals/demo/DemoContainer.d.ts +2 -2
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +2 -2
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
- package/internals/hooks/useField/useField.d.ts +1 -1
- package/internals/hooks/useField/useField.js +8 -3
- package/internals/hooks/useField/useField.types.d.ts +8 -2
- package/internals/hooks/useField/useFieldState.d.ts +1 -1
- package/internals/hooks/useField/useFieldState.js +22 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +2 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +32 -2
- package/internals/hooks/usePicker/usePickerViews.js +8 -10
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +2 -2
- package/internals/hooks/useViews.js +10 -9
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -1
- package/internals/models/fields.d.ts +1 -1
- package/internals/utils/date-utils.d.ts +4 -1
- package/internals/utils/date-utils.js +4 -1
- package/internals/utils/fields.js +1 -1
- package/internals/utils/getDefaultReferenceDate.d.ts +15 -0
- package/internals/utils/getDefaultReferenceDate.js +62 -0
- package/internals/utils/time-utils.d.ts +2 -1
- package/internals/utils/time-utils.js +1 -0
- package/internals/utils/valueManagers.js +21 -3
- package/legacy/AdapterDateFns/AdapterDateFns.js +18 -0
- package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
- package/legacy/AdapterDayjs/AdapterDayjs.js +135 -14
- package/legacy/AdapterLuxon/AdapterLuxon.js +58 -9
- package/legacy/AdapterMoment/AdapterMoment.js +97 -6
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
- package/legacy/DateCalendar/DateCalendar.js +2 -2
- package/legacy/DateCalendar/PickersCalendarHeader.js +2 -2
- package/legacy/DateField/DateField.js +6 -0
- package/legacy/DateTimeField/DateTimeField.js +6 -0
- package/legacy/DateTimePicker/DateTimePicker.js +19 -2
- package/legacy/DateTimePicker/DateTimePickerTabs.js +6 -5
- package/legacy/DateTimePicker/DateTimePickerToolbar.js +51 -23
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +54 -10
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +2 -2
- package/legacy/MonthCalendar/MonthCalendar.js +2 -2
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
- package/legacy/TimeField/TimeField.js +6 -0
- package/legacy/YearCalendar/YearCalendar.js +2 -2
- package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +147 -0
- package/legacy/dateTimeViewRenderers/index.js +1 -0
- package/legacy/dateViewRenderers/dateViewRenderers.js +2 -4
- package/legacy/{internals/components/icons → icons}/index.js +7 -7
- package/legacy/index.js +3 -2
- package/legacy/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
- package/legacy/internals/components/DateTimeViewWrapper/index.js +1 -0
- package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/legacy/internals/components/PickersToolbarButton.js +7 -2
- package/legacy/internals/constants/dimensions.js +2 -1
- package/legacy/internals/hooks/useField/useField.js +8 -3
- package/legacy/internals/hooks/useField/useFieldState.js +22 -2
- package/legacy/internals/hooks/usePicker/usePickerViews.js +4 -4
- package/legacy/internals/hooks/useViews.js +10 -9
- package/legacy/internals/index.js +2 -1
- package/legacy/internals/utils/date-utils.js +7 -0
- package/legacy/internals/utils/fields.js +1 -1
- package/legacy/internals/utils/getDefaultReferenceDate.js +64 -0
- package/legacy/internals/utils/time-utils.js +3 -0
- package/legacy/internals/utils/valueManagers.js +20 -4
- package/legacy/locales/index.js +1 -0
- package/legacy/locales/viVN.js +93 -0
- package/legacy/models/index.js +1 -0
- package/legacy/models/timezone.js +1 -0
- package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +16 -1
- package/legacy/tests/describeGregorianAdapter/testCalculations.js +349 -79
- package/legacy/tests/describeGregorianAdapter/testLocalization.js +3 -3
- package/legacy/tests/describeValidation/testDayViewValidation.js +129 -52
- package/legacy/tests/describeValidation/testMinutesViewValidation.js +3 -10
- package/legacy/tests/describeValidation/testMonthViewValidation.js +3 -10
- package/legacy/tests/describeValidation/testYearViewValidation.js +3 -10
- package/legacy/tests/describeValue/describeValue.js +12 -5
- package/legacy/tests/describeValue/testControlledUnControlled.js +19 -4
- package/legacy/tests/describeValue/testPickerActionBar.js +12 -10
- package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +10 -7
- package/legacy/timeViewRenderers/timeViewRenderers.js +1 -1
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/viVN.d.ts +53 -0
- package/locales/viVN.js +57 -0
- package/models/adapters.d.ts +50 -9
- package/models/fields.d.ts +1 -1
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/timezone.d.ts +1 -0
- package/models/timezone.js +1 -0
- package/modern/AdapterDateFns/AdapterDateFns.js +18 -0
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
- package/modern/AdapterDayjs/AdapterDayjs.js +130 -14
- package/modern/AdapterLuxon/AdapterLuxon.js +57 -9
- package/modern/AdapterMoment/AdapterMoment.js +90 -2
- package/modern/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
- package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
- package/modern/DateCalendar/DateCalendar.js +2 -2
- package/modern/DateCalendar/PickersCalendarHeader.js +2 -2
- package/modern/DateField/DateField.js +6 -0
- package/modern/DateTimeField/DateTimeField.js +6 -0
- package/modern/DateTimePicker/DateTimePicker.js +19 -2
- package/modern/DateTimePicker/DateTimePickerTabs.js +6 -5
- package/modern/DateTimePicker/DateTimePickerToolbar.js +46 -22
- package/modern/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +52 -9
- package/modern/DesktopTimePicker/DesktopTimePicker.js +2 -2
- package/modern/MonthCalendar/MonthCalendar.js +2 -2
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
- package/modern/TimeField/TimeField.js +6 -0
- package/modern/YearCalendar/YearCalendar.js +2 -2
- package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +147 -0
- package/modern/dateTimeViewRenderers/index.js +1 -0
- package/modern/dateViewRenderers/dateViewRenderers.js +2 -2
- package/modern/{internals/components/icons → icons}/index.js +7 -7
- package/modern/index.js +3 -2
- package/modern/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
- package/modern/internals/components/DateTimeViewWrapper/index.js +1 -0
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/modern/internals/components/PickersToolbarButton.js +8 -3
- package/modern/internals/constants/dimensions.js +2 -1
- package/modern/internals/hooks/useField/useField.js +8 -3
- package/modern/internals/hooks/useField/useFieldState.js +22 -2
- package/modern/internals/hooks/usePicker/usePickerViews.js +8 -10
- package/modern/internals/hooks/useViews.js +10 -9
- package/modern/internals/index.js +2 -1
- package/modern/internals/utils/date-utils.js +4 -1
- package/modern/internals/utils/fields.js +1 -1
- package/modern/internals/utils/getDefaultReferenceDate.js +58 -0
- package/modern/internals/utils/time-utils.js +1 -0
- package/modern/internals/utils/valueManagers.js +21 -3
- package/modern/locales/index.js +1 -0
- package/modern/locales/viVN.js +57 -0
- package/modern/models/index.js +1 -0
- package/modern/models/timezone.js +1 -0
- package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +13 -1
- package/modern/tests/describeGregorianAdapter/testCalculations.js +347 -79
- package/modern/tests/describeGregorianAdapter/testLocalization.js +3 -3
- package/modern/tests/describeValidation/testDayViewValidation.js +129 -52
- package/modern/tests/describeValidation/testMinutesViewValidation.js +3 -10
- package/modern/tests/describeValidation/testMonthViewValidation.js +3 -10
- package/modern/tests/describeValidation/testYearViewValidation.js +3 -10
- package/modern/tests/describeValue/describeValue.js +13 -4
- package/modern/tests/describeValue/testControlledUnControlled.js +15 -4
- package/modern/tests/describeValue/testPickerActionBar.js +19 -17
- package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +10 -7
- package/modern/timeViewRenderers/timeViewRenderers.js +1 -1
- package/node/AdapterDateFns/AdapterDateFns.js +18 -0
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
- package/node/AdapterDayjs/AdapterDayjs.js +130 -14
- package/node/AdapterLuxon/AdapterLuxon.js +57 -9
- package/node/AdapterMoment/AdapterMoment.js +90 -2
- package/node/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
- package/node/DateCalendar/DateCalendar.js +2 -2
- package/node/DateCalendar/PickersCalendarHeader.js +2 -2
- package/node/DateField/DateField.js +6 -0
- package/node/DateTimeField/DateTimeField.js +6 -0
- package/node/DateTimePicker/DateTimePicker.js +19 -2
- package/node/DateTimePicker/DateTimePickerTabs.js +6 -5
- package/node/DateTimePicker/DateTimePickerToolbar.js +46 -22
- package/node/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +52 -9
- package/node/DesktopTimePicker/DesktopTimePicker.js +2 -2
- package/node/MonthCalendar/MonthCalendar.js +2 -2
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -2
- package/node/TimeField/TimeField.js +6 -0
- package/node/YearCalendar/YearCalendar.js +2 -2
- package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +156 -0
- package/node/dateTimeViewRenderers/index.js +12 -0
- package/node/dateViewRenderers/dateViewRenderers.js +3 -3
- package/node/{internals/components/icons → icons}/index.js +15 -15
- package/node/index.js +13 -1
- package/node/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +12 -0
- package/node/internals/components/DateTimeViewWrapper/index.js +12 -0
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/node/internals/components/PickersToolbarButton.js +8 -3
- package/node/internals/constants/dimensions.js +4 -2
- package/node/internals/hooks/useField/useField.js +8 -3
- package/node/internals/hooks/useField/useFieldState.js +22 -2
- package/node/internals/hooks/usePicker/usePickerViews.js +8 -10
- package/node/internals/hooks/useViews.js +10 -9
- package/node/internals/index.js +13 -0
- package/node/internals/utils/date-utils.js +7 -2
- package/node/internals/utils/fields.js +1 -1
- package/node/internals/utils/getDefaultReferenceDate.js +66 -0
- package/node/internals/utils/time-utils.js +3 -1
- package/node/internals/utils/valueManagers.js +21 -2
- package/node/locales/index.js +11 -0
- package/node/locales/viVN.js +64 -0
- package/node/models/index.js +11 -0
- package/node/models/timezone.js +5 -0
- package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +13 -1
- package/node/tests/describeGregorianAdapter/testCalculations.js +347 -79
- package/node/tests/describeGregorianAdapter/testLocalization.js +3 -4
- package/node/tests/describeValidation/testDayViewValidation.js +129 -52
- package/node/tests/describeValidation/testMinutesViewValidation.js +3 -10
- package/node/tests/describeValidation/testMonthViewValidation.js +3 -10
- package/node/tests/describeValidation/testYearViewValidation.js +3 -10
- package/node/tests/describeValue/describeValue.js +13 -4
- package/node/tests/describeValue/testControlledUnControlled.js +15 -4
- package/node/tests/describeValue/testPickerActionBar.js +19 -16
- package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +9 -6
- package/node/timeViewRenderers/timeViewRenderers.js +1 -1
- package/package.json +4 -4
- package/tests/describeGregorianAdapter/describeGregorianAdapter.js +14 -1
- package/tests/describeGregorianAdapter/testCalculations.js +347 -79
- package/tests/describeGregorianAdapter/testLocalization.js +3 -3
- package/tests/describeValidation/testDayViewValidation.js +129 -52
- package/tests/describeValidation/testMinutesViewValidation.js +3 -10
- package/tests/describeValidation/testMonthViewValidation.js +3 -10
- package/tests/describeValidation/testYearViewValidation.js +3 -10
- package/tests/describeValue/describeValue.js +13 -4
- package/tests/describeValue/testControlledUnControlled.js +15 -4
- package/tests/describeValue/testPickerActionBar.js +19 -17
- package/tests/describeValue/testPickerOpenCloseLifeCycle.js +10 -7
- package/timeViewRenderers/timeViewRenderers.d.ts +4 -4
- package/timeViewRenderers/timeViewRenderers.js +1 -1
- package/internals/components/icons/index.d.ts +0 -42
|
@@ -125,6 +125,8 @@ var defaultFormats = {
|
|
|
125
125
|
keyboardDateTime12h: 'L hh:mm A',
|
|
126
126
|
keyboardDateTime24h: 'L HH:mm'
|
|
127
127
|
};
|
|
128
|
+
var MISSING_UTC_PLUGIN = ['Missing UTC plugin', 'To be able to use UTC or timezones, you have to enable the `utc` plugin', 'Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-utc'].join('\n');
|
|
129
|
+
var MISSING_TIMEZONE_PLUGIN = ['Missing timezone plugin', 'To be able to use timezones, you have to enable both the `utc` and the `timezone` plugin', 'Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-timezone'].join('\n');
|
|
128
130
|
var withLocale = function withLocale(dayjs, locale) {
|
|
129
131
|
return !locale ? dayjs : function () {
|
|
130
132
|
return dayjs.apply(void 0, arguments).locale(locale);
|
|
@@ -164,6 +166,7 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
164
166
|
instance = _ref.instance;
|
|
165
167
|
_classCallCheck(this, AdapterDayjs);
|
|
166
168
|
this.isMUIAdapter = true;
|
|
169
|
+
this.isTimezoneCompatible = true;
|
|
167
170
|
this.lib = 'dayjs';
|
|
168
171
|
this.rawDayJsInstance = void 0;
|
|
169
172
|
this.dayjs = void 0;
|
|
@@ -174,6 +177,48 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
174
177
|
end: ']'
|
|
175
178
|
};
|
|
176
179
|
this.formatTokenMap = formatTokenMap;
|
|
180
|
+
this.setLocaleToValue = function (value) {
|
|
181
|
+
var expectedLocale = _this.getCurrentLocaleCode();
|
|
182
|
+
if (expectedLocale === value.locale()) {
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
return value.locale(expectedLocale);
|
|
186
|
+
};
|
|
187
|
+
this.hasUTCPlugin = function () {
|
|
188
|
+
return typeof defaultDayjs.utc !== 'undefined';
|
|
189
|
+
};
|
|
190
|
+
this.hasTimezonePlugin = function () {
|
|
191
|
+
return typeof defaultDayjs.tz !== 'undefined';
|
|
192
|
+
};
|
|
193
|
+
this.isSame = function (value, comparing, comparisonTemplate) {
|
|
194
|
+
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
195
|
+
return value.format(comparisonTemplate) === comparingInValueTimezone.format(comparisonTemplate);
|
|
196
|
+
};
|
|
197
|
+
this.createSystemDate = function (value) {
|
|
198
|
+
// TODO v7: Stop using `this.rawDayJsInstance` (drop the `instance` param on the adapters)
|
|
199
|
+
return _this.rawDayJsInstance(value);
|
|
200
|
+
};
|
|
201
|
+
this.createUTCDate = function (value) {
|
|
202
|
+
/* istanbul ignore next */
|
|
203
|
+
if (!_this.hasUTCPlugin()) {
|
|
204
|
+
throw new Error(MISSING_UTC_PLUGIN);
|
|
205
|
+
}
|
|
206
|
+
return defaultDayjs.utc(value);
|
|
207
|
+
};
|
|
208
|
+
this.createTZDate = function (value, timezone) {
|
|
209
|
+
/* istanbul ignore next */
|
|
210
|
+
if (!_this.hasUTCPlugin()) {
|
|
211
|
+
throw new Error(MISSING_UTC_PLUGIN);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* istanbul ignore next */
|
|
215
|
+
if (!_this.hasTimezonePlugin()) {
|
|
216
|
+
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
217
|
+
}
|
|
218
|
+
var cleanTimezone = timezone === 'default' ? undefined : timezone;
|
|
219
|
+
var keepLocalTime = value !== undefined && !value.endsWith('Z');
|
|
220
|
+
return defaultDayjs(value).tz(cleanTimezone, keepLocalTime);
|
|
221
|
+
};
|
|
177
222
|
this.getLocaleFormats = function () {
|
|
178
223
|
var locales = defaultDayjs.Ls;
|
|
179
224
|
var locale = _this.locale || 'en';
|
|
@@ -190,6 +235,63 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
190
235
|
}
|
|
191
236
|
return _this.dayjs(value);
|
|
192
237
|
};
|
|
238
|
+
this.dateWithTimezone = function (value, timezone) {
|
|
239
|
+
if (value === null) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
var parsedValue;
|
|
243
|
+
if (timezone === 'UTC') {
|
|
244
|
+
parsedValue = _this.createUTCDate(value);
|
|
245
|
+
} else if (timezone === 'system' || timezone === 'default' && !_this.hasTimezonePlugin()) {
|
|
246
|
+
parsedValue = _this.createSystemDate(value);
|
|
247
|
+
} else {
|
|
248
|
+
parsedValue = _this.createTZDate(value, timezone);
|
|
249
|
+
}
|
|
250
|
+
if (_this.locale === undefined) {
|
|
251
|
+
return parsedValue;
|
|
252
|
+
}
|
|
253
|
+
return parsedValue.locale(_this.locale);
|
|
254
|
+
};
|
|
255
|
+
this.getTimezone = function (value) {
|
|
256
|
+
if (_this.hasUTCPlugin() && value.isUTC()) {
|
|
257
|
+
return 'UTC';
|
|
258
|
+
}
|
|
259
|
+
if (_this.hasTimezonePlugin()) {
|
|
260
|
+
var _value$$x;
|
|
261
|
+
// @ts-ignore
|
|
262
|
+
var zone = (_value$$x = value.$x) == null ? void 0 : _value$$x.$timezone;
|
|
263
|
+
return zone != null ? zone : 'system';
|
|
264
|
+
}
|
|
265
|
+
return 'system';
|
|
266
|
+
};
|
|
267
|
+
this.setTimezone = function (value, timezone) {
|
|
268
|
+
if (_this.getTimezone(value) === timezone) {
|
|
269
|
+
return value;
|
|
270
|
+
}
|
|
271
|
+
if (timezone === 'UTC') {
|
|
272
|
+
/* istanbul ignore next */
|
|
273
|
+
if (!_this.hasUTCPlugin()) {
|
|
274
|
+
throw new Error(MISSING_UTC_PLUGIN);
|
|
275
|
+
}
|
|
276
|
+
return value.utc();
|
|
277
|
+
}
|
|
278
|
+
if (timezone === 'system') {
|
|
279
|
+
if (_this.hasUTCPlugin()) {
|
|
280
|
+
return value.local();
|
|
281
|
+
}
|
|
282
|
+
return value;
|
|
283
|
+
}
|
|
284
|
+
if (!_this.hasTimezonePlugin()) {
|
|
285
|
+
if (timezone === 'default') {
|
|
286
|
+
return value;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/* istanbul ignore next */
|
|
290
|
+
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
291
|
+
}
|
|
292
|
+
var cleanZone = timezone === 'default' ? undefined : timezone;
|
|
293
|
+
return defaultDayjs.tz(value, cleanZone);
|
|
294
|
+
};
|
|
193
295
|
this.toJsDate = function (value) {
|
|
194
296
|
return value.toDate();
|
|
195
297
|
};
|
|
@@ -254,40 +356,52 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
254
356
|
return _this.dayjs(value).isSame(comparing);
|
|
255
357
|
};
|
|
256
358
|
this.isSameYear = function (value, comparing) {
|
|
257
|
-
return
|
|
359
|
+
return _this.isSame(value, comparing, 'YYYY');
|
|
258
360
|
};
|
|
259
361
|
this.isSameMonth = function (value, comparing) {
|
|
260
|
-
return
|
|
362
|
+
return _this.isSame(value, comparing, 'YYYY-MM');
|
|
261
363
|
};
|
|
262
364
|
this.isSameDay = function (value, comparing) {
|
|
263
|
-
return
|
|
365
|
+
return _this.isSame(value, comparing, 'YYYY-MM-DD');
|
|
264
366
|
};
|
|
265
367
|
this.isSameHour = function (value, comparing) {
|
|
266
368
|
return value.isSame(comparing, 'hour');
|
|
267
369
|
};
|
|
268
370
|
this.isAfter = function (value, comparing) {
|
|
269
|
-
return value
|
|
371
|
+
return value > comparing;
|
|
270
372
|
};
|
|
271
373
|
this.isAfterYear = function (value, comparing) {
|
|
272
|
-
|
|
374
|
+
if (!_this.hasUTCPlugin()) {
|
|
375
|
+
return value.isAfter(comparing, 'year');
|
|
376
|
+
}
|
|
377
|
+
return !_this.isSameYear(value, comparing) && value.utc() > comparing.utc();
|
|
273
378
|
};
|
|
274
379
|
this.isAfterDay = function (value, comparing) {
|
|
275
|
-
|
|
380
|
+
if (!_this.hasUTCPlugin()) {
|
|
381
|
+
return value.isAfter(comparing, 'day');
|
|
382
|
+
}
|
|
383
|
+
return !_this.isSameDay(value, comparing) && value.utc() > comparing.utc();
|
|
276
384
|
};
|
|
277
385
|
this.isBefore = function (value, comparing) {
|
|
278
|
-
return value
|
|
386
|
+
return value < comparing;
|
|
279
387
|
};
|
|
280
388
|
this.isBeforeYear = function (value, comparing) {
|
|
281
|
-
|
|
389
|
+
if (!_this.hasUTCPlugin()) {
|
|
390
|
+
return value.isBefore(comparing, 'year');
|
|
391
|
+
}
|
|
392
|
+
return !_this.isSameYear(value, comparing) && value.utc() < comparing.utc();
|
|
282
393
|
};
|
|
283
394
|
this.isBeforeDay = function (value, comparing) {
|
|
284
|
-
|
|
395
|
+
if (!_this.hasUTCPlugin()) {
|
|
396
|
+
return value.isBefore(comparing, 'day');
|
|
397
|
+
}
|
|
398
|
+
return !_this.isSameDay(value, comparing) && value.utc() < comparing.utc();
|
|
285
399
|
};
|
|
286
400
|
this.isWithinRange = function (value, _ref2) {
|
|
287
401
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
288
402
|
start = _ref3[0],
|
|
289
403
|
end = _ref3[1];
|
|
290
|
-
return value
|
|
404
|
+
return value >= start && value <= end;
|
|
291
405
|
};
|
|
292
406
|
this.startOfYear = function (value) {
|
|
293
407
|
return value.startOf('year');
|
|
@@ -352,6 +466,9 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
352
466
|
this.getSeconds = function (value) {
|
|
353
467
|
return value.second();
|
|
354
468
|
};
|
|
469
|
+
this.getMilliseconds = function (value) {
|
|
470
|
+
return value.millisecond();
|
|
471
|
+
};
|
|
355
472
|
this.setYear = function (value, year) {
|
|
356
473
|
return value.set('year', year);
|
|
357
474
|
};
|
|
@@ -370,6 +487,9 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
370
487
|
this.setSeconds = function (value, seconds) {
|
|
371
488
|
return value.set('second', seconds);
|
|
372
489
|
};
|
|
490
|
+
this.setMilliseconds = function (value, milliseconds) {
|
|
491
|
+
return value.set('millisecond', milliseconds);
|
|
492
|
+
};
|
|
373
493
|
this.getDaysInMonth = function (value) {
|
|
374
494
|
return value.daysInMonth();
|
|
375
495
|
};
|
|
@@ -398,12 +518,13 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
398
518
|
});
|
|
399
519
|
};
|
|
400
520
|
this.getWeekArray = function (value) {
|
|
401
|
-
var
|
|
402
|
-
var
|
|
521
|
+
var cleanLocale = _this.setLocaleToValue(value);
|
|
522
|
+
var start = cleanLocale.startOf('month').startOf('week');
|
|
523
|
+
var end = cleanLocale.endOf('month').endOf('week');
|
|
403
524
|
var count = 0;
|
|
404
525
|
var current = start;
|
|
405
526
|
var nestedWeeks = [];
|
|
406
|
-
while (current
|
|
527
|
+
while (current < end) {
|
|
407
528
|
var weekNumber = Math.floor(count / 7);
|
|
408
529
|
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
409
530
|
nestedWeeks[weekNumber].push(current);
|
|
@@ -420,7 +541,7 @@ export var AdapterDayjs = /*#__PURE__*/_createClass(function AdapterDayjs() {
|
|
|
420
541
|
var endDate = end.endOf('year');
|
|
421
542
|
var years = [];
|
|
422
543
|
var current = startDate;
|
|
423
|
-
while (current
|
|
544
|
+
while (current < endDate) {
|
|
424
545
|
years.push(current);
|
|
425
546
|
current = current.add(1, 'year');
|
|
426
547
|
}
|
|
@@ -172,6 +172,7 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
172
172
|
formats = _ref.formats;
|
|
173
173
|
_classCallCheck(this, AdapterLuxon);
|
|
174
174
|
this.isMUIAdapter = true;
|
|
175
|
+
this.isTimezoneCompatible = true;
|
|
175
176
|
this.lib = 'luxon';
|
|
176
177
|
this.locale = void 0;
|
|
177
178
|
this.formats = void 0;
|
|
@@ -202,6 +203,38 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
202
203
|
locale: _this.locale
|
|
203
204
|
});
|
|
204
205
|
};
|
|
206
|
+
this.dateWithTimezone = function (value, timezone) {
|
|
207
|
+
if (value === null) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
if (typeof value === 'undefined') {
|
|
211
|
+
// @ts-ignore
|
|
212
|
+
return DateTime.fromJSDate(new Date(), {
|
|
213
|
+
locale: _this.locale,
|
|
214
|
+
zone: timezone
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// @ts-ignore
|
|
219
|
+
return DateTime.fromISO(value, {
|
|
220
|
+
locale: _this.locale,
|
|
221
|
+
zone: timezone
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
this.getTimezone = function (value) {
|
|
225
|
+
var _value$zoneName;
|
|
226
|
+
// When using the system zone, we want to return "system", not something like "Europe/Paris"
|
|
227
|
+
if (value.zone.type === 'system') {
|
|
228
|
+
return 'system';
|
|
229
|
+
}
|
|
230
|
+
return (_value$zoneName = value.zoneName) != null ? _value$zoneName : 'system';
|
|
231
|
+
};
|
|
232
|
+
this.setTimezone = function (value, timezone) {
|
|
233
|
+
if (!value.zone.equals(Info.normalizeZone(timezone))) {
|
|
234
|
+
return value.setZone(timezone);
|
|
235
|
+
}
|
|
236
|
+
return value;
|
|
237
|
+
};
|
|
205
238
|
this.toJsDate = function (value) {
|
|
206
239
|
return value.toJSDate();
|
|
207
240
|
};
|
|
@@ -294,40 +327,48 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
294
327
|
if (value === null || comparing === null) {
|
|
295
328
|
return false;
|
|
296
329
|
}
|
|
297
|
-
return _this.date(value)
|
|
330
|
+
return +_this.date(value) === +_this.date(comparing);
|
|
298
331
|
};
|
|
299
332
|
this.isSameYear = function (value, comparing) {
|
|
300
|
-
|
|
333
|
+
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
334
|
+
return value.hasSame(comparingInValueTimezone, 'year');
|
|
301
335
|
};
|
|
302
336
|
this.isSameMonth = function (value, comparing) {
|
|
303
|
-
|
|
337
|
+
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
338
|
+
return value.hasSame(comparingInValueTimezone, 'month');
|
|
304
339
|
};
|
|
305
340
|
this.isSameDay = function (value, comparing) {
|
|
306
|
-
|
|
341
|
+
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
342
|
+
return value.hasSame(comparingInValueTimezone, 'day');
|
|
307
343
|
};
|
|
308
344
|
this.isSameHour = function (value, comparing) {
|
|
309
|
-
|
|
345
|
+
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
346
|
+
return value.hasSame(comparingInValueTimezone, 'hour');
|
|
310
347
|
};
|
|
311
348
|
this.isAfter = function (value, comparing) {
|
|
312
349
|
return value > comparing;
|
|
313
350
|
};
|
|
314
351
|
this.isAfterYear = function (value, comparing) {
|
|
315
|
-
var
|
|
352
|
+
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
353
|
+
var diff = value.diff(comparingInValueTimezone.endOf('year'), 'years').toObject();
|
|
316
354
|
return diff.years > 0;
|
|
317
355
|
};
|
|
318
356
|
this.isAfterDay = function (value, comparing) {
|
|
319
|
-
var
|
|
357
|
+
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
358
|
+
var diff = value.diff(comparingInValueTimezone.endOf('day'), 'days').toObject();
|
|
320
359
|
return diff.days > 0;
|
|
321
360
|
};
|
|
322
361
|
this.isBefore = function (value, comparing) {
|
|
323
362
|
return value < comparing;
|
|
324
363
|
};
|
|
325
364
|
this.isBeforeYear = function (value, comparing) {
|
|
326
|
-
var
|
|
365
|
+
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
366
|
+
var diff = value.diff(comparingInValueTimezone.startOf('year'), 'years').toObject();
|
|
327
367
|
return diff.years < 0;
|
|
328
368
|
};
|
|
329
369
|
this.isBeforeDay = function (value, comparing) {
|
|
330
|
-
var
|
|
370
|
+
var comparingInValueTimezone = _this.setTimezone(comparing, _this.getTimezone(value));
|
|
371
|
+
var diff = value.diff(comparingInValueTimezone.startOf('day'), 'days').toObject();
|
|
331
372
|
return diff.days < 0;
|
|
332
373
|
};
|
|
333
374
|
this.isWithinRange = function (value, _ref2) {
|
|
@@ -414,6 +455,9 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
414
455
|
this.getSeconds = function (value) {
|
|
415
456
|
return value.get('second');
|
|
416
457
|
};
|
|
458
|
+
this.getMilliseconds = function (value) {
|
|
459
|
+
return value.get('millisecond');
|
|
460
|
+
};
|
|
417
461
|
this.setYear = function (value, year) {
|
|
418
462
|
return value.set({
|
|
419
463
|
year: year
|
|
@@ -444,6 +488,11 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
444
488
|
second: seconds
|
|
445
489
|
});
|
|
446
490
|
};
|
|
491
|
+
this.setMilliseconds = function (value, milliseconds) {
|
|
492
|
+
return value.set({
|
|
493
|
+
millisecond: milliseconds
|
|
494
|
+
});
|
|
495
|
+
};
|
|
447
496
|
this.getDaysInMonth = function (value) {
|
|
448
497
|
return value.daysInMonth;
|
|
449
498
|
};
|
|
@@ -124,6 +124,7 @@ var defaultFormats = {
|
|
|
124
124
|
keyboardDateTime12h: 'L hh:mm A',
|
|
125
125
|
keyboardDateTime24h: 'L HH:mm'
|
|
126
126
|
};
|
|
127
|
+
var MISSING_TIMEZONE_PLUGIN = ['Missing timezone plugin', 'To be able to use timezones, you have to pass the default export from `moment-timezone` to the `dateLibInstance` prop of `LocalizationProvider`', 'Find more information on https://mui.com/x/react-date-pickers/timezone/#moment-and-timezone'].join('\n');
|
|
127
128
|
|
|
128
129
|
/**
|
|
129
130
|
* Based on `@date-io/moment`
|
|
@@ -158,6 +159,7 @@ export var AdapterMoment = /*#__PURE__*/_createClass(function AdapterMoment() {
|
|
|
158
159
|
instance = _ref.instance;
|
|
159
160
|
_classCallCheck(this, AdapterMoment);
|
|
160
161
|
this.isMUIAdapter = true;
|
|
162
|
+
this.isTimezoneCompatible = true;
|
|
161
163
|
this.lib = 'moment';
|
|
162
164
|
this.moment = void 0;
|
|
163
165
|
this.locale = void 0;
|
|
@@ -167,6 +169,41 @@ export var AdapterMoment = /*#__PURE__*/_createClass(function AdapterMoment() {
|
|
|
167
169
|
end: ']'
|
|
168
170
|
};
|
|
169
171
|
this.formatTokenMap = formatTokenMap;
|
|
172
|
+
this.setLocaleToValue = function (value) {
|
|
173
|
+
var expectedLocale = _this.getCurrentLocaleCode();
|
|
174
|
+
if (expectedLocale === value.locale()) {
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
return value.locale(expectedLocale);
|
|
178
|
+
};
|
|
179
|
+
this.hasTimezonePlugin = function () {
|
|
180
|
+
return typeof _this.moment.tz !== 'undefined';
|
|
181
|
+
};
|
|
182
|
+
this.createSystemDate = function (value) {
|
|
183
|
+
var parsedValue = _this.moment(value).local();
|
|
184
|
+
if (_this.locale === undefined) {
|
|
185
|
+
return parsedValue;
|
|
186
|
+
}
|
|
187
|
+
return parsedValue.locale(_this.locale);
|
|
188
|
+
};
|
|
189
|
+
this.createUTCDate = function (value) {
|
|
190
|
+
var parsedValue = _this.moment.utc(value);
|
|
191
|
+
if (_this.locale === undefined) {
|
|
192
|
+
return parsedValue;
|
|
193
|
+
}
|
|
194
|
+
return parsedValue.locale(_this.locale);
|
|
195
|
+
};
|
|
196
|
+
this.createTZDate = function (value, timezone) {
|
|
197
|
+
/* istanbul ignore next */
|
|
198
|
+
if (!_this.hasTimezonePlugin()) {
|
|
199
|
+
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
200
|
+
}
|
|
201
|
+
var parsedValue = timezone === 'default' ? _this.moment(value) : _this.moment.tz(value, timezone);
|
|
202
|
+
if (_this.locale === undefined) {
|
|
203
|
+
return parsedValue;
|
|
204
|
+
}
|
|
205
|
+
return parsedValue.locale(_this.locale);
|
|
206
|
+
};
|
|
170
207
|
this.date = function (value) {
|
|
171
208
|
if (value === null) {
|
|
172
209
|
return null;
|
|
@@ -175,6 +212,53 @@ export var AdapterMoment = /*#__PURE__*/_createClass(function AdapterMoment() {
|
|
|
175
212
|
moment.locale(_this.getCurrentLocaleCode());
|
|
176
213
|
return moment;
|
|
177
214
|
};
|
|
215
|
+
this.dateWithTimezone = function (value, timezone) {
|
|
216
|
+
if (value === null) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
if (timezone === 'UTC') {
|
|
220
|
+
return _this.createUTCDate(value);
|
|
221
|
+
}
|
|
222
|
+
if (timezone === 'system' || timezone === 'default' && !_this.hasTimezonePlugin()) {
|
|
223
|
+
return _this.createSystemDate(value);
|
|
224
|
+
}
|
|
225
|
+
return _this.createTZDate(value, timezone);
|
|
226
|
+
};
|
|
227
|
+
this.getTimezone = function (value) {
|
|
228
|
+
var _value$_z, _ref2, _this$moment$defaultZ;
|
|
229
|
+
if (value.isUTC()) {
|
|
230
|
+
return 'UTC';
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// @ts-ignore
|
|
234
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
235
|
+
var zone = (_value$_z = value._z) == null ? void 0 : _value$_z.name;
|
|
236
|
+
|
|
237
|
+
// @ts-ignore
|
|
238
|
+
return (_ref2 = zone != null ? zone : (_this$moment$defaultZ = _this.moment.defaultZone) == null ? void 0 : _this$moment$defaultZ.name) != null ? _ref2 : 'system';
|
|
239
|
+
};
|
|
240
|
+
this.setTimezone = function (value, timezone) {
|
|
241
|
+
var _this$moment$defaultZ2, _this$moment$defaultZ3;
|
|
242
|
+
if (timezone === 'UTC') {
|
|
243
|
+
return value.clone().utc();
|
|
244
|
+
}
|
|
245
|
+
if (timezone === 'system') {
|
|
246
|
+
return value.clone().local();
|
|
247
|
+
}
|
|
248
|
+
if (!_this.hasTimezonePlugin()) {
|
|
249
|
+
if (timezone === 'default') {
|
|
250
|
+
return value;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/* istanbul ignore next */
|
|
254
|
+
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
255
|
+
}
|
|
256
|
+
var cleanZone = timezone === 'default' ? // @ts-ignore
|
|
257
|
+
(_this$moment$defaultZ2 = (_this$moment$defaultZ3 = _this.moment.defaultZone) == null ? void 0 : _this$moment$defaultZ3.name) != null ? _this$moment$defaultZ2 : 'system' : timezone;
|
|
258
|
+
var newValue = value.clone();
|
|
259
|
+
newValue.tz(cleanZone);
|
|
260
|
+
return newValue;
|
|
261
|
+
};
|
|
178
262
|
this.toJsDate = function (value) {
|
|
179
263
|
return value.toDate();
|
|
180
264
|
};
|
|
@@ -269,10 +353,10 @@ export var AdapterMoment = /*#__PURE__*/_createClass(function AdapterMoment() {
|
|
|
269
353
|
this.isBeforeDay = function (value, comparing) {
|
|
270
354
|
return value.isBefore(comparing, 'day');
|
|
271
355
|
};
|
|
272
|
-
this.isWithinRange = function (value,
|
|
273
|
-
var
|
|
274
|
-
start =
|
|
275
|
-
end =
|
|
356
|
+
this.isWithinRange = function (value, _ref3) {
|
|
357
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
358
|
+
start = _ref4[0],
|
|
359
|
+
end = _ref4[1];
|
|
276
360
|
return value.isBetween(start, end, null, '[]');
|
|
277
361
|
};
|
|
278
362
|
this.startOfYear = function (value) {
|
|
@@ -338,6 +422,9 @@ export var AdapterMoment = /*#__PURE__*/_createClass(function AdapterMoment() {
|
|
|
338
422
|
this.getSeconds = function (value) {
|
|
339
423
|
return value.get('seconds');
|
|
340
424
|
};
|
|
425
|
+
this.getMilliseconds = function (value) {
|
|
426
|
+
return value.get('milliseconds');
|
|
427
|
+
};
|
|
341
428
|
this.setYear = function (value, year) {
|
|
342
429
|
return value.clone().year(year);
|
|
343
430
|
};
|
|
@@ -356,6 +443,9 @@ export var AdapterMoment = /*#__PURE__*/_createClass(function AdapterMoment() {
|
|
|
356
443
|
this.setSeconds = function (value, seconds) {
|
|
357
444
|
return value.clone().seconds(seconds);
|
|
358
445
|
};
|
|
446
|
+
this.setMilliseconds = function (value, milliseconds) {
|
|
447
|
+
return value.clone().milliseconds(milliseconds);
|
|
448
|
+
};
|
|
359
449
|
this.getDaysInMonth = function (value) {
|
|
360
450
|
return value.daysInMonth();
|
|
361
451
|
};
|
|
@@ -381,8 +471,9 @@ export var AdapterMoment = /*#__PURE__*/_createClass(function AdapterMoment() {
|
|
|
381
471
|
return defaultMoment.weekdaysShort(true);
|
|
382
472
|
};
|
|
383
473
|
this.getWeekArray = function (value) {
|
|
384
|
-
var
|
|
385
|
-
var
|
|
474
|
+
var cleanLocale = _this.setLocaleToValue(value);
|
|
475
|
+
var start = cleanLocale.clone().startOf('month').startOf('week');
|
|
476
|
+
var end = cleanLocale.clone().endOf('month').endOf('week');
|
|
386
477
|
var count = 0;
|
|
387
478
|
var current = start;
|
|
388
479
|
var nestedWeeks = [];
|
|
@@ -155,6 +155,7 @@ export var AdapterMomentHijri = /*#__PURE__*/function (_AdapterMoment) {
|
|
|
155
155
|
});
|
|
156
156
|
_this.lib = 'moment-hijri';
|
|
157
157
|
_this.moment = void 0;
|
|
158
|
+
_this.isTimezoneCompatible = false;
|
|
158
159
|
_this.formatTokenMap = formatTokenMap;
|
|
159
160
|
_this.date = function (value) {
|
|
160
161
|
if (value === null) {
|
|
@@ -162,6 +163,15 @@ export var AdapterMomentHijri = /*#__PURE__*/function (_AdapterMoment) {
|
|
|
162
163
|
}
|
|
163
164
|
return _this.moment(value).locale('ar-SA');
|
|
164
165
|
};
|
|
166
|
+
_this.dateWithTimezone = function (value) {
|
|
167
|
+
return _this.date(value);
|
|
168
|
+
};
|
|
169
|
+
_this.getTimezone = function () {
|
|
170
|
+
return 'default';
|
|
171
|
+
};
|
|
172
|
+
_this.setTimezone = function (value) {
|
|
173
|
+
return value;
|
|
174
|
+
};
|
|
165
175
|
_this.parse = function (value, format) {
|
|
166
176
|
if (value === '') {
|
|
167
177
|
return null;
|
|
@@ -151,6 +151,7 @@ export var AdapterMomentJalaali = /*#__PURE__*/function (_AdapterMoment) {
|
|
|
151
151
|
locale: 'fa',
|
|
152
152
|
instance: instance
|
|
153
153
|
});
|
|
154
|
+
_this.isTimezoneCompatible = false;
|
|
154
155
|
_this.lib = 'moment-jalaali';
|
|
155
156
|
_this.moment = void 0;
|
|
156
157
|
_this.formatTokenMap = formatTokenMap;
|
|
@@ -160,6 +161,15 @@ export var AdapterMomentJalaali = /*#__PURE__*/function (_AdapterMoment) {
|
|
|
160
161
|
}
|
|
161
162
|
return _this.moment(value).locale('fa');
|
|
162
163
|
};
|
|
164
|
+
_this.dateWithTimezone = function (value) {
|
|
165
|
+
return _this.date(value);
|
|
166
|
+
};
|
|
167
|
+
_this.getTimezone = function () {
|
|
168
|
+
return 'default';
|
|
169
|
+
};
|
|
170
|
+
_this.setTimezone = function (value) {
|
|
171
|
+
return value;
|
|
172
|
+
};
|
|
163
173
|
_this.parseISO = function (isoString) {
|
|
164
174
|
return _this.moment(isoString).locale('fa');
|
|
165
175
|
};
|
|
@@ -213,9 +213,9 @@ export var DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(in
|
|
|
213
213
|
var handleSelectedDayChange = useEventCallback(function (day) {
|
|
214
214
|
if (value && day) {
|
|
215
215
|
// If there is a date already selected, then we want to keep its time
|
|
216
|
-
return
|
|
216
|
+
return handleValueChange(mergeDateAndTime(utils, day, value), 'finish');
|
|
217
217
|
}
|
|
218
|
-
return
|
|
218
|
+
return handleValueChange(day, 'finish');
|
|
219
219
|
});
|
|
220
220
|
React.useEffect(function () {
|
|
221
221
|
if (value != null && utils.isValid(value)) {
|
|
@@ -10,7 +10,7 @@ import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
|
10
10
|
import IconButton from '@mui/material/IconButton';
|
|
11
11
|
import { useLocaleText, useUtils } from '../internals/hooks/useUtils';
|
|
12
12
|
import { PickersFadeTransitionGroup } from './PickersFadeTransitionGroup';
|
|
13
|
-
import {
|
|
13
|
+
import { ArrowDropDownIcon } from '../icons';
|
|
14
14
|
import { PickersArrowSwitcher } from '../internals/components/PickersArrowSwitcher';
|
|
15
15
|
import { usePreviousMonthDisabled, useNextMonthDisabled } from '../internals/hooks/date-helpers-hooks';
|
|
16
16
|
import { getPickersCalendarHeaderUtilityClass, pickersCalendarHeaderClasses } from './pickersCalendarHeaderClasses';
|
|
@@ -87,7 +87,7 @@ var PickersCalendarHeaderSwitchViewButton = styled(IconButton, {
|
|
|
87
87
|
transform: 'rotate(180deg)'
|
|
88
88
|
}));
|
|
89
89
|
});
|
|
90
|
-
var PickersCalendarHeaderSwitchViewIcon = styled(
|
|
90
|
+
var PickersCalendarHeaderSwitchViewIcon = styled(ArrowDropDownIcon, {
|
|
91
91
|
name: 'MuiPickersCalendarHeader',
|
|
92
92
|
slot: 'SwitchViewIcon',
|
|
93
93
|
overridesResolver: function overridesResolver(_, styles) {
|
|
@@ -223,6 +223,12 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
|
|
|
223
223
|
* @default false
|
|
224
224
|
*/
|
|
225
225
|
readOnly: PropTypes.bool,
|
|
226
|
+
/**
|
|
227
|
+
* The date used to generate a part of the date-time that is not present in the format when both `value` and `defaultValue` are not present.
|
|
228
|
+
* For example, on time fields it will be used to determine the date to set.
|
|
229
|
+
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used.
|
|
230
|
+
*/
|
|
231
|
+
referenceDate: PropTypes.any,
|
|
226
232
|
/**
|
|
227
233
|
* If `true`, the label is displayed as required and the `input` element is required.
|
|
228
234
|
* @default false
|
|
@@ -256,6 +256,12 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
256
256
|
* @default false
|
|
257
257
|
*/
|
|
258
258
|
readOnly: PropTypes.bool,
|
|
259
|
+
/**
|
|
260
|
+
* The date used to generate a part of the date-time that is not present in the format when both `value` and `defaultValue` are not present.
|
|
261
|
+
* For example, on time fields it will be used to determine the date to set.
|
|
262
|
+
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used.
|
|
263
|
+
*/
|
|
264
|
+
referenceDate: PropTypes.any,
|
|
259
265
|
/**
|
|
260
266
|
* If `true`, the label is displayed as required and the `input` element is required.
|
|
261
267
|
* @default false
|