@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.
- package/AdapterLuxon/AdapterLuxon.d.ts +27 -27
- package/AdapterLuxon/AdapterLuxon.js +0 -1
- package/CHANGELOG.md +123 -0
- package/DateCalendar/useCalendarState.js +0 -1
- package/MonthCalendar/MonthCalendar.js +0 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -2
- package/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +2 -2
- package/PickersCalendarHeader/PickersCalendarHeader.js +4 -4
- package/TimeClock/Clock.js +0 -1
- package/TimeClock/ClockPointer.js +0 -1
- package/YearCalendar/YearCalendar.js +0 -1
- package/index.js +1 -1
- package/internals/components/PickersTextField/Outline.d.ts +7 -1
- package/internals/components/PickersTextField/Outline.js +2 -4
- package/internals/components/PickersTextField/PickersInput.d.ts +1 -2
- package/internals/components/PickersTextField/PickersInput.js +117 -112
- package/internals/components/PickersTextField/PickersInput.types.d.ts +35 -20
- package/internals/components/PickersTextField/PickersTextField.js +57 -48
- package/internals/components/PickersTextField/PickersTextField.types.d.ts +19 -16
- package/internals/components/PickersTextField/pickersTextFieldClasses.d.ts +11 -7
- package/internals/components/PickersTextField/pickersTextFieldClasses.js +1 -1
- package/internals/constants/dimensions.d.ts +1 -1
- package/internals/constants/dimensions.js +1 -1
- package/internals/demo/DemoContainer.d.ts +4 -0
- package/internals/demo/DemoContainer.js +47 -19
- package/internals/hooks/useClockReferenceDate.js +0 -1
- package/internals/hooks/useField/useField.utils.js +0 -2
- package/internals/hooks/useViews.js +0 -1
- package/legacy/AdapterLuxon/AdapterLuxon.js +0 -1
- package/legacy/DateCalendar/useCalendarState.js +0 -1
- package/legacy/MonthCalendar/MonthCalendar.js +0 -1
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -2
- package/legacy/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +2 -2
- package/legacy/PickersCalendarHeader/PickersCalendarHeader.js +4 -4
- package/legacy/TimeClock/Clock.js +0 -1
- package/legacy/TimeClock/ClockPointer.js +0 -1
- package/legacy/YearCalendar/YearCalendar.js +0 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersTextField/Outline.js +1 -4
- package/legacy/internals/components/PickersTextField/PickersInput.js +119 -115
- package/legacy/internals/components/PickersTextField/PickersTextField.js +51 -51
- package/legacy/internals/components/PickersTextField/pickersTextFieldClasses.js +1 -1
- package/legacy/internals/constants/dimensions.js +1 -1
- package/legacy/internals/demo/DemoContainer.js +45 -19
- package/legacy/internals/hooks/useClockReferenceDate.js +0 -1
- package/legacy/internals/hooks/useField/useField.utils.js +0 -2
- package/legacy/internals/hooks/useViews.js +0 -1
- package/legacy/locales/plPL.js +0 -1
- package/legacy/locales/svSE.js +0 -1
- package/legacy/locales/urPK.js +0 -1
- package/locales/plPL.js +0 -1
- package/locales/svSE.js +0 -1
- package/locales/urPK.js +0 -1
- package/modern/AdapterLuxon/AdapterLuxon.js +0 -1
- package/modern/DateCalendar/useCalendarState.js +0 -1
- package/modern/MonthCalendar/MonthCalendar.js +0 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -2
- package/modern/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +2 -2
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +4 -4
- package/modern/TimeClock/Clock.js +0 -1
- package/modern/TimeClock/ClockPointer.js +0 -1
- package/modern/YearCalendar/YearCalendar.js +0 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersTextField/Outline.js +2 -4
- package/modern/internals/components/PickersTextField/PickersInput.js +116 -112
- package/modern/internals/components/PickersTextField/PickersTextField.js +57 -47
- package/modern/internals/components/PickersTextField/pickersTextFieldClasses.js +1 -1
- package/modern/internals/constants/dimensions.js +1 -1
- package/modern/internals/demo/DemoContainer.js +47 -19
- package/modern/internals/hooks/useClockReferenceDate.js +0 -1
- package/modern/internals/hooks/useField/useField.utils.js +0 -2
- package/modern/internals/hooks/useViews.js +0 -1
- package/modern/locales/plPL.js +0 -1
- package/modern/locales/svSE.js +0 -1
- package/modern/locales/urPK.js +0 -1
- package/node/AdapterLuxon/AdapterLuxon.js +0 -1
- package/node/DateCalendar/useCalendarState.js +0 -1
- package/node/MonthCalendar/MonthCalendar.js +0 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -2
- package/node/MultiSectionDigitalClock/multiSectionDigitalClockSectionClasses.js +2 -2
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +4 -4
- package/node/TimeClock/Clock.js +0 -1
- package/node/TimeClock/ClockPointer.js +0 -1
- package/node/YearCalendar/YearCalendar.js +0 -1
- package/node/index.js +1 -1
- package/node/internals/components/PickersTextField/Outline.js +2 -4
- package/node/internals/components/PickersTextField/PickersInput.js +119 -115
- package/node/internals/components/PickersTextField/PickersTextField.js +58 -48
- package/node/internals/components/PickersTextField/pickersTextFieldClasses.js +1 -1
- package/node/internals/constants/dimensions.js +1 -1
- package/node/internals/demo/DemoContainer.js +47 -19
- package/node/internals/hooks/useClockReferenceDate.js +0 -1
- package/node/internals/hooks/useField/useField.utils.js +0 -2
- package/node/internals/hooks/useViews.js +0 -1
- package/node/locales/plPL.js +0 -1
- package/node/locales/svSE.js +0 -1
- package/node/locales/urPK.js +0 -1
- 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", "
|
|
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
|
|
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
|
|
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
|
|
65
|
+
const PickersInputSectionsContainer = styled('div', {
|
|
63
66
|
name: 'MuiPickersInput',
|
|
64
|
-
slot: '
|
|
65
|
-
overridesResolver: (props, styles) => styles.
|
|
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
|
-
|
|
76
|
-
})
|
|
77
|
-
|
|
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
|
|
101
|
+
const PickersInputContent = styled('span', {
|
|
91
102
|
name: 'MuiPickersInput',
|
|
92
|
-
slot: '
|
|
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
|
|
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
|
|
121
|
+
const PickersInputInput = styled('input', {
|
|
111
122
|
name: 'MuiPickersInput',
|
|
112
|
-
slot: '
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
202
|
-
|
|
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
|
|
211
|
-
const
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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(
|
|
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":
|
|
239
|
-
|
|
215
|
+
"aria-invalid": muiFormControl.error,
|
|
216
|
+
ref: handleRootRef,
|
|
217
|
+
children: [startAdornment, /*#__PURE__*/_jsx(PickersInputSectionsContainer, {
|
|
240
218
|
ownerState: ownerState,
|
|
241
|
-
className: classes.
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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:
|
|
255
|
-
notched:
|
|
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 !== '' &&
|
|
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
|
-
|
|
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 = ["
|
|
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
|
-
|
|
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
|
-
|
|
42
|
+
required = false,
|
|
41
43
|
variant = 'outlined',
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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', '
|
|
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 =
|
|
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
|
|
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
|
-
|
|
125
|
+
extraSx = {
|
|
117
126
|
[`& > .${textFieldClasses.root}`]: {
|
|
118
127
|
minWidth: 300
|
|
119
128
|
}
|
|
120
|
-
}
|
|
129
|
+
};
|
|
121
130
|
} else {
|
|
122
|
-
|
|
131
|
+
extraSx = {
|
|
123
132
|
[`& > .${textFieldClasses.root}`]: {
|
|
124
133
|
minWidth: {
|
|
125
134
|
xs: 300,
|
|
126
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
}
|
|
@@ -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 => {
|