@mui/x-date-pickers 6.0.2 → 6.0.4
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/index.js +1 -0
- package/AdapterDateFnsJalali/index.js +69 -0
- package/AdapterDayjs/index.js +5 -0
- package/AdapterLuxon/index.js +13 -3
- package/AdapterMoment/index.js +5 -0
- package/AdapterMomentHijri/index.js +5 -0
- package/AdapterMomentJalaali/index.js +5 -0
- package/CHANGELOG.md +119 -5
- package/DateCalendar/DateCalendar.types.d.ts +1 -1
- package/DateCalendar/PickersCalendarHeader.d.ts +1 -1
- package/DateCalendar/index.d.ts +0 -1
- package/DateField/DateField.js +4 -0
- package/DateField/DateField.types.d.ts +2 -2
- package/DateField/useDateField.js +5 -3
- package/DatePicker/DatePickerToolbar.d.ts +1 -1
- package/DatePicker/shared.d.ts +2 -2
- package/DateTimeField/DateTimeField.js +4 -0
- package/DateTimeField/DateTimeField.types.d.ts +2 -2
- package/DateTimeField/useDateTimeField.js +5 -3
- package/DateTimePicker/DateTimePickerTabs.d.ts +1 -1
- package/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
- package/DateTimePicker/shared.d.ts +1 -2
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +1 -1
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +1 -1
- package/MobileDatePicker/MobileDatePicker.types.d.ts +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -1
- package/MobileTimePicker/MobileTimePicker.types.d.ts +1 -1
- package/PickersDay/PickersDay.js +4 -4
- package/PickersLayout/PickersLayout.d.ts +1 -1
- package/PickersLayout/PickersLayout.types.d.ts +1 -1
- package/PickersLayout/index.d.ts +1 -1
- package/PickersLayout/usePickerLayout.d.ts +1 -1
- package/README.md +1 -1
- package/StaticDatePicker/StaticDatePicker.types.d.ts +2 -1
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +2 -1
- package/StaticTimePicker/StaticTimePicker.types.d.ts +2 -1
- package/TimeClock/Clock.d.ts +1 -1
- package/TimeClock/ClockPointer.d.ts +1 -1
- package/TimeClock/TimeClock.types.d.ts +1 -1
- package/TimeClock/index.d.ts +0 -1
- package/TimeField/TimeField.js +4 -0
- package/TimeField/TimeField.types.d.ts +2 -2
- package/TimeField/useTimeField.js +5 -3
- package/TimePicker/TimePickerToolbar.d.ts +1 -1
- package/TimePicker/shared.d.ts +1 -2
- package/dateViewRenderers/dateViewRenderers.d.ts +1 -1
- package/index.d.ts +1 -6
- package/index.js +4 -2
- package/internals/components/PickersToolbar.d.ts +1 -1
- package/internals/demo/DemoContainer.js +15 -7
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +7 -7
- package/internals/hooks/useField/index.d.ts +2 -2
- package/internals/hooks/useField/index.js +1 -1
- package/internals/hooks/useField/useField.d.ts +3 -2
- package/internals/hooks/useField/useField.js +61 -30
- package/internals/hooks/useField/useField.types.d.ts +48 -116
- package/internals/hooks/useField/useField.utils.d.ts +7 -5
- package/internals/hooks/useField/useField.utils.js +68 -50
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +2 -1
- package/internals/hooks/useField/useFieldState.d.ts +4 -3
- package/internals/hooks/useField/useFieldState.js +86 -65
- package/internals/hooks/useIsLandscape.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +7 -7
- package/internals/hooks/usePicker/usePicker.d.ts +2 -2
- package/internals/hooks/usePicker/usePicker.types.d.ts +4 -4
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.d.ts +9 -8
- package/internals/hooks/usePicker/usePickerValue.js +7 -11
- package/internals/hooks/usePicker/usePickerViews.d.ts +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +2 -2
- package/internals/hooks/useViews.d.ts +1 -1
- package/internals/hooks/useViews.js +8 -0
- package/internals/hooks/validation/models.d.ts +1 -1
- package/internals/hooks/validation/useDateTimeValidation.d.ts +3 -3
- package/internals/hooks/validation/useDateValidation.d.ts +2 -2
- package/internals/hooks/validation/useTimeValidation.d.ts +2 -2
- package/internals/index.d.ts +4 -8
- package/internals/index.js +2 -2
- package/internals/models/fields.d.ts +2 -20
- package/internals/models/index.d.ts +0 -1
- package/internals/models/index.js +0 -1
- package/internals/models/muiPickersAdapter.d.ts +1 -10
- package/internals/models/props/basePickerProps.d.ts +3 -3
- package/internals/models/props/tabs.d.ts +1 -1
- package/internals/models/props/toolbar.d.ts +1 -1
- package/internals/utils/date-utils.d.ts +1 -0
- package/internals/utils/date-utils.js +6 -0
- package/internals/utils/time-utils.d.ts +2 -1
- package/internals/utils/utils.d.ts +1 -1
- package/internals/utils/utils.js +3 -3
- package/internals/utils/validation.d.ts +1 -1
- package/internals/utils/valueManagers.d.ts +2 -4
- package/internals/utils/valueManagers.js +11 -12
- package/internals/utils/views.d.ts +1 -1
- package/legacy/AdapterDateFns/index.js +1 -0
- package/legacy/AdapterDateFnsJalali/index.js +69 -0
- package/legacy/AdapterDayjs/index.js +5 -0
- package/legacy/AdapterLuxon/index.js +13 -3
- package/legacy/AdapterMoment/index.js +5 -0
- package/legacy/AdapterMomentHijri/index.js +5 -0
- package/legacy/AdapterMomentJalaali/index.js +5 -0
- package/legacy/DateField/DateField.js +4 -0
- package/legacy/DateField/useDateField.js +4 -2
- package/legacy/DateTimeField/DateTimeField.js +4 -0
- package/legacy/DateTimeField/useDateTimeField.js +4 -2
- package/legacy/PickersDay/PickersDay.js +4 -4
- package/legacy/TimeField/TimeField.js +4 -0
- package/legacy/TimeField/useTimeField.js +4 -2
- package/legacy/index.js +4 -2
- package/legacy/internals/demo/DemoContainer.js +12 -6
- package/legacy/internals/hooks/useField/index.js +1 -1
- package/legacy/internals/hooks/useField/useField.js +86 -44
- package/legacy/internals/hooks/useField/useField.utils.js +76 -54
- package/legacy/internals/hooks/useField/useFieldState.js +92 -72
- package/legacy/internals/hooks/usePicker/usePickerValue.js +9 -13
- package/legacy/internals/hooks/useViews.js +10 -0
- package/legacy/internals/index.js +2 -2
- package/legacy/internals/models/index.js +0 -1
- package/legacy/internals/utils/date-utils.js +6 -0
- package/legacy/internals/utils/utils.js +3 -3
- package/legacy/internals/utils/valueManagers.js +12 -19
- package/legacy/locales/daDK.js +91 -0
- package/legacy/locales/faIR.js +33 -16
- package/legacy/locales/nbNO.js +12 -10
- package/legacy/locales/nlNL.js +12 -10
- package/legacy/locales/plPL.js +12 -10
- package/legacy/locales/svSE.js +12 -10
- package/legacy/models/index.js +3 -0
- package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +2 -3
- package/locales/daDK.d.ts +51 -0
- package/locales/daDK.js +59 -0
- package/locales/faIR.js +13 -16
- package/locales/nbNO.js +8 -10
- package/locales/nlNL.d.ts +4 -4
- package/locales/nlNL.js +8 -10
- package/locales/plPL.js +8 -10
- package/locales/svSE.js +8 -10
- package/locales/utils/pickersLocaleTextApi.d.ts +2 -1
- package/models/fields.d.ts +117 -0
- package/models/fields.js +1 -0
- package/models/index.d.ts +3 -0
- package/models/index.js +3 -0
- package/models/package.json +6 -0
- package/models/validation.d.ts +8 -0
- package/models/validation.js +1 -0
- package/models/views.js +1 -0
- package/modern/AdapterDateFns/index.js +1 -0
- package/modern/AdapterDateFnsJalali/index.js +69 -0
- package/modern/AdapterDayjs/index.js +5 -0
- package/modern/AdapterLuxon/index.js +13 -3
- package/modern/AdapterMoment/index.js +5 -0
- package/modern/AdapterMomentHijri/index.js +5 -0
- package/modern/AdapterMomentJalaali/index.js +5 -0
- package/modern/DateField/DateField.js +4 -0
- package/modern/DateField/useDateField.js +5 -3
- package/modern/DateTimeField/DateTimeField.js +4 -0
- package/modern/DateTimeField/useDateTimeField.js +5 -3
- package/modern/PickersDay/PickersDay.js +4 -4
- package/modern/TimeField/TimeField.js +4 -0
- package/modern/TimeField/useTimeField.js +5 -3
- package/modern/index.js +4 -2
- package/modern/internals/demo/DemoContainer.js +15 -7
- package/modern/internals/hooks/useField/index.js +1 -1
- package/modern/internals/hooks/useField/useField.js +59 -29
- package/modern/internals/hooks/useField/useField.utils.js +68 -50
- package/modern/internals/hooks/useField/useFieldState.js +86 -65
- package/modern/internals/hooks/usePicker/usePickerValue.js +7 -11
- package/modern/internals/hooks/useViews.js +8 -0
- package/modern/internals/index.js +2 -2
- package/modern/internals/models/index.js +0 -1
- package/modern/internals/utils/date-utils.js +6 -0
- package/modern/internals/utils/utils.js +3 -3
- package/modern/internals/utils/valueManagers.js +11 -12
- package/modern/locales/daDK.js +56 -0
- package/modern/locales/faIR.js +13 -16
- package/modern/locales/nbNO.js +8 -10
- package/modern/locales/nlNL.js +8 -10
- package/modern/locales/plPL.js +8 -10
- package/modern/locales/svSE.js +8 -10
- package/modern/models/fields.js +1 -0
- package/modern/models/index.js +3 -0
- package/modern/models/validation.js +1 -0
- package/modern/models/views.js +1 -0
- package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +2 -3
- package/node/AdapterDateFns/index.js +1 -0
- package/node/AdapterDateFnsJalali/index.js +69 -0
- package/node/AdapterDayjs/index.js +5 -0
- package/node/AdapterLuxon/index.js +13 -3
- package/node/AdapterMoment/index.js +5 -0
- package/node/AdapterMomentHijri/index.js +5 -0
- package/node/AdapterMomentJalaali/index.js +5 -0
- package/node/DateField/DateField.js +4 -0
- package/node/DateField/useDateField.js +5 -3
- package/node/DateTimeField/DateTimeField.js +4 -0
- package/node/DateTimeField/useDateTimeField.js +5 -3
- package/node/PickersDay/PickersDay.js +4 -4
- package/node/TimeField/TimeField.js +4 -0
- package/node/TimeField/useTimeField.js +5 -3
- package/node/index.js +14 -2
- package/node/internals/demo/DemoContainer.js +15 -7
- package/node/internals/hooks/useField/index.js +0 -6
- package/node/internals/hooks/useField/useField.js +58 -28
- package/node/internals/hooks/useField/useField.utils.js +71 -52
- package/node/internals/hooks/useField/useFieldState.js +85 -64
- package/node/internals/hooks/usePicker/usePickerValue.js +7 -11
- package/node/internals/hooks/useViews.js +8 -0
- package/node/internals/index.js +6 -12
- package/node/internals/models/index.js +0 -11
- package/node/internals/utils/date-utils.js +9 -2
- package/node/internals/utils/utils.js +3 -3
- package/node/internals/utils/valueManagers.js +9 -10
- package/node/locales/daDK.js +62 -0
- package/node/locales/faIR.js +13 -16
- package/node/locales/nbNO.js +8 -10
- package/node/locales/nlNL.js +8 -10
- package/node/locales/plPL.js +8 -10
- package/node/locales/svSE.js +8 -10
- package/node/models/index.js +38 -0
- package/node/models/validation.js +5 -0
- package/node/models/views.js +5 -0
- package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +2 -3
- package/package.json +2 -2
- package/tests/describeValue/testPickerOpenCloseLifeCycle.js +2 -3
- package/themeAugmentation/props.d.ts +1 -1
- package/timeViewRenderers/timeViewRenderers.d.ts +1 -1
- /package/{internals/models/views.js → legacy/models/fields.js} +0 -0
- /package/legacy/{internals/models/views.js → models/validation.js} +0 -0
- /package/{modern/internals → legacy}/models/views.js +0 -0
- /package/{internals/models → models}/views.d.ts +0 -0
- /package/node/{internals/models/views.js → models/fields.js} +0 -0
package/internals/index.d.ts
CHANGED
|
@@ -22,11 +22,11 @@ export type { PickersPopperClassKey, PickersPopperClasses, } from './components/
|
|
|
22
22
|
export { PickersToolbarButton } from './components/PickersToolbarButton';
|
|
23
23
|
export { DAY_MARGIN, DIALOG_WIDTH } from './constants/dimensions';
|
|
24
24
|
export type { DesktopOnlyPickerProps } from './hooks/useDesktopPicker';
|
|
25
|
-
export { useField, createDateStrForInputFromSections, addPositionPropertiesToSections,
|
|
26
|
-
export type { UseFieldInternalProps, UseFieldParams, UseFieldResponse, UseFieldForwardedProps, FieldValueManager,
|
|
25
|
+
export { useField, createDateStrForInputFromSections, addPositionPropertiesToSections, } from './hooks/useField';
|
|
26
|
+
export type { UseFieldInternalProps, UseFieldParams, UseFieldResponse, UseFieldForwardedProps, FieldValueManager, FieldChangeHandler, FieldChangeHandlerContext, } from './hooks/useField';
|
|
27
27
|
export type { MobileOnlyPickerProps } from './hooks/useMobilePicker';
|
|
28
28
|
export { usePicker } from './hooks/usePicker';
|
|
29
|
-
export type { UsePickerResponse, UsePickerParams } from './hooks/usePicker';
|
|
29
|
+
export type { UsePickerResponse, UsePickerParams, UsePickerProps } from './hooks/usePicker';
|
|
30
30
|
export type { UsePickerValueNonStaticProps, PickerValueManager, PickerSelectionState, } from './hooks/usePicker/usePickerValue';
|
|
31
31
|
export type { UsePickerViewsNonStaticProps, PickerViewRendererLookup, UsePickerViewsProps, } from './hooks/usePicker/usePickerViews';
|
|
32
32
|
export { useStaticPicker } from './hooks/useStaticPicker';
|
|
@@ -39,18 +39,14 @@ export type { ValidationCommonProps, ValidationProps, Validator, InferError, } f
|
|
|
39
39
|
export { validateDate } from './hooks/validation/useDateValidation';
|
|
40
40
|
export { validateTime } from './hooks/validation/useTimeValidation';
|
|
41
41
|
export { validateDateTime } from './hooks/validation/useDateTimeValidation';
|
|
42
|
-
export type { DateValidationError } from './hooks/validation/useDateValidation';
|
|
43
|
-
export type { TimeValidationError } from './hooks/validation/useTimeValidation';
|
|
44
|
-
export type { DateTimeValidationError } from './hooks/validation/useDateTimeValidation';
|
|
45
42
|
export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
|
|
46
43
|
export type { BaseFieldProps, FieldsTextFieldProps } from './models/fields';
|
|
47
44
|
export type { BasePickerProps, BasePickerInputProps, BaseNonStaticPickerProps, } from './models/props/basePickerProps';
|
|
48
45
|
export type { BaseToolbarProps, ExportedBaseToolbarProps } from './models/props/toolbar';
|
|
49
46
|
export type { MuiPickersAdapter } from './models/muiPickersAdapter';
|
|
50
47
|
export type { DefaultizedProps, MakeOptional } from './models/helpers';
|
|
51
|
-
export type { DateOrTimeView, DateView, TimeView } from './models/views';
|
|
52
48
|
export type { WrapperVariant } from './models/common';
|
|
53
|
-
export { applyDefaultDate, replaceInvalidDateByNull } from './utils/date-utils';
|
|
49
|
+
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual } from './utils/date-utils';
|
|
54
50
|
export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, } from './utils/utils';
|
|
55
51
|
export { defaultReduceAnimations } from './utils/defaultReduceAnimations';
|
|
56
52
|
export { extractValidationProps } from './utils/validation';
|
package/internals/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export { pickersArrowSwitcherClasses } from './components/PickersArrowSwitcher/p
|
|
|
9
9
|
export { pickersPopperClasses } from './components/pickersPopperClasses';
|
|
10
10
|
export { PickersToolbarButton } from './components/PickersToolbarButton';
|
|
11
11
|
export { DAY_MARGIN, DIALOG_WIDTH } from './constants/dimensions';
|
|
12
|
-
export { useField, createDateStrForInputFromSections, addPositionPropertiesToSections
|
|
12
|
+
export { useField, createDateStrForInputFromSections, addPositionPropertiesToSections } from './hooks/useField';
|
|
13
13
|
export { usePicker } from './hooks/usePicker';
|
|
14
14
|
export { useStaticPicker } from './hooks/useStaticPicker';
|
|
15
15
|
export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText, useNow } from './hooks/useUtils';
|
|
@@ -18,7 +18,7 @@ export { validateDate } from './hooks/validation/useDateValidation';
|
|
|
18
18
|
export { validateTime } from './hooks/validation/useTimeValidation';
|
|
19
19
|
export { validateDateTime } from './hooks/validation/useDateTimeValidation';
|
|
20
20
|
export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
|
|
21
|
-
export { applyDefaultDate, replaceInvalidDateByNull } from './utils/date-utils';
|
|
21
|
+
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual } from './utils/date-utils';
|
|
22
22
|
export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './utils/utils';
|
|
23
23
|
export { defaultReduceAnimations } from './utils/defaultReduceAnimations';
|
|
24
24
|
export { extractValidationProps } from './utils/validation';
|
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TextFieldProps } from '@mui/material/TextField';
|
|
3
3
|
import type { UseFieldInternalProps } from '../hooks/useField';
|
|
4
|
-
|
|
4
|
+
import type { FieldSection } from '../../models';
|
|
5
|
+
export interface BaseFieldProps<TValue, TSection extends FieldSection, TError> extends Omit<UseFieldInternalProps<TValue, TSection, TError>, 'format'> {
|
|
5
6
|
className?: string;
|
|
6
7
|
format?: string;
|
|
7
8
|
disabled?: boolean;
|
|
8
|
-
inputRef?: React.Ref<HTMLInputElement>;
|
|
9
9
|
ref?: React.Ref<HTMLDivElement>;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Props the single input field can receive when used inside a picker.
|
|
13
|
-
* Only contains what the MUI component are passing to the field, not what users can pass using the `props.slotProps.field`.
|
|
14
|
-
*/
|
|
15
|
-
export interface BaseSingleInputFieldProps<TValue, TError> extends BaseFieldProps<TValue, TError> {
|
|
16
|
-
label?: React.ReactNode;
|
|
17
|
-
id?: string;
|
|
18
|
-
InputProps?: {
|
|
19
|
-
ref?: React.Ref<any>;
|
|
20
|
-
endAdornment?: React.ReactNode;
|
|
21
|
-
startAdornment?: React.ReactNode;
|
|
22
|
-
};
|
|
23
|
-
inputProps?: {
|
|
24
|
-
'aria-label'?: string;
|
|
25
|
-
};
|
|
26
|
-
slots?: {};
|
|
27
|
-
slotProps?: {};
|
|
28
|
-
}
|
|
29
11
|
export interface FieldsTextFieldProps extends Omit<TextFieldProps, 'autoComplete' | 'error' | 'maxRows' | 'minRows' | 'multiline' | 'placeholder' | 'rows' | 'select' | 'SelectProps' | 'type'> {
|
|
30
12
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Do not remove the `.d.ts` file extension, it allows to keep the `@ts-expect-error` below after the build.
|
|
2
2
|
import { IUtils } from '@date-io/core/IUtils';
|
|
3
|
+
import { FieldSectionType } from '../../models';
|
|
3
4
|
|
|
4
5
|
// TODO: Maybe we should add the same constraint.
|
|
5
6
|
// @ts-ignore TDate in our codebase does not have the `ExtendableDateType` constraint.
|
|
@@ -18,16 +19,6 @@ export type MuiPickersAdapter<TDate> = IUtils<TDate> & {
|
|
|
18
19
|
getWeekNumber: (date: TDate) => number;
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
export type FieldSectionType =
|
|
22
|
-
| 'year'
|
|
23
|
-
| 'month'
|
|
24
|
-
| 'day'
|
|
25
|
-
| 'weekDay'
|
|
26
|
-
| 'hours'
|
|
27
|
-
| 'minutes'
|
|
28
|
-
| 'seconds'
|
|
29
|
-
| 'meridiem';
|
|
30
|
-
|
|
31
22
|
export type FieldFormatTokenMap = {
|
|
32
23
|
[formatToken: string]:
|
|
33
24
|
| FieldSectionType
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { Theme } from '@mui/material/styles';
|
|
3
3
|
import { SxProps } from '@mui/system';
|
|
4
4
|
import { UsePickerBaseProps } from '../../hooks/usePicker';
|
|
5
|
-
import { DateOrTimeView } from '
|
|
5
|
+
import { DateOrTimeView } from '../../../models';
|
|
6
6
|
import { PickersInputComponentLocaleText } from '../../../locales/utils/pickersLocaleTextApi';
|
|
7
7
|
import type { UsePickerViewsProps } from '../../hooks/usePicker/usePickerViews';
|
|
8
8
|
import { MakeOptional } from '../helpers';
|
|
@@ -41,10 +41,10 @@ export interface BaseNonStaticPickerProps {
|
|
|
41
41
|
format?: string;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Props common to all non-static pickers
|
|
44
|
+
* Props common to all non-range non-static pickers.
|
|
45
45
|
* These props are handled by the headless wrappers.
|
|
46
46
|
*/
|
|
47
|
-
export interface
|
|
47
|
+
export interface BaseNonRangeNonStaticPickerProps {
|
|
48
48
|
/**
|
|
49
49
|
* The label content.
|
|
50
50
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { DateOrTimeView } from '
|
|
2
|
+
import { DateOrTimeView } from '../../../models';
|
|
3
3
|
export interface BaseToolbarProps<TValue, TView extends DateOrTimeView> extends ExportedBaseToolbarProps {
|
|
4
4
|
isLandscape: boolean;
|
|
5
5
|
onChange: (newValue: TValue) => void;
|
|
@@ -12,4 +12,5 @@ export declare const findClosestEnabledDate: <TDate>({ date, disableFuture, disa
|
|
|
12
12
|
export declare const clamp: <TDate>(utils: MuiPickersAdapter<TDate>, value: TDate, minDate: TDate, maxDate: TDate) => TDate;
|
|
13
13
|
export declare const replaceInvalidDateByNull: <TDate>(utils: MuiPickersAdapter<TDate>, value: TDate | null) => NonNullable<TDate> | null;
|
|
14
14
|
export declare const applyDefaultDate: <TDate>(utils: MuiPickersAdapter<TDate>, value: TDate | null | undefined, defaultValue: TDate) => TDate;
|
|
15
|
+
export declare const areDatesEqual: <TDate>(utils: MuiPickersAdapter<TDate>, a: TDate, b: TDate) => boolean;
|
|
15
16
|
export {};
|
|
@@ -63,4 +63,10 @@ export const applyDefaultDate = (utils, value, defaultValue) => {
|
|
|
63
63
|
return defaultValue;
|
|
64
64
|
}
|
|
65
65
|
return value;
|
|
66
|
+
};
|
|
67
|
+
export const areDatesEqual = (utils, a, b) => {
|
|
68
|
+
if (!utils.isValid(a) && a != null && !utils.isValid(b) && b != null) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
return utils.isEqual(a, b);
|
|
66
72
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MuiPickersAdapter } from '../models';
|
|
2
|
+
import { DateOrTimeView } from '../../models';
|
|
2
3
|
export declare const isTimeView: (view: DateOrTimeView) => boolean;
|
|
3
4
|
type Meridiem = 'am' | 'pm' | null;
|
|
4
5
|
export declare const getMeridiem: <TDate>(date: TDate | null, utils: MuiPickersAdapter<TDate>) => Meridiem;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export declare function arrayIncludes<T>(array: T[] | readonly T[], itemOrItems: T | T[]): boolean;
|
|
3
|
-
export declare const onSpaceOrEnter: (innerFn: (ev: React.MouseEvent<any> | React.KeyboardEvent<any>) => void,
|
|
3
|
+
export declare const onSpaceOrEnter: (innerFn: (ev: React.MouseEvent<any> | React.KeyboardEvent<any>) => void, externalEvent?: ((event: React.KeyboardEvent<any>) => void) | undefined) => (event: React.KeyboardEvent) => void;
|
|
4
4
|
export declare const executeInTheNextEventLoopTick: (fn: () => void) => void;
|
|
5
5
|
export declare const getActiveElement: (root?: Document | ShadowRoot) => Element | null;
|
|
6
6
|
export declare const DEFAULT_DESKTOP_MODE_MEDIA_QUERY = "@media (pointer: fine)";
|
package/internals/utils/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ export function arrayIncludes(array, itemOrItems) {
|
|
|
5
5
|
}
|
|
6
6
|
return array.indexOf(itemOrItems) !== -1;
|
|
7
7
|
}
|
|
8
|
-
export const onSpaceOrEnter = (innerFn,
|
|
8
|
+
export const onSpaceOrEnter = (innerFn, externalEvent) => event => {
|
|
9
9
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
10
10
|
innerFn(event);
|
|
11
11
|
|
|
@@ -13,8 +13,8 @@ export const onSpaceOrEnter = (innerFn, onFocus) => event => {
|
|
|
13
13
|
event.preventDefault();
|
|
14
14
|
event.stopPropagation();
|
|
15
15
|
}
|
|
16
|
-
if (
|
|
17
|
-
|
|
16
|
+
if (externalEvent) {
|
|
17
|
+
externalEvent(event);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
export const executeInTheNextEventLoopTick = fn => {
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const extractValidationProps: <Props extends {
|
|
6
6
|
[key: string]: any;
|
|
7
|
-
}>(props: Props) => Pick<Props, "
|
|
7
|
+
}>(props: Props) => Pick<Props, "disableFuture" | "disablePast" | "shouldDisableDate" | "shouldDisableMonth" | "shouldDisableYear" | "minDate" | "maxDate" | "minTime" | "maxTime" | "shouldDisableTime" | "shouldDisableClock" | "minDateTime" | "maxDateTime" | "minuteStep">;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { PickerValueManager } from '../hooks/usePicker';
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
import type { DateTimeValidationError } from '../hooks/validation/useDateTimeValidation';
|
|
5
|
-
import type { FieldSection, FieldValueManager } from '../hooks/useField';
|
|
2
|
+
import { DateValidationError, TimeValidationError, DateTimeValidationError, FieldSection } from '../../models';
|
|
3
|
+
import type { FieldValueManager } from '../hooks/useField';
|
|
6
4
|
export type SingleItemPickerValueManager<TValue = any, TDate = any, TError extends DateValidationError | TimeValidationError | DateTimeValidationError = any> = PickerValueManager<TValue, TDate, TError>;
|
|
7
5
|
export declare const singleItemValueManager: SingleItemPickerValueManager;
|
|
8
6
|
export declare const singleItemFieldValueManager: FieldValueManager<any, any, FieldSection, DateValidationError | TimeValidationError | DateTimeValidationError>;
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
import { replaceInvalidDateByNull } from './date-utils';
|
|
2
|
-
import { addPositionPropertiesToSections, createDateStrForInputFromSections
|
|
1
|
+
import { areDatesEqual, replaceInvalidDateByNull } from './date-utils';
|
|
2
|
+
import { addPositionPropertiesToSections, createDateStrForInputFromSections } from '../hooks/useField/useField.utils';
|
|
3
3
|
export const singleItemValueManager = {
|
|
4
4
|
emptyValue: null,
|
|
5
5
|
getTodayValue: utils => utils.date(),
|
|
6
6
|
cleanValue: replaceInvalidDateByNull,
|
|
7
|
-
areValuesEqual:
|
|
7
|
+
areValuesEqual: areDatesEqual,
|
|
8
8
|
isSameError: (a, b) => a === b,
|
|
9
9
|
defaultErrorState: null
|
|
10
10
|
};
|
|
11
11
|
export const singleItemFieldValueManager = {
|
|
12
12
|
updateReferenceValue: (utils, value, prevReferenceValue) => value == null || !utils.isValid(value) ? prevReferenceValue : value,
|
|
13
|
-
getSectionsFromValue: (utils,
|
|
13
|
+
getSectionsFromValue: (utils, date, prevSections, isRTL, getSectionsFromDate) => {
|
|
14
14
|
const shouldReUsePrevDateSections = !utils.isValid(date) && !!prevSections;
|
|
15
15
|
if (shouldReUsePrevDateSections) {
|
|
16
16
|
return prevSections;
|
|
17
17
|
}
|
|
18
|
-
return addPositionPropertiesToSections(
|
|
18
|
+
return addPositionPropertiesToSections(getSectionsFromDate(date), isRTL);
|
|
19
19
|
},
|
|
20
|
-
getValueStrFromSections:
|
|
21
|
-
getActiveDateSections: sections => sections,
|
|
20
|
+
getValueStrFromSections: createDateStrForInputFromSections,
|
|
22
21
|
getActiveDateManager: (utils, state) => ({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
date: state.value,
|
|
23
|
+
referenceDate: state.referenceValue,
|
|
24
|
+
getSections: sections => sections,
|
|
25
|
+
getNewValuesFromNewActiveDate: newActiveDate => ({
|
|
26
26
|
value: newActiveDate,
|
|
27
27
|
referenceValue: newActiveDate == null || !utils.isValid(newActiveDate) ? state.referenceValue : newActiveDate
|
|
28
28
|
})
|
|
29
29
|
}),
|
|
30
30
|
parseValueStr: (valueStr, referenceValue, parseDate) => parseDate(valueStr.trim(), referenceValue),
|
|
31
|
-
hasError: error => error != null
|
|
32
|
-
getSectionOrder: (utils, localeText, format, isRTL) => getSectionOrder(splitFormatIntoSections(utils, localeText, format, null), isRTL)
|
|
31
|
+
hasError: error => error != null
|
|
33
32
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateOrTimeView, DateView } from '
|
|
1
|
+
import { DateOrTimeView, DateView } from '../../models';
|
|
2
2
|
export declare const isYearOnlyView: (views: readonly DateView[]) => views is readonly "year"[];
|
|
3
3
|
export declare const isYearAndMonthViews: (views: readonly DateView[]) => views is readonly ("month" | "year")[];
|
|
4
4
|
export declare const applyDefaultViewProps: <TView extends DateOrTimeView>({ openTo, defaultOpenTo, views, defaultViews, }: {
|
|
@@ -150,6 +150,7 @@ export var AdapterDateFns = /*#__PURE__*/function (_BaseAdapterDateFns) {
|
|
|
150
150
|
return token;
|
|
151
151
|
}).join('');
|
|
152
152
|
};
|
|
153
|
+
// Redefined here just to show how it can be written using expandFormat
|
|
153
154
|
_this.getFormatHelperText = function (format) {
|
|
154
155
|
return _this.expandFormat(format).replace(/(aaa|aa|a)/g, '(a|p)m').toLocaleLowerCase();
|
|
155
156
|
};
|
|
@@ -38,6 +38,74 @@ var formatTokenMap = {
|
|
|
38
38
|
// Day of the month
|
|
39
39
|
d: 'day',
|
|
40
40
|
dd: 'day',
|
|
41
|
+
do: 'day',
|
|
42
|
+
// Day of the week
|
|
43
|
+
E: {
|
|
44
|
+
sectionType: 'weekDay',
|
|
45
|
+
contentType: 'letter'
|
|
46
|
+
},
|
|
47
|
+
EE: {
|
|
48
|
+
sectionType: 'weekDay',
|
|
49
|
+
contentType: 'letter'
|
|
50
|
+
},
|
|
51
|
+
EEE: {
|
|
52
|
+
sectionType: 'weekDay',
|
|
53
|
+
contentType: 'letter'
|
|
54
|
+
},
|
|
55
|
+
EEEE: {
|
|
56
|
+
sectionType: 'weekDay',
|
|
57
|
+
contentType: 'letter'
|
|
58
|
+
},
|
|
59
|
+
EEEEE: {
|
|
60
|
+
sectionType: 'weekDay',
|
|
61
|
+
contentType: 'letter'
|
|
62
|
+
},
|
|
63
|
+
i: 'weekDay',
|
|
64
|
+
ii: 'weekDay',
|
|
65
|
+
iii: {
|
|
66
|
+
sectionType: 'weekDay',
|
|
67
|
+
contentType: 'letter'
|
|
68
|
+
},
|
|
69
|
+
iiii: {
|
|
70
|
+
sectionType: 'weekDay',
|
|
71
|
+
contentType: 'letter'
|
|
72
|
+
},
|
|
73
|
+
e: 'weekDay',
|
|
74
|
+
ee: 'weekDay',
|
|
75
|
+
eee: {
|
|
76
|
+
sectionType: 'weekDay',
|
|
77
|
+
contentType: 'letter'
|
|
78
|
+
},
|
|
79
|
+
eeee: {
|
|
80
|
+
sectionType: 'weekDay',
|
|
81
|
+
contentType: 'letter'
|
|
82
|
+
},
|
|
83
|
+
eeeee: {
|
|
84
|
+
sectionType: 'weekDay',
|
|
85
|
+
contentType: 'letter'
|
|
86
|
+
},
|
|
87
|
+
eeeeee: {
|
|
88
|
+
sectionType: 'weekDay',
|
|
89
|
+
contentType: 'letter'
|
|
90
|
+
},
|
|
91
|
+
c: 'weekDay',
|
|
92
|
+
cc: 'weekDay',
|
|
93
|
+
ccc: {
|
|
94
|
+
sectionType: 'weekDay',
|
|
95
|
+
contentType: 'letter'
|
|
96
|
+
},
|
|
97
|
+
cccc: {
|
|
98
|
+
sectionType: 'weekDay',
|
|
99
|
+
contentType: 'letter'
|
|
100
|
+
},
|
|
101
|
+
ccccc: {
|
|
102
|
+
sectionType: 'weekDay',
|
|
103
|
+
contentType: 'letter'
|
|
104
|
+
},
|
|
105
|
+
cccccc: {
|
|
106
|
+
sectionType: 'weekDay',
|
|
107
|
+
contentType: 'letter'
|
|
108
|
+
},
|
|
41
109
|
// Meridiem
|
|
42
110
|
a: 'meridiem',
|
|
43
111
|
aa: 'meridiem',
|
|
@@ -82,6 +150,7 @@ export var AdapterDateFnsJalali = /*#__PURE__*/function (_BaseAdapterDateFnsJa)
|
|
|
82
150
|
return token;
|
|
83
151
|
}).join('');
|
|
84
152
|
};
|
|
153
|
+
// Redefined here just to show how it can be written using expandFormat
|
|
85
154
|
_this.getFormatHelperText = function (format) {
|
|
86
155
|
return _this.expandFormat(format).replace(/(aaa|aa|a)/g, '(a|p)m').toLocaleLowerCase();
|
|
87
156
|
};
|
|
@@ -87,6 +87,10 @@ export var AdapterDayjs = /*#__PURE__*/function (_BaseAdapterDayjs) {
|
|
|
87
87
|
/* istanbul ignore next */
|
|
88
88
|
return /A|a/.test(_this.getLocaleFormats().LT || '');
|
|
89
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* The current getFormatHelperText method uses an outdated format parsing logic.
|
|
92
|
+
* We should use this one in the future to support all localized formats.
|
|
93
|
+
*/
|
|
90
94
|
_this.expandFormat = function (format) {
|
|
91
95
|
var localeFormats = _this.getLocaleFormats();
|
|
92
96
|
|
|
@@ -101,6 +105,7 @@ export var AdapterDayjs = /*#__PURE__*/function (_BaseAdapterDayjs) {
|
|
|
101
105
|
return a || localeFormats[b] || t(localeFormats[B]);
|
|
102
106
|
});
|
|
103
107
|
};
|
|
108
|
+
// Redefined here just to show how it can be written using expandFormat
|
|
104
109
|
_this.getFormatHelperText = function (format) {
|
|
105
110
|
return _this.expandFormat(format).replace(/a/gi, '(a|p)m').toLocaleLowerCase();
|
|
106
111
|
};
|
|
@@ -98,13 +98,23 @@ export var AdapterLuxon = /*#__PURE__*/function (_BaseAdapterLuxon) {
|
|
|
98
98
|
if (!DateTime.expandFormat) {
|
|
99
99
|
throw Error('Your luxon version does not support `expandFormat`. Consider upgrading it to v3.0.2');
|
|
100
100
|
}
|
|
101
|
+
// Extract escaped section to avoid entending them
|
|
102
|
+
var longFormatRegexp = /''|'(''|[^'])+('|$)|[^']*/g;
|
|
103
|
+
return format.match(longFormatRegexp).map(function (token) {
|
|
104
|
+
var firstCharacter = token[0];
|
|
105
|
+
if (firstCharacter === "'") {
|
|
106
|
+
return token;
|
|
107
|
+
}
|
|
108
|
+
return DateTime.expandFormat(token, {
|
|
109
|
+
locale: _this.locale
|
|
110
|
+
});
|
|
111
|
+
}).join('')
|
|
101
112
|
// The returned format can contain `yyyyy` which means year between 4 and 6 digits.
|
|
102
113
|
// This value is supported by luxon parser but not luxon formatter.
|
|
103
114
|
// To avoid conflicts, we replace it by 4 digits which is enough for most use-cases.
|
|
104
|
-
|
|
105
|
-
locale: _this.locale
|
|
106
|
-
}).replace('yyyyy', 'yyyy');
|
|
115
|
+
.replace('yyyyy', 'yyyy');
|
|
107
116
|
};
|
|
117
|
+
// Redefined here just to show how it can be written using expandFormat
|
|
108
118
|
_this.getFormatHelperText = function (format) {
|
|
109
119
|
return _this.expandFormat(format).replace(/(a)/g, '(a|p)m').toLocaleLowerCase();
|
|
110
120
|
};
|
|
@@ -78,6 +78,10 @@ export var AdapterMoment = /*#__PURE__*/function (_BaseAdapterMoment) {
|
|
|
78
78
|
start: '[',
|
|
79
79
|
end: ']'
|
|
80
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* The current getFormatHelperText method uses an outdated format parsing logic.
|
|
83
|
+
* We should use this one in the future to support all localized formats.
|
|
84
|
+
*/
|
|
81
85
|
_this.expandFormat = function (format) {
|
|
82
86
|
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
|
|
83
87
|
var localFormattingTokens = /(\[[^[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
|
|
@@ -92,6 +96,7 @@ export var AdapterMoment = /*#__PURE__*/function (_BaseAdapterMoment) {
|
|
|
92
96
|
_this.getCurrentLocaleCode = function () {
|
|
93
97
|
return _this.locale || defaultMoment.locale();
|
|
94
98
|
};
|
|
99
|
+
// Redefined here just to show how it can be written using expandFormat
|
|
95
100
|
_this.getFormatHelperText = function (format) {
|
|
96
101
|
return _this.expandFormat(format).replace(/a/gi, '(a|p)m').toLocaleLowerCase();
|
|
97
102
|
};
|
|
@@ -62,6 +62,10 @@ export var AdapterMomentHijri = /*#__PURE__*/function (_BaseAdapterMomentHij) {
|
|
|
62
62
|
start: '[',
|
|
63
63
|
end: ']'
|
|
64
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* The current getFormatHelperText method uses an outdated format parsing logic.
|
|
67
|
+
* We should use this one in the future to support all localized formats.
|
|
68
|
+
*/
|
|
65
69
|
_this.expandFormat = function (format) {
|
|
66
70
|
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
|
|
67
71
|
var localFormattingTokens = /(\[[^[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
|
|
@@ -73,6 +77,7 @@ export var AdapterMomentHijri = /*#__PURE__*/function (_BaseAdapterMomentHij) {
|
|
|
73
77
|
return token;
|
|
74
78
|
}).join('').replace('dd', 'iDD'); // Fix for https://github.com/dmtrKovalenko/date-io/pull/632
|
|
75
79
|
};
|
|
80
|
+
// Redefined here just to show how it can be written using expandFormat
|
|
76
81
|
_this.getFormatHelperText = function (format) {
|
|
77
82
|
return _this.expandFormat(format).replace(/a/gi, '(a|p)m').replace('iY', 'Y').replace('iM', 'M').replace('iD', 'D').toLocaleLowerCase();
|
|
78
83
|
};
|
|
@@ -59,6 +59,10 @@ export var AdapterMomentJalaali = /*#__PURE__*/function (_BaseAdapterMomentJal)
|
|
|
59
59
|
start: '[',
|
|
60
60
|
end: ']'
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* The current getFormatHelperText method uses an outdated format parsing logic.
|
|
64
|
+
* We should use this one in the future to support all localized formats.
|
|
65
|
+
*/
|
|
62
66
|
_this.expandFormat = function (format) {
|
|
63
67
|
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
|
|
64
68
|
var localFormattingTokens = /(\[[^[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
|
|
@@ -70,6 +74,7 @@ export var AdapterMomentJalaali = /*#__PURE__*/function (_BaseAdapterMomentJal)
|
|
|
70
74
|
return token;
|
|
71
75
|
}).join('').replace('dd', 'jDD'); // Fix for https://github.com/dmtrKovalenko/date-io/pull/632;
|
|
72
76
|
};
|
|
77
|
+
// Redefined here just to show how it can be written using expandFormat
|
|
73
78
|
_this.getFormatHelperText = function (format) {
|
|
74
79
|
return _this.expandFormat(format).replace(/a/gi, '(a|p)m').replace('jY', 'Y').replace('jM', 'M').replace('jD', 'D').toLocaleLowerCase();
|
|
75
80
|
};
|
|
@@ -263,6 +263,10 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
|
|
|
263
263
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
264
264
|
*/
|
|
265
265
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
266
|
+
/**
|
|
267
|
+
* The ref object used to imperatively interact with the field.
|
|
268
|
+
*/
|
|
269
|
+
unstableFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
266
270
|
/**
|
|
267
271
|
* The selected value.
|
|
268
272
|
* Used when the component is controlled.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange"];
|
|
3
|
+
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
4
4
|
import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
|
|
5
5
|
import { useField } from '../internals/hooks/useField';
|
|
6
6
|
import { validateDate } from '../internals/hooks/validation/useDateValidation';
|
|
@@ -37,6 +37,7 @@ export var useDateField = function useDateField(_ref) {
|
|
|
37
37
|
disablePast = _useDefaultizedDateFi.disablePast,
|
|
38
38
|
selectedSections = _useDefaultizedDateFi.selectedSections,
|
|
39
39
|
onSelectedSectionsChange = _useDefaultizedDateFi.onSelectedSectionsChange,
|
|
40
|
+
unstableFieldRef = _useDefaultizedDateFi.unstableFieldRef,
|
|
40
41
|
other = _objectWithoutProperties(_useDefaultizedDateFi, _excluded);
|
|
41
42
|
return useField({
|
|
42
43
|
inputRef: inputRef,
|
|
@@ -56,7 +57,8 @@ export var useDateField = function useDateField(_ref) {
|
|
|
56
57
|
disableFuture: disableFuture,
|
|
57
58
|
disablePast: disablePast,
|
|
58
59
|
selectedSections: selectedSections,
|
|
59
|
-
onSelectedSectionsChange: onSelectedSectionsChange
|
|
60
|
+
onSelectedSectionsChange: onSelectedSectionsChange,
|
|
61
|
+
unstableFieldRef: unstableFieldRef
|
|
60
62
|
},
|
|
61
63
|
valueManager: singleItemValueManager,
|
|
62
64
|
fieldValueManager: singleItemFieldValueManager,
|
|
@@ -311,6 +311,10 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
311
311
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
312
312
|
*/
|
|
313
313
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
314
|
+
/**
|
|
315
|
+
* The ref object used to imperatively interact with the field.
|
|
316
|
+
*/
|
|
317
|
+
unstableFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
314
318
|
/**
|
|
315
319
|
* The selected value.
|
|
316
320
|
* Used when the component is controlled.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "disableIgnoringDatePartForTimeValidation", "shouldDisableClock", "shouldDisableTime", "selectedSections", "onSelectedSectionsChange", "ampm"];
|
|
3
|
+
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "disableIgnoringDatePartForTimeValidation", "shouldDisableClock", "shouldDisableTime", "selectedSections", "onSelectedSectionsChange", "ampm", "unstableFieldRef"];
|
|
4
4
|
import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
|
|
5
5
|
import { useField } from '../internals/hooks/useField';
|
|
6
6
|
import { validateDateTime } from '../internals/hooks/validation/useDateTimeValidation';
|
|
@@ -51,6 +51,7 @@ export var useDateTimeField = function useDateTimeField(_ref) {
|
|
|
51
51
|
selectedSections = _useDefaultizedDateTi.selectedSections,
|
|
52
52
|
onSelectedSectionsChange = _useDefaultizedDateTi.onSelectedSectionsChange,
|
|
53
53
|
ampm = _useDefaultizedDateTi.ampm,
|
|
54
|
+
unstableFieldRef = _useDefaultizedDateTi.unstableFieldRef,
|
|
54
55
|
other = _objectWithoutProperties(_useDefaultizedDateTi, _excluded);
|
|
55
56
|
return useField({
|
|
56
57
|
inputRef: inputRef,
|
|
@@ -77,7 +78,8 @@ export var useDateTimeField = function useDateTimeField(_ref) {
|
|
|
77
78
|
disableIgnoringDatePartForTimeValidation: disableIgnoringDatePartForTimeValidation,
|
|
78
79
|
selectedSections: selectedSections,
|
|
79
80
|
onSelectedSectionsChange: onSelectedSectionsChange,
|
|
80
|
-
ampm: ampm
|
|
81
|
+
ampm: ampm,
|
|
82
|
+
unstableFieldRef: unstableFieldRef
|
|
81
83
|
},
|
|
82
84
|
valueManager: singleItemValueManager,
|
|
83
85
|
fieldValueManager: singleItemFieldValueManager,
|
|
@@ -36,16 +36,16 @@ var styleArg = function styleArg(_ref) {
|
|
|
36
36
|
height: DAY_SIZE,
|
|
37
37
|
borderRadius: '50%',
|
|
38
38
|
padding: 0,
|
|
39
|
-
//
|
|
40
|
-
backgroundColor:
|
|
39
|
+
// explicitly setting to `transparent` to avoid potentially getting impacted by change from the overridden component
|
|
40
|
+
backgroundColor: 'transparent',
|
|
41
41
|
color: (theme.vars || theme).palette.text.primary,
|
|
42
42
|
'@media (pointer: fine)': {
|
|
43
43
|
'&:hover': {
|
|
44
|
-
backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.
|
|
44
|
+
backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.primary.mainChannel, " / ").concat(theme.vars.palette.action.hoverOpacity, ")") : alpha(theme.palette.primary.main, theme.palette.action.hoverOpacity)
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
'&:focus': _defineProperty({
|
|
48
|
-
backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.
|
|
48
|
+
backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.primary.mainChannel, " / ").concat(theme.vars.palette.action.focusOpacity, ")") : alpha(theme.palette.primary.main, theme.palette.action.focusOpacity)
|
|
49
49
|
}, "&.".concat(pickersDayClasses.selected), {
|
|
50
50
|
willChange: 'background-color',
|
|
51
51
|
backgroundColor: (theme.vars || theme).palette.primary.dark
|
|
@@ -274,6 +274,10 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
274
274
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
275
275
|
*/
|
|
276
276
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
277
|
+
/**
|
|
278
|
+
* The ref object used to imperatively interact with the field.
|
|
279
|
+
*/
|
|
280
|
+
unstableFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
277
281
|
/**
|
|
278
282
|
* The selected value.
|
|
279
283
|
* Used when the component is controlled.
|