@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
|
@@ -9,12 +9,16 @@ interface DemoItemProps {
|
|
|
9
9
|
label?: React.ReactNode;
|
|
10
10
|
component?: string;
|
|
11
11
|
children: React.ReactNode;
|
|
12
|
+
sx?: SxProps<Theme>;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
|
15
16
|
* Please do not use it in your application.
|
|
16
17
|
*/
|
|
17
18
|
export declare function DemoItem(props: DemoItemProps): React.JSX.Element;
|
|
19
|
+
export declare namespace DemoItem {
|
|
20
|
+
var displayName: string;
|
|
21
|
+
}
|
|
18
22
|
/**
|
|
19
23
|
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
|
20
24
|
* Please do not use it in your application.
|
|
@@ -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);
|
|
@@ -61,7 +61,6 @@ export function useViews({
|
|
|
61
61
|
setFocusedView(prevFocusedView => viewToFocus === prevFocusedView ? null : prevFocusedView // If false the blur is due to view switching
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
|
-
|
|
65
64
|
onFocusedViewChange == null || onFocusedViewChange(viewToFocus, hasFocus);
|
|
66
65
|
});
|
|
67
66
|
const handleChangeView = useEventCallback(newView => {
|
|
@@ -238,7 +238,6 @@ export var AdapterLuxon = /*#__PURE__*/_createClass(function AdapterLuxon() {
|
|
|
238
238
|
if (typeof Intl === 'undefined' || typeof Intl.DateTimeFormat === 'undefined') {
|
|
239
239
|
return true; // Luxon defaults to en-US if Intl not found
|
|
240
240
|
}
|
|
241
|
-
|
|
242
241
|
return Boolean((_Intl$DateTimeFormat = new Intl.DateTimeFormat(_this.locale, {
|
|
243
242
|
hour: 'numeric'
|
|
244
243
|
})) == null || (_Intl$DateTimeFormat = _Intl$DateTimeFormat.resolvedOptions()) == null ? void 0 : _Intl$DateTimeFormat.hour12);
|
|
@@ -63,7 +63,6 @@ export var useCalendarState = function useCalendarState(params) {
|
|
|
63
63
|
});
|
|
64
64
|
}, [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
65
65
|
);
|
|
66
|
-
|
|
67
66
|
var _React$useReducer = React.useReducer(reducerFn, {
|
|
68
67
|
isMonthSwitchingAnimating: false,
|
|
69
68
|
focusedDay: referenceDate,
|
|
@@ -113,7 +113,6 @@ export var MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalendar(
|
|
|
113
113
|
});
|
|
114
114
|
}, [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
115
115
|
);
|
|
116
|
-
|
|
117
116
|
var ownerState = props;
|
|
118
117
|
var classes = useUtilityClasses(ownerState);
|
|
119
118
|
var todayMonth = React.useMemo(function () {
|
|
@@ -36,7 +36,12 @@ var MultiSectionDigitalClockSectionRoot = styled(MenuList, {
|
|
|
36
36
|
'@media (prefers-reduced-motion: no-preference)': {
|
|
37
37
|
scrollBehavior: ownerState.alreadyRendered ? 'smooth' : 'auto'
|
|
38
38
|
},
|
|
39
|
-
'
|
|
39
|
+
'@media (pointer: fine)': {
|
|
40
|
+
'&:hover': {
|
|
41
|
+
overflowY: 'auto'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
'@media (pointer: none), (pointer: coarse)': {
|
|
40
45
|
overflowY: 'auto'
|
|
41
46
|
},
|
|
42
47
|
'&:not(:first-of-type)': {
|
|
@@ -162,7 +167,8 @@ export var MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(funct
|
|
|
162
167
|
"aria-disabled": readOnly,
|
|
163
168
|
"aria-label": option.ariaLabel,
|
|
164
169
|
"aria-selected": isSelected,
|
|
165
|
-
tabIndex: tabIndex
|
|
170
|
+
tabIndex: tabIndex,
|
|
171
|
+
className: classes.item
|
|
166
172
|
}, slotProps == null ? void 0 : slotProps.digitalClockSectionItem, {
|
|
167
173
|
children: option.label
|
|
168
174
|
}), option.label);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
2
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
3
|
export function getMultiSectionDigitalClockSectionUtilityClass(slot) {
|
|
4
|
-
return generateUtilityClass('
|
|
4
|
+
return generateUtilityClass('MuiMultiSectionDigitalClockSection', slot);
|
|
5
5
|
}
|
|
6
|
-
export var multiSectionDigitalClockSectionClasses = generateUtilityClasses('
|
|
6
|
+
export var multiSectionDigitalClockSectionClasses = generateUtilityClasses('MuiMultiSectionDigitalClockSection', ['root', 'item']);
|
|
@@ -39,13 +39,13 @@ var PickersCalendarHeaderRoot = styled('div', {
|
|
|
39
39
|
})({
|
|
40
40
|
display: 'flex',
|
|
41
41
|
alignItems: 'center',
|
|
42
|
-
marginTop:
|
|
43
|
-
marginBottom:
|
|
42
|
+
marginTop: 12,
|
|
43
|
+
marginBottom: 4,
|
|
44
44
|
paddingLeft: 24,
|
|
45
45
|
paddingRight: 12,
|
|
46
46
|
// prevent jumping in safari
|
|
47
|
-
maxHeight:
|
|
48
|
-
minHeight:
|
|
47
|
+
maxHeight: 40,
|
|
48
|
+
minHeight: 40
|
|
49
49
|
});
|
|
50
50
|
var PickersCalendarHeaderLabelContainer = styled('div', {
|
|
51
51
|
name: 'MuiPickersCalendarHeader',
|
|
@@ -88,7 +88,6 @@ export function ClockPointer(inProps) {
|
|
|
88
88
|
if (type === 'hours' && viewValue > 12) {
|
|
89
89
|
angle -= 360; // round up angle to max 360 degrees
|
|
90
90
|
}
|
|
91
|
-
|
|
92
91
|
return {
|
|
93
92
|
height: Math.round((isInner ? 0.26 : 0.4) * CLOCK_WIDTH),
|
|
94
93
|
transform: "rotateZ(".concat(angle, "deg)")
|
|
@@ -117,7 +117,6 @@ export var YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(in
|
|
|
117
117
|
});
|
|
118
118
|
}, [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
119
119
|
);
|
|
120
|
-
|
|
121
120
|
var ownerState = props;
|
|
122
121
|
var classes = useUtilityClasses(ownerState);
|
|
123
122
|
var todayYear = React.useMemo(function () {
|
package/legacy/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["children", "
|
|
3
|
+
var _excluded = ["children", "className", "label"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -69,14 +69,11 @@ var OutlineLegend = styled('legend')(function (_ref) {
|
|
|
69
69
|
});
|
|
70
70
|
export default function Outline(props) {
|
|
71
71
|
var children = props.children,
|
|
72
|
-
classes = props.classes,
|
|
73
72
|
className = props.className,
|
|
74
73
|
label = props.label,
|
|
75
|
-
notched = props.notched,
|
|
76
74
|
other = _objectWithoutProperties(props, _excluded);
|
|
77
75
|
var withLabel = label != null && label !== '';
|
|
78
76
|
var ownerState = _extends({}, props, {
|
|
79
|
-
notched: notched,
|
|
80
77
|
withLabel: withLabel
|
|
81
78
|
});
|
|
82
79
|
return /*#__PURE__*/_jsx(OutlineRoot, _extends({
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
-
var _excluded = ["elements", "defaultValue", "label", "
|
|
4
|
+
var _excluded = ["elements", "areAllSectionsEmpty", "defaultValue", "label", "value", "onChange", "id", "autoFocus", "endAdornment", "startAdornment", "contentEditable", "tabIndex", "fullWidth", "inputProps", "inputRef", "sectionsContainerRef"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import Box from '@mui/material/Box';
|
|
8
8
|
import { useFormControl } from '@mui/material/FormControl';
|
|
9
9
|
import { styled } from '@mui/material/styles';
|
|
10
10
|
import useForkRef from '@mui/utils/useForkRef';
|
|
11
|
-
import
|
|
11
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
12
|
+
import capitalize from '@mui/utils/capitalize';
|
|
13
|
+
import visuallyHidden from '@mui/utils/visuallyHidden';
|
|
12
14
|
import { pickersInputClasses, getPickersInputUtilityClass } from './pickersTextFieldClasses';
|
|
13
15
|
import Outline from './Outline';
|
|
14
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
var
|
|
18
|
+
var PickersInputRoot = styled(Box, {
|
|
17
19
|
name: 'MuiPickersInput',
|
|
18
20
|
slot: 'Root',
|
|
19
21
|
overridesResolver: function overridesResolver(props, styles) {
|
|
@@ -31,6 +33,7 @@ var SectionsWrapper = styled(Box, {
|
|
|
31
33
|
alignItems: 'center',
|
|
32
34
|
width: ownerState.fullWidth ? '100%' : '25ch',
|
|
33
35
|
position: 'relative',
|
|
36
|
+
outline: 'none',
|
|
34
37
|
borderRadius: (theme.vars || theme).shape.borderRadius
|
|
35
38
|
}, "&:hover .".concat(pickersInputClasses.notchedOutline), {
|
|
36
39
|
borderColor: (theme.vars || theme).palette.text.primary
|
|
@@ -50,25 +53,33 @@ var SectionsWrapper = styled(Box, {
|
|
|
50
53
|
padding: '8.5px 14px'
|
|
51
54
|
});
|
|
52
55
|
});
|
|
53
|
-
var
|
|
56
|
+
var PickersInputSectionsContainer = styled('div', {
|
|
54
57
|
name: 'MuiPickersInput',
|
|
55
|
-
slot: '
|
|
58
|
+
slot: 'SectionsContainer',
|
|
56
59
|
overridesResolver: function overridesResolver(props, styles) {
|
|
57
|
-
return styles.
|
|
60
|
+
return styles.sectionsContainer;
|
|
58
61
|
}
|
|
59
62
|
})(function (_ref2) {
|
|
60
63
|
var theme = _ref2.theme,
|
|
61
64
|
ownerState = _ref2.ownerState;
|
|
62
|
-
return {
|
|
65
|
+
return _extends({
|
|
63
66
|
fontFamily: theme.typography.fontFamily,
|
|
64
67
|
fontSize: 'inherit',
|
|
65
68
|
lineHeight: '1.4375em',
|
|
66
69
|
// 23px
|
|
67
70
|
flexGrow: 1,
|
|
68
|
-
|
|
69
|
-
}
|
|
71
|
+
outline: 'none'
|
|
72
|
+
}, !(ownerState.adornedStart || ownerState.focused || ownerState.filled) && _extends({
|
|
73
|
+
color: 'currentColor'
|
|
74
|
+
}, ownerState.label == null && (theme.vars ? {
|
|
75
|
+
opacity: theme.vars.opacity.inputPlaceholder
|
|
76
|
+
} : {
|
|
77
|
+
opacity: theme.palette.mode === 'light' ? 0.42 : 0.5
|
|
78
|
+
}), ownerState.label != null && {
|
|
79
|
+
opacity: 0
|
|
80
|
+
}));
|
|
70
81
|
});
|
|
71
|
-
var
|
|
82
|
+
var PickersInputSection = styled('span', {
|
|
72
83
|
name: 'MuiPickersInput',
|
|
73
84
|
slot: 'Section',
|
|
74
85
|
overridesResolver: function overridesResolver(props, styles) {
|
|
@@ -84,9 +95,9 @@ var SectionContainer = styled('span', {
|
|
|
84
95
|
flexGrow: 1
|
|
85
96
|
};
|
|
86
97
|
});
|
|
87
|
-
var
|
|
98
|
+
var PickersInputContent = styled('span', {
|
|
88
99
|
name: 'MuiPickersInput',
|
|
89
|
-
slot: '
|
|
100
|
+
slot: 'SectionContent',
|
|
90
101
|
overridesResolver: function overridesResolver(props, styles) {
|
|
91
102
|
return styles.content;
|
|
92
103
|
}
|
|
@@ -100,7 +111,7 @@ var SectionInput = styled('span', {
|
|
|
100
111
|
width: 'fit-content'
|
|
101
112
|
};
|
|
102
113
|
});
|
|
103
|
-
var
|
|
114
|
+
var PickersInputSeparator = styled('span', {
|
|
104
115
|
name: 'MuiPickersInput',
|
|
105
116
|
slot: 'Separator',
|
|
106
117
|
overridesResolver: function overridesResolver(props, styles) {
|
|
@@ -111,9 +122,9 @@ var SectionSeparator = styled('span', {
|
|
|
111
122
|
whiteSpace: 'pre'
|
|
112
123
|
};
|
|
113
124
|
});
|
|
114
|
-
var
|
|
125
|
+
var PickersInputInput = styled('input', {
|
|
115
126
|
name: 'MuiPickersInput',
|
|
116
|
-
slot: '
|
|
127
|
+
slot: 'Input',
|
|
117
128
|
overridesResolver: function overridesResolver(props, styles) {
|
|
118
129
|
return styles.hiddenInput;
|
|
119
130
|
}
|
|
@@ -131,143 +142,136 @@ var NotchedOutlineRoot = styled(Outline, {
|
|
|
131
142
|
borderColor: theme.vars ? "rgba(".concat(theme.vars.palette.common.onBackgroundChannel, " / 0.23)") : borderColor
|
|
132
143
|
};
|
|
133
144
|
});
|
|
134
|
-
function InputContent(_ref6) {
|
|
135
|
-
var elements = _ref6.elements,
|
|
136
|
-
contentEditable = _ref6.contentEditable,
|
|
137
|
-
ownerState = _ref6.ownerState;
|
|
138
|
-
if (contentEditable) {
|
|
139
|
-
return elements.map(function (_ref7) {
|
|
140
|
-
var content = _ref7.content,
|
|
141
|
-
before = _ref7.before,
|
|
142
|
-
after = _ref7.after;
|
|
143
|
-
return "".concat(before.children).concat(content.children).concat(after.children);
|
|
144
|
-
}).join('');
|
|
145
|
-
}
|
|
146
|
-
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
147
|
-
children: elements.map(function (_ref8, elementIndex) {
|
|
148
|
-
var container = _ref8.container,
|
|
149
|
-
content = _ref8.content,
|
|
150
|
-
before = _ref8.before,
|
|
151
|
-
after = _ref8.after;
|
|
152
|
-
return /*#__PURE__*/_jsxs(SectionContainer, _extends({}, container, {
|
|
153
|
-
children: [/*#__PURE__*/_jsx(SectionSeparator, _extends({}, before, {
|
|
154
|
-
className: clsx(pickersInputClasses.before, before == null ? void 0 : before.className)
|
|
155
|
-
})), /*#__PURE__*/_jsx(SectionInput, _extends({}, content, {
|
|
156
|
-
className: clsx(pickersInputClasses.content, content == null ? void 0 : content.className),
|
|
157
|
-
ownerState: ownerState
|
|
158
|
-
})), /*#__PURE__*/_jsx(SectionSeparator, _extends({}, after, {
|
|
159
|
-
className: clsx(pickersInputClasses.after, after == null ? void 0 : after.className)
|
|
160
|
-
}))]
|
|
161
|
-
}), elementIndex);
|
|
162
|
-
})
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
145
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
166
146
|
var focused = ownerState.focused,
|
|
167
147
|
disabled = ownerState.disabled,
|
|
168
148
|
error = ownerState.error,
|
|
169
149
|
classes = ownerState.classes,
|
|
170
150
|
fullWidth = ownerState.fullWidth,
|
|
151
|
+
readOnly = ownerState.readOnly,
|
|
171
152
|
color = ownerState.color,
|
|
172
153
|
size = ownerState.size,
|
|
173
154
|
endAdornment = ownerState.endAdornment,
|
|
174
155
|
startAdornment = ownerState.startAdornment;
|
|
175
156
|
var slots = {
|
|
176
|
-
root: ['root', focused && !disabled && 'focused', disabled && 'disabled', error && 'error', fullWidth && 'fullWidth', "color".concat(capitalize(color)), size === 'small' && 'inputSizeSmall', Boolean(startAdornment) && 'adornedStart', Boolean(endAdornment) && 'adornedEnd'],
|
|
157
|
+
root: ['root', focused && !disabled && 'focused', disabled && 'disabled', readOnly && 'readOnly', error && 'error', fullWidth && 'fullWidth', "color".concat(capitalize(color)), size === 'small' && 'inputSizeSmall', Boolean(startAdornment) && 'adornedStart', Boolean(endAdornment) && 'adornedEnd'],
|
|
177
158
|
notchedOutline: ['notchedOutline'],
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
159
|
+
input: ['input'],
|
|
160
|
+
sectionsContainer: ['sectionsContainer'],
|
|
161
|
+
sectionContent: ['sectionContent'],
|
|
162
|
+
sectionBefore: ['sectionBefore'],
|
|
163
|
+
sectionAfter: ['sectionAfter']
|
|
182
164
|
};
|
|
183
165
|
return composeClasses(slots, getPickersInputUtilityClass, classes);
|
|
184
166
|
};
|
|
185
|
-
|
|
186
|
-
// TODO: move to utils
|
|
187
|
-
// Separates the state props from the form control
|
|
188
|
-
function formControlState(_ref9) {
|
|
189
|
-
var props = _ref9.props,
|
|
190
|
-
states = _ref9.states,
|
|
191
|
-
muiFormControl = _ref9.muiFormControl;
|
|
192
|
-
return states.reduce(function (acc, state) {
|
|
193
|
-
acc[state] = props[state];
|
|
194
|
-
if (muiFormControl) {
|
|
195
|
-
if (typeof props[state] === 'undefined') {
|
|
196
|
-
acc[state] = muiFormControl[state];
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return acc;
|
|
200
|
-
}, {});
|
|
201
|
-
}
|
|
202
|
-
var PickersInput = /*#__PURE__*/React.forwardRef(function PickersInput(props, ref) {
|
|
167
|
+
export var PickersInput = /*#__PURE__*/React.forwardRef(function PickersInput(props, ref) {
|
|
203
168
|
var elements = props.elements,
|
|
169
|
+
areAllSectionsEmpty = props.areAllSectionsEmpty,
|
|
204
170
|
defaultValue = props.defaultValue,
|
|
205
171
|
label = props.label,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
onBlur = props.onBlur,
|
|
209
|
-
valueStr = props.valueStr,
|
|
210
|
-
onValueStrChange = props.onValueStrChange,
|
|
172
|
+
value = props.value,
|
|
173
|
+
onChange = props.onChange,
|
|
211
174
|
id = props.id,
|
|
212
|
-
InputProps = props.InputProps,
|
|
213
|
-
inputProps = props.inputProps,
|
|
214
175
|
autoFocus = props.autoFocus,
|
|
215
|
-
ownerStateProp = props.ownerState,
|
|
216
176
|
endAdornment = props.endAdornment,
|
|
217
177
|
startAdornment = props.startAdornment,
|
|
178
|
+
contentEditable = props.contentEditable,
|
|
179
|
+
tabIndex = props.tabIndex,
|
|
180
|
+
fullWidth = props.fullWidth,
|
|
181
|
+
inputProps = props.inputProps,
|
|
182
|
+
inputRef = props.inputRef,
|
|
183
|
+
sectionsContainerRef = props.sectionsContainerRef,
|
|
218
184
|
other = _objectWithoutProperties(props, _excluded);
|
|
219
|
-
var
|
|
220
|
-
var
|
|
185
|
+
var rootRef = React.useRef(null);
|
|
186
|
+
var handleRootRef = useForkRef(ref, rootRef);
|
|
187
|
+
var handleInputRef = useForkRef(inputProps == null ? void 0 : inputProps.ref, inputRef);
|
|
221
188
|
var muiFormControl = useFormControl();
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
189
|
+
if (!muiFormControl) {
|
|
190
|
+
throw new Error('MUI: PickersInput should always be used inside a PickersTextField component');
|
|
191
|
+
}
|
|
192
|
+
var handleInputFocus = function handleInputFocus(event) {
|
|
193
|
+
var _muiFormControl$onFoc;
|
|
194
|
+
// Fix a bug with IE11 where the focus/blur events are triggered
|
|
195
|
+
// while the component is disabled.
|
|
196
|
+
if (muiFormControl.disabled) {
|
|
197
|
+
event.stopPropagation();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
(_muiFormControl$onFoc = muiFormControl.onFocus) == null || _muiFormControl$onFoc.call(muiFormControl, event);
|
|
201
|
+
};
|
|
227
202
|
React.useEffect(function () {
|
|
228
203
|
if (muiFormControl) {
|
|
229
204
|
muiFormControl.setAdornedStart(Boolean(startAdornment));
|
|
230
205
|
}
|
|
231
206
|
}, [muiFormControl, startAdornment]);
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
207
|
+
React.useEffect(function () {
|
|
208
|
+
if (!muiFormControl) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (areAllSectionsEmpty) {
|
|
212
|
+
muiFormControl.onEmpty();
|
|
213
|
+
} else {
|
|
214
|
+
muiFormControl.onFilled();
|
|
215
|
+
}
|
|
216
|
+
}, [muiFormControl, areAllSectionsEmpty]);
|
|
217
|
+
var ownerState = _extends({}, props, muiFormControl);
|
|
240
218
|
var classes = useUtilityClasses(ownerState);
|
|
241
|
-
return /*#__PURE__*/_jsxs(
|
|
242
|
-
ref: handleInputRef
|
|
243
|
-
}, other, {
|
|
219
|
+
return /*#__PURE__*/_jsxs(PickersInputRoot, _extends({}, other, {
|
|
244
220
|
className: classes.root,
|
|
245
|
-
onClick: onWrapperClick,
|
|
246
221
|
ownerState: ownerState,
|
|
247
|
-
"aria-invalid":
|
|
248
|
-
|
|
222
|
+
"aria-invalid": muiFormControl.error,
|
|
223
|
+
ref: handleRootRef,
|
|
224
|
+
children: [startAdornment, /*#__PURE__*/_jsx(PickersInputSectionsContainer, {
|
|
249
225
|
ownerState: ownerState,
|
|
250
|
-
className: classes.
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
226
|
+
className: classes.sectionsContainer,
|
|
227
|
+
contentEditable: contentEditable,
|
|
228
|
+
suppressContentEditableWarning: true,
|
|
229
|
+
onFocus: handleInputFocus,
|
|
230
|
+
onBlur: muiFormControl.onBlur,
|
|
231
|
+
tabIndex: tabIndex,
|
|
232
|
+
ref: sectionsContainerRef,
|
|
233
|
+
children: contentEditable ? elements.map(function (_ref6) {
|
|
234
|
+
var content = _ref6.content,
|
|
235
|
+
before = _ref6.before,
|
|
236
|
+
after = _ref6.after;
|
|
237
|
+
return "".concat(before.children).concat(content.children).concat(after.children);
|
|
238
|
+
}).join('') : /*#__PURE__*/_jsx(React.Fragment, {
|
|
239
|
+
children: elements.map(function (_ref7, elementIndex) {
|
|
240
|
+
var container = _ref7.container,
|
|
241
|
+
content = _ref7.content,
|
|
242
|
+
before = _ref7.before,
|
|
243
|
+
after = _ref7.after;
|
|
244
|
+
return /*#__PURE__*/_jsxs(PickersInputSection, _extends({}, container, {
|
|
245
|
+
children: [/*#__PURE__*/_jsx(PickersInputSeparator, _extends({}, before, {
|
|
246
|
+
className: clsx(pickersInputClasses.sectionBefore, before == null ? void 0 : before.className)
|
|
247
|
+
})), /*#__PURE__*/_jsx(PickersInputContent, _extends({}, content, {
|
|
248
|
+
suppressContentEditableWarning: true,
|
|
249
|
+
className: clsx(pickersInputClasses.sectionContent, content == null ? void 0 : content.className),
|
|
250
|
+
ownerState: ownerState
|
|
251
|
+
})), /*#__PURE__*/_jsx(PickersInputSeparator, _extends({}, after, {
|
|
252
|
+
className: clsx(pickersInputClasses.sectionAfter, after == null ? void 0 : after.className)
|
|
253
|
+
}))]
|
|
254
|
+
}), elementIndex);
|
|
255
|
+
})
|
|
256
|
+
})
|
|
262
257
|
}), endAdornment, /*#__PURE__*/_jsx(NotchedOutlineRoot, {
|
|
263
|
-
shrink:
|
|
264
|
-
notched:
|
|
258
|
+
shrink: muiFormControl.adornedStart || muiFormControl.focused || muiFormControl.filled,
|
|
259
|
+
notched: muiFormControl.adornedStart || muiFormControl.focused || muiFormControl.filled,
|
|
265
260
|
className: classes.notchedOutline,
|
|
266
|
-
label: label != null && label !== '' &&
|
|
261
|
+
label: label != null && label !== '' && muiFormControl.required ? /*#__PURE__*/_jsxs(React.Fragment, {
|
|
267
262
|
children: [label, "\u2009", '*']
|
|
268
263
|
}) : label,
|
|
269
264
|
ownerState: ownerState
|
|
270
|
-
})
|
|
265
|
+
}), /*#__PURE__*/_jsx(PickersInputInput, _extends({
|
|
266
|
+
className: classes.input,
|
|
267
|
+
value: value,
|
|
268
|
+
onChange: onChange,
|
|
269
|
+
id: id,
|
|
270
|
+
"aria-hidden": "true",
|
|
271
|
+
tabIndex: -1
|
|
272
|
+
}, inputProps, {
|
|
273
|
+
ref: handleInputRef
|
|
274
|
+
}))]
|
|
271
275
|
}));
|
|
272
276
|
});
|
|
273
|
-
|
|
277
|
+
PickersInput.muiName = 'Input';
|