@mui/x-date-pickers 8.0.0-alpha.12 → 8.0.0-alpha.14
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/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
- package/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +96 -94
- package/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
- package/AdapterDateFnsV2/AdapterDateFnsV2.js +96 -94
- package/AdapterDayjs/AdapterDayjs.js +11 -5
- package/CHANGELOG.md +430 -0
- package/DateCalendar/DateCalendar.js +1 -1
- package/DateField/useDateField.d.ts +1 -1
- package/DatePicker/DatePicker.types.d.ts +2 -2
- package/DatePicker/shared.d.ts +1 -1
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
- package/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
- package/DateTimePicker/DateTimePickerToolbar.js +1 -1
- package/DateTimePicker/shared.d.ts +18 -10
- package/DateTimePicker/shared.js +23 -2
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -11
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
- package/MobileDateTimePicker/MobileDateTimePicker.js +61 -6
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
- package/PickersTextField/PickersTextField.js +3 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +60 -6
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
- package/TimeClock/Clock.js +2 -2
- package/TimeClock/ClockPointer.js +1 -1
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimePicker/TimePicker.types.d.ts +2 -2
- package/TimePicker/shared.d.ts +1 -1
- package/esm/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
- package/esm/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +47 -45
- package/esm/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
- package/esm/AdapterDateFnsV2/AdapterDateFnsV2.js +47 -45
- package/esm/AdapterDayjs/AdapterDayjs.js +9 -5
- package/esm/DateCalendar/DateCalendar.js +1 -1
- package/esm/DateField/useDateField.d.ts +1 -1
- package/esm/DatePicker/DatePicker.types.d.ts +2 -2
- package/esm/DatePicker/shared.d.ts +1 -1
- package/esm/DateTimeField/useDateTimeField.d.ts +1 -1
- package/esm/DateTimePicker/DateTimePicker.types.d.ts +3 -3
- package/esm/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
- package/esm/DateTimePicker/DateTimePickerToolbar.js +1 -1
- package/esm/DateTimePicker/shared.d.ts +18 -10
- package/esm/DateTimePicker/shared.js +23 -2
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -12
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
- package/esm/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/esm/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
- package/esm/MobileDateTimePicker/MobileDateTimePicker.js +62 -7
- package/esm/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
- package/esm/PickersTextField/PickersTextField.js +3 -1
- package/esm/StaticDateTimePicker/StaticDateTimePicker.js +61 -7
- package/esm/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
- package/esm/TimeClock/Clock.js +2 -2
- package/esm/TimeClock/ClockPointer.js +1 -1
- package/esm/TimeField/useTimeField.d.ts +1 -1
- package/esm/TimePicker/TimePicker.types.d.ts +2 -2
- package/esm/TimePicker/shared.d.ts +1 -1
- package/esm/hooks/useSplitFieldProps.d.ts +1 -1
- package/esm/hooks/useSplitFieldProps.js +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/components/PickerFieldUI.d.ts +7 -0
- package/esm/internals/components/PickerFieldUI.js +8 -4
- package/esm/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
- package/esm/internals/components/PickerPopper/PickerPopper.js +26 -14
- package/esm/internals/components/PickerProvider.d.ts +158 -7
- package/esm/internals/components/PickerProvider.js +7 -2
- package/esm/internals/demo/DemoContainer.js +3 -3
- package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
- package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -12
- package/esm/internals/hooks/useField/index.d.ts +1 -2
- package/esm/internals/hooks/useField/useField.js +7 -8
- package/esm/internals/hooks/useField/useField.types.d.ts +56 -47
- package/esm/internals/hooks/useField/useField.utils.js +4 -1
- package/esm/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/esm/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
- package/esm/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -8
- package/esm/internals/hooks/useField/useFieldState.d.ts +2 -1
- package/esm/internals/hooks/useField/useFieldState.js +136 -83
- package/esm/internals/hooks/useField/useFieldV6TextField.js +9 -7
- package/esm/internals/hooks/useField/useFieldV7TextField.js +9 -8
- package/esm/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
- package/esm/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
- package/esm/internals/hooks/useNullableFieldPrivateContext.d.ts +9 -0
- package/esm/internals/hooks/useNullableFieldPrivateContext.js +5 -0
- package/esm/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
- package/esm/internals/hooks/usePicker/hooks/useOrientation.js +34 -0
- package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
- package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +210 -0
- package/esm/internals/hooks/usePicker/index.d.ts +1 -3
- package/esm/internals/hooks/usePicker/usePicker.d.ts +5 -5
- package/esm/internals/hooks/usePicker/usePicker.js +276 -34
- package/esm/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
- package/esm/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
- package/esm/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
- package/esm/internals/hooks/useValueWithTimezone.d.ts +1 -1
- package/esm/internals/index.d.ts +7 -9
- package/esm/internals/index.js +2 -1
- package/esm/internals/models/fields.d.ts +3 -10
- package/esm/internals/models/manager.d.ts +108 -4
- package/esm/internals/models/props/basePickerProps.d.ts +2 -2
- package/esm/internals/models/props/time.d.ts +1 -1
- package/esm/internals/utils/date-time-utils.d.ts +2 -2
- package/esm/internals/utils/valueManagers.d.ts +1 -1
- package/esm/internals/utils/valueManagers.js +10 -18
- package/esm/locales/bnBD.d.ts +80 -0
- package/esm/locales/bnBD.js +73 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +1 -0
- package/esm/managers/useDateManager.d.ts +3 -4
- package/esm/managers/useDateTimeManager.d.ts +3 -4
- package/esm/managers/useTimeManager.d.ts +3 -4
- package/esm/models/adapters.d.ts +2 -1
- package/esm/models/fields.d.ts +2 -2
- package/esm/models/manager.d.ts +4 -5
- package/esm/validation/extractValidationProps.d.ts +1 -1
- package/esm/validation/index.d.ts +1 -1
- package/esm/validation/useValidation.d.ts +2 -2
- package/hooks/useSplitFieldProps.d.ts +1 -1
- package/hooks/useSplitFieldProps.js +1 -1
- package/index.js +1 -1
- package/internals/components/PickerFieldUI.d.ts +7 -0
- package/internals/components/PickerFieldUI.js +9 -3
- package/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
- package/internals/components/PickerPopper/PickerPopper.js +25 -13
- package/internals/components/PickerProvider.d.ts +158 -7
- package/internals/components/PickerProvider.js +8 -3
- package/internals/demo/DemoContainer.js +3 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -12
- package/internals/hooks/useField/index.d.ts +1 -2
- package/internals/hooks/useField/useField.js +7 -8
- package/internals/hooks/useField/useField.types.d.ts +56 -47
- package/internals/hooks/useField/useField.utils.js +4 -1
- package/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -10
- package/internals/hooks/useField/useFieldState.d.ts +2 -1
- package/internals/hooks/useField/useFieldState.js +135 -82
- package/internals/hooks/useField/useFieldV6TextField.js +9 -7
- package/internals/hooks/useField/useFieldV7TextField.js +9 -8
- package/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
- package/internals/hooks/useNullableFieldPrivateContext.d.ts +9 -0
- package/internals/hooks/useNullableFieldPrivateContext.js +13 -0
- package/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
- package/internals/hooks/usePicker/hooks/useOrientation.js +42 -0
- package/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
- package/internals/hooks/usePicker/{usePickerValue.js → hooks/useValueAndOpenStates.js} +97 -114
- package/internals/hooks/usePicker/index.d.ts +1 -3
- package/internals/hooks/usePicker/usePicker.d.ts +5 -5
- package/internals/hooks/usePicker/usePicker.js +278 -34
- package/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
- package/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
- package/internals/hooks/useValueWithTimezone.d.ts +1 -1
- package/internals/index.d.ts +7 -9
- package/internals/index.js +19 -0
- package/internals/models/fields.d.ts +3 -10
- package/internals/models/manager.d.ts +108 -4
- package/internals/models/props/basePickerProps.d.ts +2 -2
- package/internals/models/props/time.d.ts +1 -1
- package/internals/utils/date-time-utils.d.ts +2 -2
- package/internals/utils/valueManagers.d.ts +1 -1
- package/internals/utils/valueManagers.js +10 -18
- package/locales/bnBD.d.ts +80 -0
- package/locales/bnBD.js +79 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +11 -0
- package/managers/useDateManager.d.ts +3 -4
- package/managers/useDateTimeManager.d.ts +3 -4
- package/managers/useTimeManager.d.ts +3 -4
- package/models/adapters.d.ts +2 -1
- package/models/fields.d.ts +2 -2
- package/models/manager.d.ts +4 -5
- package/modern/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
- package/modern/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +47 -45
- package/modern/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
- package/modern/AdapterDateFnsV2/AdapterDateFnsV2.js +47 -45
- package/modern/AdapterDayjs/AdapterDayjs.js +9 -5
- package/modern/DateCalendar/DateCalendar.js +1 -1
- package/modern/DateField/useDateField.d.ts +1 -1
- package/modern/DatePicker/DatePicker.types.d.ts +2 -2
- package/modern/DatePicker/shared.d.ts +1 -1
- package/modern/DateTimeField/useDateTimeField.d.ts +1 -1
- package/modern/DateTimePicker/DateTimePicker.types.d.ts +3 -3
- package/modern/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
- package/modern/DateTimePicker/DateTimePickerToolbar.js +1 -1
- package/modern/DateTimePicker/shared.d.ts +18 -10
- package/modern/DateTimePicker/shared.js +23 -2
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -12
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
- package/modern/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +62 -7
- package/modern/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
- package/modern/PickersTextField/PickersTextField.js +3 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +61 -7
- package/modern/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
- package/modern/TimeClock/Clock.js +2 -2
- package/modern/TimeClock/ClockPointer.js +1 -1
- package/modern/TimeField/useTimeField.d.ts +1 -1
- package/modern/TimePicker/TimePicker.types.d.ts +2 -2
- package/modern/TimePicker/shared.d.ts +1 -1
- package/modern/hooks/useSplitFieldProps.d.ts +1 -1
- package/modern/hooks/useSplitFieldProps.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerFieldUI.d.ts +7 -0
- package/modern/internals/components/PickerFieldUI.js +8 -4
- package/modern/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
- package/modern/internals/components/PickerPopper/PickerPopper.js +26 -14
- package/modern/internals/components/PickerProvider.d.ts +158 -7
- package/modern/internals/components/PickerProvider.js +7 -2
- package/modern/internals/demo/DemoContainer.js +3 -3
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -12
- package/modern/internals/hooks/useField/index.d.ts +1 -2
- package/modern/internals/hooks/useField/useField.js +7 -8
- package/modern/internals/hooks/useField/useField.types.d.ts +56 -47
- package/modern/internals/hooks/useField/useField.utils.js +4 -1
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -8
- package/modern/internals/hooks/useField/useFieldState.d.ts +2 -1
- package/modern/internals/hooks/useField/useFieldState.js +136 -83
- package/modern/internals/hooks/useField/useFieldV6TextField.js +9 -7
- package/modern/internals/hooks/useField/useFieldV7TextField.js +9 -8
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
- package/modern/internals/hooks/useNullableFieldPrivateContext.d.ts +9 -0
- package/modern/internals/hooks/useNullableFieldPrivateContext.js +5 -0
- package/modern/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
- package/modern/internals/hooks/usePicker/hooks/useOrientation.js +34 -0
- package/modern/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
- package/modern/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +210 -0
- package/modern/internals/hooks/usePicker/index.d.ts +1 -3
- package/modern/internals/hooks/usePicker/usePicker.d.ts +5 -5
- package/modern/internals/hooks/usePicker/usePicker.js +276 -34
- package/modern/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
- package/modern/internals/hooks/useValueWithTimezone.d.ts +1 -1
- package/modern/internals/index.d.ts +7 -9
- package/modern/internals/index.js +2 -1
- package/modern/internals/models/fields.d.ts +3 -10
- package/modern/internals/models/manager.d.ts +108 -4
- package/modern/internals/models/props/basePickerProps.d.ts +2 -2
- package/modern/internals/models/props/time.d.ts +1 -1
- package/modern/internals/utils/date-time-utils.d.ts +2 -2
- package/modern/internals/utils/valueManagers.d.ts +1 -1
- package/modern/internals/utils/valueManagers.js +10 -18
- package/modern/locales/bnBD.d.ts +80 -0
- package/modern/locales/bnBD.js +73 -0
- package/modern/locales/index.d.ts +1 -0
- package/modern/locales/index.js +1 -0
- package/modern/managers/useDateManager.d.ts +3 -4
- package/modern/managers/useDateTimeManager.d.ts +3 -4
- package/modern/managers/useTimeManager.d.ts +3 -4
- package/modern/models/adapters.d.ts +2 -1
- package/modern/models/fields.d.ts +2 -2
- package/modern/models/manager.d.ts +4 -5
- package/modern/validation/extractValidationProps.d.ts +1 -1
- package/modern/validation/index.d.ts +1 -1
- package/modern/validation/useValidation.d.ts +2 -2
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/validation/extractValidationProps.d.ts +1 -1
- package/validation/index.d.ts +1 -1
- package/validation/useValidation.d.ts +2 -2
- package/esm/internals/hooks/useOpenState.d.ts +0 -14
- package/esm/internals/hooks/useOpenState.js +0 -37
- package/esm/internals/hooks/usePicker/usePickerProvider.d.ts +0 -60
- package/esm/internals/hooks/usePicker/usePickerProvider.js +0 -111
- package/esm/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
- package/esm/internals/hooks/usePicker/usePickerValue.js +0 -226
- package/esm/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
- package/esm/internals/hooks/usePicker/usePickerValue.types.js +0 -1
- package/esm/internals/hooks/usePicker/usePickerViews.d.ts +0 -120
- package/esm/internals/hooks/usePicker/usePickerViews.js +0 -176
- package/internals/hooks/useOpenState.d.ts +0 -14
- package/internals/hooks/useOpenState.js +0 -46
- package/internals/hooks/usePicker/usePickerProvider.d.ts +0 -60
- package/internals/hooks/usePicker/usePickerProvider.js +0 -121
- package/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
- package/internals/hooks/usePicker/usePickerValue.types.js +0 -5
- package/internals/hooks/usePicker/usePickerViews.d.ts +0 -120
- package/internals/hooks/usePicker/usePickerViews.js +0 -183
- package/modern/internals/hooks/useOpenState.d.ts +0 -14
- package/modern/internals/hooks/useOpenState.js +0 -37
- package/modern/internals/hooks/usePicker/usePickerProvider.d.ts +0 -60
- package/modern/internals/hooks/usePicker/usePickerProvider.js +0 -111
- package/modern/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
- package/modern/internals/hooks/usePicker/usePickerValue.js +0 -226
- package/modern/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
- package/modern/internals/hooks/usePicker/usePickerValue.types.js +0 -1
- package/modern/internals/hooks/usePicker/usePickerViews.d.ts +0 -120
- package/modern/internals/hooks/usePicker/usePickerViews.js +0 -176
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SxProps } from '@mui/system';
|
|
3
3
|
import { Theme } from '@mui/material/styles';
|
|
4
|
-
import { PickerOwnerState } from "../../models/index.js";
|
|
4
|
+
import { PickerChangeImportance, PickerOwnerState, PickersTimezone } from "../../models/index.js";
|
|
5
5
|
import { PickersInputLocaleText } from "../../locales/index.js";
|
|
6
6
|
import { DateOrTimeViewWithMeridiem, PickerOrientation, PickerValidValue, PickerVariant } from "../models/index.js";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { PickerFieldPrivateContextValue } from "../hooks/useField/useFieldInternalPropsWithDefaults.js";
|
|
7
|
+
import { PickerFieldPrivateContextValue } from "../hooks/useNullableFieldPrivateContext.js";
|
|
8
|
+
import type { PickersShortcutsItemContext } from '../../PickersShortcuts';
|
|
10
9
|
export declare const PickerActionsContext: React.Context<PickerActionsContextValue<any, any, any> | null>;
|
|
11
10
|
export declare const PickerPrivateContext: React.Context<PickerPrivateContextValue>;
|
|
12
11
|
/**
|
|
@@ -26,7 +25,24 @@ export interface PickerProviderProps<TValue extends PickerValidValue> {
|
|
|
26
25
|
localeText: PickersInputLocaleText | undefined;
|
|
27
26
|
children: React.ReactNode;
|
|
28
27
|
}
|
|
29
|
-
export interface PickerContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends
|
|
28
|
+
export interface PickerContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends PickerActionsContextValue<TValue, TView, TError> {
|
|
29
|
+
/**
|
|
30
|
+
* The current value of the picker.
|
|
31
|
+
*/
|
|
32
|
+
value: TValue;
|
|
33
|
+
/**
|
|
34
|
+
* The timezone to use when rendering the dates.
|
|
35
|
+
* If a `timezone` prop is provided, it will be used.
|
|
36
|
+
* If the `value` prop contains a valid date, its timezone will be used.
|
|
37
|
+
* If no `value` prop is provided, but the `defaultValue` contains a valid date, its timezone will be used.
|
|
38
|
+
* If no `value` or `defaultValue` is provided, but the `referenceDate` is provided, its timezone will be used.
|
|
39
|
+
* Otherwise, the timezone will be the default one of your date library.
|
|
40
|
+
*/
|
|
41
|
+
timezone: PickersTimezone;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the picker is open.
|
|
44
|
+
*/
|
|
45
|
+
open: boolean;
|
|
30
46
|
/**
|
|
31
47
|
* Whether the picker is disabled.
|
|
32
48
|
*/
|
|
@@ -35,6 +51,31 @@ export interface PickerContextValue<TValue extends PickerValidValue, TView exten
|
|
|
35
51
|
* Whether the picker is read-only.
|
|
36
52
|
*/
|
|
37
53
|
readOnly: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the picker should be focused on mount.
|
|
56
|
+
* If the picker has a field and is not open, the field should be focused.
|
|
57
|
+
* If the picker does not have a field (if it is a static picker) or is not open, the view should be focused.
|
|
58
|
+
*/
|
|
59
|
+
autoFocus: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The views that the picker has to render.
|
|
62
|
+
* It is equal to the picker `views` prop—if defined.
|
|
63
|
+
* Otherwise, a default set of views is provided based on the component you are using:
|
|
64
|
+
* - Date Pickers: ['year', 'day']
|
|
65
|
+
* - Time Pickers: ['hours', 'minutes']
|
|
66
|
+
* - Date Time Pickers: ['year', 'day', 'hours', 'minutes']
|
|
67
|
+
* - Date Range Pickers: ['day']
|
|
68
|
+
* - Date Time Range Pickers: ['day', 'hours', 'minutes']
|
|
69
|
+
*/
|
|
70
|
+
views: readonly TView[];
|
|
71
|
+
/**
|
|
72
|
+
* The currently rendered view.
|
|
73
|
+
*/
|
|
74
|
+
view: TView | null;
|
|
75
|
+
/**
|
|
76
|
+
* The view showed when first opening the picker.
|
|
77
|
+
*/
|
|
78
|
+
initialView: TView | null;
|
|
38
79
|
/**
|
|
39
80
|
* The responsive variant of the picker.
|
|
40
81
|
* It is equal to "desktop" when using a desktop picker (like <DesktopDatePicker />).
|
|
@@ -68,6 +109,11 @@ export interface PickerContextValue<TValue extends PickerValidValue, TView exten
|
|
|
68
109
|
* If it is "enabled", the field should render an interactive UI to open the Picker.
|
|
69
110
|
*/
|
|
70
111
|
triggerStatus: 'hidden' | 'disabled' | 'enabled';
|
|
112
|
+
/**
|
|
113
|
+
* The ref to attach to the popup's outermost element that contains the view, if any.
|
|
114
|
+
* When using a built-in popup component, this property is automatically attached to the appropriate element.
|
|
115
|
+
*/
|
|
116
|
+
popupRef: React.RefObject<any>;
|
|
71
117
|
/**
|
|
72
118
|
* The format to use when rendering the value in the field.
|
|
73
119
|
* It is equal to the picker `format` prop if defined.
|
|
@@ -111,10 +157,115 @@ export interface PickerContextValue<TValue extends PickerValidValue, TView exten
|
|
|
111
157
|
*/
|
|
112
158
|
rootRef: React.ForwardedRef<HTMLDivElement> | undefined;
|
|
113
159
|
}
|
|
114
|
-
export interface PickerActionsContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError = string | null>
|
|
115
|
-
|
|
160
|
+
export interface PickerActionsContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError = string | null> {
|
|
161
|
+
/**
|
|
162
|
+
* Set the current value of the picker.
|
|
163
|
+
* @param {TValue} value The new value of the picker.
|
|
164
|
+
* @param {SetValueActionOptions<TError>} options The options to customize the behavior of this update.
|
|
165
|
+
*/
|
|
166
|
+
setValue: (value: TValue, options?: SetValueActionOptions<TError>) => void;
|
|
167
|
+
/**
|
|
168
|
+
* Set the current open state of the Picker.
|
|
169
|
+
* It can be a function that will receive the current open state as parameter.
|
|
170
|
+
* ```ts
|
|
171
|
+
* setOpen(true); // Opens the picker.
|
|
172
|
+
* setOpen(false); // Closes the picker.
|
|
173
|
+
* setOpen((prevOpen) => !prevOpen); // Toggles the open state.
|
|
174
|
+
* ```
|
|
175
|
+
* @param {React.SetStateAction<boolean>} action The new open state of the Picker.
|
|
176
|
+
*/
|
|
177
|
+
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
178
|
+
/**
|
|
179
|
+
* Set the current view.
|
|
180
|
+
* @template TView
|
|
181
|
+
* @param {TView} view The view to render
|
|
182
|
+
*/
|
|
183
|
+
setView: (view: TView) => void;
|
|
184
|
+
/**
|
|
185
|
+
* Set the current value of the picker to be empty.
|
|
186
|
+
* The value will be `null` on single pickers and `[null, null]` on range pickers.
|
|
187
|
+
*/
|
|
188
|
+
clearValue: () => void;
|
|
189
|
+
/**
|
|
190
|
+
* Set the current value of the picker to be the current date.
|
|
191
|
+
* The value will be `today` on single pickers and `[today, today]` on range pickers.
|
|
192
|
+
* With `today` being the current date, with its time set to `00:00:00` on Date Pickers and its time set to the current time on Time and Date Pickers.
|
|
193
|
+
*/
|
|
194
|
+
setValueToToday: () => void;
|
|
195
|
+
/**
|
|
196
|
+
* Accept the current value of the picker.
|
|
197
|
+
* Will call `onAccept` if defined.
|
|
198
|
+
* If the picker is re-opened, this value will be the one used to initialize the views.
|
|
199
|
+
*/
|
|
200
|
+
acceptValueChanges: () => void;
|
|
201
|
+
/**
|
|
202
|
+
* Cancel the changes made to the current value of the picker.
|
|
203
|
+
* The value will be reset to the last accepted value.
|
|
204
|
+
*/
|
|
205
|
+
cancelValueChanges: () => void;
|
|
206
|
+
}
|
|
207
|
+
export interface SetValueActionOptions<TError = string | null> {
|
|
208
|
+
/**
|
|
209
|
+
* The importance of the change when picking a value:
|
|
210
|
+
* - "accept": fires `onChange`, fires `onAccept` and closes the picker.
|
|
211
|
+
* - "set": fires `onChange` but do not fire `onAccept` and does not close the picker.
|
|
212
|
+
* @default "accept"
|
|
213
|
+
*/
|
|
214
|
+
changeImportance?: PickerChangeImportance;
|
|
215
|
+
/**
|
|
216
|
+
* The validation error associated to the current value.
|
|
217
|
+
* If not defined, the validation will be computed by the picker.
|
|
218
|
+
*/
|
|
219
|
+
validationError?: TError;
|
|
220
|
+
/**
|
|
221
|
+
* The shortcut that triggered this change.
|
|
222
|
+
* It should not be defined if the change does not come from a shortcut.
|
|
223
|
+
*/
|
|
224
|
+
shortcut?: PickersShortcutsItemContext;
|
|
225
|
+
/**
|
|
226
|
+
* Whether the value should call `onChange` and `onAccept` when the value is not controlled and has never been modified.
|
|
227
|
+
* If `true`, the `onChange` and `onAccept` callback will only be fired if the value has been modified (and is not equal to the last published value).
|
|
228
|
+
* If `false`, the `onChange` and `onAccept` callback will be fired when the value has never been modified (`onAccept` only if `changeImportance` is set to "accept").
|
|
229
|
+
* @default false
|
|
230
|
+
*/
|
|
231
|
+
skipPublicationIfPristine?: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Whether the picker should close.
|
|
234
|
+
* @default changeImportance === "accept"
|
|
235
|
+
*/
|
|
236
|
+
shouldClose?: boolean;
|
|
237
|
+
}
|
|
238
|
+
export interface PickerPrivateContextValue {
|
|
116
239
|
/**
|
|
117
240
|
* The ownerState of the picker.
|
|
118
241
|
*/
|
|
119
242
|
ownerState: PickerOwnerState;
|
|
243
|
+
/**
|
|
244
|
+
* The ref of the root element.
|
|
245
|
+
* This is the object counterpart of the `usePickerContext().rootRef` property which can be a function.
|
|
246
|
+
*/
|
|
247
|
+
rootRefObject: React.RefObject<HTMLDivElement | null>;
|
|
248
|
+
/**
|
|
249
|
+
* The id of the label element.
|
|
250
|
+
*/
|
|
251
|
+
labelId: string | undefined;
|
|
252
|
+
dismissViews: () => void;
|
|
253
|
+
/**
|
|
254
|
+
* Whether at least one view has an UI (it has a view renderer associated).
|
|
255
|
+
*/
|
|
256
|
+
hasUIView: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Return the mode of the current view.
|
|
259
|
+
* @returns {boolean} The mode of the current view.
|
|
260
|
+
*/
|
|
261
|
+
getCurrentViewMode: () => 'UI' | 'field';
|
|
262
|
+
/**
|
|
263
|
+
* The aria role associated with the view container.
|
|
264
|
+
* It is equal to "dialog" when the view is rendered inside a `@mui/material/Dialog`.
|
|
265
|
+
* It is equal to "dialog" when the view is rendered inside a `@mui/material/Popper` and the focus is trapped inside the view.
|
|
266
|
+
* It is equal to "tooltip" when the view is rendered inside a `@mui/material/Popper` and the focus remains inside the field.
|
|
267
|
+
* It is always equal to null if the picker does not have a field (static pickers).
|
|
268
|
+
* It is always equal to null if the component you are accessing the context from is not wrapped by a picker.
|
|
269
|
+
*/
|
|
270
|
+
viewContainerRole: 'dialog' | 'tooltip' | null;
|
|
120
271
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { LocalizationProvider } from "../../LocalizationProvider/index.js";
|
|
3
3
|
import { IsValidValueContext } from "../../hooks/useIsValidValue.js";
|
|
4
|
-
import { PickerFieldPrivateContext } from "../hooks/
|
|
4
|
+
import { PickerFieldPrivateContext } from "../hooks/useNullableFieldPrivateContext.js";
|
|
5
5
|
import { PickerContext } from "../../hooks/usePickerContext.js";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
export const PickerActionsContext = /*#__PURE__*/React.createContext(null);
|
|
@@ -16,7 +16,12 @@ export const PickerPrivateContext = /*#__PURE__*/React.createContext({
|
|
|
16
16
|
},
|
|
17
17
|
dismissViews: () => {},
|
|
18
18
|
hasUIView: true,
|
|
19
|
-
|
|
19
|
+
getCurrentViewMode: () => 'UI',
|
|
20
|
+
rootRefObject: {
|
|
21
|
+
current: null
|
|
22
|
+
},
|
|
23
|
+
viewContainerRole: null,
|
|
24
|
+
labelId: undefined
|
|
20
25
|
});
|
|
21
26
|
|
|
22
27
|
/**
|
|
@@ -15,10 +15,10 @@ const getChildTypeFromChildName = childName => {
|
|
|
15
15
|
if (childName.match(/^Static([A-Za-z]+)/) || childName.match(/^([A-Za-z]+)(Calendar|Clock)$/)) {
|
|
16
16
|
return 'UI-view';
|
|
17
17
|
}
|
|
18
|
-
if (childName.match(/^MultiInput([A-Za-z]+)RangeField$/)
|
|
18
|
+
if (childName.match(/^MultiInput([A-Za-z]+)RangeField$/)) {
|
|
19
19
|
return 'multi-input-range-field';
|
|
20
20
|
}
|
|
21
|
-
if (childName.match(/^SingleInput([A-Za-z]+)RangeField$/)) {
|
|
21
|
+
if (childName.match(/^SingleInput([A-Za-z]+)RangeField$/) || childName.match(/^([A-Za-z]+)RangePicker$/)) {
|
|
22
22
|
return 'single-input-range-field';
|
|
23
23
|
}
|
|
24
24
|
return 'single-input-field';
|
|
@@ -133,7 +133,7 @@ export function DemoContainer(props) {
|
|
|
133
133
|
minWidth: {
|
|
134
134
|
xs: 300,
|
|
135
135
|
// If demo also contains MultiInputDateTimeRangeField, increase width to avoid cutting off the value.
|
|
136
|
-
md: childrenTypes.has('multi-input-range-field') ? 460 :
|
|
136
|
+
md: childrenTypes.has('multi-input-range-field') ? 460 : 440
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
};
|
|
@@ -4,8 +4,6 @@ const _excluded = ["props"],
|
|
|
4
4
|
_excluded2 = ["ownerState"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
7
|
-
import useForkRef from '@mui/utils/useForkRef';
|
|
8
|
-
import useId from '@mui/utils/useId';
|
|
9
7
|
import { PickerPopper } from "../../components/PickerPopper/PickerPopper.js";
|
|
10
8
|
import { usePicker } from "../usePicker/index.js";
|
|
11
9
|
import { PickersLayout } from "../../../PickersLayout/index.js";
|
|
@@ -29,35 +27,26 @@ export const useDesktopPicker = _ref => {
|
|
|
29
27
|
slotProps: innerSlotProps,
|
|
30
28
|
label,
|
|
31
29
|
inputRef,
|
|
32
|
-
readOnly,
|
|
33
|
-
autoFocus,
|
|
34
30
|
localeText
|
|
35
31
|
} = props;
|
|
36
|
-
const fieldRef = React.useRef(null);
|
|
37
|
-
const labelId = useId();
|
|
38
|
-
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
39
32
|
const {
|
|
40
33
|
providerProps,
|
|
41
34
|
renderCurrentView,
|
|
42
35
|
ownerState
|
|
43
36
|
} = usePicker(_extends({}, pickerParams, {
|
|
44
37
|
props,
|
|
45
|
-
fieldRef,
|
|
46
38
|
localeText,
|
|
47
39
|
autoFocusView: true,
|
|
40
|
+
viewContainerRole: 'dialog',
|
|
48
41
|
variant: 'desktop'
|
|
49
42
|
}));
|
|
43
|
+
const labelId = providerProps.privateContextValue.labelId;
|
|
44
|
+
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
50
45
|
const Field = slots.field;
|
|
51
46
|
const _useSlotProps = useSlotProps({
|
|
52
47
|
elementType: Field,
|
|
53
48
|
externalSlotProps: innerSlotProps?.field,
|
|
54
|
-
additionalProps: _extends({
|
|
55
|
-
// Internal props
|
|
56
|
-
readOnly,
|
|
57
|
-
autoFocus: autoFocus && !props.open,
|
|
58
|
-
// Forwarded props
|
|
59
|
-
focused: providerProps.contextValue.open ? true : undefined
|
|
60
|
-
}, isToolbarHidden && {
|
|
49
|
+
additionalProps: _extends({}, isToolbarHidden && {
|
|
61
50
|
id: labelId
|
|
62
51
|
}),
|
|
63
52
|
ownerState
|
|
@@ -80,18 +69,12 @@ export const useDesktopPicker = _ref => {
|
|
|
80
69
|
'aria-labelledby': labelledById
|
|
81
70
|
}, innerSlotProps?.popper)
|
|
82
71
|
});
|
|
83
|
-
|
|
84
|
-
// TODO: This `as any` will go away once the field ref is handled by the context.
|
|
85
|
-
const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
|
|
86
72
|
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
87
73
|
children: /*#__PURE__*/_jsxs(PickerFieldUIContextProvider, {
|
|
88
74
|
slots: slots,
|
|
89
75
|
slotProps: slotProps,
|
|
90
76
|
inputRef: inputRef,
|
|
91
|
-
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
|
|
92
|
-
unstableFieldRef: handleFieldRef
|
|
93
|
-
})), /*#__PURE__*/_jsx(PickerPopper, {
|
|
94
|
-
role: "dialog",
|
|
77
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps)), /*#__PURE__*/_jsx(PickerPopper, {
|
|
95
78
|
slots: slots,
|
|
96
79
|
slotProps: slotProps,
|
|
97
80
|
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
@@ -2,37 +2,29 @@ import * as React from 'react';
|
|
|
2
2
|
import { MakeRequired, SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
3
3
|
import { BasePickerProps } from "../../models/props/basePickerProps.js";
|
|
4
4
|
import { PickerPopperSlots, PickerPopperSlotProps } from "../../components/PickerPopper/PickerPopper.js";
|
|
5
|
-
import {
|
|
5
|
+
import { UsePickerParameters, UsePickerNonStaticProps, UsePickerProps } from "../usePicker/index.js";
|
|
6
6
|
import { PickerFieldSlotProps, PickerOwnerState } from "../../../models/index.js";
|
|
7
7
|
import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from "../../../PickersLayout/PickersLayout.types.js";
|
|
8
|
-
import { UsePickerValueNonStaticProps } from "../usePicker/usePickerValue.types.js";
|
|
9
|
-
import { UsePickerViewsProps } from "../usePicker/usePickerViews.js";
|
|
10
8
|
import { DateOrTimeViewWithMeridiem, PickerValue } from "../../models/index.js";
|
|
11
9
|
import { PickerFieldUISlotsFromContext, PickerFieldUISlotPropsFromContext } from "../../components/PickerFieldUI.js";
|
|
12
|
-
import { UsePickerProviderNonStaticProps } from "../usePicker/usePickerProvider.js";
|
|
13
10
|
export interface UseDesktopPickerSlots extends Pick<PickerPopperSlots, 'desktopPaper' | 'desktopTransition' | 'desktopTrapFocus' | 'popper'>, ExportedPickersLayoutSlots<PickerValue>, PickerFieldUISlotsFromContext {
|
|
14
11
|
/**
|
|
15
12
|
* Component used to enter the date with the keyboard.
|
|
16
13
|
*/
|
|
17
14
|
field: React.ElementType;
|
|
18
|
-
/**
|
|
19
|
-
* Form control with an input to render the value inside the default field.
|
|
20
|
-
* @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`.
|
|
21
|
-
*/
|
|
22
|
-
textField?: React.ElementType;
|
|
23
15
|
}
|
|
24
16
|
export interface ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends PickerPopperSlotProps, ExportedPickersLayoutSlotProps<PickerValue>, PickerFieldUISlotPropsFromContext {
|
|
25
17
|
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
|
|
26
18
|
}
|
|
27
19
|
export interface UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue>, 'toolbar'> {}
|
|
28
|
-
export interface DesktopOnlyPickerProps extends
|
|
20
|
+
export interface DesktopOnlyPickerProps extends UsePickerNonStaticProps {
|
|
29
21
|
/**
|
|
30
22
|
* If `true`, the `input` element is focused during the first mount.
|
|
31
23
|
* @default false
|
|
32
24
|
*/
|
|
33
25
|
autoFocus?: boolean;
|
|
34
26
|
}
|
|
35
|
-
export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends
|
|
27
|
+
export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerProps<PickerValue, TView, TError, any>> extends BasePickerProps<PickerValue, any, TError, TExternalProps>, MakeRequired<DesktopOnlyPickerProps, 'format'> {
|
|
36
28
|
/**
|
|
37
29
|
* Overridable component slots.
|
|
38
30
|
* @default {}
|
|
@@ -44,6 +36,6 @@ export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
|
44
36
|
*/
|
|
45
37
|
slotProps?: UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
46
38
|
}
|
|
47
|
-
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<
|
|
39
|
+
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParameters<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor' | 'ref'> {
|
|
48
40
|
props: TExternalProps;
|
|
49
41
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { useField } from "./useField.js";
|
|
2
2
|
export type { FieldValueManager, UseFieldInternalProps, UseFieldParams, UseFieldResponse, FieldChangeHandler, FieldChangeHandlerContext } from './useField.types';
|
|
3
3
|
export { createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections } from "./useField.utils.js";
|
|
4
|
-
export { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.js";
|
|
5
|
-
export type { PickerFieldPrivateContextValue } from './useFieldInternalPropsWithDefaults';
|
|
4
|
+
export { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.js";
|
|
@@ -29,7 +29,6 @@ export const useField = params => {
|
|
|
29
29
|
onClear
|
|
30
30
|
},
|
|
31
31
|
fieldValueManager,
|
|
32
|
-
valueManager,
|
|
33
32
|
validator,
|
|
34
33
|
getOpenPickerButtonAriaLabel: getOpenDialogAriaText
|
|
35
34
|
} = params;
|
|
@@ -37,6 +36,7 @@ export const useField = params => {
|
|
|
37
36
|
const stateResponse = useFieldState(params);
|
|
38
37
|
const {
|
|
39
38
|
state,
|
|
39
|
+
value,
|
|
40
40
|
activeSectionIndex,
|
|
41
41
|
parsedSelectedSections,
|
|
42
42
|
setSelectedSections,
|
|
@@ -59,7 +59,7 @@ export const useField = params => {
|
|
|
59
59
|
const {
|
|
60
60
|
resetCharacterQuery
|
|
61
61
|
} = characterEditingResponse;
|
|
62
|
-
const areAllSectionsEmpty =
|
|
62
|
+
const areAllSectionsEmpty = React.useMemo(() => state.sections.every(section => section.value === ''), [state.sections]);
|
|
63
63
|
const useFieldTextField = enableAccessibleFieldDOMStructure ? useFieldV7TextField : useFieldV6TextField;
|
|
64
64
|
const sectionOrder = React.useMemo(() => getSectionOrder(state.sections, isRtl && !enableAccessibleFieldDOMStructure), [state.sections, isRtl, enableAccessibleFieldDOMStructure]);
|
|
65
65
|
const {
|
|
@@ -149,12 +149,11 @@ export const useField = params => {
|
|
|
149
149
|
setSelectedSections(activeSectionIndex);
|
|
150
150
|
}
|
|
151
151
|
const activeSection = state.sections[activeSectionIndex];
|
|
152
|
-
const
|
|
153
|
-
const newSectionValue = adjustSectionValue(utils, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, activeDateManager.date, {
|
|
152
|
+
const newSectionValue = adjustSectionValue(utils, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, fieldValueManager.getDateFromSection(value, activeSection), {
|
|
154
153
|
minutesStep
|
|
155
154
|
});
|
|
156
155
|
updateSectionValue({
|
|
157
|
-
activeSection,
|
|
156
|
+
section: activeSection,
|
|
158
157
|
newSectionValue,
|
|
159
158
|
shouldGoToNextSection: false
|
|
160
159
|
});
|
|
@@ -171,7 +170,7 @@ export const useField = params => {
|
|
|
171
170
|
props: internalProps,
|
|
172
171
|
validator,
|
|
173
172
|
timezone,
|
|
174
|
-
value
|
|
173
|
+
value,
|
|
175
174
|
onError: internalProps.onError
|
|
176
175
|
});
|
|
177
176
|
const inputError = React.useMemo(() => {
|
|
@@ -225,8 +224,8 @@ export const useField = params => {
|
|
|
225
224
|
};
|
|
226
225
|
const localizationContext = useLocalizationContext();
|
|
227
226
|
const openPickerAriaLabel = React.useMemo(() => getOpenDialogAriaText(_extends({}, localizationContext, {
|
|
228
|
-
value
|
|
229
|
-
})), [getOpenDialogAriaText,
|
|
227
|
+
value
|
|
228
|
+
})), [getOpenDialogAriaText, value, localizationContext]);
|
|
230
229
|
const commonAdditionalProps = {
|
|
231
230
|
disabled,
|
|
232
231
|
readOnly,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, PickerValidDate, FieldRef, OnErrorProps, InferError, InferFieldSection, PickerValueType } from "../../../models/index.js";
|
|
3
|
-
import type { PickerValueManager } from '
|
|
3
|
+
import type { PickerValueManager } from '../../models';
|
|
4
4
|
import type { Validator } from '../../../validation';
|
|
5
5
|
import type { UseFieldStateResponse } from './useFieldState';
|
|
6
6
|
import type { UseFieldCharacterEditingResponse } from './useFieldCharacterEditing';
|
|
@@ -96,6 +96,10 @@ export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableA
|
|
|
96
96
|
* @default false
|
|
97
97
|
*/
|
|
98
98
|
autoFocus?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* If `true`, the component is displayed in focused state.
|
|
101
|
+
*/
|
|
102
|
+
focused?: boolean;
|
|
99
103
|
}
|
|
100
104
|
export interface UseFieldCommonAdditionalProps extends Required<Pick<UseFieldInternalProps<any, any, any>, 'disabled' | 'readOnly' | 'autoFocus'>> {
|
|
101
105
|
/**
|
|
@@ -110,21 +114,22 @@ export interface UseFieldCommonForwardedProps extends Pick<ExportedPickerFieldUI
|
|
|
110
114
|
export type UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure extends boolean> = UseFieldCommonForwardedProps & (TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps);
|
|
111
115
|
export interface UseFieldV6ForwardedProps {
|
|
112
116
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
113
|
-
onBlur?:
|
|
117
|
+
onBlur?: React.FocusEventHandler;
|
|
114
118
|
onClick?: React.MouseEventHandler;
|
|
115
|
-
onFocus?:
|
|
119
|
+
onFocus?: React.FocusEventHandler;
|
|
116
120
|
onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
|
|
117
121
|
placeholder?: string;
|
|
118
122
|
}
|
|
119
123
|
interface UseFieldV6AdditionalProps extends Required<Pick<React.InputHTMLAttributes<HTMLInputElement>, 'inputMode' | 'placeholder' | 'value' | 'onChange' | 'autoComplete'>> {
|
|
120
124
|
enableAccessibleFieldDOMStructure: false;
|
|
125
|
+
focused?: boolean;
|
|
121
126
|
}
|
|
122
127
|
export interface UseFieldV7ForwardedProps {
|
|
123
128
|
focused?: boolean;
|
|
124
129
|
sectionListRef?: React.Ref<PickersSectionListRef>;
|
|
125
|
-
onBlur?:
|
|
130
|
+
onBlur?: React.FocusEventHandler;
|
|
126
131
|
onClick?: React.MouseEventHandler;
|
|
127
|
-
onFocus?:
|
|
132
|
+
onFocus?: React.FocusEventHandler;
|
|
128
133
|
onInput?: React.FormEventHandler<HTMLDivElement>;
|
|
129
134
|
onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
|
|
130
135
|
}
|
|
@@ -136,6 +141,7 @@ interface UseFieldV7AdditionalProps {
|
|
|
136
141
|
value: string;
|
|
137
142
|
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
138
143
|
areAllSectionsEmpty: boolean;
|
|
144
|
+
focused: boolean;
|
|
139
145
|
}
|
|
140
146
|
export type UseFieldResponse<TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & {
|
|
141
147
|
[key: string]: any;
|
|
@@ -159,47 +165,17 @@ export type FieldChangeHandler<TValue extends PickerValidValue, TError> = (value
|
|
|
159
165
|
export interface FieldChangeHandlerContext<TError> {
|
|
160
166
|
validationError: TError;
|
|
161
167
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Object used to access and update the active date (i.e: the date containing the active section).
|
|
164
|
-
* Mainly useful in the range fields where we need to update the date containing the active section without impacting the other one.
|
|
165
|
-
*/
|
|
166
|
-
interface FieldActiveDateManager<TValue extends PickerValidValue> {
|
|
167
|
-
/**
|
|
168
|
-
* Active date from `state.value`.
|
|
169
|
-
*/
|
|
170
|
-
date: PickerValidDate | null;
|
|
171
|
-
/**
|
|
172
|
-
* Active date from the `state.referenceValue`.
|
|
173
|
-
*/
|
|
174
|
-
referenceDate: PickerValidDate;
|
|
175
|
-
/**
|
|
176
|
-
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
177
|
-
* @param {InferFieldSection<TValue>[]} sections The sections of the full value.
|
|
178
|
-
* @returns {InferFieldSection<TValue>[]} The sections of the active date.
|
|
179
|
-
* Get the sections of the active date.
|
|
180
|
-
*/
|
|
181
|
-
getSections: (sections: InferFieldSection<TValue>[]) => InferFieldSection<TValue>[];
|
|
182
|
-
/**
|
|
183
|
-
* Creates the new value and reference value based on the new active date and the current state.
|
|
184
|
-
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
185
|
-
* @param {PickerValidDate | null} newActiveDate The new value of the date containing the active section.
|
|
186
|
-
* @returns {Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>} The new value and reference value to publish and store in the state.
|
|
187
|
-
*/
|
|
188
|
-
getNewValuesFromNewActiveDate: (newActiveDate: PickerValidDate | null) => Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>;
|
|
189
|
-
}
|
|
190
168
|
export type FieldParsedSelectedSections = number | 'all' | null;
|
|
191
169
|
export interface FieldValueManager<TValue extends PickerValidValue> {
|
|
192
170
|
/**
|
|
193
171
|
* Creates the section list from the current value.
|
|
194
172
|
* The `prevSections` are used on the range fields to avoid losing the sections of a partially filled date when editing the other date.
|
|
195
173
|
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
196
|
-
* @param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
197
174
|
* @param {TValue} value The current value to generate sections from.
|
|
198
|
-
* @param {
|
|
199
|
-
* @param {(date: PickerValidDate) => FieldSection[]} getSectionsFromDate Returns the sections of the given date.
|
|
175
|
+
* @param {(date: PickerValidDate | null) => FieldSection[]} getSectionsFromDate Returns the sections of the given date.
|
|
200
176
|
* @returns {InferFieldSection<TValue>[]} The new section list.
|
|
201
177
|
*/
|
|
202
|
-
getSectionsFromValue: (
|
|
178
|
+
getSectionsFromValue: (value: TValue, getSectionsFromDate: (date: PickerValidDate | null) => FieldSection[]) => InferFieldSection<TValue>[];
|
|
203
179
|
/**
|
|
204
180
|
* Creates the string value to render in the input based on the current section list.
|
|
205
181
|
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
@@ -216,15 +192,6 @@ export interface FieldValueManager<TValue extends PickerValidValue> {
|
|
|
216
192
|
* @returns {string} The string value to render in the input.
|
|
217
193
|
*/
|
|
218
194
|
getV7HiddenInputValueFromSections: (sections: InferFieldSection<TValue>[]) => string;
|
|
219
|
-
/**
|
|
220
|
-
* Returns the manager of the active date.
|
|
221
|
-
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
222
|
-
* @param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
223
|
-
* @param {UseFieldState<TValue>} state The current state of the field.
|
|
224
|
-
* @param {InferFieldSection<TValue>} activeSection The active section.
|
|
225
|
-
* @returns {FieldActiveDateManager<TValue>} The manager of the active date.
|
|
226
|
-
*/
|
|
227
|
-
getActiveDateManager: (utils: MuiPickersAdapter, state: UseFieldState<TValue>, activeSection: InferFieldSection<TValue>) => FieldActiveDateManager<TValue>;
|
|
228
195
|
/**
|
|
229
196
|
* Parses a string version (most of the time coming from the input).
|
|
230
197
|
* This method should only be used when the change does not come from a single section.
|
|
@@ -245,9 +212,51 @@ export interface FieldValueManager<TValue extends PickerValidValue> {
|
|
|
245
212
|
* @returns {TValue} The new reference value with no invalid date.
|
|
246
213
|
*/
|
|
247
214
|
updateReferenceValue: (utils: MuiPickersAdapter, value: TValue, prevReferenceValue: InferNonNullablePickerValue<TValue>) => InferNonNullablePickerValue<TValue>;
|
|
215
|
+
/**
|
|
216
|
+
* Extract from the given value the date that contains the given section.
|
|
217
|
+
* @param {TValue} value The value to extract the date from.
|
|
218
|
+
* @param {InferFieldSection<TValue>} section The section to get the date from.
|
|
219
|
+
* @returns {PickerValidDate | null} The date that contains the section.
|
|
220
|
+
*/
|
|
221
|
+
getDateFromSection: (value: TValue, section: InferFieldSection<TValue>) => PickerValidDate | null;
|
|
222
|
+
/**
|
|
223
|
+
* Get the sections of the date that contains the given section.
|
|
224
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
225
|
+
* @param {InferFieldSection<TValue>[]} sections The sections of the full value.
|
|
226
|
+
* @param {InferFieldSection<TValue>} section A section of the date from which we want to get all the sections.
|
|
227
|
+
* @returns {InferFieldSection<TValue>[]} The sections of the date that contains the section.
|
|
228
|
+
*/
|
|
229
|
+
getDateSectionsFromValue: (sections: InferFieldSection<TValue>[], section: InferFieldSection<TValue>) => InferFieldSection<TValue>[];
|
|
230
|
+
/**
|
|
231
|
+
* Creates a new value based on the provided date and the current value.
|
|
232
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
233
|
+
* @param {TValue} value The value to update the date in.
|
|
234
|
+
* @param {InferFieldSection<TValue>} section A section of the date we want to update in the value.
|
|
235
|
+
* @param {PickerValidDate | null} date The date that contains the section.
|
|
236
|
+
* @returns {TValue} The updated value.
|
|
237
|
+
*/
|
|
238
|
+
updateDateInValue: (value: TValue, section: InferFieldSection<TValue>, date: PickerValidDate | null) => TValue;
|
|
239
|
+
/**
|
|
240
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
241
|
+
* @param {InferFieldSection<TValue>[]} sections The sections of the full value.
|
|
242
|
+
* @param {InferFieldSection<TValue>} section A section of the date from which we want to clear all the sections.
|
|
243
|
+
* @returns {InferFieldSection<TValue>[]} The sections of the full value with all the sections of the target date cleared.
|
|
244
|
+
*/
|
|
245
|
+
clearDateSections: (sections: InferFieldSection<TValue>[], section: InferFieldSection<TValue>) => InferFieldSection<TValue>[];
|
|
248
246
|
}
|
|
249
247
|
export interface UseFieldState<TValue extends PickerValidValue> {
|
|
250
|
-
|
|
248
|
+
/**
|
|
249
|
+
* Last value returned by `useControlledValueWithTimezone`.
|
|
250
|
+
*/
|
|
251
|
+
lastValue: TValue | undefined;
|
|
252
|
+
/**
|
|
253
|
+
* Last value of the parameters used to generate the sections.
|
|
254
|
+
*/
|
|
255
|
+
lastSectionsDependencies: {
|
|
256
|
+
format: string;
|
|
257
|
+
isRtl: boolean;
|
|
258
|
+
locale: any;
|
|
259
|
+
};
|
|
251
260
|
/**
|
|
252
261
|
* Non-nullable value used to keep trace of the timezone and the date parts not present in the format.
|
|
253
262
|
* It is updated whenever we have a valid date (for the range picker we update only the portion of the range that is valid).
|
|
@@ -447,8 +447,11 @@ const transferDateSectionValue = (utils, section, dateToTransferFrom, dateToTran
|
|
|
447
447
|
}
|
|
448
448
|
case 'weekDay':
|
|
449
449
|
{
|
|
450
|
+
let dayInWeekStrOfActiveDate = utils.formatByString(dateToTransferFrom, section.format);
|
|
451
|
+
if (section.hasLeadingZerosInInput) {
|
|
452
|
+
dayInWeekStrOfActiveDate = cleanLeadingZeros(dayInWeekStrOfActiveDate, section.maxLength);
|
|
453
|
+
}
|
|
450
454
|
const formattedDaysInWeek = getDaysInWeekStr(utils, section.format);
|
|
451
|
-
const dayInWeekStrOfActiveDate = utils.formatByString(dateToTransferFrom, section.format);
|
|
452
455
|
const dayInWeekOfActiveDate = formattedDaysInWeek.indexOf(dayInWeekStrOfActiveDate);
|
|
453
456
|
const dayInWeekOfNewSectionValue = formattedDaysInWeek.indexOf(section.value);
|
|
454
457
|
const diff = dayInWeekOfNewSectionValue - dayInWeekOfActiveDate;
|
|
@@ -236,7 +236,7 @@ export const useFieldCharacterEditing = ({
|
|
|
236
236
|
return applyQuery(params, getFirstSectionValueMatchingWithQuery, queryValue => isStringNumber(queryValue, localizedDigits));
|
|
237
237
|
};
|
|
238
238
|
const applyCharacterEditing = useEventCallback(params => {
|
|
239
|
-
const
|
|
239
|
+
const section = sections[params.sectionIndex];
|
|
240
240
|
const isNumericEditing = isStringNumber(params.keyPressed, localizedDigits);
|
|
241
241
|
const response = isNumericEditing ? applyNumericEditing(_extends({}, params, {
|
|
242
242
|
keyPressed: applyLocalizedDigits(params.keyPressed, localizedDigits)
|
|
@@ -246,7 +246,7 @@ export const useFieldCharacterEditing = ({
|
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
248
|
updateSectionValue({
|
|
249
|
-
|
|
249
|
+
section,
|
|
250
250
|
newSectionValue: response.sectionValue,
|
|
251
251
|
shouldGoToNextSection: response.shouldGoToNextSection
|
|
252
252
|
});
|