@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
@@ -12,7 +12,7 @@ import { gridExpandedSortedRowIdsSelector } from '../filter/gridFilterSelector';
12
12
  import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from '../../../colDef';
13
13
  import { GridCellModes } from '../../../models/gridEditRowModel';
14
14
  import { isKeyboardEvent, isNavigationKey } from '../../../utils/keyboardUtils';
15
- import { getVisibleRows, useGridVisibleRows } from '../../utils/useGridVisibleRows';
15
+ import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
16
16
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
17
17
  import { gridClasses } from '../../../constants/gridClasses';
18
18
  var getSelectionModelPropValue = function getSelectionModelPropValue(selectionModelProp, prevSelectionModel) {
@@ -63,8 +63,6 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
63
63
  var checkboxSelection = props.checkboxSelection,
64
64
  disableMultipleRowSelection = props.disableMultipleRowSelection,
65
65
  disableRowSelectionOnClick = props.disableRowSelectionOnClick,
66
- pagination = props.pagination,
67
- paginationMode = props.paginationMode,
68
66
  propIsRowSelectable = props.isRowSelectable;
69
67
  var canHaveMultipleSelection = !disableMultipleRowSelection || checkboxSelection;
70
68
  var visibleRows = useGridVisibleRows(apiRef, props);
@@ -408,30 +406,13 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
408
406
  }
409
407
  }, [apiRef, isRowSelectable, isStateControlled, props.rowSelection]);
410
408
  React.useEffect(function () {
411
- if (!props.rowSelection) {
409
+ if (!props.rowSelection || isStateControlled) {
412
410
  return;
413
411
  }
414
412
  var currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
415
413
  if (!canHaveMultipleSelection && currentSelection.length > 1) {
416
- var _getVisibleRows = getVisibleRows(apiRef, {
417
- pagination: pagination,
418
- paginationMode: paginationMode
419
- }),
420
- currentPageRows = _getVisibleRows.rows;
421
- var currentPageRowsLookup = currentPageRows.reduce(function (acc, _ref4) {
422
- var id = _ref4.id;
423
- acc[id] = true;
424
- return acc;
425
- }, {});
426
- var firstSelectableRow = currentSelection.find(function (id) {
427
- var isSelectable = true;
428
- if (isRowSelectable) {
429
- isSelectable = isRowSelectable(id);
430
- }
431
- return isSelectable && currentPageRowsLookup[id]; // Check if the row is in the current page
432
- });
433
-
434
- apiRef.current.setRowSelectionModel(firstSelectableRow !== undefined ? [firstSelectableRow] : []);
414
+ // See https://github.com/mui/mui-x/issues/8455
415
+ apiRef.current.setRowSelectionModel([]);
435
416
  }
436
- }, [apiRef, canHaveMultipleSelection, checkboxSelection, disableMultipleRowSelection, isRowSelectable, pagination, paginationMode, props.rowSelection]);
417
+ }, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
437
418
  };
@@ -186,11 +186,13 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
186
186
  height: rootRef.current.clientHeight
187
187
  });
188
188
  }, [rowsMeta.currentPageTotalHeight]);
189
- var handleResize = React.useCallback(function (params) {
190
- setContainerDimensions({
191
- width: params.width,
192
- height: params.height
193
- });
189
+ var handleResize = React.useCallback(function () {
190
+ if (rootRef.current) {
191
+ setContainerDimensions({
192
+ width: rootRef.current.clientWidth,
193
+ height: rootRef.current.clientHeight
194
+ });
195
+ }
194
196
  }, []);
195
197
  useGridApiEventHandler(apiRef, 'debouncedResize', handleResize);
196
198
  var updateRenderZonePosition = React.useCallback(function (nextRenderContext) {
@@ -323,7 +325,8 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
323
325
  var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
324
326
  renderContext: renderContext
325
327
  };
326
- var nextRenderContext = params.renderContext,
328
+ var onRowRender = params.onRowRender,
329
+ nextRenderContext = params.renderContext,
327
330
  _params$minFirstColum = params.minFirstColumn,
328
331
  minFirstColumn = _params$minFirstColum === void 0 ? renderZoneMinColumnIndex : _params$minFirstColum,
329
332
  _params$maxLastColumn = params.maxLastColumn,
@@ -414,6 +417,9 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
414
417
  } else {
415
418
  isSelected = apiRef.current.isRowSelectable(_id);
416
419
  }
420
+ if (onRowRender) {
421
+ onRowRender(_id);
422
+ }
417
423
  var focusedCell = cellFocus !== null && cellFocus.id === _id ? cellFocus.field : null;
418
424
  var tabbableCell = null;
419
425
  if (cellTabIndex !== null && cellTabIndex.id === _id) {
package/legacy/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,73 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _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
+ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
12
+ var touchRippleRef = _ref.touchRippleRef,
13
+ inputProps = _ref.inputProps,
14
+ onChange = _ref.onChange,
15
+ color = _ref.color,
16
+ size = _ref.size,
17
+ checked = _ref.checked,
18
+ sx = _ref.sx,
19
+ value = _ref.value,
20
+ inputRef = _ref.inputRef,
21
+ props = _objectWithoutProperties(_ref, _excluded);
22
+ return /*#__PURE__*/_jsx(JoyCheckbox, _extends({}, props, {
23
+ slotProps: {
24
+ input: _extends({}, inputProps, {
25
+ ref: inputRef
26
+ })
27
+ },
28
+ ref: ref,
29
+ checked: checked,
30
+ onChange: onChange
31
+ }));
32
+ });
33
+ var TextField = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
34
+ var onChange = _ref2.onChange,
35
+ label = _ref2.label,
36
+ placeholder = _ref2.placeholder,
37
+ value = _ref2.value,
38
+ inputRef = _ref2.inputRef,
39
+ type = _ref2.type;
40
+ return /*#__PURE__*/_jsxs(JoyFormControl, {
41
+ ref: ref,
42
+ children: [/*#__PURE__*/_jsx(JoyFormLabel, {
43
+ sx: {
44
+ fontSize: 12
45
+ },
46
+ children: label
47
+ }), /*#__PURE__*/_jsx(JoyInput, {
48
+ type: type,
49
+ value: value,
50
+ onChange: onChange,
51
+ placeholder: placeholder,
52
+ size: "sm",
53
+ slotProps: {
54
+ input: {
55
+ ref: inputRef
56
+ }
57
+ }
58
+ })]
59
+ });
60
+ });
61
+ var joySlots = {
62
+ baseCheckbox: Checkbox,
63
+ baseTextField: TextField
64
+ // BaseFormControl: MUIFormControl,
65
+ // BaseSelect: MUISelect,
66
+ // BaseSwitch: MUISwitch,
67
+ // BaseButton: MUIButton,
68
+ // BaseIconButton: MUIIconButton,
69
+ // BaseTooltip: MUITooltip,
70
+ // BasePopper: MUIPopper,
71
+ };
72
+
73
+ export default joySlots;
@@ -123,15 +123,13 @@ var frFRGrid = {
123
123
  expandDetailPanel: 'Afficher',
124
124
  collapseDetailPanel: 'Masquer',
125
125
  // Row reordering text
126
- rowReorderingHeaderName: 'Positionnement des lignes'
127
-
126
+ rowReorderingHeaderName: 'Positionnement des lignes',
128
127
  // Aggregation
129
- // aggregationMenuItemHeader: 'Aggregation',
130
- // aggregationFunctionLabelSum: 'sum',
131
- // aggregationFunctionLabelAvg: 'avg',
132
- // aggregationFunctionLabelMin: 'min',
133
- // aggregationFunctionLabelMax: 'max',
134
- // aggregationFunctionLabelSize: 'size',
128
+ aggregationMenuItemHeader: 'Agrégation',
129
+ aggregationFunctionLabelSum: 'Somme',
130
+ aggregationFunctionLabelAvg: 'Moyenne',
131
+ aggregationFunctionLabelMin: 'Minimum',
132
+ aggregationFunctionLabelMax: 'Maximum',
133
+ aggregationFunctionLabelSize: "Nombre d'éléments"
135
134
  };
136
-
137
135
  export var frFR = getGridLocalization(frFRGrid, frFRCore);
@@ -125,11 +125,11 @@ var urPKGrid = {
125
125
  // Row reordering text
126
126
  rowReorderingHeaderName: 'قطاروں کی ترتیب تبدیل کریں',
127
127
  // Aggregation
128
- aggregationMenuItemHeader: 'Aggregation',
129
- aggregationFunctionLabelSum: 'sum',
130
- aggregationFunctionLabelAvg: 'avg',
131
- aggregationFunctionLabelMin: 'min',
132
- aggregationFunctionLabelMax: 'max',
133
- aggregationFunctionLabelSize: 'size'
128
+ aggregationMenuItemHeader: 'ایگریگیشن',
129
+ aggregationFunctionLabelSum: 'کل',
130
+ aggregationFunctionLabelAvg: 'اوسط',
131
+ aggregationFunctionLabelMin: 'کم از کم',
132
+ aggregationFunctionLabelMax: 'زیادہ سے زیادہ',
133
+ aggregationFunctionLabelSize: 'سائز'
134
134
  };
135
135
  export var urPK = getGridLocalization(urPKGrid, urPKCore);
@@ -36,7 +36,7 @@ export var clamp = function clamp(value, min, max) {
36
36
  /**
37
37
  * Based on `fast-deep-equal`
38
38
  *
39
- * MIT License
39
+ * MIT License
40
40
  *
41
41
  * Copyright (c) 2017 Evgeny Poberezkin
42
42
  *
package/locales/frFR.js CHANGED
@@ -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);
package/locales/urPK.js CHANGED
@@ -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);
@@ -20,7 +20,7 @@ declare const materialSlots: {
20
20
  Root?: import("react").ElementType<any> | undefined;
21
21
  } | undefined;
22
22
  componentsProps?: {
23
- root?: import("@mui/base").SlotComponentProps<"div", import("@mui/base").PopperUnstyledRootSlotPropsOverrides, import("@mui/base").PopperUnstyledOwnerState> | undefined;
23
+ root?: import("@mui/base").SlotComponentProps<"div", import("@mui/base").PopperUnstyledRootSlotPropsOverrides, import("@mui/base").PopperUnstyledOwnProps> | undefined;
24
24
  } | undefined;
25
25
  sx?: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
26
26
  } & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { UncapitalizeObjectKeys } from '../internals/utils';
3
- import { GridIconSlotsComponent } from './gridIconSlotsComponent';
2
+ import type { UncapitalizeObjectKeys } from '../internals/utils';
3
+ import type { GridIconSlotsComponent } from './gridIconSlotsComponent';
4
4
  /**
5
5
  * Grid components React prop interface containing all the overridable components.
6
6
  */
@@ -3,11 +3,9 @@ import * as React from 'react';
3
3
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
5
  import { jsxs as _jsxs } from "react/jsx-runtime";
6
- export const GridHeader = /*#__PURE__*/React.forwardRef(function GridHeader(props, ref) {
6
+ export function GridHeader() {
7
7
  const rootProps = useGridRootProps();
8
- return /*#__PURE__*/_jsxs("div", _extends({
9
- ref: ref
10
- }, props, {
8
+ return /*#__PURE__*/_jsxs(React.Fragment, {
11
9
  children: [/*#__PURE__*/_jsx(rootProps.slots.preferencesPanel, _extends({}, rootProps.slotProps?.preferencesPanel)), rootProps.slots.toolbar && /*#__PURE__*/_jsx(rootProps.slots.toolbar, _extends({}, rootProps.slotProps?.toolbar))]
12
- }));
13
- });
10
+ });
11
+ }
@@ -1,10 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
+ import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
4
5
  import { useGridPrivateApiContext } from '../../hooks/utils/useGridPrivateApiContext';
5
6
  import { useGridSelector } from '../../hooks/utils/useGridSelector';
6
7
  import { GridMainContainer } from '../containers/GridMainContainer';
7
- import { GridAutoSizer } from '../GridAutoSizer';
8
8
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
9
9
  import { gridColumnPositionsSelector, gridColumnVisibilityModelSelector, gridVisibleColumnDefinitionsSelector } from '../../hooks/features/columns/gridColumnsSelector';
10
10
  import { gridFilterActiveItemsLookupSelector } from '../../hooks/features/filter/gridFilterSelector';
@@ -17,12 +17,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
17
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
18
  function GridBody(props) {
19
19
  const {
20
- children,
21
20
  VirtualScrollerComponent,
22
21
  ColumnHeadersProps
23
22
  } = props;
24
23
  const apiRef = useGridPrivateApiContext();
25
24
  const rootProps = useGridRootProps();
25
+ const rootRef = React.useRef(null);
26
26
  const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
27
27
  const filterColumnLookup = useGridSelector(apiRef, gridFilterActiveItemsLookupSelector);
28
28
  const sortColumnLookup = useGridSelector(apiRef, gridSortColumnLookupSelector);
@@ -39,6 +39,24 @@ function GridBody(props) {
39
39
  const columnGroupsHeaderStructure = useGridSelector(apiRef, gridColumnGroupsHeaderStructureSelector);
40
40
  const hasOtherElementInTabSequence = !(columnGroupHeaderTabIndexState === null && columnHeaderTabIndexState === null && cellTabIndexState === null);
41
41
  const [isVirtualizationDisabled, setIsVirtualizationDisabled] = React.useState(rootProps.disableVirtualization);
42
+ useEnhancedEffect(() => {
43
+ apiRef.current.computeSizeAndPublishResizeEvent();
44
+ const elementToObserve = rootRef.current;
45
+ if (typeof ResizeObserver === 'undefined') {
46
+ return () => {};
47
+ }
48
+ const observer = new ResizeObserver(() => {
49
+ apiRef.current.computeSizeAndPublishResizeEvent();
50
+ });
51
+ if (elementToObserve) {
52
+ observer.observe(elementToObserve);
53
+ }
54
+ return () => {
55
+ if (elementToObserve) {
56
+ observer.unobserve(elementToObserve);
57
+ }
58
+ };
59
+ }, [apiRef]);
42
60
  const disableVirtualization = React.useCallback(() => {
43
61
  setIsVirtualizationDisabled(true);
44
62
  }, []);
@@ -65,10 +83,9 @@ function GridBody(props) {
65
83
  columnHeadersElementRef: columnHeadersRef,
66
84
  virtualScrollerRef
67
85
  });
68
- const handleResize = React.useCallback(size => {
69
- apiRef.current.publishEvent('resize', size);
70
- }, [apiRef]);
86
+ const hasDimensions = !!apiRef.current.getRootDimensions();
71
87
  return /*#__PURE__*/_jsxs(GridMainContainer, {
88
+ ref: rootRef,
72
89
  children: [/*#__PURE__*/_jsx(rootProps.slots.columnHeaders, _extends({
73
90
  ref: columnsContainerRef,
74
91
  innerRef: columnHeadersRef,
@@ -86,15 +103,16 @@ function GridBody(props) {
86
103
  columnVisibility: columnVisibility,
87
104
  columnGroupsHeaderStructure: columnGroupsHeaderStructure,
88
105
  hasOtherElementInTabSequence: hasOtherElementInTabSequence
89
- }, ColumnHeadersProps)), /*#__PURE__*/_jsx(GridAutoSizer, {
90
- nonce: rootProps.nonce,
91
- disableHeight: rootProps.autoHeight,
92
- onResize: handleResize,
93
- children: /*#__PURE__*/_jsx(VirtualScrollerComponent, {
94
- ref: virtualScrollerRef,
95
- disableVirtualization: isVirtualizationDisabled
96
- })
97
- }), children]
106
+ }, ColumnHeadersProps)), hasDimensions && /*#__PURE__*/_jsx(VirtualScrollerComponent
107
+ // The content is only rendered after dimensions are computed because
108
+ // the lazy-loading hook is listening to `renderedRowsIntervalChange`,
109
+ // but only does something if the dimensions are also available.
110
+ // If this event is published while dimensions haven't been computed,
111
+ // the `onFetchRows` prop won't be called during mount.
112
+ , {
113
+ ref: virtualScrollerRef,
114
+ disableVirtualization: isVirtualizationDisabled
115
+ })]
98
116
  });
99
117
  }
100
118
  process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
@@ -102,7 +120,6 @@ process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
102
120
  // | These PropTypes are generated from the TypeScript type definitions |
103
121
  // | To update them edit the TypeScript types and run "yarn proptypes" |
104
122
  // ----------------------------------------------------------------------
105
- children: PropTypes.node,
106
123
  ColumnHeadersProps: PropTypes.object,
107
124
  VirtualScrollerComponent: PropTypes.elementType.isRequired
108
125
  } : void 0;
@@ -35,7 +35,7 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
35
35
  };
36
36
  const classes = useUtilityClasses(ownerState);
37
37
  const checkboxElement = React.useRef(null);
38
- const rippleRef = React.useRef();
38
+ const rippleRef = React.useRef(null);
39
39
  const handleRef = useForkRef(checkboxElement, ref);
40
40
  const element = apiRef.current.getCellElement(id, field);
41
41
  const handleChange = event => {
@@ -24,12 +24,13 @@ const GridMainContainerRoot = styled('div', {
24
24
  flexDirection: 'column',
25
25
  overflow: 'hidden'
26
26
  }));
27
- export function GridMainContainer(props) {
27
+ export const GridMainContainer = /*#__PURE__*/React.forwardRef((props, ref) => {
28
28
  const rootProps = useGridRootProps();
29
29
  const classes = useUtilityClasses(rootProps);
30
30
  return /*#__PURE__*/_jsx(GridMainContainerRoot, {
31
+ ref: ref,
31
32
  className: classes.root,
32
33
  ownerState: rootProps,
33
34
  children: props.children
34
35
  });
35
- }
36
+ });
@@ -54,11 +54,6 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
54
54
  useEnhancedEffect(() => {
55
55
  setMountedState(true);
56
56
  }, []);
57
- useEnhancedEffect(() => {
58
- if (mountedState) {
59
- apiRef.current.updateGridDimensionsRef();
60
- }
61
- }, [apiRef, mountedState]);
62
57
  if (!mountedState) {
63
58
  return null;
64
59
  }
@@ -8,7 +8,6 @@ export * from './menu';
8
8
  export * from './panel';
9
9
  export * from './toolbar';
10
10
  export * from './GridApiContext';
11
- export * from './GridAutoSizer';
12
11
  export * from './GridFooter';
13
12
  export * from './GridHeader';
14
13
  export * from './GridLoadingOverlay';
@@ -94,8 +94,9 @@ function GridColumnsPanel(props) {
94
94
  const toggleAllColumns = React.useCallback(isVisible => {
95
95
  const currentModel = gridColumnVisibilityModelSelector(apiRef);
96
96
  const newModel = _extends({}, currentModel);
97
+ const togglableColumns = getTogglableColumns ? getTogglableColumns(columns) : null;
97
98
  columns.forEach(col => {
98
- if (col.hideable) {
99
+ if (col.hideable && (togglableColumns == null || togglableColumns.includes(col.field))) {
99
100
  if (isVisible) {
100
101
  // delete the key from the model instead of setting it to `true`
101
102
  delete newModel[col.field];
@@ -105,7 +106,7 @@ function GridColumnsPanel(props) {
105
106
  }
106
107
  });
107
108
  return apiRef.current.setColumnVisibilityModel(newModel);
108
- }, [apiRef, columns]);
109
+ }, [apiRef, columns, getTogglableColumns]);
109
110
  const handleSearchValueChange = React.useCallback(event => {
110
111
  setSearchValue(event.target.value);
111
112
  }, []);
@@ -115,6 +115,7 @@ process.env.NODE_ENV !== "production" ? GridPanel.propTypes = {
115
115
  /**
116
116
  * If `true`, the component is shown.
117
117
  */
118
- open: PropTypes.bool.isRequired
118
+ open: PropTypes.bool.isRequired,
119
+ ownerState: PropTypes.object
119
120
  } : void 0;
120
121
  export { GridPanel };
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["item", "applyValue", "apiRef", "focusElementRef"];
4
4
  import * as React from 'react';
5
+ import { unstable_useId as useId } from '@mui/utils';
5
6
  import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
8
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -15,6 +16,8 @@ export function GridFilterInputBoolean(props) {
15
16
  others = _objectWithoutPropertiesLoose(props, _excluded);
16
17
  const [filterValueState, setFilterValueState] = React.useState(item.value || '');
17
18
  const rootProps = useGridRootProps();
19
+ const labelId = useId();
20
+ const selectId = useId();
18
21
  const baseSelectProps = rootProps.slotProps?.baseSelect || {};
19
22
  const isSelectNative = baseSelectProps.native ?? true;
20
23
  const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
@@ -28,34 +31,39 @@ export function GridFilterInputBoolean(props) {
28
31
  React.useEffect(() => {
29
32
  setFilterValueState(item.value || '');
30
33
  }, [item.value]);
31
- return /*#__PURE__*/_jsxs(rootProps.slots.baseTextField, _extends({
32
- // TODO: use baseSelect slot
33
- label: apiRef.current.getLocaleText('filterPanelInputLabel'),
34
- value: filterValueState,
35
- onChange: onFilterChange,
36
- select: true,
37
- variant: "standard",
38
- SelectProps: _extends({
34
+ const label = apiRef.current.getLocaleText('filterPanelInputLabel');
35
+ return /*#__PURE__*/_jsxs(React.Fragment, {
36
+ children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, rootProps.slotProps?.baseInputLabel, {
37
+ id: labelId,
38
+ shrink: true,
39
+ variant: "standard",
40
+ children: label
41
+ })), /*#__PURE__*/_jsxs(rootProps.slots.baseSelect, _extends({
42
+ labelId: labelId,
43
+ id: selectId,
44
+ label: label,
45
+ value: filterValueState,
46
+ onChange: onFilterChange,
47
+ variant: "standard",
39
48
  native: isSelectNative,
40
- displayEmpty: true
41
- }, rootProps.slotProps?.baseSelect),
42
- InputLabelProps: {
43
- shrink: true
44
- },
45
- inputRef: focusElementRef
46
- }, others, rootProps.slotProps?.baseTextField, {
47
- children: [/*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
48
- native: isSelectNative,
49
- value: "",
50
- children: apiRef.current.getLocaleText('filterValueAny')
51
- })), /*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
52
- native: isSelectNative,
53
- value: "true",
54
- children: apiRef.current.getLocaleText('filterValueTrue')
55
- })), /*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
56
- native: isSelectNative,
57
- value: "false",
58
- children: apiRef.current.getLocaleText('filterValueFalse')
49
+ displayEmpty: true,
50
+ inputProps: {
51
+ ref: focusElementRef
52
+ }
53
+ }, others, baseSelectProps, {
54
+ children: [/*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
55
+ native: isSelectNative,
56
+ value: "",
57
+ children: apiRef.current.getLocaleText('filterValueAny')
58
+ })), /*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
59
+ native: isSelectNative,
60
+ value: "true",
61
+ children: apiRef.current.getLocaleText('filterValueTrue')
62
+ })), /*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
63
+ native: isSelectNative,
64
+ value: "false",
65
+ children: apiRef.current.getLocaleText('filterValueFalse')
66
+ }))]
59
67
  }))]
60
- }));
68
+ });
61
69
  }