@mui/x-date-pickers 9.0.0-rc.0 → 9.0.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +328 -6892
  2. package/DateField/DateField.js +0 -24
  3. package/DateField/DateField.mjs +0 -24
  4. package/DateTimeField/DateTimeField.js +0 -24
  5. package/DateTimeField/DateTimeField.mjs +0 -24
  6. package/LocalizationProvider/LocalizationProvider.d.mts +0 -6
  7. package/LocalizationProvider/LocalizationProvider.d.ts +0 -6
  8. package/LocalizationProvider/LocalizationProvider.js +1 -10
  9. package/LocalizationProvider/LocalizationProvider.mjs +0 -9
  10. package/LocalizationProvider/index.d.mts +1 -1
  11. package/LocalizationProvider/index.d.ts +1 -1
  12. package/LocalizationProvider/index.js +0 -6
  13. package/LocalizationProvider/index.mjs +1 -1
  14. package/PickersTextField/PickersFilledInput/PickersFilledInput.js +14 -19
  15. package/PickersTextField/PickersFilledInput/PickersFilledInput.mjs +14 -19
  16. package/PickersTextField/PickersInput/PickersInput.js +12 -17
  17. package/PickersTextField/PickersInput/PickersInput.mjs +12 -17
  18. package/PickersTextField/PickersInputBase/PickersInputBase.js +16 -12
  19. package/PickersTextField/PickersInputBase/PickersInputBase.mjs +16 -12
  20. package/PickersTextField/PickersInputBase/PickersInputBase.types.d.mts +34 -17
  21. package/PickersTextField/PickersInputBase/PickersInputBase.types.d.ts +34 -17
  22. package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +10 -14
  23. package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.mjs +10 -14
  24. package/PickersTextField/PickersTextField.js +68 -55
  25. package/PickersTextField/PickersTextField.mjs +68 -55
  26. package/PickersTextField/PickersTextField.types.d.mts +52 -40
  27. package/PickersTextField/PickersTextField.types.d.ts +52 -40
  28. package/PickersTextField/index.d.mts +1 -1
  29. package/PickersTextField/index.d.ts +1 -1
  30. package/TimeField/TimeField.js +1 -25
  31. package/TimeField/TimeField.mjs +1 -25
  32. package/index.js +1 -1
  33. package/index.mjs +1 -1
  34. package/internals/components/PickerFieldUI.d.mts +4 -20
  35. package/internals/components/PickerFieldUI.d.ts +4 -20
  36. package/internals/components/PickerFieldUI.js +57 -49
  37. package/internals/components/PickerFieldUI.mjs +57 -49
  38. package/internals/hooks/useField/useField.js +15 -2
  39. package/internals/hooks/useField/useField.mjs +15 -2
  40. package/internals/hooks/useField/useField.utils.js +3 -9
  41. package/internals/hooks/useField/useField.utils.mjs +3 -9
  42. package/models/fields.d.mts +1 -1
  43. package/models/fields.d.ts +1 -1
  44. package/package.json +125 -125
@@ -11,10 +11,11 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
11
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
12
  var React = _interopRequireWildcard(require("react"));
13
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
- var _clsx = _interopRequireDefault(require("clsx"));
14
+ var _warning = require("@mui/x-internals/warning");
15
15
  var _styles = require("@mui/material/styles");
16
16
  var _refType = _interopRequireDefault(require("@mui/utils/refType"));
17
17
  var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
18
+ var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
18
19
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
19
20
  var _useId = _interopRequireDefault(require("@mui/utils/useId"));
20
21
  var _InputLabel = _interopRequireDefault(require("@mui/material/InputLabel"));
@@ -27,7 +28,7 @@ var _PickersInput = require("./PickersInput");
27
28
  var _useFieldOwnerState = require("../internals/hooks/useFieldOwnerState");
28
29
  var _usePickerTextFieldOwnerState = require("./usePickerTextFieldOwnerState");
29
30
  var _jsxRuntime = require("react/jsx-runtime");
30
- const _excluded = ["onFocus", "onBlur", "className", "classes", "color", "disabled", "error", "variant", "required", "hiddenLabel", "InputProps", "inputProps", "inputRef", "sectionListRef", "elements", "areAllSectionsEmpty", "onClick", "onKeyDown", "onKeyUp", "onPaste", "onInput", "endAdornment", "startAdornment", "tabIndex", "contentEditable", "focused", "value", "onChange", "fullWidth", "id", "name", "helperText", "FormHelperTextProps", "label", "InputLabelProps", "data-active-range-position"];
31
+ const _excluded = ["onFocus", "onBlur", "className", "classes", "color", "disabled", "error", "variant", "required", "hiddenLabel", "inputRef", "sectionListRef", "elements", "areAllSectionsEmpty", "onClick", "onKeyDown", "onKeyUp", "onPaste", "onInput", "endAdornment", "startAdornment", "tabIndex", "contentEditable", "focused", "value", "onChange", "fullWidth", "id", "name", "helperText", "label", "slots", "slotProps", "data-active-range-position"];
31
32
  const VARIANT_COMPONENT = {
32
33
  standard: _PickersInput.PickersInput,
33
34
  filled: _PickersFilledInput.PickersFilledInput,
@@ -55,6 +56,14 @@ const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRe
55
56
  props: inProps,
56
57
  name: 'MuiPickersTextField'
57
58
  });
59
+
60
+ // TODO v10: remove
61
+ if (process.env.NODE_ENV !== 'production') {
62
+ const legacyProps = inProps;
63
+ if (legacyProps.InputProps || legacyProps.inputProps || legacyProps.InputLabelProps || legacyProps.FormHelperTextProps) {
64
+ (0, _warning.warnOnce)(['MUI X: `PickersTextField` no longer supports the `InputProps`, `inputProps`, `InputLabelProps` and `FormHelperTextProps` props.', 'They are silently dropped, which can hide configuration bugs in JavaScript codebases that do not benefit from TypeScript checks.', 'Use `slotProps.input`, `slotProps.htmlInput`, `slotProps.inputLabel` and `slotProps.formHelperText` instead.', 'You can run the `migrate-text-field-props` codemod to migrate automatically.']);
65
+ }
66
+ }
58
67
  const {
59
68
  // Props used by FormControl
60
69
  onFocus,
@@ -68,8 +77,6 @@ const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRe
68
77
  required = false,
69
78
  hiddenLabel = false,
70
79
  // Props used by PickersInput
71
- InputProps,
72
- inputProps,
73
80
  inputRef,
74
81
  sectionListRef,
75
82
  elements,
@@ -91,10 +98,11 @@ const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRe
91
98
  name,
92
99
  // Props used by FormHelperText
93
100
  helperText,
94
- FormHelperTextProps,
95
101
  // Props used by InputLabel
96
102
  label,
97
- InputLabelProps,
103
+ // Slot system
104
+ slots,
105
+ slotProps,
98
106
  // @ts-ignore
99
107
  'data-active-range-position': dataActiveRangePosition
100
108
  } = props,
@@ -104,10 +112,12 @@ const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRe
104
112
  const id = (0, _useId.default)(idProp);
105
113
  const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
106
114
  const inputLabelId = label && id ? `${id}-label` : undefined;
115
+ const inputSlotProps = slotProps?.input;
116
+ const inputLabelSlotProps = slotProps?.inputLabel;
107
117
  const fieldOwnerState = (0, _useFieldOwnerState.useFieldOwnerState)({
108
118
  disabled: props.disabled,
109
119
  required: props.required,
110
- readOnly: InputProps?.readOnly
120
+ readOnly: inputSlotProps?.readOnly
111
121
  });
112
122
  const ownerState = React.useMemo(() => (0, _extends2.default)({}, fieldOwnerState, {
113
123
  isFieldValueEmpty: areAllSectionsEmpty,
@@ -116,40 +126,51 @@ const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRe
116
126
  inputSize: props.size ?? 'medium',
117
127
  inputColor: color ?? 'primary',
118
128
  isInputInFullWidth: fullWidth ?? false,
119
- hasStartAdornment: Boolean(startAdornment ?? InputProps?.startAdornment),
120
- hasEndAdornment: Boolean(endAdornment ?? InputProps?.endAdornment),
129
+ hasStartAdornment: Boolean(startAdornment ?? inputSlotProps?.startAdornment),
130
+ hasEndAdornment: Boolean(endAdornment ?? inputSlotProps?.endAdornment),
121
131
  inputHasLabel: !!label,
122
- isLabelShrunk: Boolean(InputLabelProps?.shrink)
123
- }), [fieldOwnerState, areAllSectionsEmpty, focused, error, props.size, color, fullWidth, startAdornment, endAdornment, InputProps?.startAdornment, InputProps?.endAdornment, label, InputLabelProps?.shrink]);
132
+ isLabelShrunk: Boolean(inputLabelSlotProps?.shrink)
133
+ }), [fieldOwnerState, areAllSectionsEmpty, focused, error, props.size, color, fullWidth, startAdornment, endAdornment, inputSlotProps?.startAdornment, inputSlotProps?.endAdornment, label, inputLabelSlotProps?.shrink]);
124
134
  const classes = useUtilityClasses(classesProp, ownerState);
125
- const PickersInputComponent = VARIANT_COMPONENT[variant];
135
+ const PickersInputComponent = slots?.input ?? VARIANT_COMPONENT[variant];
136
+ const RootComponent = slots?.root ?? PickersTextFieldRoot;
137
+ const InputLabelComponent = slots?.inputLabel ?? _InputLabel.default;
138
+ const FormHelperTextComponent = slots?.formHelperText ?? _FormHelperText.default;
126
139
  const inputAdditionalProps = {};
127
140
  if (variant === 'outlined') {
128
- if (InputLabelProps && typeof InputLabelProps.shrink !== 'undefined') {
129
- inputAdditionalProps.notched = InputLabelProps.shrink;
141
+ if (inputLabelSlotProps && typeof inputLabelSlotProps.shrink !== 'undefined') {
142
+ inputAdditionalProps.notched = inputLabelSlotProps.shrink;
130
143
  }
131
144
  inputAdditionalProps.label = label;
132
145
  } else if (variant === 'filled') {
133
146
  inputAdditionalProps.hiddenLabel = hiddenLabel;
134
147
  }
148
+ const rootSlotProps = (0, _useSlotProps.default)({
149
+ elementType: RootComponent,
150
+ externalSlotProps: slotProps?.root,
151
+ externalForwardedProps: (0, _extends2.default)({}, other, {
152
+ className
153
+ }),
154
+ additionalProps: {
155
+ ref: handleRootRef,
156
+ focused,
157
+ disabled,
158
+ variant,
159
+ error,
160
+ color,
161
+ fullWidth,
162
+ required
163
+ },
164
+ className: classes.root,
165
+ ownerState
166
+ });
135
167
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_usePickerTextFieldOwnerState.PickerTextFieldOwnerStateContext.Provider, {
136
168
  value: ownerState,
137
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(PickersTextFieldRoot, (0, _extends2.default)({
138
- className: (0, _clsx.default)(classes.root, className),
139
- ref: handleRootRef,
140
- focused: focused,
141
- disabled: disabled,
142
- variant: variant,
143
- error: error,
144
- color: color,
145
- fullWidth: fullWidth,
146
- required: required,
147
- ownerState: ownerState
148
- }, other, {
149
- children: [label != null && label !== '' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputLabel.default, (0, _extends2.default)({
169
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(RootComponent, (0, _extends2.default)({}, rootSlotProps, {
170
+ children: [label != null && label !== '' && /*#__PURE__*/(0, _jsxRuntime.jsx)(InputLabelComponent, (0, _extends2.default)({
150
171
  htmlFor: id,
151
172
  id: inputLabelId
152
- }, InputLabelProps, {
173
+ }, inputLabelSlotProps, {
153
174
  children: label
154
175
  })), /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersInputComponent, (0, _extends2.default)({
155
176
  elements: elements,
@@ -169,7 +190,6 @@ const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRe
169
190
  onChange: onChange,
170
191
  id: id,
171
192
  fullWidth: fullWidth,
172
- inputProps: inputProps,
173
193
  inputRef: inputRef,
174
194
  sectionListRef: sectionListRef,
175
195
  label: label,
@@ -179,9 +199,16 @@ const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRe
179
199
  "aria-describedby": helperTextId,
180
200
  "aria-live": helperTextId ? 'polite' : undefined,
181
201
  "data-active-range-position": dataActiveRangePosition
182
- }, inputAdditionalProps, InputProps)), helperText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormHelperText.default, (0, _extends2.default)({
202
+ }, inputAdditionalProps, inputSlotProps, {
203
+ slots: (0, _extends2.default)({}, inputSlotProps?.slots, slots?.htmlInput !== undefined && {
204
+ htmlInput: slots.htmlInput
205
+ }),
206
+ slotProps: (0, _extends2.default)({}, inputSlotProps?.slotProps, slotProps?.htmlInput !== undefined && {
207
+ htmlInput: slotProps.htmlInput
208
+ })
209
+ })), helperText && /*#__PURE__*/(0, _jsxRuntime.jsx)(FormHelperTextComponent, (0, _extends2.default)({
183
210
  id: helperTextId
184
- }, FormHelperTextProps, {
211
+ }, slotProps?.formHelperText, {
185
212
  children: helperText
186
213
  }))]
187
214
  }))
@@ -237,11 +264,6 @@ process.env.NODE_ENV !== "production" ? PickersTextField.propTypes = {
237
264
  * If `true`, the component is displayed in focused state.
238
265
  */
239
266
  focused: _propTypes.default.bool,
240
- /**
241
- * Props applied to the [`FormHelperText`](https://mui.com/material-ui/api/form-helper-text/) element.
242
- * @deprecated Use `slotProps.formHelperText` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
243
- */
244
- FormHelperTextProps: _propTypes.default.object,
245
267
  /**
246
268
  * If `true`, the input will take up the full width of its container.
247
269
  * @default false
@@ -262,25 +284,6 @@ process.env.NODE_ENV !== "production" ? PickersTextField.propTypes = {
262
284
  * The id of the `input` element.
263
285
  */
264
286
  id: _propTypes.default.string,
265
- /**
266
- * Props applied to the [`InputLabel`](https://mui.com/material-ui/api/input-label/) element.
267
- * Pointer events like `onClick` are enabled if and only if `shrink` is `true`.
268
- * @deprecated Use `slotProps.inputLabel` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
269
- */
270
- InputLabelProps: _propTypes.default.object,
271
- /**
272
- * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#attributes) applied to the `input` element.
273
- * @deprecated Use `slotProps.htmlInput` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
274
- */
275
- inputProps: _propTypes.default.object,
276
- /**
277
- * Props applied to the Input element.
278
- * It will be a [`FilledInput`](https://mui.com/material-ui/api/filled-input/),
279
- * [`OutlinedInput`](https://mui.com/material-ui/api/outlined-input/) or [`Input`](https://mui.com/material-ui/api/input/)
280
- * component depending on the `variant` prop value.
281
- * @deprecated Use `slotProps.input` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
282
- */
283
- InputProps: _propTypes.default.object,
284
287
  /**
285
288
  * Pass a ref to the `input` element.
286
289
  */
@@ -324,6 +327,16 @@ process.env.NODE_ENV !== "production" ? PickersTextField.propTypes = {
324
327
  * @default 'medium'
325
328
  */
326
329
  size: _propTypes.default.oneOf(['medium', 'small']),
330
+ /**
331
+ * The props used for each component slot.
332
+ * @default {}
333
+ */
334
+ slotProps: _propTypes.default.object,
335
+ /**
336
+ * The components used for each slot inside.
337
+ * @default {}
338
+ */
339
+ slots: _propTypes.default.object,
327
340
  /**
328
341
  * Start `InputAdornment` for this component.
329
342
  */
@@ -2,13 +2,14 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["onFocus", "onBlur", "className", "classes", "color", "disabled", "error", "variant", "required", "hiddenLabel", "InputProps", "inputProps", "inputRef", "sectionListRef", "elements", "areAllSectionsEmpty", "onClick", "onKeyDown", "onKeyUp", "onPaste", "onInput", "endAdornment", "startAdornment", "tabIndex", "contentEditable", "focused", "value", "onChange", "fullWidth", "id", "name", "helperText", "FormHelperTextProps", "label", "InputLabelProps", "data-active-range-position"];
5
+ const _excluded = ["onFocus", "onBlur", "className", "classes", "color", "disabled", "error", "variant", "required", "hiddenLabel", "inputRef", "sectionListRef", "elements", "areAllSectionsEmpty", "onClick", "onKeyDown", "onKeyUp", "onPaste", "onInput", "endAdornment", "startAdornment", "tabIndex", "contentEditable", "focused", "value", "onChange", "fullWidth", "id", "name", "helperText", "label", "slots", "slotProps", "data-active-range-position"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import clsx from 'clsx';
8
+ import { warnOnce } from '@mui/x-internals/warning';
9
9
  import { styled, useThemeProps } from '@mui/material/styles';
10
10
  import refType from '@mui/utils/refType';
11
11
  import useForkRef from '@mui/utils/useForkRef';
12
+ import useSlotProps from '@mui/utils/useSlotProps';
12
13
  import composeClasses from '@mui/utils/composeClasses';
13
14
  import useId from '@mui/utils/useId';
14
15
  import InputLabel from '@mui/material/InputLabel';
@@ -48,6 +49,14 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
48
49
  props: inProps,
49
50
  name: 'MuiPickersTextField'
50
51
  });
52
+
53
+ // TODO v10: remove
54
+ if (process.env.NODE_ENV !== 'production') {
55
+ const legacyProps = inProps;
56
+ if (legacyProps.InputProps || legacyProps.inputProps || legacyProps.InputLabelProps || legacyProps.FormHelperTextProps) {
57
+ warnOnce(['MUI X: `PickersTextField` no longer supports the `InputProps`, `inputProps`, `InputLabelProps` and `FormHelperTextProps` props.', 'They are silently dropped, which can hide configuration bugs in JavaScript codebases that do not benefit from TypeScript checks.', 'Use `slotProps.input`, `slotProps.htmlInput`, `slotProps.inputLabel` and `slotProps.formHelperText` instead.', 'You can run the `migrate-text-field-props` codemod to migrate automatically.']);
58
+ }
59
+ }
51
60
  const {
52
61
  // Props used by FormControl
53
62
  onFocus,
@@ -61,8 +70,6 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
61
70
  required = false,
62
71
  hiddenLabel = false,
63
72
  // Props used by PickersInput
64
- InputProps,
65
- inputProps,
66
73
  inputRef,
67
74
  sectionListRef,
68
75
  elements,
@@ -84,10 +91,11 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
84
91
  name,
85
92
  // Props used by FormHelperText
86
93
  helperText,
87
- FormHelperTextProps,
88
94
  // Props used by InputLabel
89
95
  label,
90
- InputLabelProps,
96
+ // Slot system
97
+ slots,
98
+ slotProps,
91
99
  // @ts-ignore
92
100
  'data-active-range-position': dataActiveRangePosition
93
101
  } = props,
@@ -97,10 +105,12 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
97
105
  const id = useId(idProp);
98
106
  const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
99
107
  const inputLabelId = label && id ? `${id}-label` : undefined;
108
+ const inputSlotProps = slotProps?.input;
109
+ const inputLabelSlotProps = slotProps?.inputLabel;
100
110
  const fieldOwnerState = useFieldOwnerState({
101
111
  disabled: props.disabled,
102
112
  required: props.required,
103
- readOnly: InputProps?.readOnly
113
+ readOnly: inputSlotProps?.readOnly
104
114
  });
105
115
  const ownerState = React.useMemo(() => _extends({}, fieldOwnerState, {
106
116
  isFieldValueEmpty: areAllSectionsEmpty,
@@ -109,40 +119,51 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
109
119
  inputSize: props.size ?? 'medium',
110
120
  inputColor: color ?? 'primary',
111
121
  isInputInFullWidth: fullWidth ?? false,
112
- hasStartAdornment: Boolean(startAdornment ?? InputProps?.startAdornment),
113
- hasEndAdornment: Boolean(endAdornment ?? InputProps?.endAdornment),
122
+ hasStartAdornment: Boolean(startAdornment ?? inputSlotProps?.startAdornment),
123
+ hasEndAdornment: Boolean(endAdornment ?? inputSlotProps?.endAdornment),
114
124
  inputHasLabel: !!label,
115
- isLabelShrunk: Boolean(InputLabelProps?.shrink)
116
- }), [fieldOwnerState, areAllSectionsEmpty, focused, error, props.size, color, fullWidth, startAdornment, endAdornment, InputProps?.startAdornment, InputProps?.endAdornment, label, InputLabelProps?.shrink]);
125
+ isLabelShrunk: Boolean(inputLabelSlotProps?.shrink)
126
+ }), [fieldOwnerState, areAllSectionsEmpty, focused, error, props.size, color, fullWidth, startAdornment, endAdornment, inputSlotProps?.startAdornment, inputSlotProps?.endAdornment, label, inputLabelSlotProps?.shrink]);
117
127
  const classes = useUtilityClasses(classesProp, ownerState);
118
- const PickersInputComponent = VARIANT_COMPONENT[variant];
128
+ const PickersInputComponent = slots?.input ?? VARIANT_COMPONENT[variant];
129
+ const RootComponent = slots?.root ?? PickersTextFieldRoot;
130
+ const InputLabelComponent = slots?.inputLabel ?? InputLabel;
131
+ const FormHelperTextComponent = slots?.formHelperText ?? FormHelperText;
119
132
  const inputAdditionalProps = {};
120
133
  if (variant === 'outlined') {
121
- if (InputLabelProps && typeof InputLabelProps.shrink !== 'undefined') {
122
- inputAdditionalProps.notched = InputLabelProps.shrink;
134
+ if (inputLabelSlotProps && typeof inputLabelSlotProps.shrink !== 'undefined') {
135
+ inputAdditionalProps.notched = inputLabelSlotProps.shrink;
123
136
  }
124
137
  inputAdditionalProps.label = label;
125
138
  } else if (variant === 'filled') {
126
139
  inputAdditionalProps.hiddenLabel = hiddenLabel;
127
140
  }
141
+ const rootSlotProps = useSlotProps({
142
+ elementType: RootComponent,
143
+ externalSlotProps: slotProps?.root,
144
+ externalForwardedProps: _extends({}, other, {
145
+ className
146
+ }),
147
+ additionalProps: {
148
+ ref: handleRootRef,
149
+ focused,
150
+ disabled,
151
+ variant,
152
+ error,
153
+ color,
154
+ fullWidth,
155
+ required
156
+ },
157
+ className: classes.root,
158
+ ownerState
159
+ });
128
160
  return /*#__PURE__*/_jsx(PickerTextFieldOwnerStateContext.Provider, {
129
161
  value: ownerState,
130
- children: /*#__PURE__*/_jsxs(PickersTextFieldRoot, _extends({
131
- className: clsx(classes.root, className),
132
- ref: handleRootRef,
133
- focused: focused,
134
- disabled: disabled,
135
- variant: variant,
136
- error: error,
137
- color: color,
138
- fullWidth: fullWidth,
139
- required: required,
140
- ownerState: ownerState
141
- }, other, {
142
- children: [label != null && label !== '' && /*#__PURE__*/_jsx(InputLabel, _extends({
162
+ children: /*#__PURE__*/_jsxs(RootComponent, _extends({}, rootSlotProps, {
163
+ children: [label != null && label !== '' && /*#__PURE__*/_jsx(InputLabelComponent, _extends({
143
164
  htmlFor: id,
144
165
  id: inputLabelId
145
- }, InputLabelProps, {
166
+ }, inputLabelSlotProps, {
146
167
  children: label
147
168
  })), /*#__PURE__*/_jsx(PickersInputComponent, _extends({
148
169
  elements: elements,
@@ -162,7 +183,6 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
162
183
  onChange: onChange,
163
184
  id: id,
164
185
  fullWidth: fullWidth,
165
- inputProps: inputProps,
166
186
  inputRef: inputRef,
167
187
  sectionListRef: sectionListRef,
168
188
  label: label,
@@ -172,9 +192,16 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
172
192
  "aria-describedby": helperTextId,
173
193
  "aria-live": helperTextId ? 'polite' : undefined,
174
194
  "data-active-range-position": dataActiveRangePosition
175
- }, inputAdditionalProps, InputProps)), helperText && /*#__PURE__*/_jsx(FormHelperText, _extends({
195
+ }, inputAdditionalProps, inputSlotProps, {
196
+ slots: _extends({}, inputSlotProps?.slots, slots?.htmlInput !== undefined && {
197
+ htmlInput: slots.htmlInput
198
+ }),
199
+ slotProps: _extends({}, inputSlotProps?.slotProps, slotProps?.htmlInput !== undefined && {
200
+ htmlInput: slotProps.htmlInput
201
+ })
202
+ })), helperText && /*#__PURE__*/_jsx(FormHelperTextComponent, _extends({
176
203
  id: helperTextId
177
- }, FormHelperTextProps, {
204
+ }, slotProps?.formHelperText, {
178
205
  children: helperText
179
206
  }))]
180
207
  }))
@@ -230,11 +257,6 @@ process.env.NODE_ENV !== "production" ? PickersTextField.propTypes = {
230
257
  * If `true`, the component is displayed in focused state.
231
258
  */
232
259
  focused: PropTypes.bool,
233
- /**
234
- * Props applied to the [`FormHelperText`](https://mui.com/material-ui/api/form-helper-text/) element.
235
- * @deprecated Use `slotProps.formHelperText` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
236
- */
237
- FormHelperTextProps: PropTypes.object,
238
260
  /**
239
261
  * If `true`, the input will take up the full width of its container.
240
262
  * @default false
@@ -255,25 +277,6 @@ process.env.NODE_ENV !== "production" ? PickersTextField.propTypes = {
255
277
  * The id of the `input` element.
256
278
  */
257
279
  id: PropTypes.string,
258
- /**
259
- * Props applied to the [`InputLabel`](https://mui.com/material-ui/api/input-label/) element.
260
- * Pointer events like `onClick` are enabled if and only if `shrink` is `true`.
261
- * @deprecated Use `slotProps.inputLabel` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
262
- */
263
- InputLabelProps: PropTypes.object,
264
- /**
265
- * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#attributes) applied to the `input` element.
266
- * @deprecated Use `slotProps.htmlInput` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
267
- */
268
- inputProps: PropTypes.object,
269
- /**
270
- * Props applied to the Input element.
271
- * It will be a [`FilledInput`](https://mui.com/material-ui/api/filled-input/),
272
- * [`OutlinedInput`](https://mui.com/material-ui/api/outlined-input/) or [`Input`](https://mui.com/material-ui/api/input/)
273
- * component depending on the `variant` prop value.
274
- * @deprecated Use `slotProps.input` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
275
- */
276
- InputProps: PropTypes.object,
277
280
  /**
278
281
  * Pass a ref to the `input` element.
279
282
  */
@@ -317,6 +320,16 @@ process.env.NODE_ENV !== "production" ? PickersTextField.propTypes = {
317
320
  * @default 'medium'
318
321
  */
319
322
  size: PropTypes.oneOf(['medium', 'small']),
323
+ /**
324
+ * The props used for each component slot.
325
+ * @default {}
326
+ */
327
+ slotProps: PropTypes.object,
328
+ /**
329
+ * The components used for each slot inside.
330
+ * @default {}
331
+ */
332
+ slots: PropTypes.object,
320
333
  /**
321
334
  * Start `InputAdornment` for this component.
322
335
  */
@@ -3,10 +3,57 @@ import { FormControlProps } from '@mui/material/FormControl';
3
3
  import { FormHelperTextProps } from '@mui/material/FormHelperText';
4
4
  import { InputLabelProps } from '@mui/material/InputLabel';
5
5
  import { TextFieldVariants } from '@mui/material/TextField';
6
- import { PickersInputPropsUsedByField } from "./PickersInputBase/PickersInputBase.types.mjs";
6
+ import { PickersInputBaseProps, PickersInputPropsUsedByField } from "./PickersInputBase/PickersInputBase.types.mjs";
7
7
  import type { PickersInputProps } from "./PickersInput/index.mjs";
8
8
  import type { PickersOutlinedInputProps } from "./PickersOutlinedInput/index.mjs";
9
9
  import type { PickersFilledInputProps } from "./PickersFilledInput/index.mjs";
10
+ export interface PickersTextFieldSlots {
11
+ /**
12
+ * The component used for the root slot.
13
+ * @default FormControl
14
+ */
15
+ root?: React.ElementType;
16
+ /**
17
+ * The component used for the input slot.
18
+ * Defaults to one of `PickersInput`, `PickersFilledInput`, `PickersOutlinedInput` based on `variant`.
19
+ * @default PickersOutlinedInput
20
+ */
21
+ input?: React.ElementType;
22
+ /**
23
+ * The component used for the input label slot.
24
+ * @default InputLabel
25
+ */
26
+ inputLabel?: React.ElementType;
27
+ /**
28
+ * The component rendered as the underlying hidden `<input>` element.
29
+ * @default PickersInputBaseInput
30
+ */
31
+ htmlInput?: React.ElementType;
32
+ /**
33
+ * The component used for the form helper text slot.
34
+ * @default FormHelperText
35
+ */
36
+ formHelperText?: React.ElementType;
37
+ }
38
+ export interface PickersTextFieldSlotProps<InputPropsType extends PickersInputBaseProps> {
39
+ root?: Partial<FormControlProps>;
40
+ input?: Partial<InputPropsType>;
41
+ inputLabel?: Partial<InputLabelProps>;
42
+ htmlInput?: React.ComponentPropsWithRef<'input'>;
43
+ formHelperText?: Partial<FormHelperTextProps>;
44
+ }
45
+ export interface PickersTextFieldSlotsAndSlotProps<InputPropsType extends PickersInputBaseProps> {
46
+ /**
47
+ * The components used for each slot inside.
48
+ * @default {}
49
+ */
50
+ slots?: PickersTextFieldSlots;
51
+ /**
52
+ * The props used for each component slot.
53
+ * @default {}
54
+ */
55
+ slotProps?: PickersTextFieldSlotProps<InputPropsType>;
56
+ }
10
57
  interface PickersTextFieldPropsUsedByField {
11
58
  onFocus: React.FocusEventHandler<HTMLDivElement>;
12
59
  onBlur: React.FocusEventHandler<HTMLDivElement>;
@@ -17,67 +64,32 @@ interface PickersTextFieldPropsUsedByField {
17
64
  */
18
65
  error: boolean;
19
66
  }
20
- export interface PickersBaseTextFieldProps extends PickersInputPropsUsedByField, PickersTextFieldPropsUsedByField, Omit<FormControlProps, keyof PickersInputPropsUsedByField | keyof PickersTextFieldPropsUsedByField> {
21
- /**
22
- * Props applied to the [`FormHelperText`](https://mui.com/material-ui/api/form-helper-text/) element.
23
- * @deprecated Use `slotProps.formHelperText` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
24
- */
25
- FormHelperTextProps?: Partial<FormHelperTextProps>;
26
- /**
27
- * Props applied to the [`InputLabel`](https://mui.com/material-ui/api/input-label/) element.
28
- * Pointer events like `onClick` are enabled if and only if `shrink` is `true`.
29
- * @deprecated Use `slotProps.inputLabel` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
30
- */
31
- InputLabelProps?: Partial<InputLabelProps>;
67
+ export interface PickersBaseTextFieldProps extends PickersInputPropsUsedByField, PickersTextFieldPropsUsedByField, Omit<FormControlProps, keyof PickersInputPropsUsedByField | keyof PickersTextFieldPropsUsedByField | 'slots' | 'slotProps'> {
32
68
  /**
33
69
  * The helper text content.
34
70
  */
35
71
  helperText?: React.ReactNode;
36
72
  }
37
- export interface PickersStandardTextFieldProps extends PickersBaseTextFieldProps {
73
+ export interface PickersStandardTextFieldProps extends PickersBaseTextFieldProps, PickersTextFieldSlotsAndSlotProps<PickersInputProps> {
38
74
  /**
39
75
  * The variant to use.
40
76
  * @default 'outlined'
41
77
  */
42
78
  variant?: 'standard';
43
- /**
44
- * Props applied to the Input element.
45
- * It will be a [`FilledInput`](https://mui.com/material-ui/api/filled-input/),
46
- * [`OutlinedInput`](https://mui.com/material-ui/api/outlined-input/) or [`Input`](https://mui.com/material-ui/api/input/)
47
- * component depending on the `variant` prop value.
48
- * @deprecated Use `slotProps.input` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
49
- */
50
- InputProps?: Partial<PickersInputProps>;
51
79
  }
52
- export interface PickersOutlinedTextFieldProps extends PickersBaseTextFieldProps {
80
+ export interface PickersOutlinedTextFieldProps extends PickersBaseTextFieldProps, PickersTextFieldSlotsAndSlotProps<PickersOutlinedInputProps> {
53
81
  /**
54
82
  * The variant to use.
55
83
  * @default 'outlined'
56
84
  */
57
85
  variant?: 'outlined';
58
- /**
59
- * Props applied to the Input element.
60
- * It will be a [`FilledInput`](https://mui.com/material-ui/api/filled-input/),
61
- * [`OutlinedInput`](https://mui.com/material-ui/api/outlined-input/) or [`Input`](https://mui.com/material-ui/api/input/)
62
- * component depending on the `variant` prop value.
63
- * @deprecated Use `slotProps.input` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
64
- */
65
- InputProps?: Partial<PickersOutlinedInputProps>;
66
86
  }
67
- export interface PickersFilledTextFieldProps extends PickersBaseTextFieldProps {
87
+ export interface PickersFilledTextFieldProps extends PickersBaseTextFieldProps, PickersTextFieldSlotsAndSlotProps<PickersFilledInputProps> {
68
88
  /**
69
89
  * The variant to use.
70
90
  * @default 'outlined'
71
91
  */
72
92
  variant?: 'filled';
73
- /**
74
- * Props applied to the Input element.
75
- * It will be a [`FilledInput`](https://mui.com/material-ui/api/filled-input/),
76
- * [`OutlinedInput`](https://mui.com/material-ui/api/outlined-input/) or [`Input`](https://mui.com/material-ui/api/input/)
77
- * component depending on the `variant` prop value.
78
- * @deprecated Use `slotProps.input` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
79
- */
80
- InputProps?: Partial<PickersFilledInputProps>;
81
93
  }
82
94
  export type PickersTextFieldProps<Variant extends TextFieldVariants = TextFieldVariants> = Variant extends 'filled' ? PickersFilledTextFieldProps : Variant extends 'standard' ? PickersStandardTextFieldProps : PickersOutlinedTextFieldProps;
83
95
  export {};