@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 == null ? void 0 : before.className)
|
|
148
|
-
})), /*#__PURE__*/_jsx(SectionInput, _extends({}, content, {
|
|
149
|
-
className: clsx(pickersInputClasses.content, content == null ? void 0 : content.className),
|
|
150
|
-
ownerState
|
|
151
|
-
})), /*#__PURE__*/_jsx(SectionSeparator, _extends({}, after, {
|
|
152
|
-
className: clsx(pickersInputClasses.after, after == null ? void 0 : after.className)
|
|
153
|
-
}))]
|
|
154
|
-
}), elementIndex))
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
138
|
const useUtilityClasses = ownerState => {
|
|
158
139
|
const {
|
|
159
140
|
focused,
|
|
@@ -161,104 +142,128 @@ 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 == null ? void 0 : 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
|
+
var _muiFormControl$onFoc;
|
|
188
|
+
// Fix a bug with IE11 where the focus/blur events are triggered
|
|
189
|
+
// while the component is disabled.
|
|
190
|
+
if (muiFormControl.disabled) {
|
|
191
|
+
event.stopPropagation();
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
(_muiFormControl$onFoc = muiFormControl.onFocus) == null || _muiFormControl$onFoc.call(muiFormControl, event);
|
|
195
|
+
};
|
|
218
196
|
React.useEffect(() => {
|
|
219
197
|
if (muiFormControl) {
|
|
220
198
|
muiFormControl.setAdornedStart(Boolean(startAdornment));
|
|
221
199
|
}
|
|
222
200
|
}, [muiFormControl, startAdornment]);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
201
|
+
React.useEffect(() => {
|
|
202
|
+
if (!muiFormControl) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (areAllSectionsEmpty) {
|
|
206
|
+
muiFormControl.onEmpty();
|
|
207
|
+
} else {
|
|
208
|
+
muiFormControl.onFilled();
|
|
209
|
+
}
|
|
210
|
+
}, [muiFormControl, areAllSectionsEmpty]);
|
|
211
|
+
const ownerState = _extends({}, props, muiFormControl);
|
|
231
212
|
const classes = useUtilityClasses(ownerState);
|
|
232
|
-
return /*#__PURE__*/_jsxs(
|
|
233
|
-
ref: handleInputRef
|
|
234
|
-
}, other, {
|
|
213
|
+
return /*#__PURE__*/_jsxs(PickersInputRoot, _extends({}, other, {
|
|
235
214
|
className: classes.root,
|
|
236
|
-
onClick: onWrapperClick,
|
|
237
215
|
ownerState: ownerState,
|
|
238
|
-
"aria-invalid":
|
|
239
|
-
|
|
216
|
+
"aria-invalid": muiFormControl.error,
|
|
217
|
+
ref: handleRootRef,
|
|
218
|
+
children: [startAdornment, /*#__PURE__*/_jsx(PickersInputSectionsContainer, {
|
|
240
219
|
ownerState: ownerState,
|
|
241
|
-
className: classes.
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
})
|
|
220
|
+
className: classes.sectionsContainer,
|
|
221
|
+
contentEditable: contentEditable,
|
|
222
|
+
suppressContentEditableWarning: true,
|
|
223
|
+
onFocus: handleInputFocus,
|
|
224
|
+
onBlur: muiFormControl.onBlur,
|
|
225
|
+
tabIndex: tabIndex,
|
|
226
|
+
ref: sectionsContainerRef,
|
|
227
|
+
children: contentEditable ? elements.map(({
|
|
228
|
+
content,
|
|
229
|
+
before,
|
|
230
|
+
after
|
|
231
|
+
}) => `${before.children}${content.children}${after.children}`).join('') : /*#__PURE__*/_jsx(React.Fragment, {
|
|
232
|
+
children: elements.map(({
|
|
233
|
+
container,
|
|
234
|
+
content,
|
|
235
|
+
before,
|
|
236
|
+
after
|
|
237
|
+
}, elementIndex) => /*#__PURE__*/_jsxs(PickersInputSection, _extends({}, container, {
|
|
238
|
+
children: [/*#__PURE__*/_jsx(PickersInputSeparator, _extends({}, before, {
|
|
239
|
+
className: clsx(pickersInputClasses.sectionBefore, before == null ? void 0 : before.className)
|
|
240
|
+
})), /*#__PURE__*/_jsx(PickersInputContent, _extends({}, content, {
|
|
241
|
+
suppressContentEditableWarning: true,
|
|
242
|
+
className: clsx(pickersInputClasses.sectionContent, content == null ? void 0 : content.className),
|
|
243
|
+
ownerState
|
|
244
|
+
})), /*#__PURE__*/_jsx(PickersInputSeparator, _extends({}, after, {
|
|
245
|
+
className: clsx(pickersInputClasses.sectionAfter, after == null ? void 0 : after.className)
|
|
246
|
+
}))]
|
|
247
|
+
}), elementIndex))
|
|
248
|
+
})
|
|
253
249
|
}), endAdornment, /*#__PURE__*/_jsx(NotchedOutlineRoot, {
|
|
254
|
-
shrink:
|
|
255
|
-
notched:
|
|
250
|
+
shrink: muiFormControl.adornedStart || muiFormControl.focused || muiFormControl.filled,
|
|
251
|
+
notched: muiFormControl.adornedStart || muiFormControl.focused || muiFormControl.filled,
|
|
256
252
|
className: classes.notchedOutline,
|
|
257
|
-
label: label != null && label !== '' &&
|
|
253
|
+
label: label != null && label !== '' && muiFormControl.required ? /*#__PURE__*/_jsxs(React.Fragment, {
|
|
258
254
|
children: [label, "\u2009", '*']
|
|
259
255
|
}) : label,
|
|
260
256
|
ownerState: ownerState
|
|
261
|
-
})
|
|
257
|
+
}), /*#__PURE__*/_jsx(PickersInputInput, _extends({
|
|
258
|
+
className: classes.input,
|
|
259
|
+
value: value,
|
|
260
|
+
onChange: onChange,
|
|
261
|
+
id: id,
|
|
262
|
+
"aria-hidden": "true",
|
|
263
|
+
tabIndex: -1
|
|
264
|
+
}, inputProps, {
|
|
265
|
+
ref: handleInputRef
|
|
266
|
+
}))]
|
|
262
267
|
}));
|
|
263
268
|
});
|
|
264
|
-
|
|
269
|
+
PickersInput.muiName = 'Input';
|
|
@@ -1,30 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { FieldsTextFieldProps } from '../../models';
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { BoxProps } from '@mui/material/Box';
|
|
4
3
|
export interface PickersInputElement {
|
|
5
4
|
container: React.HTMLAttributes<HTMLSpanElement>;
|
|
6
5
|
content: React.HTMLAttributes<HTMLSpanElement>;
|
|
7
6
|
before: React.HTMLAttributes<HTMLSpanElement>;
|
|
8
7
|
after: React.HTMLAttributes<HTMLSpanElement>;
|
|
9
8
|
}
|
|
10
|
-
export interface
|
|
9
|
+
export interface PickersInputPropsUsedByField {
|
|
10
|
+
/**
|
|
11
|
+
* The elements to render.
|
|
12
|
+
* Each element contains the prop to edit a section of the value.
|
|
13
|
+
*/
|
|
11
14
|
elements: PickersInputElement[];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
label?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Is `true` if the current values equals the empty value.
|
|
17
|
+
* For a single item value, it means that `value === null`
|
|
18
|
+
* For a range value, it means that `value === [null, null]`
|
|
19
|
+
*/
|
|
20
|
+
areAllSectionsEmpty: boolean;
|
|
21
|
+
onClick: React.MouseEventHandler<HTMLDivElement>;
|
|
22
|
+
onKeyDown: React.KeyboardEventHandler<HTMLDivElement>;
|
|
23
|
+
onInput: React.FormEventHandler<HTMLDivElement>;
|
|
24
|
+
onPaste: React.ClipboardEventHandler<HTMLDivElement>;
|
|
23
25
|
endAdornment?: React.ReactNode;
|
|
24
26
|
startAdornment?: React.ReactNode;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
tabIndex: number | undefined;
|
|
28
|
+
contentEditable: boolean;
|
|
29
|
+
value: string;
|
|
30
|
+
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
31
|
+
label?: React.ReactNode;
|
|
32
|
+
id?: string;
|
|
33
|
+
fullWidth?: boolean;
|
|
34
|
+
readOnly?: boolean;
|
|
35
|
+
inputProps?: React.HTMLAttributes<HTMLInputElement> & {
|
|
36
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
37
|
+
};
|
|
38
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
39
|
+
sectionsContainerRef?: React.Ref<HTMLDivElement>;
|
|
40
|
+
}
|
|
41
|
+
export interface PickersInputOtherProps extends Omit<BoxProps, keyof PickersInputPropsUsedByField> {
|
|
42
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
43
|
+
}
|
|
44
|
+
export interface PickersInputProps extends PickersInputPropsUsedByField, PickersInputOtherProps {
|
|
30
45
|
}
|
|
@@ -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 == null ? void 0 : 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,56 +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
|
-
var _inputRef$current;
|
|
76
|
-
setFocused(true);
|
|
77
|
-
const container = rootRef.current;
|
|
78
|
-
|
|
79
|
-
// Find the first input element within the container
|
|
80
|
-
const firstInput = container == null ? void 0 : container.querySelector('.content');
|
|
81
|
-
|
|
82
|
-
// Check if the input element exists before focusing it
|
|
83
|
-
if (firstInput) {
|
|
84
|
-
firstInput.focus();
|
|
85
|
-
}
|
|
86
|
-
(_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
return /*#__PURE__*/_jsxs(PickersTextFieldRoot, {
|
|
86
|
+
return /*#__PURE__*/_jsxs(PickersTextFieldRoot, _extends({
|
|
90
87
|
className: clsx(classes.root, className),
|
|
91
88
|
ref: handleRootRef,
|
|
92
89
|
focused: focused,
|
|
90
|
+
onFocus: onFocus,
|
|
91
|
+
onBlur: onBlur,
|
|
93
92
|
disabled: disabled,
|
|
94
93
|
variant: variant,
|
|
95
94
|
error: error,
|
|
96
95
|
color: color,
|
|
97
|
-
fullWidth: fullWidth,
|
|
98
96
|
required: required,
|
|
99
|
-
ownerState: ownerState
|
|
97
|
+
ownerState: ownerState
|
|
98
|
+
}, other, {
|
|
100
99
|
children: [/*#__PURE__*/_jsx(InputLabel, _extends({
|
|
101
100
|
htmlFor: id,
|
|
102
101
|
id: inputLabelId
|
|
103
102
|
}, InputLabelProps, {
|
|
104
103
|
children: label
|
|
105
104
|
})), /*#__PURE__*/_jsx(PickersInput, _extends({
|
|
106
|
-
elements,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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({
|
|
115
124
|
id: helperTextId
|
|
116
125
|
}, FormHelperTextProps, {
|
|
117
126
|
children: helperText
|
|
118
127
|
}))]
|
|
119
|
-
});
|
|
128
|
+
}));
|
|
120
129
|
});
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FormControlProps } from '@mui/material/FormControl';
|
|
3
|
+
import { FormHelperTextProps } from '@mui/material/FormHelperText';
|
|
4
|
+
import { InputLabelProps } from '@mui/material/InputLabel';
|
|
5
|
+
import { PickersInputOtherProps, PickersInputPropsUsedByField } from './PickersInput.types';
|
|
6
|
+
interface PickersTextFieldPropsUsedByField {
|
|
7
|
+
onFocus: React.FocusEventHandler<HTMLDivElement>;
|
|
8
|
+
onBlur: React.FocusEventHandler<HTMLDivElement>;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
error: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface PickersTextFieldProps extends PickersInputPropsUsedByField, PickersTextFieldPropsUsedByField, Omit<FormControlProps, keyof PickersInputPropsUsedByField | keyof PickersTextFieldPropsUsedByField> {
|
|
13
|
+
InputProps?: PickersInputOtherProps;
|
|
14
|
+
FormHelperTextProps?: Partial<FormHelperTextProps>;
|
|
15
|
+
InputLabelProps?: Partial<InputLabelProps>;
|
|
16
|
+
/**
|
|
17
|
+
* The helper text content.
|
|
18
|
+
*/
|
|
11
19
|
helperText?: React.ReactNode;
|
|
12
|
-
size?: 'small' | 'medium';
|
|
13
|
-
variant?: 'filled' | 'outlined' | 'standard';
|
|
14
|
-
valueStr: string;
|
|
15
|
-
InputProps: any;
|
|
16
|
-
valueType: 'value' | 'placeholder';
|
|
17
|
-
required?: boolean;
|
|
18
20
|
}
|
|
21
|
+
export {};
|
|
@@ -20,18 +20,22 @@ export interface PickersInputClasses {
|
|
|
20
20
|
focused: string;
|
|
21
21
|
/** State class applied to the root element if `disabled=true`. */
|
|
22
22
|
disabled: string;
|
|
23
|
+
/** State class applied to the root element if `readOnly=true`. */
|
|
24
|
+
readOnly: string;
|
|
23
25
|
/** State class applied to the root element if `error=true`. */
|
|
24
26
|
error: string;
|
|
25
27
|
/** Styles applied to the NotchedOutline element. */
|
|
26
28
|
notchedOutline: string;
|
|
27
|
-
/** Styles applied to the
|
|
29
|
+
/** Styles applied to the real hidden input element. */
|
|
28
30
|
input: string;
|
|
29
|
-
/** Styles applied to the
|
|
30
|
-
|
|
31
|
-
/** Styles applied to the
|
|
32
|
-
|
|
33
|
-
/** Styles applied to the
|
|
34
|
-
|
|
31
|
+
/** Styles applied to the container of the sections. */
|
|
32
|
+
sectionsContainer: string;
|
|
33
|
+
/** Styles applied to the content of a section. */
|
|
34
|
+
sectionContent: string;
|
|
35
|
+
/** Styles applied to the separator before a section */
|
|
36
|
+
sectionBefore: string;
|
|
37
|
+
/** Styles applied to the separator after a section */
|
|
38
|
+
sectionAfter: string;
|
|
35
39
|
/** Styles applied to the root if there is a startAdornment present */
|
|
36
40
|
adornedStart: string;
|
|
37
41
|
/** Styles applied to the root if there is an endAdornment present */
|
|
@@ -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 declare const DAY_SIZE = 36;
|
|
|
2
2
|
export declare const DAY_MARGIN = 2;
|
|
3
3
|
export declare const DIALOG_WIDTH = 320;
|
|
4
4
|
export declare const MAX_CALENDAR_HEIGHT = 280;
|
|
5
|
-
export declare const VIEW_HEIGHT =
|
|
5
|
+
export declare const VIEW_HEIGHT = 336;
|
|
6
6
|
export declare const DIGITAL_CLOCK_VIEW_HEIGHT = 232;
|
|
7
7
|
export declare const MULTI_SECTION_CLOCK_SECTION_WIDTH = 48;
|
|
@@ -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;
|