@mui/x-date-pickers-pro 6.0.3 → 6.1.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.
Files changed (111) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/DateRangeCalendar/useDragRange.d.ts +1 -1
  3. package/DateRangePicker/DateRangePicker.js +12 -0
  4. package/DateRangePicker/DateRangePickerToolbar.d.ts +1 -1
  5. package/DateRangePicker/shared.d.ts +1 -1
  6. package/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
  7. package/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
  8. package/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -0
  9. package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +1 -1
  10. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -0
  11. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +1 -1
  12. package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -0
  13. package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +1 -1
  14. package/README.md +2 -2
  15. package/SingleInputDateRangeField/SingleInputDateRangeField.d.ts +1 -0
  16. package/SingleInputDateRangeField/SingleInputDateRangeField.js +23 -11
  17. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.d.ts +1 -0
  18. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +27 -15
  19. package/SingleInputTimeRangeField/SingleInputTimeRangeField.d.ts +1 -0
  20. package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +27 -15
  21. package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +1 -1
  22. package/index.js +1 -1
  23. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +1 -1
  24. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +32 -40
  25. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +9 -29
  26. package/internal/hooks/useEnrichedRangePickerFieldProps.d.ts +53 -0
  27. package/internal/hooks/useEnrichedRangePickerFieldProps.js +202 -0
  28. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +1 -1
  29. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +36 -39
  30. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +9 -28
  31. package/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.d.ts +1 -1
  32. package/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.d.ts +1 -1
  33. package/internal/hooks/useMultiInputRangeField/useMultiInputRangeField.types.d.ts +3 -3
  34. package/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.d.ts +1 -1
  35. package/internal/hooks/useRangePosition.d.ts +4 -0
  36. package/internal/hooks/useRangePosition.js +16 -1
  37. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +1 -1
  38. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +3 -2
  39. package/internal/hooks/validation/useDateRangeValidation.d.ts +2 -1
  40. package/internal/hooks/validation/useDateTimeRangeValidation.d.ts +2 -1
  41. package/internal/hooks/validation/useTimeRangeValidation.d.ts +2 -1
  42. package/internal/models/fields.d.ts +7 -2
  43. package/internal/models/index.d.ts +1 -0
  44. package/internal/models/index.js +2 -1
  45. package/internal/models/rangePickerProps.d.ts +17 -0
  46. package/internal/models/rangePickerProps.js +1 -0
  47. package/internal/utils/date-range-manager.d.ts +1 -1
  48. package/internal/utils/date-utils.d.ts +1 -1
  49. package/internal/utils/releaseInfo.js +1 -1
  50. package/internal/utils/valueManagers.d.ts +1 -1
  51. package/internal/utils/valueManagers.js +23 -21
  52. package/legacy/DateRangePicker/DateRangePicker.js +12 -0
  53. package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
  54. package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
  55. package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -0
  56. package/legacy/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -0
  57. package/legacy/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -0
  58. package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.js +20 -10
  59. package/legacy/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +24 -14
  60. package/legacy/SingleInputTimeRangeField/SingleInputTimeRangeField.js +24 -14
  61. package/legacy/index.js +1 -1
  62. package/legacy/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +32 -40
  63. package/legacy/internal/hooks/useEnrichedRangePickerFieldProps.js +200 -0
  64. package/legacy/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +36 -39
  65. package/legacy/internal/hooks/useRangePosition.js +16 -1
  66. package/legacy/internal/models/index.js +2 -1
  67. package/legacy/internal/models/rangePickerProps.js +1 -0
  68. package/legacy/internal/utils/releaseInfo.js +1 -1
  69. package/legacy/internal/utils/valueManagers.js +24 -22
  70. package/modern/DateRangePicker/DateRangePicker.js +12 -0
  71. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
  72. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
  73. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -0
  74. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -0
  75. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -0
  76. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +23 -11
  77. package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +27 -15
  78. package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +27 -15
  79. package/modern/index.js +1 -1
  80. package/modern/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +30 -38
  81. package/modern/internal/hooks/useEnrichedRangePickerFieldProps.js +195 -0
  82. package/modern/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +35 -38
  83. package/modern/internal/hooks/useRangePosition.js +16 -1
  84. package/modern/internal/models/index.js +2 -1
  85. package/modern/internal/models/rangePickerProps.js +1 -0
  86. package/modern/internal/utils/releaseInfo.js +1 -1
  87. package/modern/internal/utils/valueManagers.js +23 -21
  88. package/node/DateRangePicker/DateRangePicker.js +12 -0
  89. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
  90. package/node/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
  91. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -0
  92. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -0
  93. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -0
  94. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +23 -11
  95. package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +26 -14
  96. package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +26 -14
  97. package/node/index.js +1 -1
  98. package/node/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +29 -37
  99. package/node/internal/hooks/useEnrichedRangePickerFieldProps.js +205 -0
  100. package/node/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +34 -37
  101. package/node/internal/hooks/useRangePosition.js +18 -1
  102. package/node/internal/models/index.js +11 -0
  103. package/node/internal/models/rangePickerProps.js +5 -0
  104. package/node/internal/utils/releaseInfo.js +1 -1
  105. package/node/internal/utils/valueManagers.js +22 -20
  106. package/package.json +5 -5
  107. package/internal/hooks/useRangePickerInputProps.d.ts +0 -19
  108. package/internal/hooks/useRangePickerInputProps.js +0 -89
  109. package/legacy/internal/hooks/useRangePickerInputProps.js +0 -88
  110. package/modern/internal/hooks/useRangePickerInputProps.js +0 -86
  111. package/node/internal/hooks/useRangePickerInputProps.js +0 -96
@@ -1,12 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { resolveComponentProps, useSlotProps } from '@mui/base/utils';
3
+ import { useSlotProps } from '@mui/base/utils';
4
4
  import { useLicenseVerifier } from '@mui/x-license-pro';
5
5
  import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
6
6
  import { PickersLayout } from '@mui/x-date-pickers/PickersLayout';
7
7
  import { usePicker, PickersModalDialog, useLocaleText } from '@mui/x-date-pickers/internals';
8
8
  import useId from '@mui/utils/useId';
9
- import { useRangePickerInputProps } from '../useRangePickerInputProps';
9
+ import { useEnrichedRangePickerFieldProps } from '../useEnrichedRangePickerFieldProps';
10
10
  import { getReleaseInfo } from '../../utils/releaseInfo';
11
11
  import { useRangePosition } from '../useRangePosition';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -24,6 +24,8 @@ export const useMobileRangePicker = ({
24
24
  className,
25
25
  sx,
26
26
  format,
27
+ label,
28
+ inputRef,
27
29
  readOnly,
28
30
  disabled,
29
31
  disableOpenPicker,
@@ -31,7 +33,8 @@ export const useMobileRangePicker = ({
31
33
  } = props;
32
34
  const {
33
35
  rangePosition,
34
- onRangePositionChange
36
+ onRangePositionChange,
37
+ singleInputFieldRef
35
38
  } = useRangePosition(props);
36
39
  const labelId = useId();
37
40
  const contextLocaleText = useLocaleText();
@@ -52,18 +55,8 @@ export const useMobileRangePicker = ({
52
55
  onRangePositionChange
53
56
  }
54
57
  });
55
- const fieldSlotProps = useRangePickerInputProps({
56
- wrapperVariant: 'mobile',
57
- open,
58
- actions,
59
- readOnly,
60
- disabled,
61
- disableOpenPicker,
62
- localeText,
63
- rangePosition,
64
- onRangePositionChange
65
- });
66
58
  const Field = slots.field;
59
+ const fieldType = Field.fieldType ?? 'multi-input';
67
60
  const fieldProps = useSlotProps({
68
61
  elementType: Field,
69
62
  externalSlotProps: innerSlotProps?.field,
@@ -73,25 +66,28 @@ export const useMobileRangePicker = ({
73
66
  className,
74
67
  sx,
75
68
  format
69
+ }, fieldType === 'single-input' && {
70
+ inputRef
76
71
  }),
77
72
  ownerState: props
78
73
  });
79
- const slotsForField = _extends({
80
- textField: slots.textField
81
- }, fieldProps.slots);
82
74
  const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
83
- const slotPropsForField = _extends({}, fieldProps.slotProps, {
84
- textField: ownerState => {
85
- const externalInputProps = resolveComponentProps(innerSlotProps?.textField, ownerState);
86
- return _extends({}, isToolbarHidden && {
87
- id: `${labelId}-${ownerState.position}`
88
- }, ownerState.position === 'start' ? fieldSlotProps.startInput : fieldSlotProps.endInput, externalInputProps);
89
- },
90
- root: ownerState => {
91
- const externalRootProps = resolveComponentProps(innerSlotProps?.fieldRoot, ownerState);
92
- return _extends({}, externalRootProps, fieldSlotProps.root);
93
- },
94
- separator: innerSlotProps?.fieldSeparator
75
+ const enrichedFieldProps = useEnrichedRangePickerFieldProps({
76
+ wrapperVariant: 'mobile',
77
+ fieldType,
78
+ open,
79
+ actions,
80
+ readOnly,
81
+ labelId,
82
+ disableOpenPicker,
83
+ label,
84
+ localeText,
85
+ rangePosition,
86
+ onRangePositionChange,
87
+ singleInputFieldRef,
88
+ pickerSlots: slots,
89
+ pickerSlotProps: innerSlotProps,
90
+ fieldProps
95
91
  });
96
92
  const slotPropsForLayout = _extends({}, innerSlotProps, {
97
93
  toolbar: _extends({}, innerSlotProps?.toolbar, {
@@ -105,11 +101,15 @@ export const useMobileRangePicker = ({
105
101
  let labelledById = labelId;
106
102
  if (isToolbarHidden) {
107
103
  const labels = [];
108
- if (finalLocaleText.start) {
109
- labels.push(`${labelId}-start-label`);
110
- }
111
- if (finalLocaleText.end) {
112
- labels.push(`${labelId}-end-label`);
104
+ if (fieldType === 'multi-input') {
105
+ if (finalLocaleText.start) {
106
+ labels.push(`${labelId}-start-label`);
107
+ }
108
+ if (finalLocaleText.end) {
109
+ labels.push(`${labelId}-end-label`);
110
+ }
111
+ } else if (label != null) {
112
+ labels.push(`${labelId}-label`);
113
113
  }
114
114
  labelledById = labels.length > 0 ? labels.join(' ') : undefined;
115
115
  }
@@ -120,10 +120,7 @@ export const useMobileRangePicker = ({
120
120
  });
121
121
  const renderPicker = () => /*#__PURE__*/_jsxs(LocalizationProvider, {
122
122
  localeText: localeText,
123
- children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
124
- slots: slotsForField,
125
- slotProps: slotPropsForField
126
- })), /*#__PURE__*/_jsx(PickersModalDialog, _extends({}, actions, {
123
+ children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersModalDialog, _extends({}, actions, {
127
124
  open: open,
128
125
  slots: slots,
129
126
  slotProps: slotProps,
@@ -1,18 +1,33 @@
1
+ import * as React from 'react';
1
2
  import useControlled from '@mui/utils/useControlled';
2
3
  import useEventCallback from '@mui/utils/useEventCallback';
3
4
  export const useRangePosition = props => {
5
+ const singleInputFieldRef = React.useRef();
4
6
  const [rangePosition, setRangePosition] = useControlled({
5
7
  name: 'useRangePosition',
6
8
  state: 'rangePosition',
7
9
  controlled: props.rangePosition,
8
10
  default: props.defaultRangePosition ?? 'start'
9
11
  });
12
+
13
+ // When using a single input field,
14
+ // we want to select the 1st section of the edited date when updating the range position.
15
+ const syncRangePositionWithSingleInputField = newRangePosition => {
16
+ if (singleInputFieldRef.current == null) {
17
+ return;
18
+ }
19
+ const sections = singleInputFieldRef.current.getSections();
20
+ const targetActiveSectionIndex = newRangePosition === 'start' ? 0 : sections.length / 2;
21
+ singleInputFieldRef.current.setSelectedSections(targetActiveSectionIndex);
22
+ };
10
23
  const handleRangePositionChange = useEventCallback(newRangePosition => {
11
24
  setRangePosition(newRangePosition);
12
25
  props.onRangePositionChange?.(newRangePosition);
26
+ syncRangePositionWithSingleInputField(newRangePosition);
13
27
  });
14
28
  return {
15
29
  rangePosition,
16
- onRangePositionChange: handleRangePositionChange
30
+ onRangePositionChange: handleRangePositionChange,
31
+ singleInputFieldRef
17
32
  };
18
33
  };
@@ -2,4 +2,5 @@ export * from './dateRange';
2
2
  export * from './range';
3
3
  export * from './dateTimeRange';
4
4
  export * from './timeRange';
5
- export * from './fields';
5
+ export * from './fields';
6
+ export * from './rangePickerProps';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTY3OTUyNjAwMDAwMA==";
3
+ const releaseInfo = "MTY4MTA3NDAwMDAwMA==";
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
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { replaceInvalidDateByNull, splitFormatIntoSections, addPositionPropertiesToSections, createDateStrForInputFromSections, areDatesEqual } from '@mui/x-date-pickers/internals';
2
+ import { replaceInvalidDateByNull, addPositionPropertiesToSections, createDateStrForInputFromSections, areDatesEqual } from '@mui/x-date-pickers/internals';
3
3
  import { splitDateRangeSections, removeLastSeparator } from './date-fields-utils';
4
4
  export const rangeValueManager = {
5
5
  emptyValue: [null, null],
@@ -7,6 +7,7 @@ export const rangeValueManager = {
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],
10
+ hasError: error => error[0] != null || error[1] != null,
10
11
  defaultErrorState: [null, null]
11
12
  };
12
13
  export const rangeFieldValueManager = {
@@ -24,17 +25,17 @@ export const rangeFieldValueManager = {
24
25
  }
25
26
  return [prevReferenceValue[1], value[1]];
26
27
  },
27
- getSectionsFromValue: (utils, localeText, prevSections, [start, end], format) => {
28
- const prevDateRangeSections = prevSections == null ? {
28
+ getSectionsFromValue: (utils, [start, end], fallbackSections, isRTL, getSectionsFromDate) => {
29
+ const separatedFallbackSections = fallbackSections == null ? {
29
30
  startDate: null,
30
31
  endDate: null
31
- } : splitDateRangeSections(prevSections);
32
- const getSections = (newDate, prevDateSections, position) => {
33
- const shouldReUsePrevDateSections = !utils.isValid(newDate) && !!prevDateSections;
32
+ } : splitDateRangeSections(fallbackSections);
33
+ const getSections = (newDate, fallbackDateSections, position) => {
34
+ const shouldReUsePrevDateSections = !utils.isValid(newDate) && !!fallbackDateSections;
34
35
  if (shouldReUsePrevDateSections) {
35
- return prevDateSections;
36
+ return fallbackDateSections;
36
37
  }
37
- const sections = splitFormatIntoSections(utils, localeText, format, newDate);
38
+ const sections = getSectionsFromDate(newDate);
38
39
  return sections.map((section, sectionIndex) => {
39
40
  if (sectionIndex === sections.length - 1 && position === 'start') {
40
41
  return _extends({}, section, {
@@ -47,16 +48,11 @@ export const rangeFieldValueManager = {
47
48
  });
48
49
  });
49
50
  };
50
- return addPositionPropertiesToSections([...getSections(start, prevDateRangeSections.startDate, 'start'), ...getSections(end, prevDateRangeSections.endDate, 'end')]);
51
+ return addPositionPropertiesToSections([...getSections(start, separatedFallbackSections.startDate, 'start'), ...getSections(end, separatedFallbackSections.endDate, 'end')], isRTL);
51
52
  },
52
- getValueStrFromSections: sections => {
53
+ getValueStrFromSections: (sections, isRTL) => {
53
54
  const dateRangeSections = splitDateRangeSections(sections);
54
- return createDateStrForInputFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate]);
55
- },
56
- getActiveDateSections: (sections, activeSection) => {
57
- const index = activeSection.dateName === 'start' ? 0 : 1;
58
- const dateRangeSections = splitDateRangeSections(sections);
59
- return index === 0 ? removeLastSeparator(dateRangeSections.startDate) : dateRangeSections.endDate;
55
+ return createDateStrForInputFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate], isRTL);
60
56
  },
61
57
  parseValueStr: (valueStr, referenceValue, parseDate) => {
62
58
  // TODO: Improve because it would not work if the date format has `–` as a separator.
@@ -72,13 +68,19 @@ export const rangeFieldValueManager = {
72
68
  const index = activeSection.dateName === 'start' ? 0 : 1;
73
69
  const updateDateInRange = (newDate, prevDateRange) => index === 0 ? [newDate, prevDateRange[1]] : [prevDateRange[0], newDate];
74
70
  return {
75
- activeDate: state.value[index],
76
- referenceActiveDate: state.referenceValue[index],
77
- getNewValueFromNewActiveDate: newActiveDate => ({
71
+ date: state.value[index],
72
+ referenceDate: state.referenceValue[index],
73
+ getSections: sections => {
74
+ const dateRangeSections = splitDateRangeSections(sections);
75
+ if (index === 0) {
76
+ return removeLastSeparator(dateRangeSections.startDate);
77
+ }
78
+ return dateRangeSections.endDate;
79
+ },
80
+ getNewValuesFromNewActiveDate: newActiveDate => ({
78
81
  value: updateDateInRange(newActiveDate, state.value),
79
82
  referenceValue: newActiveDate == null || !utils.isValid(newActiveDate) ? state.referenceValue : updateDateInRange(newActiveDate, state.referenceValue)
80
83
  })
81
84
  };
82
- },
83
- hasError: error => error[0] != null || error[1] != null
85
+ }
84
86
  };
@@ -157,6 +157,18 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
157
157
  * Defaults to localized format based on the used `views`.
158
158
  */
159
159
  format: _propTypes.default.string,
160
+ /**
161
+ * Pass a ref to the `input` element.
162
+ * Ignored if the field has several inputs.
163
+ */
164
+ inputRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
165
+ current: _propTypes.default.object
166
+ })]),
167
+ /**
168
+ * The label content.
169
+ * Ignored if the field has several inputs.
170
+ */
171
+ label: _propTypes.default.node,
160
172
  /**
161
173
  * If `true`, calls `renderLoading` instead of rendering the day calendar.
162
174
  * Can be used to preload information and show it in calendar.
@@ -161,6 +161,18 @@ DesktopDateRangePicker.propTypes = {
161
161
  * Defaults to localized format based on the used `views`.
162
162
  */
163
163
  format: _propTypes.default.string,
164
+ /**
165
+ * Pass a ref to the `input` element.
166
+ * Ignored if the field has several inputs.
167
+ */
168
+ inputRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
169
+ current: _propTypes.default.object
170
+ })]),
171
+ /**
172
+ * The label content.
173
+ * Ignored if the field has several inputs.
174
+ */
175
+ label: _propTypes.default.node,
164
176
  /**
165
177
  * If `true`, calls `renderLoading` instead of rendering the day calendar.
166
178
  * Can be used to preload information and show it in calendar.
@@ -164,6 +164,18 @@ MobileDateRangePicker.propTypes = {
164
164
  * Defaults to localized format based on the used `views`.
165
165
  */
166
166
  format: _propTypes.default.string,
167
+ /**
168
+ * Pass a ref to the `input` element.
169
+ * Ignored if the field has several inputs.
170
+ */
171
+ inputRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
172
+ current: _propTypes.default.object
173
+ })]),
174
+ /**
175
+ * The label content.
176
+ * Ignored if the field has several inputs.
177
+ */
178
+ label: _propTypes.default.node,
167
179
  /**
168
180
  * If `true`, calls `renderLoading` instead of rendering the day calendar.
169
181
  * Can be used to preload information and show it in calendar.
@@ -294,6 +294,16 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
294
294
  sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
295
295
  unstableEndFieldRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
296
296
  unstableStartFieldRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
297
+ /**
298
+ * If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
299
+ *
300
+ * While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack#limitations),
301
+ * it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
302
+ *
303
+ * To enable this flag globally, follow the [theme's default props](https://mui.com/material-ui/customization/theme-components/#default-props) configuration.
304
+ * @default false
305
+ */
306
+ useFlexGap: _propTypes.default.bool,
297
307
  /**
298
308
  * The selected value.
299
309
  * Used when the component is controlled.
@@ -360,6 +360,16 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
360
360
  sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
361
361
  unstableEndFieldRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
362
362
  unstableStartFieldRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
363
+ /**
364
+ * If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
365
+ *
366
+ * While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack#limitations),
367
+ * it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
368
+ *
369
+ * To enable this flag globally, follow the [theme's default props](https://mui.com/material-ui/customization/theme-components/#default-props) configuration.
370
+ * @default false
371
+ */
372
+ useFlexGap: _propTypes.default.bool,
363
373
  /**
364
374
  * The selected value.
365
375
  * Used when the component is controlled.
@@ -326,6 +326,16 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
326
326
  sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
327
327
  unstableEndFieldRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
328
328
  unstableStartFieldRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
329
+ /**
330
+ * If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
331
+ *
332
+ * While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack#limitations),
333
+ * it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
334
+ *
335
+ * To enable this flag globally, follow the [theme's default props](https://mui.com/material-ui/customization/theme-components/#default-props) configuration.
336
+ * @default false
337
+ */
338
+ useFlexGap: _propTypes.default.bool,
329
339
  /**
330
340
  * The selected value.
331
341
  * Used when the component is controlled.
@@ -14,8 +14,9 @@ var _styles = require("@mui/material/styles");
14
14
  var _utils = require("@mui/base/utils");
15
15
  var _useSingleInputDateRangeField = require("./useSingleInputDateRangeField");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
- const _excluded = ["slots", "slotProps", "components", "componentsProps"],
18
- _excluded2 = ["ref", "onPaste", "inputMode", "readOnly"];
17
+ const _excluded = ["slots", "slotProps", "components", "componentsProps", "InputProps", "inputProps"],
18
+ _excluded2 = ["inputRef"],
19
+ _excluded3 = ["ref", "onPaste", "inputMode", "readOnly"];
19
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
21
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
22
  const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleInputDateRangeField(inProps, ref) {
@@ -27,20 +28,30 @@ const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleI
27
28
  slots,
28
29
  slotProps,
29
30
  components,
30
- componentsProps
31
+ componentsProps,
32
+ InputProps,
33
+ inputProps
31
34
  } = themeProps,
32
35
  other = (0, _objectWithoutPropertiesLoose2.default)(themeProps, _excluded);
33
36
  const ownerState = themeProps;
34
37
  const TextField = slots?.textField ?? components?.TextField ?? _TextField.default;
35
- const textFieldProps = (0, _utils.useSlotProps)({
36
- elementType: TextField,
37
- externalSlotProps: slotProps?.textField ?? componentsProps?.textField,
38
- externalForwardedProps: other,
39
- ownerState
40
- });
38
+ const _useSlotProps = (0, _utils.useSlotProps)({
39
+ elementType: TextField,
40
+ externalSlotProps: slotProps?.textField ?? componentsProps?.textField,
41
+ externalForwardedProps: other,
42
+ ownerState
43
+ }),
44
+ {
45
+ inputRef: externalInputRef
46
+ } = _useSlotProps,
47
+ textFieldProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded2);
48
+
49
+ // TODO: Remove when mui/material-ui#35088 will be merged
50
+ textFieldProps.inputProps = (0, _extends2.default)({}, textFieldProps.inputProps, inputProps);
51
+ textFieldProps.InputProps = (0, _extends2.default)({}, textFieldProps.InputProps, InputProps);
41
52
  const _useSingleInputDateRa = (0, _useSingleInputDateRangeField.useSingleInputDateRangeField)({
42
53
  props: textFieldProps,
43
- inputRef: textFieldProps.inputRef
54
+ inputRef: externalInputRef
44
55
  }),
45
56
  {
46
57
  ref: inputRef,
@@ -48,7 +59,7 @@ const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleI
48
59
  inputMode,
49
60
  readOnly
50
61
  } = _useSingleInputDateRa,
51
- fieldProps = (0, _objectWithoutPropertiesLoose2.default)(_useSingleInputDateRa, _excluded2);
62
+ fieldProps = (0, _objectWithoutPropertiesLoose2.default)(_useSingleInputDateRa, _excluded3);
52
63
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(TextField, (0, _extends2.default)({
53
64
  ref: ref
54
65
  }, fieldProps, {
@@ -61,6 +72,7 @@ const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleI
61
72
  }));
62
73
  });
63
74
  exports.SingleInputDateRangeField = SingleInputDateRangeField;
75
+ SingleInputDateRangeField.fieldType = 'single-input';
64
76
  process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
65
77
  // ----------------------------- Warning --------------------------------
66
78
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -14,8 +14,9 @@ var _styles = require("@mui/material/styles");
14
14
  var _utils = require("@mui/base/utils");
15
15
  var _useSingleInputDateTimeRangeField = require("./useSingleInputDateTimeRangeField");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
- const _excluded = ["slots", "slotProps", "components", "componentsProps"],
18
- _excluded2 = ["ref", "onPaste", "inputMode", "readOnly"];
17
+ const _excluded = ["slots", "slotProps", "components", "componentsProps", "InputProps", "inputProps"],
18
+ _excluded2 = ["inputRef"],
19
+ _excluded3 = ["ref", "onPaste", "inputMode", "readOnly"];
19
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
21
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
22
  const SingleInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleInputDateTimeRangeField(inProps, ref) {
@@ -27,20 +28,30 @@ const SingleInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Sin
27
28
  slots,
28
29
  slotProps,
29
30
  components,
30
- componentsProps
31
+ componentsProps,
32
+ InputProps,
33
+ inputProps
31
34
  } = themeProps,
32
35
  other = (0, _objectWithoutPropertiesLoose2.default)(themeProps, _excluded);
33
36
  const ownerState = themeProps;
34
- const Input = slots?.textField ?? components?.TextField ?? _TextField.default;
35
- const inputProps = (0, _utils.useSlotProps)({
36
- elementType: Input,
37
- externalSlotProps: slotProps?.textField ?? componentsProps?.textField,
38
- externalForwardedProps: other,
39
- ownerState
40
- });
37
+ const TextField = slots?.textField ?? components?.TextField ?? _TextField.default;
38
+ const _useSlotProps = (0, _utils.useSlotProps)({
39
+ elementType: TextField,
40
+ externalSlotProps: slotProps?.textField ?? componentsProps?.textField,
41
+ externalForwardedProps: other,
42
+ ownerState
43
+ }),
44
+ {
45
+ inputRef: externalInputRef
46
+ } = _useSlotProps,
47
+ textFieldProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded2);
48
+
49
+ // TODO: Remove when mui/material-ui#35088 will be merged
50
+ textFieldProps.inputProps = (0, _extends2.default)({}, textFieldProps.inputProps, inputProps);
51
+ textFieldProps.InputProps = (0, _extends2.default)({}, textFieldProps.InputProps, InputProps);
41
52
  const _useSingleInputDateTi = (0, _useSingleInputDateTimeRangeField.useSingleInputDateTimeRangeField)({
42
- props: inputProps,
43
- inputRef: inputProps.inputRef
53
+ props: textFieldProps,
54
+ inputRef: externalInputRef
44
55
  }),
45
56
  {
46
57
  ref: inputRef,
@@ -48,8 +59,8 @@ const SingleInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Sin
48
59
  inputMode,
49
60
  readOnly
50
61
  } = _useSingleInputDateTi,
51
- fieldProps = (0, _objectWithoutPropertiesLoose2.default)(_useSingleInputDateTi, _excluded2);
52
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Input, (0, _extends2.default)({
62
+ fieldProps = (0, _objectWithoutPropertiesLoose2.default)(_useSingleInputDateTi, _excluded3);
63
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(TextField, (0, _extends2.default)({
53
64
  ref: ref
54
65
  }, fieldProps, {
55
66
  inputProps: (0, _extends2.default)({}, fieldProps.inputProps, {
@@ -61,6 +72,7 @@ const SingleInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Sin
61
72
  }));
62
73
  });
63
74
  exports.SingleInputDateTimeRangeField = SingleInputDateTimeRangeField;
75
+ SingleInputDateTimeRangeField.fieldType = 'single-input';
64
76
  process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes = {
65
77
  // ----------------------------- Warning --------------------------------
66
78
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -14,8 +14,9 @@ var _styles = require("@mui/material/styles");
14
14
  var _utils = require("@mui/base/utils");
15
15
  var _useSingleInputTimeRangeField = require("./useSingleInputTimeRangeField");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
- const _excluded = ["slots", "slotProps", "components", "componentsProps"],
18
- _excluded2 = ["ref", "onPaste", "inputMode", "readOnly"];
17
+ const _excluded = ["slots", "slotProps", "components", "componentsProps", "InputProps", "inputProps"],
18
+ _excluded2 = ["inputRef"],
19
+ _excluded3 = ["ref", "onPaste", "inputMode", "readOnly"];
19
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
21
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
22
  const SingleInputTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleInputTimeRangeField(inProps, ref) {
@@ -27,20 +28,30 @@ const SingleInputTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleI
27
28
  slots,
28
29
  slotProps,
29
30
  components,
30
- componentsProps
31
+ componentsProps,
32
+ InputProps,
33
+ inputProps
31
34
  } = themeProps,
32
35
  other = (0, _objectWithoutPropertiesLoose2.default)(themeProps, _excluded);
33
36
  const ownerState = themeProps;
34
- const Input = slots?.textField ?? components?.TextField ?? _TextField.default;
35
- const inputProps = (0, _utils.useSlotProps)({
36
- elementType: Input,
37
- externalSlotProps: slotProps?.textField ?? componentsProps?.textField,
38
- externalForwardedProps: other,
39
- ownerState
40
- });
37
+ const TextField = slots?.textField ?? components?.TextField ?? _TextField.default;
38
+ const _useSlotProps = (0, _utils.useSlotProps)({
39
+ elementType: TextField,
40
+ externalSlotProps: slotProps?.textField ?? componentsProps?.textField,
41
+ externalForwardedProps: other,
42
+ ownerState
43
+ }),
44
+ {
45
+ inputRef: externalInputRef
46
+ } = _useSlotProps,
47
+ textFieldProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded2);
48
+
49
+ // TODO: Remove when mui/material-ui#35088 will be merged
50
+ textFieldProps.inputProps = (0, _extends2.default)({}, textFieldProps.inputProps, inputProps);
51
+ textFieldProps.InputProps = (0, _extends2.default)({}, textFieldProps.InputProps, InputProps);
41
52
  const _useSingleInputTimeRa = (0, _useSingleInputTimeRangeField.useSingleInputTimeRangeField)({
42
- props: inputProps,
43
- inputRef: inputProps.inputRef
53
+ props: textFieldProps,
54
+ inputRef: externalInputRef
44
55
  }),
45
56
  {
46
57
  ref: inputRef,
@@ -48,8 +59,8 @@ const SingleInputTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleI
48
59
  inputMode,
49
60
  readOnly
50
61
  } = _useSingleInputTimeRa,
51
- fieldProps = (0, _objectWithoutPropertiesLoose2.default)(_useSingleInputTimeRa, _excluded2);
52
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Input, (0, _extends2.default)({
62
+ fieldProps = (0, _objectWithoutPropertiesLoose2.default)(_useSingleInputTimeRa, _excluded3);
63
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(TextField, (0, _extends2.default)({
53
64
  ref: ref
54
65
  }, fieldProps, {
55
66
  inputProps: (0, _extends2.default)({}, fieldProps.inputProps, {
@@ -61,6 +72,7 @@ const SingleInputTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleI
61
72
  }));
62
73
  });
63
74
  exports.SingleInputTimeRangeField = SingleInputTimeRangeField;
75
+ SingleInputTimeRangeField.fieldType = 'single-input';
64
76
  process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
65
77
  // ----------------------------- Warning --------------------------------
66
78
  // | These PropTypes are generated from the TypeScript type definitions |
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers-pro v6.0.3
2
+ * @mui/x-date-pickers-pro v6.1.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the