@mui/x-date-pickers 8.0.0-alpha.2 → 8.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/CHANGELOG.md +376 -0
- package/DateField/useDateField.d.ts +1 -1
- package/DatePicker/DatePickerToolbar.js +8 -9
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimePicker/DateTimePickerToolbar.d.ts +6 -2
- package/DateTimePicker/DateTimePickerToolbar.js +53 -39
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
- package/DigitalClock/DigitalClock.js +13 -11
- package/DigitalClock/DigitalClock.types.d.ts +8 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +12 -10
- package/PickersActionBar/PickersActionBar.js +8 -1
- package/PickersLayout/PickersLayout.js +2 -2
- package/PickersLayout/PickersLayout.types.d.ts +4 -2
- package/PickersLayout/usePickerLayout.js +3 -3
- package/PickersShortcuts/PickersShortcuts.js +8 -1
- package/README.md +1 -1
- package/TimeClock/Clock.js +18 -21
- package/TimeClock/ClockNumber.js +15 -11
- package/TimeClock/ClockPointer.d.ts +6 -1
- package/TimeClock/ClockPointer.js +14 -10
- package/TimeClock/TimeClock.js +9 -8
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimePicker/TimePickerToolbar.js +14 -17
- package/hooks/useClearableField.d.ts +5 -3
- package/hooks/useClearableField.js +4 -2
- package/index.js +1 -1
- package/internals/components/PickerProvider.d.ts +2 -15
- package/internals/components/PickersPopper.d.ts +11 -7
- package/internals/components/PickersPopper.js +18 -20
- package/internals/components/PickersToolbar.js +15 -12
- package/internals/components/PickersToolbarButton.js +4 -6
- package/internals/components/PickersToolbarText.js +11 -13
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +3 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +3 -2
- package/internals/hooks/useOpenState.d.ts +3 -2
- package/internals/hooks/useOpenState.js +10 -9
- package/internals/hooks/usePicker/usePicker.js +3 -3
- package/internals/hooks/usePicker/usePicker.types.d.ts +3 -2
- package/internals/hooks/usePicker/usePickerProvider.d.ts +17 -6
- package/internals/hooks/usePicker/usePickerProvider.js +14 -12
- package/internals/hooks/usePicker/usePickerValue.js +22 -11
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +26 -0
- package/internals/hooks/usePicker/usePickerViews.d.ts +5 -15
- package/internals/hooks/usePicker/usePickerViews.js +5 -6
- package/internals/hooks/useToolbarOwnerState.d.ts +10 -0
- package/internals/hooks/useToolbarOwnerState.js +13 -0
- package/internals/index.d.ts +5 -1
- package/internals/index.js +3 -1
- package/internals/models/common.d.ts +1 -1
- package/locales/roRO.js +15 -18
- package/modern/DatePicker/DatePickerToolbar.js +8 -9
- package/modern/DateTimePicker/DateTimePickerToolbar.js +53 -39
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
- package/modern/DigitalClock/DigitalClock.js +13 -11
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +12 -10
- package/modern/PickersActionBar/PickersActionBar.js +8 -1
- package/modern/PickersLayout/PickersLayout.js +2 -2
- package/modern/PickersLayout/usePickerLayout.js +3 -3
- package/modern/PickersShortcuts/PickersShortcuts.js +8 -1
- package/modern/TimeClock/Clock.js +18 -21
- package/modern/TimeClock/ClockNumber.js +15 -11
- package/modern/TimeClock/ClockPointer.js +14 -10
- package/modern/TimeClock/TimeClock.js +9 -8
- package/modern/TimePicker/TimePickerToolbar.js +14 -17
- package/modern/hooks/useClearableField.js +4 -2
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersPopper.js +18 -20
- package/modern/internals/components/PickersToolbar.js +15 -12
- package/modern/internals/components/PickersToolbarButton.js +4 -6
- package/modern/internals/components/PickersToolbarText.js +11 -13
- package/modern/internals/hooks/useOpenState.js +10 -9
- package/modern/internals/hooks/usePicker/usePicker.js +3 -3
- package/modern/internals/hooks/usePicker/usePickerProvider.js +14 -12
- package/modern/internals/hooks/usePicker/usePickerValue.js +22 -11
- package/modern/internals/hooks/usePicker/usePickerViews.js +5 -6
- package/modern/internals/hooks/useToolbarOwnerState.js +13 -0
- package/modern/internals/index.js +3 -1
- package/modern/locales/roRO.js +15 -18
- package/node/DatePicker/DatePickerToolbar.js +8 -9
- package/node/DateTimePicker/DateTimePickerToolbar.js +54 -39
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
- package/node/DigitalClock/DigitalClock.js +13 -11
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +12 -10
- package/node/PickersActionBar/PickersActionBar.js +8 -1
- package/node/PickersLayout/PickersLayout.js +2 -2
- package/node/PickersLayout/usePickerLayout.js +3 -3
- package/node/PickersShortcuts/PickersShortcuts.js +8 -1
- package/node/TimeClock/Clock.js +18 -21
- package/node/TimeClock/ClockNumber.js +15 -11
- package/node/TimeClock/ClockPointer.js +14 -10
- package/node/TimeClock/TimeClock.js +9 -8
- package/node/TimePicker/TimePickerToolbar.js +14 -17
- package/node/hooks/useClearableField.js +4 -2
- package/node/index.js +1 -1
- package/node/internals/components/PickersPopper.js +18 -20
- package/node/internals/components/PickersToolbar.js +15 -12
- package/node/internals/components/PickersToolbarButton.js +4 -6
- package/node/internals/components/PickersToolbarText.js +10 -12
- package/node/internals/hooks/useOpenState.js +10 -9
- package/node/internals/hooks/usePicker/usePicker.js +3 -3
- package/node/internals/hooks/usePicker/usePickerProvider.js +15 -13
- package/node/internals/hooks/usePicker/usePickerValue.js +22 -11
- package/node/internals/hooks/usePicker/usePickerViews.js +5 -6
- package/node/internals/hooks/useToolbarOwnerState.js +21 -0
- package/node/internals/index.js +15 -1
- package/node/locales/roRO.js +15 -18
- package/package.json +1 -1
|
@@ -5,12 +5,19 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
5
5
|
const _excluded = ["items", "changeImportance", "isLandscape", "onChange", "isValid"],
|
|
6
6
|
_excluded2 = ["getValue"];
|
|
7
7
|
import * as React from 'react';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
8
9
|
import PropTypes from 'prop-types';
|
|
9
10
|
import List from '@mui/material/List';
|
|
10
11
|
import ListItem from '@mui/material/ListItem';
|
|
11
12
|
import Chip from '@mui/material/Chip';
|
|
12
13
|
import { VIEW_HEIGHT } from "../internals/constants/dimensions.js";
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const PickersShortcutsRoot = styled(List, {
|
|
16
|
+
name: 'MuiPickersLayout',
|
|
17
|
+
slot: 'Shortcuts',
|
|
18
|
+
overridesResolver: (_, styles) => styles.shortcuts
|
|
19
|
+
})({});
|
|
20
|
+
|
|
14
21
|
/**
|
|
15
22
|
* Demos:
|
|
16
23
|
*
|
|
@@ -47,7 +54,7 @@ function PickersShortcuts(props) {
|
|
|
47
54
|
disabled: !isValid(newValue)
|
|
48
55
|
});
|
|
49
56
|
});
|
|
50
|
-
return /*#__PURE__*/_jsx(
|
|
57
|
+
return /*#__PURE__*/_jsx(PickersShortcutsRoot, _extends({
|
|
51
58
|
dense: true,
|
|
52
59
|
sx: [{
|
|
53
60
|
maxHeight: VIEW_HEIGHT,
|
|
@@ -11,20 +11,17 @@ import { useUtils } from "../internals/hooks/useUtils.js";
|
|
|
11
11
|
import { CLOCK_HOUR_WIDTH, getHours, getMinutes } from "./shared.js";
|
|
12
12
|
import { getClockUtilityClass } from "./clockClasses.js";
|
|
13
13
|
import { formatMeridiem } from "../internals/utils/date-utils.js";
|
|
14
|
+
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
14
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
const useUtilityClasses = ownerState => {
|
|
16
|
-
const {
|
|
17
|
-
classes,
|
|
18
|
-
meridiemMode
|
|
19
|
-
} = ownerState;
|
|
16
|
+
const useUtilityClasses = (classes, ownerState) => {
|
|
20
17
|
const slots = {
|
|
21
18
|
root: ['root'],
|
|
22
19
|
clock: ['clock'],
|
|
23
20
|
wrapper: ['wrapper'],
|
|
24
21
|
squareMask: ['squareMask'],
|
|
25
22
|
pin: ['pin'],
|
|
26
|
-
amButton: ['amButton',
|
|
27
|
-
pmButton: ['pmButton',
|
|
23
|
+
amButton: ['amButton', ownerState.clockMeridiemMode === 'am' && 'selected'],
|
|
24
|
+
pmButton: ['pmButton', ownerState.clockMeridiemMode === 'pm' && 'selected'],
|
|
28
25
|
meridiemText: ['meridiemText']
|
|
29
26
|
};
|
|
30
27
|
return composeClasses(slots, getClockUtilityClass, classes);
|
|
@@ -78,7 +75,7 @@ const ClockSquareMask = styled('div', {
|
|
|
78
75
|
userSelect: 'none',
|
|
79
76
|
variants: [{
|
|
80
77
|
props: {
|
|
81
|
-
|
|
78
|
+
isClockDisabled: false
|
|
82
79
|
},
|
|
83
80
|
style: {
|
|
84
81
|
'@media (pointer: fine)': {
|
|
@@ -182,13 +179,20 @@ export function Clock(inProps) {
|
|
|
182
179
|
viewValue,
|
|
183
180
|
disabled = false,
|
|
184
181
|
readOnly,
|
|
185
|
-
className
|
|
182
|
+
className,
|
|
183
|
+
classes: classesProp
|
|
186
184
|
} = props;
|
|
187
|
-
const ownerState = props;
|
|
188
185
|
const utils = useUtils();
|
|
189
186
|
const translations = usePickerTranslations();
|
|
187
|
+
const {
|
|
188
|
+
ownerState: pickerOwnerState
|
|
189
|
+
} = usePickerPrivateContext();
|
|
190
|
+
const ownerState = _extends({}, pickerOwnerState, {
|
|
191
|
+
isClockDisabled: disabled,
|
|
192
|
+
clockMeridiemMode: meridiemMode
|
|
193
|
+
});
|
|
190
194
|
const isMoving = React.useRef(false);
|
|
191
|
-
const classes = useUtilityClasses(ownerState);
|
|
195
|
+
const classes = useUtilityClasses(classesProp, ownerState);
|
|
192
196
|
const isSelectedTimeDisabled = isTimeDisabled(viewValue, type);
|
|
193
197
|
const isPointerInner = !ampm && type === 'hours' && (viewValue < 1 || viewValue > 12);
|
|
194
198
|
const handleValueChange = (newValue, isFinish) => {
|
|
@@ -236,12 +240,7 @@ export function Clock(inProps) {
|
|
|
236
240
|
}
|
|
237
241
|
setTime(event.nativeEvent, 'finish');
|
|
238
242
|
};
|
|
239
|
-
const
|
|
240
|
-
if (type === 'hours') {
|
|
241
|
-
return true;
|
|
242
|
-
}
|
|
243
|
-
return viewValue % 5 === 0;
|
|
244
|
-
}, [type, viewValue]);
|
|
243
|
+
const isPointerBetweenTwoClockValues = type === 'hours' ? false : viewValue % 5 !== 0;
|
|
245
244
|
const keyboardControlStep = type === 'minutes' ? minutesStep : 1;
|
|
246
245
|
const listboxRef = React.useRef(null);
|
|
247
246
|
// Since this is rendered when a Popper is opened we can't use passive effects.
|
|
@@ -302,9 +301,7 @@ export function Clock(inProps) {
|
|
|
302
301
|
onTouchEnd: handleTouchEnd,
|
|
303
302
|
onMouseUp: handleMouseUp,
|
|
304
303
|
onMouseMove: handleMouseMove,
|
|
305
|
-
ownerState:
|
|
306
|
-
disabled
|
|
307
|
-
},
|
|
304
|
+
ownerState: ownerState,
|
|
308
305
|
className: classes.squareMask
|
|
309
306
|
}), !isSelectedTimeDisabled && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
310
307
|
children: [/*#__PURE__*/_jsx(ClockPin, {
|
|
@@ -313,7 +310,7 @@ export function Clock(inProps) {
|
|
|
313
310
|
type: type,
|
|
314
311
|
viewValue: viewValue,
|
|
315
312
|
isInner: isPointerInner,
|
|
316
|
-
|
|
313
|
+
isBetweenTwoClockValues: isPointerBetweenTwoClockValues
|
|
317
314
|
})]
|
|
318
315
|
}), /*#__PURE__*/_jsx(ClockWrapper, {
|
|
319
316
|
"aria-activedescendant": selectedId,
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["className", "disabled", "index", "inner", "label", "selected"];
|
|
3
|
+
const _excluded = ["className", "classes", "disabled", "index", "inner", "label", "selected"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
7
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
8
|
import { CLOCK_WIDTH, CLOCK_HOUR_WIDTH } from "./shared.js";
|
|
9
9
|
import { getClockNumberUtilityClass, clockNumberClasses } from "./clockNumberClasses.js";
|
|
10
|
+
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
const useUtilityClasses = ownerState => {
|
|
12
|
-
const {
|
|
13
|
-
classes,
|
|
14
|
-
selected,
|
|
15
|
-
disabled
|
|
16
|
-
} = ownerState;
|
|
12
|
+
const useUtilityClasses = (classes, ownerState) => {
|
|
17
13
|
const slots = {
|
|
18
|
-
root: ['root',
|
|
14
|
+
root: ['root', ownerState.isClockNumberSelected && 'selected', ownerState.isClockNumberDisabled && 'disabled']
|
|
19
15
|
};
|
|
20
16
|
return composeClasses(slots, getClockNumberUtilityClass, classes);
|
|
21
17
|
};
|
|
@@ -52,7 +48,7 @@ const ClockNumberRoot = styled('span', {
|
|
|
52
48
|
},
|
|
53
49
|
variants: [{
|
|
54
50
|
props: {
|
|
55
|
-
|
|
51
|
+
isClockNumberInInnerRing: true
|
|
56
52
|
},
|
|
57
53
|
style: _extends({}, theme.typography.body2, {
|
|
58
54
|
color: (theme.vars || theme).palette.text.secondary
|
|
@@ -70,6 +66,7 @@ export function ClockNumber(inProps) {
|
|
|
70
66
|
});
|
|
71
67
|
const {
|
|
72
68
|
className,
|
|
69
|
+
classes: classesProp,
|
|
73
70
|
disabled,
|
|
74
71
|
index,
|
|
75
72
|
inner,
|
|
@@ -77,8 +74,15 @@ export function ClockNumber(inProps) {
|
|
|
77
74
|
selected
|
|
78
75
|
} = props,
|
|
79
76
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
80
|
-
const
|
|
81
|
-
|
|
77
|
+
const {
|
|
78
|
+
ownerState: pickerOwnerState
|
|
79
|
+
} = usePickerPrivateContext();
|
|
80
|
+
const ownerState = _extends({}, pickerOwnerState, {
|
|
81
|
+
isClockNumberInInnerRing: inner,
|
|
82
|
+
isClockNumberSelected: selected,
|
|
83
|
+
isClockNumberDisabled: disabled
|
|
84
|
+
});
|
|
85
|
+
const classes = useUtilityClasses(classesProp, ownerState);
|
|
82
86
|
const angle = index % 12 / 12 * Math.PI * 2 - Math.PI / 2;
|
|
83
87
|
const length = (CLOCK_WIDTH - CLOCK_HOUR_WIDTH - 2) / 2 * (inner ? 0.65 : 1);
|
|
84
88
|
const x = Math.round(Math.cos(angle) * length);
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["className", "
|
|
3
|
+
const _excluded = ["className", "classes", "isBetweenTwoClockValues", "isInner", "type", "viewValue"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
7
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
8
|
import { CLOCK_WIDTH, CLOCK_HOUR_WIDTH } from "./shared.js";
|
|
9
9
|
import { getClockPointerUtilityClass } from "./clockPointerClasses.js";
|
|
10
|
+
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
const useUtilityClasses =
|
|
12
|
-
const {
|
|
13
|
-
classes
|
|
14
|
-
} = ownerState;
|
|
12
|
+
const useUtilityClasses = classes => {
|
|
15
13
|
const slots = {
|
|
16
14
|
root: ['root'],
|
|
17
15
|
thumb: ['thumb']
|
|
@@ -33,7 +31,7 @@ const ClockPointerRoot = styled('div', {
|
|
|
33
31
|
transformOrigin: 'center bottom 0px',
|
|
34
32
|
variants: [{
|
|
35
33
|
props: {
|
|
36
|
-
|
|
34
|
+
isClockPointerAnimated: true
|
|
37
35
|
},
|
|
38
36
|
style: {
|
|
39
37
|
transition: theme.transitions.create(['transform', 'height'])
|
|
@@ -58,7 +56,7 @@ const ClockPointerThumb = styled('div', {
|
|
|
58
56
|
boxSizing: 'content-box',
|
|
59
57
|
variants: [{
|
|
60
58
|
props: {
|
|
61
|
-
|
|
59
|
+
isBetweenTwoClockValues: false
|
|
62
60
|
},
|
|
63
61
|
style: {
|
|
64
62
|
backgroundColor: (theme.vars || theme).palette.primary.main
|
|
@@ -76,6 +74,8 @@ export function ClockPointer(inProps) {
|
|
|
76
74
|
});
|
|
77
75
|
const {
|
|
78
76
|
className,
|
|
77
|
+
classes: classesProp,
|
|
78
|
+
isBetweenTwoClockValues,
|
|
79
79
|
isInner,
|
|
80
80
|
type,
|
|
81
81
|
viewValue
|
|
@@ -85,10 +85,14 @@ export function ClockPointer(inProps) {
|
|
|
85
85
|
React.useEffect(() => {
|
|
86
86
|
previousType.current = type;
|
|
87
87
|
}, [type]);
|
|
88
|
-
const
|
|
89
|
-
|
|
88
|
+
const {
|
|
89
|
+
ownerState: pickerOwnerState
|
|
90
|
+
} = usePickerPrivateContext();
|
|
91
|
+
const ownerState = _extends({}, pickerOwnerState, {
|
|
92
|
+
isClockPointerAnimated: previousType.current !== type,
|
|
93
|
+
isClockPointerBetweenTwoValues: isBetweenTwoClockValues
|
|
90
94
|
});
|
|
91
|
-
const classes = useUtilityClasses(
|
|
95
|
+
const classes = useUtilityClasses(classesProp);
|
|
92
96
|
const getAngleStyle = () => {
|
|
93
97
|
const max = type === 'hours' ? 12 : 60;
|
|
94
98
|
let angle = 360 / max * viewValue;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["ampm", "ampmInClock", "autoFocus", "slots", "slotProps", "value", "defaultValue", "referenceDate", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableTime", "showViewSwitcher", "onChange", "view", "views", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "disabled", "readOnly", "timezone"];
|
|
5
|
+
const _excluded = ["ampm", "ampmInClock", "autoFocus", "slots", "slotProps", "value", "defaultValue", "referenceDate", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableTime", "showViewSwitcher", "onChange", "view", "views", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "classes", "disabled", "readOnly", "timezone"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
@@ -21,11 +21,9 @@ import { getHourNumbers, getMinutesNumbers } from "./ClockNumbers.js";
|
|
|
21
21
|
import { useControlledValueWithTimezone } from "../internals/hooks/useValueWithTimezone.js";
|
|
22
22
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
23
23
|
import { useClockReferenceDate } from "../internals/hooks/useClockReferenceDate.js";
|
|
24
|
+
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
24
25
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
-
const useUtilityClasses =
|
|
26
|
-
const {
|
|
27
|
-
classes
|
|
28
|
-
} = ownerState;
|
|
26
|
+
const useUtilityClasses = classes => {
|
|
29
27
|
const slots = {
|
|
30
28
|
root: ['root'],
|
|
31
29
|
arrowSwitcher: ['arrowSwitcher']
|
|
@@ -93,6 +91,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
93
91
|
focusedView,
|
|
94
92
|
onFocusedViewChange,
|
|
95
93
|
className,
|
|
94
|
+
classes: classesProp,
|
|
96
95
|
disabled,
|
|
97
96
|
readOnly,
|
|
98
97
|
timezone: timezoneProp
|
|
@@ -120,6 +119,10 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
120
119
|
});
|
|
121
120
|
const translations = usePickerTranslations();
|
|
122
121
|
const now = useNow(timezone);
|
|
122
|
+
const selectedId = useId();
|
|
123
|
+
const {
|
|
124
|
+
ownerState
|
|
125
|
+
} = usePickerPrivateContext();
|
|
123
126
|
const {
|
|
124
127
|
view,
|
|
125
128
|
setView,
|
|
@@ -214,7 +217,6 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
214
217
|
throw new Error('not supported');
|
|
215
218
|
}
|
|
216
219
|
}, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
|
|
217
|
-
const selectedId = useId();
|
|
218
220
|
const viewProps = React.useMemo(() => {
|
|
219
221
|
switch (view) {
|
|
220
222
|
case 'hours':
|
|
@@ -279,8 +281,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
279
281
|
throw new Error('You must provide the type for ClockView');
|
|
280
282
|
}
|
|
281
283
|
}, [view, utils, value, ampm, translations.hoursClockNumberText, translations.minutesClockNumberText, translations.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, isTimeDisabled, selectedId, disabled]);
|
|
282
|
-
const
|
|
283
|
-
const classes = useUtilityClasses(ownerState);
|
|
284
|
+
const classes = useUtilityClasses(classesProp);
|
|
284
285
|
return /*#__PURE__*/_jsxs(TimeClockRoot, _extends({
|
|
285
286
|
ref: ref,
|
|
286
287
|
className: clsx(classes.root, className),
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["ampm", "ampmInClock", "value", "isLandscape", "onChange", "view", "onViewChange", "views", "className"];
|
|
5
|
+
const _excluded = ["ampm", "ampmInClock", "value", "isLandscape", "onChange", "view", "onViewChange", "views", "className", "classes"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
|
-
import { useRtl } from '@mui/system/RtlProvider';
|
|
10
9
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
11
10
|
import composeClasses from '@mui/utils/composeClasses';
|
|
12
11
|
import { PickersToolbarText } from "../internals/components/PickersToolbarText.js";
|
|
@@ -19,18 +18,18 @@ import { useMeridiemMode } from "../internals/hooks/date-helpers-hooks.js";
|
|
|
19
18
|
import { getTimePickerToolbarUtilityClass, timePickerToolbarClasses } from "./timePickerToolbarClasses.js";
|
|
20
19
|
import { formatMeridiem } from "../internals/utils/date-utils.js";
|
|
21
20
|
import { usePickerContext } from "../hooks/index.js";
|
|
21
|
+
import { useToolbarOwnerState } from "../internals/hooks/useToolbarOwnerState.js";
|
|
22
22
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
|
-
const useUtilityClasses = ownerState => {
|
|
23
|
+
const useUtilityClasses = (classes, ownerState) => {
|
|
24
24
|
const {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
isRtl
|
|
25
|
+
pickerOrientation,
|
|
26
|
+
toolbarDirection
|
|
28
27
|
} = ownerState;
|
|
29
28
|
const slots = {
|
|
30
29
|
root: ['root'],
|
|
31
30
|
separator: ['separator'],
|
|
32
|
-
hourMinuteLabel: ['hourMinuteLabel',
|
|
33
|
-
ampmSelection: ['ampmSelection',
|
|
31
|
+
hourMinuteLabel: ['hourMinuteLabel', pickerOrientation === 'landscape' && 'hourMinuteLabelLandscape', toolbarDirection === 'rtl' && 'hourMinuteLabelReverse'],
|
|
32
|
+
ampmSelection: ['ampmSelection', pickerOrientation === 'landscape' && 'ampmLandscape'],
|
|
34
33
|
ampmLabel: ['ampmLabel']
|
|
35
34
|
};
|
|
36
35
|
return composeClasses(slots, getTimePickerToolbarUtilityClass, classes);
|
|
@@ -62,14 +61,14 @@ const TimePickerToolbarHourMinuteLabel = styled('div', {
|
|
|
62
61
|
alignItems: 'flex-end',
|
|
63
62
|
variants: [{
|
|
64
63
|
props: {
|
|
65
|
-
|
|
64
|
+
toolbarDirection: 'rtl'
|
|
66
65
|
},
|
|
67
66
|
style: {
|
|
68
67
|
flexDirection: 'row-reverse'
|
|
69
68
|
}
|
|
70
69
|
}, {
|
|
71
70
|
props: {
|
|
72
|
-
|
|
71
|
+
pickerOrientation: 'landscape'
|
|
73
72
|
},
|
|
74
73
|
style: {
|
|
75
74
|
marginTop: 'auto'
|
|
@@ -94,7 +93,7 @@ const TimePickerToolbarAmPmSelection = styled('div', {
|
|
|
94
93
|
},
|
|
95
94
|
variants: [{
|
|
96
95
|
props: {
|
|
97
|
-
|
|
96
|
+
pickerOrientation: 'landscape'
|
|
98
97
|
},
|
|
99
98
|
style: {
|
|
100
99
|
margin: '4px 0 auto',
|
|
@@ -129,12 +128,14 @@ function TimePickerToolbar(inProps) {
|
|
|
129
128
|
view,
|
|
130
129
|
onViewChange,
|
|
131
130
|
views,
|
|
132
|
-
className
|
|
131
|
+
className,
|
|
132
|
+
classes: classesProp
|
|
133
133
|
} = props,
|
|
134
134
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
135
135
|
const utils = useUtils();
|
|
136
136
|
const translations = usePickerTranslations();
|
|
137
|
-
const
|
|
137
|
+
const ownerState = useToolbarOwnerState();
|
|
138
|
+
const classes = useUtilityClasses(classesProp, ownerState);
|
|
138
139
|
const {
|
|
139
140
|
disabled,
|
|
140
141
|
readOnly
|
|
@@ -145,10 +146,6 @@ function TimePickerToolbar(inProps) {
|
|
|
145
146
|
handleMeridiemChange
|
|
146
147
|
} = useMeridiemMode(value, ampm, onChange);
|
|
147
148
|
const formatHours = time => ampm ? utils.format(time, 'hours12h') : utils.format(time, 'hours24h');
|
|
148
|
-
const ownerState = _extends({}, props, {
|
|
149
|
-
isRtl
|
|
150
|
-
});
|
|
151
|
-
const classes = useUtilityClasses(ownerState);
|
|
152
149
|
const separator = /*#__PURE__*/_jsx(TimePickerToolbarSeparator, {
|
|
153
150
|
tabIndex: -1,
|
|
154
151
|
value: ":",
|
|
@@ -10,9 +10,11 @@ import MuiIconButton from '@mui/material/IconButton';
|
|
|
10
10
|
import InputAdornment from '@mui/material/InputAdornment';
|
|
11
11
|
import { ClearIcon } from "../icons/index.js";
|
|
12
12
|
import { usePickerTranslations } from "./usePickerTranslations.js";
|
|
13
|
+
import { useFieldOwnerState } from "../internals/hooks/useFieldOwnerState.js";
|
|
13
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
15
|
export const useClearableField = props => {
|
|
15
16
|
const translations = usePickerTranslations();
|
|
17
|
+
const ownerState = useFieldOwnerState(props);
|
|
16
18
|
const {
|
|
17
19
|
clearable,
|
|
18
20
|
onClear,
|
|
@@ -27,7 +29,7 @@ export const useClearableField = props => {
|
|
|
27
29
|
const _useSlotProps = useSlotProps({
|
|
28
30
|
elementType: IconButton,
|
|
29
31
|
externalSlotProps: slotProps?.clearButton,
|
|
30
|
-
ownerState
|
|
32
|
+
ownerState,
|
|
31
33
|
className: 'clearButton',
|
|
32
34
|
additionalProps: {
|
|
33
35
|
title: translations.fieldClearLabel,
|
|
@@ -39,7 +41,7 @@ export const useClearableField = props => {
|
|
|
39
41
|
const endClearIconProps = useSlotProps({
|
|
40
42
|
elementType: EndClearIcon,
|
|
41
43
|
externalSlotProps: slotProps?.clearIcon,
|
|
42
|
-
ownerState
|
|
44
|
+
ownerState
|
|
43
45
|
});
|
|
44
46
|
return _extends({}, other, {
|
|
45
47
|
InputProps: _extends({}, InputProps, {
|
package/modern/index.js
CHANGED
|
@@ -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 = ["PaperComponent", "
|
|
3
|
+
const _excluded = ["PaperComponent", "ownerState", "children", "paperSlotProps", "paperClasses", "onPaperClick", "onPaperTouchStart"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
6
6
|
import Grow from '@mui/material/Grow';
|
|
@@ -13,11 +13,9 @@ import { styled, useThemeProps } from '@mui/material/styles';
|
|
|
13
13
|
import { getPickersPopperUtilityClass } from "./pickersPopperClasses.js";
|
|
14
14
|
import { getActiveElement } from "../utils/utils.js";
|
|
15
15
|
import { useDefaultReduceAnimations } from "../hooks/useDefaultReduceAnimations.js";
|
|
16
|
+
import { usePickerPrivateContext } from "../hooks/usePickerPrivateContext.js";
|
|
16
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
-
const useUtilityClasses =
|
|
18
|
-
const {
|
|
19
|
-
classes
|
|
20
|
-
} = ownerState;
|
|
18
|
+
const useUtilityClasses = classes => {
|
|
21
19
|
const slots = {
|
|
22
20
|
root: ['root'],
|
|
23
21
|
paper: ['paper']
|
|
@@ -42,8 +40,8 @@ const PickersPopperPaper = styled(MuiPaper, {
|
|
|
42
40
|
transformOrigin: 'top center',
|
|
43
41
|
variants: [{
|
|
44
42
|
props: ({
|
|
45
|
-
|
|
46
|
-
}) => ['top', 'top-start', 'top-end'].includes(
|
|
43
|
+
popperPlacement
|
|
44
|
+
}) => ['top', 'top-start', 'top-end'].includes(popperPlacement),
|
|
47
45
|
style: {
|
|
48
46
|
transformOrigin: 'bottom center'
|
|
49
47
|
}
|
|
@@ -167,8 +165,7 @@ function useClickAwayListener(active, onClickAway) {
|
|
|
167
165
|
const PickersPopperPaperWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
168
166
|
const {
|
|
169
167
|
PaperComponent,
|
|
170
|
-
|
|
171
|
-
ownerState: inOwnerState,
|
|
168
|
+
ownerState,
|
|
172
169
|
children,
|
|
173
170
|
paperSlotProps,
|
|
174
171
|
paperClasses,
|
|
@@ -178,9 +175,6 @@ const PickersPopperPaperWrapper = /*#__PURE__*/React.forwardRef((props, ref) =>
|
|
|
178
175
|
// https://mui.com/material-ui/transitions/#child-requirement
|
|
179
176
|
} = props,
|
|
180
177
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
181
|
-
const ownerState = _extends({}, inOwnerState, {
|
|
182
|
-
placement: popperPlacement
|
|
183
|
-
});
|
|
184
178
|
const paperProps = useSlotProps({
|
|
185
179
|
elementType: PaperComponent,
|
|
186
180
|
externalSlotProps: paperSlotProps,
|
|
@@ -219,10 +213,11 @@ export function PickersPopper(inProps) {
|
|
|
219
213
|
onDismiss,
|
|
220
214
|
open,
|
|
221
215
|
role,
|
|
222
|
-
placement,
|
|
216
|
+
placement = 'bottom',
|
|
223
217
|
slots,
|
|
224
218
|
slotProps,
|
|
225
|
-
reduceAnimations: inReduceAnimations
|
|
219
|
+
reduceAnimations: inReduceAnimations,
|
|
220
|
+
classes: classesProp
|
|
226
221
|
} = props;
|
|
227
222
|
React.useEffect(() => {
|
|
228
223
|
function handleKeyDown(nativeEvent) {
|
|
@@ -256,10 +251,15 @@ export function PickersPopper(inProps) {
|
|
|
256
251
|
const paperRef = React.useRef(null);
|
|
257
252
|
const handleRef = useForkRef(paperRef, containerRef);
|
|
258
253
|
const handlePaperRef = useForkRef(handleRef, clickAwayRef);
|
|
259
|
-
const
|
|
260
|
-
const classes = useUtilityClasses(ownerState);
|
|
254
|
+
const classes = useUtilityClasses(classesProp);
|
|
261
255
|
const defaultReduceAnimations = useDefaultReduceAnimations();
|
|
262
256
|
const reduceAnimations = inReduceAnimations ?? defaultReduceAnimations;
|
|
257
|
+
const {
|
|
258
|
+
ownerState: pickerOwnerState
|
|
259
|
+
} = usePickerPrivateContext();
|
|
260
|
+
const ownerState = _extends({}, pickerOwnerState, {
|
|
261
|
+
popperPlacement: placement
|
|
262
|
+
});
|
|
263
263
|
const handleKeyDown = event => {
|
|
264
264
|
if (event.key === 'Escape') {
|
|
265
265
|
// stop the propagation to avoid closing parent modal
|
|
@@ -283,12 +283,11 @@ export function PickersPopper(inProps) {
|
|
|
283
283
|
onKeyDown: handleKeyDown
|
|
284
284
|
},
|
|
285
285
|
className: classes.root,
|
|
286
|
-
ownerState
|
|
286
|
+
ownerState
|
|
287
287
|
});
|
|
288
288
|
return /*#__PURE__*/_jsx(Popper, _extends({}, popperProps, {
|
|
289
289
|
children: ({
|
|
290
|
-
TransitionProps
|
|
291
|
-
placement: popperPlacement
|
|
290
|
+
TransitionProps
|
|
292
291
|
}) => /*#__PURE__*/_jsx(FocusTrap, _extends({
|
|
293
292
|
open: open,
|
|
294
293
|
disableAutoFocus: true
|
|
@@ -304,7 +303,6 @@ export function PickersPopper(inProps) {
|
|
|
304
303
|
children: /*#__PURE__*/_jsx(PickersPopperPaperWrapper, {
|
|
305
304
|
PaperComponent: Paper,
|
|
306
305
|
ownerState: ownerState,
|
|
307
|
-
popperPlacement: popperPlacement,
|
|
308
306
|
ref: handlePaperRef,
|
|
309
307
|
onPaperClick: onPaperClick,
|
|
310
308
|
onPaperTouchStart: onPaperTouchStart,
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["children", "className", "toolbarTitle", "hidden", "titleId", "isLandscape", "classes", "landscapeDirection"];
|
|
3
|
+
const _excluded = ["children", "className", "classes", "toolbarTitle", "hidden", "titleId", "isLandscape", "classes", "landscapeDirection"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import Typography from '@mui/material/Typography';
|
|
7
7
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
8
8
|
import composeClasses from '@mui/utils/composeClasses';
|
|
9
|
+
import { shouldForwardProp } from '@mui/system/createStyled';
|
|
9
10
|
import { getPickersToolbarUtilityClass } from "./pickersToolbarClasses.js";
|
|
11
|
+
import { useToolbarOwnerState } from "../hooks/useToolbarOwnerState.js";
|
|
10
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
const useUtilityClasses =
|
|
12
|
-
const {
|
|
13
|
-
classes
|
|
14
|
-
} = ownerState;
|
|
13
|
+
const useUtilityClasses = classes => {
|
|
15
14
|
const slots = {
|
|
16
15
|
root: ['root'],
|
|
17
16
|
content: ['content']
|
|
@@ -32,7 +31,7 @@ const PickersToolbarRoot = styled('div', {
|
|
|
32
31
|
padding: theme.spacing(2, 3),
|
|
33
32
|
variants: [{
|
|
34
33
|
props: {
|
|
35
|
-
|
|
34
|
+
pickerOrientation: 'landscape'
|
|
36
35
|
},
|
|
37
36
|
style: {
|
|
38
37
|
height: 'auto',
|
|
@@ -46,7 +45,8 @@ const PickersToolbarRoot = styled('div', {
|
|
|
46
45
|
const PickersToolbarContent = styled('div', {
|
|
47
46
|
name: 'MuiPickersToolbar',
|
|
48
47
|
slot: 'Content',
|
|
49
|
-
overridesResolver: (props, styles) => styles.content
|
|
48
|
+
overridesResolver: (props, styles) => styles.content,
|
|
49
|
+
shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'landscapeDirection'
|
|
50
50
|
})({
|
|
51
51
|
display: 'flex',
|
|
52
52
|
flexWrap: 'wrap',
|
|
@@ -57,7 +57,7 @@ const PickersToolbarContent = styled('div', {
|
|
|
57
57
|
flexDirection: 'row',
|
|
58
58
|
variants: [{
|
|
59
59
|
props: {
|
|
60
|
-
|
|
60
|
+
pickerOrientation: 'landscape'
|
|
61
61
|
},
|
|
62
62
|
style: {
|
|
63
63
|
justifyContent: 'flex-start',
|
|
@@ -66,7 +66,7 @@ const PickersToolbarContent = styled('div', {
|
|
|
66
66
|
}
|
|
67
67
|
}, {
|
|
68
68
|
props: {
|
|
69
|
-
|
|
69
|
+
pickerOrientation: 'landscape',
|
|
70
70
|
landscapeDirection: 'row'
|
|
71
71
|
},
|
|
72
72
|
style: {
|
|
@@ -82,13 +82,15 @@ export const PickersToolbar = /*#__PURE__*/React.forwardRef(function PickersTool
|
|
|
82
82
|
const {
|
|
83
83
|
children,
|
|
84
84
|
className,
|
|
85
|
+
classes: classesProp,
|
|
85
86
|
toolbarTitle,
|
|
86
87
|
hidden,
|
|
87
|
-
titleId
|
|
88
|
+
titleId,
|
|
89
|
+
landscapeDirection
|
|
88
90
|
} = props,
|
|
89
91
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
90
|
-
const ownerState =
|
|
91
|
-
const classes = useUtilityClasses(
|
|
92
|
+
const ownerState = useToolbarOwnerState();
|
|
93
|
+
const classes = useUtilityClasses(classesProp);
|
|
92
94
|
if (hidden) {
|
|
93
95
|
return null;
|
|
94
96
|
}
|
|
@@ -105,6 +107,7 @@ export const PickersToolbar = /*#__PURE__*/React.forwardRef(function PickersTool
|
|
|
105
107
|
}), /*#__PURE__*/_jsx(PickersToolbarContent, {
|
|
106
108
|
className: classes.content,
|
|
107
109
|
ownerState: ownerState,
|
|
110
|
+
landscapeDirection: landscapeDirection,
|
|
108
111
|
children: children
|
|
109
112
|
})]
|
|
110
113
|
}));
|
|
@@ -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 = ["align", "className", "selected", "typographyClassName", "value", "variant", "width"];
|
|
3
|
+
const _excluded = ["align", "className", "classes", "selected", "typographyClassName", "value", "variant", "width"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import Button from '@mui/material/Button';
|
|
@@ -9,10 +9,7 @@ import composeClasses from '@mui/utils/composeClasses';
|
|
|
9
9
|
import { PickersToolbarText } from "./PickersToolbarText.js";
|
|
10
10
|
import { getPickersToolbarUtilityClass } from "./pickersToolbarClasses.js";
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
const useUtilityClasses =
|
|
13
|
-
const {
|
|
14
|
-
classes
|
|
15
|
-
} = ownerState;
|
|
12
|
+
const useUtilityClasses = classes => {
|
|
16
13
|
const slots = {
|
|
17
14
|
root: ['root']
|
|
18
15
|
};
|
|
@@ -35,6 +32,7 @@ export const PickersToolbarButton = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
35
32
|
const {
|
|
36
33
|
align,
|
|
37
34
|
className,
|
|
35
|
+
classes: classesProp,
|
|
38
36
|
selected,
|
|
39
37
|
typographyClassName,
|
|
40
38
|
value,
|
|
@@ -42,7 +40,7 @@ export const PickersToolbarButton = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
42
40
|
width
|
|
43
41
|
} = props,
|
|
44
42
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
45
|
-
const classes = useUtilityClasses(
|
|
43
|
+
const classes = useUtilityClasses(classesProp);
|
|
46
44
|
return /*#__PURE__*/_jsx(PickersToolbarButtonRoot, _extends({
|
|
47
45
|
variant: "text",
|
|
48
46
|
ref: ref,
|