@mui/x-date-pickers 7.0.0-beta.7 → 7.1.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.js +1 -1
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +1 -2
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -4
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -1
- package/AdapterDayjs/AdapterDayjs.js +2 -4
- package/AdapterLuxon/AdapterLuxon.js +12 -9
- package/AdapterMoment/AdapterMoment.js +5 -6
- package/CHANGELOG.md +266 -12
- package/DateCalendar/DateCalendar.js +14 -16
- package/DateCalendar/DayCalendar.js +5 -6
- package/DateField/DateField.js +3 -4
- package/DatePicker/DatePicker.js +1 -1
- package/DatePicker/DatePickerToolbar.js +11 -6
- package/DatePicker/shared.d.ts +2 -1
- package/DatePicker/shared.js +3 -5
- package/DateTimeField/DateTimeField.js +3 -4
- package/DateTimePicker/DateTimePicker.js +1 -1
- package/DateTimePicker/DateTimePickerToolbar.js +98 -46
- package/DateTimePicker/shared.d.ts +2 -1
- package/DateTimePicker/shared.js +11 -13
- package/DayCalendarSkeleton/DayCalendarSkeleton.js +12 -8
- package/DesktopDatePicker/DesktopDatePicker.js +7 -11
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +72 -37
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +12 -0
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +101 -0
- package/DesktopDateTimePicker/index.d.ts +1 -0
- package/DesktopDateTimePicker/index.js +2 -1
- package/DesktopTimePicker/DesktopTimePicker.js +8 -12
- package/DigitalClock/DigitalClock.js +16 -9
- package/LocalizationProvider/LocalizationProvider.js +1 -2
- package/MobileDatePicker/MobileDatePicker.js +6 -10
- package/MobileDateTimePicker/MobileDateTimePicker.js +8 -12
- package/MobileTimePicker/MobileTimePicker.js +6 -10
- package/MonthCalendar/MonthCalendar.js +4 -4
- package/MonthCalendar/PickersMonth.js +13 -8
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +16 -9
- package/PickersActionBar/PickersActionBar.js +1 -1
- package/PickersCalendarHeader/PickersCalendarHeader.js +17 -14
- package/PickersDay/PickersDay.js +30 -15
- package/PickersLayout/PickersLayout.js +31 -17
- package/PickersLayout/usePickerLayout.js +8 -9
- package/PickersSectionList/PickersSectionList.js +9 -11
- package/PickersTextField/PickersFilledInput/PickersFilledInput.js +138 -74
- package/PickersTextField/PickersInput/PickersInput.js +77 -55
- package/PickersTextField/PickersInputBase/PickersInputBase.js +67 -28
- package/PickersTextField/PickersInputBase/PickersInputBase.types.d.ts +7 -0
- package/PickersTextField/PickersOutlinedInput/Outline.js +58 -41
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +33 -14
- package/README.md +1 -1
- package/StaticDatePicker/StaticDatePicker.js +4 -5
- package/StaticDateTimePicker/StaticDateTimePicker.js +6 -7
- package/StaticTimePicker/StaticTimePicker.js +3 -4
- package/TimeClock/Clock.js +48 -35
- package/TimeClock/ClockNumber.js +12 -7
- package/TimeClock/ClockPointer.js +23 -13
- package/TimeClock/TimeClock.js +1 -1
- package/TimeField/TimeField.js +2 -3
- package/TimePicker/TimePickerToolbar.js +25 -16
- package/TimePicker/shared.d.ts +2 -1
- package/TimePicker/shared.js +5 -7
- package/YearCalendar/PickersYear.js +12 -6
- package/YearCalendar/YearCalendar.js +5 -6
- package/hooks/useClearableField.js +6 -7
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +19 -15
- package/internals/components/PickersModalDialog.js +6 -7
- package/internals/components/PickersPopper.js +25 -24
- package/internals/components/PickersToolbar.js +42 -24
- package/internals/hooks/date-helpers-hooks.js +1 -1
- package/internals/hooks/defaultizedFieldProps.js +15 -18
- package/internals/hooks/useClockReferenceDate.js +1 -1
- package/internals/hooks/useDesktopPicker/index.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +11 -12
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
- package/internals/hooks/useField/buildSectionsFromFormat.js +35 -31
- package/internals/hooks/useField/useField.js +6 -4
- package/internals/hooks/useField/useField.types.d.ts +1 -0
- package/internals/hooks/useField/useField.utils.js +4 -7
- package/internals/hooks/useField/useFieldCharacterEditing.js +1 -2
- package/internals/hooks/useField/useFieldState.js +1 -1
- package/internals/hooks/useField/useFieldV6TextField.js +17 -18
- package/internals/hooks/useField/useFieldV7TextField.js +9 -11
- package/internals/hooks/useMobilePicker/useMobilePicker.js +7 -8
- package/internals/hooks/useOpenState.js +1 -1
- package/internals/hooks/usePicker/index.d.ts +1 -0
- package/internals/hooks/usePicker/usePickerViews.d.ts +4 -2
- package/internals/hooks/usePicker/usePickerViews.js +1 -2
- package/internals/hooks/useStaticPicker/useStaticPicker.js +13 -17
- package/internals/hooks/useValueWithTimezone.js +5 -6
- package/internals/hooks/useViews.js +3 -4
- package/internals/index.d.ts +1 -1
- package/internals/models/validation.d.ts +1 -1
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +3 -3
- package/internals/utils/date-time-utils.js +2 -5
- package/internals/utils/fields.js +1 -1
- package/internals/utils/getDefaultReferenceDate.js +2 -6
- package/internals/utils/views.js +1 -1
- package/locales/csCZ.js +1 -4
- package/locales/daDK.js +1 -4
- package/locales/deDE.js +1 -4
- package/locales/huHU.js +1 -4
- package/locales/itIT.js +16 -20
- package/locales/jaJP.js +1 -4
- package/locales/roRO.js +1 -4
- package/locales/skSK.js +1 -4
- package/locales/zhHK.js +14 -17
- package/modern/AdapterLuxon/AdapterLuxon.js +9 -4
- package/modern/DateCalendar/DateCalendar.js +1 -1
- package/modern/DateField/DateField.js +1 -1
- package/modern/DatePicker/DatePicker.js +1 -1
- package/modern/DatePicker/DatePickerToolbar.js +11 -6
- package/modern/DateTimeField/DateTimeField.js +1 -1
- package/modern/DateTimePicker/DateTimePicker.js +1 -1
- package/modern/DateTimePicker/DateTimePickerToolbar.js +97 -45
- package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +12 -8
- package/modern/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +64 -25
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +101 -0
- package/modern/DesktopDateTimePicker/index.js +2 -1
- package/modern/DigitalClock/DigitalClock.js +14 -6
- package/modern/MobileDatePicker/MobileDatePicker.js +1 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/modern/MonthCalendar/PickersMonth.js +12 -6
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +13 -4
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +13 -9
- package/modern/PickersDay/PickersDay.js +30 -15
- package/modern/PickersLayout/PickersLayout.js +31 -17
- package/modern/PickersTextField/PickersFilledInput/PickersFilledInput.js +137 -72
- package/modern/PickersTextField/PickersInput/PickersInput.js +76 -54
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +64 -24
- package/modern/PickersTextField/PickersOutlinedInput/Outline.js +58 -41
- package/modern/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +31 -12
- package/modern/StaticDatePicker/StaticDatePicker.js +1 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/modern/TimeClock/Clock.js +48 -35
- package/modern/TimeClock/ClockNumber.js +12 -7
- package/modern/TimeClock/ClockPointer.js +23 -13
- package/modern/TimePicker/TimePickerToolbar.js +25 -16
- package/modern/YearCalendar/PickersYear.js +12 -6
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -6
- package/modern/internals/components/PickersPopper.js +13 -9
- package/modern/internals/components/PickersToolbar.js +39 -18
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +34 -30
- package/modern/internals/hooks/useField/useField.js +4 -2
- package/modern/internals/hooks/useField/useFieldV6TextField.js +8 -3
- package/modern/internals/hooks/useField/useFieldV7TextField.js +1 -1
- package/modern/internals/hooks/useOpenState.js +1 -1
- package/modern/internals/utils/fields.js +1 -1
- package/modern/locales/itIT.js +16 -20
- package/modern/locales/zhHK.js +14 -17
- package/node/AdapterLuxon/AdapterLuxon.js +9 -4
- package/node/DateCalendar/DateCalendar.js +1 -1
- package/node/DateField/DateField.js +1 -1
- package/node/DatePicker/DatePicker.js +1 -1
- package/node/DatePicker/DatePickerToolbar.js +11 -6
- package/node/DateTimeField/DateTimeField.js +1 -1
- package/node/DateTimePicker/DateTimePicker.js +1 -1
- package/node/DateTimePicker/DateTimePickerToolbar.js +97 -45
- package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +12 -8
- package/node/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +63 -25
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +108 -0
- package/node/DesktopDateTimePicker/index.js +8 -1
- package/node/DigitalClock/DigitalClock.js +14 -6
- package/node/MobileDatePicker/MobileDatePicker.js +1 -1
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/node/MonthCalendar/PickersMonth.js +12 -6
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +13 -4
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +13 -9
- package/node/PickersDay/PickersDay.js +30 -15
- package/node/PickersLayout/PickersLayout.js +31 -17
- package/node/PickersTextField/PickersFilledInput/PickersFilledInput.js +137 -72
- package/node/PickersTextField/PickersInput/PickersInput.js +76 -54
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +64 -24
- package/node/PickersTextField/PickersOutlinedInput/Outline.js +58 -41
- package/node/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +31 -12
- package/node/StaticDatePicker/StaticDatePicker.js +1 -1
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/node/TimeClock/Clock.js +48 -35
- package/node/TimeClock/ClockNumber.js +12 -7
- package/node/TimeClock/ClockPointer.js +23 -13
- package/node/TimePicker/TimePickerToolbar.js +25 -16
- package/node/YearCalendar/PickersYear.js +12 -6
- package/node/index.js +1 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -6
- package/node/internals/components/PickersPopper.js +13 -9
- package/node/internals/components/PickersToolbar.js +39 -18
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +34 -30
- package/node/internals/hooks/useField/useField.js +4 -2
- package/node/internals/hooks/useField/useFieldV6TextField.js +8 -3
- package/node/internals/hooks/useField/useFieldV7TextField.js +1 -1
- package/node/internals/hooks/useOpenState.js +1 -1
- package/node/internals/utils/fields.js +1 -1
- package/node/locales/itIT.js +16 -20
- package/node/locales/zhHK.js +14 -17
- package/package.json +5 -5
- package/timeViewRenderers/timeViewRenderers.js +1 -1
- package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +0 -15
- package/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -163
- package/dateTimeViewRenderers/index.d.ts +0 -2
- package/dateTimeViewRenderers/index.js +0 -1
- package/dateTimeViewRenderers/package.json +0 -6
- package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -162
- package/modern/dateTimeViewRenderers/index.js +0 -1
- package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -171
- package/node/dateTimeViewRenderers/index.js +0 -12
|
@@ -14,10 +14,9 @@ export const useValueWithTimezone = ({
|
|
|
14
14
|
onChange,
|
|
15
15
|
valueManager
|
|
16
16
|
}) => {
|
|
17
|
-
var _ref, _ref2;
|
|
18
17
|
const utils = useUtils();
|
|
19
18
|
const firstDefaultValue = React.useRef(defaultValue);
|
|
20
|
-
const inputValue =
|
|
19
|
+
const inputValue = valueProp ?? firstDefaultValue.current ?? valueManager.emptyValue;
|
|
21
20
|
const inputTimezone = React.useMemo(() => valueManager.getTimezone(utils, inputValue), [utils, valueManager, inputValue]);
|
|
22
21
|
const setInputTimezone = useEventCallback(newValue => {
|
|
23
22
|
if (inputTimezone == null) {
|
|
@@ -25,11 +24,11 @@ export const useValueWithTimezone = ({
|
|
|
25
24
|
}
|
|
26
25
|
return valueManager.setTimezone(utils, inputTimezone, newValue);
|
|
27
26
|
});
|
|
28
|
-
const timezoneToRender =
|
|
27
|
+
const timezoneToRender = timezoneProp ?? inputTimezone ?? 'default';
|
|
29
28
|
const valueWithTimezoneToRender = React.useMemo(() => valueManager.setTimezone(utils, timezoneToRender, inputValue), [valueManager, utils, timezoneToRender, inputValue]);
|
|
30
29
|
const handleValueChange = useEventCallback((newValue, ...otherParams) => {
|
|
31
30
|
const newValueWithInputTimezone = setInputTimezone(newValue);
|
|
32
|
-
onChange
|
|
31
|
+
onChange?.(newValueWithInputTimezone, ...otherParams);
|
|
33
32
|
});
|
|
34
33
|
return {
|
|
35
34
|
value: valueWithTimezoneToRender,
|
|
@@ -53,11 +52,11 @@ export const useControlledValueWithTimezone = ({
|
|
|
53
52
|
name,
|
|
54
53
|
state: 'value',
|
|
55
54
|
controlled: valueProp,
|
|
56
|
-
default: defaultValue
|
|
55
|
+
default: defaultValue ?? valueManager.emptyValue
|
|
57
56
|
});
|
|
58
57
|
const onChange = useEventCallback((newValue, ...otherParams) => {
|
|
59
58
|
setValue(newValue);
|
|
60
|
-
onChangeProp
|
|
59
|
+
onChangeProp?.(newValue, ...otherParams);
|
|
61
60
|
});
|
|
62
61
|
return useValueWithTimezone({
|
|
63
62
|
timezone: timezoneProp,
|
|
@@ -12,7 +12,6 @@ export function useViews({
|
|
|
12
12
|
focusedView: inFocusedView,
|
|
13
13
|
onFocusedViewChange
|
|
14
14
|
}) {
|
|
15
|
-
var _views, _views2;
|
|
16
15
|
if (process.env.NODE_ENV !== 'production') {
|
|
17
16
|
if (!warnedOnceNotValidView) {
|
|
18
17
|
if (inView != null && !views.includes(inView)) {
|
|
@@ -50,8 +49,8 @@ export function useViews({
|
|
|
50
49
|
}
|
|
51
50
|
}, [openTo, setView, view, views]);
|
|
52
51
|
const viewIndex = views.indexOf(view);
|
|
53
|
-
const previousView =
|
|
54
|
-
const nextView =
|
|
52
|
+
const previousView = views[viewIndex - 1] ?? null;
|
|
53
|
+
const nextView = views[viewIndex + 1] ?? null;
|
|
55
54
|
const handleFocusedViewChange = useEventCallback((viewToFocus, hasFocus) => {
|
|
56
55
|
if (hasFocus) {
|
|
57
56
|
// Focus event
|
|
@@ -61,7 +60,7 @@ export function useViews({
|
|
|
61
60
|
setFocusedView(prevFocusedView => viewToFocus === prevFocusedView ? null : prevFocusedView // If false the blur is due to view switching
|
|
62
61
|
);
|
|
63
62
|
}
|
|
64
|
-
onFocusedViewChange
|
|
63
|
+
onFocusedViewChange?.(viewToFocus, hasFocus);
|
|
65
64
|
});
|
|
66
65
|
const handleChangeView = useEventCallback(newView => {
|
|
67
66
|
// always keep the focused view in sync
|
package/internals/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export { useField, createDateStrForV7HiddenInputFromSections, createDateStrForV6
|
|
|
27
27
|
export type { UseFieldInternalProps, UseFieldParams, UseFieldResponse, FieldValueManager, FieldChangeHandler, FieldChangeHandlerContext, } from './hooks/useField';
|
|
28
28
|
export type { MobileOnlyPickerProps } from './hooks/useMobilePicker';
|
|
29
29
|
export { usePicker } from './hooks/usePicker';
|
|
30
|
-
export type { UsePickerResponse, UsePickerParams, UsePickerProps, UsePickerValueFieldResponse, } from './hooks/usePicker';
|
|
30
|
+
export type { UsePickerResponse, UsePickerParams, UsePickerProps, UsePickerValueFieldResponse, PickerViewsRendererProps, } from './hooks/usePicker';
|
|
31
31
|
export type { UsePickerValueNonStaticProps, PickerValueManager, PickerSelectionState, } from './hooks/usePicker/usePickerValue.types';
|
|
32
32
|
export type { UsePickerViewsNonStaticProps, PickerViewRendererLookup, PickerViewRenderer, UsePickerViewsProps, } from './hooks/usePicker/usePickerViews';
|
|
33
33
|
export { useStaticPicker } from './hooks/useStaticPicker';
|
|
@@ -71,7 +71,7 @@ export interface DayValidationProps<TDate extends PickerValidDate> {
|
|
|
71
71
|
/**
|
|
72
72
|
* Disable specific date.
|
|
73
73
|
*
|
|
74
|
-
* Warning: This function can be called multiple times (
|
|
74
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
75
75
|
*
|
|
76
76
|
* @template TDate
|
|
77
77
|
* @param {TDate} day The date to test.
|
|
@@ -15,7 +15,7 @@ export const convertFieldResponseIntoMuiTextFieldProps = _ref => {
|
|
|
15
15
|
} = fieldResponse,
|
|
16
16
|
other = _objectWithoutPropertiesLoose(fieldResponse, _excluded2);
|
|
17
17
|
return _extends({}, other, {
|
|
18
|
-
InputProps: _extends({}, InputProps
|
|
18
|
+
InputProps: _extends({}, InputProps ?? {}, {
|
|
19
19
|
readOnly
|
|
20
20
|
})
|
|
21
21
|
});
|
|
@@ -31,10 +31,10 @@ export const convertFieldResponseIntoMuiTextFieldProps = _ref => {
|
|
|
31
31
|
} = fieldResponse,
|
|
32
32
|
other = _objectWithoutPropertiesLoose(fieldResponse, _excluded3);
|
|
33
33
|
return _extends({}, other, {
|
|
34
|
-
InputProps: _extends({}, InputProps
|
|
34
|
+
InputProps: _extends({}, InputProps ?? {}, {
|
|
35
35
|
readOnly
|
|
36
36
|
}),
|
|
37
|
-
inputProps: _extends({}, inputProps
|
|
37
|
+
inputProps: _extends({}, inputProps ?? {}, {
|
|
38
38
|
inputMode,
|
|
39
39
|
onPaste,
|
|
40
40
|
onKeyDown,
|
|
@@ -45,17 +45,14 @@ const resolveViews = (ampm, views, shouldUseSingleColumn) => {
|
|
|
45
45
|
}
|
|
46
46
|
return ampm ? [...views, 'meridiem'] : views;
|
|
47
47
|
};
|
|
48
|
-
const resolveShouldRenderTimeInASingleColumn = (timeSteps, threshold) =>
|
|
49
|
-
var _timeSteps$hours, _timeSteps$minutes;
|
|
50
|
-
return 24 * 60 / (((_timeSteps$hours = timeSteps.hours) != null ? _timeSteps$hours : 1) * ((_timeSteps$minutes = timeSteps.minutes) != null ? _timeSteps$minutes : 5)) <= threshold;
|
|
51
|
-
};
|
|
48
|
+
const resolveShouldRenderTimeInASingleColumn = (timeSteps, threshold) => 24 * 60 / ((timeSteps.hours ?? 1) * (timeSteps.minutes ?? 5)) <= threshold;
|
|
52
49
|
export function resolveTimeViewsResponse({
|
|
53
50
|
thresholdToRenderTimeInASingleColumn: inThreshold,
|
|
54
51
|
ampm,
|
|
55
52
|
timeSteps: inTimeSteps,
|
|
56
53
|
views
|
|
57
54
|
}) {
|
|
58
|
-
const thresholdToRenderTimeInASingleColumn = inThreshold
|
|
55
|
+
const thresholdToRenderTimeInASingleColumn = inThreshold ?? 24;
|
|
59
56
|
const timeSteps = _extends({
|
|
60
57
|
hours: 1,
|
|
61
58
|
minutes: 5,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from './validation/extractValidationProps';
|
|
3
|
-
const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly'];
|
|
3
|
+
const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly', 'dateSeparator'];
|
|
4
4
|
export const splitFieldInternalAndForwardedProps = (props, valueType) => {
|
|
5
5
|
const forwardedProps = _extends({}, props);
|
|
6
6
|
const internalProps = {};
|
|
@@ -9,10 +9,7 @@ export const SECTION_TYPE_GRANULARITY = {
|
|
|
9
9
|
seconds: 6,
|
|
10
10
|
milliseconds: 7
|
|
11
11
|
};
|
|
12
|
-
export const getSectionTypeGranularity = sections => Math.max(...sections.map(section =>
|
|
13
|
-
var _SECTION_TYPE_GRANULA;
|
|
14
|
-
return (_SECTION_TYPE_GRANULA = SECTION_TYPE_GRANULARITY[section.type]) != null ? _SECTION_TYPE_GRANULA : 1;
|
|
15
|
-
}));
|
|
12
|
+
export const getSectionTypeGranularity = sections => Math.max(...sections.map(section => SECTION_TYPE_GRANULARITY[section.type] ?? 1));
|
|
16
13
|
const roundDate = (utils, granularity, date) => {
|
|
17
14
|
if (granularity === SECTION_TYPE_GRANULARITY.year) {
|
|
18
15
|
return utils.startOfYear(date);
|
|
@@ -44,7 +41,6 @@ export const getDefaultReferenceDate = ({
|
|
|
44
41
|
timezone,
|
|
45
42
|
getTodayDate: inGetTodayDate
|
|
46
43
|
}) => {
|
|
47
|
-
var _props$disableIgnorin;
|
|
48
44
|
let referenceDate = inGetTodayDate ? inGetTodayDate() : roundDate(utils, granularity, getTodayDate(utils, timezone));
|
|
49
45
|
if (props.minDate != null && utils.isAfterDay(props.minDate, referenceDate)) {
|
|
50
46
|
referenceDate = roundDate(utils, granularity, props.minDate);
|
|
@@ -52,7 +48,7 @@ export const getDefaultReferenceDate = ({
|
|
|
52
48
|
if (props.maxDate != null && utils.isBeforeDay(props.maxDate, referenceDate)) {
|
|
53
49
|
referenceDate = roundDate(utils, granularity, props.maxDate);
|
|
54
50
|
}
|
|
55
|
-
const isAfter = createIsAfterIgnoreDatePart(
|
|
51
|
+
const isAfter = createIsAfterIgnoreDatePart(props.disableIgnoringDatePartForTimeValidation ?? false, utils);
|
|
56
52
|
if (props.minTime != null && isAfter(props.minTime, referenceDate)) {
|
|
57
53
|
referenceDate = roundDate(utils, granularity, props.disableIgnoringDatePartForTimeValidation ? props.minTime : mergeDateAndTime(utils, referenceDate, props.minTime));
|
|
58
54
|
}
|
package/internals/utils/views.js
CHANGED
|
@@ -10,7 +10,7 @@ export const applyDefaultViewProps = ({
|
|
|
10
10
|
views,
|
|
11
11
|
defaultViews
|
|
12
12
|
}) => {
|
|
13
|
-
const viewsWithDefault = views
|
|
13
|
+
const viewsWithDefault = views ?? defaultViews;
|
|
14
14
|
let openToWithDefault;
|
|
15
15
|
if (openTo != null) {
|
|
16
16
|
openToWithDefault = openTo;
|
package/locales/csCZ.js
CHANGED
|
@@ -33,10 +33,7 @@ const csCZPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Vyberte čas',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Vyberete rozmezí dat',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view} vybrány. ${time === null ? 'Není vybrán čas' : `Vybraný čas je ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view} vybrány. ${time === null ? 'Není vybrán čas' : `Vybraný čas je ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} hodin`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} minut`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} sekund`,
|
package/locales/daDK.js
CHANGED
|
@@ -33,10 +33,7 @@ const daDKPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Vælg tidspunkt',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Vælg datointerval',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `Vælg ${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view}. ${time === null ? 'Intet tidspunkt valgt' : `Valgte tidspunkt er ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `Vælg ${timeViews[view] ?? view}. ${time === null ? 'Intet tidspunkt valgt' : `Valgte tidspunkt er ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} timer`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} minutter`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} sekunder`,
|
package/locales/deDE.js
CHANGED
|
@@ -33,10 +33,7 @@ const deDEPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Uhrzeit auswählen',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Datumsbereich auswählen',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view} auswählen. ${time === null ? 'Keine Uhrzeit ausgewählt' : `Gewählte Uhrzeit ist ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view} auswählen. ${time === null ? 'Keine Uhrzeit ausgewählt' : `Gewählte Uhrzeit ist ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} ${timeViews.hours}`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} ${timeViews.minutes}`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} ${timeViews.seconds}`,
|
package/locales/huHU.js
CHANGED
|
@@ -33,10 +33,7 @@ const huHUPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Idő kiválasztása',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Dátumhatárok kiválasztása',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view} kiválasztása. ${time === null ? 'Nincs kiválasztva idő' : `A kiválasztott idő ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view} kiválasztása. ${time === null ? 'Nincs kiválasztva idő' : `A kiválasztott idő ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} ${timeViews.hours.toLowerCase()}`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} ${timeViews.minutes.toLowerCase()}`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} ${timeViews.seconds.toLowerCase()}`,
|
package/locales/itIT.js
CHANGED
|
@@ -16,11 +16,10 @@ const itITPickers = {
|
|
|
16
16
|
// DateRange labels
|
|
17
17
|
start: 'Inizio',
|
|
18
18
|
end: 'Fine',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
startDate: 'Data di inizio',
|
|
20
|
+
startTime: 'Ora di inizio',
|
|
21
|
+
endDate: 'Data di fine',
|
|
22
|
+
endTime: 'Ora di fine',
|
|
24
23
|
// Action bar
|
|
25
24
|
cancelButtonLabel: 'Cancellare',
|
|
26
25
|
clearButtonLabel: 'Sgomberare',
|
|
@@ -46,8 +45,7 @@ const itITPickers = {
|
|
|
46
45
|
// Open picker labels
|
|
47
46
|
openDatePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Scegli la data, la data selezionata è ${utils.format(value, 'fullDate')}` : 'Scegli la data',
|
|
48
47
|
openTimePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Scegli l'ora, l'ora selezionata è ${utils.format(value, 'fullTime')}` : "Scegli l'ora",
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
fieldClearLabel: 'Cancella valore',
|
|
51
49
|
// Table labels
|
|
52
50
|
timeTableLabel: "scegli un'ora",
|
|
53
51
|
dateTableLabel: 'scegli una data',
|
|
@@ -55,23 +53,21 @@ const itITPickers = {
|
|
|
55
53
|
fieldYearPlaceholder: params => 'A'.repeat(params.digitAmount),
|
|
56
54
|
fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'MMMM' : 'MM',
|
|
57
55
|
fieldDayPlaceholder: () => 'GG',
|
|
58
|
-
|
|
56
|
+
fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'GGGG' : 'GG',
|
|
59
57
|
fieldHoursPlaceholder: () => 'hh',
|
|
60
58
|
fieldMinutesPlaceholder: () => 'mm',
|
|
61
59
|
fieldSecondsPlaceholder: () => 'ss',
|
|
62
|
-
fieldMeridiemPlaceholder: () => 'aa'
|
|
63
|
-
|
|
60
|
+
fieldMeridiemPlaceholder: () => 'aa',
|
|
64
61
|
// View names
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
year: 'Anno',
|
|
63
|
+
month: 'Mese',
|
|
64
|
+
day: 'Giorno',
|
|
65
|
+
weekDay: 'Giorno della settimana',
|
|
66
|
+
hours: 'Ore',
|
|
67
|
+
minutes: 'Minuti',
|
|
68
|
+
seconds: 'Secondi',
|
|
69
|
+
meridiem: 'Meridiano',
|
|
74
70
|
// Common
|
|
75
|
-
|
|
71
|
+
empty: 'Vuoto'
|
|
76
72
|
};
|
|
77
73
|
export const itIT = getPickersLocalization(itITPickers);
|
package/locales/jaJP.js
CHANGED
|
@@ -32,10 +32,7 @@ const jaJPPickers = {
|
|
|
32
32
|
timePickerToolbarTitle: '時間を選択',
|
|
33
33
|
dateRangePickerToolbarTitle: '日付の範囲を選択',
|
|
34
34
|
// Clock labels
|
|
35
|
-
clockLabelText: (view, time, adapter) => {
|
|
36
|
-
var _timeViews$view;
|
|
37
|
-
return `${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view}を選択してください ${time === null ? '時間が選択されていません' : `選択した時間は ${adapter.format(time, 'fullTime')} です`}`;
|
|
38
|
-
},
|
|
35
|
+
clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view}を選択してください ${time === null ? '時間が選択されていません' : `選択した時間は ${adapter.format(time, 'fullTime')} です`}`,
|
|
39
36
|
hoursClockNumberText: hours => `${hours} ${timeViews.hours}`,
|
|
40
37
|
minutesClockNumberText: minutes => `${minutes} ${timeViews.minutes}`,
|
|
41
38
|
secondsClockNumberText: seconds => `${seconds} ${timeViews.seconds}`,
|
package/locales/roRO.js
CHANGED
|
@@ -33,10 +33,7 @@ const roROPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Selectați ora',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Selectați intervalul de date',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `Selectați ${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view}. ${time === null ? 'Nicio oră selectată' : `Ora selectată este ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `Selectați ${timeViews[view] ?? view}. ${time === null ? 'Nicio oră selectată' : `Ora selectată este ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} ${timeViews.hours}`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} ${timeViews.minutes}`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} ${timeViews.seconds}`,
|
package/locales/skSK.js
CHANGED
|
@@ -33,10 +33,7 @@ const skSKPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Vyberte čas',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Vyberete rozmedzie dátumov',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view} vybraný. ${time === null ? 'Nie je vybraný čas' : `Vybraný čas je ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view} vybraný. ${time === null ? 'Nie je vybraný čas' : `Vybraný čas je ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} hodín`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} minút`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} sekúnd`,
|
package/locales/zhHK.js
CHANGED
|
@@ -16,11 +16,10 @@ const zhHKPickers = {
|
|
|
16
16
|
// DateRange labels
|
|
17
17
|
start: '開始',
|
|
18
18
|
end: '結束',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
startDate: '開始日期',
|
|
20
|
+
startTime: '開始時間',
|
|
21
|
+
endDate: '結束日期',
|
|
22
|
+
endTime: '結束時間',
|
|
24
23
|
// Action bar
|
|
25
24
|
cancelButtonLabel: '取消',
|
|
26
25
|
clearButtonLabel: '清除',
|
|
@@ -59,19 +58,17 @@ const zhHKPickers = {
|
|
|
59
58
|
fieldHoursPlaceholder: () => 'hh',
|
|
60
59
|
fieldMinutesPlaceholder: () => 'mm',
|
|
61
60
|
fieldSecondsPlaceholder: () => 'ss',
|
|
62
|
-
fieldMeridiemPlaceholder: () => 'aa'
|
|
63
|
-
|
|
61
|
+
fieldMeridiemPlaceholder: () => 'aa',
|
|
64
62
|
// View names
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
year: '年',
|
|
64
|
+
month: '月',
|
|
65
|
+
day: '日',
|
|
66
|
+
weekDay: '星期',
|
|
67
|
+
hours: '小時',
|
|
68
|
+
minutes: '分鐘',
|
|
69
|
+
seconds: '秒',
|
|
70
|
+
meridiem: '子午線',
|
|
74
71
|
// Common
|
|
75
|
-
|
|
72
|
+
empty: '空值'
|
|
76
73
|
};
|
|
77
74
|
export const zhHK = getPickersLocalization(zhHKPickers);
|
|
@@ -240,6 +240,10 @@ export class AdapterLuxon {
|
|
|
240
240
|
// Extract escaped section to avoid extending them
|
|
241
241
|
const catchEscapedSectionsRegexp = /''|'(''|[^'])+('|$)|[^']*/g;
|
|
242
242
|
|
|
243
|
+
// This RegExp tests if a string is only mad of supported tokens
|
|
244
|
+
const validTokens = [...Object.keys(this.formatTokenMap), 'yyyyy'];
|
|
245
|
+
const isWordComposedOfTokens = new RegExp(`^(${validTokens.join('|')})+$`);
|
|
246
|
+
|
|
243
247
|
// Extract words to test if they are a token or a word to escape.
|
|
244
248
|
const catchWordsRegexp = /(?:^|[^a-z])([a-z]+)(?:[^a-z]|$)|([a-z]+)/gi;
|
|
245
249
|
return format.match(catchEscapedSectionsRegexp).map(token => {
|
|
@@ -250,12 +254,13 @@ export class AdapterLuxon {
|
|
|
250
254
|
const expandedToken = DateTime.expandFormat(token, {
|
|
251
255
|
locale: this.locale
|
|
252
256
|
});
|
|
253
|
-
return expandedToken.replace(catchWordsRegexp, (
|
|
257
|
+
return expandedToken.replace(catchWordsRegexp, (substring, g1, g2) => {
|
|
254
258
|
const word = g1 || g2; // words are either in group 1 or group 2
|
|
255
|
-
|
|
256
|
-
|
|
259
|
+
|
|
260
|
+
if (isWordComposedOfTokens.test(word)) {
|
|
261
|
+
return substring;
|
|
257
262
|
}
|
|
258
|
-
return `'${
|
|
263
|
+
return `'${substring}'`;
|
|
259
264
|
});
|
|
260
265
|
}).join('')
|
|
261
266
|
// The returned format can contain `yyyyy` which means year between 4 and 6 digits.
|
|
@@ -487,7 +487,7 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
487
487
|
/**
|
|
488
488
|
* Disable specific date.
|
|
489
489
|
*
|
|
490
|
-
* Warning: This function can be called multiple times (
|
|
490
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
491
491
|
*
|
|
492
492
|
* @template TDate
|
|
493
493
|
* @param {TDate} day The date to test.
|
|
@@ -241,7 +241,7 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
|
|
|
241
241
|
/**
|
|
242
242
|
* Disable specific date.
|
|
243
243
|
*
|
|
244
|
-
* Warning: This function can be called multiple times (
|
|
244
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
245
245
|
*
|
|
246
246
|
* @template TDate
|
|
247
247
|
* @param {TDate} day The date to test.
|
|
@@ -266,7 +266,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
|
|
|
266
266
|
/**
|
|
267
267
|
* Disable specific date.
|
|
268
268
|
*
|
|
269
|
-
* Warning: This function can be called multiple times (
|
|
269
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
270
270
|
*
|
|
271
271
|
* @template TDate
|
|
272
272
|
* @param {TDate} day The date to test.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["value", "isLandscape", "onChange", "toolbarFormat", "toolbarPlaceholder", "views", "className", "onViewChange", "view"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
@@ -31,11 +31,16 @@ const DatePickerToolbarTitle = styled(Typography, {
|
|
|
31
31
|
name: 'MuiDatePickerToolbar',
|
|
32
32
|
slot: 'Title',
|
|
33
33
|
overridesResolver: (_, styles) => styles.title
|
|
34
|
-
})(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
34
|
+
})({
|
|
35
|
+
variants: [{
|
|
36
|
+
props: {
|
|
37
|
+
isLandscape: true
|
|
38
|
+
},
|
|
39
|
+
style: {
|
|
40
|
+
margin: 'auto 16px auto auto'
|
|
41
|
+
}
|
|
42
|
+
}]
|
|
43
|
+
});
|
|
39
44
|
/**
|
|
40
45
|
* Demos:
|
|
41
46
|
*
|
|
@@ -274,7 +274,7 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
274
274
|
/**
|
|
275
275
|
* Disable specific date.
|
|
276
276
|
*
|
|
277
|
-
* Warning: This function can be called multiple times (
|
|
277
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
278
278
|
*
|
|
279
279
|
* @template TDate
|
|
280
280
|
* @param {TDate} day The date to test.
|
|
@@ -304,7 +304,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
304
304
|
/**
|
|
305
305
|
* Disable specific date.
|
|
306
306
|
*
|
|
307
|
-
* Warning: This function can be called multiple times (
|
|
307
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
308
308
|
*
|
|
309
309
|
* @template TDate
|
|
310
310
|
* @param {TDate} day The date to test.
|