@mui/lab 5.0.0-alpha.50 → 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 (234) hide show
  1. package/CHANGELOG.md +274 -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/CalendarPicker/PickersFadeTransitionGroup.js +2 -2
  9. package/CalendarPickerSkeleton/CalendarPickerSkeleton.d.ts +2 -1
  10. package/CalendarPickerSkeleton/CalendarPickerSkeleton.js +1 -1
  11. package/DatePicker/DatePicker.js +7 -0
  12. package/DateRangePicker/DateRangePicker.js +7 -0
  13. package/DateRangePickerDay/DateRangePickerDay.js +1 -1
  14. package/DateTimePicker/DateTimePicker.js +7 -0
  15. package/DesktopDatePicker/DesktopDatePicker.js +10 -1
  16. package/DesktopDateRangePicker/DesktopDateRangePicker.js +7 -0
  17. package/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
  18. package/DesktopTimePicker/DesktopTimePicker.js +5 -0
  19. package/LoadingButton/LoadingButton.js +37 -7
  20. package/Masonry/Masonry.d.ts +13 -1
  21. package/Masonry/Masonry.js +207 -57
  22. package/MobileDatePicker/MobileDatePicker.js +2 -0
  23. package/MobileDateRangePicker/MobileDateRangePicker.js +2 -0
  24. package/MobileDateTimePicker/MobileDateTimePicker.js +2 -0
  25. package/MonthPicker/MonthPicker.d.ts +4 -0
  26. package/MonthPicker/MonthPicker.js +20 -4
  27. package/PickersDay/PickersDay.js +1 -1
  28. package/StaticDatePicker/StaticDatePicker.js +2 -0
  29. package/StaticDateRangePicker/StaticDateRangePicker.js +2 -0
  30. package/StaticDateTimePicker/StaticDateTimePicker.js +2 -0
  31. package/TabPanel/TabPanel.js +1 -1
  32. package/TimePicker/TimePicker.js +5 -0
  33. package/Timeline/Timeline.js +1 -1
  34. package/TimelineConnector/TimelineConnector.js +1 -1
  35. package/TimelineContent/TimelineContent.js +1 -1
  36. package/TimelineDot/TimelineDot.js +1 -1
  37. package/TimelineItem/TimelineItem.js +1 -1
  38. package/TimelineOppositeContent/TimelineOppositeContent.js +1 -1
  39. package/TimelineSeparator/TimelineSeparator.js +1 -1
  40. package/TreeItem/TreeItem.js +1 -1
  41. package/TreeView/TreeView.js +1 -1
  42. package/YearPicker/YearPicker.d.ts +2 -0
  43. package/YearPicker/YearPicker.js +17 -1
  44. package/index.js +1 -1
  45. package/internal/pickers/Picker/Picker.d.ts +1 -1
  46. package/internal/pickers/Picker/PickerView.d.ts +1 -1
  47. package/internal/pickers/PickersArrowSwitcher.d.ts +2 -2
  48. package/internal/pickers/PickersArrowSwitcher.js +1 -3
  49. package/internal/pickers/PickersPopper.d.ts +9 -1
  50. package/internal/pickers/PickersPopper.js +31 -7
  51. package/internal/pickers/test-utils.js +4 -2
  52. package/internal/pickers/wrappers/DesktopWrapper.d.ts +2 -2
  53. package/internal/pickers/wrappers/DesktopWrapper.js +2 -0
  54. package/legacy/CalendarPicker/CalendarPicker.js +12 -0
  55. package/legacy/CalendarPicker/PickersCalendar.js +10 -3
  56. package/legacy/CalendarPicker/PickersCalendarHeader.js +5 -4
  57. package/legacy/CalendarPicker/PickersFadeTransitionGroup.js +3 -5
  58. package/legacy/CalendarPickerSkeleton/CalendarPickerSkeleton.js +1 -1
  59. package/legacy/DatePicker/DatePicker.js +7 -0
  60. package/legacy/DateRangePicker/DateRangePicker.js +7 -0
  61. package/legacy/DateRangePickerDay/DateRangePickerDay.js +1 -1
  62. package/legacy/DateTimePicker/DateTimePicker.js +7 -0
  63. package/legacy/DesktopDatePicker/DesktopDatePicker.js +10 -1
  64. package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +7 -0
  65. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
  66. package/legacy/DesktopTimePicker/DesktopTimePicker.js +5 -0
  67. package/legacy/LoadingButton/LoadingButton.js +36 -10
  68. package/legacy/Masonry/Masonry.js +216 -57
  69. package/legacy/MobileDatePicker/MobileDatePicker.js +2 -0
  70. package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +2 -0
  71. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +2 -0
  72. package/legacy/MonthPicker/MonthPicker.js +19 -3
  73. package/legacy/PickersDay/PickersDay.js +1 -1
  74. package/legacy/StaticDatePicker/StaticDatePicker.js +2 -0
  75. package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +2 -0
  76. package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +2 -0
  77. package/legacy/TabPanel/TabPanel.js +1 -1
  78. package/legacy/TimePicker/TimePicker.js +5 -0
  79. package/legacy/Timeline/Timeline.js +1 -1
  80. package/legacy/TimelineConnector/TimelineConnector.js +1 -1
  81. package/legacy/TimelineContent/TimelineContent.js +1 -1
  82. package/legacy/TimelineDot/TimelineDot.js +1 -1
  83. package/legacy/TimelineItem/TimelineItem.js +1 -1
  84. package/legacy/TimelineOppositeContent/TimelineOppositeContent.js +1 -1
  85. package/legacy/TimelineSeparator/TimelineSeparator.js +1 -1
  86. package/legacy/TreeItem/TreeItem.js +1 -1
  87. package/legacy/TreeView/TreeView.js +1 -1
  88. package/legacy/YearPicker/YearPicker.js +17 -1
  89. package/legacy/index.js +1 -1
  90. package/legacy/internal/pickers/PickersArrowSwitcher.js +1 -3
  91. package/legacy/internal/pickers/PickersPopper.js +29 -7
  92. package/legacy/internal/pickers/test-utils.js +3 -2
  93. package/legacy/internal/pickers/wrappers/DesktopWrapper.js +2 -0
  94. package/modern/CalendarPicker/CalendarPicker.js +12 -0
  95. package/modern/CalendarPicker/PickersCalendar.js +9 -3
  96. package/modern/CalendarPicker/PickersCalendarHeader.js +5 -4
  97. package/modern/CalendarPicker/PickersFadeTransitionGroup.js +2 -2
  98. package/modern/CalendarPickerSkeleton/CalendarPickerSkeleton.js +1 -1
  99. package/modern/DatePicker/DatePicker.js +7 -0
  100. package/modern/DateRangePicker/DateRangePicker.js +7 -0
  101. package/modern/DateRangePickerDay/DateRangePickerDay.js +1 -1
  102. package/modern/DateTimePicker/DateTimePicker.js +7 -0
  103. package/modern/DesktopDatePicker/DesktopDatePicker.js +10 -1
  104. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +7 -0
  105. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
  106. package/modern/DesktopTimePicker/DesktopTimePicker.js +5 -0
  107. package/modern/LoadingButton/LoadingButton.js +37 -7
  108. package/modern/Masonry/Masonry.js +207 -57
  109. package/modern/MobileDatePicker/MobileDatePicker.js +2 -0
  110. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +2 -0
  111. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -0
  112. package/modern/MonthPicker/MonthPicker.js +20 -4
  113. package/modern/PickersDay/PickersDay.js +1 -1
  114. package/modern/StaticDatePicker/StaticDatePicker.js +2 -0
  115. package/modern/StaticDateRangePicker/StaticDateRangePicker.js +2 -0
  116. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +2 -0
  117. package/modern/TabPanel/TabPanel.js +1 -1
  118. package/modern/TimePicker/TimePicker.js +5 -0
  119. package/modern/Timeline/Timeline.js +1 -1
  120. package/modern/TimelineConnector/TimelineConnector.js +1 -1
  121. package/modern/TimelineContent/TimelineContent.js +1 -1
  122. package/modern/TimelineDot/TimelineDot.js +1 -1
  123. package/modern/TimelineItem/TimelineItem.js +1 -1
  124. package/modern/TimelineOppositeContent/TimelineOppositeContent.js +1 -1
  125. package/modern/TimelineSeparator/TimelineSeparator.js +1 -1
  126. package/modern/TreeItem/TreeItem.js +1 -1
  127. package/modern/TreeView/TreeView.js +1 -1
  128. package/modern/YearPicker/YearPicker.js +17 -1
  129. package/modern/index.js +1 -1
  130. package/modern/internal/pickers/PickersArrowSwitcher.js +1 -3
  131. package/modern/internal/pickers/PickersPopper.js +31 -7
  132. package/modern/internal/pickers/test-utils.js +4 -2
  133. package/modern/internal/pickers/wrappers/DesktopWrapper.js +2 -0
  134. package/node/CalendarPicker/CalendarPicker.js +13 -1
  135. package/node/CalendarPicker/PickersCalendar.js +9 -3
  136. package/node/CalendarPicker/PickersCalendarHeader.js +5 -4
  137. package/node/CalendarPicker/PickersFadeTransitionGroup.js +2 -2
  138. package/node/CalendarPicker/PickersSlideTransition.js +1 -1
  139. package/node/CalendarPicker/index.js +4 -4
  140. package/node/CalendarPicker/useCalendarState.js +1 -1
  141. package/node/CalendarPickerSkeleton/CalendarPickerSkeleton.js +2 -2
  142. package/node/CalendarPickerSkeleton/index.js +4 -4
  143. package/node/ClockPicker/ClockPicker.js +1 -1
  144. package/node/ClockPicker/index.js +4 -4
  145. package/node/ClockPicker/shared.js +1 -1
  146. package/node/DatePicker/DatePicker.js +7 -0
  147. package/node/DatePicker/shared.js +1 -1
  148. package/node/DateRangePicker/DateRangePicker.js +7 -0
  149. package/node/DateRangePickerDay/DateRangePickerDay.js +2 -2
  150. package/node/DateTimePicker/DateTimePicker.js +7 -0
  151. package/node/DesktopDatePicker/DesktopDatePicker.js +10 -1
  152. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +7 -0
  153. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
  154. package/node/DesktopTimePicker/DesktopTimePicker.js +5 -0
  155. package/node/LoadingButton/LoadingButton.js +37 -7
  156. package/node/LoadingButton/loadingButtonClasses.js +1 -1
  157. package/node/Masonry/Masonry.js +211 -61
  158. package/node/Masonry/masonryClasses.js +1 -1
  159. package/node/MobileDatePicker/MobileDatePicker.js +2 -0
  160. package/node/MobileDateRangePicker/MobileDateRangePicker.js +2 -0
  161. package/node/MobileDateTimePicker/MobileDateTimePicker.js +2 -0
  162. package/node/MonthPicker/MonthPicker.js +22 -5
  163. package/node/PickersDay/PickersDay.js +3 -2
  164. package/node/PickersDay/index.js +4 -4
  165. package/node/StaticDatePicker/StaticDatePicker.js +2 -0
  166. package/node/StaticDateRangePicker/StaticDateRangePicker.js +2 -0
  167. package/node/StaticDateTimePicker/StaticDateTimePicker.js +2 -0
  168. package/node/TabContext/TabContext.js +1 -1
  169. package/node/TabPanel/TabPanel.js +1 -1
  170. package/node/TabPanel/tabPanelClasses.js +1 -1
  171. package/node/TimePicker/TimePicker.js +5 -0
  172. package/node/TimePicker/TimePickerToolbar.js +2 -1
  173. package/node/Timeline/Timeline.js +1 -1
  174. package/node/Timeline/timelineClasses.js +1 -1
  175. package/node/TimelineConnector/TimelineConnector.js +1 -1
  176. package/node/TimelineConnector/timelineConnectorClasses.js +1 -1
  177. package/node/TimelineContent/TimelineContent.js +1 -1
  178. package/node/TimelineContent/timelineContentClasses.js +1 -1
  179. package/node/TimelineDot/TimelineDot.js +1 -1
  180. package/node/TimelineDot/timelineDotClasses.js +1 -1
  181. package/node/TimelineItem/TimelineItem.js +1 -1
  182. package/node/TimelineItem/timelineItemClasses.js +1 -1
  183. package/node/TimelineOppositeContent/TimelineOppositeContent.js +1 -1
  184. package/node/TimelineOppositeContent/timelineOppositeContentClasses.js +1 -1
  185. package/node/TimelineSeparator/TimelineSeparator.js +1 -1
  186. package/node/TimelineSeparator/timelineSeparatorClasses.js +1 -1
  187. package/node/TreeItem/TreeItem.js +1 -1
  188. package/node/TreeItem/index.js +4 -4
  189. package/node/TreeItem/treeItemClasses.js +1 -1
  190. package/node/TreeView/TreeView.js +1 -1
  191. package/node/TreeView/descendants.js +1 -1
  192. package/node/TreeView/treeViewClasses.js +1 -1
  193. package/node/YearPicker/PickersYear.js +2 -1
  194. package/node/YearPicker/YearPicker.js +17 -1
  195. package/node/YearPicker/yearPickerClasses.js +1 -1
  196. package/node/index.js +7 -7
  197. package/node/internal/pickers/PickersArrowSwitcher.js +1 -3
  198. package/node/internal/pickers/PickersPopper.js +31 -7
  199. package/node/internal/pickers/constants/dimensions.js +1 -1
  200. package/node/internal/pickers/date-utils.js +2 -1
  201. package/node/internal/pickers/hooks/date-helpers-hooks.js +1 -1
  202. package/node/internal/pickers/hooks/useIsLandscape.js +1 -1
  203. package/node/internal/pickers/hooks/useMaskedInput.js +1 -1
  204. package/node/internal/pickers/hooks/useOpenState.js +1 -1
  205. package/node/internal/pickers/hooks/useUtils.js +1 -1
  206. package/node/internal/pickers/hooks/useValidation.js +3 -3
  207. package/node/internal/pickers/test-utils.js +5 -3
  208. package/node/internal/pickers/text-field-helper.js +3 -2
  209. package/node/internal/pickers/time-utils.js +2 -1
  210. package/node/internal/pickers/utils.js +1 -1
  211. package/node/internal/pickers/wrappers/DesktopWrapper.js +2 -0
  212. package/node/internal/pickers/wrappers/WrapperVariantContext.js +1 -1
  213. package/node/useAutocomplete/index.js +4 -4
  214. package/package.json +8 -7
  215. package/Masonry/MasonryContext.js +0 -12
  216. package/MasonryItem/MasonryItem.d.ts +0 -49
  217. package/MasonryItem/MasonryItem.js +0 -196
  218. package/MasonryItem/index.d.ts +0 -5
  219. package/MasonryItem/index.js +0 -3
  220. package/MasonryItem/masonryItemClasses.d.ts +0 -8
  221. package/MasonryItem/masonryItemClasses.js +0 -6
  222. package/MasonryItem/package.json +0 -6
  223. package/legacy/Masonry/MasonryContext.js +0 -12
  224. package/legacy/MasonryItem/MasonryItem.js +0 -201
  225. package/legacy/MasonryItem/index.js +0 -3
  226. package/legacy/MasonryItem/masonryItemClasses.js +0 -6
  227. package/modern/Masonry/MasonryContext.js +0 -12
  228. package/modern/MasonryItem/MasonryItem.js +0 -196
  229. package/modern/MasonryItem/index.js +0 -3
  230. package/modern/MasonryItem/masonryItemClasses.js +0 -6
  231. package/node/Masonry/MasonryContext.js +0 -24
  232. package/node/MasonryItem/MasonryItem.js +0 -220
  233. package/node/MasonryItem/index.js +0 -42
  234. package/node/MasonryItem/masonryItemClasses.js +0 -17
@@ -149,6 +149,7 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePicker.propTypes
149
149
 
150
150
  /**
151
151
  * If `true`, the picker and text field are disabled.
152
+ * @default false
152
153
  */
153
154
  disabled: PropTypes.bool,
154
155
 
@@ -374,6 +375,11 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePicker.propTypes
374
375
  */
375
376
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
376
377
 
378
+ /**
379
+ * Paper props passed down to [Paper](https://mui.com/api/paper/) component.
380
+ */
381
+ PaperProps: PropTypes.object,
382
+
377
383
  /**
378
384
  * Popper props passed down to [Popper](https://mui.com/api/popper/) component.
379
385
  */
@@ -381,6 +387,7 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePicker.propTypes
381
387
 
382
388
  /**
383
389
  * Make picker read only.
390
+ * @default false
384
391
  */
385
392
  readOnly: PropTypes.bool,
386
393
 
@@ -272,6 +272,11 @@ process.env.NODE_ENV !== "production" ? DesktopTimePicker.propTypes
272
272
  */
273
273
  orientation: PropTypes.oneOf(['landscape', 'portrait']),
274
274
 
275
+ /**
276
+ * Paper props passed down to [Paper](https://mui.com/api/paper/) component.
277
+ */
278
+ PaperProps: PropTypes.object,
279
+
275
280
  /**
276
281
  * Popper props passed down to [Popper](https://mui.com/api/popper/) component.
277
282
  */
@@ -60,6 +60,22 @@ const LoadingButtonRoot = styled(Button, {
60
60
  [`&.${loadingButtonClasses.loading}`]: {
61
61
  color: 'transparent'
62
62
  }
63
+ }, ownerState.loadingPosition === 'start' && ownerState.fullWidth && {
64
+ [`& .${loadingButtonClasses.startIconLoadingStart}, & .${loadingButtonClasses.endIconLoadingEnd}`]: {
65
+ transition: theme.transitions.create(['opacity'], {
66
+ duration: theme.transitions.duration.short
67
+ }),
68
+ opacity: 0,
69
+ marginRight: -8
70
+ }
71
+ }, ownerState.loadingPosition === 'end' && ownerState.fullWidth && {
72
+ [`& .${loadingButtonClasses.startIconLoadingStart}, & .${loadingButtonClasses.endIconLoadingEnd}`]: {
73
+ transition: theme.transitions.create(['opacity'], {
74
+ duration: theme.transitions.duration.short
75
+ }),
76
+ opacity: 0,
77
+ marginLeft: -8
78
+ }
63
79
  }));
64
80
  const LoadingButtonLoadingIndicator = styled('div', {
65
81
  name: 'MuiLoadingButton',
@@ -85,6 +101,12 @@ const LoadingButtonLoadingIndicator = styled('div', {
85
101
  color: theme.palette.action.disabled
86
102
  }, ownerState.loadingPosition === 'end' && {
87
103
  right: 14
104
+ }, ownerState.loadingPosition === 'start' && ownerState.fullWidth && {
105
+ position: 'relative',
106
+ left: -10
107
+ }, ownerState.loadingPosition === 'end' && ownerState.fullWidth && {
108
+ position: 'relative',
109
+ right: -10
88
110
  }));
89
111
 
90
112
  const LoadingIndicator = /*#__PURE__*/_jsx(CircularProgress, {
@@ -115,17 +137,25 @@ const LoadingButton = /*#__PURE__*/React.forwardRef(function LoadingButton(inPro
115
137
  });
116
138
 
117
139
  const classes = useUtilityClasses(ownerState);
118
- return /*#__PURE__*/_jsxs(LoadingButtonRoot, _extends({
140
+ return /*#__PURE__*/_jsx(LoadingButtonRoot, _extends({
119
141
  disabled: disabled || loading,
120
142
  ref: ref
121
143
  }, other, {
122
144
  classes: classes,
123
145
  ownerState: ownerState,
124
- children: [loading && /*#__PURE__*/_jsx(LoadingButtonLoadingIndicator, {
125
- className: classes.loadingIndicator,
126
- ownerState: ownerState,
127
- children: loadingIndicator
128
- }), children]
146
+ children: ownerState.loadingPosition === 'end' ? /*#__PURE__*/_jsxs(React.Fragment, {
147
+ children: [children, loading && /*#__PURE__*/_jsx(LoadingButtonLoadingIndicator, {
148
+ className: classes.loadingIndicator,
149
+ ownerState: ownerState,
150
+ children: loadingIndicator
151
+ })]
152
+ }) : /*#__PURE__*/_jsxs(React.Fragment, {
153
+ children: [loading && /*#__PURE__*/_jsx(LoadingButtonLoadingIndicator, {
154
+ className: classes.loadingIndicator,
155
+ ownerState: ownerState,
156
+ children: loadingIndicator
157
+ }), children]
158
+ })
129
159
  }));
130
160
  });
131
161
  process.env.NODE_ENV !== "production" ? LoadingButton.propTypes
@@ -183,6 +213,6 @@ process.env.NODE_ENV !== "production" ? LoadingButton.propTypes
183
213
  /**
184
214
  * The system prop that allows defining system overrides as well as additional CSS styles.
185
215
  */
186
- sx: PropTypes.object
216
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
187
217
  } : void 0;
188
218
  export default LoadingButton;
@@ -6,7 +6,7 @@ import { MasonryClasses } from './masonryClasses';
6
6
  export interface MasonryTypeMap<P = {}, D extends React.ElementType = 'div'> {
7
7
  props: P & {
8
8
  /**
9
- * The content of the component. It's recommended to be `<MasonryItem />`s.
9
+ * The content of the component.
10
10
  */
11
11
  children: NonNullable<React.ReactNode>;
12
12
  /**
@@ -18,6 +18,18 @@ export interface MasonryTypeMap<P = {}, D extends React.ElementType = 'div'> {
18
18
  * @default 4
19
19
  */
20
20
  columns?: ResponsiveStyleValue<number | string>;
21
+ /**
22
+ * The default number of columns of the component. This is provided for server-side rendering.
23
+ */
24
+ defaultColumns?: number;
25
+ /**
26
+ * The default height of the component in px. This is provided for server-side rendering.
27
+ */
28
+ defaultHeight?: number;
29
+ /**
30
+ * The default spacing of the component. Like `spacing`, it is a factor of the theme's spacing. This is provided for server-side rendering.
31
+ */
32
+ defaultSpacing?: number;
21
33
  /**
22
34
  * Defines the space between children. It is a factor of the theme's spacing.
23
35
  * @default 1
@@ -1,16 +1,19 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["children", "className", "component", "columns", "spacing"];
4
- import * as React from 'react';
5
- import PropTypes from 'prop-types';
6
- import clsx from 'clsx';
7
- import { createUnarySpacing, getValue, handleBreakpoints, unstable_resolveBreakpointValues as resolveBreakpointValues } from '@mui/system';
8
- import { deepmerge, unstable_useForkRef as useForkRef } from '@mui/utils';
3
+ const _excluded = ["children", "className", "component", "columns", "spacing", "defaultColumns", "defaultHeight", "defaultSpacing"];
9
4
  import { unstable_composeClasses as composeClasses } from '@mui/core';
10
5
  import { styled, useThemeProps } from '@mui/material/styles';
6
+ import { createUnarySpacing, getValue, handleBreakpoints, unstable_resolveBreakpointValues as resolveBreakpointValues } from '@mui/system';
7
+ import { deepmerge, unstable_useForkRef as useForkRef } from '@mui/utils';
8
+ import clsx from 'clsx';
9
+ import PropTypes from 'prop-types';
10
+ import * as React from 'react';
11
11
  import { getMasonryUtilityClass } from './masonryClasses';
12
- import MasonryContext from './MasonryContext';
13
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ export const parseToNumber = val => {
15
+ return Number(val.replace('px', ''));
16
+ };
14
17
 
15
18
  const useUtilityClasses = ownerState => {
16
19
  const {
@@ -22,54 +25,104 @@ const useUtilityClasses = ownerState => {
22
25
  return composeClasses(slots, getMasonryUtilityClass, classes);
23
26
  };
24
27
 
25
- export const style = ({
28
+ export const getStyle = ({
26
29
  ownerState,
27
30
  theme
28
31
  }) => {
29
32
  let styles = {
30
- display: 'grid',
31
- gridAutoRows: 0,
32
- padding: 0,
33
- overflow: 'auto',
34
33
  width: '100%',
35
- rowGap: 2,
36
- boxSizing: 'border-box'
34
+ display: 'flex',
35
+ flexFlow: 'column wrap',
36
+ alignContent: 'space-between',
37
+ boxSizing: 'border-box',
38
+ '& > *': {
39
+ boxSizing: 'border-box'
40
+ }
37
41
  };
38
- const base = {};
39
- Object.keys(theme.breakpoints.values).forEach(breakpoint => {
40
- if (ownerState.spacing[breakpoint] != null) {
41
- base[breakpoint] = true;
42
+ const stylesSSR = {};
43
+
44
+ if (ownerState.isSSR) {
45
+ const orderStyleSSR = {};
46
+ const defaultSpacing = Number(theme.spacing(ownerState.defaultSpacing).replace('px', ''));
47
+
48
+ for (let i = 1; i <= ownerState.defaultColumns; i += 1) {
49
+ orderStyleSSR[`&:nth-of-type(${ownerState.defaultColumns}n+${i % ownerState.defaultColumns})`] = {
50
+ order: i
51
+ };
42
52
  }
43
- });
53
+
54
+ stylesSSR.height = ownerState.defaultHeight;
55
+ stylesSSR.margin = -(defaultSpacing / 2);
56
+ stylesSSR['& > *'] = _extends({}, styles['& > *'], orderStyleSSR, {
57
+ margin: defaultSpacing / 2,
58
+ width: `calc(${(100 / ownerState.defaultColumns).toFixed(2)}% - ${defaultSpacing}px)`
59
+ });
60
+ return _extends({}, styles, stylesSSR);
61
+ }
62
+
44
63
  const spacingValues = resolveBreakpointValues({
45
64
  values: ownerState.spacing,
46
- base
65
+ breakpoints: theme.breakpoints.values
47
66
  });
48
67
  const transformer = createUnarySpacing(theme);
49
68
 
50
69
  const spacingStyleFromPropValue = propValue => {
51
- return {
52
- columnGap: getValue(transformer, propValue)
53
- };
70
+ const themeSpacingValue = Number(propValue);
71
+ const spacing = Number(getValue(transformer, themeSpacingValue).replace('px', ''));
72
+ return _extends({
73
+ margin: -(spacing / 2),
74
+ '& > *': {
75
+ margin: spacing / 2
76
+ }
77
+ }, ownerState.maxColumnHeight && {
78
+ height: Math.ceil(ownerState.maxColumnHeight + spacing)
79
+ });
54
80
  };
55
81
 
56
- styles = _extends({}, styles, handleBreakpoints({
82
+ styles = deepmerge(styles, handleBreakpoints({
57
83
  theme
58
84
  }, spacingValues, spacingStyleFromPropValue));
59
85
  const columnValues = resolveBreakpointValues({
60
86
  values: ownerState.columns,
61
- base
87
+ breakpoints: theme.breakpoints.values
62
88
  });
63
89
 
64
90
  const columnStyleFromPropValue = propValue => {
91
+ const columnValue = Number(propValue);
92
+ const width = `${(100 / columnValue).toFixed(2)}%`;
93
+ const spacing = typeof spacingValues !== 'object' ? getValue(transformer, Number(spacingValues)) : '0px';
65
94
  return {
66
- gridTemplateColumns: `repeat(${propValue}, 1fr)`
95
+ '& > *': {
96
+ width: `calc(${width} - ${spacing})`
97
+ }
67
98
  };
68
99
  };
69
100
 
70
101
  styles = deepmerge(styles, handleBreakpoints({
71
102
  theme
72
- }, columnValues, columnStyleFromPropValue));
103
+ }, columnValues, columnStyleFromPropValue)); // configure width for responsive spacing values
104
+
105
+ if (typeof spacingValues === 'object') {
106
+ styles = deepmerge(styles, handleBreakpoints({
107
+ theme
108
+ }, spacingValues, (propValue, breakpoint) => {
109
+ if (breakpoint) {
110
+ const themeSpacingValue = Number(propValue);
111
+ const lastBreakpoint = Object.keys(columnValues).pop();
112
+ const spacing = getValue(transformer, themeSpacingValue);
113
+ const column = typeof columnValues === 'object' ? columnValues[breakpoint] || columnValues[lastBreakpoint] : columnValues;
114
+ const width = `${(100 / column).toFixed(2)}%`;
115
+ return {
116
+ '& > *': {
117
+ width: `calc(${width} - ${spacing})`
118
+ }
119
+ };
120
+ }
121
+
122
+ return null;
123
+ }));
124
+ }
125
+
73
126
  return styles;
74
127
  };
75
128
  const MasonryRoot = styled('div', {
@@ -78,61 +131,143 @@ const MasonryRoot = styled('div', {
78
131
  overridesResolver: (props, styles) => {
79
132
  return [styles.root];
80
133
  }
81
- })(style);
134
+ })(getStyle);
82
135
  const Masonry = /*#__PURE__*/React.forwardRef(function Masonry(inProps, ref) {
83
136
  const props = useThemeProps({
84
137
  props: inProps,
85
138
  name: 'MuiMasonry'
86
139
  });
87
- const masonryRef = React.useRef();
88
140
 
89
141
  const {
90
142
  children,
91
143
  className,
92
144
  component = 'div',
93
145
  columns = 4,
94
- spacing = 1
146
+ spacing = 1,
147
+ defaultColumns,
148
+ defaultHeight,
149
+ defaultSpacing
95
150
  } = props,
96
151
  other = _objectWithoutPropertiesLoose(props, _excluded);
97
152
 
153
+ const masonryRef = React.useRef();
154
+ const [maxColumnHeight, setMaxColumnHeight] = React.useState();
155
+ const isSSR = !maxColumnHeight && defaultHeight && defaultColumns !== undefined && defaultSpacing !== undefined;
156
+ const [numberOfLineBreaks, setNumberOfLineBreaks] = React.useState(isSSR ? defaultColumns - 1 : 0);
157
+
98
158
  const ownerState = _extends({}, props, {
99
159
  spacing,
100
- columns
160
+ columns,
161
+ maxColumnHeight,
162
+ defaultColumns,
163
+ defaultHeight,
164
+ defaultSpacing,
165
+ isSSR
101
166
  });
102
167
 
103
168
  const classes = useUtilityClasses(ownerState);
104
- const contextValue = React.useMemo(() => ({
105
- spacing
106
- }), [spacing]);
107
- let didWarn = false;
108
169
  React.useEffect(() => {
109
- // scroller always appears when masonry's height goes beyond 2,000px on Chrome
110
- const handleScroll = () => {
111
- if (masonryRef.current.clientHeight === 1998 && !didWarn) {
112
- console.warn(['MUI: The Masonry can have the maximum height of 2,000px on Chrome browser.', 'Items that go beyond this height fail to be rendered on Chrome browser.', 'You can find more in this open issue: https://github.com/mui-org/material-ui/issues/27934'].join('\n')); // eslint-disable-next-line react-hooks/exhaustive-deps
170
+ const handleResize = () => {
171
+ const parentWidth = masonryRef.current.clientWidth;
172
+ const childWidth = masonryRef.current.firstChild.clientWidth;
173
+ const firstChildComputedStyle = window.getComputedStyle(masonryRef.current.firstChild);
174
+ const firstChildMarginLeft = parseToNumber(firstChildComputedStyle.marginLeft);
175
+ const firstChildMarginRight = parseToNumber(firstChildComputedStyle.marginRight);
113
176
 
114
- didWarn = true;
177
+ if (parentWidth === 0 || childWidth === 0) {
178
+ return;
115
179
  }
116
- };
117
180
 
181
+ const currentNumberOfColumns = Math.round(parentWidth / (childWidth + firstChildMarginLeft + firstChildMarginRight));
182
+ const columnHeights = new Array(currentNumberOfColumns).fill(0);
183
+ let skip = false;
184
+ masonryRef.current.childNodes.forEach(child => {
185
+ if (child.nodeType !== Node.ELEMENT_NODE || child.dataset.class === 'line-break' || skip) {
186
+ return;
187
+ }
188
+
189
+ const childComputedStyle = window.getComputedStyle(child);
190
+ const childMarginTop = parseToNumber(childComputedStyle.marginTop);
191
+ const childMarginBottom = parseToNumber(childComputedStyle.marginBottom); // if any one of children isn't rendered yet, masonry's height shouldn't be computed yet
192
+
193
+ const childHeight = parseToNumber(childComputedStyle.height) ? Math.ceil(parseToNumber(childComputedStyle.height)) + childMarginTop + childMarginBottom : 0;
194
+
195
+ if (childHeight === 0) {
196
+ skip = true;
197
+ return;
198
+ } // if there is a nested image that isn't rendered yet, masonry's height shouldn't be computed yet
199
+
200
+
201
+ for (let i = 0; i < child.childNodes.length; i += 1) {
202
+ const nestedChild = child.childNodes[i];
203
+
204
+ if (nestedChild.tagName === 'IMG' && nestedChild.clientHeight === 0) {
205
+ skip = true;
206
+ break;
207
+ }
208
+ }
209
+
210
+ if (!skip) {
211
+ // find the current shortest column (where the current item will be placed)
212
+ const currentMinColumnIndex = columnHeights.indexOf(Math.min(...columnHeights));
213
+ columnHeights[currentMinColumnIndex] += childHeight;
214
+ const order = currentMinColumnIndex + 1;
215
+ child.style.order = order;
216
+ }
217
+ });
218
+
219
+ if (!skip) {
220
+ setMaxColumnHeight(Math.max(...columnHeights));
221
+ const numOfLineBreaks = currentNumberOfColumns > 0 ? currentNumberOfColumns - 1 : 0;
222
+ setNumberOfLineBreaks(numOfLineBreaks);
223
+ }
224
+ }; // IE and old browsers are not supported
225
+
226
+
227
+ if (typeof ResizeObserver === 'undefined') {
228
+ return undefined;
229
+ }
230
+
231
+ const resizeObserver = new ResizeObserver(handleResize);
118
232
  const container = masonryRef.current;
119
- container.addEventListener('scroll', handleScroll);
233
+
234
+ if (container) {
235
+ // only the masonry container and its first child are observed for resizing;
236
+ // this might cause unforeseen problems in some use cases;
237
+ resizeObserver.observe(container);
238
+
239
+ if (container.firstChild) {
240
+ resizeObserver.observe(container.firstChild);
241
+ }
242
+ }
243
+
120
244
  return () => {
121
- container.removeEventListener('scroll', handleScroll);
245
+ resizeObserver.disconnect();
122
246
  };
123
- }, []);
247
+ }, [columns, spacing, children]);
124
248
  const handleRef = useForkRef(ref, masonryRef);
125
- return /*#__PURE__*/_jsx(MasonryContext.Provider, {
126
- value: contextValue,
127
- children: /*#__PURE__*/_jsx(MasonryRoot, _extends({
128
- as: component,
129
- className: clsx(classes.root, className),
130
- ref: handleRef,
131
- ownerState: ownerState
132
- }, other, {
133
- children: children
134
- }))
135
- });
249
+ const lineBreakStyle = {
250
+ flexBasis: '100%',
251
+ width: 0,
252
+ margin: 0,
253
+ padding: 0
254
+ }; // columns are likely to have different heights and hence can start to merge;
255
+ // a line break at the end of each column prevents columns from merging
256
+
257
+ const lineBreaks = new Array(numberOfLineBreaks).fill('').map((_, index) => /*#__PURE__*/_jsx("span", {
258
+ "data-class": "line-break",
259
+ style: _extends({}, lineBreakStyle, {
260
+ order: index + 1
261
+ })
262
+ }, index));
263
+ return /*#__PURE__*/_jsxs(MasonryRoot, _extends({
264
+ as: component,
265
+ className: clsx(classes.root, className),
266
+ ref: handleRef,
267
+ ownerState: ownerState
268
+ }, other, {
269
+ children: [children, lineBreaks]
270
+ }));
136
271
  });
137
272
  process.env.NODE_ENV !== "production" ? Masonry.propTypes
138
273
  /* remove-proptypes */
@@ -143,7 +278,7 @@ process.env.NODE_ENV !== "production" ? Masonry.propTypes
143
278
  // ----------------------------------------------------------------------
144
279
 
145
280
  /**
146
- * The content of the component. It's recommended to be `<MasonryItem />`s.
281
+ * The content of the component.
147
282
  */
148
283
  children: PropTypes
149
284
  /* @typescript-to-proptypes-ignore */
@@ -171,6 +306,21 @@ process.env.NODE_ENV !== "production" ? Masonry.propTypes
171
306
  */
172
307
  component: PropTypes.elementType,
173
308
 
309
+ /**
310
+ * The default number of columns of the component. This is provided for server-side rendering.
311
+ */
312
+ defaultColumns: PropTypes.number,
313
+
314
+ /**
315
+ * The default height of the component in px. This is provided for server-side rendering.
316
+ */
317
+ defaultHeight: PropTypes.number,
318
+
319
+ /**
320
+ * The default spacing of the component. Like `spacing`, it is a factor of the theme's spacing. This is provided for server-side rendering.
321
+ */
322
+ defaultSpacing: PropTypes.number,
323
+
174
324
  /**
175
325
  * Defines the space between children. It is a factor of the theme's spacing.
176
326
  * @default 1
@@ -180,6 +330,6 @@ process.env.NODE_ENV !== "production" ? Masonry.propTypes
180
330
  /**
181
331
  * Allows defining system overrides as well as additional CSS styles.
182
332
  */
183
- sx: PropTypes.object
333
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
184
334
  } : void 0;
185
335
  export default Masonry;
@@ -152,6 +152,7 @@ process.env.NODE_ENV !== "production" ? MobileDatePicker.propTypes
152
152
 
153
153
  /**
154
154
  * If `true`, the picker and text field are disabled.
155
+ * @default false
155
156
  */
156
157
  disabled: PropTypes.bool,
157
158
 
@@ -333,6 +334,7 @@ process.env.NODE_ENV !== "production" ? MobileDatePicker.propTypes
333
334
 
334
335
  /**
335
336
  * Make picker read only.
337
+ * @default false
336
338
  */
337
339
  readOnly: PropTypes.bool,
338
340
 
@@ -200,6 +200,7 @@ process.env.NODE_ENV !== "production" ? MobileDateRangePicker.propTypes
200
200
 
201
201
  /**
202
202
  * If `true`, the picker and text field are disabled.
203
+ * @default false
203
204
  */
204
205
  disabled: PropTypes.bool,
205
206
 
@@ -380,6 +381,7 @@ process.env.NODE_ENV !== "production" ? MobileDateRangePicker.propTypes
380
381
 
381
382
  /**
382
383
  * Make picker read only.
384
+ * @default false
383
385
  */
384
386
  readOnly: PropTypes.bool,
385
387
 
@@ -169,6 +169,7 @@ process.env.NODE_ENV !== "production" ? MobileDateTimePicker.propTypes
169
169
 
170
170
  /**
171
171
  * If `true`, the picker and text field are disabled.
172
+ * @default false
172
173
  */
173
174
  disabled: PropTypes.bool,
174
175
 
@@ -402,6 +403,7 @@ process.env.NODE_ENV !== "production" ? MobileDateTimePicker.propTypes
402
403
 
403
404
  /**
404
405
  * Make picker read only.
406
+ * @default false
405
407
  */
406
408
  readOnly: PropTypes.bool,
407
409
 
@@ -16,6 +16,8 @@ export interface MonthPickerProps<TDate> {
16
16
  };
17
17
  /** Date value for the MonthPicker */
18
18
  date: TDate | null;
19
+ /** If `true` picker is disabled */
20
+ disabled?: boolean;
19
21
  /** If `true` past days are disabled. */
20
22
  disablePast?: boolean | null;
21
23
  /** If `true` future days are disabled. */
@@ -27,6 +29,8 @@ export interface MonthPickerProps<TDate> {
27
29
  /** Callback fired on date change. */
28
30
  onChange: PickerOnChangeFn<TDate>;
29
31
  onMonthChange?: (date: TDate) => void | Promise<void>;
32
+ /** If `true` picker is readonly */
33
+ readOnly?: boolean;
30
34
  /**
31
35
  * The system prop that allows defining system overrides as well as additional CSS styles.
32
36
  */
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["className", "date", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "onMonthChange"];
3
+ const _excluded = ["className", "date", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "onMonthChange", "readOnly"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
@@ -43,12 +43,14 @@ const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inProps,
43
43
  const {
44
44
  className,
45
45
  date,
46
+ disabled,
46
47
  disableFuture,
47
48
  disablePast,
48
49
  maxDate,
49
50
  minDate,
50
51
  onChange,
51
- onMonthChange
52
+ onMonthChange,
53
+ readOnly
52
54
  } = props,
53
55
  other = _objectWithoutPropertiesLoose(props, _excluded);
54
56
 
@@ -67,6 +69,10 @@ const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inProps,
67
69
  };
68
70
 
69
71
  const onMonthSelect = month => {
72
+ if (readOnly) {
73
+ return;
74
+ }
75
+
70
76
  const newDate = utils.setMonth(date || now, month);
71
77
  onChange(newDate, 'finish');
72
78
 
@@ -87,7 +93,7 @@ const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inProps,
87
93
  value: monthNumber,
88
94
  selected: monthNumber === currentMonth,
89
95
  onSelect: onMonthSelect,
90
- disabled: shouldDisableMonth(month),
96
+ disabled: disabled || shouldDisableMonth(month),
91
97
  children: monthText
92
98
  }, monthText);
93
99
  })
@@ -116,6 +122,11 @@ process.env.NODE_ENV !== "production" ? MonthPicker.propTypes
116
122
  */
117
123
  date: PropTypes.any,
118
124
 
125
+ /**
126
+ * If `true` picker is disabled
127
+ */
128
+ disabled: PropTypes.bool,
129
+
119
130
  /**
120
131
  * If `true` future days are disabled.
121
132
  */
@@ -146,10 +157,15 @@ process.env.NODE_ENV !== "production" ? MonthPicker.propTypes
146
157
  */
147
158
  onMonthChange: PropTypes.func,
148
159
 
160
+ /**
161
+ * If `true` picker is readonly
162
+ */
163
+ readOnly: PropTypes.bool,
164
+
149
165
  /**
150
166
  * The system prop that allows defining system overrides as well as additional CSS styles.
151
167
  */
152
- sx: PropTypes.object
168
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object])
153
169
  } : void 0;
154
170
  /**
155
171
  *
@@ -374,7 +374,7 @@ process.env.NODE_ENV !== "production" ? PickersDay.propTypes
374
374
  /**
375
375
  * The system prop that allows defining system overrides as well as additional CSS styles.
376
376
  */
377
- sx: PropTypes.object,
377
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])), PropTypes.func, PropTypes.object]),
378
378
 
379
379
  /**
380
380
  * If `true`, renders as today date.
@@ -121,6 +121,7 @@ process.env.NODE_ENV !== "production" ? StaticDatePicker.propTypes
121
121
 
122
122
  /**
123
123
  * If `true`, the picker and text field are disabled.
124
+ * @default false
124
125
  */
125
126
  disabled: PropTypes.bool,
126
127
 
@@ -302,6 +303,7 @@ process.env.NODE_ENV !== "production" ? StaticDatePicker.propTypes
302
303
 
303
304
  /**
304
305
  * Make picker read only.
306
+ * @default false
305
307
  */
306
308
  readOnly: PropTypes.bool,
307
309