@mui/x-date-pickers 8.0.0-beta.1 → 8.0.0-beta.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/CHANGELOG.md +94 -0
- package/DateCalendar/DateCalendar.js +4 -8
- package/DateCalendar/DayCalendar.js +2 -2
- package/DatePicker/shared.js +3 -9
- package/DateTimePicker/shared.js +3 -13
- package/MonthCalendar/MonthCalendar.js +4 -9
- package/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/TimePicker/shared.js +3 -3
- package/YearCalendar/YearCalendar.js +4 -10
- package/esm/DateCalendar/DateCalendar.js +6 -10
- package/esm/DateCalendar/DayCalendar.js +2 -2
- package/esm/DatePicker/shared.js +3 -9
- package/esm/DateTimePicker/shared.js +4 -14
- package/esm/MonthCalendar/MonthCalendar.js +6 -11
- package/esm/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/esm/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/esm/TimePicker/shared.js +3 -3
- package/esm/YearCalendar/YearCalendar.js +5 -11
- package/esm/index.js +1 -1
- package/esm/internals/hooks/useField/syncSelectionToDOM.d.ts +9 -0
- package/esm/internals/hooks/useField/syncSelectionToDOM.js +50 -0
- package/esm/internals/hooks/useField/useField.types.d.ts +8 -1
- package/esm/internals/hooks/useField/useField.utils.d.ts +1 -3
- package/esm/internals/hooks/useField/useField.utils.js +0 -57
- package/esm/internals/hooks/useField/useFieldHiddenInputProps.d.ts +20 -0
- package/esm/internals/hooks/useField/useFieldHiddenInputProps.js +31 -0
- package/esm/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +8 -10
- package/esm/internals/hooks/useField/useFieldRootHandleKeyDown.js +1 -0
- package/esm/internals/hooks/useField/useFieldRootProps.d.ts +32 -0
- package/esm/internals/hooks/useField/useFieldRootProps.js +150 -0
- package/esm/internals/hooks/useField/useFieldSectionContainerProps.d.ts +15 -0
- package/esm/internals/hooks/useField/useFieldSectionContainerProps.js +29 -0
- package/esm/internals/hooks/useField/useFieldSectionContentProps.d.ts +23 -0
- package/esm/internals/hooks/useField/useFieldSectionContentProps.js +226 -0
- package/esm/internals/hooks/useField/useFieldV7TextField.js +76 -307
- package/esm/internals/index.d.ts +4 -4
- package/esm/internals/index.js +3 -3
- package/esm/locales/deDE.js +2 -3
- package/esm/managers/useDateManager.d.ts +4 -13
- package/esm/managers/useDateManager.js +18 -28
- package/esm/managers/useDateTimeManager.d.ts +4 -13
- package/esm/managers/useDateTimeManager.js +23 -33
- package/esm/managers/useTimeManager.d.ts +4 -13
- package/esm/managers/useTimeManager.js +14 -24
- package/esm/models/manager.d.ts +3 -8
- package/esm/validation/validateDate.js +3 -4
- package/index.js +1 -1
- package/internals/hooks/useField/syncSelectionToDOM.d.ts +9 -0
- package/internals/hooks/useField/syncSelectionToDOM.js +56 -0
- package/internals/hooks/useField/useField.types.d.ts +8 -1
- package/internals/hooks/useField/useField.utils.d.ts +1 -3
- package/internals/hooks/useField/useField.utils.js +2 -61
- package/internals/hooks/useField/useFieldHiddenInputProps.d.ts +20 -0
- package/internals/hooks/useField/useFieldHiddenInputProps.js +39 -0
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +8 -10
- package/internals/hooks/useField/useFieldRootHandleKeyDown.js +1 -0
- package/internals/hooks/useField/useFieldRootProps.d.ts +32 -0
- package/internals/hooks/useField/useFieldRootProps.js +156 -0
- package/internals/hooks/useField/useFieldSectionContainerProps.d.ts +15 -0
- package/internals/hooks/useField/useFieldSectionContainerProps.js +37 -0
- package/internals/hooks/useField/useFieldSectionContentProps.d.ts +23 -0
- package/internals/hooks/useField/useFieldSectionContentProps.js +234 -0
- package/internals/hooks/useField/useFieldV7TextField.js +75 -306
- package/internals/index.d.ts +4 -4
- package/internals/index.js +18 -18
- package/locales/deDE.js +2 -3
- package/managers/useDateManager.d.ts +4 -13
- package/managers/useDateManager.js +18 -28
- package/managers/useDateTimeManager.d.ts +4 -13
- package/managers/useDateTimeManager.js +23 -33
- package/managers/useTimeManager.d.ts +4 -13
- package/managers/useTimeManager.js +15 -25
- package/models/manager.d.ts +3 -8
- package/modern/DateCalendar/DateCalendar.js +6 -10
- package/modern/DateCalendar/DayCalendar.js +2 -2
- package/modern/DatePicker/shared.js +3 -9
- package/modern/DateTimePicker/shared.js +4 -14
- package/modern/MonthCalendar/MonthCalendar.js +6 -11
- package/modern/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/modern/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/modern/TimePicker/shared.js +3 -3
- package/modern/YearCalendar/YearCalendar.js +5 -11
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useField/syncSelectionToDOM.d.ts +9 -0
- package/modern/internals/hooks/useField/syncSelectionToDOM.js +50 -0
- package/modern/internals/hooks/useField/useField.types.d.ts +8 -1
- package/modern/internals/hooks/useField/useField.utils.d.ts +1 -3
- package/modern/internals/hooks/useField/useField.utils.js +0 -57
- package/modern/internals/hooks/useField/useFieldHiddenInputProps.d.ts +20 -0
- package/modern/internals/hooks/useField/useFieldHiddenInputProps.js +31 -0
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +8 -10
- package/modern/internals/hooks/useField/useFieldRootHandleKeyDown.js +1 -0
- package/modern/internals/hooks/useField/useFieldRootProps.d.ts +32 -0
- package/modern/internals/hooks/useField/useFieldRootProps.js +150 -0
- package/modern/internals/hooks/useField/useFieldSectionContainerProps.d.ts +15 -0
- package/modern/internals/hooks/useField/useFieldSectionContainerProps.js +29 -0
- package/modern/internals/hooks/useField/useFieldSectionContentProps.d.ts +23 -0
- package/modern/internals/hooks/useField/useFieldSectionContentProps.js +226 -0
- package/modern/internals/hooks/useField/useFieldV7TextField.js +76 -307
- package/modern/internals/index.d.ts +4 -4
- package/modern/internals/index.js +3 -3
- package/modern/locales/deDE.js +2 -3
- package/modern/managers/useDateManager.d.ts +4 -13
- package/modern/managers/useDateManager.js +18 -28
- package/modern/managers/useDateTimeManager.d.ts +4 -13
- package/modern/managers/useDateTimeManager.js +23 -33
- package/modern/managers/useTimeManager.d.ts +4 -13
- package/modern/managers/useTimeManager.js +14 -24
- package/modern/models/manager.d.ts +3 -8
- package/modern/validation/validateDate.js +3 -4
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/validation/validateDate.js +3 -4
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import type { MakeOptional } from '@mui/x-internals/types';
|
|
2
2
|
import { PickerManager, DateTimeValidationError } from "../models/index.js";
|
|
3
3
|
import { UseFieldInternalProps } from "../internals/hooks/useField/index.js";
|
|
4
|
-
import { MuiPickersAdapterContextValue } from "../LocalizationProvider/LocalizationProvider.js";
|
|
5
4
|
import { AmPmProps } from "../internals/models/props/time.js";
|
|
6
|
-
import { ExportedValidateDateTimeProps, ValidateDateTimeProps
|
|
7
|
-
import {
|
|
5
|
+
import { ExportedValidateDateTimeProps, ValidateDateTimeProps } from "../validation/validateDateTime.js";
|
|
6
|
+
import { PickerValue } from "../internals/models/index.js";
|
|
8
7
|
export declare function useDateTimeManager<TEnableAccessibleFieldDOMStructure extends boolean = true>(parameters?: UseDateTimeManagerParameters<TEnableAccessibleFieldDOMStructure>): UseDateTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Is used by the `useDateTimeManager` and `useDateTimeRangeManager` hooks.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getDateTimeFieldInternalPropsDefaults(parameters: GetDateTimeFieldInternalPropsDefaultsParameters): GetDateTimeFieldInternalPropsDefaultsReturnValue;
|
|
8
|
+
type SharedDateTimeAndDateTimeRangeValidationProps = 'disablePast' | 'disableFuture' | 'minTime' | 'maxTime' | 'minDate' | 'maxDate';
|
|
9
|
+
export declare function useApplyDefaultValuesToDateTimeValidationProps(props: Pick<ExportedValidateDateTimeProps, SharedDateTimeAndDateTimeRangeValidationProps | 'minDateTime' | 'maxDateTime'>): Pick<ValidateDateTimeProps, SharedDateTimeAndDateTimeRangeValidationProps>;
|
|
14
10
|
export interface UseDateTimeManagerParameters<TEnableAccessibleFieldDOMStructure extends boolean> {
|
|
15
11
|
enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
|
|
16
12
|
}
|
|
17
13
|
export type UseDateTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerValue, TEnableAccessibleFieldDOMStructure, DateTimeValidationError, ValidateDateTimeProps, DateTimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>>;
|
|
18
14
|
export interface DateTimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerValue, TEnableAccessibleFieldDOMStructure, DateTimeValidationError>, 'format'>, ExportedValidateDateTimeProps, AmPmProps {}
|
|
19
|
-
type DateTimeManagerFieldPropsToDefault = 'format' | 'minTime' | 'maxTime' | ValidateDateTimePropsToDefault;
|
|
20
|
-
interface GetDateTimeFieldInternalPropsDefaultsParameters extends Pick<MuiPickersAdapterContextValue, 'defaultDates' | 'utils'> {
|
|
21
|
-
internalProps: Pick<DateTimeManagerFieldInternalProps<true>, DateTimeManagerFieldPropsToDefault | 'minDateTime' | 'maxDateTime' | 'ampm'>;
|
|
22
|
-
}
|
|
23
|
-
interface GetDateTimeFieldInternalPropsDefaultsReturnValue extends Pick<PickerManagerFieldInternalPropsWithDefaults<UseDateTimeManagerReturnValue<true>>, DateTimeManagerFieldPropsToDefault | 'disableIgnoringDatePartForTimeValidation'> {}
|
|
24
15
|
export {};
|
|
@@ -6,7 +6,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.
|
|
9
|
+
exports.useApplyDefaultValuesToDateTimeValidationProps = useApplyDefaultValuesToDateTimeValidationProps;
|
|
10
10
|
exports.useDateTimeManager = useDateTimeManager;
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -25,15 +25,7 @@ function useDateTimeManager(parameters = {}) {
|
|
|
25
25
|
internal_valueManager: _valueManagers.singleItemValueManager,
|
|
26
26
|
internal_fieldValueManager: _valueManagers.singleItemFieldValueManager,
|
|
27
27
|
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
28
|
-
|
|
29
|
-
internalProps,
|
|
30
|
-
utils,
|
|
31
|
-
defaultDates
|
|
32
|
-
}) => (0, _extends2.default)({}, internalProps, getDateTimeFieldInternalPropsDefaults({
|
|
33
|
-
internalProps,
|
|
34
|
-
utils,
|
|
35
|
-
defaultDates
|
|
36
|
-
})),
|
|
28
|
+
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToDateTimeFieldInternalProps,
|
|
37
29
|
internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
|
|
38
30
|
}), [enableAccessibleFieldDOMStructure]);
|
|
39
31
|
}
|
|
@@ -45,27 +37,25 @@ function useOpenPickerButtonAriaLabel(value) {
|
|
|
45
37
|
return translations.openDatePickerDialogue(formattedValue);
|
|
46
38
|
}, [value, translations, utils]);
|
|
47
39
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
maxTime: internalProps.maxDateTime ?? internalProps.maxTime
|
|
70
|
-
};
|
|
40
|
+
function useApplyDefaultValuesToDateTimeFieldInternalProps(internalProps) {
|
|
41
|
+
const utils = (0, _useUtils.useUtils)();
|
|
42
|
+
const validationProps = useApplyDefaultValuesToDateTimeValidationProps(internalProps);
|
|
43
|
+
const ampm = React.useMemo(() => internalProps.ampm ?? utils.is12HourCycleInCurrentLocale(), [internalProps.ampm, utils]);
|
|
44
|
+
return React.useMemo(() => (0, _extends2.default)({}, internalProps, validationProps, {
|
|
45
|
+
format: internalProps.format ?? (ampm ? utils.formats.keyboardDateTime12h : utils.formats.keyboardDateTime24h)
|
|
46
|
+
}), [internalProps, validationProps, ampm, utils]);
|
|
47
|
+
}
|
|
48
|
+
function useApplyDefaultValuesToDateTimeValidationProps(props) {
|
|
49
|
+
const utils = (0, _useUtils.useUtils)();
|
|
50
|
+
const defaultDates = (0, _useUtils.useDefaultDates)();
|
|
51
|
+
return React.useMemo(() => ({
|
|
52
|
+
disablePast: props.disablePast ?? false,
|
|
53
|
+
disableFuture: props.disableFuture ?? false,
|
|
54
|
+
// TODO: Explore if we can remove it from the public API
|
|
55
|
+
disableIgnoringDatePartForTimeValidation: !!props.minDateTime || !!props.maxDateTime || !!props.disableFuture || !!props.disablePast,
|
|
56
|
+
minDate: (0, _dateUtils.applyDefaultDate)(utils, props.minDateTime ?? props.minDate, defaultDates.minDate),
|
|
57
|
+
maxDate: (0, _dateUtils.applyDefaultDate)(utils, props.maxDateTime ?? props.maxDate, defaultDates.maxDate),
|
|
58
|
+
minTime: props.minDateTime ?? props.minTime,
|
|
59
|
+
maxTime: props.maxDateTime ?? props.maxTime
|
|
60
|
+
}), [props.minDateTime, props.maxDateTime, props.minTime, props.maxTime, props.minDate, props.maxDate, props.disableFuture, props.disablePast, utils, defaultDates]);
|
|
71
61
|
}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import type { MakeOptional } from '@mui/x-internals/types';
|
|
2
2
|
import { PickerManager, TimeValidationError } from "../models/index.js";
|
|
3
3
|
import { UseFieldInternalProps } from "../internals/hooks/useField/index.js";
|
|
4
|
-
import { MuiPickersAdapterContextValue } from "../LocalizationProvider/LocalizationProvider.js";
|
|
5
4
|
import { AmPmProps } from "../internals/models/props/time.js";
|
|
6
|
-
import { ExportedValidateTimeProps, ValidateTimeProps
|
|
7
|
-
import {
|
|
5
|
+
import { ExportedValidateTimeProps, ValidateTimeProps } from "../validation/validateTime.js";
|
|
6
|
+
import { PickerValue } from "../internals/models/index.js";
|
|
8
7
|
export declare function useTimeManager<TEnableAccessibleFieldDOMStructure extends boolean = true>(parameters?: UseTimeManagerParameters<TEnableAccessibleFieldDOMStructure>): UseTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Is used by the `useTimeManager` and `useTimeRangeManager` hooks.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getTimeFieldInternalPropsDefaults(parameters: GetTimeFieldInternalPropsDefaultsParameters): GetTimeFieldInternalPropsDefaultsReturnValue;
|
|
8
|
+
type SharedTimeAndTimeRangeValidationProps = 'disablePast' | 'disableFuture';
|
|
9
|
+
export declare function useApplyDefaultValuesToTimeValidationProps(props: Pick<ExportedValidateTimeProps, SharedTimeAndTimeRangeValidationProps>): Pick<ValidateTimeProps, SharedTimeAndTimeRangeValidationProps>;
|
|
14
10
|
export interface UseTimeManagerParameters<TEnableAccessibleFieldDOMStructure extends boolean> extends AmPmProps {
|
|
15
11
|
enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
|
|
16
12
|
}
|
|
17
13
|
export type UseTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerValue, TEnableAccessibleFieldDOMStructure, TimeValidationError, ValidateTimeProps, TimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>>;
|
|
18
14
|
export interface TimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerValue, TEnableAccessibleFieldDOMStructure, TimeValidationError>, 'format'>, ExportedValidateTimeProps, AmPmProps {}
|
|
19
|
-
type TimeManagerFieldPropsToDefault = 'format' | ValidateTimePropsToDefault;
|
|
20
|
-
interface GetTimeFieldInternalPropsDefaultsParameters extends Pick<MuiPickersAdapterContextValue, 'utils'> {
|
|
21
|
-
internalProps: Pick<TimeManagerFieldInternalProps<true>, TimeManagerFieldPropsToDefault | 'ampm'>;
|
|
22
|
-
}
|
|
23
|
-
interface GetTimeFieldInternalPropsDefaultsReturnValue extends Pick<PickerManagerFieldInternalPropsWithDefaults<UseTimeManagerReturnValue<true>>, TimeManagerFieldPropsToDefault> {}
|
|
24
15
|
export {};
|
|
@@ -6,7 +6,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.
|
|
9
|
+
exports.useApplyDefaultValuesToTimeValidationProps = useApplyDefaultValuesToTimeValidationProps;
|
|
10
10
|
exports.useTimeManager = useTimeManager;
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -25,13 +25,7 @@ function useTimeManager(parameters = {}) {
|
|
|
25
25
|
internal_valueManager: _valueManagers.singleItemValueManager,
|
|
26
26
|
internal_fieldValueManager: _valueManagers.singleItemFieldValueManager,
|
|
27
27
|
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
28
|
-
|
|
29
|
-
internalProps,
|
|
30
|
-
utils
|
|
31
|
-
}) => (0, _extends2.default)({}, internalProps, getTimeFieldInternalPropsDefaults({
|
|
32
|
-
utils,
|
|
33
|
-
internalProps
|
|
34
|
-
})),
|
|
28
|
+
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToTimeFieldInternalProps,
|
|
35
29
|
internal_useOpenPickerButtonAriaLabel: createUseOpenPickerButtonAriaLabel(ampm)
|
|
36
30
|
}), [ampm, enableAccessibleFieldDOMStructure]);
|
|
37
31
|
}
|
|
@@ -46,21 +40,17 @@ function createUseOpenPickerButtonAriaLabel(ampm) {
|
|
|
46
40
|
}, [value, translations, utils]);
|
|
47
41
|
};
|
|
48
42
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
disablePast: internalProps.disablePast ?? false,
|
|
63
|
-
disableFuture: internalProps.disableFuture ?? false,
|
|
64
|
-
format: internalProps.format ?? defaultFormat
|
|
65
|
-
};
|
|
43
|
+
function useApplyDefaultValuesToTimeFieldInternalProps(internalProps) {
|
|
44
|
+
const utils = (0, _useUtils.useUtils)();
|
|
45
|
+
const validationProps = useApplyDefaultValuesToTimeValidationProps(internalProps);
|
|
46
|
+
const ampm = React.useMemo(() => internalProps.ampm ?? utils.is12HourCycleInCurrentLocale(), [internalProps.ampm, utils]);
|
|
47
|
+
return React.useMemo(() => (0, _extends2.default)({}, internalProps, validationProps, {
|
|
48
|
+
format: internalProps.format ?? (ampm ? utils.formats.fullTime12h : utils.formats.fullTime24h)
|
|
49
|
+
}), [internalProps, validationProps, ampm, utils]);
|
|
50
|
+
}
|
|
51
|
+
function useApplyDefaultValuesToTimeValidationProps(props) {
|
|
52
|
+
return React.useMemo(() => ({
|
|
53
|
+
disablePast: props.disablePast ?? false,
|
|
54
|
+
disableFuture: props.disableFuture ?? false
|
|
55
|
+
}), [props.disablePast, props.disableFuture]);
|
|
66
56
|
}
|
package/models/manager.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { FieldValueManager, UseFieldInternalProps } from '../internals/hooks/useField';
|
|
2
|
-
import type { UseLocalizationContextReturnValue } from '../internals/hooks/useUtils';
|
|
3
2
|
import type { PickerValidValue, PickerValueManager } from '../internals/models';
|
|
4
3
|
import type { Validator } from '../validation';
|
|
5
4
|
import type { PickerValueType } from './common';
|
|
@@ -66,18 +65,14 @@ export interface PickerManager<TValue extends PickerValidValue, TEnableAccessibl
|
|
|
66
65
|
* - a default format to display the value in the field
|
|
67
66
|
* - some default validation props that are needed to validate the value (e.g: minDate, maxDate)
|
|
68
67
|
* This property is not part of the public API and should not be used directly.
|
|
69
|
-
* @param {
|
|
68
|
+
* @param {TFieldInternalProps<TFieldInternalProps>} internalProps The field internal props to apply the defaults to.
|
|
70
69
|
* @returns {TFieldInternalPropsWithDefaults} The field internal props with the defaults applied.
|
|
71
70
|
*/
|
|
72
|
-
|
|
71
|
+
internal_useApplyDefaultValuesToFieldInternalProps: (internalProps: TFieldInternalProps) => UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, TError> & TValidationProps;
|
|
73
72
|
/**
|
|
74
73
|
* Returns a hook that creates the aria-label to apply on the button that opens the Picker.
|
|
75
74
|
* @param {TValue} value The value of the Picker.
|
|
76
75
|
* @returns {string} The aria-label to apply on the button that opens the Picker.
|
|
77
76
|
*/
|
|
78
77
|
internal_useOpenPickerButtonAriaLabel: (value: TValue) => string;
|
|
79
|
-
}
|
|
80
|
-
interface ApplyDefaultsToFieldInternalPropsParameters<TFieldInternalProps extends {}> extends UseLocalizationContextReturnValue {
|
|
81
|
-
internalProps: TFieldInternalProps;
|
|
82
|
-
}
|
|
83
|
-
export {};
|
|
78
|
+
}
|
|
@@ -10,14 +10,14 @@ import useSlotProps from '@mui/utils/useSlotProps';
|
|
|
10
10
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
11
11
|
import { unstable_composeClasses as composeClasses, unstable_useId as useId, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
12
12
|
import { useCalendarState } from "./useCalendarState.js";
|
|
13
|
-
import {
|
|
13
|
+
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
14
14
|
import { PickersFadeTransitionGroup } from "./PickersFadeTransitionGroup.js";
|
|
15
15
|
import { DayCalendar } from "./DayCalendar.js";
|
|
16
16
|
import { MonthCalendar } from "../MonthCalendar/index.js";
|
|
17
17
|
import { YearCalendar } from "../YearCalendar/index.js";
|
|
18
18
|
import { useViews } from "../internals/hooks/useViews.js";
|
|
19
19
|
import { PickersCalendarHeader } from "../PickersCalendarHeader/index.js";
|
|
20
|
-
import { findClosestEnabledDate,
|
|
20
|
+
import { findClosestEnabledDate, mergeDateAndTime } from "../internals/utils/date-utils.js";
|
|
21
21
|
import { PickerViewRoot } from "../internals/components/PickerViewRoot/index.js";
|
|
22
22
|
import { useReduceAnimations } from "../internals/hooks/useReduceAnimations.js";
|
|
23
23
|
import { getDateCalendarUtilityClass } from "./dateCalendarClasses.js";
|
|
@@ -25,6 +25,7 @@ import { useControlledValue } from "../internals/hooks/useControlledValue.js";
|
|
|
25
25
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
26
26
|
import { VIEW_HEIGHT } from "../internals/constants/dimensions.js";
|
|
27
27
|
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
28
|
+
import { useApplyDefaultValuesToDateValidationProps } from "../managers/useDateManager.js";
|
|
28
29
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
30
|
const useUtilityClasses = classes => {
|
|
30
31
|
const slots = {
|
|
@@ -34,25 +35,20 @@ const useUtilityClasses = classes => {
|
|
|
34
35
|
return composeClasses(slots, getDateCalendarUtilityClass, classes);
|
|
35
36
|
};
|
|
36
37
|
function useDateCalendarDefaultizedProps(props, name) {
|
|
37
|
-
const utils = useUtils();
|
|
38
|
-
const defaultDates = useDefaultDates();
|
|
39
38
|
const themeProps = useThemeProps({
|
|
40
39
|
props,
|
|
41
40
|
name
|
|
42
41
|
});
|
|
43
42
|
const reduceAnimations = useReduceAnimations(themeProps.reduceAnimations);
|
|
44
|
-
|
|
43
|
+
const validationProps = useApplyDefaultValuesToDateValidationProps(themeProps);
|
|
44
|
+
return _extends({}, themeProps, validationProps, {
|
|
45
45
|
loading: themeProps.loading ?? false,
|
|
46
|
-
disablePast: themeProps.disablePast ?? false,
|
|
47
|
-
disableFuture: themeProps.disableFuture ?? false,
|
|
48
46
|
openTo: themeProps.openTo ?? 'day',
|
|
49
47
|
views: themeProps.views ?? ['year', 'day'],
|
|
50
48
|
reduceAnimations,
|
|
51
49
|
renderLoading: themeProps.renderLoading ?? (() => /*#__PURE__*/_jsx("span", {
|
|
52
50
|
children: "..."
|
|
53
|
-
}))
|
|
54
|
-
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
55
|
-
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate)
|
|
51
|
+
}))
|
|
56
52
|
});
|
|
57
53
|
}
|
|
58
54
|
const DateCalendarRoot = styled(PickerViewRoot, {
|
|
@@ -81,7 +81,7 @@ const PickersCalendarWeekNumberLabel = styled(Typography, {
|
|
|
81
81
|
display: 'flex',
|
|
82
82
|
justifyContent: 'center',
|
|
83
83
|
alignItems: 'center',
|
|
84
|
-
color: theme.palette.text.disabled
|
|
84
|
+
color: (theme.vars || theme).palette.text.disabled
|
|
85
85
|
}));
|
|
86
86
|
const PickersCalendarWeekNumber = styled(Typography, {
|
|
87
87
|
name: 'MuiDayCalendar',
|
|
@@ -94,7 +94,7 @@ const PickersCalendarWeekNumber = styled(Typography, {
|
|
|
94
94
|
height: DAY_SIZE,
|
|
95
95
|
padding: 0,
|
|
96
96
|
margin: `0 ${DAY_MARGIN}px`,
|
|
97
|
-
color: theme.palette.text.disabled,
|
|
97
|
+
color: (theme.vars || theme).palette.text.disabled,
|
|
98
98
|
fontSize: '0.75rem',
|
|
99
99
|
alignItems: 'center',
|
|
100
100
|
justifyContent: 'center',
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useThemeProps } from '@mui/material/styles';
|
|
4
|
-
import { useDefaultDates, useUtils } from "../internals/hooks/useUtils.js";
|
|
5
4
|
import { applyDefaultViewProps } from "../internals/utils/views.js";
|
|
6
|
-
import { applyDefaultDate } from "../internals/utils/date-utils.js";
|
|
7
5
|
import { DatePickerToolbar } from "./DatePickerToolbar.js";
|
|
6
|
+
import { useApplyDefaultValuesToDateValidationProps } from "../managers/useDateManager.js";
|
|
8
7
|
export function useDatePickerDefaultizedProps(props, name) {
|
|
9
|
-
const utils = useUtils();
|
|
10
|
-
const defaultDates = useDefaultDates();
|
|
11
8
|
const themeProps = useThemeProps({
|
|
12
9
|
props,
|
|
13
10
|
name
|
|
14
11
|
});
|
|
12
|
+
const validationProps = useApplyDefaultValuesToDateValidationProps(themeProps);
|
|
15
13
|
const localeText = React.useMemo(() => {
|
|
16
14
|
if (themeProps.localeText?.toolbarTitle == null) {
|
|
17
15
|
return themeProps.localeText;
|
|
@@ -20,7 +18,7 @@ export function useDatePickerDefaultizedProps(props, name) {
|
|
|
20
18
|
datePickerToolbarTitle: themeProps.localeText.toolbarTitle
|
|
21
19
|
});
|
|
22
20
|
}, [themeProps.localeText]);
|
|
23
|
-
return _extends({}, themeProps, {
|
|
21
|
+
return _extends({}, themeProps, validationProps, {
|
|
24
22
|
localeText
|
|
25
23
|
}, applyDefaultViewProps({
|
|
26
24
|
views: themeProps.views,
|
|
@@ -28,10 +26,6 @@ export function useDatePickerDefaultizedProps(props, name) {
|
|
|
28
26
|
defaultViews: ['year', 'day'],
|
|
29
27
|
defaultOpenTo: 'day'
|
|
30
28
|
}), {
|
|
31
|
-
disableFuture: themeProps.disableFuture ?? false,
|
|
32
|
-
disablePast: themeProps.disablePast ?? false,
|
|
33
|
-
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
34
|
-
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate),
|
|
35
29
|
slots: _extends({
|
|
36
30
|
toolbar: DatePickerToolbar
|
|
37
31
|
}, themeProps.slots)
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useThemeProps } from '@mui/material/styles';
|
|
4
|
-
import {
|
|
5
|
-
import { applyDefaultDate } from "../internals/utils/date-utils.js";
|
|
4
|
+
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
6
5
|
import { DateTimePickerTabs } from "./DateTimePickerTabs.js";
|
|
7
6
|
import { DateTimePickerToolbar } from "./DateTimePickerToolbar.js";
|
|
8
7
|
import { applyDefaultViewProps } from "../internals/utils/views.js";
|
|
9
8
|
import { resolveTimeViewsResponse } from "../internals/utils/date-time-utils.js";
|
|
9
|
+
import { useApplyDefaultValuesToDateTimeValidationProps } from "../managers/useDateTimeManager.js";
|
|
10
10
|
export function useDateTimePickerDefaultizedProps(props, name) {
|
|
11
11
|
const utils = useUtils();
|
|
12
|
-
const defaultDates = useDefaultDates();
|
|
13
12
|
const themeProps = useThemeProps({
|
|
14
13
|
props,
|
|
15
14
|
name
|
|
16
15
|
});
|
|
16
|
+
const validationProps = useApplyDefaultValuesToDateTimeValidationProps(themeProps);
|
|
17
17
|
const ampm = themeProps.ampm ?? utils.is12HourCycleInCurrentLocale();
|
|
18
18
|
const localeText = React.useMemo(() => {
|
|
19
19
|
if (themeProps.localeText?.toolbarTitle == null) {
|
|
@@ -43,7 +43,7 @@ export function useDateTimePickerDefaultizedProps(props, name) {
|
|
|
43
43
|
timeSteps: themeProps.timeSteps,
|
|
44
44
|
views: defaultViews
|
|
45
45
|
});
|
|
46
|
-
return _extends({}, themeProps, {
|
|
46
|
+
return _extends({}, themeProps, validationProps, {
|
|
47
47
|
timeSteps,
|
|
48
48
|
openTo,
|
|
49
49
|
shouldRenderTimeInASingleColumn,
|
|
@@ -52,16 +52,6 @@ export function useDateTimePickerDefaultizedProps(props, name) {
|
|
|
52
52
|
ampm,
|
|
53
53
|
localeText,
|
|
54
54
|
orientation: themeProps.orientation ?? 'portrait',
|
|
55
|
-
// TODO: Remove from public API
|
|
56
|
-
disableIgnoringDatePartForTimeValidation: themeProps.disableIgnoringDatePartForTimeValidation ?? Boolean(themeProps.minDateTime || themeProps.maxDateTime ||
|
|
57
|
-
// allow time clock to correctly check time validity: https://github.com/mui/mui-x/issues/8520
|
|
58
|
-
themeProps.disablePast || themeProps.disableFuture),
|
|
59
|
-
disableFuture: themeProps.disableFuture ?? false,
|
|
60
|
-
disablePast: themeProps.disablePast ?? false,
|
|
61
|
-
minDate: applyDefaultDate(utils, themeProps.minDateTime ?? themeProps.minDate, defaultDates.minDate),
|
|
62
|
-
maxDate: applyDefaultDate(utils, themeProps.maxDateTime ?? themeProps.maxDate, defaultDates.maxDate),
|
|
63
|
-
minTime: themeProps.minDateTime ?? themeProps.minTime,
|
|
64
|
-
maxTime: themeProps.maxDateTime ?? themeProps.maxTime,
|
|
65
55
|
slots: _extends({
|
|
66
56
|
toolbar: DateTimePickerToolbar,
|
|
67
57
|
tabs: DateTimePickerTabs
|
|
@@ -11,14 +11,15 @@ import { shouldForwardProp } from '@mui/system/createStyled';
|
|
|
11
11
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
12
12
|
import { unstable_useControlled as useControlled, unstable_composeClasses as composeClasses, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
13
13
|
import { MonthCalendarButton } from "./MonthCalendarButton.js";
|
|
14
|
-
import { useUtils, useNow
|
|
14
|
+
import { useUtils, useNow } from "../internals/hooks/useUtils.js";
|
|
15
15
|
import { getMonthCalendarUtilityClass } from "./monthCalendarClasses.js";
|
|
16
|
-
import {
|
|
16
|
+
import { getMonthsInYear } from "../internals/utils/date-utils.js";
|
|
17
17
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
18
18
|
import { SECTION_TYPE_GRANULARITY } from "../internals/utils/getDefaultReferenceDate.js";
|
|
19
19
|
import { useControlledValue } from "../internals/hooks/useControlledValue.js";
|
|
20
20
|
import { DIALOG_WIDTH } from "../internals/constants/dimensions.js";
|
|
21
21
|
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
22
|
+
import { useApplyDefaultValuesToDateValidationProps } from "../managers/useDateManager.js";
|
|
22
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
24
|
const useUtilityClasses = classes => {
|
|
24
25
|
const slots = {
|
|
@@ -27,19 +28,13 @@ const useUtilityClasses = classes => {
|
|
|
27
28
|
return composeClasses(slots, getMonthCalendarUtilityClass, classes);
|
|
28
29
|
};
|
|
29
30
|
export function useMonthCalendarDefaultizedProps(props, name) {
|
|
30
|
-
const utils = useUtils();
|
|
31
|
-
const defaultDates = useDefaultDates();
|
|
32
31
|
const themeProps = useThemeProps({
|
|
33
32
|
props,
|
|
34
33
|
name
|
|
35
34
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}, themeProps, {
|
|
40
|
-
monthsPerRow: themeProps.monthsPerRow ?? 3,
|
|
41
|
-
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
42
|
-
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate)
|
|
35
|
+
const validationProps = useApplyDefaultValuesToDateValidationProps(themeProps);
|
|
36
|
+
return _extends({}, themeProps, validationProps, {
|
|
37
|
+
monthsPerRow: themeProps.monthsPerRow ?? 3
|
|
43
38
|
});
|
|
44
39
|
}
|
|
45
40
|
const MonthCalendarRoot = styled('div', {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { PickersSectionListProps } from
|
|
2
|
+
import type { PickersSectionListProps } from './PickersSectionList.types';
|
|
3
3
|
export declare const PickersSectionListRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
4
4
|
export declare const PickersSectionListSection: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, keyof React.ClassAttributes<HTMLSpanElement> | keyof React.HTMLAttributes<HTMLSpanElement>>, {}>;
|
|
5
5
|
export declare const PickersSectionListSectionSeparator: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, keyof React.ClassAttributes<HTMLSpanElement> | keyof React.HTMLAttributes<HTMLSpanElement>>, {}>;
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { SlotComponentProps } from '@mui/utils';
|
|
3
3
|
import { PickersSectionListClasses } from "./pickersSectionListClasses.js";
|
|
4
4
|
import { PickerOwnerState } from "../models/index.js";
|
|
5
|
+
import type { UseFieldDOMGetters } from '../internals/hooks/useField/useField.types';
|
|
5
6
|
export interface PickersSectionListSlots {
|
|
6
7
|
root: React.ElementType;
|
|
7
8
|
section: React.ElementType;
|
|
@@ -28,12 +29,7 @@ export interface PickersSectionElement {
|
|
|
28
29
|
before: React.HTMLAttributes<HTMLSpanElement>;
|
|
29
30
|
after: React.HTMLAttributes<HTMLSpanElement>;
|
|
30
31
|
}
|
|
31
|
-
export interface PickersSectionListRef {
|
|
32
|
-
getRoot: () => HTMLElement;
|
|
33
|
-
getSectionContainer: (sectionIndex: number) => HTMLElement;
|
|
34
|
-
getSectionContent: (sectionIndex: number) => HTMLElement;
|
|
35
|
-
getSectionIndexFromDOMElement: (element: Element | null | undefined) => number | null;
|
|
36
|
-
}
|
|
32
|
+
export interface PickersSectionListRef extends Omit<UseFieldDOMGetters, 'isReady'> {}
|
|
37
33
|
export interface ExportedPickersSectionListProps extends Pick<React.HTMLAttributes<HTMLDivElement>, 'tabIndex'> {
|
|
38
34
|
/**
|
|
39
35
|
* The elements to render.
|
|
@@ -4,12 +4,14 @@ import { useThemeProps } from '@mui/material/styles';
|
|
|
4
4
|
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
5
5
|
import { TimePickerToolbar } from "./TimePickerToolbar.js";
|
|
6
6
|
import { applyDefaultViewProps } from "../internals/utils/views.js";
|
|
7
|
+
import { useApplyDefaultValuesToTimeValidationProps } from "../managers/useTimeManager.js";
|
|
7
8
|
export function useTimePickerDefaultizedProps(props, name) {
|
|
8
9
|
const utils = useUtils();
|
|
9
10
|
const themeProps = useThemeProps({
|
|
10
11
|
props,
|
|
11
12
|
name
|
|
12
13
|
});
|
|
14
|
+
const validationProps = useApplyDefaultValuesToTimeValidationProps(themeProps);
|
|
13
15
|
const ampm = themeProps.ampm ?? utils.is12HourCycleInCurrentLocale();
|
|
14
16
|
const localeText = React.useMemo(() => {
|
|
15
17
|
if (themeProps.localeText?.toolbarTitle == null) {
|
|
@@ -19,7 +21,7 @@ export function useTimePickerDefaultizedProps(props, name) {
|
|
|
19
21
|
timePickerToolbarTitle: themeProps.localeText.toolbarTitle
|
|
20
22
|
});
|
|
21
23
|
}, [themeProps.localeText]);
|
|
22
|
-
return _extends({}, themeProps, {
|
|
24
|
+
return _extends({}, themeProps, validationProps, {
|
|
23
25
|
ampm,
|
|
24
26
|
localeText
|
|
25
27
|
}, applyDefaultViewProps({
|
|
@@ -28,8 +30,6 @@ export function useTimePickerDefaultizedProps(props, name) {
|
|
|
28
30
|
defaultViews: ['hours', 'minutes'],
|
|
29
31
|
defaultOpenTo: 'hours'
|
|
30
32
|
}), {
|
|
31
|
-
disableFuture: themeProps.disableFuture ?? false,
|
|
32
|
-
disablePast: themeProps.disablePast ?? false,
|
|
33
33
|
slots: _extends({
|
|
34
34
|
toolbar: TimePickerToolbar
|
|
35
35
|
}, themeProps.slots),
|
|
@@ -11,14 +11,14 @@ import { shouldForwardProp } from '@mui/system/createStyled';
|
|
|
11
11
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
12
12
|
import { unstable_useForkRef as useForkRef, unstable_composeClasses as composeClasses, unstable_useControlled as useControlled, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
13
13
|
import { YearCalendarButton } from "./YearCalendarButton.js";
|
|
14
|
-
import { useUtils, useNow
|
|
14
|
+
import { useUtils, useNow } from "../internals/hooks/useUtils.js";
|
|
15
15
|
import { getYearCalendarUtilityClass } from "./yearCalendarClasses.js";
|
|
16
|
-
import { applyDefaultDate } from "../internals/utils/date-utils.js";
|
|
17
16
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
18
17
|
import { SECTION_TYPE_GRANULARITY } from "../internals/utils/getDefaultReferenceDate.js";
|
|
19
18
|
import { useControlledValue } from "../internals/hooks/useControlledValue.js";
|
|
20
19
|
import { DIALOG_WIDTH, MAX_CALENDAR_HEIGHT } from "../internals/constants/dimensions.js";
|
|
21
20
|
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
21
|
+
import { useApplyDefaultValuesToDateValidationProps } from "../managers/useDateManager.js";
|
|
22
22
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
23
|
const useUtilityClasses = classes => {
|
|
24
24
|
const slots = {
|
|
@@ -27,20 +27,14 @@ const useUtilityClasses = classes => {
|
|
|
27
27
|
return composeClasses(slots, getYearCalendarUtilityClass, classes);
|
|
28
28
|
};
|
|
29
29
|
function useYearCalendarDefaultizedProps(props, name) {
|
|
30
|
-
const utils = useUtils();
|
|
31
|
-
const defaultDates = useDefaultDates();
|
|
32
30
|
const themeProps = useThemeProps({
|
|
33
31
|
props,
|
|
34
32
|
name
|
|
35
33
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
disableFuture: false
|
|
39
|
-
}, themeProps, {
|
|
34
|
+
const validationProps = useApplyDefaultValuesToDateValidationProps(themeProps);
|
|
35
|
+
return _extends({}, themeProps, validationProps, {
|
|
40
36
|
yearsPerRow: themeProps.yearsPerRow ?? 3,
|
|
41
|
-
yearsOrder: themeProps.yearsOrder ?? 'asc'
|
|
42
|
-
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
43
|
-
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate)
|
|
37
|
+
yearsOrder: themeProps.yearsOrder ?? 'asc'
|
|
44
38
|
});
|
|
45
39
|
}
|
|
46
40
|
const YearCalendarRoot = styled('div', {
|
package/modern/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PickerValidValue } from "../../models/index.js";
|
|
2
|
+
import { UseFieldDOMGetters } from "./useField.types.js";
|
|
3
|
+
import { UseFieldStateReturnValue } from "./useFieldState.js";
|
|
4
|
+
export declare function syncSelectionToDOM<TValue extends PickerValidValue>(parameters: SyncSelectionToDOMParameters<TValue>): void;
|
|
5
|
+
export interface SyncSelectionToDOMParameters<TValue extends PickerValidValue> {
|
|
6
|
+
domGetters: UseFieldDOMGetters;
|
|
7
|
+
stateResponse: UseFieldStateReturnValue<TValue>;
|
|
8
|
+
focused: boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getActiveElement } from "../../utils/utils.js";
|
|
2
|
+
export function syncSelectionToDOM(parameters) {
|
|
3
|
+
const {
|
|
4
|
+
focused,
|
|
5
|
+
domGetters,
|
|
6
|
+
stateResponse: {
|
|
7
|
+
// States and derived states
|
|
8
|
+
parsedSelectedSections,
|
|
9
|
+
state
|
|
10
|
+
}
|
|
11
|
+
} = parameters;
|
|
12
|
+
if (!domGetters.isReady()) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const selection = document.getSelection();
|
|
16
|
+
if (!selection) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (parsedSelectedSections == null) {
|
|
20
|
+
// If the selection contains an element inside the field, we reset it.
|
|
21
|
+
if (selection.rangeCount > 0 && domGetters.getRoot().contains(selection.getRangeAt(0).startContainer)) {
|
|
22
|
+
selection.removeAllRanges();
|
|
23
|
+
}
|
|
24
|
+
if (focused) {
|
|
25
|
+
domGetters.getRoot().blur();
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// On multi input range pickers we want to update selection range only for the active input
|
|
31
|
+
if (!domGetters.getRoot().contains(getActiveElement(document))) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const range = new window.Range();
|
|
35
|
+
let target;
|
|
36
|
+
if (parsedSelectedSections === 'all') {
|
|
37
|
+
target = domGetters.getRoot();
|
|
38
|
+
} else {
|
|
39
|
+
const section = state.sections[parsedSelectedSections];
|
|
40
|
+
if (section.type === 'empty') {
|
|
41
|
+
target = domGetters.getSectionContainer(parsedSelectedSections);
|
|
42
|
+
} else {
|
|
43
|
+
target = domGetters.getSectionContent(parsedSelectedSections);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
range.selectNodeContents(target);
|
|
47
|
+
target.focus();
|
|
48
|
+
selection.removeAllRanges();
|
|
49
|
+
selection.addRange(range);
|
|
50
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, PickerValidDate, FieldRef, OnErrorProps, InferFieldSection, PickerManager, PickerValueType } from "../../../models/index.js";
|
|
3
3
|
import { InternalPropNames } from "../../../hooks/useSplitFieldProps.js";
|
|
4
|
-
import { PickersSectionElement, PickersSectionListRef } from
|
|
4
|
+
import type { PickersSectionElement, PickersSectionListRef } from '../../../PickersSectionList';
|
|
5
5
|
import { FormProps, InferNonNullablePickerValue, PickerValidValue } from "../../models/index.js";
|
|
6
6
|
export interface UseFieldParameters<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError, TValidationProps extends {}, TProps extends UseFieldProps<TEnableAccessibleFieldDOMStructure>> {
|
|
7
7
|
manager: PickerManager<TValue, TEnableAccessibleFieldDOMStructure, TError, TValidationProps, any>;
|
|
@@ -319,4 +319,11 @@ export interface CharacterEditingQuery {
|
|
|
319
319
|
export type UseFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> = UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure> & {
|
|
320
320
|
enableAccessibleFieldDOMStructure?: boolean;
|
|
321
321
|
};
|
|
322
|
+
export interface UseFieldDOMGetters {
|
|
323
|
+
isReady: () => boolean;
|
|
324
|
+
getRoot: () => HTMLElement;
|
|
325
|
+
getSectionContainer: (sectionIndex: number) => HTMLElement;
|
|
326
|
+
getSectionContent: (sectionIndex: number) => HTMLElement;
|
|
327
|
+
getSectionIndexFromDOMElement: (element: Element | null | undefined) => number | null;
|
|
328
|
+
}
|
|
322
329
|
export {};
|