@mui/x-date-pickers 9.0.0-rc.0 → 9.0.0

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 (40) hide show
  1. package/CHANGELOG.md +114 -2
  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 +3 -18
  35. package/internals/components/PickerFieldUI.d.ts +3 -18
  36. package/internals/components/PickerFieldUI.js +56 -47
  37. package/internals/components/PickerFieldUI.mjs +56 -47
  38. package/models/fields.d.mts +1 -1
  39. package/models/fields.d.ts +1 -1
  40. package/package.json +5 -5
@@ -2,12 +2,12 @@
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 = ["InputProps", "readOnly", "onClear", "clearable", "clearButtonPosition", "openPickerButtonPosition", "openPickerAriaLabel"],
5
+ const _excluded = ["readOnly", "onClear", "clearable", "clearButtonPosition", "openPickerButtonPosition", "openPickerAriaLabel", "InputProps", "inputProps", "InputLabelProps", "FormHelperTextProps"],
6
6
  _excluded2 = ["ownerState"],
7
7
  _excluded3 = ["ownerState"],
8
8
  _excluded4 = ["ownerState"],
9
9
  _excluded5 = ["ownerState"],
10
- _excluded6 = ["InputProps", "inputProps"];
10
+ _excluded6 = ["InputProps", "inputProps", "InputLabelProps", "FormHelperTextProps"];
11
11
  import * as React from 'react';
12
12
  import useEventCallback from '@mui/utils/useEventCallback';
13
13
  import useForkRef from '@mui/utils/useForkRef';
@@ -15,41 +15,49 @@ import resolveComponentProps from '@mui/utils/resolveComponentProps';
15
15
  import MuiIconButton from '@mui/material/IconButton';
16
16
  import MuiInputAdornment from '@mui/material/InputAdornment';
17
17
  import useSlotProps from '@mui/utils/useSlotProps';
18
+ import { warnOnce } from '@mui/x-internals/warning';
18
19
  import { useFieldOwnerState } from "../hooks/useFieldOwnerState.mjs";
19
20
  import { usePickerTranslations } from "../../hooks/index.mjs";
20
21
  import { ClearIcon as MuiClearIcon } from "../../icons/index.mjs";
21
22
  import { useNullablePickerContext } from "../hooks/useNullablePickerContext.mjs";
22
23
  import { PickersTextField } from "../../PickersTextField/index.mjs";
23
24
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
- const noop = () => {};
25
25
  export const cleanFieldResponse = fieldResponse => {
26
- const {
27
- InputProps,
26
+ const _ref = fieldResponse,
27
+ {
28
28
  readOnly,
29
29
  onClear,
30
30
  clearable,
31
31
  clearButtonPosition,
32
32
  openPickerButtonPosition,
33
- openPickerAriaLabel
34
- } = fieldResponse,
35
- other = _objectWithoutPropertiesLoose(fieldResponse, _excluded);
36
- const mergedInputProps = other?.slotProps?.input ? mergeSlotProps(other?.slotProps?.input, InputProps) : noop;
33
+ openPickerAriaLabel,
34
+ // TODO v10: remove
35
+ // Explicitly discard legacy props that are no longer supported on `PickersTextField`.
36
+ // Without this, any leftover values would silently leak into `...other` and end up spread
37
+ // as unknown attributes on the underlying form control.
38
+ InputProps: legacyInputProps,
39
+ inputProps: legacyHtmlInputProps,
40
+ InputLabelProps: legacyInputLabelProps,
41
+ FormHelperTextProps: legacyFormHelperTextProps
42
+ } = _ref,
43
+ other = _objectWithoutPropertiesLoose(_ref, _excluded);
44
+ if (process.env.NODE_ENV !== 'production') {
45
+ if (legacyInputProps || legacyHtmlInputProps || legacyInputLabelProps || legacyFormHelperTextProps) {
46
+ warnOnce(['MUI X: The `InputProps`, `inputProps`, `InputLabelProps` and `FormHelperTextProps` props are no longer supported on Picker / Field components.', 'They have been silently dropped because they would otherwise be forwarded as unknown attributes on the underlying form control.', 'Use the `slotProps` shape instead (`slotProps.input`, `slotProps.htmlInput`, `slotProps.inputLabel`, `slotProps.formHelperText`).', 'See https://mui.com/x/migration/migration-pickers-v8/#textfield-props for migration details.']);
47
+ }
48
+ }
37
49
  return {
38
50
  clearable,
39
51
  onClear,
40
52
  clearButtonPosition,
41
53
  openPickerButtonPosition,
42
54
  openPickerAriaLabel,
43
- textFieldProps: _extends({}, other, other?.slotProps?.input || other?.slotProps?.htmlInput ? {
55
+ textFieldProps: _extends({}, other, {
44
56
  slotProps: _extends({}, other?.slotProps, {
45
- input: ownerState => _extends({}, resolveComponentProps(mergedInputProps, ownerState), {
57
+ input: _extends({}, other?.slotProps?.input, {
46
58
  readOnly
47
59
  })
48
60
  })
49
- } : {
50
- InputProps: _extends({}, InputProps ?? {}, {
51
- readOnly
52
- })
53
61
  })
54
62
  };
55
63
  };
@@ -165,13 +173,14 @@ export function PickerFieldUI(props) {
165
173
  ownerState
166
174
  });
167
175
  textFieldProps.ref = useForkRef(textFieldProps.ref, pickerContext?.rootRef);
168
- const additionalTextFieldInputProps = {};
169
- const textFieldInputProps = resolveComponentProps(textFieldProps?.slotProps?.input ?? textFieldProps.InputProps, ownerState);
176
+ const externalInputSlotProps = textFieldProps.slotProps?.input;
177
+ const additionalInputSlotProps = {};
178
+ const forkedInputRef = useForkRef(externalInputSlotProps?.ref, pickerContext?.triggerRef);
170
179
  if (pickerContext) {
171
- additionalTextFieldInputProps.ref = pickerContext.triggerRef;
180
+ additionalInputSlotProps.ref = forkedInputRef;
172
181
  }
173
- if (!textFieldInputProps?.startAdornment && (clearButtonPosition === 'start' || openPickerButtonPosition === 'start')) {
174
- additionalTextFieldInputProps.startAdornment = /*#__PURE__*/_jsxs(InputAdornment, _extends({}, startInputAdornmentProps, {
182
+ if (!externalInputSlotProps?.startAdornment && (clearButtonPosition === 'start' || openPickerButtonPosition === 'start')) {
183
+ additionalInputSlotProps.startAdornment = /*#__PURE__*/_jsxs(InputAdornment, _extends({}, startInputAdornmentProps, {
175
184
  children: [openPickerButtonPosition === 'start' && /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
176
185
  children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, openPickerIconProps))
177
186
  })), clearButtonPosition === 'start' && /*#__PURE__*/_jsx(ClearButton, _extends({}, clearButtonProps, {
@@ -179,8 +188,8 @@ export function PickerFieldUI(props) {
179
188
  }))]
180
189
  }));
181
190
  }
182
- if (!textFieldInputProps?.endAdornment && (clearButtonPosition === 'end' || openPickerButtonPosition === 'end')) {
183
- additionalTextFieldInputProps.endAdornment = /*#__PURE__*/_jsxs(InputAdornment, _extends({}, endInputAdornmentProps, {
191
+ if (!externalInputSlotProps?.endAdornment && (clearButtonPosition === 'end' || openPickerButtonPosition === 'end')) {
192
+ additionalInputSlotProps.endAdornment = /*#__PURE__*/_jsxs(InputAdornment, _extends({}, endInputAdornmentProps, {
184
193
  children: [clearButtonPosition === 'end' && /*#__PURE__*/_jsx(ClearButton, _extends({}, clearButtonProps, {
185
194
  children: /*#__PURE__*/_jsx(ClearIcon, _extends({}, clearIconProps))
186
195
  })), openPickerButtonPosition === 'end' && /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
@@ -189,8 +198,8 @@ export function PickerFieldUI(props) {
189
198
  }));
190
199
  }
191
200
  // handle the case of showing custom `inputAdornment` for Field components
192
- if (!additionalTextFieldInputProps?.endAdornment && !additionalTextFieldInputProps?.startAdornment && pickerFieldUIContext.slots.inputAdornment) {
193
- additionalTextFieldInputProps.endAdornment = /*#__PURE__*/_jsx(InputAdornment, _extends({}, endInputAdornmentProps));
201
+ if (!additionalInputSlotProps.endAdornment && !additionalInputSlotProps.startAdornment && pickerFieldUIContext.slots.inputAdornment) {
202
+ additionalInputSlotProps.endAdornment = /*#__PURE__*/_jsx(InputAdornment, _extends({}, endInputAdornmentProps));
194
203
  }
195
204
  if (clearButtonPosition != null) {
196
205
  textFieldProps.sx = [{
@@ -209,19 +218,10 @@ export function PickerFieldUI(props) {
209
218
  }
210
219
  }, ...(Array.isArray(textFieldProps.sx) ? textFieldProps.sx : [textFieldProps.sx])];
211
220
  }
212
- const resolvedTextFieldInputProps = textFieldProps?.slotProps?.input ? resolveComponentProps(mergeSlotProps(textFieldInputProps, additionalTextFieldInputProps), ownerState) : _extends({}, textFieldInputProps, additionalTextFieldInputProps);
213
-
214
- // We need to resolve the `inputProps` since we are messing with those props in this component.
215
- textFieldProps.inputProps = textFieldProps?.slotProps?.htmlInput ? resolveComponentProps(textFieldProps.slotProps.htmlInput, ownerState) : textFieldProps.inputProps;
216
-
217
- // Remove the `input` slotProps to avoid them overriding the manually resolved `InputProps`.
218
- // `slotProps` would take precedence over `InputProps`.
219
- delete textFieldProps?.slotProps?.input;
220
- // Remove the `slotProps` on `PickersTextField` as they are not supported.
221
- delete textFieldProps?.slotProps;
222
- return /*#__PURE__*/_jsx(TextField, _extends({}, textFieldProps, {
223
- InputProps: resolvedTextFieldInputProps
224
- }));
221
+ textFieldProps.slotProps = _extends({}, textFieldProps.slotProps, {
222
+ input: _extends({}, externalInputSlotProps, additionalInputSlotProps)
223
+ });
224
+ return /*#__PURE__*/_jsx(TextField, _extends({}, textFieldProps));
225
225
  }
226
226
  export function mergeSlotProps(slotPropsA, slotPropsB) {
227
227
  if (!slotPropsA) {
@@ -249,15 +249,28 @@ export function useFieldTextFieldProps(parameters) {
249
249
  const pickerFieldUIContext = React.useContext(PickerFieldUIContext);
250
250
  const pickerContext = useNullablePickerContext();
251
251
  const ownerState = useFieldOwnerState(externalForwardedProps);
252
- const {
253
- InputProps,
254
- inputProps
255
- } = externalForwardedProps,
256
- otherExternalForwardedProps = _objectWithoutPropertiesLoose(externalForwardedProps, _excluded6);
252
+
253
+ // TODO v10: remove
254
+ // Strip the legacy `InputProps` / `inputProps` / `InputLabelProps` / `FormHelperTextProps`
255
+ // before they reach `PickersTextField`, which would silently ignore them. JS users without
256
+ // TypeScript checks would otherwise see their configuration vanish.
257
+ const _ref2 = externalForwardedProps ?? {},
258
+ {
259
+ InputProps: legacyInputProps,
260
+ inputProps: legacyHtmlInputProps,
261
+ InputLabelProps: legacyInputLabelProps,
262
+ FormHelperTextProps: legacyFormHelperTextProps
263
+ } = _ref2,
264
+ sanitizedExternalForwardedProps = _objectWithoutPropertiesLoose(_ref2, _excluded6);
265
+ if (process.env.NODE_ENV !== 'production') {
266
+ if (legacyInputProps || legacyHtmlInputProps || legacyInputLabelProps || legacyFormHelperTextProps) {
267
+ warnOnce(['MUI X: Field components no longer accept the `InputProps`, `inputProps`, `InputLabelProps` and `FormHelperTextProps` props.', 'They have been dropped to avoid leaking unknown attributes onto the underlying form control.', 'Use the nested `slotProps.textField.slotProps.{input,htmlInput,inputLabel,formHelperText}` shape instead.']);
268
+ }
269
+ }
257
270
  const textFieldProps = useSlotProps({
258
271
  elementType: PickersTextField,
259
272
  externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.textField, slotProps?.textField),
260
- externalForwardedProps: otherExternalForwardedProps,
273
+ externalForwardedProps: sanitizedExternalForwardedProps,
261
274
  additionalProps: {
262
275
  ref,
263
276
  sx: pickerContext?.rootSx,
@@ -303,10 +316,6 @@ export function useFieldTextFieldProps(parameters) {
303
316
  }
304
317
  };
305
318
  }
306
-
307
- // TODO: Remove when mui/material-ui#35088 will be merged
308
- textFieldProps.inputProps = _extends({}, inputProps, textFieldProps.inputProps);
309
- textFieldProps.InputProps = _extends({}, InputProps, textFieldProps.InputProps);
310
319
  return textFieldProps;
311
320
  }
312
321
  export function PickerFieldUIContextProvider(props) {
@@ -143,7 +143,7 @@ export type BaseSingleInputPickersTextFieldProps = Omit<UseFieldReturnValue<Base
143
143
  /**
144
144
  * Props the built-in text field component can receive.
145
145
  */
146
- export type BuiltInFieldTextFieldProps = Partial<Omit<PickersTextFieldProps, keyof ExportedPickersSectionListProps>>;
146
+ export type BuiltInFieldTextFieldProps = Partial<Omit<PickersTextFieldProps, keyof ExportedPickersSectionListProps | 'slots' | 'slotProps'>>;
147
147
  export interface PickerTextFieldOwnerState extends FieldOwnerState {
148
148
  /**
149
149
  * `true` if the value of the field is currently empty.
@@ -143,7 +143,7 @@ export type BaseSingleInputPickersTextFieldProps = Omit<UseFieldReturnValue<Base
143
143
  /**
144
144
  * Props the built-in text field component can receive.
145
145
  */
146
- export type BuiltInFieldTextFieldProps = Partial<Omit<PickersTextFieldProps, keyof ExportedPickersSectionListProps>>;
146
+ export type BuiltInFieldTextFieldProps = Partial<Omit<PickersTextFieldProps, keyof ExportedPickersSectionListProps | 'slots' | 'slotProps'>>;
147
147
  export interface PickerTextFieldOwnerState extends FieldOwnerState {
148
148
  /**
149
149
  * `true` if the value of the field is currently empty.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-date-pickers",
3
- "version": "9.0.0-rc.0",
3
+ "version": "9.0.0",
4
4
  "author": "MUI Team",
5
5
  "description": "The community edition of the MUI X Date and Time Picker components.",
6
6
  "license": "MIT",
@@ -34,18 +34,18 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@babel/runtime": "^7.28.6",
37
- "@mui/utils": "9.0.0-beta.1",
37
+ "@mui/utils": "9.0.0",
38
38
  "@types/react-transition-group": "^4.4.12",
39
39
  "clsx": "^2.1.1",
40
40
  "prop-types": "^15.8.1",
41
41
  "react-transition-group": "^4.4.5",
42
- "@mui/x-internals": "9.0.0-rc.0"
42
+ "@mui/x-internals": "^9.0.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@emotion/react": "^11.9.0",
46
46
  "@emotion/styled": "^11.8.1",
47
- "@mui/material": "^7.3.0 || ^9.0.0-beta.0 || ^9.0.0",
48
- "@mui/system": "^7.3.0 || ^9.0.0-beta.1",
47
+ "@mui/material": "^7.3.0 || ^9.0.0",
48
+ "@mui/system": "^7.3.0 || ^9.0.0",
49
49
  "date-fns": "^2.25.0 || ^3.2.0 || ^4.0.0",
50
50
  "date-fns-jalali": "^2.13.0-0 || ^3.2.0-0 || ^4.0.0-0",
51
51
  "dayjs": "^1.10.7",