@mui/x-date-pickers 8.0.0-alpha.0 → 8.0.0-alpha.2
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/AdapterMoment/AdapterMoment.js +10 -0
- package/CHANGELOG.md +651 -6
- package/DateCalendar/DateCalendar.js +1 -0
- package/DateCalendar/DateCalendar.types.d.ts +2 -1
- package/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/DateCalendar/PickersSlideTransition.js +12 -5
- package/DateCalendar/useCalendarState.d.ts +6 -4
- package/DateField/DateField.js +5 -4
- package/DateField/DateField.types.d.ts +10 -9
- package/DatePicker/DatePicker.types.d.ts +3 -3
- package/DatePicker/DatePickerToolbar.d.ts +3 -2
- package/DatePicker/DatePickerToolbar.js +0 -12
- package/DatePicker/shared.d.ts +6 -5
- package/DateTimeField/DateTimeField.js +5 -4
- package/DateTimeField/DateTimeField.types.d.ts +10 -10
- package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
- package/DateTimePicker/DateTimePickerTabs.js +8 -6
- package/DateTimePicker/DateTimePickerToolbar.d.ts +3 -4
- package/DateTimePicker/DateTimePickerToolbar.js +6 -15
- package/DateTimePicker/shared.d.ts +6 -6
- package/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +2 -1
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -33
- package/DigitalClock/DigitalClock.js +1 -0
- package/MonthCalendar/MonthCalendar.js +1 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +6 -6
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +4 -4
- package/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +3 -4
- package/PickersLayout/PickersLayout.d.ts +7 -5
- package/PickersLayout/PickersLayout.js +22 -39
- package/PickersLayout/PickersLayout.types.d.ts +14 -15
- package/PickersLayout/usePickerLayout.d.ts +5 -4
- package/PickersLayout/usePickerLayout.js +20 -17
- package/PickersShortcuts/PickersShortcuts.d.ts +7 -6
- package/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/PickersTextField/PickersTextField.js +2 -2
- package/README.md +9 -6
- package/TimeClock/Clock.js +1 -0
- package/TimeClock/TimeClock.js +1 -0
- package/TimeField/TimeField.js +5 -4
- package/TimeField/TimeField.types.d.ts +10 -10
- package/TimePicker/TimePicker.types.d.ts +3 -3
- package/TimePicker/TimePickerToolbar.d.ts +2 -3
- package/TimePicker/TimePickerToolbar.js +6 -15
- package/TimePicker/shared.d.ts +6 -6
- package/YearCalendar/YearCalendar.js +1 -0
- package/hooks/useParsedFormat.d.ts +2 -2
- package/hooks/useParsedFormat.js +1 -1
- package/hooks/useSplitFieldProps.d.ts +3 -3
- package/index.js +1 -1
- package/internals/components/PickerProvider.d.ts +26 -0
- package/internals/components/PickerProvider.js +3 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +11 -8
- package/internals/components/PickersToolbar.d.ts +3 -3
- package/internals/components/PickersToolbar.js +2 -4
- package/internals/hooks/useClockReferenceDate.d.ts +2 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +14 -14
- package/internals/hooks/useField/useField.d.ts +3 -3
- package/internals/hooks/useField/useField.types.d.ts +46 -46
- package/internals/hooks/useField/useField.utils.d.ts +4 -3
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +6 -5
- package/internals/hooks/useField/useFieldState.d.ts +9 -8
- package/internals/hooks/useField/useFieldState.js +1 -1
- package/internals/hooks/useField/useFieldV6TextField.d.ts +4 -3
- package/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/internals/hooks/useFieldOwnerState.d.ts +6 -0
- package/internals/hooks/useFieldOwnerState.js +12 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +11 -11
- package/internals/hooks/usePicker/usePicker.d.ts +3 -3
- package/internals/hooks/usePicker/usePicker.js +10 -19
- package/internals/hooks/usePicker/usePicker.types.d.ts +8 -8
- package/internals/hooks/usePicker/usePickerProvider.d.ts +21 -6
- package/internals/hooks/usePicker/usePickerProvider.js +61 -5
- package/internals/hooks/usePicker/usePickerValue.d.ts +3 -2
- package/internals/hooks/usePicker/usePickerValue.js +18 -7
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +32 -30
- package/internals/hooks/usePicker/usePickerViews.d.ts +11 -10
- package/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +5 -6
- package/internals/hooks/useValueWithTimezone.d.ts +20 -15
- package/internals/hooks/useValueWithTimezone.js +13 -1
- package/internals/hooks/useViews.d.ts +5 -5
- package/internals/index.d.ts +5 -3
- package/internals/index.js +1 -0
- package/internals/models/common.d.ts +2 -1
- package/internals/models/fields.d.ts +6 -1
- package/internals/models/pickers.d.ts +1 -0
- package/internals/models/pickers.js +1 -0
- package/internals/models/props/basePickerProps.d.ts +4 -3
- package/internals/models/props/time.d.ts +2 -1
- package/internals/models/props/toolbar.d.ts +2 -2
- package/internals/models/value.d.ts +9 -0
- package/internals/utils/date-utils.d.ts +3 -3
- package/internals/utils/valueManagers.d.ts +4 -3
- package/locales/nlNL.js +7 -7
- package/models/adapters.d.ts +4 -4
- package/models/common.d.ts +1 -0
- package/models/fields.d.ts +19 -6
- package/models/pickers.d.ts +18 -0
- package/models/validation.d.ts +2 -1
- package/modern/AdapterMoment/AdapterMoment.js +10 -0
- package/modern/DateCalendar/DateCalendar.js +1 -0
- package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/modern/DateCalendar/PickersSlideTransition.js +12 -5
- package/modern/DateField/DateField.js +5 -4
- package/modern/DatePicker/DatePickerToolbar.js +0 -12
- package/modern/DateTimeField/DateTimeField.js +5 -4
- package/modern/DateTimePicker/DateTimePickerTabs.js +8 -6
- package/modern/DateTimePicker/DateTimePickerToolbar.js +6 -15
- package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -33
- package/modern/DigitalClock/DigitalClock.js +1 -0
- package/modern/MonthCalendar/MonthCalendar.js +1 -0
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
- package/modern/PickersLayout/PickersLayout.js +22 -39
- package/modern/PickersLayout/usePickerLayout.js +20 -17
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/modern/PickersTextField/PickersTextField.js +2 -2
- package/modern/TimeClock/Clock.js +1 -0
- package/modern/TimeClock/TimeClock.js +1 -0
- package/modern/TimeField/TimeField.js +5 -4
- package/modern/TimePicker/TimePickerToolbar.js +6 -15
- package/modern/YearCalendar/YearCalendar.js +1 -0
- package/modern/hooks/useParsedFormat.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerProvider.js +3 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
- package/modern/internals/components/PickersToolbar.js +2 -4
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/modern/internals/hooks/useField/useFieldState.js +1 -1
- package/modern/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/modern/internals/hooks/useFieldOwnerState.js +12 -0
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/modern/internals/hooks/usePicker/usePicker.js +10 -19
- package/modern/internals/hooks/usePicker/usePickerProvider.js +61 -5
- package/modern/internals/hooks/usePicker/usePickerValue.js +18 -7
- package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/modern/internals/hooks/useValueWithTimezone.js +13 -1
- package/modern/internals/index.js +1 -0
- package/modern/internals/models/pickers.js +1 -0
- package/modern/locales/nlNL.js +7 -7
- package/modern/validation/useValidation.js +1 -1
- package/modern/validation/validateDate.js +8 -0
- package/modern/validation/validateDateTime.js +8 -0
- package/modern/validation/validateTime.js +8 -0
- package/node/AdapterMoment/AdapterMoment.js +10 -0
- package/node/DateCalendar/DateCalendar.js +1 -0
- package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/node/DateCalendar/PickersSlideTransition.js +12 -5
- package/node/DateField/DateField.js +5 -4
- package/node/DatePicker/DatePickerToolbar.js +0 -12
- package/node/DateTimeField/DateTimeField.js +5 -4
- package/node/DateTimePicker/DateTimePickerTabs.js +8 -6
- package/node/DateTimePicker/DateTimePickerToolbar.js +6 -15
- package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -34
- package/node/DigitalClock/DigitalClock.js +1 -0
- package/node/MonthCalendar/MonthCalendar.js +1 -0
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
- package/node/PickersLayout/PickersLayout.js +22 -39
- package/node/PickersLayout/usePickerLayout.js +20 -17
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/node/PickersTextField/PickersTextField.js +2 -2
- package/node/TimeClock/Clock.js +1 -0
- package/node/TimeClock/TimeClock.js +1 -0
- package/node/TimeField/TimeField.js +5 -4
- package/node/TimePicker/TimePickerToolbar.js +6 -15
- package/node/YearCalendar/YearCalendar.js +1 -0
- package/node/hooks/useParsedFormat.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/components/PickerProvider.js +3 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
- package/node/internals/components/PickersToolbar.js +2 -4
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/node/internals/hooks/useField/useFieldState.js +1 -1
- package/node/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/node/internals/hooks/useFieldOwnerState.js +20 -0
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/node/internals/hooks/usePicker/usePicker.js +11 -19
- package/node/internals/hooks/usePicker/usePickerProvider.js +64 -5
- package/node/internals/hooks/usePicker/usePickerValue.js +18 -6
- package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/node/internals/hooks/useValueWithTimezone.js +13 -1
- package/node/internals/index.js +7 -0
- package/node/internals/models/pickers.js +5 -0
- package/node/locales/nlNL.js +7 -7
- package/node/validation/useValidation.js +1 -1
- package/node/validation/validateDate.js +8 -0
- package/node/validation/validateDateTime.js +8 -0
- package/node/validation/validateTime.js +8 -0
- package/package.json +4 -4
- package/themeAugmentation/overrides.d.ts +1 -1
- package/themeAugmentation/props.d.ts +3 -2
- package/validation/useValidation.d.ts +7 -6
- package/validation/useValidation.js +1 -1
- package/validation/validateDate.d.ts +12 -3
- package/validation/validateDate.js +8 -0
- package/validation/validateDateTime.d.ts +12 -4
- package/validation/validateDateTime.js +8 -0
- package/validation/validateTime.d.ts +12 -3
- package/validation/validateTime.js +8 -0
- package/internals/hooks/useIsLandscape.d.ts +0 -4
- package/internals/hooks/useIsLandscape.js +0 -35
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +0 -33
- package/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
- package/internals/hooks/usePicker/usePickerOwnerState.d.ts +0 -10
- package/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
- package/modern/internals/hooks/useIsLandscape.js +0 -35
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
- package/modern/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
- package/node/internals/hooks/useIsLandscape.js +0 -43
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +0 -41
- package/node/internals/hooks/usePicker/usePickerOwnerState.js +0 -23
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import { InputAdornmentProps } from '@mui/material/InputAdornment';
|
|
4
|
-
import
|
|
5
|
-
import { SlotComponentProps } from '@mui/utils';
|
|
2
|
+
import type { IconButtonProps } from '@mui/material/IconButton';
|
|
3
|
+
import type { InputAdornmentProps } from '@mui/material/InputAdornment';
|
|
4
|
+
import type { TextFieldProps } from '@mui/material/TextField';
|
|
6
5
|
import { MakeRequired, SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
7
6
|
import { BaseNonStaticPickerProps, BasePickerProps, BaseNonRangeNonStaticPickerProps } from '../../models/props/basePickerProps';
|
|
8
7
|
import { PickersPopperSlots, PickersPopperSlotProps } from '../../components/PickersPopper';
|
|
9
8
|
import { UsePickerParams } from '../usePicker';
|
|
10
|
-
import {
|
|
9
|
+
import { FieldOwnerState, PickerFieldSlotProps, PickerOwnerState, PickerValidDate } from '../../../models';
|
|
11
10
|
import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from '../../../PickersLayout/PickersLayout.types';
|
|
12
11
|
import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue.types';
|
|
13
12
|
import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
|
|
14
|
-
import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
13
|
+
import { DateOrTimeViewWithMeridiem, PickerValue } from '../../models';
|
|
15
14
|
import { UseClearableFieldSlots, UseClearableFieldSlotProps } from '../../../hooks/useClearableField';
|
|
16
|
-
|
|
15
|
+
import { PickersTextFieldProps } from '../../../PickersTextField';
|
|
16
|
+
export interface UseDesktopPickerSlots<TView extends DateOrTimeViewWithMeridiem> extends Pick<PickersPopperSlots, 'desktopPaper' | 'desktopTransition' | 'desktopTrapFocus' | 'popper'>, ExportedPickersLayoutSlots<PickerValue, TView>, UseClearableFieldSlots {
|
|
17
17
|
/**
|
|
18
18
|
* Component used to enter the date with the keyboard.
|
|
19
19
|
*/
|
|
@@ -38,13 +38,13 @@ export interface UseDesktopPickerSlots<TView extends DateOrTimeViewWithMeridiem>
|
|
|
38
38
|
*/
|
|
39
39
|
openPickerIcon: React.ElementType;
|
|
40
40
|
}
|
|
41
|
-
export interface UseDesktopPickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseDesktopPickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<
|
|
41
|
+
export interface UseDesktopPickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseDesktopPickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue, TView>, 'toolbar'> {
|
|
42
42
|
}
|
|
43
|
-
export interface ExportedUseDesktopPickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends PickersPopperSlotProps, ExportedPickersLayoutSlotProps<
|
|
44
|
-
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<
|
|
45
|
-
textField?:
|
|
43
|
+
export interface ExportedUseDesktopPickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends PickersPopperSlotProps, ExportedPickersLayoutSlotProps<PickerValue, TView>, UseClearableFieldSlotProps {
|
|
44
|
+
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
|
|
45
|
+
textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
|
|
46
46
|
inputAdornment?: SlotComponentPropsFromProps<InputAdornmentProps, {}, PickerOwnerState>;
|
|
47
|
-
openPickerButton?:
|
|
47
|
+
openPickerButton?: SlotComponentPropsFromProps<IconButtonProps, {}, PickerOwnerState>;
|
|
48
48
|
openPickerIcon?: SlotComponentPropsFromProps<Record<string, any>, {}, PickerOwnerState>;
|
|
49
49
|
}
|
|
50
50
|
export interface DesktopOnlyPickerProps extends BaseNonStaticPickerProps, BaseNonRangeNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerViewsNonStaticProps {
|
|
@@ -54,7 +54,7 @@ export interface DesktopOnlyPickerProps extends BaseNonStaticPickerProps, BaseNo
|
|
|
54
54
|
*/
|
|
55
55
|
autoFocus?: boolean;
|
|
56
56
|
}
|
|
57
|
-
export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<
|
|
57
|
+
export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<PickerValue, TView, any, {}>> extends BasePickerProps<PickerValue, TView, TError, TExternalProps, {}>, MakeRequired<DesktopOnlyPickerProps, 'format'> {
|
|
58
58
|
/**
|
|
59
59
|
* Overridable component slots.
|
|
60
60
|
* @default {}
|
|
@@ -66,7 +66,7 @@ export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
|
66
66
|
*/
|
|
67
67
|
slotProps?: UseDesktopPickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>;
|
|
68
68
|
}
|
|
69
|
-
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<
|
|
69
|
+
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps, {}>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor'> {
|
|
70
70
|
props: TExternalProps;
|
|
71
71
|
getOpenDialogAriaText: (date: PickerValidDate | null) => string;
|
|
72
72
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseFieldParams, UseFieldResponse, UseFieldCommonForwardedProps, UseFieldInternalProps, UseFieldForwardedProps } from './useField.types';
|
|
2
|
-
import {
|
|
3
|
-
export declare const useField: <TValue
|
|
2
|
+
import { PickerValidValue } from '../../models';
|
|
3
|
+
export declare const useField: <TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any> & {
|
|
4
4
|
minutesStep?: number;
|
|
5
|
-
}>(params: UseFieldParams<TValue,
|
|
5
|
+
}>(params: UseFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => UseFieldResponse<TEnableAccessibleFieldDOMStructure, TForwardedProps>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType,
|
|
2
|
+
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, PickerValidDate, FieldRef, OnErrorProps, InferError, InferFieldSection, PickerValueType } from '../../../models';
|
|
3
3
|
import type { PickerValueManager } from '../usePicker';
|
|
4
4
|
import type { Validator } from '../../../validation';
|
|
5
5
|
import type { UseFieldStateResponse } from './useFieldState';
|
|
6
6
|
import type { UseFieldCharacterEditingResponse } from './useFieldCharacterEditing';
|
|
7
7
|
import { PickersSectionElement, PickersSectionListRef } from '../../../PickersSectionList';
|
|
8
8
|
import { ExportedUseClearableFieldProps } from '../../../hooks/useClearableField';
|
|
9
|
-
import { FormProps } from '../../models';
|
|
10
|
-
export interface UseFieldParams<TValue
|
|
9
|
+
import { FormProps, InferNonNullablePickerValue, PickerValidValue } from '../../models';
|
|
10
|
+
export interface UseFieldParams<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any>> {
|
|
11
11
|
forwardedProps: TForwardedProps;
|
|
12
12
|
internalProps: TInternalProps;
|
|
13
13
|
valueManager: PickerValueManager<TValue, InferError<TInternalProps>>;
|
|
14
|
-
fieldValueManager: FieldValueManager<TValue
|
|
14
|
+
fieldValueManager: FieldValueManager<TValue>;
|
|
15
15
|
validator: Validator<TValue, InferError<TInternalProps>, TInternalProps>;
|
|
16
|
-
valueType:
|
|
16
|
+
valueType: PickerValueType;
|
|
17
17
|
}
|
|
18
|
-
export interface UseFieldInternalProps<TValue
|
|
18
|
+
export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends TimezoneProps, FormProps, OnErrorProps<TValue, TError> {
|
|
19
19
|
/**
|
|
20
20
|
* The selected value.
|
|
21
21
|
* Used when the component is controlled.
|
|
@@ -50,10 +50,10 @@ export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TE
|
|
|
50
50
|
*/
|
|
51
51
|
formatDensity?: 'dense' | 'spacious';
|
|
52
52
|
/**
|
|
53
|
-
* If `true`, the format will respect the leading zeroes (
|
|
54
|
-
* If `false`, the format will always add leading zeroes (
|
|
53
|
+
* If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
54
|
+
* If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
55
55
|
*
|
|
56
|
-
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (
|
|
56
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
57
57
|
*
|
|
58
58
|
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
59
59
|
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
@@ -82,7 +82,7 @@ export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TE
|
|
|
82
82
|
/**
|
|
83
83
|
* The ref object used to imperatively interact with the field.
|
|
84
84
|
*/
|
|
85
|
-
unstableFieldRef?: React.Ref<FieldRef<
|
|
85
|
+
unstableFieldRef?: React.Ref<FieldRef<TValue>>;
|
|
86
86
|
/**
|
|
87
87
|
* @default true
|
|
88
88
|
*/
|
|
@@ -93,7 +93,7 @@ export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TE
|
|
|
93
93
|
*/
|
|
94
94
|
autoFocus?: boolean;
|
|
95
95
|
}
|
|
96
|
-
export interface UseFieldCommonAdditionalProps extends Required<Pick<UseFieldInternalProps<any, any, any
|
|
96
|
+
export interface UseFieldCommonAdditionalProps extends Required<Pick<UseFieldInternalProps<any, any, any>, 'disabled' | 'readOnly'>> {
|
|
97
97
|
}
|
|
98
98
|
export interface UseFieldCommonForwardedProps extends ExportedUseClearableFieldProps {
|
|
99
99
|
onKeyDown?: React.KeyboardEventHandler;
|
|
@@ -152,7 +152,7 @@ export type FieldSectionsBoundaries = {
|
|
|
152
152
|
maximum: number;
|
|
153
153
|
};
|
|
154
154
|
};
|
|
155
|
-
export type FieldChangeHandler<TValue, TError> = (value: TValue, context: FieldChangeHandlerContext<TError>) => void;
|
|
155
|
+
export type FieldChangeHandler<TValue extends PickerValidValue, TError> = (value: TValue, context: FieldChangeHandlerContext<TError>) => void;
|
|
156
156
|
export interface FieldChangeHandlerContext<TError> {
|
|
157
157
|
validationError: TError;
|
|
158
158
|
}
|
|
@@ -160,7 +160,7 @@ export interface FieldChangeHandlerContext<TError> {
|
|
|
160
160
|
* Object used to access and update the active date (i.e: the date containing the active section).
|
|
161
161
|
* Mainly useful in the range fields where we need to update the date containing the active section without impacting the other one.
|
|
162
162
|
*/
|
|
163
|
-
interface FieldActiveDateManager<TValue
|
|
163
|
+
interface FieldActiveDateManager<TValue extends PickerValidValue> {
|
|
164
164
|
/**
|
|
165
165
|
* Active date from `state.value`.
|
|
166
166
|
*/
|
|
@@ -170,87 +170,87 @@ interface FieldActiveDateManager<TValue, TSection extends FieldSection> {
|
|
|
170
170
|
*/
|
|
171
171
|
referenceDate: PickerValidDate;
|
|
172
172
|
/**
|
|
173
|
-
* @template
|
|
174
|
-
* @param {
|
|
175
|
-
* @returns {
|
|
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.
|
|
174
|
+
* @param {InferFieldSection<TValue>[]} sections The sections of the full value.
|
|
175
|
+
* @returns {InferFieldSection<TValue>[]} The sections of the active date.
|
|
176
176
|
* Get the sections of the active date.
|
|
177
177
|
*/
|
|
178
|
-
getSections: (sections:
|
|
178
|
+
getSections: (sections: InferFieldSection<TValue>[]) => InferFieldSection<TValue>[];
|
|
179
179
|
/**
|
|
180
180
|
* Creates the new value and reference value based on the new active date and the current state.
|
|
181
|
-
* @template TValue
|
|
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.
|
|
182
182
|
* @param {PickerValidDate | null} newActiveDate The new value of the date containing the active section.
|
|
183
|
-
* @returns {Pick<UseFieldState<TValue
|
|
183
|
+
* @returns {Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>} The new value and reference value to publish and store in the state.
|
|
184
184
|
*/
|
|
185
|
-
getNewValuesFromNewActiveDate: (newActiveDate: PickerValidDate | null) => Pick<UseFieldState<TValue
|
|
185
|
+
getNewValuesFromNewActiveDate: (newActiveDate: PickerValidDate | null) => Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>;
|
|
186
186
|
}
|
|
187
187
|
export type FieldParsedSelectedSections = number | 'all' | null;
|
|
188
|
-
export interface FieldValueManager<TValue
|
|
188
|
+
export interface FieldValueManager<TValue extends PickerValidValue> {
|
|
189
189
|
/**
|
|
190
190
|
* Creates the section list from the current value.
|
|
191
191
|
* The `prevSections` are used on the range fields to avoid losing the sections of a partially filled date when editing the other date.
|
|
192
|
-
* @template TValue,
|
|
192
|
+
* @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.
|
|
193
193
|
* @param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
194
194
|
* @param {TValue} value The current value to generate sections from.
|
|
195
|
-
* @param {
|
|
195
|
+
* @param {InferFieldSection<TValue>[] | null} fallbackSections The sections to use as a fallback if a date is null or invalid.
|
|
196
196
|
* @param {(date: PickerValidDate) => FieldSection[]} getSectionsFromDate Returns the sections of the given date.
|
|
197
|
-
* @returns {
|
|
197
|
+
* @returns {InferFieldSection<TValue>[]} The new section list.
|
|
198
198
|
*/
|
|
199
|
-
getSectionsFromValue: (utils: MuiPickersAdapter, value: TValue, fallbackSections:
|
|
199
|
+
getSectionsFromValue: (utils: MuiPickersAdapter, value: TValue, fallbackSections: InferFieldSection<TValue>[] | null, getSectionsFromDate: (date: PickerValidDate) => FieldSection[]) => InferFieldSection<TValue>[];
|
|
200
200
|
/**
|
|
201
201
|
* Creates the string value to render in the input based on the current section list.
|
|
202
|
-
* @template
|
|
203
|
-
* @param {
|
|
202
|
+
* @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.
|
|
203
|
+
* @param {InferFieldSection<TValue>[]} sections The current section list.
|
|
204
204
|
* @param {string} localizedDigits The conversion table from localized to 0-9 digits.
|
|
205
205
|
* @param {boolean} isRtl `true` if the current orientation is "right to left"
|
|
206
206
|
* @returns {string} The string value to render in the input.
|
|
207
207
|
*/
|
|
208
|
-
getV6InputValueFromSections: (sections:
|
|
208
|
+
getV6InputValueFromSections: (sections: InferFieldSection<TValue>[], localizedDigits: string[], isRtl: boolean) => string;
|
|
209
209
|
/**
|
|
210
210
|
* Creates the string value to render in the input based on the current section list.
|
|
211
|
-
* @template
|
|
212
|
-
* @param {
|
|
211
|
+
* @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.
|
|
212
|
+
* @param {InferFieldSection<TValue>[]} sections The current section list.
|
|
213
213
|
* @returns {string} The string value to render in the input.
|
|
214
214
|
*/
|
|
215
|
-
getV7HiddenInputValueFromSections: (sections:
|
|
215
|
+
getV7HiddenInputValueFromSections: (sections: InferFieldSection<TValue>[]) => string;
|
|
216
216
|
/**
|
|
217
217
|
* Returns the manager of the active date.
|
|
218
|
-
* @template TValue,
|
|
218
|
+
* @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.
|
|
219
219
|
* @param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
220
|
-
* @param {UseFieldState<TValue
|
|
221
|
-
* @param {
|
|
222
|
-
* @returns {FieldActiveDateManager<TValue
|
|
220
|
+
* @param {UseFieldState<TValue>} state The current state of the field.
|
|
221
|
+
* @param {InferFieldSection<TValue>} activeSection The active section.
|
|
222
|
+
* @returns {FieldActiveDateManager<TValue>} The manager of the active date.
|
|
223
223
|
*/
|
|
224
|
-
getActiveDateManager: (utils: MuiPickersAdapter, state: UseFieldState<TValue
|
|
224
|
+
getActiveDateManager: (utils: MuiPickersAdapter, state: UseFieldState<TValue>, activeSection: InferFieldSection<TValue>) => FieldActiveDateManager<TValue>;
|
|
225
225
|
/**
|
|
226
226
|
* Parses a string version (most of the time coming from the input).
|
|
227
227
|
* This method should only be used when the change does not come from a single section.
|
|
228
|
-
* @template TValue
|
|
228
|
+
* @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.
|
|
229
229
|
* @param {string} valueStr The string value to parse.
|
|
230
230
|
* @param {TValue} referenceValue The reference value currently stored in state.
|
|
231
231
|
* @param {(dateStr: string, referenceDate: PickerValidDate) => PickerValidDate | null} parseDate A method to convert a string date into a parsed one.
|
|
232
232
|
* @returns {TValue} The new parsed value.
|
|
233
233
|
*/
|
|
234
|
-
parseValueStr: (valueStr: string, referenceValue: TValue
|
|
234
|
+
parseValueStr: (valueStr: string, referenceValue: InferNonNullablePickerValue<TValue>, parseDate: (dateStr: string, referenceDate: PickerValidDate) => PickerValidDate | null) => TValue;
|
|
235
235
|
/**
|
|
236
236
|
* Update the reference value with the new value.
|
|
237
237
|
* This method must make sure that no date inside the returned `referenceValue` is invalid.
|
|
238
|
-
* @template TValue
|
|
238
|
+
* @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.
|
|
239
239
|
* @param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
240
240
|
* @param {TValue} value The new value from which we want to take all valid dates in the `referenceValue` state.
|
|
241
241
|
* @param {TValue} prevReferenceValue The previous reference value. It is used as a fallback for invalid dates in the new value.
|
|
242
242
|
* @returns {TValue} The new reference value with no invalid date.
|
|
243
243
|
*/
|
|
244
|
-
updateReferenceValue: (utils: MuiPickersAdapter, value: TValue, prevReferenceValue: TValue) => TValue
|
|
244
|
+
updateReferenceValue: (utils: MuiPickersAdapter, value: TValue, prevReferenceValue: InferNonNullablePickerValue<TValue>) => InferNonNullablePickerValue<TValue>;
|
|
245
245
|
}
|
|
246
|
-
export interface UseFieldState<TValue
|
|
246
|
+
export interface UseFieldState<TValue extends PickerValidValue> {
|
|
247
247
|
value: TValue;
|
|
248
248
|
/**
|
|
249
249
|
* Non-nullable value used to keep trace of the timezone and the date parts not present in the format.
|
|
250
250
|
* It is updated whenever we have a valid date (for the range picker we update only the portion of the range that is valid).
|
|
251
251
|
*/
|
|
252
|
-
referenceValue: TValue
|
|
253
|
-
sections:
|
|
252
|
+
referenceValue: InferNonNullablePickerValue<TValue>;
|
|
253
|
+
sections: InferFieldSection<TValue>[];
|
|
254
254
|
/**
|
|
255
255
|
* Android `onChange` behavior when the input selection is not empty is quite different from a desktop behavior.
|
|
256
256
|
* There are two `onChange` calls:
|
|
@@ -317,13 +317,13 @@ export interface UseFieldTextFieldInteractions {
|
|
|
317
317
|
setSelectedSections: (newSelectedSections: FieldSelectedSections) => void;
|
|
318
318
|
isFieldFocused: () => boolean;
|
|
319
319
|
}
|
|
320
|
-
export type UseFieldTextField<TEnableAccessibleFieldDOMStructure extends boolean> = <TValue
|
|
320
|
+
export type UseFieldTextField<TEnableAccessibleFieldDOMStructure extends boolean> = <TValue extends PickerValidValue, TForwardedProps extends TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any> & {
|
|
321
321
|
minutesStep?: number;
|
|
322
|
-
}>(params: UseFieldTextFieldParams<TValue,
|
|
322
|
+
}>(params: UseFieldTextFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => {
|
|
323
323
|
interactions: UseFieldTextFieldInteractions;
|
|
324
324
|
returnedValue: TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6AdditionalProps & Required<UseFieldV6ForwardedProps> : UseFieldV7AdditionalProps & Required<UseFieldV7ForwardedProps>;
|
|
325
325
|
};
|
|
326
|
-
interface UseFieldTextFieldParams<TValue
|
|
326
|
+
interface UseFieldTextFieldParams<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any>> extends UseFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>, UseFieldStateResponse<TValue>, UseFieldCharacterEditingResponse {
|
|
327
327
|
areAllSectionsEmpty: boolean;
|
|
328
328
|
sectionOrder: SectionOrdering;
|
|
329
329
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AvailableAdjustKeyCode, FieldSectionsValueBoundaries, SectionOrdering, FieldSectionValueBoundaries, FieldParsedSelectedSections } from './useField.types';
|
|
2
|
-
import { FieldSectionType,
|
|
2
|
+
import { FieldSectionType, FieldSection, MuiPickersAdapter, FieldSectionContentType, PickersTimezone, PickerValidDate, FieldSelectedSections, PickerValueType, InferFieldSection } from '../../../models';
|
|
3
|
+
import { PickerValidValue } from '../../models';
|
|
3
4
|
export declare const getDateSectionConfigFromFormatToken: (utils: MuiPickersAdapter, formatToken: string) => Pick<FieldSection, "type" | "contentType"> & {
|
|
4
5
|
maxLength: number | undefined;
|
|
5
6
|
};
|
|
@@ -17,7 +18,7 @@ export declare const isStringNumber: (valueStr: string, localizedDigits: string[
|
|
|
17
18
|
*/
|
|
18
19
|
export declare const cleanLeadingZeros: (valueStr: string, size: number) => string;
|
|
19
20
|
export declare const cleanDigitSectionValue: (utils: MuiPickersAdapter, value: number, sectionBoundaries: FieldSectionValueBoundaries<any>, localizedDigits: string[], section: Pick<FieldSection, "format" | "type" | "contentType" | "hasLeadingZerosInFormat" | "hasLeadingZerosInInput" | "maxLength">) => string;
|
|
20
|
-
export declare const adjustSectionValue: <
|
|
21
|
+
export declare const adjustSectionValue: <TValue extends PickerValidValue>(utils: MuiPickersAdapter, timezone: PickersTimezone, section: InferFieldSection<TValue>, keyCode: AvailableAdjustKeyCode, sectionsValueBoundaries: FieldSectionsValueBoundaries, localizedDigits: string[], activeDate: PickerValidDate | null, stepsAttributes?: {
|
|
21
22
|
minutesStep?: number;
|
|
22
23
|
}) => string;
|
|
23
24
|
export declare const getSectionVisibleValue: (section: FieldSection, target: "input-rtl" | "input-ltr" | "non-input", localizedDigits: string[]) => string;
|
|
@@ -31,7 +32,7 @@ export declare const getDateFromDateSections: (utils: MuiPickersAdapter, section
|
|
|
31
32
|
export declare const createDateStrForV7HiddenInputFromSections: (sections: FieldSection[]) => string;
|
|
32
33
|
export declare const createDateStrForV6InputFromSections: (sections: FieldSection[], localizedDigits: string[], isRtl: boolean) => string;
|
|
33
34
|
export declare const getSectionsBoundaries: (utils: MuiPickersAdapter, localizedDigits: string[], timezone: PickersTimezone) => FieldSectionsValueBoundaries;
|
|
34
|
-
export declare const validateSections: <
|
|
35
|
+
export declare const validateSections: <TValue extends PickerValidValue>(sections: InferFieldSection<TValue>[], valueType: PickerValueType) => void;
|
|
35
36
|
export declare const mergeDateIntoReferenceDate: (utils: MuiPickersAdapter, dateToTransferFrom: PickerValidDate, sections: FieldSection[], referenceDate: PickerValidDate, shouldLimitToEditedSections: boolean) => PickerValidDate;
|
|
36
37
|
export declare const isAndroid: () => boolean;
|
|
37
38
|
export declare const getSectionOrder: (sections: FieldSection[], shouldApplyRTL: boolean) => SectionOrdering;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PickersTimezone, InferFieldSection } from '../../../models';
|
|
2
2
|
import { FieldSectionsValueBoundaries } from './useField.types';
|
|
3
3
|
import { UpdateSectionValueParams } from './useFieldState';
|
|
4
|
+
import { PickerValidValue } from '../../models';
|
|
4
5
|
export interface ApplyCharacterEditingParams {
|
|
5
6
|
keyPressed: string;
|
|
6
7
|
sectionIndex: number;
|
|
7
8
|
}
|
|
8
|
-
interface UseFieldCharacterEditingParams<
|
|
9
|
-
sections:
|
|
10
|
-
updateSectionValue: (params: UpdateSectionValueParams<
|
|
9
|
+
interface UseFieldCharacterEditingParams<TValue extends PickerValidValue> {
|
|
10
|
+
sections: InferFieldSection<TValue>[];
|
|
11
|
+
updateSectionValue: (params: UpdateSectionValueParams<TValue>) => void;
|
|
11
12
|
sectionsValueBoundaries: FieldSectionsValueBoundaries;
|
|
12
13
|
localizedDigits: string[];
|
|
13
14
|
setTempAndroidValueStr: (newValue: string | null) => void;
|
|
@@ -24,5 +25,5 @@ export interface UseFieldCharacterEditingResponse {
|
|
|
24
25
|
* 1. The numeric editing when the user presses a digit
|
|
25
26
|
* 2. The letter editing when the user presses another key
|
|
26
27
|
*/
|
|
27
|
-
export declare const useFieldCharacterEditing: <
|
|
28
|
+
export declare const useFieldCharacterEditing: <TValue extends PickerValidValue>({ sections, updateSectionValue, sectionsValueBoundaries, localizedDigits, setTempAndroidValueStr, timezone, }: UseFieldCharacterEditingParams<TValue>) => UseFieldCharacterEditingResponse;
|
|
28
29
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { UseFieldInternalProps, UseFieldParams, UseFieldState, FieldParsedSelectedSections, FieldSectionsValueBoundaries, UseFieldForwardedProps } from './useField.types';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { FieldSelectedSections, PickersTimezone, InferFieldSection } from '../../../models';
|
|
3
|
+
import { PickerValidValue } from '../../models';
|
|
4
|
+
export interface UpdateSectionValueParams<TValue extends PickerValidValue> {
|
|
4
5
|
/**
|
|
5
6
|
* The section on which we want to apply the new value.
|
|
6
7
|
*/
|
|
7
|
-
activeSection:
|
|
8
|
+
activeSection: InferFieldSection<TValue>;
|
|
8
9
|
/**
|
|
9
10
|
* Value to apply to the active section.
|
|
10
11
|
*/
|
|
@@ -14,19 +15,19 @@ export interface UpdateSectionValueParams<TSection extends FieldSection> {
|
|
|
14
15
|
*/
|
|
15
16
|
shouldGoToNextSection: boolean;
|
|
16
17
|
}
|
|
17
|
-
export interface UseFieldStateResponse<TValue
|
|
18
|
-
state: UseFieldState<TValue
|
|
18
|
+
export interface UseFieldStateResponse<TValue extends PickerValidValue> {
|
|
19
|
+
state: UseFieldState<TValue>;
|
|
19
20
|
activeSectionIndex: number | null;
|
|
20
21
|
parsedSelectedSections: FieldParsedSelectedSections;
|
|
21
22
|
setSelectedSections: (sections: FieldSelectedSections) => void;
|
|
22
23
|
clearValue: () => void;
|
|
23
24
|
clearActiveSection: () => void;
|
|
24
|
-
updateSectionValue: (params: UpdateSectionValueParams<
|
|
25
|
+
updateSectionValue: (params: UpdateSectionValueParams<TValue>) => void;
|
|
25
26
|
updateValueFromValueStr: (valueStr: string) => void;
|
|
26
27
|
setTempAndroidValueStr: (tempAndroidValueStr: string | null) => void;
|
|
27
28
|
sectionsValueBoundaries: FieldSectionsValueBoundaries;
|
|
28
|
-
getSectionsFromValue: (value: TValue, fallbackSections?:
|
|
29
|
+
getSectionsFromValue: (value: TValue, fallbackSections?: InferFieldSection<TValue>[] | null) => InferFieldSection<TValue>[];
|
|
29
30
|
localizedDigits: string[];
|
|
30
31
|
timezone: PickersTimezone;
|
|
31
32
|
}
|
|
32
|
-
export declare const useFieldState: <TValue
|
|
33
|
+
export declare const useFieldState: <TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any>>(params: UseFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => UseFieldStateResponse<TValue>;
|
|
@@ -41,6 +41,7 @@ export const useFieldState = params => {
|
|
|
41
41
|
timezone: timezoneProp,
|
|
42
42
|
value: valueProp,
|
|
43
43
|
defaultValue,
|
|
44
|
+
referenceDate: referenceDateProp,
|
|
44
45
|
onChange,
|
|
45
46
|
valueManager
|
|
46
47
|
});
|
|
@@ -63,7 +64,6 @@ export const useFieldState = params => {
|
|
|
63
64
|
const stateWithoutReferenceDate = {
|
|
64
65
|
sections,
|
|
65
66
|
value: valueFromTheOutside,
|
|
66
|
-
referenceValue: valueManager.emptyValue,
|
|
67
67
|
tempValueStrAndroid: null
|
|
68
68
|
};
|
|
69
69
|
const granularity = getSectionTypeGranularity(sections);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UseFieldTextField } from './useField.types';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { InferFieldSection } from '../../../models';
|
|
3
|
+
import { PickerValidValue } from '../../models';
|
|
4
|
+
type FieldSectionWithPositions<TValue extends PickerValidValue> = InferFieldSection<TValue> & {
|
|
4
5
|
/**
|
|
5
6
|
* Start index of the section in the format
|
|
6
7
|
*/
|
|
@@ -20,6 +21,6 @@ type FieldSectionWithPositions<TSection> = TSection & {
|
|
|
20
21
|
*/
|
|
21
22
|
endInInput: number;
|
|
22
23
|
};
|
|
23
|
-
export declare const addPositionPropertiesToSections: <
|
|
24
|
+
export declare const addPositionPropertiesToSections: <TValue extends PickerValidValue>(sections: InferFieldSection<TValue>[], localizedDigits: string[], isRtl: boolean) => FieldSectionWithPositions<TValue>[];
|
|
24
25
|
export declare const useFieldV6TextField: UseFieldTextField<false>;
|
|
25
26
|
export {};
|
|
@@ -198,8 +198,9 @@ export const useFieldV7TextField = params => {
|
|
|
198
198
|
if (focused || !sectionListRef.current) {
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
|
+
const activeElement = getActiveElement(document);
|
|
201
202
|
setFocused(true);
|
|
202
|
-
const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(
|
|
203
|
+
const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(activeElement) != null;
|
|
203
204
|
if (!isFocusInsideASection) {
|
|
204
205
|
setSelectedSections(sectionOrder.startIndex);
|
|
205
206
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FieldOwnerState } from '../../models';
|
|
2
|
+
import { FormProps } from '../models';
|
|
3
|
+
export declare function useFieldOwnerState(parameters: UseFieldOwnerStateParameters): FieldOwnerState;
|
|
4
|
+
interface UseFieldOwnerStateParameters extends FormProps {
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { usePickerPrivateContext } from "./usePickerPrivateContext.js";
|
|
4
|
+
export function useFieldOwnerState(parameters) {
|
|
5
|
+
const {
|
|
6
|
+
ownerState: pickerOwnerState
|
|
7
|
+
} = usePickerPrivateContext();
|
|
8
|
+
return React.useMemo(() => _extends({}, pickerOwnerState, {
|
|
9
|
+
isFieldDisabled: parameters.disabled ?? false,
|
|
10
|
+
isFieldReadOnly: parameters.readOnly ?? false
|
|
11
|
+
}), [pickerOwnerState, parameters.disabled, parameters.readOnly]);
|
|
12
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import { SlotComponentProps } from '@mui/utils';
|
|
2
|
+
import type { TextFieldProps } from '@mui/material/TextField';
|
|
4
3
|
import { MakeRequired, SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
5
4
|
import { BaseNonStaticPickerProps, BasePickerProps, BaseNonRangeNonStaticPickerProps } from '../../models/props/basePickerProps';
|
|
6
5
|
import { PickersModalDialogSlots, PickersModalDialogSlotProps } from '../../components/PickersModalDialog';
|
|
7
6
|
import { UsePickerParams } from '../usePicker';
|
|
8
|
-
import {
|
|
7
|
+
import { FieldOwnerState, PickerFieldSlotProps, PickerOwnerState, PickerValidDate } from '../../../models';
|
|
9
8
|
import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from '../../../PickersLayout/PickersLayout.types';
|
|
10
9
|
import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue.types';
|
|
11
10
|
import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
|
|
12
|
-
import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
13
|
-
|
|
11
|
+
import { DateOrTimeViewWithMeridiem, PickerValue } from '../../models';
|
|
12
|
+
import { PickersTextFieldProps } from '../../../PickersTextField';
|
|
13
|
+
export interface UseMobilePickerSlots<TView extends DateOrTimeViewWithMeridiem> extends PickersModalDialogSlots, ExportedPickersLayoutSlots<PickerValue, TView> {
|
|
14
14
|
/**
|
|
15
15
|
* Component used to enter the date with the keyboard.
|
|
16
16
|
*/
|
|
@@ -21,15 +21,15 @@ export interface UseMobilePickerSlots<TView extends DateOrTimeViewWithMeridiem>
|
|
|
21
21
|
*/
|
|
22
22
|
textField?: React.ElementType;
|
|
23
23
|
}
|
|
24
|
-
export interface ExportedUseMobilePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends PickersModalDialogSlotProps, ExportedPickersLayoutSlotProps<
|
|
25
|
-
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<
|
|
26
|
-
textField?:
|
|
24
|
+
export interface ExportedUseMobilePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends PickersModalDialogSlotProps, ExportedPickersLayoutSlotProps<PickerValue, TView> {
|
|
25
|
+
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
|
|
26
|
+
textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
|
|
27
27
|
}
|
|
28
|
-
export interface UseMobilePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseMobilePickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<
|
|
28
|
+
export interface UseMobilePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseMobilePickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue, TView>, 'toolbar'> {
|
|
29
29
|
}
|
|
30
30
|
export interface MobileOnlyPickerProps extends BaseNonStaticPickerProps, BaseNonRangeNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerViewsNonStaticProps {
|
|
31
31
|
}
|
|
32
|
-
export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any, any>> extends BasePickerProps<
|
|
32
|
+
export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any, any>> extends BasePickerProps<PickerValue, TView, TError, TExternalProps, {}>, MakeRequired<MobileOnlyPickerProps, 'format'> {
|
|
33
33
|
/**
|
|
34
34
|
* Overridable component slots.
|
|
35
35
|
* @default {}
|
|
@@ -41,7 +41,7 @@ export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
|
41
41
|
*/
|
|
42
42
|
slotProps?: UseMobilePickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>;
|
|
43
43
|
}
|
|
44
|
-
export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<
|
|
44
|
+
export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps, {}>, 'valueManager' | 'valueType' | 'validator'> {
|
|
45
45
|
props: TExternalProps;
|
|
46
46
|
getOpenDialogAriaText: (date: PickerValidDate | null) => string;
|
|
47
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { UsePickerParams, UsePickerProps, UsePickerResponse } from './usePicker.types';
|
|
2
|
-
import {
|
|
3
|
-
import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
4
|
-
export declare const usePicker: <TValue
|
|
2
|
+
import { InferError } from '../../../models';
|
|
3
|
+
import { DateOrTimeViewWithMeridiem, PickerValidValue } from '../../models';
|
|
4
|
+
export declare const usePicker: <TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerProps<TValue, TView, any, any, any>, TAdditionalProps extends {}>({ props, valueManager, valueType, variant, additionalViewProps, validator, autoFocusView, rendererInterceptor, fieldRef, localeText, }: UsePickerParams<TValue, TView, TExternalProps, TAdditionalProps>) => UsePickerResponse<TValue, TView, InferError<TExternalProps>>;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
2
3
|
import { usePickerValue } from "./usePickerValue.js";
|
|
3
4
|
import { usePickerViews } from "./usePickerViews.js";
|
|
4
|
-
import { usePickerLayoutProps } from "./usePickerLayoutProps.js";
|
|
5
|
-
import { usePickerOwnerState } from "./usePickerOwnerState.js";
|
|
6
5
|
import { usePickerProvider } from "./usePickerProvider.js";
|
|
7
6
|
export const usePicker = ({
|
|
8
7
|
props,
|
|
9
8
|
valueManager,
|
|
10
9
|
valueType,
|
|
11
|
-
|
|
10
|
+
variant,
|
|
12
11
|
additionalViewProps,
|
|
13
12
|
validator,
|
|
14
13
|
autoFocusView,
|
|
@@ -25,7 +24,7 @@ export const usePicker = ({
|
|
|
25
24
|
props,
|
|
26
25
|
valueManager,
|
|
27
26
|
valueType,
|
|
28
|
-
|
|
27
|
+
variant,
|
|
29
28
|
validator
|
|
30
29
|
});
|
|
31
30
|
const pickerViewsResponse = usePickerViews({
|
|
@@ -36,21 +35,13 @@ export const usePicker = ({
|
|
|
36
35
|
propsFromPickerValue: pickerValueResponse.viewProps,
|
|
37
36
|
rendererInterceptor
|
|
38
37
|
});
|
|
39
|
-
const pickerLayoutResponse = usePickerLayoutProps({
|
|
40
|
-
props,
|
|
41
|
-
wrapperVariant,
|
|
42
|
-
propsFromPickerValue: pickerValueResponse.layoutProps,
|
|
43
|
-
propsFromPickerViews: pickerViewsResponse.layoutProps
|
|
44
|
-
});
|
|
45
|
-
const pickerOwnerState = usePickerOwnerState({
|
|
46
|
-
props,
|
|
47
|
-
pickerValueResponse,
|
|
48
|
-
valueManager
|
|
49
|
-
});
|
|
50
38
|
const providerProps = usePickerProvider({
|
|
39
|
+
props,
|
|
51
40
|
pickerValueResponse,
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
localeText,
|
|
42
|
+
valueManager,
|
|
43
|
+
variant,
|
|
44
|
+
views: pickerViewsResponse.views
|
|
54
45
|
});
|
|
55
46
|
return {
|
|
56
47
|
// Picker value
|
|
@@ -62,10 +53,10 @@ export const usePicker = ({
|
|
|
62
53
|
hasUIView: pickerViewsResponse.hasUIView,
|
|
63
54
|
shouldRestoreFocus: pickerViewsResponse.shouldRestoreFocus,
|
|
64
55
|
// Picker layout
|
|
65
|
-
layoutProps:
|
|
56
|
+
layoutProps: _extends({}, pickerViewsResponse.layoutProps, pickerValueResponse.layoutProps),
|
|
66
57
|
// Picker provider
|
|
67
58
|
providerProps,
|
|
68
59
|
// Picker owner state
|
|
69
|
-
ownerState:
|
|
60
|
+
ownerState: providerProps.privateContextValue.ownerState
|
|
70
61
|
};
|
|
71
62
|
};
|