@mui/x-date-pickers 7.0.0-alpha.7 → 7.0.0-alpha.8
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/AdapterDateFns/AdapterDateFns.d.ts +4 -21
- package/AdapterDateFns/AdapterDateFns.js +11 -255
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +62 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +291 -0
- package/AdapterDateFnsBase/index.d.ts +1 -0
- package/AdapterDateFnsBase/index.js +1 -0
- package/AdapterDateFnsBase/package.json +6 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +1 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +80 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
- package/AdapterDateFnsV3/index.d.ts +1 -0
- package/AdapterDateFnsV3/index.js +1 -0
- package/AdapterDateFnsV3/package.json +6 -0
- package/CHANGELOG.md +175 -49
- package/DatePicker/DatePickerToolbar.d.ts +2 -2
- package/DatePicker/DatePickerToolbar.js +2 -7
- package/DigitalClock/DigitalClock.js +1 -0
- package/DigitalClock/DigitalClock.types.d.ts +5 -0
- package/LocalizationProvider/LocalizationProvider.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +5 -0
- package/PickersSectionList/PickersSectionList.js +1 -1
- package/TimeClock/TimeClock.js +1 -0
- package/TimeClock/TimeClock.types.d.ts +5 -0
- package/hooks/useClearableField.js +3 -3
- package/index.js +1 -1
- package/internals/components/PickersInput/PickersInput.d.ts +2 -4
- package/internals/components/PickersInput/PickersInput.js +2 -3
- package/internals/hooks/useField/useField.utils.js +5 -5
- package/internals/hooks/usePicker/index.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/internals/hooks/useUtils.js +2 -2
- package/internals/hooks/useViews.js +2 -2
- package/internals/index.d.ts +9 -3
- package/internals/index.js +6 -2
- package/internals/models/common.d.ts +1 -1
- package/internals/models/helpers.d.ts +1 -0
- package/internals/utils/views.js +1 -1
- package/legacy/AdapterDateFns/AdapterDateFns.js +222 -458
- package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +293 -0
- package/legacy/AdapterDateFnsBase/index.js +1 -0
- package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +306 -0
- package/legacy/AdapterDateFnsV3/index.js +1 -0
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +5 -6
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +5 -6
- package/legacy/DatePicker/DatePickerToolbar.js +2 -7
- package/legacy/DigitalClock/DigitalClock.js +1 -0
- package/legacy/LocalizationProvider/LocalizationProvider.js +1 -1
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/legacy/PickersSectionList/PickersSectionList.js +1 -1
- package/legacy/TimeClock/TimeClock.js +1 -0
- package/legacy/hooks/useClearableField.js +3 -3
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersInput/PickersInput.js +2 -3
- package/legacy/internals/hooks/useField/useField.utils.js +5 -5
- package/legacy/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/legacy/internals/hooks/useUtils.js +2 -2
- package/legacy/internals/hooks/useViews.js +2 -2
- package/legacy/internals/index.js +6 -2
- package/legacy/internals/utils/views.js +1 -1
- package/legacy/locales/index.js +1 -0
- package/locales/enUS.d.ts +1 -1
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/mk.d.ts +1 -1
- package/locales/utils/getPickersLocalization.d.ts +1 -1
- package/modern/AdapterDateFns/AdapterDateFns.js +11 -254
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +290 -0
- package/modern/AdapterDateFnsBase/index.js +1 -0
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
- package/modern/AdapterDateFnsV3/index.js +1 -0
- package/modern/DatePicker/DatePickerToolbar.js +2 -7
- package/modern/DigitalClock/DigitalClock.js +1 -0
- package/modern/LocalizationProvider/LocalizationProvider.js +1 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/modern/PickersSectionList/PickersSectionList.js +1 -1
- package/modern/TimeClock/TimeClock.js +1 -0
- package/modern/hooks/useClearableField.js +3 -3
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersInput/PickersInput.js +2 -3
- package/modern/internals/hooks/useField/useField.utils.js +5 -5
- package/modern/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/modern/internals/hooks/useUtils.js +2 -2
- package/modern/internals/hooks/useViews.js +2 -2
- package/modern/internals/index.js +6 -2
- package/modern/internals/utils/views.js +1 -1
- package/modern/locales/index.js +1 -0
- package/node/AdapterDateFns/AdapterDateFns.js +11 -254
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +298 -0
- package/node/AdapterDateFnsBase/index.js +12 -0
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +295 -0
- package/node/AdapterDateFnsV3/index.js +12 -0
- package/node/DatePicker/DatePickerToolbar.js +0 -4
- package/node/DigitalClock/DigitalClock.js +1 -0
- package/node/LocalizationProvider/LocalizationProvider.js +1 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/node/PickersSectionList/PickersSectionList.js +1 -1
- package/node/TimeClock/TimeClock.js +1 -0
- package/node/hooks/useClearableField.js +3 -3
- package/node/index.js +1 -1
- package/node/internals/components/PickersInput/PickersInput.js +2 -3
- package/node/internals/hooks/useField/useField.utils.js +5 -5
- package/node/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/node/internals/hooks/useUtils.js +2 -2
- package/node/internals/hooks/useViews.js +2 -2
- package/node/internals/index.js +47 -1
- package/node/internals/utils/views.js +1 -1
- package/node/locales/index.js +11 -0
- package/package.json +2 -2
|
@@ -26,10 +26,6 @@ var DatePickerToolbarRoot = styled(PickersToolbar, {
|
|
|
26
26
|
return styles.root;
|
|
27
27
|
}
|
|
28
28
|
})({});
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @ignore - do not document.
|
|
32
|
-
*/
|
|
33
29
|
var DatePickerToolbarTitle = styled(Typography, {
|
|
34
30
|
name: 'MuiDatePickerToolbar',
|
|
35
31
|
slot: 'Title',
|
|
@@ -52,7 +48,7 @@ var DatePickerToolbarTitle = styled(Typography, {
|
|
|
52
48
|
*
|
|
53
49
|
* - [DatePickerToolbar API](https://mui.com/x/api/date-pickers/date-picker-toolbar/)
|
|
54
50
|
*/
|
|
55
|
-
var DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePickerToolbar(inProps, ref) {
|
|
51
|
+
export var DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePickerToolbar(inProps, ref) {
|
|
56
52
|
var props = useThemeProps({
|
|
57
53
|
props: inProps,
|
|
58
54
|
name: 'MuiDatePickerToolbar'
|
|
@@ -136,5 +132,4 @@ process.env.NODE_ENV !== "production" ? DatePickerToolbar.propTypes = {
|
|
|
136
132
|
*/
|
|
137
133
|
view: PropTypes.oneOf(['day', 'month', 'year']).isRequired,
|
|
138
134
|
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'month', 'year']).isRequired).isRequired
|
|
139
|
-
} : void 0;
|
|
140
|
-
export { DatePickerToolbar };
|
|
135
|
+
} : void 0;
|
|
@@ -59,7 +59,7 @@ export var LocalizationProvider = function LocalizationProvider(inProps) {
|
|
|
59
59
|
instance: dateLibInstance
|
|
60
60
|
});
|
|
61
61
|
if (!adapter.isMUIAdapter) {
|
|
62
|
-
throw new Error(['MUI: The date adapter should be imported from `@mui/x-date-pickers` or `@mui/x-date-pickers-pro`, not from `@date-io`', "For example, `import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'` instead of `import AdapterDayjs from '@date-io/dayjs'`", 'More information on the installation documentation: https://mui.com/x/react-date-pickers/getting-started/#installation'].join("\n"));
|
|
62
|
+
throw new Error(['MUI X: The date adapter should be imported from `@mui/x-date-pickers` or `@mui/x-date-pickers-pro`, not from `@date-io`', "For example, `import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'` instead of `import AdapterDayjs from '@date-io/dayjs'`", 'More information on the installation documentation: https://mui.com/x/react-date-pickers/getting-started/#installation'].join("\n"));
|
|
63
63
|
}
|
|
64
64
|
return adapter;
|
|
65
65
|
}, [DateAdapter, adapterLocale, dateFormats, dateLibInstance, parentUtils]);
|
|
@@ -515,6 +515,7 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
515
515
|
view: PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']),
|
|
516
516
|
/**
|
|
517
517
|
* Available views.
|
|
518
|
+
* @default ['hours', 'minutes']
|
|
518
519
|
*/
|
|
519
520
|
views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']).isRequired)
|
|
520
521
|
} : void 0;
|
|
@@ -121,7 +121,7 @@ var PickersSectionList = /*#__PURE__*/React.forwardRef(function PickersSectionLi
|
|
|
121
121
|
var handleRootRef = useForkRef(ref, rootRef);
|
|
122
122
|
var _getRoot = function getRoot(methodName) {
|
|
123
123
|
if (!rootRef.current) {
|
|
124
|
-
throw new Error("MUI: Cannot call sectionListRef.".concat(methodName, " before the mount of the component"));
|
|
124
|
+
throw new Error("MUI X: Cannot call sectionListRef.".concat(methodName, " before the mount of the component."));
|
|
125
125
|
}
|
|
126
126
|
return rootRef.current;
|
|
127
127
|
};
|
|
@@ -475,6 +475,7 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
|
|
|
475
475
|
view: PropTypes.oneOf(['hours', 'minutes', 'seconds']),
|
|
476
476
|
/**
|
|
477
477
|
* Available views.
|
|
478
|
+
* @default ['hours', 'minutes']
|
|
478
479
|
*/
|
|
479
480
|
views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'minutes', 'seconds']).isRequired)
|
|
480
481
|
} : void 0;
|
|
@@ -42,8 +42,8 @@ export var useClearableField = function useClearableField(props) {
|
|
|
42
42
|
});
|
|
43
43
|
return _extends({}, other, {
|
|
44
44
|
InputProps: _extends({}, InputProps, {
|
|
45
|
-
endAdornment:
|
|
46
|
-
children: [/*#__PURE__*/_jsx(InputAdornment, {
|
|
45
|
+
endAdornment: /*#__PURE__*/_jsxs(React.Fragment, {
|
|
46
|
+
children: [clearable && /*#__PURE__*/_jsx(InputAdornment, {
|
|
47
47
|
position: "end",
|
|
48
48
|
sx: {
|
|
49
49
|
marginRight: InputProps != null && InputProps.endAdornment ? -1 : -1.5
|
|
@@ -55,7 +55,7 @@ export var useClearableField = function useClearableField(props) {
|
|
|
55
55
|
}, endClearIconProps))
|
|
56
56
|
}))
|
|
57
57
|
}), InputProps == null ? void 0 : InputProps.endAdornment]
|
|
58
|
-
})
|
|
58
|
+
})
|
|
59
59
|
}),
|
|
60
60
|
sx: [{
|
|
61
61
|
'& .clearButton': {
|
package/legacy/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
var _excluded = ["elements", "areAllSectionsEmpty", "defaultValue", "label", "value", "onChange", "id", "autoFocus", "endAdornment", "startAdornment", "renderSuffix", "slots", "contentEditable", "tabIndex", "onInput", "onPaste", "onKeyDown", "fullWidth", "inputProps", "inputRef", "sectionListRef"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import Box from '@mui/material/Box';
|
|
6
5
|
import { useFormControl } from '@mui/material/FormControl';
|
|
7
6
|
import { styled } from '@mui/material/styles';
|
|
8
7
|
import useForkRef from '@mui/utils/useForkRef';
|
|
@@ -16,7 +15,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
16
15
|
var round = function round(value) {
|
|
17
16
|
return Math.round(value * 1e5) / 1e5;
|
|
18
17
|
};
|
|
19
|
-
export var PickersInputRoot = styled(
|
|
18
|
+
export var PickersInputRoot = styled('div', {
|
|
20
19
|
name: 'MuiPickersInput',
|
|
21
20
|
slot: 'Root',
|
|
22
21
|
overridesResolver: function overridesResolver(props, styles) {
|
|
@@ -180,7 +179,7 @@ export var PickersInput = /*#__PURE__*/React.forwardRef(function PickersInput(pr
|
|
|
180
179
|
var handleInputRef = useForkRef(inputProps == null ? void 0 : inputProps.ref, inputRef);
|
|
181
180
|
var muiFormControl = useFormControl();
|
|
182
181
|
if (!muiFormControl) {
|
|
183
|
-
throw new Error('MUI: PickersInput should always be used inside a PickersTextField component');
|
|
182
|
+
throw new Error('MUI X: PickersInput should always be used inside a PickersTextField component');
|
|
184
183
|
}
|
|
185
184
|
var handleInputFocus = function handleInputFocus(event) {
|
|
186
185
|
var _muiFormControl$onFoc;
|
|
@@ -4,7 +4,7 @@ import { getMonthsInYear } from '../../utils/date-utils';
|
|
|
4
4
|
export var getDateSectionConfigFromFormatToken = function getDateSectionConfigFromFormatToken(utils, formatToken) {
|
|
5
5
|
var config = utils.formatTokenMap[formatToken];
|
|
6
6
|
if (config == null) {
|
|
7
|
-
throw new Error(["MUI: The token \"".concat(formatToken, "\" is not supported by the Date and Time Pickers."), 'Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported.'].join('\n'));
|
|
7
|
+
throw new Error(["MUI X: The token \"".concat(formatToken, "\" is not supported by the Date and Time Pickers."), 'Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported.'].join('\n'));
|
|
8
8
|
}
|
|
9
9
|
if (typeof config === 'string') {
|
|
10
10
|
return {
|
|
@@ -87,7 +87,7 @@ export var cleanLeadingZeros = function cleanLeadingZeros(utils, valueStr, size)
|
|
|
87
87
|
export var cleanDigitSectionValue = function cleanDigitSectionValue(utils, timezone, value, sectionBoundaries, section) {
|
|
88
88
|
if (process.env.NODE_ENV !== 'production') {
|
|
89
89
|
if (section.type !== 'day' && section.contentType === 'digit-with-letter') {
|
|
90
|
-
throw new Error(["MUI: The token \"".concat(section.format, "\" is a digit format with letter in it.'\n This type of format is only supported for 'day' sections")].join('\n'));
|
|
90
|
+
throw new Error(["MUI X: The token \"".concat(section.format, "\" is a digit format with letter in it.'\n This type of format is only supported for 'day' sections")].join('\n'));
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
if (section.type === 'day' && section.contentType === 'digit-with-letter') {
|
|
@@ -367,7 +367,7 @@ export var splitFormatIntoSections = function splitFormatIntoSections(utils, tim
|
|
|
367
367
|
maxLength = sectionValue === '' ? utils.formatByString(now, token).length : sectionValue.length;
|
|
368
368
|
} else {
|
|
369
369
|
if (sectionConfig.maxLength == null) {
|
|
370
|
-
throw new Error("MUI: The token ".concat(token, " should have a 'maxDigitNumber' property on it's adapter"));
|
|
370
|
+
throw new Error("MUI X: The token ".concat(token, " should have a 'maxDigitNumber' property on it's adapter"));
|
|
371
371
|
}
|
|
372
372
|
maxLength = sectionConfig.maxLength;
|
|
373
373
|
if (isValidDate) {
|
|
@@ -398,7 +398,7 @@ export var splitFormatIntoSections = function splitFormatIntoSections(utils, tim
|
|
|
398
398
|
nextFormat = utils.expandFormat(prevFormat);
|
|
399
399
|
formatExpansionOverflow -= 1;
|
|
400
400
|
if (formatExpansionOverflow < 0) {
|
|
401
|
-
throw new Error('MUI: The format expansion seems to be enter in an infinite loop. Please open an issue with the format passed to the picker component');
|
|
401
|
+
throw new Error('MUI X: The format expansion seems to be enter in an infinite loop. Please open an issue with the format passed to the picker component.');
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
var expandedFormat = nextFormat;
|
|
@@ -633,7 +633,7 @@ export var validateSections = function validateSections(sections, valueType) {
|
|
|
633
633
|
return !supportedSections.includes(section.type);
|
|
634
634
|
});
|
|
635
635
|
if (invalidSection) {
|
|
636
|
-
console.warn("MUI: The field component you are using is not compatible with the \"".concat(invalidSection.type, "\" date section."), "The supported date sections are [\"".concat(supportedSections.join('", "'), "\"]`."));
|
|
636
|
+
console.warn("MUI X: The field component you are using is not compatible with the \"".concat(invalidSection.type, "\" date section."), "The supported date sections are [\"".concat(supportedSections.join('", "'), "\"]`."));
|
|
637
637
|
warnedOnceInvalidSection = true;
|
|
638
638
|
}
|
|
639
639
|
}
|
|
@@ -129,12 +129,12 @@ export var usePickerValue = function usePickerValue(_ref) {
|
|
|
129
129
|
if (process.env.NODE_ENV !== 'production') {
|
|
130
130
|
React.useEffect(function () {
|
|
131
131
|
if (isControlled !== (inValue !== undefined)) {
|
|
132
|
-
console.error(["MUI: A component is changing the ".concat(isControlled ? '' : 'un', "controlled value of a picker to be ").concat(isControlled ? 'un' : '', "controlled."), 'Elements should not switch from uncontrolled to controlled (or vice versa).', "Decide between using a controlled or uncontrolled value" + 'for the lifetime of the component.', "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", 'More info: https://fb.me/react-controlled-components'].join('\n'));
|
|
132
|
+
console.error(["MUI X: A component is changing the ".concat(isControlled ? '' : 'un', "controlled value of a picker to be ").concat(isControlled ? 'un' : '', "controlled."), 'Elements should not switch from uncontrolled to controlled (or vice versa).', "Decide between using a controlled or uncontrolled value" + 'for the lifetime of the component.', "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", 'More info: https://fb.me/react-controlled-components'].join('\n'));
|
|
133
133
|
}
|
|
134
134
|
}, [inValue]);
|
|
135
135
|
React.useEffect(function () {
|
|
136
136
|
if (!isControlled && defaultValue !== inDefaultValue) {
|
|
137
|
-
console.error(["MUI: A component is changing the defaultValue of an uncontrolled picker after being initialized. " + "To suppress this warning opt to use a controlled value."].join('\n'));
|
|
137
|
+
console.error(["MUI X: A component is changing the defaultValue of an uncontrolled picker after being initialized. " + "To suppress this warning opt to use a controlled value."].join('\n'));
|
|
138
138
|
}
|
|
139
139
|
}, [JSON.stringify(defaultValue)]);
|
|
140
140
|
}
|
|
@@ -5,10 +5,10 @@ import { DEFAULT_LOCALE } from '../../locales/enUS';
|
|
|
5
5
|
export var useLocalizationContext = function useLocalizationContext() {
|
|
6
6
|
var localization = React.useContext(MuiPickersAdapterContext);
|
|
7
7
|
if (localization === null) {
|
|
8
|
-
throw new Error(['MUI: Can not find the date and time pickers localization context.', 'It looks like you forgot to wrap your component in LocalizationProvider.', 'This can also happen if you are bundling multiple versions of the `@mui/x-date-pickers` package'].join('\n'));
|
|
8
|
+
throw new Error(['MUI X: Can not find the date and time pickers localization context.', 'It looks like you forgot to wrap your component in LocalizationProvider.', 'This can also happen if you are bundling multiple versions of the `@mui/x-date-pickers` package'].join('\n'));
|
|
9
9
|
}
|
|
10
10
|
if (localization.utils === null) {
|
|
11
|
-
throw new Error(['MUI: Can not find the date and time pickers adapter from its localization context.', 'It looks like you forgot to pass a `dateAdapter` to your LocalizationProvider.'].join('\n'));
|
|
11
|
+
throw new Error(['MUI X: Can not find the date and time pickers adapter from its localization context.', 'It looks like you forgot to pass a `dateAdapter` to your LocalizationProvider.'].join('\n'));
|
|
12
12
|
}
|
|
13
13
|
var localeText = React.useMemo(function () {
|
|
14
14
|
return _extends({}, DEFAULT_LOCALE, localization.localeText);
|
|
@@ -16,11 +16,11 @@ export function useViews(_ref) {
|
|
|
16
16
|
if (process.env.NODE_ENV !== 'production') {
|
|
17
17
|
if (!warnedOnceNotValidView) {
|
|
18
18
|
if (inView != null && !views.includes(inView)) {
|
|
19
|
-
console.warn("MUI: `view=\"".concat(inView, "\"` is not a valid prop."), "It must be an element of `views=[\"".concat(views.join('", "'), "\"]`."));
|
|
19
|
+
console.warn("MUI X: `view=\"".concat(inView, "\"` is not a valid prop."), "It must be an element of `views=[\"".concat(views.join('", "'), "\"]`."));
|
|
20
20
|
warnedOnceNotValidView = true;
|
|
21
21
|
}
|
|
22
22
|
if (inView == null && openTo != null && !views.includes(openTo)) {
|
|
23
|
-
console.warn("MUI: `openTo=\"".concat(openTo, "\"` is not a valid prop."), "It must be an element of `views=[\"".concat(views.join('", "'), "\"]`."));
|
|
23
|
+
console.warn("MUI X: `openTo=\"".concat(openTo, "\"` is not a valid prop."), "It must be an element of `views=[\"".concat(views.join('", "'), "\"]`."));
|
|
24
24
|
warnedOnceNotValidView = true;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -14,10 +14,12 @@ export { useField, createDateStrForInputFromSections, addPositionPropertiesToSec
|
|
|
14
14
|
export { usePicker } from './hooks/usePicker';
|
|
15
15
|
export { useStaticPicker } from './hooks/useStaticPicker';
|
|
16
16
|
export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText, useNow } from './hooks/useUtils';
|
|
17
|
+
export { useViews } from './hooks/useViews';
|
|
17
18
|
export { useValidation } from './hooks/useValidation';
|
|
18
19
|
export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
|
|
19
20
|
export { convertFieldResponseIntoMuiTextFieldProps } from './utils/convertFieldResponseIntoMuiTextFieldProps';
|
|
20
|
-
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate } from './utils/date-utils';
|
|
21
|
+
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate, isDatePickerView, mergeDateAndTime, formatMeridiem } from './utils/date-utils';
|
|
22
|
+
export { resolveTimeViewsResponse } from './utils/date-time-utils';
|
|
21
23
|
export { splitFieldInternalAndForwardedProps } from './utils/fields';
|
|
22
24
|
export { getDefaultReferenceDate } from './utils/getDefaultReferenceDate';
|
|
23
25
|
export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './utils/utils';
|
|
@@ -26,6 +28,8 @@ export { extractValidationProps } from './utils/validation/extractValidationProp
|
|
|
26
28
|
export { validateDate } from './utils/validation/validateDate';
|
|
27
29
|
export { validateDateTime } from './utils/validation/validateDateTime';
|
|
28
30
|
export { validateTime } from './utils/validation/validateTime';
|
|
31
|
+
export { applyDefaultViewProps } from './utils/views';
|
|
29
32
|
export { buildDeprecatedPropsWarning, buildWarning } from './utils/warning';
|
|
30
33
|
export { DayCalendar } from '../DateCalendar/DayCalendar';
|
|
31
|
-
export { useCalendarState } from '../DateCalendar/useCalendarState';
|
|
34
|
+
export { useCalendarState } from '../DateCalendar/useCalendarState';
|
|
35
|
+
export { isTimeView } from './utils/time-utils';
|
|
@@ -20,7 +20,7 @@ export var applyDefaultViewProps = function applyDefaultViewProps(_ref) {
|
|
|
20
20
|
} else if (viewsWithDefault.length > 0) {
|
|
21
21
|
openToWithDefault = viewsWithDefault[0];
|
|
22
22
|
} else {
|
|
23
|
-
throw new Error('MUI: The `views` prop must contain at least one view');
|
|
23
|
+
throw new Error('MUI X: The `views` prop must contain at least one view.');
|
|
24
24
|
}
|
|
25
25
|
return {
|
|
26
26
|
views: viewsWithDefault,
|
package/legacy/locales/index.js
CHANGED
package/locales/enUS.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare const enUS: {
|
|
|
24
24
|
hoursClockNumberText?: ((hours: string) => string) | undefined;
|
|
25
25
|
minutesClockNumberText?: ((minutes: string) => string) | undefined;
|
|
26
26
|
secondsClockNumberText?: ((seconds: string) => string) | undefined;
|
|
27
|
-
selectViewText?: ((view: import("../internals
|
|
27
|
+
selectViewText?: ((view: import("../internals").TimeViewWithMeridiem) => string) | undefined;
|
|
28
28
|
openDatePickerDialogue?: ((date: any, utils: import("..").MuiPickersAdapter<any, any>) => string) | undefined;
|
|
29
29
|
openTimePickerDialogue?: ((date: any, utils: import("..").MuiPickersAdapter<any, any>) => string) | undefined;
|
|
30
30
|
fieldClearLabel?: string | undefined;
|
package/locales/index.d.ts
CHANGED
package/locales/index.js
CHANGED
package/locales/mk.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare const mk: {
|
|
|
22
22
|
hoursClockNumberText?: ((hours: string) => string) | undefined;
|
|
23
23
|
minutesClockNumberText?: ((minutes: string) => string) | undefined;
|
|
24
24
|
secondsClockNumberText?: ((seconds: string) => string) | undefined;
|
|
25
|
-
selectViewText?: ((view: import("../internals
|
|
25
|
+
selectViewText?: ((view: import("../internals").TimeViewWithMeridiem) => string) | undefined;
|
|
26
26
|
openDatePickerDialogue?: ((date: any, utils: import("..").MuiPickersAdapter<any, any>) => string) | undefined;
|
|
27
27
|
openTimePickerDialogue?: ((date: any, utils: import("..").MuiPickersAdapter<any, any>) => string) | undefined;
|
|
28
28
|
fieldClearLabel?: string | undefined;
|
|
@@ -23,7 +23,7 @@ export declare const getPickersLocalization: (pickersTranslations: Partial<Picke
|
|
|
23
23
|
hoursClockNumberText?: ((hours: string) => string) | undefined;
|
|
24
24
|
minutesClockNumberText?: ((minutes: string) => string) | undefined;
|
|
25
25
|
secondsClockNumberText?: ((seconds: string) => string) | undefined;
|
|
26
|
-
selectViewText?: ((view: import("../../internals
|
|
26
|
+
selectViewText?: ((view: import("../../internals").TimeViewWithMeridiem) => string) | undefined;
|
|
27
27
|
openDatePickerDialogue?: ((date: any, utils: import("../..").MuiPickersAdapter<any, any>) => string) | undefined;
|
|
28
28
|
openTimePickerDialogue?: ((date: any, utils: import("../..").MuiPickersAdapter<any, any>) => string) | undefined;
|
|
29
29
|
fieldClearLabel?: string | undefined;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
/* eslint-disable class-methods-use-this */
|
|
3
2
|
import addDays from 'date-fns/addDays';
|
|
4
3
|
import addSeconds from 'date-fns/addSeconds';
|
|
@@ -45,196 +44,7 @@ import isWithinInterval from 'date-fns/isWithinInterval';
|
|
|
45
44
|
import defaultLocale from 'date-fns/locale/en-US';
|
|
46
45
|
// @ts-ignore
|
|
47
46
|
import longFormatters from 'date-fns/_lib/format/longFormatters';
|
|
48
|
-
|
|
49
|
-
// Year
|
|
50
|
-
y: {
|
|
51
|
-
sectionType: 'year',
|
|
52
|
-
contentType: 'digit',
|
|
53
|
-
maxLength: 4
|
|
54
|
-
},
|
|
55
|
-
yy: 'year',
|
|
56
|
-
yyy: {
|
|
57
|
-
sectionType: 'year',
|
|
58
|
-
contentType: 'digit',
|
|
59
|
-
maxLength: 4
|
|
60
|
-
},
|
|
61
|
-
yyyy: 'year',
|
|
62
|
-
// Month
|
|
63
|
-
M: {
|
|
64
|
-
sectionType: 'month',
|
|
65
|
-
contentType: 'digit',
|
|
66
|
-
maxLength: 2
|
|
67
|
-
},
|
|
68
|
-
MM: 'month',
|
|
69
|
-
MMMM: {
|
|
70
|
-
sectionType: 'month',
|
|
71
|
-
contentType: 'letter'
|
|
72
|
-
},
|
|
73
|
-
MMM: {
|
|
74
|
-
sectionType: 'month',
|
|
75
|
-
contentType: 'letter'
|
|
76
|
-
},
|
|
77
|
-
L: {
|
|
78
|
-
sectionType: 'month',
|
|
79
|
-
contentType: 'digit',
|
|
80
|
-
maxLength: 2
|
|
81
|
-
},
|
|
82
|
-
LL: 'month',
|
|
83
|
-
LLL: {
|
|
84
|
-
sectionType: 'month',
|
|
85
|
-
contentType: 'letter'
|
|
86
|
-
},
|
|
87
|
-
LLLL: {
|
|
88
|
-
sectionType: 'month',
|
|
89
|
-
contentType: 'letter'
|
|
90
|
-
},
|
|
91
|
-
// Day of the month
|
|
92
|
-
d: {
|
|
93
|
-
sectionType: 'day',
|
|
94
|
-
contentType: 'digit',
|
|
95
|
-
maxLength: 2
|
|
96
|
-
},
|
|
97
|
-
dd: 'day',
|
|
98
|
-
do: {
|
|
99
|
-
sectionType: 'day',
|
|
100
|
-
contentType: 'digit-with-letter'
|
|
101
|
-
},
|
|
102
|
-
// Day of the week
|
|
103
|
-
E: {
|
|
104
|
-
sectionType: 'weekDay',
|
|
105
|
-
contentType: 'letter'
|
|
106
|
-
},
|
|
107
|
-
EE: {
|
|
108
|
-
sectionType: 'weekDay',
|
|
109
|
-
contentType: 'letter'
|
|
110
|
-
},
|
|
111
|
-
EEE: {
|
|
112
|
-
sectionType: 'weekDay',
|
|
113
|
-
contentType: 'letter'
|
|
114
|
-
},
|
|
115
|
-
EEEE: {
|
|
116
|
-
sectionType: 'weekDay',
|
|
117
|
-
contentType: 'letter'
|
|
118
|
-
},
|
|
119
|
-
EEEEE: {
|
|
120
|
-
sectionType: 'weekDay',
|
|
121
|
-
contentType: 'letter'
|
|
122
|
-
},
|
|
123
|
-
i: {
|
|
124
|
-
sectionType: 'weekDay',
|
|
125
|
-
contentType: 'digit',
|
|
126
|
-
maxLength: 1
|
|
127
|
-
},
|
|
128
|
-
ii: 'weekDay',
|
|
129
|
-
iii: {
|
|
130
|
-
sectionType: 'weekDay',
|
|
131
|
-
contentType: 'letter'
|
|
132
|
-
},
|
|
133
|
-
iiii: {
|
|
134
|
-
sectionType: 'weekDay',
|
|
135
|
-
contentType: 'letter'
|
|
136
|
-
},
|
|
137
|
-
e: {
|
|
138
|
-
sectionType: 'weekDay',
|
|
139
|
-
contentType: 'digit',
|
|
140
|
-
maxLength: 1
|
|
141
|
-
},
|
|
142
|
-
ee: 'weekDay',
|
|
143
|
-
eee: {
|
|
144
|
-
sectionType: 'weekDay',
|
|
145
|
-
contentType: 'letter'
|
|
146
|
-
},
|
|
147
|
-
eeee: {
|
|
148
|
-
sectionType: 'weekDay',
|
|
149
|
-
contentType: 'letter'
|
|
150
|
-
},
|
|
151
|
-
eeeee: {
|
|
152
|
-
sectionType: 'weekDay',
|
|
153
|
-
contentType: 'letter'
|
|
154
|
-
},
|
|
155
|
-
eeeeee: {
|
|
156
|
-
sectionType: 'weekDay',
|
|
157
|
-
contentType: 'letter'
|
|
158
|
-
},
|
|
159
|
-
c: {
|
|
160
|
-
sectionType: 'weekDay',
|
|
161
|
-
contentType: 'digit',
|
|
162
|
-
maxLength: 1
|
|
163
|
-
},
|
|
164
|
-
cc: 'weekDay',
|
|
165
|
-
ccc: {
|
|
166
|
-
sectionType: 'weekDay',
|
|
167
|
-
contentType: 'letter'
|
|
168
|
-
},
|
|
169
|
-
cccc: {
|
|
170
|
-
sectionType: 'weekDay',
|
|
171
|
-
contentType: 'letter'
|
|
172
|
-
},
|
|
173
|
-
ccccc: {
|
|
174
|
-
sectionType: 'weekDay',
|
|
175
|
-
contentType: 'letter'
|
|
176
|
-
},
|
|
177
|
-
cccccc: {
|
|
178
|
-
sectionType: 'weekDay',
|
|
179
|
-
contentType: 'letter'
|
|
180
|
-
},
|
|
181
|
-
// Meridiem
|
|
182
|
-
a: 'meridiem',
|
|
183
|
-
aa: 'meridiem',
|
|
184
|
-
aaa: 'meridiem',
|
|
185
|
-
// Hours
|
|
186
|
-
H: {
|
|
187
|
-
sectionType: 'hours',
|
|
188
|
-
contentType: 'digit',
|
|
189
|
-
maxLength: 2
|
|
190
|
-
},
|
|
191
|
-
HH: 'hours',
|
|
192
|
-
h: {
|
|
193
|
-
sectionType: 'hours',
|
|
194
|
-
contentType: 'digit',
|
|
195
|
-
maxLength: 2
|
|
196
|
-
},
|
|
197
|
-
hh: 'hours',
|
|
198
|
-
// Minutes
|
|
199
|
-
m: {
|
|
200
|
-
sectionType: 'minutes',
|
|
201
|
-
contentType: 'digit',
|
|
202
|
-
maxLength: 2
|
|
203
|
-
},
|
|
204
|
-
mm: 'minutes',
|
|
205
|
-
// Seconds
|
|
206
|
-
s: {
|
|
207
|
-
sectionType: 'seconds',
|
|
208
|
-
contentType: 'digit',
|
|
209
|
-
maxLength: 2
|
|
210
|
-
},
|
|
211
|
-
ss: 'seconds'
|
|
212
|
-
};
|
|
213
|
-
const defaultFormats = {
|
|
214
|
-
year: 'yyyy',
|
|
215
|
-
month: 'LLLL',
|
|
216
|
-
monthShort: 'MMM',
|
|
217
|
-
dayOfMonth: 'd',
|
|
218
|
-
weekday: 'EEEE',
|
|
219
|
-
weekdayShort: 'EEEEEE',
|
|
220
|
-
hours24h: 'HH',
|
|
221
|
-
hours12h: 'hh',
|
|
222
|
-
meridiem: 'aa',
|
|
223
|
-
minutes: 'mm',
|
|
224
|
-
seconds: 'ss',
|
|
225
|
-
fullDate: 'PP',
|
|
226
|
-
keyboardDate: 'P',
|
|
227
|
-
shortDate: 'MMM d',
|
|
228
|
-
normalDate: 'd MMMM',
|
|
229
|
-
normalDateWithWeekday: 'EEE, MMM d',
|
|
230
|
-
fullTime: 'p',
|
|
231
|
-
fullTime12h: 'hh:mm aa',
|
|
232
|
-
fullTime24h: 'HH:mm',
|
|
233
|
-
keyboardDateTime: 'P p',
|
|
234
|
-
keyboardDateTime12h: 'P hh:mm aa',
|
|
235
|
-
keyboardDateTime24h: 'P HH:mm'
|
|
236
|
-
};
|
|
237
|
-
|
|
47
|
+
import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
|
|
238
48
|
/**
|
|
239
49
|
* Based on `@date-io/date-fns`
|
|
240
50
|
*
|
|
@@ -260,40 +70,19 @@ const defaultFormats = {
|
|
|
260
70
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
261
71
|
* SOFTWARE.
|
|
262
72
|
*/
|
|
263
|
-
export class AdapterDateFns {
|
|
73
|
+
export class AdapterDateFns extends AdapterDateFnsBase {
|
|
264
74
|
constructor({
|
|
265
|
-
locale
|
|
75
|
+
locale,
|
|
266
76
|
formats
|
|
267
77
|
} = {}) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
end: "'"
|
|
277
|
-
};
|
|
278
|
-
this.date = value => {
|
|
279
|
-
if (typeof value === 'undefined') {
|
|
280
|
-
return new Date();
|
|
281
|
-
}
|
|
282
|
-
if (value === null) {
|
|
283
|
-
return null;
|
|
284
|
-
}
|
|
285
|
-
return new Date(value);
|
|
286
|
-
};
|
|
287
|
-
this.getInvalidDate = () => new Date('Invalid Date');
|
|
288
|
-
this.getTimezone = () => {
|
|
289
|
-
return 'default';
|
|
290
|
-
};
|
|
291
|
-
this.setTimezone = value => {
|
|
292
|
-
return value;
|
|
293
|
-
};
|
|
294
|
-
this.toJsDate = value => {
|
|
295
|
-
return value;
|
|
296
|
-
};
|
|
78
|
+
if (typeof addDays !== 'function') {
|
|
79
|
+
throw new Error(['MUI: The `date-fns` package v3.x is not compatible with this adapter.', 'Please, install v2.x of the package or use the `AdapterDateFnsV3` instead.'].join('\n'));
|
|
80
|
+
}
|
|
81
|
+
super({
|
|
82
|
+
locale: locale ?? defaultLocale,
|
|
83
|
+
formats,
|
|
84
|
+
longFormatters
|
|
85
|
+
});
|
|
297
86
|
this.parse = (value, format) => {
|
|
298
87
|
if (value === '') {
|
|
299
88
|
return null;
|
|
@@ -302,33 +91,6 @@ export class AdapterDateFns {
|
|
|
302
91
|
locale: this.locale
|
|
303
92
|
});
|
|
304
93
|
};
|
|
305
|
-
this.getCurrentLocaleCode = () => {
|
|
306
|
-
return this.locale?.code || 'en-US';
|
|
307
|
-
};
|
|
308
|
-
// Note: date-fns input types are more lenient than this adapter, so we need to expose our more
|
|
309
|
-
// strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
|
|
310
|
-
this.is12HourCycleInCurrentLocale = () => {
|
|
311
|
-
if (this.locale) {
|
|
312
|
-
return /a/.test(this.locale.formatLong.time());
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// By default, date-fns is using en-US locale with am/pm enabled
|
|
316
|
-
return true;
|
|
317
|
-
};
|
|
318
|
-
this.expandFormat = format => {
|
|
319
|
-
const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
|
|
320
|
-
|
|
321
|
-
// @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
|
|
322
|
-
return format.match(longFormatRegexp).map(token => {
|
|
323
|
-
const firstCharacter = token[0];
|
|
324
|
-
if (firstCharacter === 'p' || firstCharacter === 'P') {
|
|
325
|
-
const longFormatter = longFormatters[firstCharacter];
|
|
326
|
-
const locale = this.locale || defaultLocale;
|
|
327
|
-
return longFormatter(token, locale.formatLong, {});
|
|
328
|
-
}
|
|
329
|
-
return token;
|
|
330
|
-
}).join('');
|
|
331
|
-
};
|
|
332
94
|
this.isValid = value => {
|
|
333
95
|
if (value == null) {
|
|
334
96
|
return false;
|
|
@@ -343,9 +105,6 @@ export class AdapterDateFns {
|
|
|
343
105
|
locale: this.locale
|
|
344
106
|
});
|
|
345
107
|
};
|
|
346
|
-
this.formatNumber = numberToFormat => {
|
|
347
|
-
return numberToFormat;
|
|
348
|
-
};
|
|
349
108
|
this.isEqual = (value, comparing) => {
|
|
350
109
|
if (value === null && comparing === null) {
|
|
351
110
|
return true;
|
|
@@ -516,7 +275,5 @@ export class AdapterDateFns {
|
|
|
516
275
|
}
|
|
517
276
|
return years;
|
|
518
277
|
};
|
|
519
|
-
this.locale = _locale;
|
|
520
|
-
this.formats = _extends({}, defaultFormats, formats);
|
|
521
278
|
}
|
|
522
279
|
}
|