@mui/x-date-pickers 8.0.0-alpha.4 → 8.0.0-alpha.6
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 +182 -0
- package/DatePicker/DatePickerToolbar.d.ts +1 -2
- package/DatePicker/DatePickerToolbar.js +6 -17
- package/DateTimePicker/DateTimePicker.types.d.ts +2 -2
- package/DateTimePicker/DateTimePickerTabs.d.ts +2 -5
- package/DateTimePicker/DateTimePickerTabs.js +6 -13
- package/DateTimePicker/DateTimePickerToolbar.d.ts +8 -4
- package/DateTimePicker/DateTimePickerToolbar.js +13 -24
- package/DateTimePicker/shared.d.ts +2 -2
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +2 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +1 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/MobileDatePicker/MobileDatePicker.types.d.ts +2 -3
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +4 -4
- package/MobileTimePicker/MobileTimePicker.types.d.ts +4 -4
- 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/PickersActionBar/PickersActionBar.d.ts +0 -4
- package/PickersActionBar/PickersActionBar.js +12 -13
- package/PickersLayout/PickersLayout.d.ts +2 -2
- package/PickersLayout/PickersLayout.js +1 -11
- package/PickersLayout/PickersLayout.types.d.ts +12 -14
- package/PickersLayout/usePickerLayout.d.ts +2 -2
- package/PickersLayout/usePickerLayout.js +3 -18
- 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/StaticDatePicker/StaticDatePicker.types.d.ts +2 -3
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +2 -2
- package/StaticTimePicker/StaticTimePicker.types.d.ts +2 -2
- package/TimeClock/Clock.d.ts +4 -0
- package/TimeClock/Clock.js +9 -6
- package/TimeClock/TimeClock.js +21 -4
- package/TimePicker/TimePicker.types.d.ts +2 -2
- package/TimePicker/TimePickerToolbar.d.ts +2 -2
- package/TimePicker/TimePickerToolbar.js +6 -20
- 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/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/usePickerActionsContext.d.ts +5 -0
- package/hooks/usePickerActionsContext.js +16 -0
- package/hooks/usePickerContext.d.ts +3 -1
- package/hooks/usePickerContext.js +0 -1
- package/index.js +1 -1
- package/internals/components/PickerProvider.d.ts +11 -6
- package/internals/components/PickerProvider.js +12 -6
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +1 -1
- package/internals/components/PickersModalDialog.d.ts +1 -3
- package/internals/components/PickersModalDialog.js +9 -3
- package/internals/components/PickersPopper.d.ts +1 -3
- package/internals/components/PickersPopper.js +11 -6
- package/internals/components/PickersToolbar.d.ts +3 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +5 -5
- package/internals/hooks/useFieldOwnerState.d.ts +1 -0
- package/internals/hooks/useFieldOwnerState.js +6 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +5 -5
- package/internals/hooks/usePicker/usePicker.js +1 -3
- package/internals/hooks/usePicker/usePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/usePickerProvider.js +5 -4
- package/internals/hooks/usePicker/usePickerValue.js +46 -64
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +38 -17
- package/internals/hooks/usePicker/usePickerViews.d.ts +15 -4
- package/internals/hooks/usePicker/usePickerViews.js +9 -7
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +4 -4
- package/internals/index.d.ts +4 -4
- package/internals/index.js +1 -1
- package/internals/models/props/tabs.d.ts +0 -13
- package/internals/models/props/toolbar.d.ts +1 -16
- package/models/fields.d.ts +11 -1
- package/modern/DatePicker/DatePickerToolbar.js +6 -17
- package/modern/DateTimePicker/DateTimePickerTabs.js +6 -13
- package/modern/DateTimePicker/DateTimePickerToolbar.js +13 -24
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
- 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/PickersActionBar/PickersActionBar.js +12 -13
- package/modern/PickersLayout/PickersLayout.js +1 -11
- package/modern/PickersLayout/usePickerLayout.js +3 -18
- 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/TimePicker/TimePickerToolbar.js +6 -20
- 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/hooks/index.js +2 -1
- package/modern/hooks/usePickerActionsContext.js +16 -0
- package/modern/hooks/usePickerContext.js +0 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerProvider.js +12 -6
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/modern/internals/components/PickersModalDialog.js +9 -3
- package/modern/internals/components/PickersPopper.js +11 -6
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
- package/modern/internals/hooks/useFieldOwnerState.js +6 -2
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
- package/modern/internals/hooks/usePicker/usePicker.js +1 -3
- package/modern/internals/hooks/usePicker/usePickerProvider.js +5 -4
- package/modern/internals/hooks/usePicker/usePickerValue.js +46 -64
- package/modern/internals/hooks/usePicker/usePickerViews.js +9 -7
- package/modern/internals/index.js +1 -1
- package/node/DatePicker/DatePickerToolbar.js +6 -17
- package/node/DateTimePicker/DateTimePickerTabs.js +6 -13
- package/node/DateTimePicker/DateTimePickerToolbar.js +14 -25
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
- 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/PickersActionBar/PickersActionBar.js +12 -13
- package/node/PickersLayout/PickersLayout.js +1 -11
- package/node/PickersLayout/usePickerLayout.js +3 -18
- 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/TimePicker/TimePickerToolbar.js +6 -20
- 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/hooks/index.js +8 -1
- package/node/hooks/usePickerActionsContext.js +22 -0
- package/node/index.js +1 -1
- package/node/internals/components/PickerProvider.js +13 -7
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/node/internals/components/PickersModalDialog.js +9 -3
- package/node/internals/components/PickersPopper.js +11 -6
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
- package/node/internals/hooks/useFieldOwnerState.js +6 -2
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
- package/node/internals/hooks/usePicker/usePicker.js +1 -3
- package/node/internals/hooks/usePicker/usePickerProvider.js +5 -4
- package/node/internals/hooks/usePicker/usePickerValue.js +46 -64
- package/node/internals/hooks/usePicker/usePickerViews.js +9 -7
- package/node/internals/index.js +2 -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 +4 -7
- 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
|
@@ -3,6 +3,8 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["children", "className", "label", "notched", "shrink"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
|
+
import { shouldForwardProp } from '@mui/system/createStyled';
|
|
7
|
+
import { usePickerTextFieldOwnerState } from "../usePickerTextFieldOwnerState.js";
|
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
9
|
const OutlineRoot = styled('fieldset', {
|
|
8
10
|
name: 'MuiPickersOutlinedInput',
|
|
@@ -36,7 +38,9 @@ const OutlineLabel = styled('span')(({
|
|
|
36
38
|
fontFamily: theme.typography.fontFamily,
|
|
37
39
|
fontSize: 'inherit'
|
|
38
40
|
}));
|
|
39
|
-
const OutlineLegend = styled('legend'
|
|
41
|
+
const OutlineLegend = styled('legend', {
|
|
42
|
+
shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'notched'
|
|
43
|
+
})(({
|
|
40
44
|
theme
|
|
41
45
|
}) => ({
|
|
42
46
|
float: 'unset',
|
|
@@ -47,7 +51,7 @@ const OutlineLegend = styled('legend')(({
|
|
|
47
51
|
// Fix Horizontal scroll when label too long
|
|
48
52
|
variants: [{
|
|
49
53
|
props: {
|
|
50
|
-
|
|
54
|
+
inputHasLabel: false
|
|
51
55
|
},
|
|
52
56
|
style: {
|
|
53
57
|
padding: 0,
|
|
@@ -60,7 +64,7 @@ const OutlineLegend = styled('legend')(({
|
|
|
60
64
|
}
|
|
61
65
|
}, {
|
|
62
66
|
props: {
|
|
63
|
-
|
|
67
|
+
inputHasLabel: true
|
|
64
68
|
},
|
|
65
69
|
style: {
|
|
66
70
|
display: 'block',
|
|
@@ -86,7 +90,7 @@ const OutlineLegend = styled('legend')(({
|
|
|
86
90
|
}
|
|
87
91
|
}, {
|
|
88
92
|
props: {
|
|
89
|
-
|
|
93
|
+
inputHasLabel: true,
|
|
90
94
|
notched: true
|
|
91
95
|
},
|
|
92
96
|
style: {
|
|
@@ -106,13 +110,11 @@ const OutlineLegend = styled('legend')(({
|
|
|
106
110
|
export default function Outline(props) {
|
|
107
111
|
const {
|
|
108
112
|
className,
|
|
109
|
-
label
|
|
113
|
+
label,
|
|
114
|
+
notched
|
|
110
115
|
} = props,
|
|
111
116
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
112
|
-
const
|
|
113
|
-
const ownerState = _extends({}, props, {
|
|
114
|
-
withLabel
|
|
115
|
-
});
|
|
117
|
+
const ownerState = usePickerTextFieldOwnerState();
|
|
116
118
|
return /*#__PURE__*/_jsx(OutlineRoot, _extends({
|
|
117
119
|
"aria-hidden": true,
|
|
118
120
|
className: className
|
|
@@ -120,7 +122,8 @@ export default function Outline(props) {
|
|
|
120
122
|
ownerState: ownerState,
|
|
121
123
|
children: /*#__PURE__*/_jsx(OutlineLegend, {
|
|
122
124
|
ownerState: ownerState,
|
|
123
|
-
|
|
125
|
+
notched: notched,
|
|
126
|
+
children: label ? /*#__PURE__*/_jsx(OutlineLabel, {
|
|
124
127
|
children: label
|
|
125
128
|
}) :
|
|
126
129
|
/*#__PURE__*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["label", "autoFocus", "ownerState", "notched"];
|
|
3
|
+
const _excluded = ["label", "autoFocus", "ownerState", "classes", "notched"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { useFormControl } from '@mui/material/FormControl';
|
|
@@ -51,7 +51,7 @@ const PickersOutlinedInputRoot = styled(PickersInputBaseRoot, {
|
|
|
51
51
|
// @ts-ignore
|
|
52
52
|
.filter(key => (theme.vars ?? theme).palette[key]?.main ?? false).map(color => ({
|
|
53
53
|
props: {
|
|
54
|
-
color
|
|
54
|
+
inputColor: color
|
|
55
55
|
},
|
|
56
56
|
style: {
|
|
57
57
|
[`&.${pickersOutlinedInputClasses.focused}:not(.${pickersOutlinedInputClasses.error}) .${pickersOutlinedInputClasses.notchedOutline}`]: {
|
|
@@ -70,17 +70,14 @@ const PickersOutlinedInputSectionsContainer = styled(PickersInputBaseSectionsCon
|
|
|
70
70
|
padding: '16.5px 0',
|
|
71
71
|
variants: [{
|
|
72
72
|
props: {
|
|
73
|
-
|
|
73
|
+
inputSize: 'small'
|
|
74
74
|
},
|
|
75
75
|
style: {
|
|
76
76
|
padding: '8.5px 0'
|
|
77
77
|
}
|
|
78
78
|
}]
|
|
79
79
|
});
|
|
80
|
-
const useUtilityClasses =
|
|
81
|
-
const {
|
|
82
|
-
classes
|
|
83
|
-
} = ownerState;
|
|
80
|
+
const useUtilityClasses = classes => {
|
|
84
81
|
const slots = {
|
|
85
82
|
root: ['root'],
|
|
86
83
|
notchedOutline: ['notchedOutline'],
|
|
@@ -89,6 +86,7 @@ const useUtilityClasses = ownerState => {
|
|
|
89
86
|
const composedClasses = composeClasses(slots, getPickersOutlinedInputUtilityClass, classes);
|
|
90
87
|
return _extends({}, classes, composedClasses);
|
|
91
88
|
};
|
|
89
|
+
|
|
92
90
|
/**
|
|
93
91
|
* @ignore - internal component.
|
|
94
92
|
*/
|
|
@@ -99,15 +97,12 @@ const PickersOutlinedInput = /*#__PURE__*/React.forwardRef(function PickersOutli
|
|
|
99
97
|
});
|
|
100
98
|
const {
|
|
101
99
|
label,
|
|
102
|
-
|
|
100
|
+
classes: classesProp,
|
|
103
101
|
notched
|
|
104
102
|
} = props,
|
|
105
103
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
106
104
|
const muiFormControl = useFormControl();
|
|
107
|
-
const
|
|
108
|
-
color: muiFormControl?.color || 'primary'
|
|
109
|
-
});
|
|
110
|
-
const classes = useUtilityClasses(ownerState);
|
|
105
|
+
const classes = useUtilityClasses(classesProp);
|
|
111
106
|
return /*#__PURE__*/_jsx(PickersInputBase, _extends({
|
|
112
107
|
slots: {
|
|
113
108
|
root: PickersOutlinedInputRoot,
|
|
@@ -119,8 +114,7 @@ const PickersOutlinedInput = /*#__PURE__*/React.forwardRef(function PickersOutli
|
|
|
119
114
|
className: classes.notchedOutline,
|
|
120
115
|
label: label != null && label !== '' && muiFormControl?.required ? /*#__PURE__*/_jsxs(React.Fragment, {
|
|
121
116
|
children: [label, "\u2009", '*']
|
|
122
|
-
}) : label
|
|
123
|
-
ownerState: ownerState
|
|
117
|
+
}) : label
|
|
124
118
|
})
|
|
125
119
|
}, other, {
|
|
126
120
|
label: label,
|
|
@@ -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 = ["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"];
|
|
5
|
+
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"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import clsx from 'clsx';
|
|
@@ -18,6 +18,8 @@ import { getPickersTextFieldUtilityClass } from "./pickersTextFieldClasses.js";
|
|
|
18
18
|
import { PickersOutlinedInput } from "./PickersOutlinedInput/index.js";
|
|
19
19
|
import { PickersFilledInput } from "./PickersFilledInput/index.js";
|
|
20
20
|
import { PickersInput } from "./PickersInput/index.js";
|
|
21
|
+
import { useFieldOwnerState } from "../internals/hooks/useFieldOwnerState.js";
|
|
22
|
+
import { PickerTextFieldOwnerStateContext } from "./usePickerTextFieldOwnerState.js";
|
|
21
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
24
|
const VARIANT_COMPONENT = {
|
|
23
25
|
standard: PickersInput,
|
|
@@ -29,15 +31,14 @@ const PickersTextFieldRoot = styled(FormControl, {
|
|
|
29
31
|
slot: 'Root',
|
|
30
32
|
overridesResolver: (props, styles) => styles.root
|
|
31
33
|
})({});
|
|
32
|
-
const useUtilityClasses = ownerState => {
|
|
34
|
+
const useUtilityClasses = (classes, ownerState) => {
|
|
33
35
|
const {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
required
|
|
36
|
+
isFieldFocused,
|
|
37
|
+
isFieldDisabled,
|
|
38
|
+
isFieldRequired
|
|
38
39
|
} = ownerState;
|
|
39
40
|
const slots = {
|
|
40
|
-
root: ['root',
|
|
41
|
+
root: ['root', isFieldFocused && !isFieldDisabled && 'focused', isFieldDisabled && 'disabled', isFieldRequired && 'required']
|
|
41
42
|
};
|
|
42
43
|
return composeClasses(slots, getPickersTextFieldUtilityClass, classes);
|
|
43
44
|
};
|
|
@@ -51,6 +52,7 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
|
|
|
51
52
|
onFocus,
|
|
52
53
|
onBlur,
|
|
53
54
|
className,
|
|
55
|
+
classes: classesProp,
|
|
54
56
|
color = 'primary',
|
|
55
57
|
disabled = false,
|
|
56
58
|
error = false,
|
|
@@ -91,64 +93,75 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
|
|
|
91
93
|
const id = useId(idProp);
|
|
92
94
|
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
93
95
|
const inputLabelId = label && id ? `${id}-label` : undefined;
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
focused,
|
|
99
|
-
required,
|
|
100
|
-
variant
|
|
96
|
+
const fieldOwnerState = useFieldOwnerState({
|
|
97
|
+
disabled: props.disabled,
|
|
98
|
+
required: props.required,
|
|
99
|
+
readOnly: InputProps?.readOnly
|
|
101
100
|
});
|
|
102
|
-
const
|
|
101
|
+
const ownerState = React.useMemo(() => _extends({}, fieldOwnerState, {
|
|
102
|
+
isFieldValueEmpty: areAllSectionsEmpty,
|
|
103
|
+
isFieldFocused: focused ?? false,
|
|
104
|
+
hasFieldError: error ?? false,
|
|
105
|
+
inputSize: props.size ?? 'medium',
|
|
106
|
+
inputColor: color ?? 'primary',
|
|
107
|
+
isInputInFullWidth: fullWidth ?? false,
|
|
108
|
+
hasStartAdornment: Boolean(startAdornment ?? InputProps?.startAdornment),
|
|
109
|
+
hasEndAdornment: Boolean(endAdornment ?? InputProps?.endAdornment),
|
|
110
|
+
inputHasLabel: !!label
|
|
111
|
+
}), [fieldOwnerState, areAllSectionsEmpty, focused, error, props.size, color, fullWidth, startAdornment, endAdornment, InputProps?.startAdornment, InputProps?.endAdornment, label]);
|
|
112
|
+
const classes = useUtilityClasses(classesProp, ownerState);
|
|
103
113
|
const PickersInputComponent = VARIANT_COMPONENT[variant];
|
|
104
|
-
return /*#__PURE__*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
ownerState: ownerState
|
|
115
|
-
}, other, {
|
|
116
|
-
children: [/*#__PURE__*/_jsx(InputLabel, _extends({
|
|
117
|
-
htmlFor: id,
|
|
118
|
-
id: inputLabelId
|
|
119
|
-
}, InputLabelProps, {
|
|
120
|
-
children: label
|
|
121
|
-
})), /*#__PURE__*/_jsx(PickersInputComponent, _extends({
|
|
122
|
-
elements: elements,
|
|
123
|
-
areAllSectionsEmpty: areAllSectionsEmpty,
|
|
124
|
-
onClick: onClick,
|
|
125
|
-
onKeyDown: onKeyDown,
|
|
126
|
-
onKeyUp: onKeyUp,
|
|
127
|
-
onInput: onInput,
|
|
128
|
-
onPaste: onPaste,
|
|
129
|
-
onFocus: onFocus,
|
|
130
|
-
onBlur: onBlur,
|
|
131
|
-
endAdornment: endAdornment,
|
|
132
|
-
startAdornment: startAdornment,
|
|
133
|
-
tabIndex: tabIndex,
|
|
134
|
-
contentEditable: contentEditable,
|
|
135
|
-
value: value,
|
|
136
|
-
onChange: onChange,
|
|
137
|
-
id: id,
|
|
114
|
+
return /*#__PURE__*/_jsx(PickerTextFieldOwnerStateContext.Provider, {
|
|
115
|
+
value: ownerState,
|
|
116
|
+
children: /*#__PURE__*/_jsxs(PickersTextFieldRoot, _extends({
|
|
117
|
+
className: clsx(classes.root, className),
|
|
118
|
+
ref: handleRootRef,
|
|
119
|
+
focused: focused,
|
|
120
|
+
disabled: disabled,
|
|
121
|
+
variant: variant,
|
|
122
|
+
error: error,
|
|
123
|
+
color: color,
|
|
138
124
|
fullWidth: fullWidth,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
125
|
+
required: required,
|
|
126
|
+
ownerState: ownerState
|
|
127
|
+
}, other, {
|
|
128
|
+
children: [/*#__PURE__*/_jsx(InputLabel, _extends({
|
|
129
|
+
htmlFor: id,
|
|
130
|
+
id: inputLabelId
|
|
131
|
+
}, InputLabelProps, {
|
|
132
|
+
children: label
|
|
133
|
+
})), /*#__PURE__*/_jsx(PickersInputComponent, _extends({
|
|
134
|
+
elements: elements,
|
|
135
|
+
areAllSectionsEmpty: areAllSectionsEmpty,
|
|
136
|
+
onClick: onClick,
|
|
137
|
+
onKeyDown: onKeyDown,
|
|
138
|
+
onKeyUp: onKeyUp,
|
|
139
|
+
onInput: onInput,
|
|
140
|
+
onPaste: onPaste,
|
|
141
|
+
onFocus: onFocus,
|
|
142
|
+
onBlur: onBlur,
|
|
143
|
+
endAdornment: endAdornment,
|
|
144
|
+
startAdornment: startAdornment,
|
|
145
|
+
tabIndex: tabIndex,
|
|
146
|
+
contentEditable: contentEditable,
|
|
147
|
+
value: value,
|
|
148
|
+
onChange: onChange,
|
|
149
|
+
id: id,
|
|
150
|
+
fullWidth: fullWidth,
|
|
151
|
+
inputProps: inputProps,
|
|
152
|
+
inputRef: inputRef,
|
|
153
|
+
sectionListRef: sectionListRef,
|
|
154
|
+
label: label,
|
|
155
|
+
name: name,
|
|
156
|
+
role: "group",
|
|
157
|
+
"aria-labelledby": inputLabelId
|
|
158
|
+
}, InputProps)), helperText && /*#__PURE__*/_jsx(FormHelperText, _extends({
|
|
159
|
+
id: helperTextId
|
|
160
|
+
}, FormHelperTextProps, {
|
|
161
|
+
children: helperText
|
|
162
|
+
}))]
|
|
163
|
+
}))
|
|
164
|
+
});
|
|
152
165
|
});
|
|
153
166
|
process.env.NODE_ENV !== "production" ? PickersTextField.propTypes = {
|
|
154
167
|
// ----------------------------- Warning --------------------------------
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { FormControlProps } from '@mui/material/FormControl';
|
|
2
|
+
import { FormControlOwnProps, FormControlProps } from '@mui/material/FormControl';
|
|
3
3
|
import { FormHelperTextProps } from '@mui/material/FormHelperText';
|
|
4
4
|
import { InputLabelProps } from '@mui/material/InputLabel';
|
|
5
5
|
import { TextFieldVariants } from '@mui/material/TextField';
|
|
6
6
|
import { PickersInputPropsUsedByField } from './PickersInputBase/PickersInputBase.types';
|
|
7
|
-
import { PickersInputProps } from './PickersInput';
|
|
8
|
-
import { PickersOutlinedInputProps } from './PickersOutlinedInput';
|
|
9
|
-
import { PickersFilledInputProps } from './PickersFilledInput';
|
|
7
|
+
import type { PickersInputProps } from './PickersInput';
|
|
8
|
+
import type { PickersOutlinedInputProps } from './PickersOutlinedInput';
|
|
9
|
+
import type { PickersFilledInputProps } from './PickersFilledInput';
|
|
10
|
+
import { FieldOwnerState } from '../models';
|
|
10
11
|
interface PickersTextFieldPropsUsedByField {
|
|
11
12
|
onFocus: React.FocusEventHandler<HTMLDivElement>;
|
|
12
13
|
onBlur: React.FocusEventHandler<HTMLDivElement>;
|
|
@@ -64,4 +65,42 @@ export interface PickersFilledTextFieldProps extends PickersBaseTextFieldProps {
|
|
|
64
65
|
InputProps?: Partial<PickersFilledInputProps>;
|
|
65
66
|
}
|
|
66
67
|
export type PickersTextFieldProps<Variant extends TextFieldVariants = TextFieldVariants> = Variant extends 'filled' ? PickersFilledTextFieldProps : Variant extends 'standard' ? PickersStandardTextFieldProps : PickersOutlinedTextFieldProps;
|
|
68
|
+
export interface PickerTextFieldOwnerState extends FieldOwnerState {
|
|
69
|
+
/**
|
|
70
|
+
* `true` if the value of the field is currently empty.
|
|
71
|
+
*/
|
|
72
|
+
isFieldValueEmpty: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* `true` if the field is focused, `false` otherwise.
|
|
75
|
+
*/
|
|
76
|
+
isFieldFocused: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* `true` if the field has an error, `false` otherwise.
|
|
79
|
+
*/
|
|
80
|
+
hasFieldError: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The size of the input.
|
|
83
|
+
*/
|
|
84
|
+
inputSize: Exclude<FormControlOwnProps['size'], undefined>;
|
|
85
|
+
/**
|
|
86
|
+
* The color of the input.
|
|
87
|
+
*/
|
|
88
|
+
inputColor: Exclude<FormControlOwnProps['color'], undefined>;
|
|
89
|
+
/**
|
|
90
|
+
* `true` if the input takes up the full width of its container.
|
|
91
|
+
*/
|
|
92
|
+
isInputInFullWidth: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* `true` if the input has a start adornment, `false` otherwise.
|
|
95
|
+
*/
|
|
96
|
+
hasStartAdornment: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* `true` if the input has an end adornment, `false` otherwise.
|
|
99
|
+
*/
|
|
100
|
+
hasEndAdornment: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* `true` if the input has a label, `false` otherwise.
|
|
103
|
+
*/
|
|
104
|
+
inputHasLabel: boolean;
|
|
105
|
+
}
|
|
67
106
|
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PickerTextFieldOwnerState } from './PickersTextField.types';
|
|
3
|
+
export declare const PickerTextFieldOwnerStateContext: React.Context<PickerTextFieldOwnerState | null>;
|
|
4
|
+
export declare const usePickerTextFieldOwnerState: () => PickerTextFieldOwnerState;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export const PickerTextFieldOwnerStateContext = /*#__PURE__*/React.createContext(null);
|
|
5
|
+
export const usePickerTextFieldOwnerState = () => {
|
|
6
|
+
const value = React.useContext(PickerTextFieldOwnerStateContext);
|
|
7
|
+
if (value == null) {
|
|
8
|
+
throw new Error(['MUI X: The `usePickerTextFieldOwnerState` can only be called in components that are used inside a PickerTextField component'].join('\n'));
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { MakeOptional } from '@mui/x-internals/types';
|
|
2
2
|
import { BaseDatePickerProps, BaseDatePickerSlots, BaseDatePickerSlotProps } from '../DatePicker/shared';
|
|
3
3
|
import { StaticOnlyPickerProps, UseStaticPickerSlots, UseStaticPickerSlotProps } from '../internals/hooks/useStaticPicker';
|
|
4
|
-
|
|
5
|
-
export interface StaticDatePickerSlots extends BaseDatePickerSlots, UseStaticPickerSlots<DateView> {
|
|
4
|
+
export interface StaticDatePickerSlots extends BaseDatePickerSlots, UseStaticPickerSlots {
|
|
6
5
|
}
|
|
7
|
-
export interface StaticDatePickerSlotProps extends BaseDatePickerSlotProps, UseStaticPickerSlotProps
|
|
6
|
+
export interface StaticDatePickerSlotProps extends BaseDatePickerSlotProps, UseStaticPickerSlotProps {
|
|
8
7
|
}
|
|
9
8
|
export interface StaticDatePickerProps extends BaseDatePickerProps, MakeOptional<StaticOnlyPickerProps, 'displayStaticWrapperAs'> {
|
|
10
9
|
/**
|
|
@@ -2,9 +2,9 @@ import { MakeOptional } from '@mui/x-internals/types';
|
|
|
2
2
|
import { BaseDateTimePickerProps, BaseDateTimePickerSlots, BaseDateTimePickerSlotProps } from '../DateTimePicker/shared';
|
|
3
3
|
import { StaticOnlyPickerProps, UseStaticPickerSlots, UseStaticPickerSlotProps } from '../internals/hooks/useStaticPicker';
|
|
4
4
|
import { DateOrTimeView } from '../models';
|
|
5
|
-
export interface StaticDateTimePickerSlots extends BaseDateTimePickerSlots, UseStaticPickerSlots
|
|
5
|
+
export interface StaticDateTimePickerSlots extends BaseDateTimePickerSlots, UseStaticPickerSlots {
|
|
6
6
|
}
|
|
7
|
-
export interface StaticDateTimePickerSlotProps extends BaseDateTimePickerSlotProps, UseStaticPickerSlotProps
|
|
7
|
+
export interface StaticDateTimePickerSlotProps extends BaseDateTimePickerSlotProps, UseStaticPickerSlotProps {
|
|
8
8
|
}
|
|
9
9
|
export interface StaticDateTimePickerProps extends BaseDateTimePickerProps<DateOrTimeView>, MakeOptional<StaticOnlyPickerProps, 'displayStaticWrapperAs'> {
|
|
10
10
|
/**
|
|
@@ -2,9 +2,9 @@ import { MakeOptional } from '@mui/x-internals/types';
|
|
|
2
2
|
import { BaseTimePickerProps, BaseTimePickerSlots, BaseTimePickerSlotProps } from '../TimePicker/shared';
|
|
3
3
|
import { StaticOnlyPickerProps, UseStaticPickerSlots, UseStaticPickerSlotProps } from '../internals/hooks/useStaticPicker';
|
|
4
4
|
import { TimeView } from '../models';
|
|
5
|
-
export interface StaticTimePickerSlots extends BaseTimePickerSlots, UseStaticPickerSlots
|
|
5
|
+
export interface StaticTimePickerSlots extends BaseTimePickerSlots, UseStaticPickerSlots {
|
|
6
6
|
}
|
|
7
|
-
export interface StaticTimePickerSlotProps extends BaseTimePickerSlotProps, UseStaticPickerSlotProps
|
|
7
|
+
export interface StaticTimePickerSlotProps extends BaseTimePickerSlotProps, UseStaticPickerSlotProps {
|
|
8
8
|
}
|
|
9
9
|
export interface StaticTimePickerProps extends BaseTimePickerProps<TimeView>, MakeOptional<StaticOnlyPickerProps, 'displayStaticWrapperAs'> {
|
|
10
10
|
/**
|
package/TimeClock/Clock.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ export interface ClockProps extends ReturnType<typeof useMeridiemMode>, FormProp
|
|
|
26
26
|
* The current full date value.
|
|
27
27
|
*/
|
|
28
28
|
value: PickerValidDate | null;
|
|
29
|
+
/**
|
|
30
|
+
* Minimum and maximum value of the clock.
|
|
31
|
+
*/
|
|
32
|
+
viewRange: [number, number];
|
|
29
33
|
className?: string;
|
|
30
34
|
classes?: Partial<ClockClasses>;
|
|
31
35
|
}
|
package/TimeClock/Clock.js
CHANGED
|
@@ -177,6 +177,7 @@ export function Clock(inProps) {
|
|
|
177
177
|
selectedId,
|
|
178
178
|
type,
|
|
179
179
|
viewValue,
|
|
180
|
+
viewRange: [minViewValue, maxViewValue],
|
|
180
181
|
disabled = false,
|
|
181
182
|
readOnly,
|
|
182
183
|
className,
|
|
@@ -251,6 +252,8 @@ export function Clock(inProps) {
|
|
|
251
252
|
listboxRef.current.focus();
|
|
252
253
|
}
|
|
253
254
|
}, [autoFocus]);
|
|
255
|
+
const clampValue = newValue => Math.max(minViewValue, Math.min(maxViewValue, newValue));
|
|
256
|
+
const circleValue = newValue => (newValue + (maxViewValue + 1)) % (maxViewValue + 1);
|
|
254
257
|
const handleKeyDown = event => {
|
|
255
258
|
// TODO: Why this early exit?
|
|
256
259
|
if (isMoving.current) {
|
|
@@ -259,27 +262,27 @@ export function Clock(inProps) {
|
|
|
259
262
|
switch (event.key) {
|
|
260
263
|
case 'Home':
|
|
261
264
|
// reset both hours and minutes
|
|
262
|
-
handleValueChange(
|
|
265
|
+
handleValueChange(minViewValue, 'partial');
|
|
263
266
|
event.preventDefault();
|
|
264
267
|
break;
|
|
265
268
|
case 'End':
|
|
266
|
-
handleValueChange(
|
|
269
|
+
handleValueChange(maxViewValue, 'partial');
|
|
267
270
|
event.preventDefault();
|
|
268
271
|
break;
|
|
269
272
|
case 'ArrowUp':
|
|
270
|
-
handleValueChange(viewValue + keyboardControlStep, 'partial');
|
|
273
|
+
handleValueChange(circleValue(viewValue + keyboardControlStep), 'partial');
|
|
271
274
|
event.preventDefault();
|
|
272
275
|
break;
|
|
273
276
|
case 'ArrowDown':
|
|
274
|
-
handleValueChange(viewValue - keyboardControlStep, 'partial');
|
|
277
|
+
handleValueChange(circleValue(viewValue - keyboardControlStep), 'partial');
|
|
275
278
|
event.preventDefault();
|
|
276
279
|
break;
|
|
277
280
|
case 'PageUp':
|
|
278
|
-
handleValueChange(viewValue + 5, 'partial');
|
|
281
|
+
handleValueChange(clampValue(viewValue + 5), 'partial');
|
|
279
282
|
event.preventDefault();
|
|
280
283
|
break;
|
|
281
284
|
case 'PageDown':
|
|
282
|
-
handleValueChange(viewValue - 5, 'partial');
|
|
285
|
+
handleValueChange(clampValue(viewValue - 5), 'partial');
|
|
283
286
|
event.preventDefault();
|
|
284
287
|
break;
|
|
285
288
|
case 'Enter':
|
package/TimeClock/TimeClock.js
CHANGED
|
@@ -186,6 +186,9 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
186
186
|
{
|
|
187
187
|
const valueWithMeridiem = convertValueToMeridiem(rawValue, meridiemMode, ampm);
|
|
188
188
|
const dateWithNewHours = utils.setHours(valueOrReferenceDate, valueWithMeridiem);
|
|
189
|
+
if (utils.getHours(dateWithNewHours) !== valueWithMeridiem) {
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
189
192
|
const start = utils.setSeconds(utils.setMinutes(dateWithNewHours, 0), 0);
|
|
190
193
|
const end = utils.setSeconds(utils.setMinutes(dateWithNewHours, 59), 59);
|
|
191
194
|
return !containsValidTime({
|
|
@@ -225,9 +228,20 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
225
228
|
const valueWithMeridiem = convertValueToMeridiem(hourValue, meridiemMode, ampm);
|
|
226
229
|
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), isFinish, 'hours');
|
|
227
230
|
};
|
|
231
|
+
const viewValue = utils.getHours(valueOrReferenceDate);
|
|
232
|
+
let viewRange;
|
|
233
|
+
if (ampm) {
|
|
234
|
+
if (viewValue > 12) {
|
|
235
|
+
viewRange = [12, 23];
|
|
236
|
+
} else {
|
|
237
|
+
viewRange = [0, 11];
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
viewRange = [0, 23];
|
|
241
|
+
}
|
|
228
242
|
return {
|
|
229
243
|
onChange: handleHoursChange,
|
|
230
|
-
viewValue
|
|
244
|
+
viewValue,
|
|
231
245
|
children: getHourNumbers({
|
|
232
246
|
value,
|
|
233
247
|
utils,
|
|
@@ -236,7 +250,8 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
236
250
|
getClockNumberText: translations.hoursClockNumberText,
|
|
237
251
|
isDisabled: hourValue => disabled || isTimeDisabled(hourValue, 'hours'),
|
|
238
252
|
selectedId
|
|
239
|
-
})
|
|
253
|
+
}),
|
|
254
|
+
viewRange
|
|
240
255
|
};
|
|
241
256
|
}
|
|
242
257
|
case 'minutes':
|
|
@@ -255,7 +270,8 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
255
270
|
getClockNumberText: translations.minutesClockNumberText,
|
|
256
271
|
isDisabled: minuteValue => disabled || isTimeDisabled(minuteValue, 'minutes'),
|
|
257
272
|
selectedId
|
|
258
|
-
})
|
|
273
|
+
}),
|
|
274
|
+
viewRange: [0, 59]
|
|
259
275
|
};
|
|
260
276
|
}
|
|
261
277
|
case 'seconds':
|
|
@@ -274,7 +290,8 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
274
290
|
getClockNumberText: translations.secondsClockNumberText,
|
|
275
291
|
isDisabled: secondValue => disabled || isTimeDisabled(secondValue, 'seconds'),
|
|
276
292
|
selectedId
|
|
277
|
-
})
|
|
293
|
+
}),
|
|
294
|
+
viewRange: [0, 59]
|
|
278
295
|
};
|
|
279
296
|
}
|
|
280
297
|
default:
|
|
@@ -3,9 +3,9 @@ import { BaseSingleInputFieldProps, PickerValue, TimeViewWithMeridiem } from '..
|
|
|
3
3
|
import { MobileTimePickerProps, MobileTimePickerSlots, MobileTimePickerSlotProps } from '../MobileTimePicker';
|
|
4
4
|
import { TimeValidationError } from '../models';
|
|
5
5
|
import { ValidateTimeProps } from '../validation/validateTime';
|
|
6
|
-
export interface TimePickerSlots extends DesktopTimePickerSlots, MobileTimePickerSlots
|
|
6
|
+
export interface TimePickerSlots extends DesktopTimePickerSlots, MobileTimePickerSlots {
|
|
7
7
|
}
|
|
8
|
-
export interface TimePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends DesktopTimePickerSlotProps<TEnableAccessibleFieldDOMStructure>, MobileTimePickerSlotProps<
|
|
8
|
+
export interface TimePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends DesktopTimePickerSlotProps<TEnableAccessibleFieldDOMStructure>, MobileTimePickerSlotProps<TEnableAccessibleFieldDOMStructure> {
|
|
9
9
|
}
|
|
10
10
|
export interface TimePickerProps<TEnableAccessibleFieldDOMStructure extends boolean = true> extends DesktopTimePickerProps<TEnableAccessibleFieldDOMStructure>, Omit<MobileTimePickerProps<TimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure>, 'views'> {
|
|
11
11
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BaseToolbarProps, ExportedBaseToolbarProps } from '../internals/models/props/toolbar';
|
|
3
3
|
import { TimePickerToolbarClasses } from './timePickerToolbarClasses';
|
|
4
|
-
import { PickerValue
|
|
5
|
-
export interface TimePickerToolbarProps extends BaseToolbarProps<PickerValue
|
|
4
|
+
import { PickerValue } from '../internals/models';
|
|
5
|
+
export interface TimePickerToolbarProps extends BaseToolbarProps<PickerValue>, ExportedTimePickerToolbarProps {
|
|
6
6
|
ampm?: boolean;
|
|
7
7
|
ampmInClock?: boolean;
|
|
8
8
|
}
|
|
@@ -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", "value", "isLandscape", "onChange", "
|
|
5
|
+
const _excluded = ["ampm", "ampmInClock", "value", "isLandscape", "onChange", "className", "classes"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
@@ -125,9 +125,6 @@ function TimePickerToolbar(inProps) {
|
|
|
125
125
|
value,
|
|
126
126
|
isLandscape,
|
|
127
127
|
onChange,
|
|
128
|
-
view,
|
|
129
|
-
onViewChange,
|
|
130
|
-
views,
|
|
131
128
|
className,
|
|
132
129
|
classes: classesProp
|
|
133
130
|
} = props,
|
|
@@ -138,7 +135,10 @@ function TimePickerToolbar(inProps) {
|
|
|
138
135
|
const classes = useUtilityClasses(classesProp, ownerState);
|
|
139
136
|
const {
|
|
140
137
|
disabled,
|
|
141
|
-
readOnly
|
|
138
|
+
readOnly,
|
|
139
|
+
view,
|
|
140
|
+
onViewChange,
|
|
141
|
+
views
|
|
142
142
|
} = usePickerContext();
|
|
143
143
|
const showAmPmControl = Boolean(ampm && !ampmInClock && views.includes('hours'));
|
|
144
144
|
const {
|
|
@@ -223,12 +223,6 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
|
|
|
223
223
|
hidden: PropTypes.bool,
|
|
224
224
|
isLandscape: PropTypes.bool.isRequired,
|
|
225
225
|
onChange: PropTypes.func.isRequired,
|
|
226
|
-
/**
|
|
227
|
-
* Callback called when a toolbar is clicked
|
|
228
|
-
* @template TView
|
|
229
|
-
* @param {TView} view The view to open
|
|
230
|
-
*/
|
|
231
|
-
onViewChange: PropTypes.func.isRequired,
|
|
232
226
|
/**
|
|
233
227
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
234
228
|
*/
|
|
@@ -243,14 +237,6 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
|
|
|
243
237
|
* @default "––"
|
|
244
238
|
*/
|
|
245
239
|
toolbarPlaceholder: PropTypes.node,
|
|
246
|
-
value: PropTypes.object
|
|
247
|
-
/**
|
|
248
|
-
* Currently visible picker view.
|
|
249
|
-
*/
|
|
250
|
-
view: PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']).isRequired,
|
|
251
|
-
/**
|
|
252
|
-
* Available views.
|
|
253
|
-
*/
|
|
254
|
-
views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']).isRequired).isRequired
|
|
240
|
+
value: PropTypes.object
|
|
255
241
|
} : void 0;
|
|
256
242
|
export { TimePickerToolbar };
|