@mui/x-date-pickers 7.0.0-beta.6 → 7.0.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 +311 -12
- package/DateCalendar/DateCalendar.js +14 -16
- package/DateCalendar/DayCalendar.js +7 -7
- package/DateField/DateField.js +3 -4
- package/DatePicker/DatePicker.js +1 -1
- 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 +1 -1
- package/DateTimePicker/shared.d.ts +2 -1
- package/DateTimePicker/shared.js +11 -13
- 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 +2 -3
- 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 +1 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -5
- package/PickersActionBar/PickersActionBar.js +1 -1
- package/PickersCalendarHeader/PickersCalendarHeader.d.ts +1 -1
- package/PickersCalendarHeader/PickersCalendarHeader.js +4 -5
- package/PickersLayout/usePickerLayout.js +8 -9
- package/PickersSectionList/PickersSectionList.js +9 -11
- package/PickersTextField/PickersFilledInput/PickersFilledInput.js +2 -3
- package/PickersTextField/PickersInput/PickersInput.js +1 -1
- package/PickersTextField/PickersInputBase/PickersInputBase.js +4 -5
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +2 -2
- 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/TimeClock.js +1 -1
- package/TimeField/TimeField.js +2 -3
- package/TimePicker/shared.d.ts +2 -1
- package/TimePicker/shared.js +5 -7
- package/YearCalendar/YearCalendar.js +5 -6
- package/hooks/useClearableField.js +6 -7
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +8 -9
- package/internals/components/PickersModalDialog.js +6 -7
- package/internals/components/PickersPopper.js +13 -16
- package/internals/components/PickersToolbar.js +9 -12
- 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 +2 -2
- 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 +9 -15
- package/internals/hooks/useField/useFieldV7TextField.js +11 -13
- 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/date-utils.d.ts +1 -1
- package/internals/utils/date-utils.js +8 -8
- 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/jaJP.js +16 -23
- package/locales/roRO.js +1 -4
- package/locales/skSK.js +1 -4
- package/modern/AdapterLuxon/AdapterLuxon.js +9 -4
- package/modern/DateCalendar/DateCalendar.js +1 -1
- package/modern/DateCalendar/DayCalendar.js +2 -1
- package/modern/DateField/DateField.js +1 -1
- package/modern/DatePicker/DatePicker.js +1 -1
- package/modern/DateTimeField/DateTimeField.js +1 -1
- package/modern/DateTimePicker/DateTimePicker.js +1 -1
- 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/MobileDatePicker/MobileDatePicker.js +1 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/modern/StaticDatePicker/StaticDatePicker.js +1 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersPopper.js +1 -1
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +34 -30
- package/modern/internals/hooks/useField/useFieldV7TextField.js +3 -3
- package/modern/internals/hooks/useOpenState.js +1 -1
- package/modern/internals/utils/date-utils.js +8 -8
- package/modern/internals/utils/fields.js +1 -1
- package/modern/locales/jaJP.js +15 -19
- package/node/AdapterLuxon/AdapterLuxon.js +9 -4
- package/node/DateCalendar/DateCalendar.js +1 -1
- package/node/DateCalendar/DayCalendar.js +2 -1
- package/node/DateField/DateField.js +1 -1
- package/node/DatePicker/DatePicker.js +1 -1
- package/node/DateTimeField/DateTimeField.js +1 -1
- package/node/DateTimePicker/DateTimePicker.js +1 -1
- 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/MobileDatePicker/MobileDatePicker.js +1 -1
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/node/StaticDatePicker/StaticDatePicker.js +1 -1
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/components/PickersPopper.js +1 -1
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +34 -30
- package/node/internals/hooks/useField/useFieldV7TextField.js +3 -3
- package/node/internals/hooks/useOpenState.js +1 -1
- package/node/internals/utils/date-utils.js +9 -9
- package/node/internals/utils/fields.js +1 -1
- package/node/locales/jaJP.js +15 -19
- 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,5 +1,6 @@
|
|
|
1
1
|
import { DateView, FieldValueType, MuiPickersAdapter, PickersTimezone, PickerValidDate } from '../../models';
|
|
2
2
|
import { DateOrTimeViewWithMeridiem } from '../models';
|
|
3
|
+
export declare const mergeDateAndTime: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate, any>, dateParam: TDate, timeParam: TDate) => TDate;
|
|
3
4
|
interface FindClosestDateParams<TDate extends PickerValidDate> {
|
|
4
5
|
date: TDate;
|
|
5
6
|
disableFuture?: boolean;
|
|
@@ -15,7 +16,6 @@ export declare const replaceInvalidDateByNull: <TDate extends PickerValidDate>(u
|
|
|
15
16
|
export declare const applyDefaultDate: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate, any>, value: TDate | null | undefined, defaultValue: TDate) => TDate;
|
|
16
17
|
export declare const areDatesEqual: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate, any>, a: TDate, b: TDate) => boolean;
|
|
17
18
|
export declare const getMonthsInYear: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate, any>, year: TDate) => TDate[];
|
|
18
|
-
export declare const mergeDateAndTime: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate, any>, dateParam: TDate, timeParam: TDate) => TDate;
|
|
19
19
|
export declare const getTodayDate: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone, valueType?: FieldValueType) => TDate;
|
|
20
20
|
export declare const formatMeridiem: <TDate extends PickerValidDate>(utils: MuiPickersAdapter<TDate, any>, meridiem: 'am' | 'pm') => string;
|
|
21
21
|
export declare const isDatePickerView: (view: DateOrTimeViewWithMeridiem) => view is DateView;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { areViewsEqual } from './views';
|
|
2
|
+
export const mergeDateAndTime = (utils, dateParam, timeParam) => {
|
|
3
|
+
let mergedDate = dateParam;
|
|
4
|
+
mergedDate = utils.setHours(mergedDate, utils.getHours(timeParam));
|
|
5
|
+
mergedDate = utils.setMinutes(mergedDate, utils.getMinutes(timeParam));
|
|
6
|
+
mergedDate = utils.setSeconds(mergedDate, utils.getSeconds(timeParam));
|
|
7
|
+
return mergedDate;
|
|
8
|
+
};
|
|
2
9
|
export const findClosestEnabledDate = ({
|
|
3
10
|
date,
|
|
4
11
|
disableFuture,
|
|
@@ -9,7 +16,7 @@ export const findClosestEnabledDate = ({
|
|
|
9
16
|
utils,
|
|
10
17
|
timezone
|
|
11
18
|
}) => {
|
|
12
|
-
const today =
|
|
19
|
+
const today = mergeDateAndTime(utils, utils.date(undefined, timezone), date);
|
|
13
20
|
if (disablePast && utils.isBefore(minDate, today)) {
|
|
14
21
|
minDate = today;
|
|
15
22
|
}
|
|
@@ -72,13 +79,6 @@ export const getMonthsInYear = (utils, year) => {
|
|
|
72
79
|
}
|
|
73
80
|
return months;
|
|
74
81
|
};
|
|
75
|
-
export const mergeDateAndTime = (utils, dateParam, timeParam) => {
|
|
76
|
-
let mergedDate = dateParam;
|
|
77
|
-
mergedDate = utils.setHours(mergedDate, utils.getHours(timeParam));
|
|
78
|
-
mergedDate = utils.setMinutes(mergedDate, utils.getMinutes(timeParam));
|
|
79
|
-
mergedDate = utils.setSeconds(mergedDate, utils.getSeconds(timeParam));
|
|
80
|
-
return mergedDate;
|
|
81
|
-
};
|
|
82
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);
|
|
@@ -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/jaJP.js
CHANGED
|
@@ -17,11 +17,10 @@ const jaJPPickers = {
|
|
|
17
17
|
// DateRange labels
|
|
18
18
|
start: '開始',
|
|
19
19
|
end: '終了',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
startDate: '開始日',
|
|
21
|
+
startTime: '開始時間',
|
|
22
|
+
endDate: '終了日',
|
|
23
|
+
endTime: '終了時間',
|
|
25
24
|
// Action bar
|
|
26
25
|
cancelButtonLabel: 'キャンセル',
|
|
27
26
|
clearButtonLabel: 'クリア',
|
|
@@ -33,10 +32,7 @@ const jaJPPickers = {
|
|
|
33
32
|
timePickerToolbarTitle: '時間を選択',
|
|
34
33
|
dateRangePickerToolbarTitle: '日付の範囲を選択',
|
|
35
34
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view}を選択してください ${time === null ? '時間が選択されていません' : `選択した時間は ${adapter.format(time, 'fullTime')} です`}`;
|
|
39
|
-
},
|
|
35
|
+
clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view}を選択してください ${time === null ? '時間が選択されていません' : `選択した時間は ${adapter.format(time, 'fullTime')} です`}`,
|
|
40
36
|
hoursClockNumberText: hours => `${hours} ${timeViews.hours}`,
|
|
41
37
|
minutesClockNumberText: minutes => `${minutes} ${timeViews.minutes}`,
|
|
42
38
|
secondsClockNumberText: seconds => `${seconds} ${timeViews.seconds}`,
|
|
@@ -50,8 +46,7 @@ const jaJPPickers = {
|
|
|
50
46
|
// Open picker labels
|
|
51
47
|
openDatePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `日付を選択してください。選択した日付は ${utils.format(value, 'fullDate')} です` : '日付を選択してください',
|
|
52
48
|
openTimePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `時間を選択してください。選択した時間は ${utils.format(value, 'fullTime')} です` : '時間を選択してください',
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
fieldClearLabel: 'クリア',
|
|
55
50
|
// Table labels
|
|
56
51
|
timeTableLabel: '時間を選択',
|
|
57
52
|
dateTableLabel: '日付を選択',
|
|
@@ -63,19 +58,17 @@ const jaJPPickers = {
|
|
|
63
58
|
fieldHoursPlaceholder: () => 'hh',
|
|
64
59
|
fieldMinutesPlaceholder: () => 'mm',
|
|
65
60
|
fieldSecondsPlaceholder: () => 'ss',
|
|
66
|
-
fieldMeridiemPlaceholder: () => 'aa'
|
|
67
|
-
|
|
61
|
+
fieldMeridiemPlaceholder: () => 'aa',
|
|
68
62
|
// View names
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
year: '年',
|
|
64
|
+
month: '月',
|
|
65
|
+
day: '日',
|
|
66
|
+
weekDay: '平日',
|
|
67
|
+
hours: '時間',
|
|
68
|
+
minutes: '分',
|
|
69
|
+
seconds: '秒',
|
|
70
|
+
meridiem: 'メリディム',
|
|
78
71
|
// Common
|
|
79
|
-
|
|
72
|
+
empty: '空'
|
|
80
73
|
};
|
|
81
74
|
export const jaJP = getPickersLocalization(jaJPPickers);
|
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`,
|
|
@@ -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.
|
|
@@ -353,10 +353,11 @@ export function DayCalendar(inProps) {
|
|
|
353
353
|
}
|
|
354
354
|
});
|
|
355
355
|
const currentMonthNumber = utils.getMonth(currentMonth);
|
|
356
|
+
const currentYearNumber = utils.getYear(currentMonth);
|
|
356
357
|
const validSelectedDays = React.useMemo(() => selectedDays.filter(day => !!day).map(day => utils.startOfDay(day)), [utils, selectedDays]);
|
|
357
358
|
|
|
358
359
|
// need a new ref whenever the `key` of the transition changes: https://reactcommunity.org/react-transition-group/transition/#Transition-prop-nodeRef.
|
|
359
|
-
const transitionKey = currentMonthNumber
|
|
360
|
+
const transitionKey = `${currentYearNumber}-${currentMonthNumber}`;
|
|
360
361
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
361
362
|
const slideNodeRef = React.useMemo(() => /*#__PURE__*/React.createRef(), [transitionKey]);
|
|
362
363
|
const startOfCurrentWeek = utils.startOfWeek(now);
|
|
@@ -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.
|
|
@@ -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.
|
|
@@ -281,7 +281,7 @@ DesktopDatePicker.propTypes = {
|
|
|
281
281
|
/**
|
|
282
282
|
* Disable specific date.
|
|
283
283
|
*
|
|
284
|
-
* Warning: This function can be called multiple times (
|
|
284
|
+
* 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.
|
|
285
285
|
*
|
|
286
286
|
* @template TDate
|
|
287
287
|
* @param {TDate} day The date to test.
|