@mui/x-date-pickers 8.0.0-alpha.4 → 8.0.0-alpha.5
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/CHANGELOG.md +103 -0
- package/MonthCalendar/MonthCalendar.d.ts +1 -1
- package/MonthCalendar/MonthCalendar.js +31 -11
- package/MonthCalendar/MonthCalendar.types.d.ts +2 -2
- package/MonthCalendar/MonthCalendarButton.d.ts +24 -0
- package/MonthCalendar/{PickersMonth.js → MonthCalendarButton.js} +20 -61
- package/MonthCalendar/index.d.ts +0 -3
- package/MonthCalendar/index.js +1 -2
- package/MonthCalendar/monthCalendarClasses.d.ts +7 -1
- package/MonthCalendar/monthCalendarClasses.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -0
- package/PickersSectionList/PickersSectionList.js +21 -16
- package/PickersSectionList/PickersSectionList.types.d.ts +13 -6
- package/PickersTextField/PickersFilledInput/PickersFilledInput.d.ts +7 -0
- package/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/PickersTextField/PickersFilledInput/pickersFilledInputClasses.d.ts +1 -1
- package/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/PickersTextField/PickersInput/pickersInputClasses.d.ts +3 -2
- package/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/PickersTextField/PickersInputBase/PickersInputBase.d.ts +3 -6
- package/PickersTextField/PickersInputBase/PickersInputBase.js +36 -37
- package/PickersTextField/PickersInputBase/PickersInputBase.types.d.ts +1 -0
- package/PickersTextField/PickersOutlinedInput/Outline.d.ts +0 -1
- package/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/PickersTextField/PickersTextField.js +75 -62
- package/PickersTextField/PickersTextField.types.d.ts +43 -4
- package/PickersTextField/usePickerTextFieldOwnerState.d.ts +4 -0
- package/PickersTextField/usePickerTextFieldOwnerState.js +11 -0
- package/TimeClock/Clock.d.ts +4 -0
- package/TimeClock/Clock.js +9 -6
- package/TimeClock/TimeClock.js +21 -4
- package/YearCalendar/YearCalendar.js +46 -13
- package/YearCalendar/YearCalendar.types.d.ts +2 -2
- package/YearCalendar/YearCalendarButton.d.ts +23 -0
- package/YearCalendar/{PickersYear.js → YearCalendarButton.js} +20 -59
- package/YearCalendar/index.d.ts +0 -3
- package/YearCalendar/index.js +1 -2
- package/YearCalendar/yearCalendarClasses.d.ts +7 -1
- package/YearCalendar/yearCalendarClasses.js +1 -1
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +1 -1
- package/internals/hooks/useFieldOwnerState.d.ts +1 -0
- package/internals/hooks/useFieldOwnerState.js +6 -2
- package/models/fields.d.ts +11 -1
- package/modern/MonthCalendar/MonthCalendar.js +31 -11
- package/modern/MonthCalendar/{PickersMonth.js → MonthCalendarButton.js} +20 -61
- package/modern/MonthCalendar/index.js +1 -2
- package/modern/MonthCalendar/monthCalendarClasses.js +1 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -0
- package/modern/PickersSectionList/PickersSectionList.js +21 -16
- package/modern/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/modern/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/modern/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +36 -37
- package/modern/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/modern/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/modern/PickersTextField/PickersTextField.js +75 -62
- package/modern/PickersTextField/usePickerTextFieldOwnerState.js +11 -0
- package/modern/TimeClock/Clock.js +9 -6
- package/modern/TimeClock/TimeClock.js +21 -4
- package/modern/YearCalendar/YearCalendar.js +46 -13
- package/modern/YearCalendar/{PickersYear.js → YearCalendarButton.js} +20 -59
- package/modern/YearCalendar/index.js +1 -2
- package/modern/YearCalendar/yearCalendarClasses.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/modern/internals/hooks/useFieldOwnerState.js +6 -2
- package/node/MonthCalendar/MonthCalendar.js +31 -11
- package/node/MonthCalendar/{PickersMonth.js → MonthCalendarButton.js} +20 -61
- package/node/MonthCalendar/index.js +1 -8
- package/node/MonthCalendar/monthCalendarClasses.js +1 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -0
- package/node/PickersSectionList/PickersSectionList.js +21 -16
- package/node/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/node/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/node/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +36 -37
- package/node/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/node/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/node/PickersTextField/PickersTextField.js +75 -62
- package/node/PickersTextField/usePickerTextFieldOwnerState.js +18 -0
- package/node/TimeClock/Clock.js +9 -6
- package/node/TimeClock/TimeClock.js +21 -4
- package/node/YearCalendar/YearCalendar.js +45 -12
- package/node/YearCalendar/{PickersYear.js → YearCalendarButton.js} +20 -59
- package/node/YearCalendar/index.js +1 -8
- package/node/YearCalendar/yearCalendarClasses.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/node/internals/hooks/useFieldOwnerState.js +6 -2
- package/package.json +3 -3
- package/themeAugmentation/components.d.ts +0 -8
- package/themeAugmentation/overrides.d.ts +2 -4
- package/themeAugmentation/props.d.ts +2 -4
- package/MonthCalendar/PickersMonth.d.ts +0 -28
- package/MonthCalendar/pickersMonthClasses.d.ts +0 -13
- package/MonthCalendar/pickersMonthClasses.js +0 -5
- package/YearCalendar/PickersYear.d.ts +0 -27
- package/YearCalendar/pickersYearClasses.d.ts +0 -13
- package/YearCalendar/pickersYearClasses.js +0 -5
- package/modern/MonthCalendar/pickersMonthClasses.js +0 -5
- package/modern/YearCalendar/pickersYearClasses.js +0 -5
- package/node/MonthCalendar/pickersMonthClasses.js +0 -12
- package/node/YearCalendar/pickersYearClasses.js +0 -12
|
@@ -18,11 +18,11 @@ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"
|
|
|
18
18
|
var _capitalize = _interopRequireDefault(require("@mui/utils/capitalize"));
|
|
19
19
|
var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
|
|
20
20
|
var _visuallyHidden = _interopRequireDefault(require("@mui/utils/visuallyHidden"));
|
|
21
|
-
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
22
21
|
var _pickersInputBaseClasses = require("./pickersInputBaseClasses");
|
|
23
22
|
var _PickersSectionList = require("../../PickersSectionList");
|
|
23
|
+
var _usePickerTextFieldOwnerState = require("../usePickerTextFieldOwnerState");
|
|
24
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
-
const _excluded = ["elements", "areAllSectionsEmpty", "defaultValue", "label", "value", "onChange", "id", "autoFocus", "endAdornment", "startAdornment", "renderSuffix", "slots", "slotProps", "contentEditable", "tabIndex", "onInput", "onPaste", "onKeyDown", "fullWidth", "name", "readOnly", "inputProps", "inputRef", "sectionListRef", "onFocus", "onBlur"];
|
|
25
|
+
const _excluded = ["elements", "areAllSectionsEmpty", "defaultValue", "label", "value", "onChange", "id", "autoFocus", "endAdornment", "startAdornment", "renderSuffix", "slots", "slotProps", "contentEditable", "tabIndex", "onInput", "onPaste", "onKeyDown", "fullWidth", "name", "readOnly", "inputProps", "inputRef", "sectionListRef", "onFocus", "onBlur", "classes", "ownerState"];
|
|
26
26
|
const round = value => Math.round(value * 1e5) / 1e5;
|
|
27
27
|
const PickersInputBaseRoot = exports.PickersInputBaseRoot = (0, _styles.styled)('div', {
|
|
28
28
|
name: 'MuiPickersInputBase',
|
|
@@ -43,7 +43,7 @@ const PickersInputBaseRoot = exports.PickersInputBaseRoot = (0, _styles.styled)(
|
|
|
43
43
|
letterSpacing: `${round(0.15 / 16)}em`,
|
|
44
44
|
variants: [{
|
|
45
45
|
props: {
|
|
46
|
-
|
|
46
|
+
isInputInFullWidth: true
|
|
47
47
|
},
|
|
48
48
|
style: {
|
|
49
49
|
width: '100%'
|
|
@@ -72,36 +72,35 @@ const PickersInputBaseSectionsContainer = exports.PickersInputBaseSectionsContai
|
|
|
72
72
|
width: '182px',
|
|
73
73
|
variants: [{
|
|
74
74
|
props: {
|
|
75
|
-
|
|
75
|
+
fieldDirection: 'rtl'
|
|
76
76
|
},
|
|
77
77
|
style: {
|
|
78
78
|
textAlign: 'right /*! @noflip */'
|
|
79
79
|
}
|
|
80
80
|
}, {
|
|
81
81
|
props: {
|
|
82
|
-
|
|
82
|
+
inputSize: 'small'
|
|
83
83
|
},
|
|
84
84
|
style: {
|
|
85
85
|
paddingTop: 1
|
|
86
86
|
}
|
|
87
87
|
}, {
|
|
88
88
|
props: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
hasStartAdornment: false,
|
|
90
|
+
isFieldFocused: false,
|
|
91
|
+
isFieldValueEmpty: true
|
|
92
92
|
},
|
|
93
93
|
style: {
|
|
94
94
|
color: 'currentColor',
|
|
95
95
|
opacity: 0
|
|
96
96
|
}
|
|
97
97
|
}, {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}) => !adornedStart && !focused && !filled && label == null,
|
|
98
|
+
props: {
|
|
99
|
+
hasStartAdornment: false,
|
|
100
|
+
isFieldFocused: false,
|
|
101
|
+
isFieldValueEmpty: true,
|
|
102
|
+
inputHasLabel: false
|
|
103
|
+
},
|
|
105
104
|
style: theme.vars ? {
|
|
106
105
|
opacity: theme.vars.opacity.inputPlaceholder
|
|
107
106
|
} : {
|
|
@@ -150,21 +149,20 @@ const PickersInputBaseInput = (0, _styles.styled)('input', {
|
|
|
150
149
|
slot: 'Input',
|
|
151
150
|
overridesResolver: (props, styles) => styles.hiddenInput
|
|
152
151
|
})((0, _extends2.default)({}, _visuallyHidden.default));
|
|
153
|
-
const useUtilityClasses = ownerState => {
|
|
152
|
+
const useUtilityClasses = (classes, ownerState) => {
|
|
154
153
|
const {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
startAdornment
|
|
154
|
+
isFieldFocused,
|
|
155
|
+
isFieldDisabled,
|
|
156
|
+
isFieldReadOnly,
|
|
157
|
+
hasFieldError,
|
|
158
|
+
inputSize,
|
|
159
|
+
isInputInFullWidth,
|
|
160
|
+
inputColor,
|
|
161
|
+
hasStartAdornment,
|
|
162
|
+
hasEndAdornment
|
|
165
163
|
} = ownerState;
|
|
166
164
|
const slots = {
|
|
167
|
-
root: ['root',
|
|
165
|
+
root: ['root', isFieldFocused && !isFieldDisabled && 'focused', isFieldDisabled && 'disabled', isFieldReadOnly && 'readOnly', hasFieldError && 'error', isInputInFullWidth && 'fullWidth', `color${(0, _capitalize.default)(inputColor)}`, inputSize === 'small' && 'inputSizeSmall', hasStartAdornment && 'adornedStart', hasEndAdornment && 'adornedEnd'],
|
|
168
166
|
notchedOutline: ['notchedOutline'],
|
|
169
167
|
input: ['input'],
|
|
170
168
|
sectionsContainer: ['sectionsContainer'],
|
|
@@ -174,6 +172,7 @@ const useUtilityClasses = ownerState => {
|
|
|
174
172
|
};
|
|
175
173
|
return (0, _composeClasses.default)(slots, _pickersInputBaseClasses.getPickersInputBaseUtilityClass, classes);
|
|
176
174
|
};
|
|
175
|
+
|
|
177
176
|
/**
|
|
178
177
|
* @ignore - internal component.
|
|
179
178
|
*/
|
|
@@ -204,17 +203,20 @@ const PickersInputBase = exports.PickersInputBase = /*#__PURE__*/React.forwardRe
|
|
|
204
203
|
inputRef,
|
|
205
204
|
sectionListRef,
|
|
206
205
|
onFocus,
|
|
207
|
-
onBlur
|
|
206
|
+
onBlur,
|
|
207
|
+
classes: classesProp,
|
|
208
|
+
ownerState: ownerStateProp
|
|
208
209
|
} = props,
|
|
209
210
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
211
|
+
const ownerStateContext = (0, _usePickerTextFieldOwnerState.usePickerTextFieldOwnerState)();
|
|
210
212
|
const rootRef = React.useRef(null);
|
|
211
213
|
const handleRootRef = (0, _useForkRef.default)(ref, rootRef);
|
|
212
214
|
const handleInputRef = (0, _useForkRef.default)(inputProps?.ref, inputRef);
|
|
213
|
-
const isRtl = (0, _RtlProvider.useRtl)();
|
|
214
215
|
const muiFormControl = (0, _FormControl.useFormControl)();
|
|
215
216
|
if (!muiFormControl) {
|
|
216
217
|
throw new Error('MUI X: PickersInputBase should always be used inside a PickersTextField component');
|
|
217
218
|
}
|
|
219
|
+
const ownerState = ownerStateProp ?? ownerStateContext;
|
|
218
220
|
const handleInputFocus = event => {
|
|
219
221
|
muiFormControl.onFocus?.(event);
|
|
220
222
|
onFocus?.(event);
|
|
@@ -238,10 +240,7 @@ const PickersInputBase = exports.PickersInputBase = /*#__PURE__*/React.forwardRe
|
|
|
238
240
|
muiFormControl.onFilled();
|
|
239
241
|
}
|
|
240
242
|
}, [muiFormControl, areAllSectionsEmpty]);
|
|
241
|
-
const
|
|
242
|
-
isRtl
|
|
243
|
-
});
|
|
244
|
-
const classes = useUtilityClasses(ownerState);
|
|
243
|
+
const classes = useUtilityClasses(classesProp, ownerState);
|
|
245
244
|
const InputRoot = slots?.root || PickersInputBaseRoot;
|
|
246
245
|
const inputRootProps = (0, _useSlotProps.default)({
|
|
247
246
|
elementType: InputRoot,
|
|
@@ -274,16 +273,16 @@ const PickersInputBase = exports.PickersInputBase = /*#__PURE__*/React.forwardRe
|
|
|
274
273
|
sectionSeparator: PickersInputBaseSectionSeparator
|
|
275
274
|
},
|
|
276
275
|
slotProps: {
|
|
277
|
-
root: {
|
|
276
|
+
root: (0, _extends2.default)({}, slotProps?.input, {
|
|
278
277
|
ownerState
|
|
279
|
-
},
|
|
278
|
+
}),
|
|
280
279
|
sectionContent: {
|
|
281
280
|
className: _pickersInputBaseClasses.pickersInputBaseClasses.sectionContent
|
|
282
281
|
},
|
|
283
282
|
sectionSeparator: ({
|
|
284
|
-
|
|
283
|
+
separatorPosition
|
|
285
284
|
}) => ({
|
|
286
|
-
className:
|
|
285
|
+
className: separatorPosition === 'before' ? _pickersInputBaseClasses.pickersInputBaseClasses.sectionBefore : _pickersInputBaseClasses.pickersInputBaseClasses.sectionAfter
|
|
287
286
|
})
|
|
288
287
|
}
|
|
289
288
|
}), endAdornment, renderSuffix ? renderSuffix((0, _extends2.default)({}, muiFormControl)) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersInputBaseInput, (0, _extends2.default)({
|
|
@@ -10,6 +10,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
10
10
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _styles = require("@mui/material/styles");
|
|
13
|
+
var _createStyled = require("@mui/system/createStyled");
|
|
14
|
+
var _usePickerTextFieldOwnerState = require("../usePickerTextFieldOwnerState");
|
|
13
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
16
|
const _excluded = ["children", "className", "label", "notched", "shrink"];
|
|
15
17
|
const OutlineRoot = (0, _styles.styled)('fieldset', {
|
|
@@ -44,7 +46,9 @@ const OutlineLabel = (0, _styles.styled)('span')(({
|
|
|
44
46
|
fontFamily: theme.typography.fontFamily,
|
|
45
47
|
fontSize: 'inherit'
|
|
46
48
|
}));
|
|
47
|
-
const OutlineLegend = (0, _styles.styled)('legend'
|
|
49
|
+
const OutlineLegend = (0, _styles.styled)('legend', {
|
|
50
|
+
shouldForwardProp: prop => (0, _createStyled.shouldForwardProp)(prop) && prop !== 'notched'
|
|
51
|
+
})(({
|
|
48
52
|
theme
|
|
49
53
|
}) => ({
|
|
50
54
|
float: 'unset',
|
|
@@ -55,7 +59,7 @@ const OutlineLegend = (0, _styles.styled)('legend')(({
|
|
|
55
59
|
// Fix Horizontal scroll when label too long
|
|
56
60
|
variants: [{
|
|
57
61
|
props: {
|
|
58
|
-
|
|
62
|
+
inputHasLabel: false
|
|
59
63
|
},
|
|
60
64
|
style: {
|
|
61
65
|
padding: 0,
|
|
@@ -68,7 +72,7 @@ const OutlineLegend = (0, _styles.styled)('legend')(({
|
|
|
68
72
|
}
|
|
69
73
|
}, {
|
|
70
74
|
props: {
|
|
71
|
-
|
|
75
|
+
inputHasLabel: true
|
|
72
76
|
},
|
|
73
77
|
style: {
|
|
74
78
|
display: 'block',
|
|
@@ -94,7 +98,7 @@ const OutlineLegend = (0, _styles.styled)('legend')(({
|
|
|
94
98
|
}
|
|
95
99
|
}, {
|
|
96
100
|
props: {
|
|
97
|
-
|
|
101
|
+
inputHasLabel: true,
|
|
98
102
|
notched: true
|
|
99
103
|
},
|
|
100
104
|
style: {
|
|
@@ -114,13 +118,11 @@ const OutlineLegend = (0, _styles.styled)('legend')(({
|
|
|
114
118
|
function Outline(props) {
|
|
115
119
|
const {
|
|
116
120
|
className,
|
|
117
|
-
label
|
|
121
|
+
label,
|
|
122
|
+
notched
|
|
118
123
|
} = props,
|
|
119
124
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
120
|
-
const
|
|
121
|
-
const ownerState = (0, _extends2.default)({}, props, {
|
|
122
|
-
withLabel
|
|
123
|
-
});
|
|
125
|
+
const ownerState = (0, _usePickerTextFieldOwnerState.usePickerTextFieldOwnerState)();
|
|
124
126
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(OutlineRoot, (0, _extends2.default)({
|
|
125
127
|
"aria-hidden": true,
|
|
126
128
|
className: className
|
|
@@ -128,7 +130,8 @@ function Outline(props) {
|
|
|
128
130
|
ownerState: ownerState,
|
|
129
131
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(OutlineLegend, {
|
|
130
132
|
ownerState: ownerState,
|
|
131
|
-
|
|
133
|
+
notched: notched,
|
|
134
|
+
children: label ? /*#__PURE__*/(0, _jsxRuntime.jsx)(OutlineLabel, {
|
|
132
135
|
children: label
|
|
133
136
|
}) :
|
|
134
137
|
/*#__PURE__*/
|
|
@@ -19,7 +19,7 @@ var _Outline = _interopRequireDefault(require("./Outline"));
|
|
|
19
19
|
var _PickersInputBase = require("../PickersInputBase");
|
|
20
20
|
var _PickersInputBase2 = require("../PickersInputBase/PickersInputBase");
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _excluded = ["label", "autoFocus", "ownerState", "notched"];
|
|
22
|
+
const _excluded = ["label", "autoFocus", "ownerState", "classes", "notched"];
|
|
23
23
|
const PickersOutlinedInputRoot = (0, _styles.styled)(_PickersInputBase2.PickersInputBaseRoot, {
|
|
24
24
|
name: 'MuiPickersOutlinedInput',
|
|
25
25
|
slot: 'Root',
|
|
@@ -59,7 +59,7 @@ const PickersOutlinedInputRoot = (0, _styles.styled)(_PickersInputBase2.PickersI
|
|
|
59
59
|
// @ts-ignore
|
|
60
60
|
.filter(key => (theme.vars ?? theme).palette[key]?.main ?? false).map(color => ({
|
|
61
61
|
props: {
|
|
62
|
-
color
|
|
62
|
+
inputColor: color
|
|
63
63
|
},
|
|
64
64
|
style: {
|
|
65
65
|
[`&.${_pickersOutlinedInputClasses.pickersOutlinedInputClasses.focused}:not(.${_pickersOutlinedInputClasses.pickersOutlinedInputClasses.error}) .${_pickersOutlinedInputClasses.pickersOutlinedInputClasses.notchedOutline}`]: {
|
|
@@ -78,17 +78,14 @@ const PickersOutlinedInputSectionsContainer = (0, _styles.styled)(_PickersInputB
|
|
|
78
78
|
padding: '16.5px 0',
|
|
79
79
|
variants: [{
|
|
80
80
|
props: {
|
|
81
|
-
|
|
81
|
+
inputSize: 'small'
|
|
82
82
|
},
|
|
83
83
|
style: {
|
|
84
84
|
padding: '8.5px 0'
|
|
85
85
|
}
|
|
86
86
|
}]
|
|
87
87
|
});
|
|
88
|
-
const useUtilityClasses =
|
|
89
|
-
const {
|
|
90
|
-
classes
|
|
91
|
-
} = ownerState;
|
|
88
|
+
const useUtilityClasses = classes => {
|
|
92
89
|
const slots = {
|
|
93
90
|
root: ['root'],
|
|
94
91
|
notchedOutline: ['notchedOutline'],
|
|
@@ -97,6 +94,7 @@ const useUtilityClasses = ownerState => {
|
|
|
97
94
|
const composedClasses = (0, _composeClasses.default)(slots, _pickersOutlinedInputClasses.getPickersOutlinedInputUtilityClass, classes);
|
|
98
95
|
return (0, _extends2.default)({}, classes, composedClasses);
|
|
99
96
|
};
|
|
97
|
+
|
|
100
98
|
/**
|
|
101
99
|
* @ignore - internal component.
|
|
102
100
|
*/
|
|
@@ -107,15 +105,12 @@ const PickersOutlinedInput = exports.PickersOutlinedInput = /*#__PURE__*/React.f
|
|
|
107
105
|
});
|
|
108
106
|
const {
|
|
109
107
|
label,
|
|
110
|
-
|
|
108
|
+
classes: classesProp,
|
|
111
109
|
notched
|
|
112
110
|
} = props,
|
|
113
111
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
114
112
|
const muiFormControl = (0, _FormControl.useFormControl)();
|
|
115
|
-
const
|
|
116
|
-
color: muiFormControl?.color || 'primary'
|
|
117
|
-
});
|
|
118
|
-
const classes = useUtilityClasses(ownerState);
|
|
113
|
+
const classes = useUtilityClasses(classesProp);
|
|
119
114
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersInputBase.PickersInputBase, (0, _extends2.default)({
|
|
120
115
|
slots: {
|
|
121
116
|
root: PickersOutlinedInputRoot,
|
|
@@ -127,8 +122,7 @@ const PickersOutlinedInput = exports.PickersOutlinedInput = /*#__PURE__*/React.f
|
|
|
127
122
|
className: classes.notchedOutline,
|
|
128
123
|
label: label != null && label !== '' && muiFormControl?.required ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
129
124
|
children: [label, "\u2009", '*']
|
|
130
|
-
}) : label
|
|
131
|
-
ownerState: ownerState
|
|
125
|
+
}) : label
|
|
132
126
|
})
|
|
133
127
|
}, other, {
|
|
134
128
|
label: label,
|
|
@@ -24,8 +24,10 @@ var _pickersTextFieldClasses = require("./pickersTextFieldClasses");
|
|
|
24
24
|
var _PickersOutlinedInput = require("./PickersOutlinedInput");
|
|
25
25
|
var _PickersFilledInput = require("./PickersFilledInput");
|
|
26
26
|
var _PickersInput = require("./PickersInput");
|
|
27
|
+
var _useFieldOwnerState = require("../internals/hooks/useFieldOwnerState");
|
|
28
|
+
var _usePickerTextFieldOwnerState = require("./usePickerTextFieldOwnerState");
|
|
27
29
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
-
const _excluded = ["onFocus", "onBlur", "className", "color", "disabled", "error", "variant", "required", "InputProps", "inputProps", "inputRef", "sectionListRef", "elements", "areAllSectionsEmpty", "onClick", "onKeyDown", "onKeyUp", "onPaste", "onInput", "endAdornment", "startAdornment", "tabIndex", "contentEditable", "focused", "value", "onChange", "fullWidth", "id", "name", "helperText", "FormHelperTextProps", "label", "InputLabelProps"];
|
|
30
|
+
const _excluded = ["onFocus", "onBlur", "className", "classes", "color", "disabled", "error", "variant", "required", "InputProps", "inputProps", "inputRef", "sectionListRef", "elements", "areAllSectionsEmpty", "onClick", "onKeyDown", "onKeyUp", "onPaste", "onInput", "endAdornment", "startAdornment", "tabIndex", "contentEditable", "focused", "value", "onChange", "fullWidth", "id", "name", "helperText", "FormHelperTextProps", "label", "InputLabelProps"];
|
|
29
31
|
const VARIANT_COMPONENT = {
|
|
30
32
|
standard: _PickersInput.PickersInput,
|
|
31
33
|
filled: _PickersFilledInput.PickersFilledInput,
|
|
@@ -36,15 +38,14 @@ const PickersTextFieldRoot = (0, _styles.styled)(_FormControl.default, {
|
|
|
36
38
|
slot: 'Root',
|
|
37
39
|
overridesResolver: (props, styles) => styles.root
|
|
38
40
|
})({});
|
|
39
|
-
const useUtilityClasses = ownerState => {
|
|
41
|
+
const useUtilityClasses = (classes, ownerState) => {
|
|
40
42
|
const {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
required
|
|
43
|
+
isFieldFocused,
|
|
44
|
+
isFieldDisabled,
|
|
45
|
+
isFieldRequired
|
|
45
46
|
} = ownerState;
|
|
46
47
|
const slots = {
|
|
47
|
-
root: ['root',
|
|
48
|
+
root: ['root', isFieldFocused && !isFieldDisabled && 'focused', isFieldDisabled && 'disabled', isFieldRequired && 'required']
|
|
48
49
|
};
|
|
49
50
|
return (0, _composeClasses.default)(slots, _pickersTextFieldClasses.getPickersTextFieldUtilityClass, classes);
|
|
50
51
|
};
|
|
@@ -58,6 +59,7 @@ const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRe
|
|
|
58
59
|
onFocus,
|
|
59
60
|
onBlur,
|
|
60
61
|
className,
|
|
62
|
+
classes: classesProp,
|
|
61
63
|
color = 'primary',
|
|
62
64
|
disabled = false,
|
|
63
65
|
error = false,
|
|
@@ -98,64 +100,75 @@ const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRe
|
|
|
98
100
|
const id = (0, _useId.default)(idProp);
|
|
99
101
|
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
100
102
|
const inputLabelId = label && id ? `${id}-label` : undefined;
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
focused,
|
|
106
|
-
required,
|
|
107
|
-
variant
|
|
103
|
+
const fieldOwnerState = (0, _useFieldOwnerState.useFieldOwnerState)({
|
|
104
|
+
disabled: props.disabled,
|
|
105
|
+
required: props.required,
|
|
106
|
+
readOnly: InputProps?.readOnly
|
|
108
107
|
});
|
|
109
|
-
const
|
|
108
|
+
const ownerState = React.useMemo(() => (0, _extends2.default)({}, fieldOwnerState, {
|
|
109
|
+
isFieldValueEmpty: areAllSectionsEmpty,
|
|
110
|
+
isFieldFocused: focused ?? false,
|
|
111
|
+
hasFieldError: error ?? false,
|
|
112
|
+
inputSize: props.size ?? 'medium',
|
|
113
|
+
inputColor: color ?? 'primary',
|
|
114
|
+
isInputInFullWidth: fullWidth ?? false,
|
|
115
|
+
hasStartAdornment: Boolean(startAdornment ?? InputProps?.startAdornment),
|
|
116
|
+
hasEndAdornment: Boolean(endAdornment ?? InputProps?.endAdornment),
|
|
117
|
+
inputHasLabel: !!label
|
|
118
|
+
}), [fieldOwnerState, areAllSectionsEmpty, focused, error, props.size, color, fullWidth, startAdornment, endAdornment, InputProps?.startAdornment, InputProps?.endAdornment, label]);
|
|
119
|
+
const classes = useUtilityClasses(classesProp, ownerState);
|
|
110
120
|
const PickersInputComponent = VARIANT_COMPONENT[variant];
|
|
111
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
ownerState: ownerState
|
|
122
|
-
}, other, {
|
|
123
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_InputLabel.default, (0, _extends2.default)({
|
|
124
|
-
htmlFor: id,
|
|
125
|
-
id: inputLabelId
|
|
126
|
-
}, InputLabelProps, {
|
|
127
|
-
children: label
|
|
128
|
-
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersInputComponent, (0, _extends2.default)({
|
|
129
|
-
elements: elements,
|
|
130
|
-
areAllSectionsEmpty: areAllSectionsEmpty,
|
|
131
|
-
onClick: onClick,
|
|
132
|
-
onKeyDown: onKeyDown,
|
|
133
|
-
onKeyUp: onKeyUp,
|
|
134
|
-
onInput: onInput,
|
|
135
|
-
onPaste: onPaste,
|
|
136
|
-
onFocus: onFocus,
|
|
137
|
-
onBlur: onBlur,
|
|
138
|
-
endAdornment: endAdornment,
|
|
139
|
-
startAdornment: startAdornment,
|
|
140
|
-
tabIndex: tabIndex,
|
|
141
|
-
contentEditable: contentEditable,
|
|
142
|
-
value: value,
|
|
143
|
-
onChange: onChange,
|
|
144
|
-
id: id,
|
|
121
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_usePickerTextFieldOwnerState.PickerTextFieldOwnerStateContext.Provider, {
|
|
122
|
+
value: ownerState,
|
|
123
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(PickersTextFieldRoot, (0, _extends2.default)({
|
|
124
|
+
className: (0, _clsx.default)(classes.root, className),
|
|
125
|
+
ref: handleRootRef,
|
|
126
|
+
focused: focused,
|
|
127
|
+
disabled: disabled,
|
|
128
|
+
variant: variant,
|
|
129
|
+
error: error,
|
|
130
|
+
color: color,
|
|
145
131
|
fullWidth: fullWidth,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
132
|
+
required: required,
|
|
133
|
+
ownerState: ownerState
|
|
134
|
+
}, other, {
|
|
135
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_InputLabel.default, (0, _extends2.default)({
|
|
136
|
+
htmlFor: id,
|
|
137
|
+
id: inputLabelId
|
|
138
|
+
}, InputLabelProps, {
|
|
139
|
+
children: label
|
|
140
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersInputComponent, (0, _extends2.default)({
|
|
141
|
+
elements: elements,
|
|
142
|
+
areAllSectionsEmpty: areAllSectionsEmpty,
|
|
143
|
+
onClick: onClick,
|
|
144
|
+
onKeyDown: onKeyDown,
|
|
145
|
+
onKeyUp: onKeyUp,
|
|
146
|
+
onInput: onInput,
|
|
147
|
+
onPaste: onPaste,
|
|
148
|
+
onFocus: onFocus,
|
|
149
|
+
onBlur: onBlur,
|
|
150
|
+
endAdornment: endAdornment,
|
|
151
|
+
startAdornment: startAdornment,
|
|
152
|
+
tabIndex: tabIndex,
|
|
153
|
+
contentEditable: contentEditable,
|
|
154
|
+
value: value,
|
|
155
|
+
onChange: onChange,
|
|
156
|
+
id: id,
|
|
157
|
+
fullWidth: fullWidth,
|
|
158
|
+
inputProps: inputProps,
|
|
159
|
+
inputRef: inputRef,
|
|
160
|
+
sectionListRef: sectionListRef,
|
|
161
|
+
label: label,
|
|
162
|
+
name: name,
|
|
163
|
+
role: "group",
|
|
164
|
+
"aria-labelledby": inputLabelId
|
|
165
|
+
}, InputProps)), helperText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormHelperText.default, (0, _extends2.default)({
|
|
166
|
+
id: helperTextId
|
|
167
|
+
}, FormHelperTextProps, {
|
|
168
|
+
children: helperText
|
|
169
|
+
}))]
|
|
170
|
+
}))
|
|
171
|
+
});
|
|
159
172
|
});
|
|
160
173
|
process.env.NODE_ENV !== "production" ? PickersTextField.propTypes = {
|
|
161
174
|
// ----------------------------- Warning --------------------------------
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.usePickerTextFieldOwnerState = exports.PickerTextFieldOwnerStateContext = void 0;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
const PickerTextFieldOwnerStateContext = exports.PickerTextFieldOwnerStateContext = /*#__PURE__*/React.createContext(null);
|
|
11
|
+
const usePickerTextFieldOwnerState = () => {
|
|
12
|
+
const value = React.useContext(PickerTextFieldOwnerStateContext);
|
|
13
|
+
if (value == null) {
|
|
14
|
+
throw new Error(['MUI X: The `usePickerTextFieldOwnerState` can only be called in components that are used inside a PickerTextField component'].join('\n'));
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
};
|
|
18
|
+
exports.usePickerTextFieldOwnerState = usePickerTextFieldOwnerState;
|
package/node/TimeClock/Clock.js
CHANGED
|
@@ -185,6 +185,7 @@ function Clock(inProps) {
|
|
|
185
185
|
selectedId,
|
|
186
186
|
type,
|
|
187
187
|
viewValue,
|
|
188
|
+
viewRange: [minViewValue, maxViewValue],
|
|
188
189
|
disabled = false,
|
|
189
190
|
readOnly,
|
|
190
191
|
className,
|
|
@@ -259,6 +260,8 @@ function Clock(inProps) {
|
|
|
259
260
|
listboxRef.current.focus();
|
|
260
261
|
}
|
|
261
262
|
}, [autoFocus]);
|
|
263
|
+
const clampValue = newValue => Math.max(minViewValue, Math.min(maxViewValue, newValue));
|
|
264
|
+
const circleValue = newValue => (newValue + (maxViewValue + 1)) % (maxViewValue + 1);
|
|
262
265
|
const handleKeyDown = event => {
|
|
263
266
|
// TODO: Why this early exit?
|
|
264
267
|
if (isMoving.current) {
|
|
@@ -267,27 +270,27 @@ function Clock(inProps) {
|
|
|
267
270
|
switch (event.key) {
|
|
268
271
|
case 'Home':
|
|
269
272
|
// reset both hours and minutes
|
|
270
|
-
handleValueChange(
|
|
273
|
+
handleValueChange(minViewValue, 'partial');
|
|
271
274
|
event.preventDefault();
|
|
272
275
|
break;
|
|
273
276
|
case 'End':
|
|
274
|
-
handleValueChange(
|
|
277
|
+
handleValueChange(maxViewValue, 'partial');
|
|
275
278
|
event.preventDefault();
|
|
276
279
|
break;
|
|
277
280
|
case 'ArrowUp':
|
|
278
|
-
handleValueChange(viewValue + keyboardControlStep, 'partial');
|
|
281
|
+
handleValueChange(circleValue(viewValue + keyboardControlStep), 'partial');
|
|
279
282
|
event.preventDefault();
|
|
280
283
|
break;
|
|
281
284
|
case 'ArrowDown':
|
|
282
|
-
handleValueChange(viewValue - keyboardControlStep, 'partial');
|
|
285
|
+
handleValueChange(circleValue(viewValue - keyboardControlStep), 'partial');
|
|
283
286
|
event.preventDefault();
|
|
284
287
|
break;
|
|
285
288
|
case 'PageUp':
|
|
286
|
-
handleValueChange(viewValue + 5, 'partial');
|
|
289
|
+
handleValueChange(clampValue(viewValue + 5), 'partial');
|
|
287
290
|
event.preventDefault();
|
|
288
291
|
break;
|
|
289
292
|
case 'PageDown':
|
|
290
|
-
handleValueChange(viewValue - 5, 'partial');
|
|
293
|
+
handleValueChange(clampValue(viewValue - 5), 'partial');
|
|
291
294
|
event.preventDefault();
|
|
292
295
|
break;
|
|
293
296
|
case 'Enter':
|
|
@@ -193,6 +193,9 @@ const TimeClock = exports.TimeClock = /*#__PURE__*/React.forwardRef(function Tim
|
|
|
193
193
|
{
|
|
194
194
|
const valueWithMeridiem = (0, _timeUtils.convertValueToMeridiem)(rawValue, meridiemMode, ampm);
|
|
195
195
|
const dateWithNewHours = utils.setHours(valueOrReferenceDate, valueWithMeridiem);
|
|
196
|
+
if (utils.getHours(dateWithNewHours) !== valueWithMeridiem) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
196
199
|
const start = utils.setSeconds(utils.setMinutes(dateWithNewHours, 0), 0);
|
|
197
200
|
const end = utils.setSeconds(utils.setMinutes(dateWithNewHours, 59), 59);
|
|
198
201
|
return !containsValidTime({
|
|
@@ -232,9 +235,20 @@ const TimeClock = exports.TimeClock = /*#__PURE__*/React.forwardRef(function Tim
|
|
|
232
235
|
const valueWithMeridiem = (0, _timeUtils.convertValueToMeridiem)(hourValue, meridiemMode, ampm);
|
|
233
236
|
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), isFinish, 'hours');
|
|
234
237
|
};
|
|
238
|
+
const viewValue = utils.getHours(valueOrReferenceDate);
|
|
239
|
+
let viewRange;
|
|
240
|
+
if (ampm) {
|
|
241
|
+
if (viewValue > 12) {
|
|
242
|
+
viewRange = [12, 23];
|
|
243
|
+
} else {
|
|
244
|
+
viewRange = [0, 11];
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
viewRange = [0, 23];
|
|
248
|
+
}
|
|
235
249
|
return {
|
|
236
250
|
onChange: handleHoursChange,
|
|
237
|
-
viewValue
|
|
251
|
+
viewValue,
|
|
238
252
|
children: (0, _ClockNumbers.getHourNumbers)({
|
|
239
253
|
value,
|
|
240
254
|
utils,
|
|
@@ -243,7 +257,8 @@ const TimeClock = exports.TimeClock = /*#__PURE__*/React.forwardRef(function Tim
|
|
|
243
257
|
getClockNumberText: translations.hoursClockNumberText,
|
|
244
258
|
isDisabled: hourValue => disabled || isTimeDisabled(hourValue, 'hours'),
|
|
245
259
|
selectedId
|
|
246
|
-
})
|
|
260
|
+
}),
|
|
261
|
+
viewRange
|
|
247
262
|
};
|
|
248
263
|
}
|
|
249
264
|
case 'minutes':
|
|
@@ -262,7 +277,8 @@ const TimeClock = exports.TimeClock = /*#__PURE__*/React.forwardRef(function Tim
|
|
|
262
277
|
getClockNumberText: translations.minutesClockNumberText,
|
|
263
278
|
isDisabled: minuteValue => disabled || isTimeDisabled(minuteValue, 'minutes'),
|
|
264
279
|
selectedId
|
|
265
|
-
})
|
|
280
|
+
}),
|
|
281
|
+
viewRange: [0, 59]
|
|
266
282
|
};
|
|
267
283
|
}
|
|
268
284
|
case 'seconds':
|
|
@@ -281,7 +297,8 @@ const TimeClock = exports.TimeClock = /*#__PURE__*/React.forwardRef(function Tim
|
|
|
281
297
|
getClockNumberText: translations.secondsClockNumberText,
|
|
282
298
|
isDisabled: secondValue => disabled || isTimeDisabled(secondValue, 'seconds'),
|
|
283
299
|
selectedId
|
|
284
|
-
})
|
|
300
|
+
}),
|
|
301
|
+
viewRange: [0, 59]
|
|
285
302
|
};
|
|
286
303
|
}
|
|
287
304
|
default:
|