@mui/x-date-pickers 7.0.0-alpha.5 → 7.0.0-alpha.7
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 +408 -6
- package/DateCalendar/DateCalendar.js +6 -4
- package/DateCalendar/DateCalendar.types.d.ts +0 -8
- package/DigitalClock/DigitalClock.js +3 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
- package/PickersSectionList/PickersSectionList.d.ts +11 -0
- package/PickersSectionList/PickersSectionList.js +223 -0
- package/PickersSectionList/PickersSectionList.types.d.ts +56 -0
- package/PickersSectionList/index.d.ts +4 -0
- package/PickersSectionList/index.js +2 -0
- package/PickersSectionList/package.json +6 -0
- package/PickersSectionList/pickersSectionListClasses.d.ts +11 -0
- package/PickersSectionList/pickersSectionListClasses.js +6 -0
- package/TimeClock/TimeClock.js +3 -2
- package/index.d.ts +1 -0
- package/index.js +4 -1
- package/internals/components/{PickersTextField → PickersInput}/Outline.d.ts +1 -0
- package/internals/components/{PickersTextField → PickersInput}/Outline.js +35 -19
- package/internals/components/PickersInput/PickersFilledInput.d.ts +3 -0
- package/internals/components/PickersInput/PickersFilledInput.js +166 -0
- package/internals/components/PickersInput/PickersInput.d.ts +15 -0
- package/internals/components/{PickersTextField → PickersInput}/PickersInput.js +78 -106
- package/internals/components/PickersInput/PickersInput.types.d.ts +60 -0
- package/internals/components/PickersInput/PickersOutlinedInput.d.ts +3 -0
- package/internals/components/PickersInput/PickersOutlinedInput.js +117 -0
- package/internals/components/PickersInput/PickersStandardInput.d.ts +3 -0
- package/internals/components/PickersInput/PickersStandardInput.js +123 -0
- package/internals/components/PickersInput/index.d.ts +4 -0
- package/internals/components/PickersInput/index.js +3 -0
- package/internals/components/PickersInput/pickersInputClasses.d.ts +84 -0
- package/internals/components/PickersInput/pickersInputClasses.js +18 -0
- package/internals/components/PickersTextField/PickersTextField.d.ts +1 -2
- package/internals/components/PickersTextField/PickersTextField.js +15 -6
- package/internals/components/PickersTextField/PickersTextField.types.d.ts +46 -3
- package/internals/components/PickersTextField/pickersTextFieldClasses.d.ts +0 -31
- package/internals/components/PickersTextField/pickersTextFieldClasses.js +3 -6
- package/internals/hooks/useField/useField.js +8 -1
- package/internals/hooks/useViews.d.ts +4 -4
- package/internals/hooks/useViews.js +13 -13
- package/internals/models/props/clock.d.ts +0 -9
- package/legacy/DateCalendar/DateCalendar.js +6 -4
- package/legacy/DigitalClock/DigitalClock.js +3 -2
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
- package/legacy/PickersSectionList/PickersSectionList.js +230 -0
- package/legacy/PickersSectionList/index.js +2 -0
- package/legacy/PickersSectionList/pickersSectionListClasses.js +6 -0
- package/legacy/TimeClock/TimeClock.js +3 -2
- package/legacy/index.js +4 -1
- package/legacy/internals/components/{PickersTextField → PickersInput}/Outline.js +40 -22
- package/legacy/internals/components/PickersInput/PickersFilledInput.js +161 -0
- package/legacy/internals/components/{PickersTextField → PickersInput}/PickersInput.js +75 -90
- package/legacy/internals/components/PickersInput/PickersInput.types.js +1 -0
- package/legacy/internals/components/PickersInput/PickersOutlinedInput.js +110 -0
- package/legacy/internals/components/PickersInput/PickersStandardInput.js +117 -0
- package/legacy/internals/components/PickersInput/index.js +3 -0
- package/legacy/internals/components/PickersInput/pickersInputClasses.js +18 -0
- package/legacy/internals/components/PickersTextField/PickersTextField.js +16 -7
- package/legacy/internals/components/PickersTextField/pickersTextFieldClasses.js +3 -6
- package/legacy/internals/hooks/useField/useField.js +8 -1
- package/legacy/internals/hooks/useViews.js +13 -13
- package/legacy/locales/ruRU.js +1 -2
- package/locales/ruRU.js +1 -2
- package/modern/DateCalendar/DateCalendar.js +6 -4
- package/modern/DigitalClock/DigitalClock.js +3 -2
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
- package/modern/PickersSectionList/PickersSectionList.js +221 -0
- package/modern/PickersSectionList/PickersSectionList.types.js +1 -0
- package/modern/PickersSectionList/index.js +2 -0
- package/modern/PickersSectionList/pickersSectionListClasses.js +6 -0
- package/modern/TimeClock/TimeClock.js +3 -2
- package/modern/index.js +4 -1
- package/modern/internals/components/{PickersTextField → PickersInput}/Outline.js +35 -19
- package/modern/internals/components/PickersInput/PickersFilledInput.js +165 -0
- package/modern/internals/components/{PickersTextField → PickersInput}/PickersInput.js +78 -106
- package/modern/internals/components/PickersInput/PickersInput.types.js +1 -0
- package/modern/internals/components/PickersInput/PickersOutlinedInput.js +117 -0
- package/modern/internals/components/PickersInput/PickersStandardInput.js +123 -0
- package/modern/internals/components/PickersInput/index.js +3 -0
- package/modern/internals/components/PickersInput/pickersInputClasses.js +18 -0
- package/modern/internals/components/PickersTextField/PickersTextField.js +15 -6
- package/modern/internals/components/PickersTextField/pickersTextFieldClasses.js +3 -6
- package/modern/internals/hooks/useField/useField.js +8 -1
- package/modern/internals/hooks/useViews.js +13 -13
- package/modern/locales/ruRU.js +1 -2
- package/node/DateCalendar/DateCalendar.js +6 -4
- package/node/DigitalClock/DigitalClock.js +3 -2
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
- package/node/PickersSectionList/PickersSectionList.js +228 -0
- package/node/PickersSectionList/index.js +49 -0
- package/node/PickersSectionList/pickersSectionListClasses.js +14 -0
- package/node/TimeClock/TimeClock.js +3 -2
- package/node/index.js +13 -1
- package/node/internals/components/{PickersTextField → PickersInput}/Outline.js +35 -19
- package/node/internals/components/PickersInput/PickersFilledInput.js +174 -0
- package/node/internals/components/{PickersTextField → PickersInput}/PickersInput.js +80 -108
- package/node/internals/components/PickersInput/PickersInput.types.js +5 -0
- package/node/internals/components/PickersInput/PickersOutlinedInput.js +125 -0
- package/node/internals/components/PickersInput/PickersStandardInput.js +132 -0
- package/node/internals/components/PickersInput/index.js +32 -0
- package/node/internals/components/PickersInput/pickersInputClasses.js +29 -0
- package/node/internals/components/PickersTextField/PickersTextField.js +15 -6
- package/node/internals/components/PickersTextField/pickersTextFieldClasses.js +6 -9
- package/node/internals/hooks/useField/useField.js +8 -1
- package/node/internals/hooks/useViews.js +13 -13
- package/node/locales/ruRU.js +1 -2
- package/package.json +5 -5
- package/internals/components/PickersTextField/PickersInput.d.ts +0 -3
- package/internals/components/PickersTextField/PickersInput.types.d.ts +0 -45
- /package/{internals/components/PickersTextField/PickersInput.types.js → PickersSectionList/PickersSectionList.types.js} +0 -0
- /package/{legacy/internals/components/PickersTextField → internals/components/PickersInput}/PickersInput.types.js +0 -0
- /package/{modern/internals/components/PickersTextField/PickersInput.types.js → legacy/PickersSectionList/PickersSectionList.types.js} +0 -0
- /package/node/{internals/components/PickersTextField/PickersInput.types.js → PickersSectionList/PickersSectionList.types.js} +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["label", "autoFocus", "ownerState"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useFormControl } from '@mui/material/FormControl';
|
|
6
|
+
import { styled } from '@mui/material/styles';
|
|
7
|
+
import { unstable_composeClasses as composeClasses, unstable_capitalize as capitalize } from '@mui/utils';
|
|
8
|
+
import { pickersStandardInputClasses, getPickersStandardInputUtilityClass } from './pickersInputClasses';
|
|
9
|
+
import { PickersInputRoot, PickersInput } from './PickersInput';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
const StandardInputRoot = styled(PickersInputRoot, {
|
|
12
|
+
name: 'MuiPickersStandardInput',
|
|
13
|
+
slot: 'Root',
|
|
14
|
+
overridesResolver: (props, styles) => styles.root
|
|
15
|
+
})(({
|
|
16
|
+
theme,
|
|
17
|
+
ownerState
|
|
18
|
+
}) => {
|
|
19
|
+
const light = theme.palette.mode === 'light';
|
|
20
|
+
let bottomLineColor = light ? 'rgba(0, 0, 0, 0.42)' : 'rgba(255, 255, 255, 0.7)';
|
|
21
|
+
if (theme.vars) {
|
|
22
|
+
bottomLineColor = `rgba(${theme.vars.palette.common.onBackgroundChannel} / ${theme.vars.opacity.inputUnderline})`;
|
|
23
|
+
}
|
|
24
|
+
return _extends({
|
|
25
|
+
'label + &': {
|
|
26
|
+
marginTop: 16
|
|
27
|
+
}
|
|
28
|
+
}, !ownerState.disableUnderline && {
|
|
29
|
+
'&::after': {
|
|
30
|
+
background: 'red',
|
|
31
|
+
borderBottom: `2px solid ${(theme.vars || theme).palette[ownerState.color].main}`,
|
|
32
|
+
left: 0,
|
|
33
|
+
bottom: 0,
|
|
34
|
+
// Doing the other way around crash on IE11 "''" https://github.com/cssinjs/jss/issues/242
|
|
35
|
+
content: '""',
|
|
36
|
+
position: 'absolute',
|
|
37
|
+
right: 0,
|
|
38
|
+
transform: 'scaleX(0)',
|
|
39
|
+
transition: theme.transitions.create('transform', {
|
|
40
|
+
duration: theme.transitions.duration.shorter,
|
|
41
|
+
easing: theme.transitions.easing.easeOut
|
|
42
|
+
}),
|
|
43
|
+
pointerEvents: 'none' // Transparent to the hover style.
|
|
44
|
+
},
|
|
45
|
+
[`&.${pickersStandardInputClasses.focused}:after`]: {
|
|
46
|
+
// translateX(0) is a workaround for Safari transform scale bug
|
|
47
|
+
// See https://github.com/mui/material-ui/issues/31766
|
|
48
|
+
transform: 'scaleX(1) translateX(0)'
|
|
49
|
+
},
|
|
50
|
+
[`&.${pickersStandardInputClasses.error}`]: {
|
|
51
|
+
'&:before, &:after': {
|
|
52
|
+
borderBottomColor: (theme.vars || theme).palette.error.main
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
'&::before': {
|
|
56
|
+
borderBottom: `1px solid ${bottomLineColor}`,
|
|
57
|
+
left: 0,
|
|
58
|
+
bottom: 0,
|
|
59
|
+
// Doing the other way around crash on IE11 "''" https://github.com/cssinjs/jss/issues/242
|
|
60
|
+
content: '"\\00a0"',
|
|
61
|
+
position: 'absolute',
|
|
62
|
+
right: 0,
|
|
63
|
+
transition: theme.transitions.create('border-bottom-color', {
|
|
64
|
+
duration: theme.transitions.duration.shorter
|
|
65
|
+
}),
|
|
66
|
+
pointerEvents: 'none' // Transparent to the hover style.
|
|
67
|
+
},
|
|
68
|
+
[`&:hover:not(.${pickersStandardInputClasses.disabled}, .${pickersStandardInputClasses.error}):before`]: {
|
|
69
|
+
borderBottom: `2px solid ${(theme.vars || theme).palette.text.primary}`,
|
|
70
|
+
// Reset on touch devices, it doesn't add specificity
|
|
71
|
+
'@media (hover: none)': {
|
|
72
|
+
borderBottom: `1px solid ${bottomLineColor}`
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
[`&.${pickersStandardInputClasses.disabled}:before`]: {
|
|
76
|
+
borderBottomStyle: 'dotted'
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
const useUtilityClasses = ownerState => {
|
|
81
|
+
const {
|
|
82
|
+
focused,
|
|
83
|
+
disabled,
|
|
84
|
+
error,
|
|
85
|
+
classes,
|
|
86
|
+
fullWidth,
|
|
87
|
+
color,
|
|
88
|
+
size,
|
|
89
|
+
endAdornment,
|
|
90
|
+
startAdornment
|
|
91
|
+
} = ownerState;
|
|
92
|
+
const slots = {
|
|
93
|
+
root: ['root', focused && !disabled && 'focused', disabled && 'disabled', error && 'error', fullWidth && 'fullWidth', `color${capitalize(color)}`, size === 'small' && 'inputSizeSmall', Boolean(startAdornment) && 'adornedStart', Boolean(endAdornment) && 'adornedEnd'],
|
|
94
|
+
notchedOutline: ['notchedOutline'],
|
|
95
|
+
before: ['before'],
|
|
96
|
+
after: ['after'],
|
|
97
|
+
content: ['content'],
|
|
98
|
+
input: ['input']
|
|
99
|
+
};
|
|
100
|
+
return composeClasses(slots, getPickersStandardInputUtilityClass, classes);
|
|
101
|
+
};
|
|
102
|
+
export const PickersStandardInput = /*#__PURE__*/React.forwardRef(function PickersStandardInput(props, ref) {
|
|
103
|
+
const {
|
|
104
|
+
label,
|
|
105
|
+
ownerState: ownerStateProp
|
|
106
|
+
} = props,
|
|
107
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
108
|
+
const muiFormControl = useFormControl();
|
|
109
|
+
const ownerState = _extends({}, props, ownerStateProp, muiFormControl, {
|
|
110
|
+
color: muiFormControl?.color || 'primary'
|
|
111
|
+
});
|
|
112
|
+
const classes = useUtilityClasses(ownerState);
|
|
113
|
+
return /*#__PURE__*/_jsx(PickersInput, _extends({
|
|
114
|
+
slots: {
|
|
115
|
+
root: StandardInputRoot
|
|
116
|
+
}
|
|
117
|
+
}, other, {
|
|
118
|
+
label: label,
|
|
119
|
+
classes: classes,
|
|
120
|
+
ref: ref
|
|
121
|
+
}));
|
|
122
|
+
});
|
|
123
|
+
PickersInput.muiName = 'Input';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
|
|
3
|
+
export function getPickersInputUtilityClass(slot) {
|
|
4
|
+
return generateUtilityClass('MuiPickersInput', slot);
|
|
5
|
+
}
|
|
6
|
+
export function getPickersOutlinedInputUtilityClass(slot) {
|
|
7
|
+
return generateUtilityClass('MuiPickersOutlinedInput', slot);
|
|
8
|
+
}
|
|
9
|
+
export function getPickersFilledInputUtilityClass(slot) {
|
|
10
|
+
return generateUtilityClass('MuiPickersFilledInput', slot);
|
|
11
|
+
}
|
|
12
|
+
export function getPickersStandardInputUtilityClass(slot) {
|
|
13
|
+
return generateUtilityClass('MuiPickersStandardInput', slot);
|
|
14
|
+
}
|
|
15
|
+
export const pickersInputClasses = generateUtilityClasses('MuiPickersInput', ['root', 'focused', 'disabled', 'error', 'notchedOutline', 'sectionContent', 'sectionBefore', 'sectionAfter', 'adornedStart', 'adornedEnd', 'input']);
|
|
16
|
+
export const pickersOutlinedInputClasses = _extends({}, pickersInputClasses, generateUtilityClasses('MuiPickersOutlinedInput', ['root', 'notchedOutline', 'input']));
|
|
17
|
+
export const pickersFilledInputClasses = _extends({}, pickersInputClasses, generateUtilityClasses('MuiPickersFilledInput', ['root', 'underline', 'input']));
|
|
18
|
+
export const pickersStandardInputClasses = _extends({}, pickersInputClasses, generateUtilityClasses('MuiPickersStandardInput', ['root', 'underline', 'input']));
|
|
@@ -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 = ["onFocus", "onBlur", "className", "color", "disabled", "error", "
|
|
3
|
+
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", "helperText", "FormHelperTextProps", "label", "InputLabelProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { styled } from '@mui/material/styles';
|
|
@@ -10,9 +10,16 @@ import InputLabel from '@mui/material/InputLabel';
|
|
|
10
10
|
import FormHelperText from '@mui/material/FormHelperText';
|
|
11
11
|
import FormControl from '@mui/material/FormControl';
|
|
12
12
|
import { getPickersTextFieldUtilityClass } from './pickersTextFieldClasses';
|
|
13
|
-
import {
|
|
13
|
+
import { PickersOutlinedInput } from '../PickersInput/PickersOutlinedInput';
|
|
14
|
+
import { PickersFilledInput } from '../PickersInput/PickersFilledInput';
|
|
15
|
+
import { PickersStandardInput } from '../PickersInput/PickersStandardInput';
|
|
14
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
const VARIANT_COMPONENT = {
|
|
19
|
+
standard: PickersStandardInput,
|
|
20
|
+
filled: PickersFilledInput,
|
|
21
|
+
outlined: PickersOutlinedInput
|
|
22
|
+
};
|
|
16
23
|
const PickersTextFieldRoot = styled(FormControl, {
|
|
17
24
|
name: 'MuiPickersTextField',
|
|
18
25
|
slot: 'Root',
|
|
@@ -39,13 +46,13 @@ export const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTe
|
|
|
39
46
|
color = 'primary',
|
|
40
47
|
disabled = false,
|
|
41
48
|
error = false,
|
|
42
|
-
required = false,
|
|
43
49
|
variant = 'outlined',
|
|
50
|
+
required = false,
|
|
44
51
|
// Props used by PickersInput
|
|
45
52
|
InputProps,
|
|
46
53
|
inputProps,
|
|
47
54
|
inputRef,
|
|
48
|
-
|
|
55
|
+
sectionListRef,
|
|
49
56
|
elements,
|
|
50
57
|
areAllSectionsEmpty,
|
|
51
58
|
onClick,
|
|
@@ -83,6 +90,7 @@ export const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTe
|
|
|
83
90
|
variant
|
|
84
91
|
});
|
|
85
92
|
const classes = useUtilityClasses(ownerState);
|
|
93
|
+
const PickersInputComponent = VARIANT_COMPONENT[variant];
|
|
86
94
|
return /*#__PURE__*/_jsxs(PickersTextFieldRoot, _extends({
|
|
87
95
|
className: clsx(classes.root, className),
|
|
88
96
|
ref: handleRootRef,
|
|
@@ -93,6 +101,7 @@ export const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTe
|
|
|
93
101
|
variant: variant,
|
|
94
102
|
error: error,
|
|
95
103
|
color: color,
|
|
104
|
+
fullWidth: fullWidth,
|
|
96
105
|
required: required,
|
|
97
106
|
ownerState: ownerState
|
|
98
107
|
}, other, {
|
|
@@ -101,7 +110,7 @@ export const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTe
|
|
|
101
110
|
id: inputLabelId
|
|
102
111
|
}, InputLabelProps, {
|
|
103
112
|
children: label
|
|
104
|
-
})), /*#__PURE__*/_jsx(
|
|
113
|
+
})), /*#__PURE__*/_jsx(PickersInputComponent, _extends({
|
|
105
114
|
elements: elements,
|
|
106
115
|
areAllSectionsEmpty: areAllSectionsEmpty,
|
|
107
116
|
onClick: onClick,
|
|
@@ -118,7 +127,7 @@ export const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTe
|
|
|
118
127
|
fullWidth: fullWidth,
|
|
119
128
|
inputProps: inputProps,
|
|
120
129
|
inputRef: inputRef,
|
|
121
|
-
|
|
130
|
+
sectionListRef: sectionListRef,
|
|
122
131
|
label: label
|
|
123
132
|
}, InputProps)), helperText && /*#__PURE__*/_jsx(FormHelperText, _extends({
|
|
124
133
|
id: helperTextId
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
3
|
export function getPickersTextFieldUtilityClass(slot) {
|
|
3
4
|
return generateUtilityClass('MuiPickersTextField', slot);
|
|
4
5
|
}
|
|
5
|
-
export const pickersTextFieldClasses = generateUtilityClasses('MuiPickersTextField', ['root', 'focused', 'disabled', 'error', 'required']);
|
|
6
|
-
export function getPickersInputUtilityClass(slot) {
|
|
7
|
-
return generateUtilityClass('MuiPickersInput', slot);
|
|
8
|
-
}
|
|
9
|
-
export const pickersInputClasses = generateUtilityClasses('MuiPickersInput', ['root', 'focused', 'disabled', 'error', 'notchedOutline', 'adornedStart', 'adornedEnd', 'input', 'sectionsContainer', 'sectionContent', 'sectionBefore', 'sectionAfter']);
|
|
6
|
+
export const pickersTextFieldClasses = generateUtilityClasses('MuiPickersTextField', ['root', 'focused', 'disabled', 'error', 'required']);
|
|
@@ -142,7 +142,14 @@ export const useField = params => {
|
|
|
142
142
|
const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
|
|
143
143
|
const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
|
|
144
144
|
if (isValidPastedValue) {
|
|
145
|
-
|
|
145
|
+
resetCharacterQuery();
|
|
146
|
+
updateSectionValue({
|
|
147
|
+
activeSection,
|
|
148
|
+
newSectionValue: pastedValue,
|
|
149
|
+
shouldGoToNextSection: true
|
|
150
|
+
});
|
|
151
|
+
// prevent default to avoid the input change handler being called
|
|
152
|
+
event.preventDefault();
|
|
146
153
|
return;
|
|
147
154
|
}
|
|
148
155
|
if (lettersOnly || digitsOnly) {
|
|
@@ -63,11 +63,12 @@ export function useViews({
|
|
|
63
63
|
onFocusedViewChange?.(viewToFocus, hasFocus);
|
|
64
64
|
});
|
|
65
65
|
const handleChangeView = useEventCallback(newView => {
|
|
66
|
+
// always keep the focused view in sync
|
|
67
|
+
handleFocusedViewChange(newView, true);
|
|
66
68
|
if (newView === view) {
|
|
67
69
|
return;
|
|
68
70
|
}
|
|
69
71
|
setView(newView);
|
|
70
|
-
handleFocusedViewChange(newView, true);
|
|
71
72
|
if (onViewChange) {
|
|
72
73
|
onViewChange(newView);
|
|
73
74
|
}
|
|
@@ -76,7 +77,6 @@ export function useViews({
|
|
|
76
77
|
if (nextView) {
|
|
77
78
|
handleChangeView(nextView);
|
|
78
79
|
}
|
|
79
|
-
handleFocusedViewChange(nextView, true);
|
|
80
80
|
});
|
|
81
81
|
const setValueAndGoToNextView = useEventCallback((value, currentViewSelectionState, selectedView) => {
|
|
82
82
|
const isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
|
|
@@ -85,18 +85,19 @@ export function useViews({
|
|
|
85
85
|
// but when it's not the final view given all `views` -> overall selection state should be `partial`.
|
|
86
86
|
views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
|
|
87
87
|
const globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? 'partial' : currentViewSelectionState;
|
|
88
|
-
onChange(value, globalSelectionState);
|
|
89
|
-
if
|
|
88
|
+
onChange(value, globalSelectionState, selectedView);
|
|
89
|
+
// Detects if the selected view is not the active one.
|
|
90
|
+
// Can happen if multiple views are displayed, like in `DesktopDateTimePicker` or `MultiSectionDigitalClock`.
|
|
91
|
+
if (selectedView && selectedView !== view) {
|
|
92
|
+
const nextViewAfterSelected = views[views.indexOf(selectedView) + 1];
|
|
93
|
+
if (nextViewAfterSelected) {
|
|
94
|
+
// move to next view after the selected one
|
|
95
|
+
handleChangeView(nextViewAfterSelected);
|
|
96
|
+
}
|
|
97
|
+
} else if (isSelectionFinishedOnCurrentView) {
|
|
90
98
|
goToNextView();
|
|
91
99
|
}
|
|
92
100
|
});
|
|
93
|
-
const setValueAndGoToView = useEventCallback((value, newView, selectedView) => {
|
|
94
|
-
onChange(value, newView ? 'partial' : 'finish', selectedView);
|
|
95
|
-
if (newView) {
|
|
96
|
-
handleChangeView(newView);
|
|
97
|
-
handleFocusedViewChange(newView, true);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
101
|
return {
|
|
101
102
|
view,
|
|
102
103
|
setView: handleChangeView,
|
|
@@ -107,7 +108,6 @@ export function useViews({
|
|
|
107
108
|
// Always return up-to-date default view instead of the initial one (i.e. defaultView.current)
|
|
108
109
|
defaultView: views.includes(openTo) ? openTo : views[0],
|
|
109
110
|
goToNextView,
|
|
110
|
-
setValueAndGoToNextView
|
|
111
|
-
setValueAndGoToView
|
|
111
|
+
setValueAndGoToNextView
|
|
112
112
|
};
|
|
113
113
|
}
|
package/modern/locales/ruRU.js
CHANGED
|
@@ -42,8 +42,7 @@ const ruRUPickers = {
|
|
|
42
42
|
// Open picker labels
|
|
43
43
|
openDatePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Выберите дату, выбрана дата ${utils.format(value, 'fullDate')}` : 'Выберите дату',
|
|
44
44
|
openTimePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Выберите время, выбрано время ${utils.format(value, 'fullTime')}` : 'Выберите время',
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
fieldClearLabel: 'Очистить значение',
|
|
47
46
|
// Table labels
|
|
48
47
|
timeTableLabel: 'выбрать время',
|
|
49
48
|
dateTableLabel: 'выбрать дату',
|
|
@@ -260,9 +260,9 @@ const DateCalendar = exports.DateCalendar = /*#__PURE__*/React.forwardRef(functi
|
|
|
260
260
|
const handleSelectedDayChange = (0, _utils2.unstable_useEventCallback)(day => {
|
|
261
261
|
if (day) {
|
|
262
262
|
// If there is a date already selected, then we want to keep its time
|
|
263
|
-
return handleValueChange((0, _dateUtils.mergeDateAndTime)(utils, day, value ?? referenceDate), 'finish');
|
|
263
|
+
return handleValueChange((0, _dateUtils.mergeDateAndTime)(utils, day, value ?? referenceDate), 'finish', view);
|
|
264
264
|
}
|
|
265
|
-
return handleValueChange(day, 'finish');
|
|
265
|
+
return handleValueChange(day, 'finish', view);
|
|
266
266
|
});
|
|
267
267
|
React.useEffect(() => {
|
|
268
268
|
if (value != null && utils.isValid(value)) {
|
|
@@ -431,9 +431,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
431
431
|
monthsPerRow: _propTypes.default.oneOf([3, 4]),
|
|
432
432
|
/**
|
|
433
433
|
* Callback fired when the value changes.
|
|
434
|
-
* @template
|
|
435
|
-
* @
|
|
434
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
435
|
+
* @template TView The view type. Will be one of date or time views.
|
|
436
|
+
* @param {TValue} value The new value.
|
|
436
437
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
438
|
+
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
437
439
|
*/
|
|
438
440
|
onChange: _propTypes.default.func,
|
|
439
441
|
/**
|
|
@@ -336,8 +336,9 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
|
|
|
336
336
|
minutesStep: _propTypes.default.number,
|
|
337
337
|
/**
|
|
338
338
|
* Callback fired when the value changes.
|
|
339
|
-
* @template
|
|
340
|
-
* @
|
|
339
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
340
|
+
* @template TView The view type. Will be one of date or time views.
|
|
341
|
+
* @param {TValue} value The new value.
|
|
341
342
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
342
343
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
343
344
|
*/
|
|
@@ -131,7 +131,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
|
|
|
131
131
|
}, [ampm, inViews]);
|
|
132
132
|
const {
|
|
133
133
|
view,
|
|
134
|
-
|
|
134
|
+
setValueAndGoToNextView,
|
|
135
135
|
focusedView
|
|
136
136
|
} = (0, _useViews.useViews)({
|
|
137
137
|
view: inView,
|
|
@@ -143,7 +143,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
|
|
|
143
143
|
onFocusedViewChange
|
|
144
144
|
});
|
|
145
145
|
const handleMeridiemValueChange = (0, _useEventCallback.default)(newValue => {
|
|
146
|
-
|
|
146
|
+
setValueAndGoToNextView(newValue, 'finish', 'meridiem');
|
|
147
147
|
});
|
|
148
148
|
const {
|
|
149
149
|
meridiemMode,
|
|
@@ -224,11 +224,6 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
|
|
|
224
224
|
throw new Error('not supported');
|
|
225
225
|
}
|
|
226
226
|
}, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
|
|
227
|
-
const handleSectionChange = (0, _useEventCallback.default)((sectionView, newValue) => {
|
|
228
|
-
const viewIndex = views.indexOf(sectionView);
|
|
229
|
-
const nextView = views[viewIndex + 1];
|
|
230
|
-
setValueAndGoToView(newValue, nextView, sectionView);
|
|
231
|
-
});
|
|
232
227
|
const buildViewProps = React.useCallback(viewToBuild => {
|
|
233
228
|
switch (viewToBuild) {
|
|
234
229
|
case 'hours':
|
|
@@ -236,7 +231,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
|
|
|
236
231
|
return {
|
|
237
232
|
onChange: hours => {
|
|
238
233
|
const valueWithMeridiem = (0, _timeUtils.convertValueToMeridiem)(hours, meridiemMode, ampm);
|
|
239
|
-
|
|
234
|
+
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), 'finish', 'hours');
|
|
240
235
|
},
|
|
241
236
|
items: (0, _MultiSectionDigitalClock.getHourSectionOptions)({
|
|
242
237
|
now,
|
|
@@ -254,7 +249,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
|
|
|
254
249
|
{
|
|
255
250
|
return {
|
|
256
251
|
onChange: minutes => {
|
|
257
|
-
|
|
252
|
+
setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minutes), 'finish', 'minutes');
|
|
258
253
|
},
|
|
259
254
|
items: (0, _MultiSectionDigitalClock.getTimeSectionOptions)({
|
|
260
255
|
value: utils.getMinutes(valueOrReferenceDate),
|
|
@@ -271,7 +266,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
|
|
|
271
266
|
{
|
|
272
267
|
return {
|
|
273
268
|
onChange: seconds => {
|
|
274
|
-
|
|
269
|
+
setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, seconds), 'finish', 'seconds');
|
|
275
270
|
},
|
|
276
271
|
items: (0, _MultiSectionDigitalClock.getTimeSectionOptions)({
|
|
277
272
|
value: utils.getSeconds(valueOrReferenceDate),
|
|
@@ -308,7 +303,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
|
|
|
308
303
|
default:
|
|
309
304
|
throw new Error(`Unknown view: ${viewToBuild} found.`);
|
|
310
305
|
}
|
|
311
|
-
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode,
|
|
306
|
+
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
|
|
312
307
|
const viewTimeOptions = React.useMemo(() => {
|
|
313
308
|
return views.reduce((result, currentView) => {
|
|
314
309
|
return (0, _extends2.default)({}, result, {
|
|
@@ -406,8 +401,9 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
406
401
|
minutesStep: _propTypes.default.number,
|
|
407
402
|
/**
|
|
408
403
|
* Callback fired when the value changes.
|
|
409
|
-
* @template
|
|
410
|
-
* @
|
|
404
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
405
|
+
* @template TView The view type. Will be one of date or time views.
|
|
406
|
+
* @param {TValue} value The new value.
|
|
411
407
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
412
408
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
413
409
|
*/
|
|
@@ -56,7 +56,7 @@ const MultiSectionDigitalClockSectionRoot = (0, _styles.styled)(_MenuList.defaul
|
|
|
56
56
|
'&:not(:first-of-type)': {
|
|
57
57
|
borderLeft: `1px solid ${(theme.vars || theme).palette.divider}`
|
|
58
58
|
},
|
|
59
|
-
'
|
|
59
|
+
'&::after': {
|
|
60
60
|
display: 'block',
|
|
61
61
|
content: '""',
|
|
62
62
|
// subtracting the height of one item, extra margin and borders to make sure the max height is correct
|
|
@@ -125,17 +125,13 @@ const MultiSectionDigitalClockSection = exports.MultiSectionDigitalClockSection
|
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
const activeItem = containerRef.current.querySelector('[role="option"][tabindex="0"], [role="option"][aria-selected="true"]');
|
|
128
|
+
if (active && autoFocus && activeItem) {
|
|
129
|
+
activeItem.focus();
|
|
130
|
+
}
|
|
128
131
|
if (!activeItem || previousActive.current === activeItem) {
|
|
129
|
-
// Handle setting the ref to null if the selected item is ever reset via UI
|
|
130
|
-
if (previousActive.current !== activeItem) {
|
|
131
|
-
previousActive.current = activeItem;
|
|
132
|
-
}
|
|
133
132
|
return;
|
|
134
133
|
}
|
|
135
134
|
previousActive.current = activeItem;
|
|
136
|
-
if (active && autoFocus) {
|
|
137
|
-
activeItem.focus();
|
|
138
|
-
}
|
|
139
135
|
const offsetTop = activeItem.offsetTop;
|
|
140
136
|
|
|
141
137
|
// Subtracting the 4px of extra margin intended for the first visible section item
|