@mui/x-date-pickers 9.0.0 → 9.0.3
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/AdapterDateFnsBase/AdapterDateFnsBase.js +14 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.mjs +14 -0
- package/AdapterDayjs/AdapterDayjs.js +1 -13
- package/AdapterDayjs/AdapterDayjs.mjs +1 -13
- package/AdapterMoment/AdapterMoment.js +6 -0
- package/AdapterMoment/AdapterMoment.mjs +6 -0
- package/CHANGELOG.md +351 -6891
- package/PickersLayout/PickersLayout.js +12 -7
- package/PickersLayout/PickersLayout.mjs +12 -7
- package/PickersLayout/PickersLayout.types.d.mts +1 -1
- package/PickersLayout/PickersLayout.types.d.ts +1 -1
- package/PickersTextField/PickersFilledInput/PickersFilledInput.js +2 -2
- package/PickersTextField/PickersFilledInput/PickersFilledInput.mjs +2 -2
- package/PickersTextField/PickersInput/PickersInput.js +2 -2
- package/PickersTextField/PickersInput/PickersInput.mjs +2 -2
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +3 -3
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.mjs +3 -3
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/components/PickerFieldUI.d.mts +1 -2
- package/internals/components/PickerFieldUI.d.ts +1 -2
- package/internals/components/PickerFieldUI.js +1 -2
- package/internals/components/PickerFieldUI.mjs +1 -2
- package/internals/components/PickerPopper/PickerPopper.js +1 -1
- package/internals/components/PickerPopper/PickerPopper.mjs +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/internals/hooks/useDesktopPicker/useDesktopPicker.mjs +2 -0
- package/internals/hooks/useField/useField.js +15 -2
- package/internals/hooks/useField/useField.mjs +15 -2
- package/internals/hooks/useField/useField.utils.js +25 -11
- package/internals/hooks/useField/useField.utils.mjs +25 -11
- package/internals/hooks/useField/useFieldRootProps.js +1 -1
- package/internals/hooks/useField/useFieldRootProps.mjs +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.mjs +2 -0
- package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.mjs +2 -2
- package/internals/index.d.mts +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +6 -0
- package/internals/index.mjs +1 -1
- package/internals/utils/utils.d.mts +6 -0
- package/internals/utils/utils.d.ts +6 -0
- package/internals/utils/utils.js +18 -1
- package/internals/utils/utils.mjs +15 -0
- package/package.json +2 -2
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
9
|
exports.PickersLayoutRoot = exports.PickersLayoutContentWrapper = exports.PickersLayout = void 0;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
12
|
var React = _interopRequireWildcard(require("react"));
|
|
11
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
14
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
@@ -16,6 +18,7 @@ var _pickersLayoutClasses = require("./pickersLayoutClasses");
|
|
|
16
18
|
var _usePickerLayout = _interopRequireDefault(require("./usePickerLayout"));
|
|
17
19
|
var _usePickerContext = require("../hooks/usePickerContext");
|
|
18
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
const _excluded = ["sx", "className", "classes", "children", "slots", "slotProps"];
|
|
19
22
|
const useUtilityClasses = (classes, ownerState) => {
|
|
20
23
|
const {
|
|
21
24
|
pickerOrientation
|
|
@@ -126,16 +129,18 @@ const PickersLayout = exports.PickersLayout = /*#__PURE__*/React.forwardRef(func
|
|
|
126
129
|
variant
|
|
127
130
|
} = (0, _usePickerContext.usePickerContext)();
|
|
128
131
|
const {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
sx,
|
|
133
|
+
className,
|
|
134
|
+
classes: classesProp
|
|
135
|
+
} = props,
|
|
136
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
133
137
|
const classes = useUtilityClasses(classesProp, ownerState);
|
|
134
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PickersLayoutRoot, {
|
|
138
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PickersLayoutRoot, (0, _extends2.default)({
|
|
135
139
|
ref: ref,
|
|
136
140
|
sx: sx,
|
|
137
141
|
className: (0, _clsx.default)(classes.root, className),
|
|
138
|
-
ownerState: ownerState
|
|
142
|
+
ownerState: ownerState
|
|
143
|
+
}, other, {
|
|
139
144
|
children: [orientation === 'landscape' ? shortcuts : toolbar, orientation === 'landscape' ? toolbar : shortcuts, /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersLayoutContentWrapper, {
|
|
140
145
|
className: classes.contentWrapper,
|
|
141
146
|
ownerState: ownerState,
|
|
@@ -145,7 +150,7 @@ const PickersLayout = exports.PickersLayout = /*#__PURE__*/React.forwardRef(func
|
|
|
145
150
|
children: [tabs, content]
|
|
146
151
|
})
|
|
147
152
|
}), actionBar]
|
|
148
|
-
});
|
|
153
|
+
}));
|
|
149
154
|
});
|
|
150
155
|
if (process.env.NODE_ENV !== "production") PickersLayout.displayName = "PickersLayout";
|
|
151
156
|
process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["sx", "className", "classes", "children", "slots", "slotProps"];
|
|
3
6
|
import * as React from 'react';
|
|
4
7
|
import PropTypes from 'prop-types';
|
|
5
8
|
import clsx from 'clsx';
|
|
@@ -119,16 +122,18 @@ const PickersLayout = /*#__PURE__*/React.forwardRef(function PickersLayout(inPro
|
|
|
119
122
|
variant
|
|
120
123
|
} = usePickerContext();
|
|
121
124
|
const {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
sx,
|
|
126
|
+
className,
|
|
127
|
+
classes: classesProp
|
|
128
|
+
} = props,
|
|
129
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
126
130
|
const classes = useUtilityClasses(classesProp, ownerState);
|
|
127
|
-
return /*#__PURE__*/_jsxs(PickersLayoutRoot, {
|
|
131
|
+
return /*#__PURE__*/_jsxs(PickersLayoutRoot, _extends({
|
|
128
132
|
ref: ref,
|
|
129
133
|
sx: sx,
|
|
130
134
|
className: clsx(classes.root, className),
|
|
131
|
-
ownerState: ownerState
|
|
135
|
+
ownerState: ownerState
|
|
136
|
+
}, other, {
|
|
132
137
|
children: [orientation === 'landscape' ? shortcuts : toolbar, orientation === 'landscape' ? toolbar : shortcuts, /*#__PURE__*/_jsx(PickersLayoutContentWrapper, {
|
|
133
138
|
className: classes.contentWrapper,
|
|
134
139
|
ownerState: ownerState,
|
|
@@ -138,7 +143,7 @@ const PickersLayout = /*#__PURE__*/React.forwardRef(function PickersLayout(inPro
|
|
|
138
143
|
children: [tabs, content]
|
|
139
144
|
})
|
|
140
145
|
}), actionBar]
|
|
141
|
-
});
|
|
146
|
+
}));
|
|
142
147
|
});
|
|
143
148
|
if (process.env.NODE_ENV !== "production") PickersLayout.displayName = "PickersLayout";
|
|
144
149
|
process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
|
|
@@ -74,7 +74,7 @@ export interface PickersLayoutSlotProps<TValue extends PickerValidValue> extends
|
|
|
74
74
|
*/
|
|
75
75
|
toolbar?: ExportedBaseToolbarProps;
|
|
76
76
|
}
|
|
77
|
-
export interface PickersLayoutProps<TValue extends PickerValidValue> {
|
|
77
|
+
export interface PickersLayoutProps<TValue extends PickerValidValue> extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'className'> {
|
|
78
78
|
className?: string;
|
|
79
79
|
children?: React.ReactNode;
|
|
80
80
|
/**
|
|
@@ -74,7 +74,7 @@ export interface PickersLayoutSlotProps<TValue extends PickerValidValue> extends
|
|
|
74
74
|
*/
|
|
75
75
|
toolbar?: ExportedBaseToolbarProps;
|
|
76
76
|
}
|
|
77
|
-
export interface PickersLayoutProps<TValue extends PickerValidValue> {
|
|
77
|
+
export interface PickersLayoutProps<TValue extends PickerValidValue> extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'className'> {
|
|
78
78
|
className?: string;
|
|
79
79
|
children?: React.ReactNode;
|
|
80
80
|
/**
|
|
@@ -75,7 +75,7 @@ const PickersFilledInputRoot = (0, _styles.styled)(_PickersInputBase2.PickersInp
|
|
|
75
75
|
'&::after': {
|
|
76
76
|
left: 0,
|
|
77
77
|
bottom: 0,
|
|
78
|
-
// Doing the other way around crash on
|
|
78
|
+
// Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
|
|
79
79
|
content: '""',
|
|
80
80
|
position: 'absolute',
|
|
81
81
|
right: 0,
|
|
@@ -100,7 +100,7 @@ const PickersFilledInputRoot = (0, _styles.styled)(_PickersInputBase2.PickersInp
|
|
|
100
100
|
borderBottom: `1px solid ${theme.vars ? theme.alpha(theme.vars.palette.common.onBackground, theme.vars.opacity.inputUnderline) : bottomLineColor}`,
|
|
101
101
|
left: 0,
|
|
102
102
|
bottom: 0,
|
|
103
|
-
// Doing the other way around crash on
|
|
103
|
+
// Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
|
|
104
104
|
content: '"\\00a0"',
|
|
105
105
|
position: 'absolute',
|
|
106
106
|
right: 0,
|
|
@@ -68,7 +68,7 @@ const PickersFilledInputRoot = styled(PickersInputBaseRoot, {
|
|
|
68
68
|
'&::after': {
|
|
69
69
|
left: 0,
|
|
70
70
|
bottom: 0,
|
|
71
|
-
// Doing the other way around crash on
|
|
71
|
+
// Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
|
|
72
72
|
content: '""',
|
|
73
73
|
position: 'absolute',
|
|
74
74
|
right: 0,
|
|
@@ -93,7 +93,7 @@ const PickersFilledInputRoot = styled(PickersInputBaseRoot, {
|
|
|
93
93
|
borderBottom: `1px solid ${theme.vars ? theme.alpha(theme.vars.palette.common.onBackground, theme.vars.opacity.inputUnderline) : bottomLineColor}`,
|
|
94
94
|
left: 0,
|
|
95
95
|
bottom: 0,
|
|
96
|
-
// Doing the other way around crash on
|
|
96
|
+
// Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
|
|
97
97
|
content: '"\\00a0"',
|
|
98
98
|
position: 'absolute',
|
|
99
99
|
right: 0,
|
|
@@ -59,7 +59,7 @@ const PickersInputRoot = (0, _styles.styled)(_PickersInputBase2.PickersInputBase
|
|
|
59
59
|
background: 'red',
|
|
60
60
|
left: 0,
|
|
61
61
|
bottom: 0,
|
|
62
|
-
// Doing the other way around crash on
|
|
62
|
+
// Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
|
|
63
63
|
content: '""',
|
|
64
64
|
position: 'absolute',
|
|
65
65
|
right: 0,
|
|
@@ -84,7 +84,7 @@ const PickersInputRoot = (0, _styles.styled)(_PickersInputBase2.PickersInputBase
|
|
|
84
84
|
borderBottom: `1px solid ${bottomLineColor}`,
|
|
85
85
|
left: 0,
|
|
86
86
|
bottom: 0,
|
|
87
|
-
// Doing the other way around crash on
|
|
87
|
+
// Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
|
|
88
88
|
content: '"\\00a0"',
|
|
89
89
|
position: 'absolute',
|
|
90
90
|
right: 0,
|
|
@@ -52,7 +52,7 @@ const PickersInputRoot = styled(PickersInputBaseRoot, {
|
|
|
52
52
|
background: 'red',
|
|
53
53
|
left: 0,
|
|
54
54
|
bottom: 0,
|
|
55
|
-
// Doing the other way around crash on
|
|
55
|
+
// Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
|
|
56
56
|
content: '""',
|
|
57
57
|
position: 'absolute',
|
|
58
58
|
right: 0,
|
|
@@ -77,7 +77,7 @@ const PickersInputRoot = styled(PickersInputBaseRoot, {
|
|
|
77
77
|
borderBottom: `1px solid ${bottomLineColor}`,
|
|
78
78
|
left: 0,
|
|
79
79
|
bottom: 0,
|
|
80
|
-
// Doing the other way around crash on
|
|
80
|
+
// Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
|
|
81
81
|
content: '"\\00a0"',
|
|
82
82
|
position: 'absolute',
|
|
83
83
|
right: 0,
|
|
@@ -44,6 +44,9 @@ const PickersOutlinedInputRoot = (0, _styles.styled)(_PickersInputBase2.PickersI
|
|
|
44
44
|
borderStyle: 'solid',
|
|
45
45
|
borderWidth: 2
|
|
46
46
|
},
|
|
47
|
+
[`&.${_pickersOutlinedInputClasses.pickersOutlinedInputClasses.error} .${_pickersOutlinedInputClasses.pickersOutlinedInputClasses.notchedOutline}`]: {
|
|
48
|
+
borderColor: (theme.vars || theme).palette.error.main
|
|
49
|
+
},
|
|
47
50
|
[`&.${_pickersOutlinedInputClasses.pickersOutlinedInputClasses.disabled}`]: {
|
|
48
51
|
[`& .${_pickersOutlinedInputClasses.pickersOutlinedInputClasses.notchedOutline}`]: {
|
|
49
52
|
borderColor: (theme.vars || theme).palette.action.disabled
|
|
@@ -52,9 +55,6 @@ const PickersOutlinedInputRoot = (0, _styles.styled)(_PickersInputBase2.PickersI
|
|
|
52
55
|
color: (theme.vars || theme).palette.action.disabled
|
|
53
56
|
}
|
|
54
57
|
},
|
|
55
|
-
[`&.${_pickersOutlinedInputClasses.pickersOutlinedInputClasses.error} .${_pickersOutlinedInputClasses.pickersOutlinedInputClasses.notchedOutline}`]: {
|
|
56
|
-
borderColor: (theme.vars || theme).palette.error.main
|
|
57
|
-
},
|
|
58
58
|
variants: Object.keys((theme.vars ?? theme).palette)
|
|
59
59
|
// @ts-ignore
|
|
60
60
|
.filter(key => (theme.vars ?? theme).palette[key]?.main ?? false).map(color => ({
|
|
@@ -37,6 +37,9 @@ const PickersOutlinedInputRoot = styled(PickersInputBaseRoot, {
|
|
|
37
37
|
borderStyle: 'solid',
|
|
38
38
|
borderWidth: 2
|
|
39
39
|
},
|
|
40
|
+
[`&.${pickersOutlinedInputClasses.error} .${pickersOutlinedInputClasses.notchedOutline}`]: {
|
|
41
|
+
borderColor: (theme.vars || theme).palette.error.main
|
|
42
|
+
},
|
|
40
43
|
[`&.${pickersOutlinedInputClasses.disabled}`]: {
|
|
41
44
|
[`& .${pickersOutlinedInputClasses.notchedOutline}`]: {
|
|
42
45
|
borderColor: (theme.vars || theme).palette.action.disabled
|
|
@@ -45,9 +48,6 @@ const PickersOutlinedInputRoot = styled(PickersInputBaseRoot, {
|
|
|
45
48
|
color: (theme.vars || theme).palette.action.disabled
|
|
46
49
|
}
|
|
47
50
|
},
|
|
48
|
-
[`&.${pickersOutlinedInputClasses.error} .${pickersOutlinedInputClasses.notchedOutline}`]: {
|
|
49
|
-
borderColor: (theme.vars || theme).palette.error.main
|
|
50
|
-
},
|
|
51
51
|
variants: Object.keys((theme.vars ?? theme).palette)
|
|
52
52
|
// @ts-ignore
|
|
53
53
|
.filter(key => (theme.vars ?? theme).palette[key]?.main ?? false).map(color => ({
|
package/index.js
CHANGED
package/index.mjs
CHANGED
|
@@ -106,8 +106,7 @@ interface PickerFieldUIContextValue {
|
|
|
106
106
|
export declare function mergeSlotProps<TProps extends {}, TOwnerState extends FieldOwnerState>(slotPropsA: SlotComponentPropsFromProps<TProps, {}, TOwnerState> | undefined, slotPropsB: SlotComponentPropsFromProps<TProps, {}, TOwnerState> | undefined): Partial<TProps> | ((ownerState: TOwnerState) => {}) | undefined;
|
|
107
107
|
/**
|
|
108
108
|
* The `textField` slot props cannot be handled inside `PickerFieldUI` because it would be a breaking change to not pass the enriched props to `useField`.
|
|
109
|
-
*
|
|
110
|
-
* TODO: Address with the needed support for the `textField` slotProps given the change of minimum version of MUI.
|
|
109
|
+
* TODO v10: Remove the `textField` slot and clean this logic up.
|
|
111
110
|
*/
|
|
112
111
|
export declare function useFieldTextFieldProps<TProps extends UseFieldOwnerStateParameters>(parameters: UseFieldTextFieldPropsParameters): TProps;
|
|
113
112
|
interface UseFieldTextFieldPropsParameters {
|
|
@@ -106,8 +106,7 @@ interface PickerFieldUIContextValue {
|
|
|
106
106
|
export declare function mergeSlotProps<TProps extends {}, TOwnerState extends FieldOwnerState>(slotPropsA: SlotComponentPropsFromProps<TProps, {}, TOwnerState> | undefined, slotPropsB: SlotComponentPropsFromProps<TProps, {}, TOwnerState> | undefined): Partial<TProps> | ((ownerState: TOwnerState) => {}) | undefined;
|
|
107
107
|
/**
|
|
108
108
|
* The `textField` slot props cannot be handled inside `PickerFieldUI` because it would be a breaking change to not pass the enriched props to `useField`.
|
|
109
|
-
*
|
|
110
|
-
* TODO: Address with the needed support for the `textField` slotProps given the change of minimum version of MUI.
|
|
109
|
+
* TODO v10: Remove the `textField` slot and clean this logic up.
|
|
111
110
|
*/
|
|
112
111
|
export declare function useFieldTextFieldProps<TProps extends UseFieldOwnerStateParameters>(parameters: UseFieldTextFieldPropsParameters): TProps;
|
|
113
112
|
interface UseFieldTextFieldPropsParameters {
|
|
@@ -250,8 +250,7 @@ function mergeSlotProps(slotPropsA, slotPropsB) {
|
|
|
250
250
|
|
|
251
251
|
/**
|
|
252
252
|
* The `textField` slot props cannot be handled inside `PickerFieldUI` because it would be a breaking change to not pass the enriched props to `useField`.
|
|
253
|
-
*
|
|
254
|
-
* TODO: Address with the needed support for the `textField` slotProps given the change of minimum version of MUI.
|
|
253
|
+
* TODO v10: Remove the `textField` slot and clean this logic up.
|
|
255
254
|
*/
|
|
256
255
|
function useFieldTextFieldProps(parameters) {
|
|
257
256
|
const {
|
|
@@ -237,8 +237,7 @@ export function mergeSlotProps(slotPropsA, slotPropsB) {
|
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
239
|
* The `textField` slot props cannot be handled inside `PickerFieldUI` because it would be a breaking change to not pass the enriched props to `useField`.
|
|
240
|
-
*
|
|
241
|
-
* TODO: Address with the needed support for the `textField` slotProps given the change of minimum version of MUI.
|
|
240
|
+
* TODO v10: Remove the `textField` slot and clean this logic up.
|
|
242
241
|
*/
|
|
243
242
|
export function useFieldTextFieldProps(parameters) {
|
|
244
243
|
const {
|
|
@@ -112,7 +112,7 @@ function useClickAwayListener(active, onClickAway) {
|
|
|
112
112
|
syntheticEventRef.current = false;
|
|
113
113
|
const doc = (0, _ownerDocument.default)(nodeRef.current);
|
|
114
114
|
|
|
115
|
-
// 1.
|
|
115
|
+
// 1. IE 11 support, which trigger the handleClickAway even after the unbind
|
|
116
116
|
// 2. The child might render null.
|
|
117
117
|
// 3. Behave like a blur listener.
|
|
118
118
|
if (!nodeRef.current ||
|
|
@@ -105,7 +105,7 @@ function useClickAwayListener(active, onClickAway) {
|
|
|
105
105
|
syntheticEventRef.current = false;
|
|
106
106
|
const doc = ownerDocument(nodeRef.current);
|
|
107
107
|
|
|
108
|
-
// 1.
|
|
108
|
+
// 1. IE 11 support, which trigger the handleClickAway even after the unbind
|
|
109
109
|
// 2. The child might render null.
|
|
110
110
|
// 3. Behave like a blur listener.
|
|
111
111
|
if (!nodeRef.current ||
|
|
@@ -13,6 +13,7 @@ var _usePicker = require("../usePicker");
|
|
|
13
13
|
var _PickersLayout = require("../../../PickersLayout");
|
|
14
14
|
var _PickerProvider = require("../../components/PickerProvider");
|
|
15
15
|
var _createNonRangePickerStepNavigation = require("../../utils/createNonRangePickerStepNavigation");
|
|
16
|
+
var _utils = require("../../utils/utils");
|
|
16
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
18
|
const _excluded = ["props", "steps"],
|
|
18
19
|
_excluded2 = ["ownerState"];
|
|
@@ -56,6 +57,7 @@ const useDesktopPicker = _ref => {
|
|
|
56
57
|
const _useSlotProps = (0, _useSlotProps2.default)({
|
|
57
58
|
elementType: Field,
|
|
58
59
|
externalSlotProps: innerSlotProps?.field,
|
|
60
|
+
externalForwardedProps: (0, _utils.extractRootForwardedProps)(props),
|
|
59
61
|
additionalProps: (0, _extends2.default)({}, isToolbarHidden && {
|
|
60
62
|
id: labelId
|
|
61
63
|
}),
|
|
@@ -8,6 +8,7 @@ import { usePicker } from "../usePicker/index.mjs";
|
|
|
8
8
|
import { PickersLayout } from "../../../PickersLayout/index.mjs";
|
|
9
9
|
import { PickerProvider } from "../../components/PickerProvider.mjs";
|
|
10
10
|
import { createNonRangePickerStepNavigation } from "../../utils/createNonRangePickerStepNavigation.mjs";
|
|
11
|
+
import { extractRootForwardedProps } from "../../utils/utils.mjs";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Hook managing all the single-date desktop pickers:
|
|
@@ -50,6 +51,7 @@ export const useDesktopPicker = _ref => {
|
|
|
50
51
|
const _useSlotProps = useSlotProps({
|
|
51
52
|
elementType: Field,
|
|
52
53
|
externalSlotProps: innerSlotProps?.field,
|
|
54
|
+
externalForwardedProps: extractRootForwardedProps(props),
|
|
53
55
|
additionalProps: _extends({}, isToolbarHidden && {
|
|
54
56
|
id: labelId
|
|
55
57
|
}),
|
|
@@ -138,12 +138,25 @@ const useField = parameters => {
|
|
|
138
138
|
rootProps.onKeyDown(event);
|
|
139
139
|
});
|
|
140
140
|
const handleRootBlur = (0, _useEventCallback.default)(event => {
|
|
141
|
-
onBlur?.(event);
|
|
142
141
|
rootProps.onBlur(event);
|
|
142
|
+
// Skip the user callback when focus is only moving to another element inside the field
|
|
143
|
+
// (e.g. the section that gains focus after the focusable root gives it up).
|
|
144
|
+
const next = event.relatedTarget;
|
|
145
|
+
if (domGetters.isReady() && next instanceof Node && domGetters.getRoot().contains(next)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
onBlur?.(event);
|
|
143
149
|
});
|
|
144
150
|
const handleRootFocus = (0, _useEventCallback.default)(event => {
|
|
145
|
-
onFocus?.(event);
|
|
146
151
|
rootProps.onFocus(event);
|
|
152
|
+
// Skip the user callback when focus is only arriving from another element inside the field
|
|
153
|
+
// (e.g. the focusable root receiving it before it is forwarded to a section, and the section
|
|
154
|
+
// focus event bubbling back up to the root).
|
|
155
|
+
const previous = event.relatedTarget;
|
|
156
|
+
if (domGetters.isReady() && previous instanceof Node && domGetters.getRoot().contains(previous)) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
onFocus?.(event);
|
|
147
160
|
});
|
|
148
161
|
const handleRootClick = (0, _useEventCallback.default)(event => {
|
|
149
162
|
// The click event on the clear or open button would propagate to the input, trigger this handler and result in an inadvertent section selection.
|
|
@@ -131,12 +131,25 @@ export const useField = parameters => {
|
|
|
131
131
|
rootProps.onKeyDown(event);
|
|
132
132
|
});
|
|
133
133
|
const handleRootBlur = useEventCallback(event => {
|
|
134
|
-
onBlur?.(event);
|
|
135
134
|
rootProps.onBlur(event);
|
|
135
|
+
// Skip the user callback when focus is only moving to another element inside the field
|
|
136
|
+
// (e.g. the section that gains focus after the focusable root gives it up).
|
|
137
|
+
const next = event.relatedTarget;
|
|
138
|
+
if (domGetters.isReady() && next instanceof Node && domGetters.getRoot().contains(next)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
onBlur?.(event);
|
|
136
142
|
});
|
|
137
143
|
const handleRootFocus = useEventCallback(event => {
|
|
138
|
-
onFocus?.(event);
|
|
139
144
|
rootProps.onFocus(event);
|
|
145
|
+
// Skip the user callback when focus is only arriving from another element inside the field
|
|
146
|
+
// (e.g. the focusable root receiving it before it is forwarded to a section, and the section
|
|
147
|
+
// focus event bubbling back up to the root).
|
|
148
|
+
const previous = event.relatedTarget;
|
|
149
|
+
if (domGetters.isReady() && previous instanceof Node && domGetters.getRoot().contains(previous)) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
onFocus?.(event);
|
|
140
153
|
});
|
|
141
154
|
const handleRootClick = useEventCallback(event => {
|
|
142
155
|
// The click event on the clear or open button would propagate to the input, trigger this handler and result in an inadvertent section selection.
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.validateSections = exports.removeLocalizedDigits = exports.parseSelectedSections = exports.mergeDateIntoReferenceDate = exports.isStringNumber = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionOrder = exports.getLocalizedDigits = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.doesSectionFormatHaveLeadingZeros = exports.createDateStrForHiddenInputFromSections = exports.cleanLeadingZeros = exports.cleanDigitSectionValue = exports.changeSectionValueFormat = exports.applyLocalizedDigits = exports.FORMAT_SECONDS_NO_LEADING_ZEROS = void 0;
|
|
8
8
|
var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
|
|
9
9
|
var _dateUtils = require("../../utils/date-utils");
|
|
10
|
+
var _timeUtils = require("../../utils/time-utils");
|
|
10
11
|
const getDateSectionConfigFromFormatToken = (adapter, formatToken) => {
|
|
11
12
|
const config = adapter.formatTokenMap[formatToken];
|
|
12
13
|
if (config == null) {
|
|
@@ -305,13 +306,33 @@ const getSectionsBoundaries = (adapter, localizedDigits, timezone) => {
|
|
|
305
306
|
format
|
|
306
307
|
}) => {
|
|
307
308
|
const lastHourInDay = adapter.getHours(endOfDay);
|
|
308
|
-
const
|
|
309
|
+
const formattedMidnight = Number(removeLocalizedDigits(adapter.formatByString(adapter.startOfDay(today), format), localizedDigits));
|
|
310
|
+
const formattedEndOfDay = Number(removeLocalizedDigits(adapter.formatByString(adapter.endOfDay(today), format), localizedDigits));
|
|
311
|
+
const hasMeridiem = formattedEndOfDay !== lastHourInDay;
|
|
309
312
|
if (hasMeridiem) {
|
|
313
|
+
// K/KK format (hour 0-11): midnight formats as 0
|
|
314
|
+
if (formattedMidnight === 0) {
|
|
315
|
+
return {
|
|
316
|
+
minimum: 0,
|
|
317
|
+
maximum: formattedEndOfDay
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
// h/hh format (hour 1-12): midnight formats as 12
|
|
321
|
+
return {
|
|
322
|
+
minimum: 1,
|
|
323
|
+
maximum: formattedMidnight
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// k/kk format (hour 1-24): midnight formats as 24 (> lastHourInDay)
|
|
328
|
+
if (formattedMidnight > lastHourInDay) {
|
|
310
329
|
return {
|
|
311
330
|
minimum: 1,
|
|
312
|
-
maximum:
|
|
331
|
+
maximum: formattedMidnight
|
|
313
332
|
};
|
|
314
333
|
}
|
|
334
|
+
|
|
335
|
+
// H/HH format (hour 0-23)
|
|
315
336
|
return {
|
|
316
337
|
minimum: 0,
|
|
317
338
|
maximum: lastHourInDay
|
|
@@ -386,15 +407,8 @@ const transferDateSectionValue = (adapter, section, dateToTransferFrom, dateToTr
|
|
|
386
407
|
}
|
|
387
408
|
case 'meridiem':
|
|
388
409
|
{
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
if (isAM && mergedDateHours >= 12) {
|
|
392
|
-
return adapter.addHours(dateToTransferTo, -12);
|
|
393
|
-
}
|
|
394
|
-
if (!isAM && mergedDateHours < 12) {
|
|
395
|
-
return adapter.addHours(dateToTransferTo, 12);
|
|
396
|
-
}
|
|
397
|
-
return dateToTransferTo;
|
|
410
|
+
const meridiem = adapter.getHours(dateToTransferFrom) < 12 ? 'am' : 'pm';
|
|
411
|
+
return (0, _timeUtils.convertToMeridiem)(dateToTransferTo, meridiem, true, adapter);
|
|
398
412
|
}
|
|
399
413
|
case 'hours':
|
|
400
414
|
{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
2
2
|
import { getMonthsInYear } from "../../utils/date-utils.mjs";
|
|
3
|
+
import { convertToMeridiem } from "../../utils/time-utils.mjs";
|
|
3
4
|
export const getDateSectionConfigFromFormatToken = (adapter, formatToken) => {
|
|
4
5
|
const config = adapter.formatTokenMap[formatToken];
|
|
5
6
|
if (config == null) {
|
|
@@ -284,13 +285,33 @@ export const getSectionsBoundaries = (adapter, localizedDigits, timezone) => {
|
|
|
284
285
|
format
|
|
285
286
|
}) => {
|
|
286
287
|
const lastHourInDay = adapter.getHours(endOfDay);
|
|
287
|
-
const
|
|
288
|
+
const formattedMidnight = Number(removeLocalizedDigits(adapter.formatByString(adapter.startOfDay(today), format), localizedDigits));
|
|
289
|
+
const formattedEndOfDay = Number(removeLocalizedDigits(adapter.formatByString(adapter.endOfDay(today), format), localizedDigits));
|
|
290
|
+
const hasMeridiem = formattedEndOfDay !== lastHourInDay;
|
|
288
291
|
if (hasMeridiem) {
|
|
292
|
+
// K/KK format (hour 0-11): midnight formats as 0
|
|
293
|
+
if (formattedMidnight === 0) {
|
|
294
|
+
return {
|
|
295
|
+
minimum: 0,
|
|
296
|
+
maximum: formattedEndOfDay
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
// h/hh format (hour 1-12): midnight formats as 12
|
|
300
|
+
return {
|
|
301
|
+
minimum: 1,
|
|
302
|
+
maximum: formattedMidnight
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// k/kk format (hour 1-24): midnight formats as 24 (> lastHourInDay)
|
|
307
|
+
if (formattedMidnight > lastHourInDay) {
|
|
289
308
|
return {
|
|
290
309
|
minimum: 1,
|
|
291
|
-
maximum:
|
|
310
|
+
maximum: formattedMidnight
|
|
292
311
|
};
|
|
293
312
|
}
|
|
313
|
+
|
|
314
|
+
// H/HH format (hour 0-23)
|
|
294
315
|
return {
|
|
295
316
|
minimum: 0,
|
|
296
317
|
maximum: lastHourInDay
|
|
@@ -363,15 +384,8 @@ const transferDateSectionValue = (adapter, section, dateToTransferFrom, dateToTr
|
|
|
363
384
|
}
|
|
364
385
|
case 'meridiem':
|
|
365
386
|
{
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
if (isAM && mergedDateHours >= 12) {
|
|
369
|
-
return adapter.addHours(dateToTransferTo, -12);
|
|
370
|
-
}
|
|
371
|
-
if (!isAM && mergedDateHours < 12) {
|
|
372
|
-
return adapter.addHours(dateToTransferTo, 12);
|
|
373
|
-
}
|
|
374
|
-
return dateToTransferTo;
|
|
387
|
+
const meridiem = adapter.getHours(dateToTransferFrom) < 12 ? 'am' : 'pm';
|
|
388
|
+
return convertToMeridiem(dateToTransferTo, meridiem, true, adapter);
|
|
375
389
|
}
|
|
376
390
|
case 'hours':
|
|
377
391
|
{
|
|
@@ -60,7 +60,7 @@ function useFieldRootProps(parameters) {
|
|
|
60
60
|
// eslint-disable-next-line default-case
|
|
61
61
|
switch (true) {
|
|
62
62
|
// Select all
|
|
63
|
-
case (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'A' && !event.shiftKey && !event.altKey:
|
|
63
|
+
case (event.ctrlKey || event.metaKey) && (event.key?.toUpperCase() === 'A' || String.fromCharCode(event.keyCode) === 'A') && !event.shiftKey && !event.altKey:
|
|
64
64
|
{
|
|
65
65
|
// prevent default to make sure that the next line "select all" while updating
|
|
66
66
|
// the internal state at the same time.
|
|
@@ -54,7 +54,7 @@ export function useFieldRootProps(parameters) {
|
|
|
54
54
|
// eslint-disable-next-line default-case
|
|
55
55
|
switch (true) {
|
|
56
56
|
// Select all
|
|
57
|
-
case (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'A' && !event.shiftKey && !event.altKey:
|
|
57
|
+
case (event.ctrlKey || event.metaKey) && (event.key?.toUpperCase() === 'A' || String.fromCharCode(event.keyCode) === 'A') && !event.shiftKey && !event.altKey:
|
|
58
58
|
{
|
|
59
59
|
// prevent default to make sure that the next line "select all" while updating
|
|
60
60
|
// the internal state at the same time.
|
|
@@ -13,6 +13,7 @@ var _usePicker = require("../usePicker");
|
|
|
13
13
|
var _PickersLayout = require("../../../PickersLayout");
|
|
14
14
|
var _PickerProvider = require("../../components/PickerProvider");
|
|
15
15
|
var _createNonRangePickerStepNavigation = require("../../utils/createNonRangePickerStepNavigation");
|
|
16
|
+
var _utils = require("../../utils/utils");
|
|
16
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
18
|
const _excluded = ["props", "steps"],
|
|
18
19
|
_excluded2 = ["ownerState"];
|
|
@@ -56,6 +57,7 @@ const useMobilePicker = _ref => {
|
|
|
56
57
|
const _useSlotProps = (0, _useSlotProps2.default)({
|
|
57
58
|
elementType: Field,
|
|
58
59
|
externalSlotProps: innerSlotProps?.field,
|
|
60
|
+
externalForwardedProps: (0, _utils.extractRootForwardedProps)(props),
|
|
59
61
|
additionalProps: (0, _extends2.default)({}, isToolbarHidden && {
|
|
60
62
|
id: labelId
|
|
61
63
|
}),
|
|
@@ -8,6 +8,7 @@ import { usePicker } from "../usePicker/index.mjs";
|
|
|
8
8
|
import { PickersLayout } from "../../../PickersLayout/index.mjs";
|
|
9
9
|
import { PickerProvider } from "../../components/PickerProvider.mjs";
|
|
10
10
|
import { createNonRangePickerStepNavigation } from "../../utils/createNonRangePickerStepNavigation.mjs";
|
|
11
|
+
import { extractRootForwardedProps } from "../../utils/utils.mjs";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Hook managing all the single-date mobile pickers:
|
|
@@ -50,6 +51,7 @@ export const useMobilePicker = _ref => {
|
|
|
50
51
|
const _useSlotProps = useSlotProps({
|
|
51
52
|
elementType: Field,
|
|
52
53
|
externalSlotProps: innerSlotProps?.field,
|
|
54
|
+
externalForwardedProps: extractRootForwardedProps(props),
|
|
53
55
|
additionalProps: _extends({}, isToolbarHidden && {
|
|
54
56
|
id: labelId
|
|
55
57
|
}),
|
|
@@ -63,7 +63,7 @@ const useStaticPicker = _ref => {
|
|
|
63
63
|
}));
|
|
64
64
|
const Layout = slots?.layout ?? PickerStaticLayout;
|
|
65
65
|
const renderPicker = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickerProvider.PickerProvider, (0, _extends2.default)({}, providerProps, {
|
|
66
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Layout, (0, _extends2.default)({}, slotProps?.layout, {
|
|
66
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Layout, (0, _extends2.default)({}, (0, _utils.extractRootForwardedProps)(props), slotProps?.layout, {
|
|
67
67
|
slots: slots,
|
|
68
68
|
slotProps: slotProps,
|
|
69
69
|
sx: (0, _utils.mergeSx)(providerProps.contextValue.rootSx, slotProps?.layout?.sx),
|
|
@@ -9,7 +9,7 @@ import { usePicker } from "../usePicker/index.mjs";
|
|
|
9
9
|
import { PickerProvider } from "../../components/PickerProvider.mjs";
|
|
10
10
|
import { PickersLayout } from "../../../PickersLayout/index.mjs";
|
|
11
11
|
import { DIALOG_WIDTH } from "../../constants/dimensions.mjs";
|
|
12
|
-
import { mergeSx } from "../../utils/utils.mjs";
|
|
12
|
+
import { extractRootForwardedProps, mergeSx } from "../../utils/utils.mjs";
|
|
13
13
|
import { createNonRangePickerStepNavigation } from "../../utils/createNonRangePickerStepNavigation.mjs";
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
const PickerStaticLayout = styled(PickersLayout, {
|
|
@@ -57,7 +57,7 @@ export const useStaticPicker = _ref => {
|
|
|
57
57
|
}));
|
|
58
58
|
const Layout = slots?.layout ?? PickerStaticLayout;
|
|
59
59
|
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
60
|
-
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
60
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, extractRootForwardedProps(props), slotProps?.layout, {
|
|
61
61
|
slots: slots,
|
|
62
62
|
slotProps: slotProps,
|
|
63
63
|
sx: mergeSx(providerProps.contextValue.rootSx, slotProps?.layout?.sx),
|
package/internals/index.d.mts
CHANGED
|
@@ -61,7 +61,7 @@ export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate
|
|
|
61
61
|
export { getDefaultReferenceDate } from "./utils/getDefaultReferenceDate.mjs";
|
|
62
62
|
export { isTimeView, isInternalTimeView, resolveTimeFormat, getMeridiem, TIME_VIEWS } from "./utils/time-utils.mjs";
|
|
63
63
|
export { resolveTimeViewsResponse, resolveDateTimeFormat } from "./utils/date-time-utils.mjs";
|
|
64
|
-
export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, mergeSx, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from "./utils/utils.mjs";
|
|
64
|
+
export { executeInTheNextEventLoopTick, extractRootForwardedProps, getActiveElement, onSpaceOrEnter, mergeSx, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from "./utils/utils.mjs";
|
|
65
65
|
export { useReduceAnimations } from "./hooks/useReduceAnimations.mjs";
|
|
66
66
|
export { applyDefaultViewProps } from "./utils/views.mjs";
|
|
67
67
|
export { isElementInteractive } from "./utils/isElementInteractive.mjs";
|
package/internals/index.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate
|
|
|
61
61
|
export { getDefaultReferenceDate } from "./utils/getDefaultReferenceDate.js";
|
|
62
62
|
export { isTimeView, isInternalTimeView, resolveTimeFormat, getMeridiem, TIME_VIEWS } from "./utils/time-utils.js";
|
|
63
63
|
export { resolveTimeViewsResponse, resolveDateTimeFormat } from "./utils/date-time-utils.js";
|
|
64
|
-
export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, mergeSx, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from "./utils/utils.js";
|
|
64
|
+
export { executeInTheNextEventLoopTick, extractRootForwardedProps, getActiveElement, onSpaceOrEnter, mergeSx, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from "./utils/utils.js";
|
|
65
65
|
export { useReduceAnimations } from "./hooks/useReduceAnimations.js";
|
|
66
66
|
export { applyDefaultViewProps } from "./utils/views.js";
|
|
67
67
|
export { isElementInteractive } from "./utils/isElementInteractive.js";
|