@mui/x-date-pickers 7.0.0-alpha.3 → 7.0.0-alpha.4

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 (98) hide show
  1. package/AdapterLuxon/AdapterLuxon.d.ts +27 -27
  2. package/AdapterLuxon/AdapterLuxon.js +0 -1
  3. package/CHANGELOG.md +123 -0
  4. package/DateCalendar/useCalendarState.js +0 -1
  5. package/MonthCalendar/MonthCalendar.js +0 -1
  6. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -2
  7. package/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +2 -2
  8. package/PickersCalendarHeader/PickersCalendarHeader.js +4 -4
  9. package/TimeClock/Clock.js +0 -1
  10. package/TimeClock/ClockPointer.js +0 -1
  11. package/YearCalendar/YearCalendar.js +0 -1
  12. package/index.js +1 -1
  13. package/internals/components/PickersTextField/Outline.d.ts +7 -1
  14. package/internals/components/PickersTextField/Outline.js +2 -4
  15. package/internals/components/PickersTextField/PickersInput.d.ts +1 -2
  16. package/internals/components/PickersTextField/PickersInput.js +117 -112
  17. package/internals/components/PickersTextField/PickersInput.types.d.ts +35 -20
  18. package/internals/components/PickersTextField/PickersTextField.js +57 -48
  19. package/internals/components/PickersTextField/PickersTextField.types.d.ts +19 -16
  20. package/internals/components/PickersTextField/pickersTextFieldClasses.d.ts +11 -7
  21. package/internals/components/PickersTextField/pickersTextFieldClasses.js +1 -1
  22. package/internals/constants/dimensions.d.ts +1 -1
  23. package/internals/constants/dimensions.js +1 -1
  24. package/internals/demo/DemoContainer.d.ts +4 -0
  25. package/internals/demo/DemoContainer.js +47 -19
  26. package/internals/hooks/useClockReferenceDate.js +0 -1
  27. package/internals/hooks/useField/useField.utils.js +0 -2
  28. package/internals/hooks/useViews.js +0 -1
  29. package/legacy/AdapterLuxon/AdapterLuxon.js +0 -1
  30. package/legacy/DateCalendar/useCalendarState.js +0 -1
  31. package/legacy/MonthCalendar/MonthCalendar.js +0 -1
  32. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -2
  33. package/legacy/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +2 -2
  34. package/legacy/PickersCalendarHeader/PickersCalendarHeader.js +4 -4
  35. package/legacy/TimeClock/Clock.js +0 -1
  36. package/legacy/TimeClock/ClockPointer.js +0 -1
  37. package/legacy/YearCalendar/YearCalendar.js +0 -1
  38. package/legacy/index.js +1 -1
  39. package/legacy/internals/components/PickersTextField/Outline.js +1 -4
  40. package/legacy/internals/components/PickersTextField/PickersInput.js +119 -115
  41. package/legacy/internals/components/PickersTextField/PickersTextField.js +51 -51
  42. package/legacy/internals/components/PickersTextField/pickersTextFieldClasses.js +1 -1
  43. package/legacy/internals/constants/dimensions.js +1 -1
  44. package/legacy/internals/demo/DemoContainer.js +45 -19
  45. package/legacy/internals/hooks/useClockReferenceDate.js +0 -1
  46. package/legacy/internals/hooks/useField/useField.utils.js +0 -2
  47. package/legacy/internals/hooks/useViews.js +0 -1
  48. package/legacy/locales/plPL.js +0 -1
  49. package/legacy/locales/svSE.js +0 -1
  50. package/legacy/locales/urPK.js +0 -1
  51. package/locales/plPL.js +0 -1
  52. package/locales/svSE.js +0 -1
  53. package/locales/urPK.js +0 -1
  54. package/modern/AdapterLuxon/AdapterLuxon.js +0 -1
  55. package/modern/DateCalendar/useCalendarState.js +0 -1
  56. package/modern/MonthCalendar/MonthCalendar.js +0 -1
  57. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -2
  58. package/modern/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +2 -2
  59. package/modern/PickersCalendarHeader/PickersCalendarHeader.js +4 -4
  60. package/modern/TimeClock/Clock.js +0 -1
  61. package/modern/TimeClock/ClockPointer.js +0 -1
  62. package/modern/YearCalendar/YearCalendar.js +0 -1
  63. package/modern/index.js +1 -1
  64. package/modern/internals/components/PickersTextField/Outline.js +2 -4
  65. package/modern/internals/components/PickersTextField/PickersInput.js +116 -112
  66. package/modern/internals/components/PickersTextField/PickersTextField.js +57 -47
  67. package/modern/internals/components/PickersTextField/pickersTextFieldClasses.js +1 -1
  68. package/modern/internals/constants/dimensions.js +1 -1
  69. package/modern/internals/demo/DemoContainer.js +47 -19
  70. package/modern/internals/hooks/useClockReferenceDate.js +0 -1
  71. package/modern/internals/hooks/useField/useField.utils.js +0 -2
  72. package/modern/internals/hooks/useViews.js +0 -1
  73. package/modern/locales/plPL.js +0 -1
  74. package/modern/locales/svSE.js +0 -1
  75. package/modern/locales/urPK.js +0 -1
  76. package/node/AdapterLuxon/AdapterLuxon.js +0 -1
  77. package/node/DateCalendar/useCalendarState.js +0 -1
  78. package/node/MonthCalendar/MonthCalendar.js +0 -1
  79. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -2
  80. package/node/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +2 -2
  81. package/node/PickersCalendarHeader/PickersCalendarHeader.js +4 -4
  82. package/node/TimeClock/Clock.js +0 -1
  83. package/node/TimeClock/ClockPointer.js +0 -1
  84. package/node/YearCalendar/YearCalendar.js +0 -1
  85. package/node/index.js +1 -1
  86. package/node/internals/components/PickersTextField/Outline.js +2 -4
  87. package/node/internals/components/PickersTextField/PickersInput.js +119 -115
  88. package/node/internals/components/PickersTextField/PickersTextField.js +58 -48
  89. package/node/internals/components/PickersTextField/pickersTextFieldClasses.js +1 -1
  90. package/node/internals/constants/dimensions.js +1 -1
  91. package/node/internals/demo/DemoContainer.js +47 -19
  92. package/node/internals/hooks/useClockReferenceDate.js +0 -1
  93. package/node/internals/hooks/useField/useField.utils.js +0 -2
  94. package/node/internals/hooks/useViews.js +0 -1
  95. package/node/locales/plPL.js +0 -1
  96. package/node/locales/svSE.js +0 -1
  97. package/node/locales/urPK.js +0 -1
  98. package/package.json +5 -5
@@ -1,18 +1,20 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["elements", "defaultValue", "label", "onFocus", "onWrapperClick", "onBlur", "valueStr", "onValueStrChange", "id", "InputProps", "inputProps", "autoFocus", "ownerState", "endAdornment", "startAdornment"];
3
+ const _excluded = ["elements", "areAllSectionsEmpty", "defaultValue", "label", "value", "onChange", "id", "autoFocus", "endAdornment", "startAdornment", "contentEditable", "tabIndex", "fullWidth", "inputProps", "inputRef", "sectionsContainerRef"];
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import Box from '@mui/material/Box';
7
7
  import { useFormControl } from '@mui/material/FormControl';
8
8
  import { styled } from '@mui/material/styles';
9
9
  import useForkRef from '@mui/utils/useForkRef';
10
- import { unstable_composeClasses as composeClasses, unstable_capitalize as capitalize, visuallyHidden } from '@mui/utils';
10
+ import composeClasses from '@mui/utils/composeClasses';
11
+ import capitalize from '@mui/utils/capitalize';
12
+ import visuallyHidden from '@mui/utils/visuallyHidden';
11
13
  import { pickersInputClasses, getPickersInputUtilityClass } from './pickersTextFieldClasses';
12
14
  import Outline from './Outline';
13
15
  import { jsx as _jsx } from "react/jsx-runtime";
14
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
- const SectionsWrapper = styled(Box, {
17
+ const PickersInputRoot = styled(Box, {
16
18
  name: 'MuiPickersInput',
17
19
  slot: 'Root',
18
20
  overridesResolver: (props, styles) => styles.root
@@ -29,6 +31,7 @@ const SectionsWrapper = styled(Box, {
29
31
  alignItems: 'center',
30
32
  width: ownerState.fullWidth ? '100%' : '25ch',
31
33
  position: 'relative',
34
+ outline: 'none',
32
35
  borderRadius: (theme.vars || theme).shape.borderRadius,
33
36
  [`&:hover .${pickersInputClasses.notchedOutline}`]: {
34
37
  borderColor: (theme.vars || theme).palette.text.primary
@@ -59,22 +62,30 @@ const SectionsWrapper = styled(Box, {
59
62
  padding: '8.5px 14px'
60
63
  });
61
64
  });
62
- const SectionsContainer = styled('div', {
65
+ const PickersInputSectionsContainer = styled('div', {
63
66
  name: 'MuiPickersInput',
64
- slot: 'Input',
65
- overridesResolver: (props, styles) => styles.input
67
+ slot: 'SectionsContainer',
68
+ overridesResolver: (props, styles) => styles.sectionsContainer
66
69
  })(({
67
70
  theme,
68
71
  ownerState
69
- }) => ({
72
+ }) => _extends({
70
73
  fontFamily: theme.typography.fontFamily,
71
74
  fontSize: 'inherit',
72
75
  lineHeight: '1.4375em',
73
76
  // 23px
74
77
  flexGrow: 1,
75
- visibility: ownerState.adornedStart || ownerState.focused ? 'visible' : 'hidden'
76
- }));
77
- const SectionContainer = styled('span', {
78
+ outline: 'none'
79
+ }, !(ownerState.adornedStart || ownerState.focused || ownerState.filled) && _extends({
80
+ color: 'currentColor'
81
+ }, ownerState.label == null && (theme.vars ? {
82
+ opacity: theme.vars.opacity.inputPlaceholder
83
+ } : {
84
+ opacity: theme.palette.mode === 'light' ? 0.42 : 0.5
85
+ }), ownerState.label != null && {
86
+ opacity: 0
87
+ })));
88
+ const PickersInputSection = styled('span', {
78
89
  name: 'MuiPickersInput',
79
90
  slot: 'Section',
80
91
  overridesResolver: (props, styles) => styles.section
@@ -87,9 +98,9 @@ const SectionContainer = styled('span', {
87
98
  // 23px
88
99
  flexGrow: 1
89
100
  }));
90
- const SectionInput = styled('span', {
101
+ const PickersInputContent = styled('span', {
91
102
  name: 'MuiPickersInput',
92
- slot: 'Content',
103
+ slot: 'SectionContent',
93
104
  overridesResolver: (props, styles) => styles.content
94
105
  })(({
95
106
  theme
@@ -100,16 +111,16 @@ const SectionInput = styled('span', {
100
111
  letterSpacing: 'inherit',
101
112
  width: 'fit-content'
102
113
  }));
103
- const SectionSeparator = styled('span', {
114
+ const PickersInputSeparator = styled('span', {
104
115
  name: 'MuiPickersInput',
105
116
  slot: 'Separator',
106
117
  overridesResolver: (props, styles) => styles.separator
107
118
  })(() => ({
108
119
  whiteSpace: 'pre'
109
120
  }));
110
- const FakeHiddenInput = styled('input', {
121
+ const PickersInputInput = styled('input', {
111
122
  name: 'MuiPickersInput',
112
- slot: 'HiddenInput',
123
+ slot: 'Input',
113
124
  overridesResolver: (props, styles) => styles.hiddenInput
114
125
  })(_extends({}, visuallyHidden));
115
126
  const NotchedOutlineRoot = styled(Outline, {
@@ -124,36 +135,6 @@ const NotchedOutlineRoot = styled(Outline, {
124
135
  borderColor: theme.vars ? `rgba(${theme.vars.palette.common.onBackgroundChannel} / 0.23)` : borderColor
125
136
  };
126
137
  });
127
- function InputContent({
128
- elements,
129
- contentEditable,
130
- ownerState
131
- }) {
132
- if (contentEditable) {
133
- return elements.map(({
134
- content,
135
- before,
136
- after
137
- }) => `${before.children}${content.children}${after.children}`).join('');
138
- }
139
- return /*#__PURE__*/_jsx(React.Fragment, {
140
- children: elements.map(({
141
- container,
142
- content,
143
- before,
144
- after
145
- }, elementIndex) => /*#__PURE__*/_jsxs(SectionContainer, _extends({}, container, {
146
- children: [/*#__PURE__*/_jsx(SectionSeparator, _extends({}, before, {
147
- className: clsx(pickersInputClasses.before, before?.className)
148
- })), /*#__PURE__*/_jsx(SectionInput, _extends({}, content, {
149
- className: clsx(pickersInputClasses.content, content?.className),
150
- ownerState
151
- })), /*#__PURE__*/_jsx(SectionSeparator, _extends({}, after, {
152
- className: clsx(pickersInputClasses.after, after?.className)
153
- }))]
154
- }), elementIndex))
155
- });
156
- }
157
138
  const useUtilityClasses = ownerState => {
158
139
  const {
159
140
  focused,
@@ -161,104 +142,127 @@ const useUtilityClasses = ownerState => {
161
142
  error,
162
143
  classes,
163
144
  fullWidth,
145
+ readOnly,
164
146
  color,
165
147
  size,
166
148
  endAdornment,
167
149
  startAdornment
168
150
  } = ownerState;
169
151
  const slots = {
170
- root: ['root', focused && !disabled && 'focused', disabled && 'disabled', error && 'error', fullWidth && 'fullWidth', `color${capitalize(color)}`, size === 'small' && 'inputSizeSmall', Boolean(startAdornment) && 'adornedStart', Boolean(endAdornment) && 'adornedEnd'],
152
+ root: ['root', focused && !disabled && 'focused', disabled && 'disabled', readOnly && 'readOnly', error && 'error', fullWidth && 'fullWidth', `color${capitalize(color)}`, size === 'small' && 'inputSizeSmall', Boolean(startAdornment) && 'adornedStart', Boolean(endAdornment) && 'adornedEnd'],
171
153
  notchedOutline: ['notchedOutline'],
172
- before: ['before'],
173
- after: ['after'],
174
- content: ['content'],
175
- input: ['input']
154
+ input: ['input'],
155
+ sectionsContainer: ['sectionsContainer'],
156
+ sectionContent: ['sectionContent'],
157
+ sectionBefore: ['sectionBefore'],
158
+ sectionAfter: ['sectionAfter']
176
159
  };
177
160
  return composeClasses(slots, getPickersInputUtilityClass, classes);
178
161
  };
179
-
180
- // TODO: move to utils
181
- // Separates the state props from the form control
182
- function formControlState({
183
- props,
184
- states,
185
- muiFormControl
186
- }) {
187
- return states.reduce((acc, state) => {
188
- acc[state] = props[state];
189
- if (muiFormControl) {
190
- if (typeof props[state] === 'undefined') {
191
- acc[state] = muiFormControl[state];
192
- }
193
- }
194
- return acc;
195
- }, {});
196
- }
197
- const PickersInput = /*#__PURE__*/React.forwardRef(function PickersInput(props, ref) {
162
+ export const PickersInput = /*#__PURE__*/React.forwardRef(function PickersInput(props, ref) {
198
163
  const {
199
164
  elements,
165
+ areAllSectionsEmpty,
200
166
  label,
201
- onWrapperClick,
202
- valueStr,
203
- onValueStrChange,
167
+ value,
168
+ onChange,
204
169
  id,
205
- ownerState: ownerStateProp,
206
170
  endAdornment,
207
- startAdornment
171
+ startAdornment,
172
+ contentEditable,
173
+ tabIndex,
174
+ inputProps,
175
+ inputRef,
176
+ sectionsContainerRef
208
177
  } = props,
209
178
  other = _objectWithoutPropertiesLoose(props, _excluded);
210
- const inputRef = React.useRef(null);
211
- const handleInputRef = useForkRef(ref, inputRef);
179
+ const rootRef = React.useRef(null);
180
+ const handleRootRef = useForkRef(ref, rootRef);
181
+ const handleInputRef = useForkRef(inputProps?.ref, inputRef);
212
182
  const muiFormControl = useFormControl();
213
- const fcs = formControlState({
214
- props,
215
- muiFormControl,
216
- states: ['color', 'disabled', 'error', 'focused', 'size', 'required', 'fullWidth', 'adornedStart']
217
- });
183
+ if (!muiFormControl) {
184
+ throw new Error('MUI: PickersInput should always be used inside a PickersTextField component');
185
+ }
186
+ const handleInputFocus = event => {
187
+ // Fix a bug with IE11 where the focus/blur events are triggered
188
+ // while the component is disabled.
189
+ if (muiFormControl.disabled) {
190
+ event.stopPropagation();
191
+ return;
192
+ }
193
+ muiFormControl.onFocus?.(event);
194
+ };
218
195
  React.useEffect(() => {
219
196
  if (muiFormControl) {
220
197
  muiFormControl.setAdornedStart(Boolean(startAdornment));
221
198
  }
222
199
  }, [muiFormControl, startAdornment]);
223
- const ownerState = _extends({}, props, ownerStateProp, {
224
- color: fcs.color || 'primary',
225
- disabled: fcs.disabled,
226
- error: fcs.error,
227
- focused: fcs.focused,
228
- fullWidth: fcs.fullWidth,
229
- size: fcs.size
230
- });
200
+ React.useEffect(() => {
201
+ if (!muiFormControl) {
202
+ return;
203
+ }
204
+ if (areAllSectionsEmpty) {
205
+ muiFormControl.onEmpty();
206
+ } else {
207
+ muiFormControl.onFilled();
208
+ }
209
+ }, [muiFormControl, areAllSectionsEmpty]);
210
+ const ownerState = _extends({}, props, muiFormControl);
231
211
  const classes = useUtilityClasses(ownerState);
232
- return /*#__PURE__*/_jsxs(SectionsWrapper, _extends({
233
- ref: handleInputRef
234
- }, other, {
212
+ return /*#__PURE__*/_jsxs(PickersInputRoot, _extends({}, other, {
235
213
  className: classes.root,
236
- onClick: onWrapperClick,
237
214
  ownerState: ownerState,
238
- "aria-invalid": fcs.error,
239
- children: [startAdornment, /*#__PURE__*/_jsxs(SectionsContainer, {
215
+ "aria-invalid": muiFormControl.error,
216
+ ref: handleRootRef,
217
+ children: [startAdornment, /*#__PURE__*/_jsx(PickersInputSectionsContainer, {
240
218
  ownerState: ownerState,
241
- className: classes.input,
242
- children: [/*#__PURE__*/_jsx(InputContent, {
243
- elements: elements,
244
- contentEditable: other.contentEditable,
245
- ownerState: ownerState
246
- }), /*#__PURE__*/_jsx(FakeHiddenInput, {
247
- value: valueStr,
248
- onChange: onValueStrChange,
249
- id: id,
250
- "aria-hidden": "true",
251
- tabIndex: -1
252
- })]
219
+ className: classes.sectionsContainer,
220
+ contentEditable: contentEditable,
221
+ suppressContentEditableWarning: true,
222
+ onFocus: handleInputFocus,
223
+ onBlur: muiFormControl.onBlur,
224
+ tabIndex: tabIndex,
225
+ ref: sectionsContainerRef,
226
+ children: contentEditable ? elements.map(({
227
+ content,
228
+ before,
229
+ after
230
+ }) => `${before.children}${content.children}${after.children}`).join('') : /*#__PURE__*/_jsx(React.Fragment, {
231
+ children: elements.map(({
232
+ container,
233
+ content,
234
+ before,
235
+ after
236
+ }, elementIndex) => /*#__PURE__*/_jsxs(PickersInputSection, _extends({}, container, {
237
+ children: [/*#__PURE__*/_jsx(PickersInputSeparator, _extends({}, before, {
238
+ className: clsx(pickersInputClasses.sectionBefore, before?.className)
239
+ })), /*#__PURE__*/_jsx(PickersInputContent, _extends({}, content, {
240
+ suppressContentEditableWarning: true,
241
+ className: clsx(pickersInputClasses.sectionContent, content?.className),
242
+ ownerState
243
+ })), /*#__PURE__*/_jsx(PickersInputSeparator, _extends({}, after, {
244
+ className: clsx(pickersInputClasses.sectionAfter, after?.className)
245
+ }))]
246
+ }), elementIndex))
247
+ })
253
248
  }), endAdornment, /*#__PURE__*/_jsx(NotchedOutlineRoot, {
254
- shrink: fcs.adornedStart || fcs.focused,
255
- notched: fcs.adornedStart || fcs.focused,
249
+ shrink: muiFormControl.adornedStart || muiFormControl.focused || muiFormControl.filled,
250
+ notched: muiFormControl.adornedStart || muiFormControl.focused || muiFormControl.filled,
256
251
  className: classes.notchedOutline,
257
- label: label != null && label !== '' && fcs.required ? /*#__PURE__*/_jsxs(React.Fragment, {
252
+ label: label != null && label !== '' && muiFormControl.required ? /*#__PURE__*/_jsxs(React.Fragment, {
258
253
  children: [label, "\u2009", '*']
259
254
  }) : label,
260
255
  ownerState: ownerState
261
- })]
256
+ }), /*#__PURE__*/_jsx(PickersInputInput, _extends({
257
+ className: classes.input,
258
+ value: value,
259
+ onChange: onChange,
260
+ id: id,
261
+ "aria-hidden": "true",
262
+ tabIndex: -1
263
+ }, inputProps, {
264
+ ref: handleInputRef
265
+ }))]
262
266
  }));
263
267
  });
264
- export default PickersInput;
268
+ PickersInput.muiName = 'Input';
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["elements", "className", "color", "disabled", "error", "label", "variant", "fullWidth", "valueStr", "helperText", "valueType", "id", "FormHelperTextProps", "InputLabelProps", "inputProps", "InputProps", "required", "focused", "ownerState"];
3
+ const _excluded = ["onFocus", "onBlur", "className", "color", "disabled", "error", "required", "variant", "InputProps", "inputProps", "inputRef", "sectionsContainerRef", "elements", "areAllSectionsEmpty", "onClick", "onKeyDown", "onKeyUp", "onPaste", "onInput", "endAdornment", "startAdornment", "tabIndex", "contentEditable", "focused", "value", "onChange", "fullWidth", "id", "helperText", "FormHelperTextProps", "label", "InputLabelProps"];
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import { styled } from '@mui/material/styles';
@@ -10,7 +10,7 @@ import InputLabel from '@mui/material/InputLabel';
10
10
  import FormHelperText from '@mui/material/FormHelperText';
11
11
  import FormControl from '@mui/material/FormControl';
12
12
  import { getPickersTextFieldUtilityClass } from './pickersTextFieldClasses';
13
- import PickersInput from './PickersInput';
13
+ import { PickersInput } from './PickersInput';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
16
  const PickersTextFieldRoot = styled(FormControl, {
@@ -32,32 +32,46 @@ const useUtilityClasses = ownerState => {
32
32
  };
33
33
  export const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField(props, ref) {
34
34
  const {
35
- elements,
35
+ // Props used by FormControl
36
+ onFocus,
37
+ onBlur,
36
38
  className,
37
39
  color = 'primary',
38
40
  disabled = false,
39
41
  error = false,
40
- label,
42
+ required = false,
41
43
  variant = 'outlined',
42
- fullWidth = false,
43
- valueStr,
44
+ // Props used by PickersInput
45
+ InputProps,
46
+ inputProps,
47
+ inputRef,
48
+ sectionsContainerRef,
49
+ elements,
50
+ areAllSectionsEmpty,
51
+ onClick,
52
+ onKeyDown,
53
+ onPaste,
54
+ onInput,
55
+ endAdornment,
56
+ startAdornment,
57
+ tabIndex,
58
+ contentEditable,
59
+ focused,
60
+ value,
61
+ onChange,
62
+ fullWidth,
63
+ id: idProp,
64
+ // Props used by FormHelperText
44
65
  helperText,
45
- valueType,
46
- id: idOverride,
47
66
  FormHelperTextProps,
48
- InputLabelProps,
49
- inputProps,
50
- InputProps,
51
- required = false,
52
- focused: focusedProp
67
+ // Props used by InputLabel
68
+ label,
69
+ InputLabelProps
53
70
  } = props,
54
71
  other = _objectWithoutPropertiesLoose(props, _excluded);
55
- const [focused, setFocused] = React.useState(focusedProp);
56
72
  const rootRef = React.useRef(null);
57
73
  const handleRootRef = useForkRef(ref, rootRef);
58
- const inputRef = React.useRef(null);
59
- const handleInputRef = useForkRef(inputRef, InputProps?.ref);
60
- const id = useId(idOverride);
74
+ const id = useId(idProp);
61
75
  const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
62
76
  const inputLabelId = label && id ? `${id}-label` : undefined;
63
77
  const ownerState = _extends({}, props, {
@@ -65,55 +79,51 @@ export const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTe
65
79
  disabled,
66
80
  error,
67
81
  focused,
82
+ required,
68
83
  variant
69
84
  });
70
85
  const classes = useUtilityClasses(ownerState);
71
-
72
- // TODO: delete after behavior implementation
73
- const onWrapperClick = () => {
74
- if (!focused) {
75
- setFocused(true);
76
- const container = rootRef.current;
77
-
78
- // Find the first input element within the container
79
- const firstInput = container?.querySelector('.content');
80
-
81
- // Check if the input element exists before focusing it
82
- if (firstInput) {
83
- firstInput.focus();
84
- }
85
- inputRef.current?.focus();
86
- }
87
- };
88
- return /*#__PURE__*/_jsxs(PickersTextFieldRoot, {
86
+ return /*#__PURE__*/_jsxs(PickersTextFieldRoot, _extends({
89
87
  className: clsx(classes.root, className),
90
88
  ref: handleRootRef,
91
89
  focused: focused,
90
+ onFocus: onFocus,
91
+ onBlur: onBlur,
92
92
  disabled: disabled,
93
93
  variant: variant,
94
94
  error: error,
95
95
  color: color,
96
- fullWidth: fullWidth,
97
96
  required: required,
98
- ownerState: ownerState,
97
+ ownerState: ownerState
98
+ }, other, {
99
99
  children: [/*#__PURE__*/_jsx(InputLabel, _extends({
100
100
  htmlFor: id,
101
101
  id: inputLabelId
102
102
  }, InputLabelProps, {
103
103
  children: label
104
104
  })), /*#__PURE__*/_jsx(PickersInput, _extends({
105
- elements,
106
- valueStr,
107
- valueType,
108
- onWrapperClick,
109
- inputProps,
110
- label
111
- }, other, InputProps, {
112
- ref: handleInputRef
113
- })), helperText && /*#__PURE__*/_jsx(FormHelperText, _extends({
105
+ elements: elements,
106
+ areAllSectionsEmpty: areAllSectionsEmpty,
107
+ onClick: onClick,
108
+ onKeyDown: onKeyDown,
109
+ onInput: onInput,
110
+ onPaste: onPaste,
111
+ endAdornment: endAdornment,
112
+ startAdornment: startAdornment,
113
+ tabIndex: tabIndex,
114
+ contentEditable: contentEditable,
115
+ value: value,
116
+ onChange: onChange,
117
+ id: id,
118
+ fullWidth: fullWidth,
119
+ inputProps: inputProps,
120
+ inputRef: inputRef,
121
+ sectionsContainerRef: sectionsContainerRef,
122
+ label: label
123
+ }, InputProps)), helperText && /*#__PURE__*/_jsx(FormHelperText, _extends({
114
124
  id: helperTextId
115
125
  }, FormHelperTextProps, {
116
126
  children: helperText
117
127
  }))]
118
- });
128
+ }));
119
129
  });
@@ -6,4 +6,4 @@ export const pickersTextFieldClasses = generateUtilityClasses('MuiPickersTextFie
6
6
  export function getPickersInputUtilityClass(slot) {
7
7
  return generateUtilityClass('MuiPickersInput', slot);
8
8
  }
9
- export const pickersInputClasses = generateUtilityClasses('MuiPickersInput', ['root', 'focused', 'disabled', 'error', 'notchedOutline', 'content', 'before', 'after', 'adornedStart', 'adornedEnd', 'input']);
9
+ export const pickersInputClasses = generateUtilityClasses('MuiPickersInput', ['root', 'focused', 'disabled', 'error', 'notchedOutline', 'adornedStart', 'adornedEnd', 'input', 'sectionsContainer', 'sectionContent', 'sectionBefore', 'sectionAfter']);
@@ -2,6 +2,6 @@ export const DAY_SIZE = 36;
2
2
  export const DAY_MARGIN = 2;
3
3
  export const DIALOG_WIDTH = 320;
4
4
  export const MAX_CALENDAR_HEIGHT = 280;
5
- export const VIEW_HEIGHT = 334;
5
+ export const VIEW_HEIGHT = 336;
6
6
  export const DIGITAL_CLOCK_VIEW_HEIGHT = 232;
7
7
  export const MULTI_SECTION_CLOCK_SECTION_WIDTH = 48;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import Stack from '@mui/material/Stack';
3
+ import Stack, { stackClasses } from '@mui/material/Stack';
4
4
  import Typography from '@mui/material/Typography';
5
5
  import { textFieldClasses } from '@mui/material/TextField';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -40,20 +40,20 @@ export function DemoItem(props) {
40
40
  const {
41
41
  label,
42
42
  children,
43
- component
43
+ component,
44
+ sx: sxProp
44
45
  } = props;
45
46
  let spacing;
46
- let sx;
47
+ let sx = sxProp;
47
48
  if (component && getChildTypeFromChildName(component) === 'multi-input-range-field') {
48
49
  spacing = 1.5;
49
- sx = {
50
+ sx = _extends({}, sx, {
50
51
  [`& .${textFieldClasses.root}`]: {
51
52
  flexGrow: 1
52
53
  }
53
- };
54
+ });
54
55
  } else {
55
56
  spacing = 1;
56
- sx = undefined;
57
57
  }
58
58
  return /*#__PURE__*/_jsxs(Stack, {
59
59
  direction: "column",
@@ -66,7 +66,14 @@ export function DemoItem(props) {
66
66
  }), children]
67
67
  });
68
68
  }
69
-
69
+ DemoItem.displayName = 'DemoItem';
70
+ const isDemoItem = child => {
71
+ if ( /*#__PURE__*/React.isValidElement(child) && typeof child.type !== 'string') {
72
+ // @ts-ignore
73
+ return child.type.displayName === 'DemoItem';
74
+ }
75
+ return false;
76
+ };
70
77
  /**
71
78
  * WARNING: This is an internal component used in documentation to achieve a desired layout.
72
79
  * Please do not use it in your application.
@@ -91,7 +98,9 @@ export function DemoContainer(props) {
91
98
  };
92
99
  let direction;
93
100
  let spacing;
94
- let sx = _extends({
101
+ let extraSx = {};
102
+ let demoItemSx = {};
103
+ const sx = _extends({
95
104
  overflow: 'auto',
96
105
  // Add padding as overflow can hide the outline text field label.
97
106
  pt: 1
@@ -113,38 +122,57 @@ export function DemoContainer(props) {
113
122
  // noop
114
123
  } else if (childrenTypes.has('single-input-range-field')) {
115
124
  if (!childrenSupportedSections.has('date-time')) {
116
- sx = _extends({}, sx, {
125
+ extraSx = {
117
126
  [`& > .${textFieldClasses.root}`]: {
118
127
  minWidth: 300
119
128
  }
120
- });
129
+ };
121
130
  } else {
122
- sx = _extends({}, sx, {
131
+ extraSx = {
123
132
  [`& > .${textFieldClasses.root}`]: {
124
133
  minWidth: {
125
134
  xs: 300,
126
- md: 400
135
+ // If demo also contains MultiInputDateTimeRangeField, increase width to avoid cutting off the value.
136
+ md: childrenTypes.has('multi-input-range-field') ? 460 : 400
127
137
  }
128
138
  }
129
- });
139
+ };
130
140
  }
131
141
  } else if (childrenSupportedSections.has('date-time')) {
132
- sx = _extends({}, sx, {
142
+ extraSx = {
133
143
  [`& > .${textFieldClasses.root}`]: {
134
144
  minWidth: 270
135
145
  }
136
- });
146
+ };
147
+ if (childrenTypes.has('multi-input-range-field')) {
148
+ // increase width for the multi input date time range fields
149
+ demoItemSx = {
150
+ [`& > .${stackClasses.root} > .${textFieldClasses.root}`]: {
151
+ minWidth: 210
152
+ }
153
+ };
154
+ }
137
155
  } else {
138
- sx = _extends({}, sx, {
156
+ extraSx = {
139
157
  [`& > .${textFieldClasses.root}`]: {
140
158
  minWidth: 200
141
159
  }
142
- });
160
+ };
143
161
  }
162
+ const finalSx = _extends({}, sx, extraSx);
144
163
  return /*#__PURE__*/_jsx(Stack, {
145
164
  direction: direction,
146
165
  spacing: spacing,
147
- sx: sx,
148
- children: children
166
+ sx: finalSx,
167
+ children: React.Children.map(children, child => {
168
+ if ( /*#__PURE__*/React.isValidElement(child) && isDemoItem(child)) {
169
+ // Inject sx styles to the `DemoItem` if it is a direct child of `DemoContainer`.
170
+ // @ts-ignore
171
+ return /*#__PURE__*/React.cloneElement(child, {
172
+ sx: _extends({}, extraSx, demoItemSx)
173
+ });
174
+ }
175
+ return child;
176
+ })
149
177
  });
150
178
  }
@@ -21,6 +21,5 @@ export const useClockReferenceDate = ({
21
21
  // We only want to compute the reference date on mount.
22
22
  [] // eslint-disable-line react-hooks/exhaustive-deps
23
23
  );
24
-
25
24
  return value ?? referenceDate;
26
25
  };
@@ -125,7 +125,6 @@ export const adjustSectionValue = (utils, timezone, section, keyCode, sectionsVa
125
125
  if (delta < 0 || isStart) {
126
126
  newSectionValueNumber += step - (step + newSectionValueNumber) % step; // for JS -3 % 5 = -3 (should be 2)
127
127
  }
128
-
129
128
  if (delta > 0 || isEnd) {
130
129
  newSectionValueNumber -= newSectionValueNumber % step;
131
130
  }
@@ -400,7 +399,6 @@ export const splitFormatIntoSections = (utils, timezone, localeText, format, dat
400
399
  const isTokenStartRegExp = new RegExp(`^(${Object.keys(utils.formatTokenMap).sort((a, b) => b.length - a.length) // Sort to put longest word first
401
400
  .join('|')})`, 'g') // used to get access to lastIndex state
402
401
  ;
403
-
404
402
  let currentTokenValue = '';
405
403
  for (let i = 0; i < expandedFormat.length; i += 1) {
406
404
  const escapedPartOfCurrentChar = escapedParts.find(escapeIndex => escapeIndex.start <= i && escapeIndex.end >= i);
@@ -60,7 +60,6 @@ export function useViews({
60
60
  setFocusedView(prevFocusedView => viewToFocus === prevFocusedView ? null : prevFocusedView // If false the blur is due to view switching
61
61
  );
62
62
  }
63
-
64
63
  onFocusedViewChange?.(viewToFocus, hasFocus);
65
64
  });
66
65
  const handleChangeView = useEventCallback(newView => {