@mui/x-date-pickers-pro 8.0.0-alpha.1 → 8.0.0-alpha.2
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 +228 -7
- package/DateRangePicker/DateRangePicker.types.d.ts +2 -2
- package/DateRangePicker/shared.d.ts +3 -2
- package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +2 -2
- package/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
- package/DateTimeRangePicker/shared.d.ts +4 -3
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
- package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +12 -10
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +11 -9
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +11 -9
- package/README.md +7 -4
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
- package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +11 -10
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.types.d.ts +11 -10
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.types.d.ts +10 -9
- package/index.js +1 -1
- package/internals/hooks/models/useRangePicker.d.ts +1 -2
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
- package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +13 -12
- package/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
- package/internals/hooks/useMultiInputFieldSelectedSections.d.ts +6 -7
- package/internals/hooks/useRangePosition.d.ts +3 -2
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +1 -2
- package/internals/models/dateTimeRange.d.ts +2 -2
- package/internals/models/fields.d.ts +6 -6
- package/internals/models/timeRange.d.ts +2 -2
- package/internals/utils/date-fields-utils.d.ts +6 -6
- package/internals/utils/releaseInfo.js +1 -1
- package/internals/utils/valueManagers.d.ts +4 -3
- package/models/dateRange.d.ts +3 -3
- package/models/fields.d.ts +6 -9
- package/models/index.d.ts +1 -0
- package/models/index.js +2 -1
- package/models/range.d.ts +0 -1
- package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
- package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/models/index.js +2 -1
- package/modern/validation/validateDateRange.js +8 -0
- package/modern/validation/validateDateTimeRange.js +4 -0
- package/modern/validation/validateTimeRange.js +8 -0
- package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +7 -6
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +9 -11
- package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +9 -11
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -11
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +4 -4
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +4 -4
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +4 -4
- package/node/index.js +1 -1
- package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
- package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
- package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
- package/node/internals/utils/releaseInfo.js +1 -1
- package/node/validation/validateDateRange.js +8 -0
- package/node/validation/validateDateTimeRange.js +4 -0
- package/node/validation/validateTimeRange.js +8 -0
- package/package.json +4 -4
- package/validation/validateDateRange.d.ts +9 -1
- package/validation/validateDateRange.js +8 -0
- package/validation/validateDateTimeRange.d.ts +6 -2
- package/validation/validateDateTimeRange.js +4 -0
- package/validation/validateTimeRange.d.ts +9 -1
- package/validation/validateTimeRange.js +8 -0
|
@@ -40,13 +40,22 @@ export const useMobileRangePicker = _ref => {
|
|
|
40
40
|
} = props;
|
|
41
41
|
const startFieldRef = React.useRef(null);
|
|
42
42
|
const endFieldRef = React.useRef(null);
|
|
43
|
+
const singleInputFieldRef = React.useRef(null);
|
|
43
44
|
const fieldType = slots.field.fieldType ?? 'multi-input';
|
|
44
45
|
const {
|
|
45
46
|
rangePosition,
|
|
46
47
|
onRangePositionChange
|
|
47
|
-
} = useRangePosition(props, fieldType === 'single-input' ?
|
|
48
|
+
} = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
|
|
48
49
|
const labelId = useId();
|
|
49
50
|
const contextTranslations = usePickerTranslations();
|
|
51
|
+
let fieldRef;
|
|
52
|
+
if (fieldType === 'single-input') {
|
|
53
|
+
fieldRef = singleInputFieldRef;
|
|
54
|
+
} else if (rangePosition === 'start') {
|
|
55
|
+
fieldRef = startFieldRef;
|
|
56
|
+
} else {
|
|
57
|
+
fieldRef = endFieldRef;
|
|
58
|
+
}
|
|
50
59
|
const {
|
|
51
60
|
open,
|
|
52
61
|
actions,
|
|
@@ -59,7 +68,7 @@ export const useMobileRangePicker = _ref => {
|
|
|
59
68
|
props,
|
|
60
69
|
variant: 'mobile',
|
|
61
70
|
autoFocusView: true,
|
|
62
|
-
fieldRef
|
|
71
|
+
fieldRef,
|
|
63
72
|
localeText,
|
|
64
73
|
additionalViewProps: {
|
|
65
74
|
rangePosition,
|
|
@@ -110,7 +119,8 @@ export const useMobileRangePicker = _ref => {
|
|
|
110
119
|
pickerSlotProps: innerSlotProps,
|
|
111
120
|
fieldProps,
|
|
112
121
|
startFieldRef,
|
|
113
|
-
endFieldRef
|
|
122
|
+
endFieldRef,
|
|
123
|
+
singleInputFieldRef
|
|
114
124
|
});
|
|
115
125
|
const slotPropsForLayout = _extends({}, innerSlotProps, {
|
|
116
126
|
tabs: _extends({}, innerSlotProps?.tabs, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTczMjgzNDgwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
package/modern/models/index.js
CHANGED
|
@@ -9,6 +9,14 @@ import { rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
|
9
9
|
* Validation props used by the Date Range Picker, Date Range Field and Date Range Calendar components.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Validation props as received by the validateDateRange method.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Name of the props that should be defaulted before being passed to the validateDateRange method.
|
|
18
|
+
*/
|
|
19
|
+
|
|
12
20
|
export const validateDateRange = ({
|
|
13
21
|
adapter,
|
|
14
22
|
value,
|
|
@@ -9,6 +9,10 @@ import { rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
|
9
9
|
* Validation props used by the Date Time Range Picker and Date Time Range Field.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Validation props as received by the validateDateTimeRange method.
|
|
14
|
+
*/
|
|
15
|
+
|
|
12
16
|
export const validateDateTimeRange = ({
|
|
13
17
|
adapter,
|
|
14
18
|
value,
|
|
@@ -6,6 +6,14 @@ import { rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
|
6
6
|
* Validation props used by the Time Range Picker and Time Range Field.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Validation props as received by the validateTimeRange method.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Name of the props that should be defaulted before being passed to the validateTimeRange method.
|
|
15
|
+
*/
|
|
16
|
+
|
|
9
17
|
export const validateTimeRange = ({
|
|
10
18
|
adapter,
|
|
11
19
|
value,
|
|
@@ -32,10 +32,7 @@ const tabToView = tab => {
|
|
|
32
32
|
}
|
|
33
33
|
return 'hours';
|
|
34
34
|
};
|
|
35
|
-
const useUtilityClasses =
|
|
36
|
-
const {
|
|
37
|
-
classes
|
|
38
|
-
} = ownerState;
|
|
35
|
+
const useUtilityClasses = classes => {
|
|
39
36
|
const slots = {
|
|
40
37
|
root: ['root'],
|
|
41
38
|
tabButton: ['tabButton'],
|
|
@@ -86,10 +83,14 @@ const DateTimeRangePickerTabs = exports.DateTimeRangePickerTabs = function DateT
|
|
|
86
83
|
rangePosition,
|
|
87
84
|
onRangePositionChange,
|
|
88
85
|
className,
|
|
86
|
+
classes: classesProp,
|
|
89
87
|
sx
|
|
90
88
|
} = props;
|
|
91
89
|
const translations = (0, _hooks.usePickerTranslations)();
|
|
92
|
-
const
|
|
90
|
+
const {
|
|
91
|
+
ownerState
|
|
92
|
+
} = (0, _internals.usePickerPrivateContext)();
|
|
93
|
+
const classes = useUtilityClasses(classesProp);
|
|
93
94
|
const value = React.useMemo(() => viewToTab(view, rangePosition), [view, rangePosition]);
|
|
94
95
|
const isPreviousHidden = value === 'start-date';
|
|
95
96
|
const isNextHidden = value === 'end-time';
|
|
@@ -128,7 +129,7 @@ const DateTimeRangePickerTabs = exports.DateTimeRangePickerTabs = function DateT
|
|
|
128
129
|
return null;
|
|
129
130
|
}
|
|
130
131
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(DateTimeRangePickerTabsRoot, {
|
|
131
|
-
ownerState:
|
|
132
|
+
ownerState: ownerState,
|
|
132
133
|
className: (0, _clsx.default)(classes.root, className),
|
|
133
134
|
sx: sx,
|
|
134
135
|
children: [!isPreviousHidden ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
@@ -23,14 +23,11 @@ var _hooks = require("@mui/x-date-pickers/hooks");
|
|
|
23
23
|
var _PickersTextField = require("@mui/x-date-pickers/PickersTextField");
|
|
24
24
|
var _useMultiInputDateRangeField = require("../internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField");
|
|
25
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
-
const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className"];
|
|
26
|
+
const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className", "classes"];
|
|
27
27
|
const multiInputDateRangeFieldClasses = exports.multiInputDateRangeFieldClasses = (0, _utils.unstable_generateUtilityClasses)('MuiMultiInputDateRangeField', ['root', 'separator']);
|
|
28
28
|
const getMultiInputDateRangeFieldUtilityClass = slot => (0, _utils.unstable_generateUtilityClass)('MuiMultiInputDateRangeField', slot);
|
|
29
29
|
exports.getMultiInputDateRangeFieldUtilityClass = getMultiInputDateRangeFieldUtilityClass;
|
|
30
|
-
const useUtilityClasses =
|
|
31
|
-
const {
|
|
32
|
-
classes
|
|
33
|
-
} = ownerState;
|
|
30
|
+
const useUtilityClasses = classes => {
|
|
34
31
|
const slots = {
|
|
35
32
|
root: ['root'],
|
|
36
33
|
separator: ['separator']
|
|
@@ -78,11 +75,12 @@ const MultiInputDateRangeField = exports.MultiInputDateRangeField = /*#__PURE__*
|
|
|
78
75
|
slotProps,
|
|
79
76
|
unstableStartFieldRef,
|
|
80
77
|
unstableEndFieldRef,
|
|
81
|
-
className
|
|
78
|
+
className,
|
|
79
|
+
classes: classesProp
|
|
82
80
|
} = forwardedProps,
|
|
83
81
|
otherForwardedProps = (0, _objectWithoutPropertiesLoose2.default)(forwardedProps, _excluded);
|
|
84
|
-
const ownerState =
|
|
85
|
-
const classes = useUtilityClasses(
|
|
82
|
+
const ownerState = (0, _internals.useFieldOwnerState)(internalProps);
|
|
83
|
+
const classes = useUtilityClasses(classesProp);
|
|
86
84
|
const Root = slots?.root ?? MultiInputDateRangeFieldRoot;
|
|
87
85
|
const rootProps = (0, _useSlotProps.default)({
|
|
88
86
|
elementType: Root,
|
|
@@ -266,10 +264,10 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
|
|
|
266
264
|
*/
|
|
267
265
|
shouldDisableDate: _propTypes.default.func,
|
|
268
266
|
/**
|
|
269
|
-
* If `true`, the format will respect the leading zeroes (
|
|
270
|
-
* If `false`, the format will always add leading zeroes (
|
|
267
|
+
* If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
268
|
+
* If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
271
269
|
*
|
|
272
|
-
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (
|
|
270
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
273
271
|
*
|
|
274
272
|
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
275
273
|
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
@@ -23,14 +23,11 @@ var _hooks = require("@mui/x-date-pickers/hooks");
|
|
|
23
23
|
var _PickersTextField = require("@mui/x-date-pickers/PickersTextField");
|
|
24
24
|
var _useMultiInputDateTimeRangeField = require("../internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField");
|
|
25
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
-
const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className"];
|
|
26
|
+
const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className", "classes"];
|
|
27
27
|
const multiInputDateTimeRangeFieldClasses = exports.multiInputDateTimeRangeFieldClasses = (0, _utils.unstable_generateUtilityClasses)('MuiMultiInputDateTimeRangeField', ['root', 'separator']);
|
|
28
28
|
const getMultiInputDateTimeRangeFieldUtilityClass = slot => (0, _utils.unstable_generateUtilityClass)('MuiMultiInputDateTimeRangeField', slot);
|
|
29
29
|
exports.getMultiInputDateTimeRangeFieldUtilityClass = getMultiInputDateTimeRangeFieldUtilityClass;
|
|
30
|
-
const useUtilityClasses =
|
|
31
|
-
const {
|
|
32
|
-
classes
|
|
33
|
-
} = ownerState;
|
|
30
|
+
const useUtilityClasses = classes => {
|
|
34
31
|
const slots = {
|
|
35
32
|
root: ['root'],
|
|
36
33
|
separator: ['separator']
|
|
@@ -78,11 +75,12 @@ const MultiInputDateTimeRangeField = exports.MultiInputDateTimeRangeField = /*#_
|
|
|
78
75
|
slotProps,
|
|
79
76
|
unstableStartFieldRef,
|
|
80
77
|
unstableEndFieldRef,
|
|
81
|
-
className
|
|
78
|
+
className,
|
|
79
|
+
classes: classesProp
|
|
82
80
|
} = forwardedProps,
|
|
83
81
|
otherForwardedProps = (0, _objectWithoutPropertiesLoose2.default)(forwardedProps, _excluded);
|
|
84
|
-
const ownerState = themeProps;
|
|
85
|
-
const classes = useUtilityClasses(
|
|
82
|
+
const ownerState = (0, _internals.useFieldOwnerState)(themeProps);
|
|
83
|
+
const classes = useUtilityClasses(classesProp);
|
|
86
84
|
const Root = slots?.root ?? MultiInputDateTimeRangeFieldRoot;
|
|
87
85
|
const rootProps = (0, _useSlotProps.default)({
|
|
88
86
|
elementType: Root,
|
|
@@ -306,10 +304,10 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
|
|
|
306
304
|
*/
|
|
307
305
|
shouldDisableTime: _propTypes.default.func,
|
|
308
306
|
/**
|
|
309
|
-
* If `true`, the format will respect the leading zeroes (
|
|
310
|
-
* If `false`, the format will always add leading zeroes (
|
|
307
|
+
* If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
308
|
+
* If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
311
309
|
*
|
|
312
|
-
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (
|
|
310
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
313
311
|
*
|
|
314
312
|
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
315
313
|
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
@@ -23,14 +23,11 @@ var _hooks = require("@mui/x-date-pickers/hooks");
|
|
|
23
23
|
var _PickersTextField = require("@mui/x-date-pickers/PickersTextField");
|
|
24
24
|
var _useMultiInputTimeRangeField = require("../internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField");
|
|
25
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
-
const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className"];
|
|
26
|
+
const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className", "classes"];
|
|
27
27
|
const multiInputTimeRangeFieldClasses = exports.multiInputTimeRangeFieldClasses = (0, _utils.unstable_generateUtilityClasses)('MuiMultiInputTimeRangeField', ['root', 'separator']);
|
|
28
28
|
const getMultiInputTimeRangeFieldUtilityClass = slot => (0, _utils.unstable_generateUtilityClass)('MuiMultiInputTimeRangeField', slot);
|
|
29
29
|
exports.getMultiInputTimeRangeFieldUtilityClass = getMultiInputTimeRangeFieldUtilityClass;
|
|
30
|
-
const useUtilityClasses =
|
|
31
|
-
const {
|
|
32
|
-
classes
|
|
33
|
-
} = ownerState;
|
|
30
|
+
const useUtilityClasses = classes => {
|
|
34
31
|
const slots = {
|
|
35
32
|
root: ['root'],
|
|
36
33
|
separator: ['separator']
|
|
@@ -78,11 +75,12 @@ const MultiInputTimeRangeField = exports.MultiInputTimeRangeField = /*#__PURE__*
|
|
|
78
75
|
slotProps,
|
|
79
76
|
unstableStartFieldRef,
|
|
80
77
|
unstableEndFieldRef,
|
|
81
|
-
className
|
|
78
|
+
className,
|
|
79
|
+
classes: classesProp
|
|
82
80
|
} = forwardedProps,
|
|
83
81
|
otherForwardedProps = (0, _objectWithoutPropertiesLoose2.default)(forwardedProps, _excluded);
|
|
84
|
-
const ownerState = themeProps;
|
|
85
|
-
const classes = useUtilityClasses(
|
|
82
|
+
const ownerState = (0, _internals.useFieldOwnerState)(themeProps);
|
|
83
|
+
const classes = useUtilityClasses(classesProp);
|
|
86
84
|
const Root = slots?.root ?? MultiInputTimeRangeFieldRoot;
|
|
87
85
|
const rootProps = (0, _useSlotProps.default)({
|
|
88
86
|
elementType: Root,
|
|
@@ -278,10 +276,10 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
|
|
|
278
276
|
*/
|
|
279
277
|
shouldDisableTime: _propTypes.default.func,
|
|
280
278
|
/**
|
|
281
|
-
* If `true`, the format will respect the leading zeroes (
|
|
282
|
-
* If `false`, the format will always add leading zeroes (
|
|
279
|
+
* If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
280
|
+
* If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
283
281
|
*
|
|
284
|
-
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (
|
|
282
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
285
283
|
*
|
|
286
284
|
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
287
285
|
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
@@ -43,7 +43,7 @@ const SingleInputDateRangeField = exports.SingleInputDateRangeField = /*#__PURE_
|
|
|
43
43
|
inputProps
|
|
44
44
|
} = themeProps,
|
|
45
45
|
other = (0, _objectWithoutPropertiesLoose2.default)(themeProps, _excluded);
|
|
46
|
-
const ownerState = themeProps;
|
|
46
|
+
const ownerState = (0, _internals.useFieldOwnerState)(themeProps);
|
|
47
47
|
const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? _TextField.default : _PickersTextField.PickersTextField);
|
|
48
48
|
const textFieldProps = (0, _useSlotProps.default)({
|
|
49
49
|
elementType: TextField,
|
|
@@ -269,10 +269,10 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
|
|
|
269
269
|
*/
|
|
270
270
|
shouldDisableDate: _propTypes.default.func,
|
|
271
271
|
/**
|
|
272
|
-
* If `true`, the format will respect the leading zeroes (
|
|
273
|
-
* If `false`, the format will always add leading zeroes (
|
|
272
|
+
* If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
273
|
+
* If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
274
274
|
*
|
|
275
|
-
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (
|
|
275
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
276
276
|
*
|
|
277
277
|
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
278
278
|
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
@@ -43,7 +43,7 @@ const SingleInputDateTimeRangeField = exports.SingleInputDateTimeRangeField = /*
|
|
|
43
43
|
inputProps
|
|
44
44
|
} = themeProps,
|
|
45
45
|
other = (0, _objectWithoutPropertiesLoose2.default)(themeProps, _excluded);
|
|
46
|
-
const ownerState = themeProps;
|
|
46
|
+
const ownerState = (0, _internals.useFieldOwnerState)(themeProps);
|
|
47
47
|
const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? _TextField.default : _PickersTextField.PickersTextField);
|
|
48
48
|
const textFieldProps = (0, _useSlotProps.default)({
|
|
49
49
|
elementType: TextField,
|
|
@@ -309,10 +309,10 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
|
|
|
309
309
|
*/
|
|
310
310
|
shouldDisableTime: _propTypes.default.func,
|
|
311
311
|
/**
|
|
312
|
-
* If `true`, the format will respect the leading zeroes (
|
|
313
|
-
* If `false`, the format will always add leading zeroes (
|
|
312
|
+
* If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
313
|
+
* If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
314
314
|
*
|
|
315
|
-
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (
|
|
315
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
316
316
|
*
|
|
317
317
|
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
318
318
|
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
@@ -43,7 +43,7 @@ const SingleInputTimeRangeField = exports.SingleInputTimeRangeField = /*#__PURE_
|
|
|
43
43
|
inputProps
|
|
44
44
|
} = themeProps,
|
|
45
45
|
other = (0, _objectWithoutPropertiesLoose2.default)(themeProps, _excluded);
|
|
46
|
-
const ownerState = themeProps;
|
|
46
|
+
const ownerState = (0, _internals.useFieldOwnerState)(themeProps);
|
|
47
47
|
const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? _TextField.default : _PickersTextField.PickersTextField);
|
|
48
48
|
const textFieldProps = (0, _useSlotProps.default)({
|
|
49
49
|
elementType: TextField,
|
|
@@ -281,10 +281,10 @@ process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
|
|
|
281
281
|
*/
|
|
282
282
|
shouldDisableTime: _propTypes.default.func,
|
|
283
283
|
/**
|
|
284
|
-
* If `true`, the format will respect the leading zeroes (
|
|
285
|
-
* If `false`, the format will always add leading zeroes (
|
|
284
|
+
* If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
285
|
+
* If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
286
286
|
*
|
|
287
|
-
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (
|
|
287
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
288
288
|
*
|
|
289
289
|
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
290
290
|
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
package/node/index.js
CHANGED
|
@@ -51,12 +51,21 @@ const useDesktopRangePicker = _ref => {
|
|
|
51
51
|
const popperRef = React.useRef(null);
|
|
52
52
|
const startFieldRef = React.useRef(null);
|
|
53
53
|
const endFieldRef = React.useRef(null);
|
|
54
|
+
const singleInputFieldRef = React.useRef(null);
|
|
54
55
|
const initialView = React.useRef(props.openTo ?? null);
|
|
55
56
|
const fieldType = slots.field.fieldType ?? 'multi-input';
|
|
56
57
|
const {
|
|
57
58
|
rangePosition,
|
|
58
59
|
onRangePositionChange
|
|
59
|
-
} = (0, _useRangePosition.useRangePosition)(props, fieldType === 'single-input' ?
|
|
60
|
+
} = (0, _useRangePosition.useRangePosition)(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
|
|
61
|
+
let fieldRef;
|
|
62
|
+
if (fieldType === 'single-input') {
|
|
63
|
+
fieldRef = singleInputFieldRef;
|
|
64
|
+
} else if (rangePosition === 'start') {
|
|
65
|
+
fieldRef = startFieldRef;
|
|
66
|
+
} else {
|
|
67
|
+
fieldRef = endFieldRef;
|
|
68
|
+
}
|
|
60
69
|
const {
|
|
61
70
|
open,
|
|
62
71
|
actions,
|
|
@@ -70,7 +79,7 @@ const useDesktopRangePicker = _ref => {
|
|
|
70
79
|
props,
|
|
71
80
|
variant: 'desktop',
|
|
72
81
|
autoFocusView: false,
|
|
73
|
-
fieldRef
|
|
82
|
+
fieldRef,
|
|
74
83
|
localeText,
|
|
75
84
|
additionalViewProps: {
|
|
76
85
|
rangePosition,
|
|
@@ -138,6 +147,7 @@ const useDesktopRangePicker = _ref => {
|
|
|
138
147
|
anchorRef,
|
|
139
148
|
startFieldRef,
|
|
140
149
|
endFieldRef,
|
|
150
|
+
singleInputFieldRef,
|
|
141
151
|
currentView: layoutProps.view !== props.openTo ? layoutProps.view : undefined,
|
|
142
152
|
initialView: initialView.current ?? undefined,
|
|
143
153
|
onViewChange: layoutProps.onViewChange
|
|
@@ -164,36 +164,35 @@ const useSingleInputFieldSlotProps = ({
|
|
|
164
164
|
onBlur,
|
|
165
165
|
rangePosition,
|
|
166
166
|
onRangePositionChange,
|
|
167
|
-
|
|
168
|
-
endFieldRef,
|
|
167
|
+
singleInputFieldRef,
|
|
169
168
|
pickerSlots,
|
|
170
169
|
pickerSlotProps,
|
|
171
170
|
fieldProps,
|
|
172
171
|
anchorRef,
|
|
173
172
|
currentView
|
|
174
173
|
}) => {
|
|
175
|
-
const handleFieldRef = (0, _useForkRef.default)(fieldProps.unstableFieldRef,
|
|
174
|
+
const handleFieldRef = (0, _useForkRef.default)(fieldProps.unstableFieldRef, singleInputFieldRef);
|
|
176
175
|
React.useEffect(() => {
|
|
177
|
-
if (!open || !
|
|
176
|
+
if (!open || !singleInputFieldRef.current || variant === 'mobile') {
|
|
178
177
|
return;
|
|
179
178
|
}
|
|
180
|
-
if (
|
|
179
|
+
if (singleInputFieldRef.current.isFieldFocused()) {
|
|
181
180
|
return;
|
|
182
181
|
}
|
|
183
182
|
|
|
184
183
|
// bring back focus to the field with the current view section selected
|
|
185
184
|
if (currentView) {
|
|
186
|
-
const sections =
|
|
185
|
+
const sections = singleInputFieldRef.current.getSections().map(section => section.type);
|
|
187
186
|
const newSelectedSection = rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView);
|
|
188
|
-
|
|
187
|
+
singleInputFieldRef.current?.focusField(newSelectedSection);
|
|
189
188
|
}
|
|
190
|
-
}, [rangePosition, open, currentView,
|
|
189
|
+
}, [rangePosition, open, currentView, singleInputFieldRef, variant]);
|
|
191
190
|
const updateRangePosition = () => {
|
|
192
|
-
if (!
|
|
191
|
+
if (!singleInputFieldRef.current?.isFieldFocused()) {
|
|
193
192
|
return;
|
|
194
193
|
}
|
|
195
|
-
const sections =
|
|
196
|
-
const activeSectionIndex =
|
|
194
|
+
const sections = singleInputFieldRef.current.getSections();
|
|
195
|
+
const activeSectionIndex = singleInputFieldRef.current?.getActiveSectionIndex();
|
|
197
196
|
const domRangePosition = activeSectionIndex == null || activeSectionIndex < sections.length / 2 ? 'start' : 'end';
|
|
198
197
|
if (domRangePosition != null && domRangePosition !== rangePosition) {
|
|
199
198
|
onRangePositionChange(domRangePosition);
|
|
@@ -48,13 +48,22 @@ const useMobileRangePicker = _ref => {
|
|
|
48
48
|
} = props;
|
|
49
49
|
const startFieldRef = React.useRef(null);
|
|
50
50
|
const endFieldRef = React.useRef(null);
|
|
51
|
+
const singleInputFieldRef = React.useRef(null);
|
|
51
52
|
const fieldType = slots.field.fieldType ?? 'multi-input';
|
|
52
53
|
const {
|
|
53
54
|
rangePosition,
|
|
54
55
|
onRangePositionChange
|
|
55
|
-
} = (0, _useRangePosition.useRangePosition)(props, fieldType === 'single-input' ?
|
|
56
|
+
} = (0, _useRangePosition.useRangePosition)(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
|
|
56
57
|
const labelId = (0, _useId.default)();
|
|
57
58
|
const contextTranslations = (0, _hooks.usePickerTranslations)();
|
|
59
|
+
let fieldRef;
|
|
60
|
+
if (fieldType === 'single-input') {
|
|
61
|
+
fieldRef = singleInputFieldRef;
|
|
62
|
+
} else if (rangePosition === 'start') {
|
|
63
|
+
fieldRef = startFieldRef;
|
|
64
|
+
} else {
|
|
65
|
+
fieldRef = endFieldRef;
|
|
66
|
+
}
|
|
58
67
|
const {
|
|
59
68
|
open,
|
|
60
69
|
actions,
|
|
@@ -67,7 +76,7 @@ const useMobileRangePicker = _ref => {
|
|
|
67
76
|
props,
|
|
68
77
|
variant: 'mobile',
|
|
69
78
|
autoFocusView: true,
|
|
70
|
-
fieldRef
|
|
79
|
+
fieldRef,
|
|
71
80
|
localeText,
|
|
72
81
|
additionalViewProps: {
|
|
73
82
|
rangePosition,
|
|
@@ -118,7 +127,8 @@ const useMobileRangePicker = _ref => {
|
|
|
118
127
|
pickerSlotProps: innerSlotProps,
|
|
119
128
|
fieldProps,
|
|
120
129
|
startFieldRef,
|
|
121
|
-
endFieldRef
|
|
130
|
+
endFieldRef,
|
|
131
|
+
singleInputFieldRef
|
|
122
132
|
});
|
|
123
133
|
const slotPropsForLayout = (0, _extends2.default)({}, innerSlotProps, {
|
|
124
134
|
tabs: (0, _extends2.default)({}, innerSlotProps?.tabs, {
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getReleaseInfo = void 0;
|
|
7
7
|
var _utils = require("@mui/utils");
|
|
8
8
|
const getReleaseInfo = () => {
|
|
9
|
-
const releaseInfo = "
|
|
9
|
+
const releaseInfo = "MTczMjgzNDgwMDAwMA==";
|
|
10
10
|
if (process.env.NODE_ENV !== 'production') {
|
|
11
11
|
// A simple hack to set the value in the test environment (has no build step).
|
|
12
12
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -15,6 +15,14 @@ const _excluded = ["shouldDisableDate"];
|
|
|
15
15
|
* Validation props used by the Date Range Picker, Date Range Field and Date Range Calendar components.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Validation props as received by the validateDateRange method.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Name of the props that should be defaulted before being passed to the validateDateRange method.
|
|
24
|
+
*/
|
|
25
|
+
|
|
18
26
|
const validateDateRange = ({
|
|
19
27
|
adapter,
|
|
20
28
|
value,
|
|
@@ -15,6 +15,10 @@ const _excluded = ["shouldDisableDate"];
|
|
|
15
15
|
* Validation props used by the Date Time Range Picker and Date Time Range Field.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Validation props as received by the validateDateTimeRange method.
|
|
20
|
+
*/
|
|
21
|
+
|
|
18
22
|
const validateDateTimeRange = ({
|
|
19
23
|
adapter,
|
|
20
24
|
value,
|
|
@@ -11,6 +11,14 @@ var _valueManagers = require("../internals/utils/valueManagers");
|
|
|
11
11
|
* Validation props used by the Time Range Picker and Time Range Field.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Validation props as received by the validateTimeRange method.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Name of the props that should be defaulted before being passed to the validateTimeRange method.
|
|
20
|
+
*/
|
|
21
|
+
|
|
14
22
|
const validateTimeRange = ({
|
|
15
23
|
adapter,
|
|
16
24
|
value,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-date-pickers-pro",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.2",
|
|
4
4
|
"description": "The Pro plan edition of the Date and Time Picker components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"clsx": "^2.1.1",
|
|
38
38
|
"prop-types": "^15.8.1",
|
|
39
39
|
"react-transition-group": "^4.4.5",
|
|
40
|
-
"@mui/x-
|
|
41
|
-
"@mui/x-
|
|
42
|
-
"@mui/x-license": "8.0.0-alpha.
|
|
40
|
+
"@mui/x-date-pickers": "8.0.0-alpha.2",
|
|
41
|
+
"@mui/x-internals": "8.0.0-alpha.2",
|
|
42
|
+
"@mui/x-license": "8.0.0-alpha.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@emotion/react": "^11.9.0",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MakeRequired } from '@mui/x-internals/types';
|
|
1
2
|
import { Validator } from '@mui/x-date-pickers/validation';
|
|
2
3
|
import { BaseDateValidationProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
|
|
3
4
|
import { DayRangeValidationProps } from '../internals/models/dateRange';
|
|
@@ -7,6 +8,13 @@ import { DateRangeValidationError } from '../models';
|
|
|
7
8
|
*/
|
|
8
9
|
export interface ExportedValidateDateRangeProps extends DayRangeValidationProps, BaseDateValidationProps {
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Validation props as received by the validateDateRange method.
|
|
13
|
+
*/
|
|
14
|
+
export interface ValidateDateRangeProps extends MakeRequired<ExportedValidateDateRangeProps, ValidateDateRangePropsToDefault> {
|
|
11
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Name of the props that should be defaulted before being passed to the validateDateRange method.
|
|
18
|
+
*/
|
|
19
|
+
export type ValidateDateRangePropsToDefault = keyof BaseDateValidationProps;
|
|
12
20
|
export declare const validateDateRange: Validator<PickerRangeValue, DateRangeValidationError, ValidateDateRangeProps>;
|
|
@@ -9,6 +9,14 @@ import { rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
|
9
9
|
* Validation props used by the Date Range Picker, Date Range Field and Date Range Calendar components.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Validation props as received by the validateDateRange method.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Name of the props that should be defaulted before being passed to the validateDateRange method.
|
|
18
|
+
*/
|
|
19
|
+
|
|
12
20
|
export const validateDateRange = ({
|
|
13
21
|
adapter,
|
|
14
22
|
value,
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { DateTimeValidationProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
|
|
2
2
|
import { Validator } from '@mui/x-date-pickers/validation';
|
|
3
3
|
import { DateTimeRangeValidationError } from '../models';
|
|
4
|
-
import { ExportedValidateDateRangeProps, ValidateDateRangeProps } from './validateDateRange';
|
|
5
|
-
import { ExportedValidateTimeRangeProps, ValidateTimeRangeProps } from './validateTimeRange';
|
|
4
|
+
import { ExportedValidateDateRangeProps, ValidateDateRangeProps, ValidateDateRangePropsToDefault } from './validateDateRange';
|
|
5
|
+
import { ExportedValidateTimeRangeProps, ValidateTimeRangeProps, ValidateTimeRangePropsToDefault } from './validateTimeRange';
|
|
6
6
|
/**
|
|
7
7
|
* Validation props used by the Date Time Range Picker and Date Time Range Field.
|
|
8
8
|
*/
|
|
9
9
|
export interface ExportedValidateDateTimeRangeProps extends ExportedValidateDateRangeProps, ExportedValidateTimeRangeProps, DateTimeValidationProps {
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Validation props as received by the validateDateTimeRange method.
|
|
13
|
+
*/
|
|
11
14
|
export interface ValidateDateTimeRangeProps extends ValidateDateRangeProps, ValidateTimeRangeProps {
|
|
12
15
|
}
|
|
16
|
+
export type ValidateDateTimeRangePropsToDefault = ValidateDateRangePropsToDefault | ValidateTimeRangePropsToDefault;
|
|
13
17
|
export declare const validateDateTimeRange: Validator<PickerRangeValue, DateTimeRangeValidationError, ValidateDateTimeRangeProps>;
|
|
@@ -9,6 +9,10 @@ import { rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
|
9
9
|
* Validation props used by the Date Time Range Picker and Date Time Range Field.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Validation props as received by the validateDateTimeRange method.
|
|
14
|
+
*/
|
|
15
|
+
|
|
12
16
|
export const validateDateTimeRange = ({
|
|
13
17
|
adapter,
|
|
14
18
|
value,
|