@mui/x-date-pickers 8.0.0-alpha.7 → 8.0.0-alpha.9
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/CHANGELOG.md +551 -3
- package/DateCalendar/DayCalendar.js +2 -0
- package/DateField/DateField.js +26 -31
- package/DateField/DateField.types.d.ts +6 -15
- package/DateField/useDateField.d.ts +1 -1
- package/DateField/useDateField.js +2 -1
- package/DateTimeField/DateTimeField.js +26 -31
- package/DateTimeField/DateTimeField.types.d.ts +6 -15
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimeField/useDateTimeField.js +2 -1
- package/DesktopDatePicker/DesktopDatePicker.js +0 -11
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -12
- package/DesktopTimePicker/DesktopTimePicker.js +1 -12
- package/MobileDatePicker/MobileDatePicker.js +0 -9
- package/MobileDateTimePicker/MobileDateTimePicker.js +0 -9
- package/MobileTimePicker/MobileTimePicker.js +0 -9
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +2 -0
- package/PickersCalendarHeader/PickersCalendarHeader.js +2 -0
- package/TimeClock/ClockPointer.js +2 -0
- package/TimeField/TimeField.js +25 -30
- package/TimeField/TimeField.types.d.ts +6 -15
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimeField/useTimeField.js +2 -1
- package/hooks/useParsedFormat.d.ts +8 -6
- package/hooks/useParsedFormat.js +10 -12
- package/hooks/usePickerActionsContext.d.ts +1 -1
- package/hooks/usePickerContext.d.ts +4 -2
- package/hooks/usePickerContext.js +2 -1
- package/hooks/useSplitFieldProps.d.ts +12 -3
- package/hooks/useSplitFieldProps.js +8 -3
- package/index.js +1 -1
- package/internals/components/PickerFieldUI.d.ts +132 -0
- package/internals/components/PickerFieldUI.js +306 -0
- package/internals/components/PickerProvider.d.ts +25 -4
- package/internals/components/PickerProvider.js +11 -6
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +21 -94
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +8 -31
- package/internals/hooks/useField/index.d.ts +3 -1
- package/internals/hooks/useField/index.js +3 -2
- package/internals/hooks/useField/useField.d.ts +1 -10
- package/internals/hooks/useField/useField.js +16 -19
- package/internals/hooks/useField/useField.types.d.ts +11 -4
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +15 -0
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +46 -0
- package/internals/hooks/useField/useFieldV6TextField.js +3 -0
- package/internals/hooks/useField/useFieldV7TextField.js +6 -3
- package/internals/hooks/useFieldOwnerState.d.ts +1 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.js +20 -49
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +6 -14
- package/internals/hooks/useNullablePickerContext.d.ts +5 -0
- package/internals/hooks/useNullablePickerContext.js +10 -0
- package/internals/hooks/usePicker/usePicker.d.ts +1 -2
- package/internals/hooks/usePicker/usePicker.js +0 -3
- package/internals/hooks/usePicker/usePicker.types.d.ts +2 -3
- package/internals/hooks/usePicker/usePickerProvider.d.ts +8 -2
- package/internals/hooks/usePicker/usePickerProvider.js +22 -2
- package/internals/hooks/usePicker/usePickerValue.js +5 -11
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +5 -2
- package/internals/hooks/useUtils.d.ts +4 -3
- package/internals/index.d.ts +6 -3
- package/internals/index.js +1 -1
- package/internals/models/fields.d.ts +3 -16
- package/internals/models/manager.d.ts +3 -0
- package/internals/models/props/basePickerProps.d.ts +0 -12
- package/locales/utils/getPickersLocalization.d.ts +0 -7
- package/locales/utils/getPickersLocalization.js +0 -13
- package/managers/index.d.ts +3 -3
- package/managers/useDateManager.d.ts +1 -1
- package/managers/useDateManager.js +9 -1
- package/managers/useDateTimeManager.d.ts +1 -1
- package/managers/useDateTimeManager.js +9 -1
- package/managers/useTimeManager.d.ts +1 -1
- package/managers/useTimeManager.js +9 -1
- package/models/fields.d.ts +4 -4
- package/models/manager.d.ts +12 -3
- package/modern/DateCalendar/DayCalendar.js +2 -0
- package/modern/DateField/DateField.js +26 -31
- package/modern/DateField/useDateField.js +2 -1
- package/modern/DateTimeField/DateTimeField.js +26 -31
- package/modern/DateTimeField/useDateTimeField.js +2 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +0 -11
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -12
- package/modern/DesktopTimePicker/DesktopTimePicker.js +1 -12
- package/modern/MobileDatePicker/MobileDatePicker.js +0 -9
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +0 -9
- package/modern/MobileTimePicker/MobileTimePicker.js +0 -9
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +2 -0
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +2 -0
- package/modern/TimeClock/ClockPointer.js +2 -0
- package/modern/TimeField/TimeField.js +25 -30
- package/modern/TimeField/useTimeField.js +2 -1
- package/modern/hooks/useParsedFormat.js +10 -12
- package/modern/hooks/usePickerContext.js +2 -1
- package/modern/hooks/useSplitFieldProps.js +8 -3
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerFieldUI.js +306 -0
- package/modern/internals/components/PickerProvider.js +11 -6
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +21 -94
- package/modern/internals/hooks/useField/index.js +3 -2
- package/modern/internals/hooks/useField/useField.js +16 -19
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +46 -0
- package/modern/internals/hooks/useField/useFieldV6TextField.js +3 -0
- package/modern/internals/hooks/useField/useFieldV7TextField.js +6 -3
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +20 -49
- package/modern/internals/hooks/useNullablePickerContext.js +10 -0
- package/modern/internals/hooks/usePicker/usePicker.js +0 -3
- package/modern/internals/hooks/usePicker/usePickerProvider.js +22 -2
- package/modern/internals/hooks/usePicker/usePickerValue.js +5 -11
- package/modern/internals/index.js +1 -1
- package/modern/locales/utils/getPickersLocalization.js +0 -13
- package/modern/managers/useDateManager.js +9 -1
- package/modern/managers/useDateTimeManager.js +9 -1
- package/modern/managers/useTimeManager.js +9 -1
- package/node/DateCalendar/DayCalendar.js +1 -0
- package/node/DateField/DateField.js +26 -31
- package/node/DateField/useDateField.js +2 -1
- package/node/DateTimeField/DateTimeField.js +26 -31
- package/node/DateTimeField/useDateTimeField.js +2 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +0 -11
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -12
- package/node/DesktopTimePicker/DesktopTimePicker.js +1 -12
- package/node/MobileDatePicker/MobileDatePicker.js +0 -9
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +0 -9
- package/node/MobileTimePicker/MobileTimePicker.js +0 -9
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -0
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +2 -0
- package/node/TimeClock/ClockPointer.js +1 -0
- package/node/TimeField/TimeField.js +25 -30
- package/node/TimeField/useTimeField.js +2 -1
- package/node/hooks/useParsedFormat.js +10 -12
- package/node/hooks/usePickerContext.js +4 -3
- package/node/hooks/useSplitFieldProps.js +7 -2
- package/node/index.js +1 -1
- package/node/internals/components/PickerFieldUI.js +318 -0
- package/node/internals/components/PickerProvider.js +13 -8
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +23 -96
- package/node/internals/hooks/useField/index.js +3 -2
- package/node/internals/hooks/useField/useField.js +17 -21
- package/node/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +55 -0
- package/node/internals/hooks/useField/useFieldV6TextField.js +3 -0
- package/node/internals/hooks/useField/useFieldV7TextField.js +6 -3
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +20 -49
- package/node/internals/hooks/useNullablePickerContext.js +16 -0
- package/node/internals/hooks/usePicker/usePicker.js +0 -3
- package/node/internals/hooks/usePicker/usePickerProvider.js +22 -2
- package/node/internals/hooks/usePicker/usePickerValue.js +5 -11
- package/node/internals/index.js +21 -3
- package/node/locales/utils/getPickersLocalization.js +2 -16
- package/node/managers/useDateManager.js +9 -1
- package/node/managers/useDateTimeManager.js +9 -1
- package/node/managers/useTimeManager.js +9 -1
- package/package.json +2 -2
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.d.ts +0 -3
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -44
- package/modern/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -44
- package/node/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -52
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface UseParsedFormatParameters {
|
|
2
|
+
/**
|
|
3
|
+
* Format to parse.
|
|
4
|
+
* @default the format provided by the picker.
|
|
5
|
+
*/
|
|
6
|
+
format?: string;
|
|
3
7
|
}
|
|
4
8
|
/**
|
|
5
9
|
* Returns the parsed format to be rendered in the field when there is no value or in other parts of the Picker.
|
|
6
10
|
* This format is localized (for example `AAAA` for the year with the French locale) and cannot be parsed by your date library.
|
|
7
11
|
* @param {object} The parameters needed to build the placeholder.
|
|
8
|
-
* @param {string} params.format Format
|
|
9
|
-
* @param {'dense' | 'spacious'} params.formatDensity Density of the format (setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character).
|
|
10
|
-
* @param {boolean} params.shouldRespectLeadingZeros If `true`, the format will respect the leading zeroes, if `false`, the format will always add leading zeroes.
|
|
12
|
+
* @param {string} params.format Format to parse.
|
|
11
13
|
* @returns
|
|
12
14
|
*/
|
|
13
|
-
export declare const useParsedFormat: (parameters
|
|
15
|
+
export declare const useParsedFormat: (parameters?: UseParsedFormatParameters) => string;
|
|
14
16
|
export {};
|
package/hooks/useParsedFormat.js
CHANGED
|
@@ -6,32 +6,30 @@ import { useUtils } from "../internals/hooks/useUtils.js";
|
|
|
6
6
|
import { buildSectionsFromFormat } from "../internals/hooks/useField/buildSectionsFromFormat.js";
|
|
7
7
|
import { getLocalizedDigits } from "../internals/hooks/useField/useField.utils.js";
|
|
8
8
|
import { usePickerTranslations } from "./usePickerTranslations.js";
|
|
9
|
+
import { useNullablePickerContext } from "../internals/hooks/useNullablePickerContext.js";
|
|
9
10
|
/**
|
|
10
11
|
* Returns the parsed format to be rendered in the field when there is no value or in other parts of the Picker.
|
|
11
12
|
* This format is localized (for example `AAAA` for the year with the French locale) and cannot be parsed by your date library.
|
|
12
13
|
* @param {object} The parameters needed to build the placeholder.
|
|
13
|
-
* @param {string} params.format Format
|
|
14
|
-
* @param {'dense' | 'spacious'} params.formatDensity Density of the format (setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character).
|
|
15
|
-
* @param {boolean} params.shouldRespectLeadingZeros If `true`, the format will respect the leading zeroes, if `false`, the format will always add leading zeroes.
|
|
14
|
+
* @param {string} params.format Format to parse.
|
|
16
15
|
* @returns
|
|
17
16
|
*/
|
|
18
|
-
export const useParsedFormat = parameters => {
|
|
19
|
-
const
|
|
20
|
-
format,
|
|
21
|
-
formatDensity = 'dense',
|
|
22
|
-
shouldRespectLeadingZeros = false
|
|
23
|
-
} = parameters;
|
|
17
|
+
export const useParsedFormat = (parameters = {}) => {
|
|
18
|
+
const pickerContext = useNullablePickerContext();
|
|
24
19
|
const utils = useUtils();
|
|
25
20
|
const isRtl = useRtl();
|
|
26
21
|
const translations = usePickerTranslations();
|
|
27
22
|
const localizedDigits = React.useMemo(() => getLocalizedDigits(utils), [utils]);
|
|
23
|
+
const {
|
|
24
|
+
format = pickerContext?.fieldFormat ?? utils.formats.fullDate
|
|
25
|
+
} = parameters;
|
|
28
26
|
return React.useMemo(() => {
|
|
29
27
|
const sections = buildSectionsFromFormat({
|
|
30
28
|
utils,
|
|
31
29
|
format,
|
|
32
|
-
formatDensity,
|
|
30
|
+
formatDensity: 'dense',
|
|
33
31
|
isRtl,
|
|
34
|
-
shouldRespectLeadingZeros,
|
|
32
|
+
shouldRespectLeadingZeros: true,
|
|
35
33
|
localeText: translations,
|
|
36
34
|
localizedDigits,
|
|
37
35
|
date: null,
|
|
@@ -39,5 +37,5 @@ export const useParsedFormat = parameters => {
|
|
|
39
37
|
enableAccessibleFieldDOMStructure: false
|
|
40
38
|
});
|
|
41
39
|
return sections.map(section => `${section.startSeparator}${section.placeholder}${section.endSeparator}`).join('');
|
|
42
|
-
}, [utils, isRtl, translations, localizedDigits, format
|
|
40
|
+
}, [utils, isRtl, translations, localizedDigits, format]);
|
|
43
41
|
};
|
|
@@ -4,4 +4,4 @@ import { DateOrTimeViewWithMeridiem, PickerValidValue, PickerValue } from '../in
|
|
|
4
4
|
* Returns a subset of the context passed by the picker wrapping the current component.
|
|
5
5
|
* It only contains the actions and never causes a re-render of the component using it.
|
|
6
6
|
*/
|
|
7
|
-
export declare const usePickerActionsContext: <TValue extends PickerValidValue = PickerValue, TView extends DateOrTimeViewWithMeridiem = DateOrTimeViewWithMeridiem, TError = string>() => PickerActionsContextValue<TValue, TView, TError>;
|
|
7
|
+
export declare const usePickerActionsContext: <TValue extends PickerValidValue = PickerValue, TView extends DateOrTimeViewWithMeridiem = DateOrTimeViewWithMeridiem, TError = string | null>() => PickerActionsContextValue<TValue, TView, TError>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PickerContextValue } from '../internals/components/PickerProvider';
|
|
2
3
|
import { DateOrTimeViewWithMeridiem, PickerValidValue, PickerValue } from '../internals/models';
|
|
4
|
+
export declare const PickerContext: React.Context<PickerContextValue<any, any, any> | null>;
|
|
3
5
|
/**
|
|
4
6
|
* Returns the context passed by the picker that wraps the current component.
|
|
5
7
|
*/
|
|
6
|
-
export declare const usePickerContext: <TValue extends PickerValidValue = PickerValue, TView extends DateOrTimeViewWithMeridiem = DateOrTimeViewWithMeridiem, TError = string>() => PickerContextValue<TValue, TView, TError>;
|
|
8
|
+
export declare const usePickerContext: <TValue extends PickerValidValue = PickerValue, TView extends DateOrTimeViewWithMeridiem = DateOrTimeViewWithMeridiem, TError = string | null>() => PickerContextValue<TValue, TView, TError>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
|
|
4
|
+
export const PickerContext = /*#__PURE__*/React.createContext(null);
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Returns the context passed by the picker that wraps the current component.
|
|
7
8
|
*/
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from '../validation/extractValidationProps';
|
|
2
2
|
import { PickerValueType } from '../models/common';
|
|
3
|
-
declare const SHARED_FIELD_INTERNAL_PROP_NAMES: readonly ["value", "defaultValue", "referenceDate", "format", "formatDensity", "onChange", "timezone", "onError", "shouldRespectLeadingZeros", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef", "enableAccessibleFieldDOMStructure", "disabled", "readOnly", "dateSeparator"];
|
|
3
|
+
declare const SHARED_FIELD_INTERNAL_PROP_NAMES: readonly ["value", "defaultValue", "referenceDate", "format", "formatDensity", "onChange", "timezone", "onError", "shouldRespectLeadingZeros", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef", "unstableStartFieldRef", "unstableEndFieldRef", "enableAccessibleFieldDOMStructure", "disabled", "readOnly", "dateSeparator", "autoFocus"];
|
|
4
4
|
type InternalPropNames<TValueType extends PickerValueType> = (typeof SHARED_FIELD_INTERNAL_PROP_NAMES)[number] | (TValueType extends 'date' | 'date-time' ? (typeof DATE_VALIDATION_PROP_NAMES)[number] : never) | (TValueType extends 'time' | 'date-time' ? (typeof TIME_VALIDATION_PROP_NAMES)[number] : never) | (TValueType extends 'date-time' ? (typeof DATE_TIME_VALIDATION_PROP_NAMES)[number] : never);
|
|
5
5
|
/**
|
|
6
6
|
* Split the props received by the field component into:
|
|
7
7
|
* - `internalProps` which are used by the various hooks called by the field component.
|
|
8
8
|
* - `forwardedProps` which are passed to the underlying component.
|
|
9
9
|
* Note that some forwarded props might be used by the hooks as well.
|
|
10
|
-
* For instance, hooks like `useDateField` need props like `
|
|
10
|
+
* For instance, hooks like `useDateField` need props like `onKeyDown` to merge the default event handler and the one provided by the application.
|
|
11
11
|
* @template TProps, TValueType
|
|
12
12
|
* @param {TProps} props The props received by the field component.
|
|
13
13
|
* @param {TValueType} valueType The type of the field value ('date', 'time', or 'date-time').
|
|
14
14
|
*/
|
|
15
15
|
export declare const useSplitFieldProps: <TValueType extends PickerValueType, TProps extends { [key in InternalPropNames<TValueType>]?: any; }>(props: TProps, valueType: TValueType) => {
|
|
16
16
|
forwardedProps: Omit<TProps, InternalPropNames<TValueType>>;
|
|
17
|
-
internalProps:
|
|
17
|
+
internalProps: ExtractInternalProps<TValueType, TProps>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Extract the internal props from the props received by the field component.
|
|
21
|
+
* This makes sure that the internal props not defined in the props are not present in the result.
|
|
22
|
+
*/
|
|
23
|
+
type ExtractInternalProps<TValueType extends PickerValueType, TProps extends {
|
|
24
|
+
[key in InternalPropNames<TValueType>]?: any;
|
|
25
|
+
}> = {
|
|
26
|
+
[K in keyof TProps]: K extends InternalPropNames<TValueType> ? TProps[K] : never;
|
|
18
27
|
};
|
|
19
28
|
export {};
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from "../validation/extractValidationProps.js";
|
|
6
|
-
const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly', 'dateSeparator'];
|
|
6
|
+
const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'unstableStartFieldRef', 'unstableEndFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly', 'dateSeparator', 'autoFocus'];
|
|
7
7
|
/**
|
|
8
8
|
* Split the props received by the field component into:
|
|
9
9
|
* - `internalProps` which are used by the various hooks called by the field component.
|
|
10
10
|
* - `forwardedProps` which are passed to the underlying component.
|
|
11
11
|
* Note that some forwarded props might be used by the hooks as well.
|
|
12
|
-
* For instance, hooks like `useDateField` need props like `
|
|
12
|
+
* For instance, hooks like `useDateField` need props like `onKeyDown` to merge the default event handler and the one provided by the application.
|
|
13
13
|
* @template TProps, TValueType
|
|
14
14
|
* @param {TProps} props The props received by the field component.
|
|
15
15
|
* @param {TValueType} valueType The type of the field value ('date', 'time', or 'date-time').
|
|
@@ -40,4 +40,9 @@ export const useSplitFieldProps = (props, valueType) => {
|
|
|
40
40
|
internalProps
|
|
41
41
|
};
|
|
42
42
|
}, [props, valueType]);
|
|
43
|
-
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Extract the internal props from the props received by the field component.
|
|
47
|
+
* This makes sure that the internal props not defined in the props are not present in the result.
|
|
48
|
+
*/
|
package/index.js
CHANGED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
import { IconButtonProps } from '@mui/material/IconButton';
|
|
4
|
+
import { InputAdornmentProps } from '@mui/material/InputAdornment';
|
|
5
|
+
import { SvgIconProps } from '@mui/material/SvgIcon';
|
|
6
|
+
import { MakeOptional, SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
7
|
+
import { FieldOwnerState } from '../../models';
|
|
8
|
+
import { UseFieldOwnerStateParameters } from '../hooks/useFieldOwnerState';
|
|
9
|
+
import type { UseFieldResponse } from '../hooks/useField';
|
|
10
|
+
import { PickersTextFieldProps } from '../../PickersTextField';
|
|
11
|
+
export declare const cleanFieldResponse: <TFieldResponse extends MakeOptional<UseFieldResponse<any, ExportedPickerFieldUIProps & {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}>, "onClear" | "clearable">>({ enableAccessibleFieldDOMStructure, ...fieldResponse }: TFieldResponse) => ExportedPickerFieldUIProps & {
|
|
14
|
+
openPickerAriaLabel: string;
|
|
15
|
+
textFieldProps: TextFieldProps | PickersTextFieldProps;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Adds the button to open the picker and the button to clear the value of the field.
|
|
19
|
+
* @ignore - internal component.
|
|
20
|
+
*/
|
|
21
|
+
export declare function PickerFieldUI(props: PickerFieldUIProps): React.JSX.Element;
|
|
22
|
+
export interface ExportedPickerFieldUIProps {
|
|
23
|
+
/**
|
|
24
|
+
* If `true`, a clear button will be shown in the field allowing value clearing.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
clearable?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Callback fired when the clear button is clicked.
|
|
30
|
+
*/
|
|
31
|
+
onClear?: React.MouseEventHandler;
|
|
32
|
+
/**
|
|
33
|
+
* The position at which the clear button is placed.
|
|
34
|
+
* If the field is not clearable, the button is not rendered.
|
|
35
|
+
* @default 'end'
|
|
36
|
+
*/
|
|
37
|
+
clearButtonPosition?: 'start' | 'end';
|
|
38
|
+
/**
|
|
39
|
+
* The position at which the opening button is placed.
|
|
40
|
+
* If there is no picker to open, the button is not rendered
|
|
41
|
+
* @default 'end'
|
|
42
|
+
*/
|
|
43
|
+
openPickerButtonPosition?: 'start' | 'end';
|
|
44
|
+
}
|
|
45
|
+
export interface PickerFieldUIProps {
|
|
46
|
+
/**
|
|
47
|
+
* Overridable component slots.
|
|
48
|
+
* @default {}
|
|
49
|
+
*/
|
|
50
|
+
slots?: PickerFieldUISlots;
|
|
51
|
+
/**
|
|
52
|
+
* The props used for each component slot.
|
|
53
|
+
* @default {}
|
|
54
|
+
*/
|
|
55
|
+
slotProps?: PickerFieldUISlotProps;
|
|
56
|
+
/**
|
|
57
|
+
* Object returned by the `useField` hook or one of its wrapper (for example `useDateField`).
|
|
58
|
+
*/
|
|
59
|
+
fieldResponse: UseFieldResponse<any, any>;
|
|
60
|
+
/**
|
|
61
|
+
* The component to use to render the picker opening icon if none is provided in the picker's slots.
|
|
62
|
+
*/
|
|
63
|
+
defaultOpenPickerIcon: React.ElementType;
|
|
64
|
+
}
|
|
65
|
+
export interface PickerFieldUISlots {
|
|
66
|
+
/**
|
|
67
|
+
* Form control with an input to render the value.
|
|
68
|
+
* @default <PickersTextField />, or <TextField /> from '@mui/material' if `enableAccessibleFieldDOMStructure` is `false`.
|
|
69
|
+
*/
|
|
70
|
+
textField?: React.ElementType;
|
|
71
|
+
/**
|
|
72
|
+
* Component displayed on the start or end input adornment used to open the picker on desktop.
|
|
73
|
+
* @default InputAdornment
|
|
74
|
+
*/
|
|
75
|
+
inputAdornment?: React.ElementType<InputAdornmentProps>;
|
|
76
|
+
/**
|
|
77
|
+
* Icon to display inside the clear button.
|
|
78
|
+
* @default ClearIcon
|
|
79
|
+
*/
|
|
80
|
+
clearIcon?: React.ElementType;
|
|
81
|
+
/**
|
|
82
|
+
* Button to clear the value.
|
|
83
|
+
* @default IconButton
|
|
84
|
+
*/
|
|
85
|
+
clearButton?: React.ElementType;
|
|
86
|
+
}
|
|
87
|
+
export interface PickerFieldUISlotsFromContext extends PickerFieldUISlots {
|
|
88
|
+
/**
|
|
89
|
+
* Button to open the picker on desktop.
|
|
90
|
+
* @default IconButton
|
|
91
|
+
*/
|
|
92
|
+
openPickerButton?: React.ElementType<IconButtonProps>;
|
|
93
|
+
/**
|
|
94
|
+
* Icon displayed in the open picker button on desktop.
|
|
95
|
+
*/
|
|
96
|
+
openPickerIcon?: React.ElementType;
|
|
97
|
+
}
|
|
98
|
+
export interface PickerFieldUISlotProps {
|
|
99
|
+
textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
|
|
100
|
+
inputAdornment?: SlotComponentPropsFromProps<InputAdornmentProps, {}, FieldInputAdornmentOwnerState>;
|
|
101
|
+
clearIcon?: SlotComponentPropsFromProps<SvgIconProps, {}, FieldOwnerState>;
|
|
102
|
+
clearButton?: SlotComponentPropsFromProps<IconButtonProps, {}, FieldOwnerState>;
|
|
103
|
+
}
|
|
104
|
+
export interface PickerFieldUISlotPropsFromContext extends PickerFieldUISlotProps {
|
|
105
|
+
openPickerButton?: SlotComponentPropsFromProps<IconButtonProps, {}, FieldOwnerState>;
|
|
106
|
+
openPickerIcon?: SlotComponentPropsFromProps<SvgIconProps, {}, FieldOwnerState>;
|
|
107
|
+
}
|
|
108
|
+
interface FieldInputAdornmentOwnerState extends FieldOwnerState {
|
|
109
|
+
position: 'start' | 'end';
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The `textField` slot props cannot be handled inside `PickerFieldUI` because it would be a breaking change to not pass the enriched props to `useField`.
|
|
113
|
+
* Once the non-accessible DOM structure will be removed, we will be able to remove the `textField` slot and clean this logic.
|
|
114
|
+
*/
|
|
115
|
+
export declare function useFieldTextFieldProps<TProps extends UseFieldOwnerStateParameters & {
|
|
116
|
+
inputProps?: {};
|
|
117
|
+
InputProps?: {};
|
|
118
|
+
}>(parameters: UseFieldTextFieldPropsParameters): TProps;
|
|
119
|
+
interface UseFieldTextFieldPropsParameters {
|
|
120
|
+
slotProps: {
|
|
121
|
+
textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
|
|
122
|
+
} | undefined;
|
|
123
|
+
ref: React.Ref<HTMLDivElement>;
|
|
124
|
+
externalForwardedProps: any;
|
|
125
|
+
}
|
|
126
|
+
export declare function PickerFieldUIContextProvider(props: PickerFieldUIContextProviderProps): React.JSX.Element;
|
|
127
|
+
interface PickerFieldUIContextProviderProps {
|
|
128
|
+
children: React.ReactNode;
|
|
129
|
+
slots: PickerFieldUISlotsFromContext | undefined;
|
|
130
|
+
slotProps: PickerFieldUISlotPropsFromContext | undefined;
|
|
131
|
+
}
|
|
132
|
+
export {};
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["enableAccessibleFieldDOMStructure"],
|
|
4
|
+
_excluded2 = ["InputProps", "readOnly", "onClear", "clearable", "clearButtonPosition", "openPickerButtonPosition", "openPickerAriaLabel"],
|
|
5
|
+
_excluded3 = ["onPaste", "onKeyDown", "inputMode", "readOnly", "InputProps", "inputProps", "inputRef", "onClear", "clearable", "clearButtonPosition", "openPickerButtonPosition", "openPickerAriaLabel"],
|
|
6
|
+
_excluded4 = ["ownerState"],
|
|
7
|
+
_excluded5 = ["ownerState"],
|
|
8
|
+
_excluded6 = ["ownerState"],
|
|
9
|
+
_excluded7 = ["ownerState"],
|
|
10
|
+
_excluded8 = ["InputProps", "inputProps"];
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
13
|
+
import resolveComponentProps from '@mui/utils/resolveComponentProps';
|
|
14
|
+
import MuiTextField from '@mui/material/TextField';
|
|
15
|
+
import MuiIconButton from '@mui/material/IconButton';
|
|
16
|
+
import MuiInputAdornment from '@mui/material/InputAdornment';
|
|
17
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
18
|
+
import { useFieldOwnerState } from "../hooks/useFieldOwnerState.js";
|
|
19
|
+
import { usePickerTranslations } from "../../hooks/index.js";
|
|
20
|
+
import { ClearIcon as MuiClearIcon } from "../../icons/index.js";
|
|
21
|
+
import { useNullablePickerContext } from "../hooks/useNullablePickerContext.js";
|
|
22
|
+
import { PickersTextField } from "../../PickersTextField/index.js";
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
export const cleanFieldResponse = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
enableAccessibleFieldDOMStructure
|
|
27
|
+
} = _ref,
|
|
28
|
+
fieldResponse = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
29
|
+
if (enableAccessibleFieldDOMStructure) {
|
|
30
|
+
const {
|
|
31
|
+
InputProps,
|
|
32
|
+
readOnly,
|
|
33
|
+
onClear,
|
|
34
|
+
clearable,
|
|
35
|
+
clearButtonPosition,
|
|
36
|
+
openPickerButtonPosition,
|
|
37
|
+
openPickerAriaLabel
|
|
38
|
+
} = fieldResponse,
|
|
39
|
+
other = _objectWithoutPropertiesLoose(fieldResponse, _excluded2);
|
|
40
|
+
return {
|
|
41
|
+
clearable,
|
|
42
|
+
onClear,
|
|
43
|
+
clearButtonPosition,
|
|
44
|
+
openPickerButtonPosition,
|
|
45
|
+
openPickerAriaLabel,
|
|
46
|
+
textFieldProps: _extends({}, other, {
|
|
47
|
+
InputProps: _extends({}, InputProps ?? {}, {
|
|
48
|
+
readOnly
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const {
|
|
54
|
+
onPaste,
|
|
55
|
+
onKeyDown,
|
|
56
|
+
inputMode,
|
|
57
|
+
readOnly,
|
|
58
|
+
InputProps,
|
|
59
|
+
inputProps,
|
|
60
|
+
inputRef,
|
|
61
|
+
onClear,
|
|
62
|
+
clearable,
|
|
63
|
+
clearButtonPosition,
|
|
64
|
+
openPickerButtonPosition,
|
|
65
|
+
openPickerAriaLabel
|
|
66
|
+
} = fieldResponse,
|
|
67
|
+
other = _objectWithoutPropertiesLoose(fieldResponse, _excluded3);
|
|
68
|
+
return {
|
|
69
|
+
clearable,
|
|
70
|
+
onClear,
|
|
71
|
+
clearButtonPosition,
|
|
72
|
+
openPickerButtonPosition,
|
|
73
|
+
openPickerAriaLabel,
|
|
74
|
+
textFieldProps: _extends({}, other, {
|
|
75
|
+
InputProps: _extends({}, InputProps ?? {}, {
|
|
76
|
+
readOnly
|
|
77
|
+
}),
|
|
78
|
+
inputProps: _extends({}, inputProps ?? {}, {
|
|
79
|
+
inputMode,
|
|
80
|
+
onPaste,
|
|
81
|
+
onKeyDown,
|
|
82
|
+
ref: inputRef
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
const PickerFieldUIContext = /*#__PURE__*/React.createContext({
|
|
88
|
+
slots: {},
|
|
89
|
+
slotProps: {}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Adds the button to open the picker and the button to clear the value of the field.
|
|
94
|
+
* @ignore - internal component.
|
|
95
|
+
*/
|
|
96
|
+
export function PickerFieldUI(props) {
|
|
97
|
+
const {
|
|
98
|
+
slots,
|
|
99
|
+
slotProps,
|
|
100
|
+
fieldResponse,
|
|
101
|
+
defaultOpenPickerIcon
|
|
102
|
+
} = props;
|
|
103
|
+
const translations = usePickerTranslations();
|
|
104
|
+
const pickerContext = useNullablePickerContext();
|
|
105
|
+
const pickerFieldUIContext = React.useContext(PickerFieldUIContext);
|
|
106
|
+
const {
|
|
107
|
+
textFieldProps,
|
|
108
|
+
onClear,
|
|
109
|
+
clearable,
|
|
110
|
+
openPickerAriaLabel,
|
|
111
|
+
clearButtonPosition: clearButtonPositionProp = 'end',
|
|
112
|
+
openPickerButtonPosition: openPickerButtonPositionProp = 'end'
|
|
113
|
+
} = cleanFieldResponse(fieldResponse);
|
|
114
|
+
const ownerState = useFieldOwnerState(textFieldProps);
|
|
115
|
+
const handleClickOpeningButton = useEventCallback(event => {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
pickerContext?.setOpen(prev => !prev);
|
|
118
|
+
});
|
|
119
|
+
const triggerStatus = pickerContext ? pickerContext.triggerStatus : 'hidden';
|
|
120
|
+
const clearButtonPosition = clearable ? clearButtonPositionProp : null;
|
|
121
|
+
const openPickerButtonPosition = triggerStatus !== 'hidden' ? openPickerButtonPositionProp : null;
|
|
122
|
+
const TextField = slots?.textField ?? pickerFieldUIContext.slots.textField ?? (fieldResponse.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
|
|
123
|
+
const InputAdornment = slots?.inputAdornment ?? pickerFieldUIContext.slots.inputAdornment ?? MuiInputAdornment;
|
|
124
|
+
const _useSlotProps = useSlotProps({
|
|
125
|
+
elementType: InputAdornment,
|
|
126
|
+
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.inputAdornment, slotProps?.inputAdornment),
|
|
127
|
+
additionalProps: {
|
|
128
|
+
position: 'start'
|
|
129
|
+
},
|
|
130
|
+
ownerState: _extends({}, ownerState, {
|
|
131
|
+
position: 'start'
|
|
132
|
+
})
|
|
133
|
+
}),
|
|
134
|
+
startInputAdornmentProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded4);
|
|
135
|
+
const _useSlotProps2 = useSlotProps({
|
|
136
|
+
elementType: InputAdornment,
|
|
137
|
+
externalSlotProps: slotProps?.inputAdornment,
|
|
138
|
+
additionalProps: {
|
|
139
|
+
position: 'end'
|
|
140
|
+
},
|
|
141
|
+
ownerState: _extends({}, ownerState, {
|
|
142
|
+
position: 'end'
|
|
143
|
+
})
|
|
144
|
+
}),
|
|
145
|
+
endInputAdornmentProps = _objectWithoutPropertiesLoose(_useSlotProps2, _excluded5);
|
|
146
|
+
const OpenPickerButton = pickerFieldUIContext.slots.openPickerButton ?? MuiIconButton;
|
|
147
|
+
// We don't want to forward the `ownerState` to the `<IconButton />` component, see mui/material-ui#34056
|
|
148
|
+
const _useSlotProps3 = useSlotProps({
|
|
149
|
+
elementType: OpenPickerButton,
|
|
150
|
+
externalSlotProps: pickerFieldUIContext.slotProps.openPickerButton,
|
|
151
|
+
additionalProps: {
|
|
152
|
+
disabled: triggerStatus === 'disabled',
|
|
153
|
+
onClick: handleClickOpeningButton,
|
|
154
|
+
'aria-label': openPickerAriaLabel,
|
|
155
|
+
edge: clearButtonPosition === 'start' && openPickerButtonPosition === 'start' ? undefined : openPickerButtonPosition
|
|
156
|
+
},
|
|
157
|
+
ownerState
|
|
158
|
+
}),
|
|
159
|
+
openPickerButtonProps = _objectWithoutPropertiesLoose(_useSlotProps3, _excluded6);
|
|
160
|
+
const OpenPickerIcon = pickerFieldUIContext.slots.openPickerIcon ?? defaultOpenPickerIcon;
|
|
161
|
+
const openPickerIconProps = useSlotProps({
|
|
162
|
+
elementType: OpenPickerIcon,
|
|
163
|
+
externalSlotProps: pickerFieldUIContext.slotProps.openPickerIcon,
|
|
164
|
+
ownerState
|
|
165
|
+
});
|
|
166
|
+
const ClearButton = slots?.clearButton ?? pickerFieldUIContext.slots.clearButton ?? MuiIconButton;
|
|
167
|
+
// We don't want to forward the `ownerState` to the `<IconButton />` component, see mui/material-ui#34056
|
|
168
|
+
const _useSlotProps4 = useSlotProps({
|
|
169
|
+
elementType: ClearButton,
|
|
170
|
+
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.clearButton, slotProps?.clearButton),
|
|
171
|
+
className: 'clearButton',
|
|
172
|
+
additionalProps: {
|
|
173
|
+
title: translations.fieldClearLabel,
|
|
174
|
+
tabIndex: -1,
|
|
175
|
+
onClick: onClear,
|
|
176
|
+
disabled: fieldResponse.disabled || fieldResponse.readOnly,
|
|
177
|
+
edge: clearButtonPosition === 'end' && openPickerButtonPosition === 'end' ? undefined : clearButtonPosition
|
|
178
|
+
},
|
|
179
|
+
ownerState
|
|
180
|
+
}),
|
|
181
|
+
clearButtonProps = _objectWithoutPropertiesLoose(_useSlotProps4, _excluded7);
|
|
182
|
+
const ClearIcon = slots?.clearIcon ?? pickerFieldUIContext.slots.clearIcon ?? MuiClearIcon;
|
|
183
|
+
const clearIconProps = useSlotProps({
|
|
184
|
+
elementType: ClearIcon,
|
|
185
|
+
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.clearIcon, slotProps?.clearIcon),
|
|
186
|
+
additionalProps: {
|
|
187
|
+
fontSize: 'small'
|
|
188
|
+
},
|
|
189
|
+
ownerState
|
|
190
|
+
});
|
|
191
|
+
if (!textFieldProps.InputProps) {
|
|
192
|
+
textFieldProps.InputProps = {};
|
|
193
|
+
}
|
|
194
|
+
if (pickerContext) {
|
|
195
|
+
textFieldProps.InputProps.ref = pickerContext.triggerRef;
|
|
196
|
+
}
|
|
197
|
+
if (!textFieldProps.InputProps?.startAdornment && (clearButtonPosition === 'start' || openPickerButtonPosition === 'start')) {
|
|
198
|
+
textFieldProps.InputProps.startAdornment = /*#__PURE__*/_jsxs(InputAdornment, _extends({}, startInputAdornmentProps, {
|
|
199
|
+
children: [openPickerButtonPosition === 'start' && /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
|
|
200
|
+
children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, openPickerIconProps))
|
|
201
|
+
})), clearButtonPosition === 'start' && /*#__PURE__*/_jsx(ClearButton, _extends({}, clearButtonProps, {
|
|
202
|
+
children: /*#__PURE__*/_jsx(ClearIcon, _extends({}, clearIconProps))
|
|
203
|
+
}))]
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
if (!textFieldProps.InputProps?.endAdornment && (clearButtonPosition === 'end' || openPickerButtonPosition === 'end')) {
|
|
207
|
+
textFieldProps.InputProps.endAdornment = /*#__PURE__*/_jsxs(InputAdornment, _extends({}, endInputAdornmentProps, {
|
|
208
|
+
children: [clearButtonPosition === 'end' && /*#__PURE__*/_jsx(ClearButton, _extends({}, clearButtonProps, {
|
|
209
|
+
children: /*#__PURE__*/_jsx(ClearIcon, _extends({}, clearIconProps))
|
|
210
|
+
})), openPickerButtonPosition === 'end' && /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
|
|
211
|
+
children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, openPickerIconProps))
|
|
212
|
+
}))]
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
if (clearButtonPosition != null) {
|
|
216
|
+
textFieldProps.sx = [{
|
|
217
|
+
'& .clearButton': {
|
|
218
|
+
opacity: 1
|
|
219
|
+
},
|
|
220
|
+
'@media (pointer: fine)': {
|
|
221
|
+
'& .clearButton': {
|
|
222
|
+
opacity: 0
|
|
223
|
+
},
|
|
224
|
+
'&:hover, &:focus-within': {
|
|
225
|
+
'.clearButton': {
|
|
226
|
+
opacity: 1
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}, ...(Array.isArray(textFieldProps.sx) ? textFieldProps.sx : [textFieldProps.sx])];
|
|
231
|
+
}
|
|
232
|
+
return /*#__PURE__*/_jsx(TextField, _extends({}, textFieldProps));
|
|
233
|
+
}
|
|
234
|
+
function mergeSlotProps(slotPropsA, slotPropsB) {
|
|
235
|
+
if (!slotPropsA) {
|
|
236
|
+
return slotPropsB;
|
|
237
|
+
}
|
|
238
|
+
if (!slotPropsB) {
|
|
239
|
+
return slotPropsA;
|
|
240
|
+
}
|
|
241
|
+
return ownerState => {
|
|
242
|
+
return _extends({}, resolveComponentProps(slotPropsB, ownerState), resolveComponentProps(slotPropsA, ownerState));
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The `textField` slot props cannot be handled inside `PickerFieldUI` because it would be a breaking change to not pass the enriched props to `useField`.
|
|
248
|
+
* Once the non-accessible DOM structure will be removed, we will be able to remove the `textField` slot and clean this logic.
|
|
249
|
+
*/
|
|
250
|
+
export function useFieldTextFieldProps(parameters) {
|
|
251
|
+
const {
|
|
252
|
+
ref,
|
|
253
|
+
externalForwardedProps,
|
|
254
|
+
slotProps
|
|
255
|
+
} = parameters;
|
|
256
|
+
const pickerFieldUIContext = React.useContext(PickerFieldUIContext);
|
|
257
|
+
const ownerState = useFieldOwnerState(externalForwardedProps);
|
|
258
|
+
const {
|
|
259
|
+
InputProps,
|
|
260
|
+
inputProps
|
|
261
|
+
} = externalForwardedProps,
|
|
262
|
+
otherExternalForwardedProps = _objectWithoutPropertiesLoose(externalForwardedProps, _excluded8);
|
|
263
|
+
const textFieldProps = useSlotProps({
|
|
264
|
+
elementType: PickersTextField,
|
|
265
|
+
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.textField, slotProps?.textField),
|
|
266
|
+
externalForwardedProps: otherExternalForwardedProps,
|
|
267
|
+
additionalProps: {
|
|
268
|
+
ref
|
|
269
|
+
},
|
|
270
|
+
ownerState
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// TODO: Remove when mui/material-ui#35088 will be merged
|
|
274
|
+
textFieldProps.inputProps = _extends({}, inputProps, textFieldProps.inputProps);
|
|
275
|
+
textFieldProps.InputProps = _extends({}, InputProps, textFieldProps.InputProps);
|
|
276
|
+
return textFieldProps;
|
|
277
|
+
}
|
|
278
|
+
export function PickerFieldUIContextProvider(props) {
|
|
279
|
+
const {
|
|
280
|
+
slots = {},
|
|
281
|
+
slotProps = {},
|
|
282
|
+
children
|
|
283
|
+
} = props;
|
|
284
|
+
const contextValue = React.useMemo(() => ({
|
|
285
|
+
slots: {
|
|
286
|
+
openPickerButton: slots.openPickerButton,
|
|
287
|
+
openPickerIcon: slots.openPickerIcon,
|
|
288
|
+
textField: slots.textField,
|
|
289
|
+
inputAdornment: slots.inputAdornment,
|
|
290
|
+
clearIcon: slots.clearIcon,
|
|
291
|
+
clearButton: slots.clearButton
|
|
292
|
+
},
|
|
293
|
+
slotProps: {
|
|
294
|
+
openPickerButton: slotProps.openPickerButton,
|
|
295
|
+
openPickerIcon: slotProps.openPickerIcon,
|
|
296
|
+
textField: slotProps.textField,
|
|
297
|
+
inputAdornment: slotProps.inputAdornment,
|
|
298
|
+
clearIcon: slotProps.clearIcon,
|
|
299
|
+
clearButton: slotProps.clearButton
|
|
300
|
+
}
|
|
301
|
+
}), [slots.openPickerButton, slots.openPickerIcon, slots.textField, slots.inputAdornment, slots.clearIcon, slots.clearButton, slotProps.openPickerButton, slotProps.openPickerIcon, slotProps.textField, slotProps.inputAdornment, slotProps.clearIcon, slotProps.clearButton]);
|
|
302
|
+
return /*#__PURE__*/_jsx(PickerFieldUIContext.Provider, {
|
|
303
|
+
value: contextValue,
|
|
304
|
+
children: children
|
|
305
|
+
});
|
|
306
|
+
}
|