@mui/x-data-grid 8.0.0-alpha.3 → 8.0.0-alpha.5

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 (176) hide show
  1. package/CHANGELOG.md +377 -0
  2. package/DataGrid/DataGrid.js +7 -11
  3. package/DataGrid/useDataGridProps.js +3 -3
  4. package/README.md +1 -1
  5. package/components/GridRow.js +13 -2
  6. package/components/cell/GridActionsCell.js +8 -1
  7. package/components/cell/GridActionsCellItem.js +4 -6
  8. package/components/cell/GridCell.js +1 -1
  9. package/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +6 -11
  10. package/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +6 -11
  11. package/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +6 -11
  12. package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +13 -22
  13. package/components/panel/GridColumnsPanel.js +1 -2
  14. package/components/panel/GridPanelContent.js +7 -3
  15. package/components/panel/GridPanelFooter.d.ts +1 -1
  16. package/components/panel/GridPanelFooter.js +4 -3
  17. package/components/panel/filterPanel/GridFilterForm.js +15 -15
  18. package/components/toolbar/GridToolbarDensitySelector.js +3 -5
  19. package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
  20. package/components/toolbar/GridToolbarFilterButton.js +3 -0
  21. package/components/toolbar/GridToolbarQuickFilter.js +27 -23
  22. package/components/virtualization/GridMainContainer.js +1 -1
  23. package/constants/dataGridPropsDefaultValues.js +1 -1
  24. package/hooks/core/useGridStateInitialization.js +3 -3
  25. package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +4 -4
  26. package/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -3
  27. package/hooks/features/columnResize/columnResizeSelector.d.ts +1 -1
  28. package/hooks/features/columnResize/gridColumnResizeApi.d.ts +6 -0
  29. package/hooks/features/columnResize/gridColumnResizeApi.js +2 -1
  30. package/hooks/features/columnResize/useGridColumnResize.d.ts +1 -1
  31. package/hooks/features/columnResize/useGridColumnResize.js +9 -4
  32. package/hooks/features/columns/gridColumnsSelector.d.ts +12 -12
  33. package/hooks/features/columns/gridColumnsUtils.d.ts +1 -1
  34. package/hooks/features/columns/gridColumnsUtils.js +2 -1
  35. package/hooks/features/density/densitySelector.d.ts +1 -1
  36. package/hooks/features/filter/gridFilterSelector.d.ts +17 -17
  37. package/hooks/features/filter/useGridFilter.js +1 -1
  38. package/hooks/features/focus/gridFocusStateSelector.d.ts +8 -8
  39. package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +3 -3
  40. package/hooks/features/overlays/useGridOverlays.js +3 -1
  41. package/hooks/features/pagination/gridPaginationSelector.d.ts +15 -9
  42. package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
  43. package/hooks/features/rowSelection/useGridRowSelection.js +5 -4
  44. package/hooks/features/rowSelection/utils.d.ts +1 -1
  45. package/hooks/features/rows/gridRowSpanningSelectors.d.ts +3 -3
  46. package/hooks/features/rows/gridRowsSelector.d.ts +23 -12
  47. package/hooks/features/rows/useGridRowSpanning.d.ts +1 -1
  48. package/hooks/features/rows/useGridRowSpanning.js +16 -8
  49. package/hooks/features/rows/useGridRows.js +5 -5
  50. package/hooks/features/sorting/gridSortingSelector.d.ts +10 -5
  51. package/hooks/features/sorting/gridSortingSelector.js +11 -0
  52. package/hooks/features/sorting/index.d.ts +2 -1
  53. package/hooks/features/sorting/index.js +1 -1
  54. package/hooks/features/sorting/useGridSorting.js +1 -1
  55. package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +5 -5
  56. package/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
  57. package/hooks/utils/useGridSelector.d.ts +4 -6
  58. package/hooks/utils/useGridSelector.js +6 -44
  59. package/index.js +1 -1
  60. package/internals/index.d.ts +2 -2
  61. package/internals/index.js +2 -2
  62. package/internals/utils/index.d.ts +0 -1
  63. package/internals/utils/index.js +0 -1
  64. package/locales/koKR.js +45 -49
  65. package/locales/roRO.js +18 -20
  66. package/material/index.js +30 -4
  67. package/models/api/gridStateApi.d.ts +1 -1
  68. package/models/controlStateItem.d.ts +2 -2
  69. package/models/gridBaseSlots.d.ts +21 -0
  70. package/models/gridBaseSlots.js +1 -0
  71. package/models/gridSlotsComponentsProps.d.ts +25 -5
  72. package/models/props/DataGridProps.d.ts +1 -6
  73. package/modern/DataGrid/DataGrid.js +7 -11
  74. package/modern/DataGrid/useDataGridProps.js +3 -3
  75. package/modern/components/GridRow.js +13 -2
  76. package/modern/components/cell/GridActionsCell.js +8 -1
  77. package/modern/components/cell/GridActionsCellItem.js +4 -6
  78. package/modern/components/cell/GridCell.js +1 -1
  79. package/modern/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +6 -11
  80. package/modern/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +6 -11
  81. package/modern/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +6 -11
  82. package/modern/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +13 -22
  83. package/modern/components/panel/GridColumnsPanel.js +1 -2
  84. package/modern/components/panel/GridPanelContent.js +7 -3
  85. package/modern/components/panel/GridPanelFooter.js +4 -3
  86. package/modern/components/panel/filterPanel/GridFilterForm.js +15 -15
  87. package/modern/components/toolbar/GridToolbarDensitySelector.js +3 -5
  88. package/modern/components/toolbar/GridToolbarFilterButton.js +3 -0
  89. package/modern/components/toolbar/GridToolbarQuickFilter.js +27 -23
  90. package/modern/components/virtualization/GridMainContainer.js +1 -1
  91. package/modern/constants/dataGridPropsDefaultValues.js +1 -1
  92. package/modern/hooks/core/useGridStateInitialization.js +3 -3
  93. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -3
  94. package/modern/hooks/features/columnResize/gridColumnResizeApi.js +2 -1
  95. package/modern/hooks/features/columnResize/useGridColumnResize.js +9 -4
  96. package/modern/hooks/features/columns/gridColumnsUtils.js +2 -1
  97. package/modern/hooks/features/filter/useGridFilter.js +1 -1
  98. package/modern/hooks/features/overlays/useGridOverlays.js +3 -1
  99. package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -4
  100. package/modern/hooks/features/rows/useGridRowSpanning.js +16 -8
  101. package/modern/hooks/features/rows/useGridRows.js +5 -5
  102. package/modern/hooks/features/sorting/gridSortingSelector.js +11 -0
  103. package/modern/hooks/features/sorting/index.js +1 -1
  104. package/modern/hooks/features/sorting/useGridSorting.js +1 -1
  105. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
  106. package/modern/hooks/utils/useGridSelector.js +6 -44
  107. package/modern/index.js +1 -1
  108. package/modern/internals/index.js +2 -2
  109. package/modern/internals/utils/index.js +0 -1
  110. package/modern/locales/koKR.js +45 -49
  111. package/modern/locales/roRO.js +18 -20
  112. package/modern/material/index.js +30 -4
  113. package/modern/models/gridBaseSlots.js +1 -0
  114. package/modern/utils/createSelector.js +1 -120
  115. package/node/DataGrid/DataGrid.js +7 -11
  116. package/node/DataGrid/useDataGridProps.js +2 -2
  117. package/node/components/GridRow.js +13 -2
  118. package/node/components/cell/GridActionsCell.js +8 -1
  119. package/node/components/cell/GridActionsCellItem.js +3 -5
  120. package/node/components/cell/GridCell.js +1 -1
  121. package/node/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +5 -10
  122. package/node/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +5 -10
  123. package/node/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +5 -10
  124. package/node/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +13 -22
  125. package/node/components/panel/GridColumnsPanel.js +1 -2
  126. package/node/components/panel/GridPanelContent.js +7 -3
  127. package/node/components/panel/GridPanelFooter.js +5 -4
  128. package/node/components/panel/filterPanel/GridFilterForm.js +15 -15
  129. package/node/components/toolbar/GridToolbarDensitySelector.js +3 -5
  130. package/node/components/toolbar/GridToolbarFilterButton.js +3 -0
  131. package/node/components/toolbar/GridToolbarQuickFilter.js +27 -23
  132. package/node/components/virtualization/GridMainContainer.js +1 -1
  133. package/node/constants/dataGridPropsDefaultValues.js +1 -1
  134. package/node/hooks/core/useGridStateInitialization.js +3 -3
  135. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -3
  136. package/node/hooks/features/columnResize/gridColumnResizeApi.js +2 -1
  137. package/node/hooks/features/columnResize/useGridColumnResize.js +9 -4
  138. package/node/hooks/features/columns/gridColumnsUtils.js +2 -1
  139. package/node/hooks/features/filter/useGridFilter.js +1 -1
  140. package/node/hooks/features/overlays/useGridOverlays.js +3 -1
  141. package/node/hooks/features/rowSelection/useGridRowSelection.js +5 -4
  142. package/node/hooks/features/rows/useGridRowSpanning.js +16 -8
  143. package/node/hooks/features/rows/useGridRows.js +5 -5
  144. package/node/hooks/features/sorting/gridSortingSelector.js +12 -1
  145. package/node/hooks/features/sorting/index.js +24 -16
  146. package/node/hooks/features/sorting/useGridSorting.js +1 -1
  147. package/node/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
  148. package/node/hooks/utils/useGridSelector.js +8 -47
  149. package/node/index.js +1 -1
  150. package/node/internals/index.js +8 -22
  151. package/node/internals/utils/index.js +0 -11
  152. package/node/locales/koKR.js +45 -49
  153. package/node/locales/roRO.js +18 -20
  154. package/node/material/index.js +31 -4
  155. package/node/models/gridBaseSlots.js +5 -0
  156. package/node/utils/createSelector.js +4 -125
  157. package/package.json +2 -2
  158. package/utils/createSelector.d.ts +4 -16
  159. package/utils/createSelector.js +1 -120
  160. package/internals/utils/useProps.d.ts +0 -1
  161. package/internals/utils/useProps.js +0 -24
  162. package/joy/icons.d.ts +0 -32
  163. package/joy/icons.js +0 -431
  164. package/joy/index.d.ts +0 -2
  165. package/joy/index.js +0 -2
  166. package/joy/joySlots.d.ts +0 -3
  167. package/joy/joySlots.js +0 -389
  168. package/joy/package.json +0 -6
  169. package/modern/internals/utils/useProps.js +0 -24
  170. package/modern/joy/icons.js +0 -431
  171. package/modern/joy/index.js +0 -2
  172. package/modern/joy/joySlots.js +0 -389
  173. package/node/internals/utils/useProps.js +0 -30
  174. package/node/joy/icons.js +0 -439
  175. package/node/joy/index.js +0 -13
  176. package/node/joy/joySlots.js +0 -397
@@ -47,7 +47,7 @@ export const useGridColumnHeaders = props => {
47
47
  const isRtl = useRtl();
48
48
  const rootProps = useGridRootProps();
49
49
  const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
50
- const hasVirtualization = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector);
50
+ const hasColumnVirtualization = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector);
51
51
  const columnGroupsModel = useGridSelector(apiRef, gridColumnGroupsUnwrappedModelSelector);
52
52
  const columnPositions = useGridSelector(apiRef, gridColumnPositionsSelector);
53
53
  const renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
@@ -87,8 +87,15 @@ export const useGridColumnHeaders = props => {
87
87
  renderContext: currentContext = renderContext,
88
88
  maxLastColumn = visibleColumns.length
89
89
  } = params || {};
90
- const firstColumnToRender = currentContext.firstColumnIndex;
91
- const lastColumnToRender = !hasVirtualization ? maxLastColumn : currentContext.lastColumnIndex;
90
+ let firstColumnToRender;
91
+ let lastColumnToRender;
92
+ if (!rootProps.disableVirtualization && !hasColumnVirtualization) {
93
+ firstColumnToRender = 0;
94
+ lastColumnToRender = maxLastColumn;
95
+ } else {
96
+ firstColumnToRender = currentContext.firstColumnIndex;
97
+ lastColumnToRender = currentContext.lastColumnIndex;
98
+ }
92
99
  const renderedColumns = visibleColumns.slice(firstColumnToRender, lastColumnToRender);
93
100
  return {
94
101
  renderedColumns,
@@ -2,7 +2,8 @@ export const DEFAULT_GRID_AUTOSIZE_OPTIONS = {
2
2
  includeHeaders: true,
3
3
  includeOutliers: false,
4
4
  outliersFactor: 1.5,
5
- expand: false
5
+ expand: false,
6
+ disableColumnVirtualization: true
6
7
  };
7
8
 
8
9
  /**
@@ -460,6 +460,7 @@ export const useGridColumnResize = (apiRef, props) => {
460
460
  return;
461
461
  }
462
462
  apiRef.current.autosizeColumns(_extends({}, props.autosizeOptions, {
463
+ disableColumnVirtualization: false,
463
464
  columns: [column.field]
464
465
  }));
465
466
  });
@@ -486,8 +487,10 @@ export const useGridColumnResize = (apiRef, props) => {
486
487
  options.columns = options.columns.filter(c => state.columnVisibilityModel[c] !== false);
487
488
  const columns = options.columns.map(c => apiRef.current.state.columns.lookup[c]);
488
489
  try {
489
- apiRef.current.unstable_setColumnVirtualization(false);
490
- await columnVirtualizationDisabled();
490
+ if (!props.disableVirtualization && options.disableColumnVirtualization) {
491
+ apiRef.current.unstable_setColumnVirtualization(false);
492
+ await columnVirtualizationDisabled();
493
+ }
491
494
  const widthByField = extractColumnWidths(apiRef, options, columns);
492
495
  const newColumns = columns.map(column => _extends({}, column, {
493
496
  width: widthByField[column.field],
@@ -519,10 +522,12 @@ export const useGridColumnResize = (apiRef, props) => {
519
522
  }
520
523
  });
521
524
  } finally {
522
- apiRef.current.unstable_setColumnVirtualization(true);
525
+ if (!props.disableVirtualization) {
526
+ apiRef.current.unstable_setColumnVirtualization(true);
527
+ }
523
528
  isAutosizingRef.current = false;
524
529
  }
525
- }, [apiRef, columnVirtualizationDisabled]);
530
+ }, [apiRef, columnVirtualizationDisabled, props.disableVirtualization]);
526
531
 
527
532
  /**
528
533
  * EFFECTS
@@ -319,6 +319,7 @@ export function getTotalHeaderHeight(apiRef, props) {
319
319
  const maxDepth = gridColumnGroupsHeaderMaxDepthSelector(apiRef);
320
320
  const isHeaderFilteringEnabled = gridHeaderFilteringEnabledSelector(apiRef);
321
321
  const columnHeadersHeight = Math.floor(props.columnHeaderHeight * densityFactor);
322
+ const columnGroupHeadersHeight = Math.floor((props.columnGroupHeaderHeight ?? props.columnHeaderHeight) * densityFactor);
322
323
  const filterHeadersHeight = isHeaderFilteringEnabled ? Math.floor((props.headerFilterHeight ?? props.columnHeaderHeight) * densityFactor) : 0;
323
- return columnHeadersHeight * (1 + (maxDepth ?? 0)) + filterHeadersHeight;
324
+ return columnHeadersHeight + columnGroupHeadersHeight * maxDepth + filterHeadersHeight;
324
325
  }
@@ -59,7 +59,7 @@ export const useGridFilter = (apiRef, props) => {
59
59
  });
60
60
  const updateFilteredRows = React.useCallback(() => {
61
61
  apiRef.current.setState(state => {
62
- const filterModel = gridFilterModelSelector(state, apiRef.current.instanceId);
62
+ const filterModel = gridFilterModelSelector(state, undefined, apiRef.current.instanceId);
63
63
  const filterState = apiRef.current.getFilterState(filterModel);
64
64
  const newState = _extends({}, state, {
65
65
  filter: _extends({}, state.filter, filterState)
@@ -5,6 +5,7 @@ import { useGridApiContext } from "../../utils/useGridApiContext.js";
5
5
  import { useGridRootProps } from "../../utils/useGridRootProps.js";
6
6
  import { gridExpandedRowCountSelector } from "../filter/index.js";
7
7
  import { gridRowCountSelector, gridRowsLoadingSelector } from "../rows/index.js";
8
+ import { gridPinnedRowsCountSelector } from "../rows/gridRowsSelector.js";
8
9
  import { GridOverlayWrapper } from "../../../components/base/GridOverlays.js";
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
11
  /**
@@ -16,7 +17,8 @@ export const useGridOverlays = () => {
16
17
  const rootProps = useGridRootProps();
17
18
  const totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
18
19
  const visibleRowCount = useGridSelector(apiRef, gridExpandedRowCountSelector);
19
- const noRows = totalRowCount === 0;
20
+ const pinnedRowsCount = useGridSelector(apiRef, gridPinnedRowsCountSelector);
21
+ const noRows = totalRowCount === 0 && pinnedRowsCount === 0;
20
22
  const loading = useGridSelector(apiRef, gridRowsLoadingSelector);
21
23
  const showNoRowsOverlay = !loading && noRows;
22
24
  const showNoResultsOverlay = !loading && totalRowCount > 0 && visibleRowCount === 0;
@@ -313,11 +313,12 @@ export const useGridRowSelection = (apiRef, props) => {
313
313
 
314
314
  const isMultipleSelectionDisabled = !checkboxSelection && !hasCtrlKey && !isKeyboardEvent(event);
315
315
  const resetSelection = !canHaveMultipleSelection || isMultipleSelectionDisabled;
316
- const isSelected = apiRef.current.isRowSelected(id);
317
- if (resetSelection) {
318
- apiRef.current.selectRow(id, !isMultipleSelectionDisabled ? !isSelected : true, true);
316
+ const selectedRowsCount = apiRef.current.getSelectedRows().size;
317
+ if (canHaveMultipleSelection && selectedRowsCount > 1 && !hasCtrlKey) {
318
+ apiRef.current.selectRow(id, true, resetSelection);
319
319
  } else {
320
- apiRef.current.selectRow(id, !isSelected, false);
320
+ const isSelected = apiRef.current.isRowSelected(id);
321
+ apiRef.current.selectRow(id, !isSelected, resetSelection);
321
322
  }
322
323
  }, [apiRef, canHaveMultipleSelection, checkboxSelection]);
323
324
  const handleRowClick = React.useCallback((params, event) => {
@@ -6,6 +6,7 @@ import { gridVisibleColumnDefinitionsSelector } from "../columns/gridColumnsSele
6
6
  import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
7
7
  import { gridRenderContextSelector } from "../virtualization/gridVirtualizationSelectors.js";
8
8
  import { useGridSelector } from "../../utils/useGridSelector.js";
9
+ import { gridRowTreeSelector } from "./gridRowsSelector.js";
9
10
  import { getUnprocessedRange, isRowRangeUpdated, isRowContextInitialized, getCellValue } from "./gridRowSpanningUtils.js";
10
11
  import { GRID_CHECKBOX_SELECTION_FIELD } from "../../../colDef/gridCheckboxSelectionColDef.js";
11
12
  const EMPTY_STATE = {
@@ -35,7 +36,7 @@ const computeRowSpanningState = (apiRef, colDefs, visibleRows, range, rangeToPro
35
36
  if (skippedFields.has(colDef.field)) {
36
37
  return;
37
38
  }
38
- for (let index = rangeToProcess.firstRowIndex; index <= rangeToProcess.lastRowIndex; index += 1) {
39
+ for (let index = rangeToProcess.firstRowIndex; index < rangeToProcess.lastRowIndex; index += 1) {
39
40
  const row = visibleRows[index];
40
41
  if (hiddenCells[row.id]?.[colDef.field]) {
41
42
  continue;
@@ -129,7 +130,7 @@ const computeRowSpanningState = (apiRef, colDefs, visibleRows, range, rangeToPro
129
130
  * @requires filterStateInitializer (method) - should be initialized before
130
131
  */
131
132
  export const rowSpanningStateInitializer = (state, props, apiRef) => {
132
- if (props.unstable_rowSpanning) {
133
+ if (props.rowSpanning) {
133
134
  const rowIds = state.rows.dataRowIds || [];
134
135
  const orderedFields = state.columns.orderedFields || [];
135
136
  const dataRowIdToModelLookup = state.rows.dataRowIdToModelLookup;
@@ -142,7 +143,7 @@ export const rowSpanningStateInitializer = (state, props, apiRef) => {
142
143
  }
143
144
  const rangeToProcess = {
144
145
  firstRowIndex: 0,
145
- lastRowIndex: Math.min(DEFAULT_ROWS_TO_PROCESS - 1, Math.max(rowIds.length - 1, 0))
146
+ lastRowIndex: Math.min(DEFAULT_ROWS_TO_PROCESS, Math.max(rowIds.length, 0))
146
147
  };
147
148
  const rows = rowIds.map(id => ({
148
149
  id,
@@ -173,10 +174,11 @@ export const useGridRowSpanning = (apiRef, props) => {
173
174
  } = useGridVisibleRows(apiRef, props);
174
175
  const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
175
176
  const colDefs = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
177
+ const tree = useGridSelector(apiRef, gridRowTreeSelector);
176
178
  const processedRange = useLazyRef(() => {
177
179
  return Object.keys(apiRef.current.state.rowSpanning.spannedCells).length > 0 ? {
178
180
  firstRowIndex: 0,
179
- lastRowIndex: Math.min(DEFAULT_ROWS_TO_PROCESS - 1, Math.max(apiRef.current.state.rows.dataRowIds.length - 1, 0))
181
+ lastRowIndex: Math.min(DEFAULT_ROWS_TO_PROCESS, Math.max(apiRef.current.state.rows.dataRowIds.length, 0))
180
182
  } : EMPTY_RANGE;
181
183
  });
182
184
  const lastRange = React.useRef(EMPTY_RANGE);
@@ -188,7 +190,7 @@ export const useGridRowSpanning = (apiRef, props) => {
188
190
  // - The `paginationModel` is updated
189
191
  // - The rows are updated
190
192
  (resetState = true) => {
191
- if (!props.unstable_rowSpanning) {
193
+ if (!props.rowSpanning) {
192
194
  if (apiRef.current.state.rowSpanning !== EMPTY_STATE) {
193
195
  apiRef.current.setState(state => _extends({}, state, {
194
196
  rowSpanning: EMPTY_STATE
@@ -204,7 +206,7 @@ export const useGridRowSpanning = (apiRef, props) => {
204
206
  }
205
207
  const rangeToProcess = getUnprocessedRange({
206
208
  firstRowIndex: renderContext.firstRowIndex,
207
- lastRowIndex: Math.min(renderContext.lastRowIndex - 1, range.lastRowIndex)
209
+ lastRowIndex: Math.min(renderContext.lastRowIndex, range.lastRowIndex + 1)
208
210
  }, processedRange.current);
209
211
  if (rangeToProcess === null) {
210
212
  return;
@@ -233,15 +235,21 @@ export const useGridRowSpanning = (apiRef, props) => {
233
235
  }
234
236
  });
235
237
  });
236
- }, [apiRef, props.unstable_rowSpanning, range, renderContext, visibleRows, colDefs, processedRange]);
238
+ }, [apiRef, props.rowSpanning, range, renderContext, visibleRows, colDefs, processedRange]);
237
239
  const prevRenderContext = React.useRef(renderContext);
238
240
  const isFirstRender = React.useRef(true);
239
241
  const shouldResetState = React.useRef(false);
242
+ const previousTree = React.useRef(tree);
240
243
  React.useEffect(() => {
241
244
  const firstRender = isFirstRender.current;
242
245
  if (isFirstRender.current) {
243
246
  isFirstRender.current = false;
244
247
  }
248
+ if (tree !== previousTree.current) {
249
+ previousTree.current = tree;
250
+ updateRowSpanningState(true);
251
+ return;
252
+ }
245
253
  if (range && lastRange.current && isRowRangeUpdated(range, lastRange.current)) {
246
254
  lastRange.current = range;
247
255
  shouldResetState.current = true;
@@ -255,5 +263,5 @@ export const useGridRowSpanning = (apiRef, props) => {
255
263
  return;
256
264
  }
257
265
  updateRowSpanningState();
258
- }, [updateRowSpanningState, renderContext, range, lastRange]);
266
+ }, [updateRowSpanningState, renderContext, range, lastRange, tree]);
259
267
  };
@@ -239,7 +239,7 @@ export const useGridRows = (apiRef, props) => {
239
239
  throw new Error(`MUI X: The row reordering do not support reordering of footer or grouping rows.`);
240
240
  }
241
241
  apiRef.current.setState(state => {
242
- const group = gridRowTreeSelector(state, apiRef.current.instanceId)[GRID_ROOT_GROUP_ID];
242
+ const group = gridRowTreeSelector(state, undefined, apiRef.current.instanceId)[GRID_ROOT_GROUP_ID];
243
243
  const allRows = group.children;
244
244
  const oldIndex = allRows.findIndex(row => row === rowId);
245
245
  if (oldIndex === -1 || oldIndex === targetIndex) {
@@ -392,10 +392,10 @@ export const useGridRows = (apiRef, props) => {
392
392
  const applyHydrateRowsProcessor = React.useCallback(() => {
393
393
  apiRef.current.setState(state => {
394
394
  const response = apiRef.current.unstable_applyPipeProcessors('hydrateRows', {
395
- tree: gridRowTreeSelector(state, apiRef.current.instanceId),
396
- treeDepths: gridRowTreeDepthsSelector(state, apiRef.current.instanceId),
397
- dataRowIds: gridDataRowIdsSelector(state, apiRef.current.instanceId),
398
- dataRowIdToModelLookup: gridRowsLookupSelector(state, apiRef.current.instanceId)
395
+ tree: gridRowTreeSelector(state, undefined, apiRef.current.instanceId),
396
+ treeDepths: gridRowTreeDepthsSelector(state, undefined, apiRef.current.instanceId),
397
+ dataRowIds: gridDataRowIdsSelector(state, undefined, apiRef.current.instanceId),
398
+ dataRowIdToModelLookup: gridRowsLookupSelector(state, undefined, apiRef.current.instanceId)
399
399
  });
400
400
  return _extends({}, state, {
401
401
  rows: _extends({}, state.rows, response, {
@@ -55,4 +55,15 @@ export const gridSortColumnLookupSelector = createSelectorMemoized(gridSortModel
55
55
  return res;
56
56
  }, {});
57
57
  return result;
58
+ });
59
+
60
+ /**
61
+ * @category Sorting
62
+ * @ignore - do not document.
63
+ */
64
+ export const gridSortedRowIndexLookupSelector = createSelectorMemoized(gridSortedRowIdsSelector, sortedIds => {
65
+ return sortedIds.reduce((acc, id, index) => {
66
+ acc[id] = index;
67
+ return acc;
68
+ }, Object.create(null));
58
69
  });
@@ -1,2 +1,2 @@
1
- export * from "./gridSortingSelector.js";
1
+ export { gridSortedRowIdsSelector, gridSortedRowEntriesSelector, gridSortModelSelector, gridSortColumnLookupSelector } from "./gridSortingSelector.js";
2
2
  export { gridDateComparator, gridNumberComparator, gridStringOrNumberComparator } from "./gridSortingUtils.js";
@@ -88,7 +88,7 @@ export const useGridSorting = (apiRef, props) => {
88
88
  })
89
89
  });
90
90
  }
91
- const sortModel = gridSortModelSelector(state, apiRef.current.instanceId);
91
+ const sortModel = gridSortModelSelector(state, undefined, apiRef.current.instanceId);
92
92
  const sortRowList = buildAggregatedSortingApplier(sortModel, apiRef);
93
93
  const sortedRows = apiRef.current.applyStrategyProcessor('sorting', {
94
94
  sortRowList
@@ -92,10 +92,7 @@ export const useGridVirtualScroller = () => {
92
92
  return undefined;
93
93
  }
94
94
  const initialRect = node.getBoundingClientRect();
95
- let lastSize = {
96
- width: initialRect.width,
97
- height: initialRect.height
98
- };
95
+ let lastSize = roundDimensions(initialRect);
99
96
  apiRef.current.publishEvent('resize', lastSize);
100
97
  if (typeof ResizeObserver === 'undefined') {
101
98
  return undefined;
@@ -105,10 +102,7 @@ export const useGridVirtualScroller = () => {
105
102
  if (!entry) {
106
103
  return;
107
104
  }
108
- const newSize = {
109
- width: entry.contentRect.width,
110
- height: entry.contentRect.height
111
- };
105
+ const newSize = roundDimensions(entry.contentRect);
112
106
  if (newSize.width === lastSize.width && newSize.height === lastSize.height) {
113
107
  return;
114
108
  }
@@ -784,4 +778,13 @@ function bufferForDirection(isRtl, direction, rowBufferPx, columnBufferPx, verti
784
778
  // eslint unable to figure out enum exhaustiveness
785
779
  throw new Error('unreachable');
786
780
  }
781
+ }
782
+
783
+ // Round to avoid issues with subpixel rendering
784
+ // https://github.com/mui/mui-x/issues/15721
785
+ function roundDimensions(dimensions) {
786
+ return {
787
+ width: Math.round(dimensions.width * 10) / 10,
788
+ height: Math.round(dimensions.height * 10) / 10
789
+ };
787
790
  }
@@ -6,20 +6,11 @@ import { useOnMount } from "./useOnMount.js";
6
6
  function isOutputSelector(selector) {
7
7
  return selector.acceptsApiRef;
8
8
  }
9
- // TODO v8: Remove this function
10
- function applySelector(apiRef, selector) {
11
- if (isOutputSelector(selector)) {
12
- return selector(apiRef);
13
- }
14
- return selector(apiRef.current.state);
15
- }
16
-
17
- // TODO v8: Rename this function to `applySelector`
18
- function applySelectorV8(apiRef, selector, args, instanceId) {
9
+ function applySelector(apiRef, selector, args, instanceId) {
19
10
  if (isOutputSelector(selector)) {
20
11
  return selector(apiRef, args);
21
12
  }
22
- return selector(apiRef.current.state, instanceId);
13
+ return selector(apiRef.current.state, args, instanceId);
23
14
  }
24
15
  const defaultCompare = Object.is;
25
16
  export const objectShallowCompare = fastObjectShallowCompare;
@@ -44,36 +35,7 @@ const createRefs = () => ({
44
35
  selector: null,
45
36
  args: null
46
37
  });
47
-
48
- // TODO v8: Remove this function
49
- export const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
50
- if (process.env.NODE_ENV !== 'production') {
51
- if (!apiRef.current.state) {
52
- warnOnce(['MUI X: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
53
- }
54
- }
55
- const refs = useLazyRef(createRefs);
56
- const didInit = refs.current.selector !== null;
57
- const [state, setState] = React.useState(
58
- // We don't use an initialization function to avoid allocations
59
- didInit ? null : applySelector(apiRef, selector));
60
- refs.current.state = state;
61
- refs.current.equals = equals;
62
- refs.current.selector = selector;
63
- useOnMount(() => {
64
- return apiRef.current.store.subscribe(() => {
65
- const newState = applySelector(apiRef, refs.current.selector);
66
- if (!refs.current.equals(refs.current.state, newState)) {
67
- refs.current.state = newState;
68
- setState(newState);
69
- }
70
- });
71
- });
72
- return state;
73
- };
74
-
75
- // TODO v8: Rename this function to `useGridSelector`
76
- export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = defaultCompare) => {
38
+ export const useGridSelector = (apiRef, selector, args = undefined, equals = defaultCompare) => {
77
39
  if (process.env.NODE_ENV !== 'production') {
78
40
  if (!apiRef.current.state) {
79
41
  warnOnce(['MUI X: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
@@ -83,14 +45,14 @@ export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = d
83
45
  const didInit = refs.current.selector !== null;
84
46
  const [state, setState] = React.useState(
85
47
  // We don't use an initialization function to avoid allocations
86
- didInit ? null : applySelectorV8(apiRef, selector, args, apiRef.current.instanceId));
48
+ didInit ? null : applySelector(apiRef, selector, args, apiRef.current.instanceId));
87
49
  refs.current.state = state;
88
50
  refs.current.equals = equals;
89
51
  refs.current.selector = selector;
90
52
  const prevArgs = refs.current.args;
91
53
  refs.current.args = args;
92
54
  if (didInit && !argsEqual(prevArgs, args)) {
93
- const newState = applySelectorV8(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
55
+ const newState = applySelector(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
94
56
  if (!refs.current.equals(refs.current.state, newState)) {
95
57
  refs.current.state = newState;
96
58
  setState(newState);
@@ -98,7 +60,7 @@ export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = d
98
60
  }
99
61
  useOnMount(() => {
100
62
  return apiRef.current.store.subscribe(() => {
101
- const newState = applySelectorV8(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
63
+ const newState = applySelector(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
102
64
  if (!refs.current.equals(refs.current.state, newState)) {
103
65
  refs.current.state = newState;
104
66
  setState(newState);
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v8.0.0-alpha.3
2
+ * @mui/x-data-grid v8.0.0-alpha.5
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -47,6 +47,7 @@ export { calculatePinnedRowsHeight } from "../hooks/features/rows/gridRowsUtils.
47
47
  export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.js";
48
48
  export { useGridRowSelectionPreProcessors } from "../hooks/features/rowSelection/useGridRowSelectionPreProcessors.js";
49
49
  export { useGridSorting, sortingStateInitializer } from "../hooks/features/sorting/useGridSorting.js";
50
+ export { gridSortedRowIndexLookupSelector } from "../hooks/features/sorting/gridSortingSelector.js";
50
51
  export { useGridScroll } from "../hooks/features/scroll/useGridScroll.js";
51
52
  export { useGridEvents } from "../hooks/features/events/useGridEvents.js";
52
53
  export { dimensionsStateInitializer, useGridDimensions } from "../hooks/features/dimensions/useGridDimensions.js";
@@ -61,8 +62,7 @@ export { useGridVisibleRows, getVisibleRows } from "../hooks/utils/useGridVisibl
61
62
  export { useGridInitializeState } from "../hooks/utils/useGridInitializeState.js";
62
63
  export { getColumnsToExport, defaultGetRowsToExport } from "../hooks/features/export/utils.js";
63
64
  export * from "../utils/createControllablePromise.js";
64
- export { createSelector, createSelectorV8, createSelectorMemoized, createSelectorMemoizedV8 } from "../utils/createSelector.js";
65
- export { useGridSelectorV8 } from "../hooks/utils/useGridSelector.js";
65
+ export { createSelector, createSelectorMemoized } from "../utils/createSelector.js";
66
66
  export { gridRowGroupsToFetchSelector } from "../hooks/features/rows/gridRowsSelector.js";
67
67
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from "../utils/domUtils.js";
68
68
  export { isNavigationKey, isPasteShortcut, isCopyShortcut } from "../utils/keyboardUtils.js";
@@ -1,4 +1,3 @@
1
1
  export * from "./computeSlots.js";
2
- export * from "./useProps.js";
3
2
  export * from "./propValidation.js";
4
3
  export * from "./gridRowGroupingUtils.js";
@@ -24,16 +24,15 @@ const koKRGrid = {
24
24
  toolbarQuickFilterLabel: '검색',
25
25
  toolbarQuickFilterDeleteIconLabel: '초기화',
26
26
  // Prompt toolbar field
27
- // toolbarPromptControlPlaceholder: 'Type a prompt…',
28
- // toolbarPromptControlWithRecordingPlaceholder: 'Type or record a prompt…',
29
- // toolbarPromptControlRecordingPlaceholder: 'Listening for prompt…',
30
- // toolbarPromptControlLabel: 'Prompt input',
31
- // toolbarPromptControlRecordButtonDefaultLabel: 'Record',
32
- // toolbarPromptControlRecordButtonActiveLabel: 'Stop recording',
33
- // toolbarPromptControlSendActionLabel: 'Send',
34
- // toolbarPromptControlSendActionAriaLabel: 'Send prompt',
35
- // toolbarPromptControlErrorMessage: 'An error occurred while processing the request. Please try again with a different prompt.',
36
-
27
+ toolbarPromptControlPlaceholder: '프롬프트 입력…',
28
+ toolbarPromptControlWithRecordingPlaceholder: '프롬프트 입력 또는 녹음…',
29
+ toolbarPromptControlRecordingPlaceholder: '녹음 중…',
30
+ toolbarPromptControlLabel: '프롬프트 입력',
31
+ toolbarPromptControlRecordButtonDefaultLabel: '녹음',
32
+ toolbarPromptControlRecordButtonActiveLabel: '녹음 정지',
33
+ toolbarPromptControlSendActionLabel: '전송',
34
+ toolbarPromptControlSendActionAriaLabel: '프롬프트 전송',
35
+ toolbarPromptControlErrorMessage: '요청을 처리하는 동안 오류가 발생했습니다. 다른 프롬프트로 다시 시도하십시오.',
37
36
  // Export selector toolbar button text
38
37
  toolbarExport: '내보내기',
39
38
  toolbarExportLabel: '내보내기',
@@ -41,15 +40,14 @@ const koKRGrid = {
41
40
  toolbarExportPrint: '프린트',
42
41
  toolbarExportExcel: 'Excel로 내보내기',
43
42
  // Columns management text
44
- // columnsManagementSearchTitle: 'Search',
45
- // columnsManagementNoColumns: 'No columns',
46
- // columnsManagementShowHideAllText: 'Show/Hide All',
47
- // columnsManagementReset: 'Reset',
48
- // columnsManagementDeleteIconLabel: 'Clear',
49
-
43
+ columnsManagementSearchTitle: '검색',
44
+ columnsManagementNoColumns: '열이 없습니다.',
45
+ columnsManagementShowHideAllText: '모두 보기/숨기기',
46
+ columnsManagementReset: '초기화',
47
+ columnsManagementDeleteIconLabel: '제거',
50
48
  // Filter panel text
51
49
  filterPanelAddFilter: '필터 추가',
52
- // filterPanelRemoveAll: 'Remove all',
50
+ filterPanelRemoveAll: '모두 삭제',
53
51
  filterPanelDeleteIconLabel: '삭제',
54
52
  filterPanelLogicOperator: '논리 연산자',
55
53
  filterPanelOperator: '연산자',
@@ -60,9 +58,9 @@ const koKRGrid = {
60
58
  filterPanelInputPlaceholder: '값 입력',
61
59
  // Filter operators text
62
60
  filterOperatorContains: '포함하는',
63
- // filterOperatorDoesNotContain: 'does not contain',
61
+ filterOperatorDoesNotContain: '포함하지 않는',
64
62
  filterOperatorEquals: '값이 같은',
65
- // filterOperatorDoesNotEqual: 'does not equal',
63
+ filterOperatorDoesNotEqual: '값이 다른',
66
64
  filterOperatorStartsWith: '시작하는',
67
65
  filterOperatorEndsWith: '끝나는',
68
66
  filterOperatorIs: '~인',
@@ -74,36 +72,34 @@ const koKRGrid = {
74
72
  filterOperatorIsEmpty: '값이 없는',
75
73
  filterOperatorIsNotEmpty: '값이 있는',
76
74
  filterOperatorIsAnyOf: '값 중 하나인',
77
- // 'filterOperator=': '=',
78
- // 'filterOperator!=': '!=',
79
- // 'filterOperator>': '>',
80
- // 'filterOperator>=': '>=',
81
- // 'filterOperator<': '<',
82
- // 'filterOperator<=': '<=',
83
-
75
+ 'filterOperator=': '=',
76
+ 'filterOperator!=': '!=',
77
+ 'filterOperator>': '>',
78
+ 'filterOperator>=': '>=',
79
+ 'filterOperator<': '<',
80
+ 'filterOperator<=': '<=',
84
81
  // Header filter operators text
85
- // headerFilterOperatorContains: 'Contains',
86
- // headerFilterOperatorDoesNotContain: 'Does not contain',
87
- // headerFilterOperatorEquals: 'Equals',
88
- // headerFilterOperatorDoesNotEqual: 'Does not equal',
89
- // headerFilterOperatorStartsWith: 'Starts with',
90
- // headerFilterOperatorEndsWith: 'Ends with',
91
- // headerFilterOperatorIs: 'Is',
92
- // headerFilterOperatorNot: 'Is not',
93
- // headerFilterOperatorAfter: 'Is after',
94
- // headerFilterOperatorOnOrAfter: 'Is on or after',
95
- // headerFilterOperatorBefore: 'Is before',
96
- // headerFilterOperatorOnOrBefore: 'Is on or before',
97
- // headerFilterOperatorIsEmpty: 'Is empty',
98
- // headerFilterOperatorIsNotEmpty: 'Is not empty',
99
- // headerFilterOperatorIsAnyOf: 'Is any of',
100
- // 'headerFilterOperator=': 'Equals',
101
- // 'headerFilterOperator!=': 'Not equals',
102
- // 'headerFilterOperator>': 'Greater than',
103
- // 'headerFilterOperator>=': 'Greater than or equal to',
104
- // 'headerFilterOperator<': 'Less than',
105
- // 'headerFilterOperator<=': 'Less than or equal to',
106
-
82
+ headerFilterOperatorContains: '포함하는',
83
+ headerFilterOperatorDoesNotContain: '포함하지 않는',
84
+ headerFilterOperatorEquals: '값이 같은',
85
+ headerFilterOperatorDoesNotEqual: '값이 다른',
86
+ headerFilterOperatorStartsWith: '시작하는',
87
+ headerFilterOperatorEndsWith: '끝나는',
88
+ headerFilterOperatorIs: '~인',
89
+ headerFilterOperatorNot: '~아닌',
90
+ headerFilterOperatorAfter: ' 이후',
91
+ headerFilterOperatorOnOrAfter: '이후',
92
+ headerFilterOperatorBefore: ' 이전',
93
+ headerFilterOperatorOnOrBefore: '이전',
94
+ headerFilterOperatorIsEmpty: '값이 없는',
95
+ headerFilterOperatorIsNotEmpty: '값이 있는',
96
+ headerFilterOperatorIsAnyOf: ' 하나인',
97
+ 'headerFilterOperator=': '값이 같은',
98
+ 'headerFilterOperator!=': '값이 다른',
99
+ 'headerFilterOperator>': ' ',
100
+ 'headerFilterOperator>=': '같거나 ',
101
+ 'headerFilterOperator<': ' 작은',
102
+ 'headerFilterOperator<=': '같거나 작은',
107
103
  // Filter values text
108
104
  filterValueAny: '아무값',
109
105
  filterValueTrue: '참',
@@ -111,7 +107,7 @@ const koKRGrid = {
111
107
  // Column menu text
112
108
  columnMenuLabel: '메뉴',
113
109
  columnMenuShowColumns: '열 표시',
114
- // columnMenuManageColumns: 'Manage columns',
110
+ columnMenuManageColumns: ' 관리',
115
111
  columnMenuFilter: '필터',
116
112
  columnMenuHideColumn: '열 숨기기',
117
113
  columnMenuUnsort: '정렬 해제',