@mui/x-data-grid 6.1.0 → 6.2.1

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 (107) hide show
  1. package/CHANGELOG.md +101 -1
  2. package/components/GridHeader.d.ts +2 -2
  3. package/components/GridHeader.js +4 -6
  4. package/components/GridPagination.d.ts +2 -2
  5. package/components/base/GridBody.d.ts +0 -1
  6. package/components/base/GridBody.js +32 -15
  7. package/components/columnSelection/GridCellCheckboxRenderer.d.ts +1 -1
  8. package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  9. package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
  10. package/components/containers/GridMainContainer.d.ts +3 -1
  11. package/components/containers/GridMainContainer.js +3 -2
  12. package/components/containers/GridRoot.js +0 -5
  13. package/components/index.d.ts +0 -1
  14. package/components/index.js +0 -1
  15. package/components/panel/GridColumnsPanel.js +3 -2
  16. package/components/panel/GridPanel.d.ts +2 -2
  17. package/components/panel/GridPanel.js +2 -1
  18. package/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
  19. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
  20. package/components/panel/filterPanel/GridFilterPanel.js +5 -2
  21. package/hooks/features/dimensions/gridDimensionsApi.d.ts +4 -0
  22. package/hooks/features/dimensions/useGridDimensions.js +49 -10
  23. package/hooks/features/export/useGridPrintExport.js +3 -1
  24. package/hooks/features/rowSelection/useGridRowSelection.js +5 -26
  25. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +37 -16
  26. package/hooks/features/virtualization/useGridVirtualScroller.js +11 -5
  27. package/index.js +1 -1
  28. package/joy/index.d.ts +2 -0
  29. package/joy/index.js +2 -0
  30. package/joy/joySlots.d.ts +4 -0
  31. package/joy/joySlots.js +71 -0
  32. package/joy/package.json +6 -0
  33. package/legacy/components/GridHeader.js +4 -6
  34. package/legacy/components/base/GridBody.js +33 -16
  35. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  36. package/legacy/components/containers/GridMainContainer.js +3 -2
  37. package/legacy/components/containers/GridRoot.js +0 -5
  38. package/legacy/components/index.js +0 -1
  39. package/legacy/components/panel/GridColumnsPanel.js +3 -2
  40. package/legacy/components/panel/GridPanel.js +2 -1
  41. package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
  42. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
  43. package/legacy/components/panel/filterPanel/GridFilterPanel.js +5 -2
  44. package/legacy/hooks/features/dimensions/useGridDimensions.js +55 -12
  45. package/legacy/hooks/features/export/useGridPrintExport.js +3 -1
  46. package/legacy/hooks/features/rowSelection/useGridRowSelection.js +5 -24
  47. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +12 -6
  48. package/legacy/index.js +1 -1
  49. package/legacy/joy/index.js +2 -0
  50. package/legacy/joy/joySlots.js +73 -0
  51. package/legacy/locales/frFR.js +7 -9
  52. package/legacy/locales/urPK.js +6 -6
  53. package/legacy/utils/utils.js +1 -1
  54. package/locales/frFR.js +7 -9
  55. package/locales/urPK.js +6 -6
  56. package/material/index.d.ts +1 -1
  57. package/models/gridSlotsComponent.d.ts +2 -2
  58. package/modern/components/GridHeader.js +4 -6
  59. package/modern/components/base/GridBody.js +32 -15
  60. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  61. package/modern/components/containers/GridMainContainer.js +3 -2
  62. package/modern/components/containers/GridRoot.js +0 -5
  63. package/modern/components/index.js +0 -1
  64. package/modern/components/panel/GridColumnsPanel.js +3 -2
  65. package/modern/components/panel/GridPanel.js +2 -1
  66. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
  67. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +33 -29
  68. package/modern/components/panel/filterPanel/GridFilterPanel.js +5 -2
  69. package/modern/hooks/features/dimensions/useGridDimensions.js +48 -10
  70. package/modern/hooks/features/export/useGridPrintExport.js +3 -1
  71. package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -26
  72. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +11 -5
  73. package/modern/index.js +1 -1
  74. package/modern/joy/index.js +2 -0
  75. package/modern/joy/joySlots.js +71 -0
  76. package/modern/locales/frFR.js +7 -9
  77. package/modern/locales/urPK.js +6 -6
  78. package/modern/utils/utils.js +1 -1
  79. package/node/components/GridHeader.js +5 -8
  80. package/node/components/base/GridBody.js +32 -15
  81. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  82. package/node/components/containers/GridMainContainer.js +5 -3
  83. package/node/components/containers/GridRoot.js +0 -5
  84. package/node/components/index.js +0 -11
  85. package/node/components/panel/GridColumnsPanel.js +3 -2
  86. package/node/components/panel/GridPanel.js +2 -1
  87. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
  88. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +32 -29
  89. package/node/components/panel/filterPanel/GridFilterPanel.js +5 -2
  90. package/node/hooks/features/dimensions/useGridDimensions.js +47 -9
  91. package/node/hooks/features/export/useGridPrintExport.js +3 -1
  92. package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -25
  93. package/node/hooks/features/virtualization/useGridVirtualScroller.js +11 -5
  94. package/node/index.js +1 -1
  95. package/node/joy/index.js +13 -0
  96. package/node/joy/joySlots.js +79 -0
  97. package/node/locales/frFR.js +7 -9
  98. package/node/locales/urPK.js +6 -6
  99. package/node/utils/utils.js +1 -1
  100. package/package.json +1 -1
  101. package/utils/utils.d.ts +1 -1
  102. package/utils/utils.js +1 -1
  103. package/components/GridAutoSizer.d.ts +0 -44
  104. package/components/GridAutoSizer.js +0 -126
  105. package/legacy/components/GridAutoSizer.js +0 -132
  106. package/modern/components/GridAutoSizer.js +0 -125
  107. package/node/components/GridAutoSizer.js +0 -132
@@ -8,6 +8,7 @@ import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
8
8
  import { getValueFromValueOptions, isSingleSelectColDef } from './filterPanelUtils';
9
9
  import { createElement as _createElement } from "react";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
12
  const renderSingleSelectOptions = ({
12
13
  column: {
13
14
  valueOptions,
@@ -45,10 +46,9 @@ function GridFilterInputSingleSelect(props) {
45
46
  others = _objectWithoutPropertiesLoose(props, _excluded);
46
47
  const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
47
48
  const id = useId();
49
+ const labelId = useId();
48
50
  const rootProps = useGridRootProps();
49
- const baseSelectProps = rootProps.slotProps?.baseSelect || {};
50
- const isSelectNative = baseSelectProps.native ?? true;
51
- const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
51
+ const isSelectNative = rootProps.slotProps?.baseSelect?.native ?? true;
52
52
  let resolvedColumn = null;
53
53
  if (item.field) {
54
54
  const column = apiRef.current.getColumn(item.field);
@@ -99,33 +99,37 @@ function GridFilterInputSingleSelect(props) {
99
99
  if (!isSingleSelectColDef(resolvedColumn)) {
100
100
  return null;
101
101
  }
102
- return /*#__PURE__*/_jsx(rootProps.slots.baseTextField, _extends({
103
- // TODO: use baseSelect slot
104
- id: id,
105
- label: apiRef.current.getLocaleText('filterPanelInputLabel'),
106
- placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder'),
107
- value: filterValueState,
108
- onChange: onFilterChange,
109
- variant: "standard",
110
- type: type || 'text',
111
- InputLabelProps: {
112
- shrink: true
113
- },
114
- inputRef: focusElementRef,
115
- select: true,
116
- SelectProps: _extends({
102
+ const label = apiRef.current.getLocaleText('filterPanelInputLabel');
103
+ return /*#__PURE__*/_jsxs(React.Fragment, {
104
+ children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, rootProps.slotProps?.baseInputLabel, {
105
+ id: labelId,
106
+ shrink: true,
107
+ variant: "standard",
108
+ children: label
109
+ })), /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
110
+ id: id,
111
+ label: label,
112
+ labelId: labelId,
113
+ value: filterValueState,
114
+ onChange: onFilterChange,
115
+ variant: "standard",
116
+ type: type || 'text',
117
+ inputProps: {
118
+ ref: focusElementRef,
119
+ placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder')
120
+ },
117
121
  native: isSelectNative
118
- }, rootProps.slotProps?.baseSelect)
119
- }, others, rootProps.slotProps?.baseTextField, {
120
- children: renderSingleSelectOptions({
121
- column: resolvedColumn,
122
- OptionComponent: rootProps.slots.baseSelectOption,
123
- getOptionLabel,
124
- getOptionValue,
125
- isSelectNative,
126
- baseSelectOptionProps
127
- })
128
- }));
122
+ }, others, rootProps.slotProps?.baseSelect, {
123
+ children: renderSingleSelectOptions({
124
+ column: resolvedColumn,
125
+ OptionComponent: rootProps.slots.baseSelectOption,
126
+ getOptionLabel,
127
+ getOptionValue,
128
+ isSelectNative,
129
+ baseSelectOptionProps: rootProps.slotProps?.baseSelectOption
130
+ })
131
+ }))]
132
+ });
129
133
  }
130
134
  process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes = {
131
135
  // ----------------------------- Warning --------------------------------
@@ -26,6 +26,7 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
26
26
  const filterModel = useGridSelector(apiRef, gridFilterModelSelector);
27
27
  const filterableColumns = useGridSelector(apiRef, gridFilterableColumnDefinitionsSelector);
28
28
  const lastFilterRef = React.useRef(null);
29
+ const placeholderFilter = React.useRef(null);
29
30
  const {
30
31
  logicOperators = [GridLogicOperator.And, GridLogicOperator.Or],
31
32
  columnsSort,
@@ -89,8 +90,10 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
89
90
  if (filterModel.items.length) {
90
91
  return filterModel.items;
91
92
  }
92
- const defaultFilter = getDefaultFilter();
93
- return defaultFilter ? [defaultFilter] : [];
93
+ if (!placeholderFilter.current) {
94
+ placeholderFilter.current = getDefaultFilter();
95
+ }
96
+ return placeholderFilter.current ? [placeholderFilter.current] : [];
94
97
  }, [filterModel.items, getDefaultFilter]);
95
98
  const hasMultipleFilters = items.length > 1;
96
99
  const addNewFilter = () => {
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { unstable_debounce as debounce, unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
2
+ import { unstable_debounce as debounce, unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect, unstable_ownerWindow as ownerWindow } from '@mui/utils';
3
3
  import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
4
4
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
5
5
  import { useGridLogger } from '../../utils/useGridLogger';
@@ -10,6 +10,7 @@ import { getVisibleRows } from '../../utils/useGridVisibleRows';
10
10
  import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
11
11
  import { calculatePinnedRowsHeight } from '../rows/gridRowsUtils';
12
12
  import { getTotalHeaderHeight } from '../columns/gridColumnsUtils';
13
+ import { gridClasses } from '../../../constants/gridClasses';
13
14
  const isTestEnvironment = process.env.NODE_ENV === 'test';
14
15
  const hasScroll = ({
15
16
  content,
@@ -113,10 +114,20 @@ export function useGridDimensions(apiRef, props) {
113
114
  apiRef.current.publishEvent('viewportInnerSizeChange', newFullDimensions.viewportInnerSize);
114
115
  }
115
116
  }, [apiRef, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, totalHeaderHeight]);
117
+ const [savedSize, setSavedSize] = React.useState();
118
+ const debouncedSetSavedSize = React.useMemo(() => debounce(setSavedSize, 60), []);
119
+ const previousSize = React.useRef();
120
+ useEnhancedEffect(() => {
121
+ if (savedSize) {
122
+ updateGridDimensionsRef();
123
+ apiRef.current.publishEvent('debouncedResize', rootDimensionsRef.current);
124
+ }
125
+ }, [apiRef, savedSize, updateGridDimensionsRef]);
126
+
127
+ // This is the function called by apiRef.current.resize()
116
128
  const resize = React.useCallback(() => {
117
- updateGridDimensionsRef();
118
- apiRef.current.publishEvent('debouncedResize', rootDimensionsRef.current);
119
- }, [apiRef, updateGridDimensionsRef]);
129
+ apiRef.current.computeSizeAndPublishResizeEvent();
130
+ }, [apiRef]);
120
131
  const getRootDimensions = React.useCallback(() => fullDimensionsRef.current, []);
121
132
  const getViewportPageSize = React.useCallback(() => {
122
133
  const dimensions = apiRef.current.getRootDimensions();
@@ -138,17 +149,44 @@ export function useGridDimensions(apiRef, props) {
138
149
  const maximumPageSizeWithoutScrollBar = Math.floor(dimensions.viewportInnerSize.height / rowHeight);
139
150
  return Math.min(maximumPageSizeWithoutScrollBar, currentPage.rows.length);
140
151
  }, [apiRef, props.pagination, props.paginationMode, props.getRowHeight, rowHeight]);
152
+ const computeSizeAndPublishResizeEvent = React.useCallback(() => {
153
+ const rootEl = apiRef.current.rootElementRef?.current;
154
+ const mainEl = rootEl?.querySelector(`.${gridClasses.main}`);
155
+ if (!mainEl) {
156
+ return;
157
+ }
158
+ const height = mainEl.offsetHeight || 0;
159
+ const width = mainEl.offsetWidth || 0;
160
+ const win = ownerWindow(mainEl);
161
+ const computedStyle = win.getComputedStyle(mainEl);
162
+ const paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
163
+ const paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
164
+ const paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
165
+ const paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
166
+ const newHeight = height - paddingTop - paddingBottom;
167
+ const newWidth = width - paddingLeft - paddingRight;
168
+ const hasHeightChanged = newHeight !== previousSize.current?.height;
169
+ const hasWidthChanged = newWidth !== previousSize.current?.width;
170
+ if (!previousSize.current || hasHeightChanged || hasWidthChanged) {
171
+ const size = {
172
+ width: newWidth,
173
+ height: newHeight
174
+ };
175
+ apiRef.current.publishEvent('resize', size);
176
+ previousSize.current = size;
177
+ }
178
+ }, [apiRef]);
141
179
  const dimensionsApi = {
142
180
  resize,
143
181
  getRootDimensions
144
182
  };
145
183
  const dimensionsPrivateApi = {
146
184
  getViewportPageSize,
147
- updateGridDimensionsRef
185
+ updateGridDimensionsRef,
186
+ computeSizeAndPublishResizeEvent
148
187
  };
149
188
  useGridApiMethod(apiRef, dimensionsApi, 'public');
150
189
  useGridApiMethod(apiRef, dimensionsPrivateApi, 'private');
151
- const debounceResize = React.useMemo(() => debounce(resize, 60), [resize]);
152
190
  const isFirstSizing = React.useRef(true);
153
191
  const handleResize = React.useCallback(size => {
154
192
  rootDimensionsRef.current = size;
@@ -165,18 +203,18 @@ export function useGridDimensions(apiRef, props) {
165
203
  }
166
204
  if (isTestEnvironment) {
167
205
  // We don't need to debounce the resize for tests.
168
- resize();
206
+ setSavedSize(size);
169
207
  isFirstSizing.current = false;
170
208
  return;
171
209
  }
172
210
  if (isFirstSizing.current) {
173
211
  // We want to initialize the grid dimensions as soon as possible to avoid flickering
174
- resize();
212
+ setSavedSize(size);
175
213
  isFirstSizing.current = false;
176
214
  return;
177
215
  }
178
- debounceResize();
179
- }, [props.autoHeight, debounceResize, logger, resize]);
216
+ debouncedSetSavedSize(size);
217
+ }, [props.autoHeight, debouncedSetSavedSize, logger]);
180
218
  useEnhancedEffect(() => updateGridDimensionsRef(), [updateGridDimensionsRef]);
181
219
  useGridApiOptionHandler(apiRef, 'sortedRowsSet', updateGridDimensionsRef);
182
220
  useGridApiOptionHandler(apiRef, 'paginationModelChange', updateGridDimensionsRef);
@@ -121,7 +121,9 @@ export const useGridPrintExport = (apiRef, props) => {
121
121
  printDoc.body.classList.add(...normalizeOptions.bodyClassName.split(' '));
122
122
  }
123
123
  if (normalizeOptions.copyStyles) {
124
- const headStyleElements = doc.current.querySelectorAll("style, link[rel='stylesheet']");
124
+ const rootCandidate = gridRootElement.getRootNode();
125
+ const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc.current;
126
+ const headStyleElements = root.querySelectorAll("style, link[rel='stylesheet']");
125
127
  for (let i = 0; i < headStyleElements.length; i += 1) {
126
128
  const node = headStyleElements[i];
127
129
  if (node.tagName === 'STYLE') {
@@ -11,7 +11,7 @@ import { gridExpandedSortedRowIdsSelector } from '../filter/gridFilterSelector';
11
11
  import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from '../../../colDef';
12
12
  import { GridCellModes } from '../../../models/gridEditRowModel';
13
13
  import { isKeyboardEvent, isNavigationKey } from '../../../utils/keyboardUtils';
14
- import { getVisibleRows, useGridVisibleRows } from '../../utils/useGridVisibleRows';
14
+ import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
15
15
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
16
16
  import { gridClasses } from '../../../constants/gridClasses';
17
17
  const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
@@ -58,8 +58,6 @@ export const useGridRowSelection = (apiRef, props) => {
58
58
  checkboxSelection,
59
59
  disableMultipleRowSelection,
60
60
  disableRowSelectionOnClick,
61
- pagination,
62
- paginationMode,
63
61
  isRowSelectable: propIsRowSelectable
64
62
  } = props;
65
63
  const canHaveMultipleSelection = !disableMultipleRowSelection || checkboxSelection;
@@ -375,32 +373,13 @@ export const useGridRowSelection = (apiRef, props) => {
375
373
  }
376
374
  }, [apiRef, isRowSelectable, isStateControlled, props.rowSelection]);
377
375
  React.useEffect(() => {
378
- if (!props.rowSelection) {
376
+ if (!props.rowSelection || isStateControlled) {
379
377
  return;
380
378
  }
381
379
  const currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
382
380
  if (!canHaveMultipleSelection && currentSelection.length > 1) {
383
- const {
384
- rows: currentPageRows
385
- } = getVisibleRows(apiRef, {
386
- pagination,
387
- paginationMode
388
- });
389
- const currentPageRowsLookup = currentPageRows.reduce((acc, {
390
- id
391
- }) => {
392
- acc[id] = true;
393
- return acc;
394
- }, {});
395
- const firstSelectableRow = currentSelection.find(id => {
396
- let isSelectable = true;
397
- if (isRowSelectable) {
398
- isSelectable = isRowSelectable(id);
399
- }
400
- return isSelectable && currentPageRowsLookup[id]; // Check if the row is in the current page
401
- });
402
-
403
- apiRef.current.setRowSelectionModel(firstSelectableRow !== undefined ? [firstSelectableRow] : []);
381
+ // See https://github.com/mui/mui-x/issues/8455
382
+ apiRef.current.setRowSelectionModel([]);
404
383
  }
405
- }, [apiRef, canHaveMultipleSelection, checkboxSelection, disableMultipleRowSelection, isRowSelectable, pagination, paginationMode, props.rowSelection]);
384
+ }, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
406
385
  };
@@ -174,11 +174,13 @@ export const useGridVirtualScroller = props => {
174
174
  height: rootRef.current.clientHeight
175
175
  });
176
176
  }, [rowsMeta.currentPageTotalHeight]);
177
- const handleResize = React.useCallback(params => {
178
- setContainerDimensions({
179
- width: params.width,
180
- height: params.height
181
- });
177
+ const handleResize = React.useCallback(() => {
178
+ if (rootRef.current) {
179
+ setContainerDimensions({
180
+ width: rootRef.current.clientWidth,
181
+ height: rootRef.current.clientHeight
182
+ });
183
+ }
182
184
  }, []);
183
185
  useGridApiEventHandler(apiRef, 'debouncedResize', handleResize);
184
186
  const updateRenderZonePosition = React.useCallback(nextRenderContext => {
@@ -304,6 +306,7 @@ export const useGridVirtualScroller = props => {
304
306
  renderContext
305
307
  }) => {
306
308
  const {
309
+ onRowRender,
307
310
  renderContext: nextRenderContext,
308
311
  minFirstColumn = renderZoneMinColumnIndex,
309
312
  maxLastColumn = renderZoneMaxColumnIndex,
@@ -387,6 +390,9 @@ export const useGridVirtualScroller = props => {
387
390
  } else {
388
391
  isSelected = apiRef.current.isRowSelectable(id);
389
392
  }
393
+ if (onRowRender) {
394
+ onRowRender(id);
395
+ }
390
396
  const focusedCell = cellFocus !== null && cellFocus.id === id ? cellFocus.field : null;
391
397
  let tabbableCell = null;
392
398
  if (cellTabIndex !== null && cellTabIndex.id === id) {
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.1.0
2
+ * @mui/x-data-grid v6.2.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1,2 @@
1
+ import joySlots from './joySlots';
2
+ export { joySlots as unstable_joySlots };
@@ -0,0 +1,71 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["touchRippleRef", "inputProps", "onChange", "color", "size", "checked", "sx", "value", "inputRef"];
4
+ import * as React from 'react';
5
+ import JoyCheckbox from '@mui/joy/Checkbox';
6
+ import JoyInput from '@mui/joy/Input';
7
+ import JoyFormControl from '@mui/joy/FormControl';
8
+ import JoyFormLabel from '@mui/joy/FormLabel';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ const Checkbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
12
+ let {
13
+ inputProps,
14
+ onChange,
15
+ checked,
16
+ inputRef
17
+ } = _ref,
18
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
19
+ return /*#__PURE__*/_jsx(JoyCheckbox, _extends({}, props, {
20
+ slotProps: {
21
+ input: _extends({}, inputProps, {
22
+ ref: inputRef
23
+ })
24
+ },
25
+ ref: ref,
26
+ checked: checked,
27
+ onChange: onChange
28
+ }));
29
+ });
30
+ const TextField = /*#__PURE__*/React.forwardRef(({
31
+ onChange,
32
+ label,
33
+ placeholder,
34
+ value,
35
+ inputRef,
36
+ type
37
+ }, ref) => {
38
+ return /*#__PURE__*/_jsxs(JoyFormControl, {
39
+ ref: ref,
40
+ children: [/*#__PURE__*/_jsx(JoyFormLabel, {
41
+ sx: {
42
+ fontSize: 12
43
+ },
44
+ children: label
45
+ }), /*#__PURE__*/_jsx(JoyInput, {
46
+ type: type,
47
+ value: value,
48
+ onChange: onChange,
49
+ placeholder: placeholder,
50
+ size: "sm",
51
+ slotProps: {
52
+ input: {
53
+ ref: inputRef
54
+ }
55
+ }
56
+ })]
57
+ });
58
+ });
59
+ const joySlots = {
60
+ baseCheckbox: Checkbox,
61
+ baseTextField: TextField
62
+ // BaseFormControl: MUIFormControl,
63
+ // BaseSelect: MUISelect,
64
+ // BaseSwitch: MUISwitch,
65
+ // BaseButton: MUIButton,
66
+ // BaseIconButton: MUIIconButton,
67
+ // BaseTooltip: MUITooltip,
68
+ // BasePopper: MUIPopper,
69
+ };
70
+
71
+ export default joySlots;
@@ -111,15 +111,13 @@ const frFRGrid = {
111
111
  expandDetailPanel: 'Afficher',
112
112
  collapseDetailPanel: 'Masquer',
113
113
  // Row reordering text
114
- rowReorderingHeaderName: 'Positionnement des lignes'
115
-
114
+ rowReorderingHeaderName: 'Positionnement des lignes',
116
115
  // Aggregation
117
- // aggregationMenuItemHeader: 'Aggregation',
118
- // aggregationFunctionLabelSum: 'sum',
119
- // aggregationFunctionLabelAvg: 'avg',
120
- // aggregationFunctionLabelMin: 'min',
121
- // aggregationFunctionLabelMax: 'max',
122
- // aggregationFunctionLabelSize: 'size',
116
+ aggregationMenuItemHeader: 'Agrégation',
117
+ aggregationFunctionLabelSum: 'Somme',
118
+ aggregationFunctionLabelAvg: 'Moyenne',
119
+ aggregationFunctionLabelMin: 'Minimum',
120
+ aggregationFunctionLabelMax: 'Maximum',
121
+ aggregationFunctionLabelSize: "Nombre d'éléments"
123
122
  };
124
-
125
123
  export const frFR = getGridLocalization(frFRGrid, frFRCore);
@@ -113,11 +113,11 @@ const urPKGrid = {
113
113
  // Row reordering text
114
114
  rowReorderingHeaderName: 'قطاروں کی ترتیب تبدیل کریں',
115
115
  // Aggregation
116
- aggregationMenuItemHeader: 'Aggregation',
117
- aggregationFunctionLabelSum: 'sum',
118
- aggregationFunctionLabelAvg: 'avg',
119
- aggregationFunctionLabelMin: 'min',
120
- aggregationFunctionLabelMax: 'max',
121
- aggregationFunctionLabelSize: 'size'
116
+ aggregationMenuItemHeader: 'ایگریگیشن',
117
+ aggregationFunctionLabelSum: 'کل',
118
+ aggregationFunctionLabelAvg: 'اوسط',
119
+ aggregationFunctionLabelMin: 'کم از کم',
120
+ aggregationFunctionLabelMax: 'زیادہ سے زیادہ',
121
+ aggregationFunctionLabelSize: 'سائز'
122
122
  };
123
123
  export const urPK = getGridLocalization(urPKGrid, urPKCore);
@@ -33,7 +33,7 @@ export const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
33
33
  /**
34
34
  * Based on `fast-deep-equal`
35
35
  *
36
- * MIT License
36
+ * MIT License
37
37
  *
38
38
  * Copyright (c) 2017 Evgeny Poberezkin
39
39
  *
@@ -4,19 +4,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.GridHeader = void 0;
7
+ exports.GridHeader = GridHeader;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _useGridRootProps = require("../hooks/utils/useGridRootProps");
11
11
  var _jsxRuntime = require("react/jsx-runtime");
12
12
  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); }
13
13
  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; }
14
- const GridHeader = /*#__PURE__*/React.forwardRef(function GridHeader(props, ref) {
14
+ function GridHeader() {
15
15
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
16
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _extends2.default)({
17
- ref: ref
18
- }, props, {
16
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
19
17
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.preferencesPanel, (0, _extends2.default)({}, rootProps.slotProps?.preferencesPanel)), rootProps.slots.toolbar && /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.toolbar, (0, _extends2.default)({}, rootProps.slotProps?.toolbar))]
20
- }));
21
- });
22
- exports.GridHeader = GridHeader;
18
+ });
19
+ }
@@ -8,10 +8,10 @@ exports.GridBody = GridBody;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _utils = require("@mui/utils");
11
12
  var _useGridPrivateApiContext = require("../../hooks/utils/useGridPrivateApiContext");
12
13
  var _useGridSelector = require("../../hooks/utils/useGridSelector");
13
14
  var _GridMainContainer = require("../containers/GridMainContainer");
14
- var _GridAutoSizer = require("../GridAutoSizer");
15
15
  var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
16
16
  var _gridColumnsSelector = require("../../hooks/features/columns/gridColumnsSelector");
17
17
  var _gridFilterSelector = require("../../hooks/features/filter/gridFilterSelector");
@@ -25,12 +25,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
25
25
  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; }
26
26
  function GridBody(props) {
27
27
  const {
28
- children,
29
28
  VirtualScrollerComponent,
30
29
  ColumnHeadersProps
31
30
  } = props;
32
31
  const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
33
32
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
33
+ const rootRef = React.useRef(null);
34
34
  const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector);
35
35
  const filterColumnLookup = (0, _useGridSelector.useGridSelector)(apiRef, _gridFilterSelector.gridFilterActiveItemsLookupSelector);
36
36
  const sortColumnLookup = (0, _useGridSelector.useGridSelector)(apiRef, _gridSortingSelector.gridSortColumnLookupSelector);
@@ -47,6 +47,24 @@ function GridBody(props) {
47
47
  const columnGroupsHeaderStructure = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnGroupsSelector.gridColumnGroupsHeaderStructureSelector);
48
48
  const hasOtherElementInTabSequence = !(columnGroupHeaderTabIndexState === null && columnHeaderTabIndexState === null && cellTabIndexState === null);
49
49
  const [isVirtualizationDisabled, setIsVirtualizationDisabled] = React.useState(rootProps.disableVirtualization);
50
+ (0, _utils.unstable_useEnhancedEffect)(() => {
51
+ apiRef.current.computeSizeAndPublishResizeEvent();
52
+ const elementToObserve = rootRef.current;
53
+ if (typeof ResizeObserver === 'undefined') {
54
+ return () => {};
55
+ }
56
+ const observer = new ResizeObserver(() => {
57
+ apiRef.current.computeSizeAndPublishResizeEvent();
58
+ });
59
+ if (elementToObserve) {
60
+ observer.observe(elementToObserve);
61
+ }
62
+ return () => {
63
+ if (elementToObserve) {
64
+ observer.unobserve(elementToObserve);
65
+ }
66
+ };
67
+ }, [apiRef]);
50
68
  const disableVirtualization = React.useCallback(() => {
51
69
  setIsVirtualizationDisabled(true);
52
70
  }, []);
@@ -73,10 +91,9 @@ function GridBody(props) {
73
91
  columnHeadersElementRef: columnHeadersRef,
74
92
  virtualScrollerRef
75
93
  });
76
- const handleResize = React.useCallback(size => {
77
- apiRef.current.publishEvent('resize', size);
78
- }, [apiRef]);
94
+ const hasDimensions = !!apiRef.current.getRootDimensions();
79
95
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridMainContainer.GridMainContainer, {
96
+ ref: rootRef,
80
97
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.columnHeaders, (0, _extends2.default)({
81
98
  ref: columnsContainerRef,
82
99
  innerRef: columnHeadersRef,
@@ -94,15 +111,16 @@ function GridBody(props) {
94
111
  columnVisibility: columnVisibility,
95
112
  columnGroupsHeaderStructure: columnGroupsHeaderStructure,
96
113
  hasOtherElementInTabSequence: hasOtherElementInTabSequence
97
- }, ColumnHeadersProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridAutoSizer.GridAutoSizer, {
98
- nonce: rootProps.nonce,
99
- disableHeight: rootProps.autoHeight,
100
- onResize: handleResize,
101
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerComponent, {
102
- ref: virtualScrollerRef,
103
- disableVirtualization: isVirtualizationDisabled
104
- })
105
- }), children]
114
+ }, ColumnHeadersProps)), hasDimensions && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerComponent
115
+ // The content is only rendered after dimensions are computed because
116
+ // the lazy-loading hook is listening to `renderedRowsIntervalChange`,
117
+ // but only does something if the dimensions are also available.
118
+ // If this event is published while dimensions haven't been computed,
119
+ // the `onFetchRows` prop won't be called during mount.
120
+ , {
121
+ ref: virtualScrollerRef,
122
+ disableVirtualization: isVirtualizationDisabled
123
+ })]
106
124
  });
107
125
  }
108
126
  process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
@@ -110,7 +128,6 @@ process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
110
128
  // | These PropTypes are generated from the TypeScript type definitions |
111
129
  // | To update them edit the TypeScript types and run "yarn proptypes" |
112
130
  // ----------------------------------------------------------------------
113
- children: _propTypes.default.node,
114
131
  ColumnHeadersProps: _propTypes.default.object,
115
132
  VirtualScrollerComponent: _propTypes.default.elementType.isRequired
116
133
  } : void 0;
@@ -44,7 +44,7 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
44
44
  };
45
45
  const classes = useUtilityClasses(ownerState);
46
46
  const checkboxElement = React.useRef(null);
47
- const rippleRef = React.useRef();
47
+ const rippleRef = React.useRef(null);
48
48
  const handleRef = (0, _utils.unstable_useForkRef)(checkboxElement, ref);
49
49
  const element = apiRef.current.getCellElement(id, field);
50
50
  const handleChange = event => {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.GridMainContainer = GridMainContainer;
6
+ exports.GridMainContainer = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _utils = require("@mui/utils");
9
9
  var _system = require("@mui/system");
@@ -32,12 +32,14 @@ const GridMainContainerRoot = (0, _system.styled)('div', {
32
32
  flexDirection: 'column',
33
33
  overflow: 'hidden'
34
34
  }));
35
- function GridMainContainer(props) {
35
+ const GridMainContainer = /*#__PURE__*/React.forwardRef((props, ref) => {
36
36
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
37
37
  const classes = useUtilityClasses(rootProps);
38
38
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridMainContainerRoot, {
39
+ ref: ref,
39
40
  className: classes.root,
40
41
  ownerState: rootProps,
41
42
  children: props.children
42
43
  });
43
- }
44
+ });
45
+ exports.GridMainContainer = GridMainContainer;
@@ -63,11 +63,6 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
63
63
  (0, _utils.unstable_useEnhancedEffect)(() => {
64
64
  setMountedState(true);
65
65
  }, []);
66
- (0, _utils.unstable_useEnhancedEffect)(() => {
67
- if (mountedState) {
68
- apiRef.current.updateGridDimensionsRef();
69
- }
70
- }, [apiRef, mountedState]);
71
66
  if (!mountedState) {
72
67
  return null;
73
68
  }
@@ -113,17 +113,6 @@ Object.keys(_GridApiContext).forEach(function (key) {
113
113
  }
114
114
  });
115
115
  });
116
- var _GridAutoSizer = require("./GridAutoSizer");
117
- Object.keys(_GridAutoSizer).forEach(function (key) {
118
- if (key === "default" || key === "__esModule") return;
119
- if (key in exports && exports[key] === _GridAutoSizer[key]) return;
120
- Object.defineProperty(exports, key, {
121
- enumerable: true,
122
- get: function () {
123
- return _GridAutoSizer[key];
124
- }
125
- });
126
- });
127
116
  var _GridFooter = require("./GridFooter");
128
117
  Object.keys(_GridFooter).forEach(function (key) {
129
118
  if (key === "default" || key === "__esModule") return;