@mui/x-date-pickers-pro 6.2.0 → 6.3.0
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 +118 -1
- package/DateRangePicker/shared.d.ts +1 -1
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -1
- package/MobileDateRangePicker/MobileDateRangePicker.js +2 -1
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +26 -4
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +27 -4
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +27 -4
- package/README.md +0 -9
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +20 -3
- package/SingleInputDateRangeField/useSingleInputDateRangeField.js +4 -2
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +21 -3
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +4 -2
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +21 -3
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +4 -2
- package/StaticDateRangePicker/StaticDateRangePicker.js +2 -1
- package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +2 -2
- package/index.d.ts +1 -3
- package/index.js +3 -2
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +2 -2
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +9 -9
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +5 -5
- package/internal/hooks/useEnrichedRangePickerFieldProps.d.ts +4 -3
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +2 -2
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +9 -9
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +5 -5
- package/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +4 -1
- package/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +4 -1
- package/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +4 -1
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +2 -2
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +10 -10
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +5 -5
- package/internal/models/dateRange.d.ts +1 -1
- package/internal/models/dateTimeRange.d.ts +1 -1
- package/internal/models/timeRange.d.ts +1 -1
- package/internal/utils/date-fields-utils.d.ts +4 -1
- package/internal/utils/releaseInfo.js +1 -1
- package/internal/{hooks/validation/useDateRangeValidation.d.ts → utils/validation/validateDateRange.d.ts} +1 -7
- package/internal/{hooks/validation/useDateRangeValidation.js → utils/validation/validateDateRange.js} +1 -1
- package/internal/utils/validation/validateDateTimeRange.d.ts +7 -0
- package/internal/{hooks/validation/useDateTimeRangeValidation.js → utils/validation/validateDateTimeRange.js} +2 -6
- package/internal/utils/validation/validateTimeRange.d.ts +6 -0
- package/internal/{hooks/validation/useTimeRangeValidation.js → utils/validation/validateTimeRange.js} +2 -6
- package/internal/utils/valueManagers.d.ts +1 -3
- package/internal/utils/valueManagers.js +1 -1
- package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -1
- package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +2 -1
- package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +26 -4
- package/legacy/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +27 -4
- package/legacy/MultiInputTimeRangeField/MultiInputTimeRangeField.js +27 -4
- package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.js +20 -3
- package/legacy/SingleInputDateRangeField/useSingleInputDateRangeField.js +4 -2
- package/legacy/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +21 -3
- package/legacy/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +4 -2
- package/legacy/SingleInputTimeRangeField/SingleInputTimeRangeField.js +21 -3
- package/legacy/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +4 -2
- package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +2 -1
- package/legacy/index.js +3 -2
- package/legacy/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +5 -6
- package/legacy/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +5 -6
- package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +4 -1
- package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +4 -1
- package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +4 -1
- package/legacy/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +6 -7
- package/legacy/internal/utils/releaseInfo.js +1 -1
- package/legacy/internal/{hooks/validation/useDateRangeValidation.js → utils/validation/validateDateRange.js} +1 -1
- package/legacy/internal/{hooks/validation/useDateTimeRangeValidation.js → utils/validation/validateDateTimeRange.js} +2 -6
- package/legacy/internal/{hooks/validation/useTimeRangeValidation.js → utils/validation/validateTimeRange.js} +2 -6
- package/legacy/internal/utils/valueManagers.js +2 -2
- package/legacy/models/index.js +1 -0
- package/legacy/models/validation.js +1 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/package.json +6 -0
- package/models/validation.d.ts +9 -0
- package/models/validation.js +1 -0
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -1
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +2 -1
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +26 -4
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +27 -4
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +27 -4
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +20 -3
- package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +4 -2
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +21 -3
- package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +4 -2
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +21 -3
- package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +4 -2
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +2 -1
- package/modern/index.js +3 -2
- package/modern/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +9 -9
- package/modern/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +9 -9
- package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +4 -1
- package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +4 -1
- package/modern/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +4 -1
- package/modern/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +10 -10
- package/modern/internal/utils/releaseInfo.js +1 -1
- package/modern/internal/{hooks/validation/useDateRangeValidation.js → utils/validation/validateDateRange.js} +1 -1
- package/modern/internal/{hooks/validation/useDateTimeRangeValidation.js → utils/validation/validateDateTimeRange.js} +2 -6
- package/modern/internal/{hooks/validation/useTimeRangeValidation.js → utils/validation/validateTimeRange.js} +2 -6
- package/modern/internal/utils/valueManagers.js +1 -1
- package/modern/models/index.js +1 -0
- package/modern/models/validation.js +1 -0
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +3 -2
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +3 -2
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +26 -4
- package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +27 -4
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +27 -4
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +20 -3
- package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +5 -3
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +21 -3
- package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +5 -3
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +21 -3
- package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +5 -3
- package/node/StaticDateRangePicker/StaticDateRangePicker.js +3 -2
- package/node/index.js +13 -1
- package/node/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +9 -9
- package/node/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +9 -9
- package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +6 -3
- package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +6 -3
- package/node/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +6 -3
- package/node/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +10 -10
- package/node/internal/utils/releaseInfo.js +1 -1
- package/node/internal/{hooks/validation/useDateRangeValidation.js → utils/validation/validateDateRange.js} +1 -1
- package/node/internal/{hooks/validation/useDateTimeRangeValidation.js → utils/validation/validateDateTimeRange.js} +3 -8
- package/node/internal/{hooks/validation/useTimeRangeValidation.js → utils/validation/validateTimeRange.js} +3 -8
- package/node/internal/utils/valueManagers.js +1 -1
- package/node/models/index.js +16 -0
- package/node/models/validation.js +5 -0
- package/package.json +4 -7
- package/internal/hooks/validation/useDateTimeRangeValidation.d.ts +0 -14
- package/internal/hooks/validation/useTimeRangeValidation.d.ts +0 -13
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { PickerValueManager, FieldValueManager } from '@mui/x-date-pickers/internals';
|
|
2
2
|
import { DateRange } from '../models/range';
|
|
3
|
-
import type { DateRangeValidationError } from '
|
|
4
|
-
import type { TimeRangeValidationError } from '../hooks/validation/useTimeRangeValidation';
|
|
5
|
-
import type { DateTimeRangeValidationError } from '../hooks/validation/useDateTimeRangeValidation';
|
|
3
|
+
import type { DateRangeValidationError, DateTimeRangeValidationError, TimeRangeValidationError } from '../../models';
|
|
6
4
|
import { RangeFieldSection } from '../models/fields';
|
|
7
5
|
export type RangePickerValueManager<TValue = [any, any], TDate = any, TError extends DateRangeValidationError | TimeRangeValidationError | DateTimeRangeValidationError = any> = PickerValueManager<TValue, TDate, TError>;
|
|
8
6
|
export declare const rangeValueManager: RangePickerValueManager;
|
|
@@ -3,7 +3,7 @@ import { replaceInvalidDateByNull, addPositionPropertiesToSections, createDateSt
|
|
|
3
3
|
import { splitDateRangeSections, removeLastSeparator } from './date-fields-utils';
|
|
4
4
|
export const rangeValueManager = {
|
|
5
5
|
emptyValue: [null, null],
|
|
6
|
-
getTodayValue: utils => [utils.date(), utils.date()],
|
|
6
|
+
getTodayValue: (utils, valueType) => valueType === 'date' ? [utils.startOfDay(utils.date()), utils.startOfDay(utils.date())] : [utils.date(), utils.date()],
|
|
7
7
|
cleanValue: (utils, value) => value.map(date => replaceInvalidDateByNull(utils, date)),
|
|
8
8
|
areValuesEqual: (utils, a, b) => areDatesEqual(utils, a[0], b[0]) && areDatesEqual(utils, a[1], b[1]),
|
|
9
9
|
isSameError: (a, b) => b !== null && a[1] === b[1] && a[0] === b[0],
|
|
@@ -8,7 +8,7 @@ import { useDateRangePickerDefaultizedProps } from '../DateRangePicker/shared';
|
|
|
8
8
|
import { renderDateRangeViewCalendar } from '../dateRangeViewRenderers';
|
|
9
9
|
import { MultiInputDateRangeField } from '../MultiInputDateRangeField';
|
|
10
10
|
import { useDesktopRangePicker } from '../internal/hooks/useDesktopRangePicker';
|
|
11
|
-
import { validateDateRange } from '../internal/
|
|
11
|
+
import { validateDateRange } from '../internal/utils/validation/validateDateRange';
|
|
12
12
|
var DesktopDateRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDateRangePicker(inProps, ref) {
|
|
13
13
|
var _defaultizedProps$cal, _defaultizedProps$slo2;
|
|
14
14
|
// Props with the default values common to all date time pickers
|
|
@@ -39,6 +39,7 @@ var DesktopDateRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDateR
|
|
|
39
39
|
var _useDesktopRangePicke = useDesktopRangePicker({
|
|
40
40
|
props: props,
|
|
41
41
|
valueManager: rangeValueManager,
|
|
42
|
+
valueType: 'date',
|
|
42
43
|
validator: validateDateRange
|
|
43
44
|
}),
|
|
44
45
|
renderPicker = _useDesktopRangePicke.renderPicker;
|
|
@@ -10,7 +10,7 @@ import { useDateRangePickerDefaultizedProps } from '../DateRangePicker/shared';
|
|
|
10
10
|
import { renderDateRangeViewCalendar } from '../dateRangeViewRenderers';
|
|
11
11
|
import { MultiInputDateRangeField } from '../MultiInputDateRangeField';
|
|
12
12
|
import { useMobileRangePicker } from '../internal/hooks/useMobileRangePicker';
|
|
13
|
-
import { validateDateRange } from '../internal/
|
|
13
|
+
import { validateDateRange } from '../internal/utils/validation/validateDateRange';
|
|
14
14
|
var MobileDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileDateRangePicker(inProps, ref) {
|
|
15
15
|
var _defaultizedProps$slo2;
|
|
16
16
|
// Props with the default values common to all date time pickers
|
|
@@ -44,6 +44,7 @@ var MobileDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileDateRan
|
|
|
44
44
|
var _useMobileRangePicker = useMobileRangePicker({
|
|
45
45
|
props: props,
|
|
46
46
|
valueManager: rangeValueManager,
|
|
47
|
+
valueType: 'date',
|
|
47
48
|
validator: validateDateRange
|
|
48
49
|
}),
|
|
49
50
|
renderPicker = _useMobileRangePicker.renderPicker;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "disabled", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "autoFocus"],
|
|
3
|
+
var _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "disabled", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "autoFocus"],
|
|
4
4
|
_excluded2 = ["onKeyDown", "ref", "readOnly", "inputMode"],
|
|
5
5
|
_excluded3 = ["onKeyDown", "ref", "readOnly", "inputMode"];
|
|
6
6
|
import * as React from 'react';
|
|
@@ -31,7 +31,7 @@ var MultiInputDateRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef(functio
|
|
|
31
31
|
var MultiInputDateRangeFieldSeparator = styled(function (props) {
|
|
32
32
|
var _props$children;
|
|
33
33
|
return /*#__PURE__*/_jsx(Typography, _extends({}, props, {
|
|
34
|
-
children: (_props$children = props.children) != null ? _props$children : '
|
|
34
|
+
children: (_props$children = props.children) != null ? _props$children : ' – '
|
|
35
35
|
}));
|
|
36
36
|
}, {
|
|
37
37
|
name: 'MuiMultiInputDateRangeField',
|
|
@@ -54,6 +54,7 @@ var MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInput
|
|
|
54
54
|
defaultValue = themeProps.defaultValue,
|
|
55
55
|
format = themeProps.format,
|
|
56
56
|
formatDensity = themeProps.formatDensity,
|
|
57
|
+
shouldRespectLeadingZeros = themeProps.shouldRespectLeadingZeros,
|
|
57
58
|
onChange = themeProps.onChange,
|
|
58
59
|
readOnly = themeProps.readOnly,
|
|
59
60
|
disabled = themeProps.disabled,
|
|
@@ -110,6 +111,7 @@ var MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInput
|
|
|
110
111
|
defaultValue: defaultValue,
|
|
111
112
|
format: format,
|
|
112
113
|
formatDensity: formatDensity,
|
|
114
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
113
115
|
onChange: onChange,
|
|
114
116
|
readOnly: readOnly,
|
|
115
117
|
disabled: disabled,
|
|
@@ -143,15 +145,20 @@ var MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInput
|
|
|
143
145
|
children: [/*#__PURE__*/_jsx(TextField, _extends({
|
|
144
146
|
fullWidth: true
|
|
145
147
|
}, startDateProps, {
|
|
148
|
+
InputProps: _extends({}, startDateProps.InputProps, {
|
|
149
|
+
readOnly: startReadOnly
|
|
150
|
+
}),
|
|
146
151
|
inputProps: _extends({}, startDateProps.inputProps, {
|
|
147
152
|
ref: startInputRef,
|
|
148
|
-
readOnly: startReadOnly,
|
|
149
153
|
inputMode: startInputMode,
|
|
150
154
|
onKeyDown: onStartInputKeyDown
|
|
151
155
|
})
|
|
152
156
|
})), /*#__PURE__*/_jsx(Separator, _extends({}, separatorProps)), /*#__PURE__*/_jsx(TextField, _extends({
|
|
153
157
|
fullWidth: true
|
|
154
158
|
}, endDateProps, {
|
|
159
|
+
InputProps: _extends({}, endDateProps.InputProps, {
|
|
160
|
+
readOnly: endReadOnly
|
|
161
|
+
}),
|
|
155
162
|
inputProps: _extends({}, endDateProps.inputProps, {
|
|
156
163
|
ref: endInputRef,
|
|
157
164
|
readOnly: endReadOnly,
|
|
@@ -275,6 +282,21 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
|
|
|
275
282
|
* @returns {boolean} Returns `true` if the date should be disabled.
|
|
276
283
|
*/
|
|
277
284
|
shouldDisableDate: PropTypes.func,
|
|
285
|
+
/**
|
|
286
|
+
* If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
287
|
+
* If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
288
|
+
*
|
|
289
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
290
|
+
*
|
|
291
|
+
* 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.
|
|
292
|
+
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
293
|
+
*
|
|
294
|
+
* Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros.
|
|
295
|
+
* This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library.
|
|
296
|
+
*
|
|
297
|
+
* @default `false`
|
|
298
|
+
*/
|
|
299
|
+
shouldRespectLeadingZeros: PropTypes.bool,
|
|
278
300
|
/**
|
|
279
301
|
* The props used for each component slot.
|
|
280
302
|
* @default {}
|
|
@@ -300,7 +322,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
|
|
|
300
322
|
/**
|
|
301
323
|
* If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
|
|
302
324
|
*
|
|
303
|
-
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack
|
|
325
|
+
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack/#limitations),
|
|
304
326
|
* it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
|
|
305
327
|
*
|
|
306
328
|
* To enable this flag globally, follow the [theme's default props](https://mui.com/material-ui/customization/theme-components/#default-props) configuration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "disabled", "onError", "shouldDisableDate", "minDate", "maxDate", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableStartFieldRef", "unstableEndFieldRef", "autoFocus"],
|
|
3
|
+
var _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "disabled", "onError", "shouldDisableDate", "minDate", "maxDate", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableStartFieldRef", "unstableEndFieldRef", "autoFocus"],
|
|
4
4
|
_excluded2 = ["onKeyDown", "ref", "readOnly", "inputMode"],
|
|
5
5
|
_excluded3 = ["onKeyDown", "ref", "readOnly", "inputMode"];
|
|
6
6
|
import * as React from 'react';
|
|
@@ -31,7 +31,7 @@ var MultiInputDateTimeRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef(fun
|
|
|
31
31
|
var MultiInputDateTimeRangeFieldSeparator = styled(function (props) {
|
|
32
32
|
var _props$children;
|
|
33
33
|
return /*#__PURE__*/_jsx(Typography, _extends({}, props, {
|
|
34
|
-
children: (_props$children = props.children) != null ? _props$children : '
|
|
34
|
+
children: (_props$children = props.children) != null ? _props$children : ' – '
|
|
35
35
|
}));
|
|
36
36
|
}, {
|
|
37
37
|
name: 'MuiMultiInputDateTimeRangeField',
|
|
@@ -54,6 +54,7 @@ var MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiI
|
|
|
54
54
|
defaultValue = themeProps.defaultValue,
|
|
55
55
|
format = themeProps.format,
|
|
56
56
|
formatDensity = themeProps.formatDensity,
|
|
57
|
+
shouldRespectLeadingZeros = themeProps.shouldRespectLeadingZeros,
|
|
57
58
|
onChange = themeProps.onChange,
|
|
58
59
|
readOnly = themeProps.readOnly,
|
|
59
60
|
disabled = themeProps.disabled,
|
|
@@ -119,6 +120,7 @@ var MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiI
|
|
|
119
120
|
defaultValue: defaultValue,
|
|
120
121
|
format: format,
|
|
121
122
|
formatDensity: formatDensity,
|
|
123
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
122
124
|
onChange: onChange,
|
|
123
125
|
readOnly: readOnly,
|
|
124
126
|
disabled: disabled,
|
|
@@ -161,15 +163,20 @@ var MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiI
|
|
|
161
163
|
children: [/*#__PURE__*/_jsx(TextField, _extends({
|
|
162
164
|
fullWidth: true
|
|
163
165
|
}, startDateProps, {
|
|
166
|
+
InputProps: _extends({}, startDateProps.InputProps, {
|
|
167
|
+
readOnly: startReadOnly
|
|
168
|
+
}),
|
|
164
169
|
inputProps: _extends({}, startDateProps.inputProps, {
|
|
165
170
|
ref: startInputRef,
|
|
166
|
-
readOnly: startReadOnly,
|
|
167
171
|
inputMode: startInputMode,
|
|
168
172
|
onKeyDown: onStartInputKeyDown
|
|
169
173
|
})
|
|
170
174
|
})), /*#__PURE__*/_jsx(Separator, _extends({}, separatorProps)), /*#__PURE__*/_jsx(TextField, _extends({
|
|
171
175
|
fullWidth: true
|
|
172
176
|
}, endDateProps, {
|
|
177
|
+
InputProps: _extends({}, endDateProps.InputProps, {
|
|
178
|
+
readOnly: endReadOnly
|
|
179
|
+
}),
|
|
173
180
|
inputProps: _extends({}, endDateProps.inputProps, {
|
|
174
181
|
ref: endInputRef,
|
|
175
182
|
readOnly: endReadOnly,
|
|
@@ -336,11 +343,27 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
|
|
|
336
343
|
shouldDisableDate: PropTypes.func,
|
|
337
344
|
/**
|
|
338
345
|
* Disable specific time.
|
|
346
|
+
* @template TDate
|
|
339
347
|
* @param {TDate} value The value to check.
|
|
340
348
|
* @param {TimeView} view The clock type of the timeValue.
|
|
341
349
|
* @returns {boolean} If `true` the time will be disabled.
|
|
342
350
|
*/
|
|
343
351
|
shouldDisableTime: PropTypes.func,
|
|
352
|
+
/**
|
|
353
|
+
* If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
354
|
+
* If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
355
|
+
*
|
|
356
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
357
|
+
*
|
|
358
|
+
* 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.
|
|
359
|
+
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
360
|
+
*
|
|
361
|
+
* Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros.
|
|
362
|
+
* This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library.
|
|
363
|
+
*
|
|
364
|
+
* @default `false`
|
|
365
|
+
*/
|
|
366
|
+
shouldRespectLeadingZeros: PropTypes.bool,
|
|
344
367
|
/**
|
|
345
368
|
* The props used for each component slot.
|
|
346
369
|
* @default {}
|
|
@@ -366,7 +389,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
|
|
|
366
389
|
/**
|
|
367
390
|
* If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
|
|
368
391
|
*
|
|
369
|
-
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack
|
|
392
|
+
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack/#limitations),
|
|
370
393
|
* it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
|
|
371
394
|
*
|
|
372
395
|
* To enable this flag globally, follow the [theme's default props](https://mui.com/material-ui/customization/theme-components/#default-props) configuration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "disabled", "onError", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableStartFieldRef", "unstableEndFieldRef", "autoFocus"],
|
|
3
|
+
var _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "disabled", "onError", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableStartFieldRef", "unstableEndFieldRef", "autoFocus"],
|
|
4
4
|
_excluded2 = ["onKeyDown", "ref", "readOnly", "inputMode"],
|
|
5
5
|
_excluded3 = ["onKeyDown", "ref", "readOnly", "inputMode"];
|
|
6
6
|
import * as React from 'react';
|
|
@@ -31,7 +31,7 @@ var MultiInputTimeRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef(functio
|
|
|
31
31
|
var MultiInputTimeRangeFieldSeparator = styled(function (props) {
|
|
32
32
|
var _props$children;
|
|
33
33
|
return /*#__PURE__*/_jsx(Typography, _extends({}, props, {
|
|
34
|
-
children: (_props$children = props.children) != null ? _props$children : '
|
|
34
|
+
children: (_props$children = props.children) != null ? _props$children : ' – '
|
|
35
35
|
}));
|
|
36
36
|
}, {
|
|
37
37
|
name: 'MuiMultiInputTimeRangeField',
|
|
@@ -54,6 +54,7 @@ var MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInput
|
|
|
54
54
|
defaultValue = themeProps.defaultValue,
|
|
55
55
|
format = themeProps.format,
|
|
56
56
|
formatDensity = themeProps.formatDensity,
|
|
57
|
+
shouldRespectLeadingZeros = themeProps.shouldRespectLeadingZeros,
|
|
57
58
|
onChange = themeProps.onChange,
|
|
58
59
|
readOnly = themeProps.readOnly,
|
|
59
60
|
disabled = themeProps.disabled,
|
|
@@ -114,6 +115,7 @@ var MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInput
|
|
|
114
115
|
defaultValue: defaultValue,
|
|
115
116
|
format: format,
|
|
116
117
|
formatDensity: formatDensity,
|
|
118
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
117
119
|
onChange: onChange,
|
|
118
120
|
readOnly: readOnly,
|
|
119
121
|
disabled: disabled,
|
|
@@ -151,15 +153,20 @@ var MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInput
|
|
|
151
153
|
children: [/*#__PURE__*/_jsx(TextField, _extends({
|
|
152
154
|
fullWidth: true
|
|
153
155
|
}, startDateProps, {
|
|
156
|
+
InputProps: _extends({}, startDateProps.InputProps, {
|
|
157
|
+
readOnly: startReadOnly
|
|
158
|
+
}),
|
|
154
159
|
inputProps: _extends({}, startDateProps.inputProps, {
|
|
155
160
|
ref: startInputRef,
|
|
156
|
-
readOnly: startReadOnly,
|
|
157
161
|
inputMode: startInputMode,
|
|
158
162
|
onKeyDown: onStartInputKeyDown
|
|
159
163
|
})
|
|
160
164
|
})), /*#__PURE__*/_jsx(Separator, _extends({}, separatorProps)), /*#__PURE__*/_jsx(TextField, _extends({
|
|
161
165
|
fullWidth: true
|
|
162
166
|
}, endDateProps, {
|
|
167
|
+
InputProps: _extends({}, endDateProps.InputProps, {
|
|
168
|
+
readOnly: endReadOnly
|
|
169
|
+
}),
|
|
163
170
|
inputProps: _extends({}, endDateProps.inputProps, {
|
|
164
171
|
ref: endInputRef,
|
|
165
172
|
readOnly: endReadOnly,
|
|
@@ -302,11 +309,27 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
|
|
|
302
309
|
shouldDisableClock: PropTypes.func,
|
|
303
310
|
/**
|
|
304
311
|
* Disable specific time.
|
|
312
|
+
* @template TDate
|
|
305
313
|
* @param {TDate} value The value to check.
|
|
306
314
|
* @param {TimeView} view The clock type of the timeValue.
|
|
307
315
|
* @returns {boolean} If `true` the time will be disabled.
|
|
308
316
|
*/
|
|
309
317
|
shouldDisableTime: PropTypes.func,
|
|
318
|
+
/**
|
|
319
|
+
* If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
320
|
+
* If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
321
|
+
*
|
|
322
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
323
|
+
*
|
|
324
|
+
* 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.
|
|
325
|
+
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
326
|
+
*
|
|
327
|
+
* Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros.
|
|
328
|
+
* This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library.
|
|
329
|
+
*
|
|
330
|
+
* @default `false`
|
|
331
|
+
*/
|
|
332
|
+
shouldRespectLeadingZeros: PropTypes.bool,
|
|
310
333
|
/**
|
|
311
334
|
* The props used for each component slot.
|
|
312
335
|
* @default {}
|
|
@@ -332,7 +355,7 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
|
|
|
332
355
|
/**
|
|
333
356
|
* If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
|
|
334
357
|
*
|
|
335
|
-
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack
|
|
358
|
+
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack/#limitations),
|
|
336
359
|
* it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
|
|
337
360
|
*
|
|
338
361
|
* To enable this flag globally, follow the [theme's default props](https://mui.com/material-ui/customization/theme-components/#default-props) configuration.
|
|
@@ -49,11 +49,13 @@ var SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleInp
|
|
|
49
49
|
return /*#__PURE__*/_jsx(TextField, _extends({
|
|
50
50
|
ref: ref
|
|
51
51
|
}, fieldProps, {
|
|
52
|
+
InputProps: _extends({}, fieldProps.InputProps, {
|
|
53
|
+
readOnly: readOnly
|
|
54
|
+
}),
|
|
52
55
|
inputProps: _extends({}, fieldProps.inputProps, {
|
|
53
|
-
ref: inputRef,
|
|
54
|
-
onPaste: onPaste,
|
|
55
56
|
inputMode: inputMode,
|
|
56
|
-
|
|
57
|
+
onPaste: onPaste,
|
|
58
|
+
ref: inputRef
|
|
57
59
|
})
|
|
58
60
|
}));
|
|
59
61
|
});
|
|
@@ -244,6 +246,21 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
|
|
|
244
246
|
* @returns {boolean} Returns `true` if the date should be disabled.
|
|
245
247
|
*/
|
|
246
248
|
shouldDisableDate: PropTypes.func,
|
|
249
|
+
/**
|
|
250
|
+
* If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
251
|
+
* If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
252
|
+
*
|
|
253
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
254
|
+
*
|
|
255
|
+
* 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.
|
|
256
|
+
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
257
|
+
*
|
|
258
|
+
* Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros.
|
|
259
|
+
* This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library.
|
|
260
|
+
*
|
|
261
|
+
* @default `false`
|
|
262
|
+
*/
|
|
263
|
+
shouldRespectLeadingZeros: PropTypes.bool,
|
|
247
264
|
/**
|
|
248
265
|
* The size of the component.
|
|
249
266
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
3
|
+
var _excluded = ["value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
4
4
|
import { useUtils, useDefaultDates, applyDefaultDate, useField } from '@mui/x-date-pickers/internals';
|
|
5
5
|
import { rangeValueManager, rangeFieldValueManager } from '../internal/utils/valueManagers';
|
|
6
|
-
import { validateDateRange } from '../internal/
|
|
6
|
+
import { validateDateRange } from '../internal/utils/validation/validateDateRange';
|
|
7
7
|
export var useDefaultizedDateRangeFieldProps = function useDefaultizedDateRangeFieldProps(props) {
|
|
8
8
|
var _props$disablePast, _props$disableFuture, _props$format;
|
|
9
9
|
var utils = useUtils();
|
|
@@ -24,6 +24,7 @@ export var useSingleInputDateRangeField = function useSingleInputDateRangeField(
|
|
|
24
24
|
defaultValue = _useDefaultizedDateRa.defaultValue,
|
|
25
25
|
format = _useDefaultizedDateRa.format,
|
|
26
26
|
formatDensity = _useDefaultizedDateRa.formatDensity,
|
|
27
|
+
shouldRespectLeadingZeros = _useDefaultizedDateRa.shouldRespectLeadingZeros,
|
|
27
28
|
onChange = _useDefaultizedDateRa.onChange,
|
|
28
29
|
readOnly = _useDefaultizedDateRa.readOnly,
|
|
29
30
|
onError = _useDefaultizedDateRa.onError,
|
|
@@ -44,6 +45,7 @@ export var useSingleInputDateRangeField = function useSingleInputDateRangeField(
|
|
|
44
45
|
defaultValue: defaultValue,
|
|
45
46
|
format: format,
|
|
46
47
|
formatDensity: formatDensity,
|
|
48
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
47
49
|
onChange: onChange,
|
|
48
50
|
readOnly: readOnly,
|
|
49
51
|
onError: onError,
|
|
@@ -49,11 +49,13 @@ var SingleInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Singl
|
|
|
49
49
|
return /*#__PURE__*/_jsx(TextField, _extends({
|
|
50
50
|
ref: ref
|
|
51
51
|
}, fieldProps, {
|
|
52
|
+
InputProps: _extends({}, fieldProps.InputProps, {
|
|
53
|
+
readOnly: readOnly
|
|
54
|
+
}),
|
|
52
55
|
inputProps: _extends({}, fieldProps.inputProps, {
|
|
53
|
-
ref: inputRef,
|
|
54
|
-
onPaste: onPaste,
|
|
55
56
|
inputMode: inputMode,
|
|
56
|
-
|
|
57
|
+
onPaste: onPaste,
|
|
58
|
+
ref: inputRef
|
|
57
59
|
})
|
|
58
60
|
}));
|
|
59
61
|
});
|
|
@@ -287,11 +289,27 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
|
|
|
287
289
|
shouldDisableDate: PropTypes.func,
|
|
288
290
|
/**
|
|
289
291
|
* Disable specific time.
|
|
292
|
+
* @template TDate
|
|
290
293
|
* @param {TDate} value The value to check.
|
|
291
294
|
* @param {TimeView} view The clock type of the timeValue.
|
|
292
295
|
* @returns {boolean} If `true` the time will be disabled.
|
|
293
296
|
*/
|
|
294
297
|
shouldDisableTime: PropTypes.func,
|
|
298
|
+
/**
|
|
299
|
+
* If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
300
|
+
* If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
301
|
+
*
|
|
302
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
303
|
+
*
|
|
304
|
+
* 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.
|
|
305
|
+
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
306
|
+
*
|
|
307
|
+
* Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros.
|
|
308
|
+
* This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library.
|
|
309
|
+
*
|
|
310
|
+
* @default `false`
|
|
311
|
+
*/
|
|
312
|
+
shouldRespectLeadingZeros: PropTypes.bool,
|
|
295
313
|
/**
|
|
296
314
|
* The size of the component.
|
|
297
315
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "shouldDisableTime", "disableIgnoringDatePartForTimeValidation", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
3
|
+
var _excluded = ["value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "shouldDisableTime", "disableIgnoringDatePartForTimeValidation", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
4
4
|
import { useUtils, useField, applyDefaultDate, useDefaultDates } from '@mui/x-date-pickers/internals';
|
|
5
5
|
import { rangeValueManager, rangeFieldValueManager } from '../internal/utils/valueManagers';
|
|
6
|
-
import { validateDateTimeRange } from '../internal/
|
|
6
|
+
import { validateDateTimeRange } from '../internal/utils/validation/validateDateTimeRange';
|
|
7
7
|
export var useDefaultizedTimeRangeFieldProps = function useDefaultizedTimeRangeFieldProps(props) {
|
|
8
8
|
var _props$ampm, _props$disablePast, _props$disableFuture, _props$format, _props$minDateTime, _props$maxDateTime, _props$minDateTime2, _props$maxDateTime2;
|
|
9
9
|
var utils = useUtils();
|
|
@@ -29,6 +29,7 @@ export var useSingleInputDateTimeRangeField = function useSingleInputDateTimeRan
|
|
|
29
29
|
defaultValue = _useDefaultizedTimeRa.defaultValue,
|
|
30
30
|
format = _useDefaultizedTimeRa.format,
|
|
31
31
|
formatDensity = _useDefaultizedTimeRa.formatDensity,
|
|
32
|
+
shouldRespectLeadingZeros = _useDefaultizedTimeRa.shouldRespectLeadingZeros,
|
|
32
33
|
onChange = _useDefaultizedTimeRa.onChange,
|
|
33
34
|
readOnly = _useDefaultizedTimeRa.readOnly,
|
|
34
35
|
onError = _useDefaultizedTimeRa.onError,
|
|
@@ -56,6 +57,7 @@ export var useSingleInputDateTimeRangeField = function useSingleInputDateTimeRan
|
|
|
56
57
|
defaultValue: defaultValue,
|
|
57
58
|
format: format,
|
|
58
59
|
formatDensity: formatDensity,
|
|
60
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
59
61
|
onChange: onChange,
|
|
60
62
|
readOnly: readOnly,
|
|
61
63
|
onError: onError,
|
|
@@ -49,11 +49,13 @@ var SingleInputTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleInp
|
|
|
49
49
|
return /*#__PURE__*/_jsx(TextField, _extends({
|
|
50
50
|
ref: ref
|
|
51
51
|
}, fieldProps, {
|
|
52
|
+
InputProps: _extends({}, fieldProps.InputProps, {
|
|
53
|
+
readOnly: readOnly
|
|
54
|
+
}),
|
|
52
55
|
inputProps: _extends({}, fieldProps.inputProps, {
|
|
53
|
-
ref: inputRef,
|
|
54
|
-
onPaste: onPaste,
|
|
55
56
|
inputMode: inputMode,
|
|
56
|
-
|
|
57
|
+
onPaste: onPaste,
|
|
58
|
+
ref: inputRef
|
|
57
59
|
})
|
|
58
60
|
}));
|
|
59
61
|
});
|
|
@@ -263,11 +265,27 @@ process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
|
|
|
263
265
|
shouldDisableClock: PropTypes.func,
|
|
264
266
|
/**
|
|
265
267
|
* Disable specific time.
|
|
268
|
+
* @template TDate
|
|
266
269
|
* @param {TDate} value The value to check.
|
|
267
270
|
* @param {TimeView} view The clock type of the timeValue.
|
|
268
271
|
* @returns {boolean} If `true` the time will be disabled.
|
|
269
272
|
*/
|
|
270
273
|
shouldDisableTime: PropTypes.func,
|
|
274
|
+
/**
|
|
275
|
+
* If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
276
|
+
* If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
277
|
+
*
|
|
278
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
279
|
+
*
|
|
280
|
+
* 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.
|
|
281
|
+
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
282
|
+
*
|
|
283
|
+
* Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros.
|
|
284
|
+
* This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library.
|
|
285
|
+
*
|
|
286
|
+
* @default `false`
|
|
287
|
+
*/
|
|
288
|
+
shouldRespectLeadingZeros: PropTypes.bool,
|
|
271
289
|
/**
|
|
272
290
|
* The size of the component.
|
|
273
291
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "onError", "minTime", "maxTime", "minutesStep", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
3
|
+
var _excluded = ["value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "onError", "minTime", "maxTime", "minutesStep", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
4
4
|
import { useUtils, useField } from '@mui/x-date-pickers/internals';
|
|
5
5
|
import { rangeValueManager, rangeFieldValueManager } from '../internal/utils/valueManagers';
|
|
6
|
-
import { validateTimeRange } from '../internal/
|
|
6
|
+
import { validateTimeRange } from '../internal/utils/validation/validateTimeRange';
|
|
7
7
|
export var useDefaultizedTimeRangeFieldProps = function useDefaultizedTimeRangeFieldProps(props) {
|
|
8
8
|
var _props$ampm, _props$disablePast, _props$disableFuture, _props$format;
|
|
9
9
|
var utils = useUtils();
|
|
@@ -23,6 +23,7 @@ export var useSingleInputTimeRangeField = function useSingleInputTimeRangeField(
|
|
|
23
23
|
defaultValue = _useDefaultizedTimeRa.defaultValue,
|
|
24
24
|
format = _useDefaultizedTimeRa.format,
|
|
25
25
|
formatDensity = _useDefaultizedTimeRa.formatDensity,
|
|
26
|
+
shouldRespectLeadingZeros = _useDefaultizedTimeRa.shouldRespectLeadingZeros,
|
|
26
27
|
onChange = _useDefaultizedTimeRa.onChange,
|
|
27
28
|
readOnly = _useDefaultizedTimeRa.readOnly,
|
|
28
29
|
onError = _useDefaultizedTimeRa.onError,
|
|
@@ -44,6 +45,7 @@ export var useSingleInputTimeRangeField = function useSingleInputTimeRangeField(
|
|
|
44
45
|
defaultValue: defaultValue,
|
|
45
46
|
format: format,
|
|
46
47
|
formatDensity: formatDensity,
|
|
48
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
47
49
|
onChange: onChange,
|
|
48
50
|
readOnly: readOnly,
|
|
49
51
|
onError: onError,
|
|
@@ -5,7 +5,7 @@ import { useStaticRangePicker } from '../internal/hooks/useStaticRangePicker';
|
|
|
5
5
|
import { useDateRangePickerDefaultizedProps } from '../DateRangePicker/shared';
|
|
6
6
|
import { renderDateRangeViewCalendar } from '../dateRangeViewRenderers';
|
|
7
7
|
import { rangeValueManager } from '../internal/utils/valueManagers';
|
|
8
|
-
import { validateDateRange } from '../internal/
|
|
8
|
+
import { validateDateRange } from '../internal/utils/validation/validateDateRange';
|
|
9
9
|
var StaticDateRangePicker = /*#__PURE__*/React.forwardRef(function StaticDateRangePicker(inProps, ref) {
|
|
10
10
|
var _defaultizedProps$dis, _defaultizedProps$cal, _defaultizedProps$slo;
|
|
11
11
|
var defaultizedProps = useDateRangePickerDefaultizedProps(inProps, 'MuiStaticDateRangePicker');
|
|
@@ -30,6 +30,7 @@ var StaticDateRangePicker = /*#__PURE__*/React.forwardRef(function StaticDateRan
|
|
|
30
30
|
var _useStaticRangePicker = useStaticRangePicker({
|
|
31
31
|
props: props,
|
|
32
32
|
valueManager: rangeValueManager,
|
|
33
|
+
valueType: 'date',
|
|
33
34
|
validator: validateDateRange,
|
|
34
35
|
ref: ref
|
|
35
36
|
}),
|
package/legacy/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-date-pickers-pro v6.
|
|
2
|
+
* @mui/x-date-pickers-pro v6.3.0
|
|
3
3
|
*
|
|
4
4
|
* @license MUI X Commercial
|
|
5
5
|
* This source code is licensed under the commercial license found in the
|
|
@@ -26,4 +26,5 @@ export * from './MobileDateRangePicker';
|
|
|
26
26
|
export * from './StaticDateRangePicker';
|
|
27
27
|
|
|
28
28
|
// View renderers
|
|
29
|
-
export * from './dateRangeViewRenderers';
|
|
29
|
+
export * from './dateRangeViewRenderers';
|
|
30
|
+
export * from './models';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["props"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import { useSlotProps } from '@mui/base/utils';
|
|
4
6
|
import { useLicenseVerifier } from '@mui/x-license-pro';
|
|
@@ -14,8 +16,7 @@ var releaseInfo = getReleaseInfo();
|
|
|
14
16
|
export var useDesktopRangePicker = function useDesktopRangePicker(_ref) {
|
|
15
17
|
var _fieldType, _slots$layout;
|
|
16
18
|
var props = _ref.props,
|
|
17
|
-
|
|
18
|
-
validator = _ref.validator;
|
|
19
|
+
pickerParams = _objectWithoutProperties(_ref, _excluded);
|
|
19
20
|
useLicenseVerifier('x-date-pickers-pro', releaseInfo);
|
|
20
21
|
var slots = props.slots,
|
|
21
22
|
slotProps = props.slotProps,
|
|
@@ -36,17 +37,15 @@ export var useDesktopRangePicker = function useDesktopRangePicker(_ref) {
|
|
|
36
37
|
rangePosition = _useRangePosition.rangePosition,
|
|
37
38
|
onRangePositionChange = _useRangePosition.onRangePositionChange,
|
|
38
39
|
singleInputFieldRef = _useRangePosition.singleInputFieldRef;
|
|
39
|
-
var _usePicker = usePicker({
|
|
40
|
+
var _usePicker = usePicker(_extends({}, pickerParams, {
|
|
40
41
|
props: props,
|
|
41
|
-
valueManager: valueManager,
|
|
42
42
|
wrapperVariant: 'desktop',
|
|
43
|
-
validator: validator,
|
|
44
43
|
autoFocusView: true,
|
|
45
44
|
additionalViewProps: {
|
|
46
45
|
rangePosition: rangePosition,
|
|
47
46
|
onRangePositionChange: onRangePositionChange
|
|
48
47
|
}
|
|
49
|
-
}),
|
|
48
|
+
})),
|
|
50
49
|
open = _usePicker.open,
|
|
51
50
|
actions = _usePicker.actions,
|
|
52
51
|
layoutProps = _usePicker.layoutProps,
|