@mui/lab 5.0.0-alpha.53 → 5.0.0-alpha.54

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 (144) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/CalendarPicker/CalendarPicker.d.ts +10 -0
  3. package/CalendarPicker/CalendarPicker.js +12 -0
  4. package/CalendarPicker/PickersCalendar.d.ts +2 -0
  5. package/CalendarPicker/PickersCalendar.js +9 -3
  6. package/CalendarPicker/PickersCalendarHeader.d.ts +1 -0
  7. package/CalendarPicker/PickersCalendarHeader.js +5 -4
  8. package/CalendarPickerSkeleton/CalendarPickerSkeleton.js +1 -1
  9. package/DatePicker/DatePicker.js +2 -0
  10. package/DateRangePicker/DateRangePicker.js +2 -0
  11. package/DateRangePickerDay/DateRangePickerDay.js +1 -1
  12. package/DateTimePicker/DateTimePicker.js +2 -0
  13. package/DesktopDatePicker/DesktopDatePicker.js +2 -0
  14. package/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -0
  15. package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -0
  16. package/LICENSE +21 -21
  17. package/LoadingButton/LoadingButton.js +1 -1
  18. package/Masonry/Masonry.js +15 -52
  19. package/MobileDatePicker/MobileDatePicker.js +2 -0
  20. package/MobileDateRangePicker/MobileDateRangePicker.js +2 -0
  21. package/MobileDateTimePicker/MobileDateTimePicker.js +2 -0
  22. package/MonthPicker/MonthPicker.d.ts +4 -0
  23. package/MonthPicker/MonthPicker.js +20 -4
  24. package/PickersDay/PickersDay.js +1 -1
  25. package/StaticDatePicker/StaticDatePicker.js +2 -0
  26. package/StaticDateRangePicker/StaticDateRangePicker.js +2 -0
  27. package/StaticDateTimePicker/StaticDateTimePicker.js +2 -0
  28. package/TabPanel/TabPanel.js +1 -1
  29. package/Timeline/Timeline.js +1 -1
  30. package/TimelineConnector/TimelineConnector.js +1 -1
  31. package/TimelineContent/TimelineContent.js +1 -1
  32. package/TimelineDot/TimelineDot.js +1 -1
  33. package/TimelineItem/TimelineItem.js +1 -1
  34. package/TimelineOppositeContent/TimelineOppositeContent.js +1 -1
  35. package/TimelineSeparator/TimelineSeparator.js +1 -1
  36. package/TreeItem/TreeItem.js +1 -1
  37. package/TreeView/TreeView.js +1 -1
  38. package/YearPicker/YearPicker.d.ts +2 -0
  39. package/YearPicker/YearPicker.js +17 -1
  40. package/index.js +1 -1
  41. package/internal/pickers/test-utils.js +4 -2
  42. package/legacy/CalendarPicker/CalendarPicker.js +12 -0
  43. package/legacy/CalendarPicker/PickersCalendar.js +10 -3
  44. package/legacy/CalendarPicker/PickersCalendarHeader.js +5 -4
  45. package/legacy/CalendarPickerSkeleton/CalendarPickerSkeleton.js +1 -1
  46. package/legacy/DatePicker/DatePicker.js +2 -0
  47. package/legacy/DateRangePicker/DateRangePicker.js +2 -0
  48. package/legacy/DateRangePickerDay/DateRangePickerDay.js +1 -1
  49. package/legacy/DateTimePicker/DateTimePicker.js +2 -0
  50. package/legacy/DesktopDatePicker/DesktopDatePicker.js +2 -0
  51. package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -0
  52. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -0
  53. package/legacy/LoadingButton/LoadingButton.js +1 -1
  54. package/legacy/Masonry/Masonry.js +15 -52
  55. package/legacy/MobileDatePicker/MobileDatePicker.js +2 -0
  56. package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +2 -0
  57. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +2 -0
  58. package/legacy/MonthPicker/MonthPicker.js +19 -3
  59. package/legacy/PickersDay/PickersDay.js +1 -1
  60. package/legacy/StaticDatePicker/StaticDatePicker.js +2 -0
  61. package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +2 -0
  62. package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +2 -0
  63. package/legacy/TabPanel/TabPanel.js +1 -1
  64. package/legacy/Timeline/Timeline.js +1 -1
  65. package/legacy/TimelineConnector/TimelineConnector.js +1 -1
  66. package/legacy/TimelineContent/TimelineContent.js +1 -1
  67. package/legacy/TimelineDot/TimelineDot.js +1 -1
  68. package/legacy/TimelineItem/TimelineItem.js +1 -1
  69. package/legacy/TimelineOppositeContent/TimelineOppositeContent.js +1 -1
  70. package/legacy/TimelineSeparator/TimelineSeparator.js +1 -1
  71. package/legacy/TreeItem/TreeItem.js +1 -1
  72. package/legacy/TreeView/TreeView.js +1 -1
  73. package/legacy/YearPicker/YearPicker.js +17 -1
  74. package/legacy/index.js +1 -1
  75. package/legacy/internal/pickers/test-utils.js +3 -2
  76. package/modern/CalendarPicker/CalendarPicker.js +12 -0
  77. package/modern/CalendarPicker/PickersCalendar.js +9 -3
  78. package/modern/CalendarPicker/PickersCalendarHeader.js +5 -4
  79. package/modern/CalendarPickerSkeleton/CalendarPickerSkeleton.js +1 -1
  80. package/modern/DatePicker/DatePicker.js +2 -0
  81. package/modern/DateRangePicker/DateRangePicker.js +2 -0
  82. package/modern/DateRangePickerDay/DateRangePickerDay.js +1 -1
  83. package/modern/DateTimePicker/DateTimePicker.js +2 -0
  84. package/modern/DesktopDatePicker/DesktopDatePicker.js +2 -0
  85. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -0
  86. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -0
  87. package/modern/LoadingButton/LoadingButton.js +1 -1
  88. package/modern/Masonry/Masonry.js +15 -52
  89. package/modern/MobileDatePicker/MobileDatePicker.js +2 -0
  90. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +2 -0
  91. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -0
  92. package/modern/MonthPicker/MonthPicker.js +20 -4
  93. package/modern/PickersDay/PickersDay.js +1 -1
  94. package/modern/StaticDatePicker/StaticDatePicker.js +2 -0
  95. package/modern/StaticDateRangePicker/StaticDateRangePicker.js +2 -0
  96. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +2 -0
  97. package/modern/TabPanel/TabPanel.js +1 -1
  98. package/modern/Timeline/Timeline.js +1 -1
  99. package/modern/TimelineConnector/TimelineConnector.js +1 -1
  100. package/modern/TimelineContent/TimelineContent.js +1 -1
  101. package/modern/TimelineDot/TimelineDot.js +1 -1
  102. package/modern/TimelineItem/TimelineItem.js +1 -1
  103. package/modern/TimelineOppositeContent/TimelineOppositeContent.js +1 -1
  104. package/modern/TimelineSeparator/TimelineSeparator.js +1 -1
  105. package/modern/TreeItem/TreeItem.js +1 -1
  106. package/modern/TreeView/TreeView.js +1 -1
  107. package/modern/YearPicker/YearPicker.js +17 -1
  108. package/modern/index.js +1 -1
  109. package/modern/internal/pickers/test-utils.js +4 -2
  110. package/node/CalendarPicker/CalendarPicker.js +12 -0
  111. package/node/CalendarPicker/PickersCalendar.js +9 -3
  112. package/node/CalendarPicker/PickersCalendarHeader.js +5 -4
  113. package/node/CalendarPickerSkeleton/CalendarPickerSkeleton.js +1 -1
  114. package/node/DatePicker/DatePicker.js +2 -0
  115. package/node/DateRangePicker/DateRangePicker.js +2 -0
  116. package/node/DateRangePickerDay/DateRangePickerDay.js +1 -1
  117. package/node/DateTimePicker/DateTimePicker.js +2 -0
  118. package/node/DesktopDatePicker/DesktopDatePicker.js +2 -0
  119. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -0
  120. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -0
  121. package/node/LoadingButton/LoadingButton.js +1 -1
  122. package/node/Masonry/Masonry.js +19 -53
  123. package/node/MobileDatePicker/MobileDatePicker.js +2 -0
  124. package/node/MobileDateRangePicker/MobileDateRangePicker.js +2 -0
  125. package/node/MobileDateTimePicker/MobileDateTimePicker.js +2 -0
  126. package/node/MonthPicker/MonthPicker.js +20 -4
  127. package/node/PickersDay/PickersDay.js +1 -1
  128. package/node/StaticDatePicker/StaticDatePicker.js +2 -0
  129. package/node/StaticDateRangePicker/StaticDateRangePicker.js +2 -0
  130. package/node/StaticDateTimePicker/StaticDateTimePicker.js +2 -0
  131. package/node/TabPanel/TabPanel.js +1 -1
  132. package/node/Timeline/Timeline.js +1 -1
  133. package/node/TimelineConnector/TimelineConnector.js +1 -1
  134. package/node/TimelineContent/TimelineContent.js +1 -1
  135. package/node/TimelineDot/TimelineDot.js +1 -1
  136. package/node/TimelineItem/TimelineItem.js +1 -1
  137. package/node/TimelineOppositeContent/TimelineOppositeContent.js +1 -1
  138. package/node/TimelineSeparator/TimelineSeparator.js +1 -1
  139. package/node/TreeItem/TreeItem.js +1 -1
  140. package/node/TreeView/TreeView.js +1 -1
  141. package/node/YearPicker/YearPicker.js +17 -1
  142. package/node/index.js +1 -1
  143. package/node/internal/pickers/test-utils.js +3 -1
  144. package/package.json +6 -5
@@ -12,6 +12,9 @@ import * as React from 'react';
12
12
  import { getMasonryUtilityClass } from './masonryClasses';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ export var parseToNumber = function parseToNumber(val) {
16
+ return Number(val.replace('px', ''));
17
+ };
15
18
 
16
19
  var useUtilityClasses = function useUtilityClasses(ownerState) {
17
20
  var classes = ownerState.classes;
@@ -19,44 +22,6 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
19
22
  root: ['root']
20
23
  };
21
24
  return composeClasses(slots, getMasonryUtilityClass, classes);
22
- }; // compute base for responsive values; e.g.,
23
- // [1,2,3] => {xs: true, sm: true, md: true}
24
- // {xs: 1, sm: 2, md: 3} => {xs: true, sm: true, md: true}
25
-
26
-
27
- var computeBreakpointsBase = function computeBreakpointsBase(breakpoints, prop) {
28
- var base = {};
29
-
30
- if (Array.isArray(prop)) {
31
- Object.keys(breakpoints.values).forEach(function (breakpoint, i, arr) {
32
- if (i < arr.length) {
33
- base[breakpoint] = true;
34
- }
35
- });
36
- } else {
37
- Object.keys(breakpoints.values).forEach(function (breakpoint) {
38
- if (prop[breakpoint] != null) {
39
- base[breakpoint] = true;
40
- }
41
- });
42
- }
43
-
44
- return base;
45
- }; // if prop is an array, convert to object; e.g.,
46
- // (base: {xs: true, sm: true, md: true}, prop: [1,2,3]) => {xs: 1, sm: 2, md: 3}
47
-
48
-
49
- var validatePropValues = function validatePropValues(base, prop) {
50
- var values = {};
51
-
52
- if (Array.isArray(prop)) {
53
- Object.keys(base).forEach(function (breakpoint, i) {
54
- values[breakpoint] = prop[i];
55
- });
56
- return values;
57
- }
58
-
59
- return prop;
60
25
  };
61
26
 
62
27
  export var getStyle = function getStyle(_ref) {
@@ -93,10 +58,9 @@ export var getStyle = function getStyle(_ref) {
93
58
  return _extends({}, styles, stylesSSR);
94
59
  }
95
60
 
96
- var spacingBreakpointsBase = computeBreakpointsBase(theme.breakpoints, ownerState.spacing);
97
61
  var spacingValues = resolveBreakpointValues({
98
- values: validatePropValues(spacingBreakpointsBase, ownerState.spacing),
99
- base: spacingBreakpointsBase
62
+ values: ownerState.spacing,
63
+ breakpoints: theme.breakpoints.values
100
64
  });
101
65
  var transformer = createUnarySpacing(theme);
102
66
 
@@ -116,10 +80,9 @@ export var getStyle = function getStyle(_ref) {
116
80
  styles = deepmerge(styles, handleBreakpoints({
117
81
  theme: theme
118
82
  }, spacingValues, spacingStyleFromPropValue));
119
- var columnBreakpointsBase = computeBreakpointsBase(theme.breakpoints, ownerState.columns);
120
83
  var columnValues = resolveBreakpointValues({
121
- values: validatePropValues(columnBreakpointsBase, ownerState.columns),
122
- base: columnBreakpointsBase
84
+ values: ownerState.columns,
85
+ breakpoints: theme.breakpoints.values
123
86
  });
124
87
 
125
88
  var columnStyleFromPropValue = function columnStyleFromPropValue(propValue) {
@@ -214,8 +177,8 @@ var Masonry = /*#__PURE__*/React.forwardRef(function Masonry(inProps, ref) {
214
177
  var parentWidth = masonryRef.current.clientWidth;
215
178
  var childWidth = masonryRef.current.firstChild.clientWidth;
216
179
  var firstChildComputedStyle = window.getComputedStyle(masonryRef.current.firstChild);
217
- var firstChildMarginLeft = Number(firstChildComputedStyle.marginLeft.replace('px', ''));
218
- var firstChildMarginRight = Number(firstChildComputedStyle.marginRight.replace('px', ''));
180
+ var firstChildMarginLeft = parseToNumber(firstChildComputedStyle.marginLeft);
181
+ var firstChildMarginRight = parseToNumber(firstChildComputedStyle.marginRight);
219
182
 
220
183
  if (parentWidth === 0 || childWidth === 0) {
221
184
  return;
@@ -230,10 +193,10 @@ var Masonry = /*#__PURE__*/React.forwardRef(function Masonry(inProps, ref) {
230
193
  }
231
194
 
232
195
  var childComputedStyle = window.getComputedStyle(child);
233
- var childMarginTop = Number(childComputedStyle.marginTop.replace('px', ''));
234
- var childMarginBottom = Number(childComputedStyle.marginBottom.replace('px', '')); // if any one of children isn't rendered yet, masonry's height shouldn't be computed yet
196
+ var childMarginTop = parseToNumber(childComputedStyle.marginTop);
197
+ var childMarginBottom = parseToNumber(childComputedStyle.marginBottom); // if any one of children isn't rendered yet, masonry's height shouldn't be computed yet
235
198
 
236
- var childHeight = child.clientHeight ? Math.ceil(child.clientHeight) + childMarginTop + childMarginBottom : 0;
199
+ var childHeight = parseToNumber(childComputedStyle.height) ? Math.ceil(parseToNumber(childComputedStyle.height)) + childMarginTop + childMarginBottom : 0;
237
200
 
238
201
  if (childHeight === 0) {
239
202
  skip = true;
@@ -268,7 +231,7 @@ var Masonry = /*#__PURE__*/React.forwardRef(function Masonry(inProps, ref) {
268
231
 
269
232
 
270
233
  if (typeof ResizeObserver === 'undefined') {
271
- return null;
234
+ return undefined;
272
235
  }
273
236
 
274
237
  var resizeObserver = new ResizeObserver(handleResize);
@@ -287,7 +250,7 @@ var Masonry = /*#__PURE__*/React.forwardRef(function Masonry(inProps, ref) {
287
250
  return function () {
288
251
  resizeObserver.disconnect();
289
252
  };
290
- }, [columns, spacing]);
253
+ }, [columns, spacing, children]);
291
254
  var handleRef = useForkRef(ref, masonryRef);
292
255
  var lineBreakStyle = {
293
256
  flexBasis: '100%',
@@ -375,6 +338,6 @@ process.env.NODE_ENV !== "production" ? Masonry.propTypes
375
338
  /**
376
339
  * Allows defining system overrides as well as additional CSS styles.
377
340
  */
378
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
341
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
379
342
  } : void 0;
380
343
  export default Masonry;
@@ -155,6 +155,7 @@ process.env.NODE_ENV !== "production" ? MobileDatePicker.propTypes
155
155
 
156
156
  /**
157
157
  * If `true`, the picker and text field are disabled.
158
+ * @default false
158
159
  */
159
160
  disabled: PropTypes.bool,
160
161
 
@@ -336,6 +337,7 @@ process.env.NODE_ENV !== "production" ? MobileDatePicker.propTypes
336
337
 
337
338
  /**
338
339
  * Make picker read only.
340
+ * @default false
339
341
  */
340
342
  readOnly: PropTypes.bool,
341
343
 
@@ -206,6 +206,7 @@ process.env.NODE_ENV !== "production" ? MobileDateRangePicker.propTypes
206
206
 
207
207
  /**
208
208
  * If `true`, the picker and text field are disabled.
209
+ * @default false
209
210
  */
210
211
  disabled: PropTypes.bool,
211
212
 
@@ -386,6 +387,7 @@ process.env.NODE_ENV !== "production" ? MobileDateRangePicker.propTypes
386
387
 
387
388
  /**
388
389
  * Make picker read only.
390
+ * @default false
389
391
  */
390
392
  readOnly: PropTypes.bool,
391
393
 
@@ -172,6 +172,7 @@ process.env.NODE_ENV !== "production" ? MobileDateTimePicker.propTypes
172
172
 
173
173
  /**
174
174
  * If `true`, the picker and text field are disabled.
175
+ * @default false
175
176
  */
176
177
  disabled: PropTypes.bool,
177
178
 
@@ -405,6 +406,7 @@ process.env.NODE_ENV !== "production" ? MobileDateTimePicker.propTypes
405
406
 
406
407
  /**
407
408
  * Make picker read only.
409
+ * @default false
408
410
  */
409
411
  readOnly: PropTypes.bool,
410
412
 
@@ -41,13 +41,15 @@ var MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inProps, re
41
41
 
42
42
  var className = props.className,
43
43
  date = props.date,
44
+ disabled = props.disabled,
44
45
  disableFuture = props.disableFuture,
45
46
  disablePast = props.disablePast,
46
47
  maxDate = props.maxDate,
47
48
  minDate = props.minDate,
48
49
  onChange = props.onChange,
49
50
  onMonthChange = props.onMonthChange,
50
- other = _objectWithoutProperties(props, ["className", "date", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "onMonthChange"]);
51
+ readOnly = props.readOnly,
52
+ other = _objectWithoutProperties(props, ["className", "date", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "onMonthChange", "readOnly"]);
51
53
 
52
54
  var ownerState = props;
53
55
  var classes = useUtilityClasses(ownerState);
@@ -64,6 +66,10 @@ var MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inProps, re
64
66
  };
65
67
 
66
68
  var onMonthSelect = function onMonthSelect(month) {
69
+ if (readOnly) {
70
+ return;
71
+ }
72
+
67
73
  var newDate = utils.setMonth(date || now, month);
68
74
  onChange(newDate, 'finish');
69
75
 
@@ -84,7 +90,7 @@ var MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inProps, re
84
90
  value: monthNumber,
85
91
  selected: monthNumber === currentMonth,
86
92
  onSelect: onMonthSelect,
87
- disabled: shouldDisableMonth(month),
93
+ disabled: disabled || shouldDisableMonth(month),
88
94
  children: monthText
89
95
  }, monthText);
90
96
  })
@@ -113,6 +119,11 @@ process.env.NODE_ENV !== "production" ? MonthPicker.propTypes
113
119
  */
114
120
  date: PropTypes.any,
115
121
 
122
+ /**
123
+ * If `true` picker is disabled
124
+ */
125
+ disabled: PropTypes.bool,
126
+
116
127
  /**
117
128
  * If `true` future days are disabled.
118
129
  */
@@ -143,10 +154,15 @@ process.env.NODE_ENV !== "production" ? MonthPicker.propTypes
143
154
  */
144
155
  onMonthChange: PropTypes.func,
145
156
 
157
+ /**
158
+ * If `true` picker is readonly
159
+ */
160
+ readOnly: PropTypes.bool,
161
+
146
162
  /**
147
163
  * The system prop that allows defining system overrides as well as additional CSS styles.
148
164
  */
149
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
165
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
150
166
  } : void 0;
151
167
  /**
152
168
  *
@@ -377,7 +377,7 @@ process.env.NODE_ENV !== "production" ? PickersDay.propTypes
377
377
  /**
378
378
  * The system prop that allows defining system overrides as well as additional CSS styles.
379
379
  */
380
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
380
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object]),
381
381
 
382
382
  /**
383
383
  * If `true`, renders as today date.
@@ -125,6 +125,7 @@ process.env.NODE_ENV !== "production" ? StaticDatePicker.propTypes
125
125
 
126
126
  /**
127
127
  * If `true`, the picker and text field are disabled.
128
+ * @default false
128
129
  */
129
130
  disabled: PropTypes.bool,
130
131
 
@@ -306,6 +307,7 @@ process.env.NODE_ENV !== "production" ? StaticDatePicker.propTypes
306
307
 
307
308
  /**
308
309
  * Make picker read only.
310
+ * @default false
309
311
  */
310
312
  readOnly: PropTypes.bool,
311
313
 
@@ -177,6 +177,7 @@ process.env.NODE_ENV !== "production" ? StaticDateRangePicker.propTypes
177
177
 
178
178
  /**
179
179
  * If `true`, the picker and text field are disabled.
180
+ * @default false
180
181
  */
181
182
  disabled: PropTypes.bool,
182
183
 
@@ -355,6 +356,7 @@ process.env.NODE_ENV !== "production" ? StaticDateRangePicker.propTypes
355
356
 
356
357
  /**
357
358
  * Make picker read only.
359
+ * @default false
358
360
  */
359
361
  readOnly: PropTypes.bool,
360
362
 
@@ -142,6 +142,7 @@ process.env.NODE_ENV !== "production" ? StaticDateTimePicker.propTypes
142
142
 
143
143
  /**
144
144
  * If `true`, the picker and text field are disabled.
145
+ * @default false
145
146
  */
146
147
  disabled: PropTypes.bool,
147
148
 
@@ -375,6 +376,7 @@ process.env.NODE_ENV !== "production" ? StaticDateTimePicker.propTypes
375
376
 
376
377
  /**
377
378
  * Make picker read only.
379
+ * @default false
378
380
  */
379
381
  readOnly: PropTypes.bool,
380
382
 
@@ -89,7 +89,7 @@ process.env.NODE_ENV !== "production" ? TabPanel.propTypes
89
89
  /**
90
90
  * The system prop that allows defining system overrides as well as additional CSS styles.
91
91
  */
92
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
92
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object]),
93
93
 
94
94
  /**
95
95
  * The `value` of the corresponding `Tab`. Must use the index of the `Tab` when
@@ -103,7 +103,7 @@ process.env.NODE_ENV !== "production" ? Timeline.propTypes
103
103
  /**
104
104
  * The system prop that allows defining system overrides as well as additional CSS styles.
105
105
  */
106
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
106
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
107
107
  } : void 0;
108
108
  /**
109
109
  *
@@ -73,6 +73,6 @@ process.env.NODE_ENV !== "production" ? TimelineConnector.propTypes
73
73
  /**
74
74
  * The system prop that allows defining system overrides as well as additional CSS styles.
75
75
  */
76
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
76
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
77
77
  } : void 0;
78
78
  export default TimelineConnector;
@@ -87,6 +87,6 @@ process.env.NODE_ENV !== "production" ? TimelineContent.propTypes
87
87
  /**
88
88
  * The system prop that allows defining system overrides as well as additional CSS styles.
89
89
  */
90
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
90
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
91
91
  } : void 0;
92
92
  export default TimelineContent;
@@ -112,7 +112,7 @@ process.env.NODE_ENV !== "production" ? TimelineDot.propTypes
112
112
  /**
113
113
  * The system prop that allows defining system overrides as well as additional CSS styles.
114
114
  */
115
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
115
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object]),
116
116
 
117
117
  /**
118
118
  * The dot can appear filled or outlined.
@@ -125,6 +125,6 @@ process.env.NODE_ENV !== "production" ? TimelineItem.propTypes
125
125
  /**
126
126
  * The system prop that allows defining system overrides as well as additional CSS styles.
127
127
  */
128
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
128
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
129
129
  } : void 0;
130
130
  export default TimelineItem;
@@ -88,7 +88,7 @@ process.env.NODE_ENV !== "production" ? TimelineOppositeContent.propTypes
88
88
  /**
89
89
  * The system prop that allows defining system overrides as well as additional CSS styles.
90
90
  */
91
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
91
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
92
92
  } : void 0;
93
93
  TimelineOppositeContent.muiName = 'TimelineOppositeContent';
94
94
  export default TimelineOppositeContent;
@@ -71,6 +71,6 @@ process.env.NODE_ENV !== "production" ? TimelineSeparator.propTypes
71
71
  /**
72
72
  * The system prop that allows defining system overrides as well as additional CSS styles.
73
73
  */
74
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
74
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
75
75
  } : void 0;
76
76
  export default TimelineSeparator;
@@ -407,7 +407,7 @@ process.env.NODE_ENV !== "production" ? TreeItem.propTypes
407
407
  /**
408
408
  * The system prop that allows defining system overrides as well as additional CSS styles.
409
409
  */
410
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
410
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object]),
411
411
 
412
412
  /**
413
413
  * The component used for the transition.
@@ -1036,6 +1036,6 @@ process.env.NODE_ENV !== "production" ? TreeView.propTypes
1036
1036
  /**
1037
1037
  * The system prop that allows defining system overrides as well as additional CSS styles.
1038
1038
  */
1039
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
1039
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
1040
1040
  } : void 0;
1041
1041
  export default TreeView;
@@ -40,6 +40,7 @@ var YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProps, ref)
40
40
  var autoFocus = props.autoFocus,
41
41
  className = props.className,
42
42
  date = props.date,
43
+ disabled = props.disabled,
43
44
  disableFuture = props.disableFuture,
44
45
  disablePast = props.disablePast,
45
46
  isDateDisabled = props.isDateDisabled,
@@ -48,6 +49,7 @@ var YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProps, ref)
48
49
  onChange = props.onChange,
49
50
  onFocusedDayChange = props.onFocusedDayChange,
50
51
  onYearChange = props.onYearChange,
52
+ readOnly = props.readOnly,
51
53
  shouldDisableYear = props.shouldDisableYear;
52
54
  var ownerState = props;
53
55
  var classes = useUtilityClasses(ownerState);
@@ -66,6 +68,10 @@ var YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProps, ref)
66
68
  var handleYearSelection = function handleYearSelection(event, year) {
67
69
  var isFinish = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'finish';
68
70
 
71
+ if (readOnly) {
72
+ return;
73
+ }
74
+
69
75
  var submitDate = function submitDate(newDate) {
70
76
  onChange(newDate, isFinish);
71
77
 
@@ -144,7 +150,7 @@ var YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProps, ref)
144
150
  onKeyDown: handleKeyDown,
145
151
  autoFocus: autoFocus && yearNumber === focusedYear,
146
152
  ref: selected ? selectedYearRef : undefined,
147
- disabled: disablePast && utils.isBeforeYear(year, now) || disableFuture && utils.isAfterYear(year, now) || shouldDisableYear && shouldDisableYear(year),
153
+ disabled: disabled || disablePast && utils.isBeforeYear(year, now) || disableFuture && utils.isAfterYear(year, now) || shouldDisableYear && shouldDisableYear(year),
148
154
  children: utils.format(year, 'year')
149
155
  }, utils.format(year, 'year'));
150
156
  })
@@ -178,6 +184,11 @@ process.env.NODE_ENV !== "production" ? YearPicker.propTypes
178
184
  */
179
185
  date: PropTypes.any,
180
186
 
187
+ /**
188
+ * @ignore
189
+ */
190
+ disabled: PropTypes.bool,
191
+
181
192
  /**
182
193
  * @ignore
183
194
  */
@@ -218,6 +229,11 @@ process.env.NODE_ENV !== "production" ? YearPicker.propTypes
218
229
  */
219
230
  onYearChange: PropTypes.func,
220
231
 
232
+ /**
233
+ * @ignore
234
+ */
235
+ readOnly: PropTypes.bool,
236
+
221
237
  /**
222
238
  * Disable specific years dynamically.
223
239
  * Works like `shouldDisableDate` but for year selection view @DateIOType.
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.0.0-alpha.53
1
+ /** @license MUI v5.0.0-alpha.54
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -11,7 +11,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
11
11
 
12
12
  import * as React from 'react';
13
13
  import { parseISO } from 'date-fns';
14
- import { createClientRender, fireEvent, screen } from 'test/utils';
14
+ import { createRenderer, fireEvent, screen } from 'test/utils';
15
15
  import AdapterDateFns from '@mui/lab/AdapterDateFns';
16
16
  import LocalizationProvider from '@mui/lab/LocalizationProvider'; // TODO make possible to pass here any utils using cli
17
17
 
@@ -84,7 +84,8 @@ export function createPickerRender() {
84
84
  var locale = _ref2.locale,
85
85
  renderOptions = _objectWithoutProperties(_ref2, ["locale"]);
86
86
 
87
- var clientRender = createClientRender(renderOptions);
87
+ var _createRenderer = createRenderer(renderOptions),
88
+ clientRender = _createRenderer.render;
88
89
 
89
90
  function Wrapper(_ref3) {
90
91
  var children = _ref3.children;
@@ -230,6 +230,12 @@ process.env.NODE_ENV !== "production" ? CalendarPicker.propTypes
230
230
  */
231
231
  defaultCalendarMonth: PropTypes.any,
232
232
 
233
+ /**
234
+ * If `true`, the picker and text field are disabled.
235
+ * @default false
236
+ */
237
+ disabled: PropTypes.bool,
238
+
233
239
  /**
234
240
  * @default false
235
241
  */
@@ -278,6 +284,12 @@ process.env.NODE_ENV !== "production" ? CalendarPicker.propTypes
278
284
  */
279
285
  openTo: PropTypes.oneOf(['day', 'month', 'year']),
280
286
 
287
+ /**
288
+ * Make picker read only.
289
+ * @default false
290
+ */
291
+ readOnly: PropTypes.bool,
292
+
281
293
  /**
282
294
  * Disable heavy animations.
283
295
  * @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
@@ -70,6 +70,7 @@ function PickersCalendar(props) {
70
70
  className,
71
71
  currentMonth,
72
72
  date,
73
+ disabled,
73
74
  disableHighlightToday,
74
75
  focusedDay,
75
76
  isDateDisabled,
@@ -77,6 +78,7 @@ function PickersCalendar(props) {
77
78
  loading,
78
79
  onChange,
79
80
  onMonthSwitchingAnimationEnd,
81
+ readOnly,
80
82
  reduceAnimations,
81
83
  renderDay,
82
84
  renderLoading = () => _span || (_span = /*#__PURE__*/_jsx("span", {
@@ -89,10 +91,14 @@ function PickersCalendar(props) {
89
91
  const now = useNow();
90
92
  const utils = useUtils();
91
93
  const handleDaySelect = React.useCallback((day, isFinish = 'finish') => {
92
- // TODO possibly buggy line figure out and add tests
94
+ if (readOnly) {
95
+ return;
96
+ } // TODO possibly buggy line figure out and add tests
97
+
98
+
93
99
  const finalDate = Array.isArray(date) ? day : utils.mergeDateAndTime(day, date || now);
94
100
  onChange(finalDate, isFinish);
95
- }, [date, now, onChange, utils]);
101
+ }, [date, now, onChange, readOnly, utils]);
96
102
  const currentMonthNumber = utils.getMonth(currentMonth);
97
103
  const selectedDates = (Array.isArray(date) ? date : [date]).filter(Boolean).map(selectedDateItem => selectedDateItem && utils.startOfDay(selectedDateItem)); // need a new ref whenever the `key` of the transition changes: https://reactcommunity.org/react-transition-group/transition#Transition-prop-nodeRef.
98
104
 
@@ -126,7 +132,7 @@ function PickersCalendar(props) {
126
132
  key: day?.toString(),
127
133
  day,
128
134
  isAnimating: isMonthSwitchingAnimating,
129
- disabled: isDateDisabled(day),
135
+ disabled: disabled || isDateDisabled(day),
130
136
  allowSameDateSelection,
131
137
  autoFocus: autoFocus && focusedDay !== null && utils.isSameDay(day, focusedDay),
132
138
  today: utils.isSameDay(day, now),
@@ -74,6 +74,7 @@ function PickersCalendarHeader(props) {
74
74
  components = {},
75
75
  componentsProps = {},
76
76
  currentMonth: month,
77
+ disabled,
77
78
  disableFuture,
78
79
  disablePast,
79
80
  getViewSwitchingButtonText = getSwitchingViewAriaText,
@@ -95,16 +96,16 @@ function PickersCalendarHeader(props) {
95
96
  const selectPreviousMonth = () => onMonthChange(utils.getPreviousMonth(month), 'right');
96
97
 
97
98
  const isNextMonthDisabled = useNextMonthDisabled(month, {
98
- disableFuture,
99
+ disableFuture: disableFuture || disabled,
99
100
  maxDate
100
101
  });
101
102
  const isPreviousMonthDisabled = usePreviousMonthDisabled(month, {
102
- disablePast,
103
+ disablePast: disablePast || disabled,
103
104
  minDate
104
105
  });
105
106
 
106
107
  const handleToggleView = () => {
107
- if (views.length === 1 || !onViewChange) {
108
+ if (views.length === 1 || !onViewChange || disabled) {
108
109
  return;
109
110
  }
110
111
 
@@ -145,7 +146,7 @@ function PickersCalendarHeader(props) {
145
146
  ownerState: ownerState,
146
147
  children: utils.format(month, 'year')
147
148
  })
148
- }), views.length > 1 && /*#__PURE__*/_jsx(PickersCalendarHeaderSwitchViewButton, _extends({
149
+ }), views.length > 1 && !disabled && /*#__PURE__*/_jsx(PickersCalendarHeaderSwitchViewButton, _extends({
149
150
  size: "small",
150
151
  as: components.SwitchViewButton,
151
152
  "aria-label": getViewSwitchingButtonText(currentView)
@@ -144,6 +144,6 @@ process.env.NODE_ENV !== "production" ? CalendarPickerSkeleton.propTypes
144
144
  /**
145
145
  * The system prop that allows defining system overrides as well as additional CSS styles.
146
146
  */
147
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
147
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
148
148
  } : void 0;
149
149
  export default CalendarPickerSkeleton;
@@ -155,6 +155,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes
155
155
 
156
156
  /**
157
157
  * If `true`, the picker and text field are disabled.
158
+ * @default false
158
159
  */
159
160
  disabled: PropTypes.bool,
160
161
 
@@ -346,6 +347,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes
346
347
 
347
348
  /**
348
349
  * Make picker read only.
350
+ * @default false
349
351
  */
350
352
  readOnly: PropTypes.bool,
351
353
 
@@ -209,6 +209,7 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes
209
209
 
210
210
  /**
211
211
  * If `true`, the picker and text field are disabled.
212
+ * @default false
212
213
  */
213
214
  disabled: PropTypes.bool,
214
215
 
@@ -399,6 +400,7 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes
399
400
 
400
401
  /**
401
402
  * Make picker read only.
403
+ * @default false
402
404
  */
403
405
  readOnly: PropTypes.bool,
404
406
 
@@ -228,7 +228,7 @@ process.env.NODE_ENV !== "production" ? DateRangePickerDay.propTypes
228
228
  /**
229
229
  * The system prop that allows defining system overrides as well as additional CSS styles.
230
230
  */
231
- sx: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
231
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
232
232
  } : void 0;
233
233
  /**
234
234
  *
@@ -172,6 +172,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes
172
172
 
173
173
  /**
174
174
  * If `true`, the picker and text field are disabled.
175
+ * @default false
175
176
  */
176
177
  disabled: PropTypes.bool,
177
178
 
@@ -415,6 +416,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes
415
416
 
416
417
  /**
417
418
  * Make picker read only.
419
+ * @default false
418
420
  */
419
421
  readOnly: PropTypes.bool,
420
422