@mui/x-data-grid 8.19.0 → 8.21.0

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 (80) hide show
  1. package/CHANGELOG.md +174 -0
  2. package/components/GridRow.js +4 -1
  3. package/components/GridRowDragAndDropOverlay.d.ts +7 -0
  4. package/components/GridRowDragAndDropOverlay.js +73 -0
  5. package/components/containers/GridRootStyles.js +16 -39
  6. package/components/virtualization/GridVirtualScroller.js +5 -3
  7. package/components/virtualization/GridVirtualScrollerRenderZone.js +4 -16
  8. package/constants/gridClasses.d.ts +0 -8
  9. package/constants/gridClasses.js +1 -1
  10. package/esm/components/GridRow.js +4 -1
  11. package/esm/components/GridRowDragAndDropOverlay.d.ts +7 -0
  12. package/esm/components/GridRowDragAndDropOverlay.js +66 -0
  13. package/esm/components/containers/GridRootStyles.js +16 -39
  14. package/esm/components/virtualization/GridVirtualScroller.js +5 -3
  15. package/esm/components/virtualization/GridVirtualScrollerRenderZone.js +3 -15
  16. package/esm/constants/gridClasses.d.ts +0 -8
  17. package/esm/constants/gridClasses.js +1 -1
  18. package/esm/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +4 -3
  19. package/esm/hooks/core/useGridVirtualizer.d.ts +6 -50
  20. package/esm/hooks/core/useGridVirtualizer.js +10 -9
  21. package/esm/hooks/features/columnResize/useGridColumnResize.js +17 -8
  22. package/esm/hooks/features/dataSource/useGridDataSourceBase.js +2 -2
  23. package/esm/hooks/features/dimensions/useGridDimensions.js +3 -1
  24. package/esm/hooks/features/editing/useGridCellEditing.js +1 -1
  25. package/esm/hooks/features/editing/useGridRowEditing.js +1 -1
  26. package/esm/hooks/features/export/serializers/csvSerializer.js +2 -4
  27. package/esm/hooks/features/filter/gridFilterUtils.js +5 -11
  28. package/esm/hooks/features/filter/index.d.ts +1 -1
  29. package/esm/hooks/features/filter/index.js +1 -1
  30. package/esm/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +19 -0
  31. package/esm/hooks/features/rowReorder/gridRowReorderSelector.d.ts +20 -1
  32. package/esm/hooks/features/rowReorder/gridRowReorderSelector.js +19 -1
  33. package/esm/hooks/features/rowSelection/useGridRowSelection.js +9 -1
  34. package/esm/hooks/features/rows/useGridRows.js +3 -1
  35. package/esm/hooks/features/rows/useGridRowsOverridableMethods.d.ts +1 -0
  36. package/esm/hooks/features/rows/useGridRowsOverridableMethods.js +57 -7
  37. package/esm/hooks/features/sorting/gridSortingUtils.js +1 -3
  38. package/esm/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
  39. package/esm/hooks/utils/useGridSelector.js +2 -4
  40. package/esm/index.js +1 -1
  41. package/esm/internals/index.d.ts +5 -4
  42. package/esm/internals/index.js +3 -3
  43. package/esm/material/index.js +1 -4
  44. package/esm/models/api/gridRowApi.d.ts +14 -1
  45. package/esm/models/api/index.d.ts +1 -1
  46. package/esm/models/api/index.js +0 -1
  47. package/esm/models/configuration/gridConfiguration.d.ts +2 -2
  48. package/esm/models/configuration/gridRowConfiguration.d.ts +6 -5
  49. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +4 -3
  50. package/hooks/core/useGridVirtualizer.d.ts +6 -50
  51. package/hooks/core/useGridVirtualizer.js +9 -8
  52. package/hooks/features/columnResize/useGridColumnResize.js +17 -8
  53. package/hooks/features/dataSource/useGridDataSourceBase.js +2 -2
  54. package/hooks/features/dimensions/useGridDimensions.js +3 -1
  55. package/hooks/features/editing/useGridCellEditing.js +1 -1
  56. package/hooks/features/editing/useGridRowEditing.js +1 -1
  57. package/hooks/features/export/serializers/csvSerializer.js +2 -4
  58. package/hooks/features/filter/gridFilterUtils.js +5 -11
  59. package/hooks/features/filter/index.d.ts +1 -1
  60. package/hooks/features/filter/index.js +6 -0
  61. package/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +19 -0
  62. package/hooks/features/rowReorder/gridRowReorderSelector.d.ts +20 -1
  63. package/hooks/features/rowReorder/gridRowReorderSelector.js +20 -2
  64. package/hooks/features/rowSelection/useGridRowSelection.js +9 -1
  65. package/hooks/features/rows/useGridRows.js +3 -1
  66. package/hooks/features/rows/useGridRowsOverridableMethods.d.ts +1 -0
  67. package/hooks/features/rows/useGridRowsOverridableMethods.js +57 -7
  68. package/hooks/features/sorting/gridSortingUtils.js +1 -3
  69. package/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
  70. package/hooks/utils/useGridSelector.js +2 -4
  71. package/index.js +1 -1
  72. package/internals/index.d.ts +5 -4
  73. package/internals/index.js +16 -9
  74. package/material/index.js +1 -4
  75. package/models/api/gridRowApi.d.ts +14 -1
  76. package/models/api/index.d.ts +1 -1
  77. package/models/api/index.js +0 -11
  78. package/models/configuration/gridConfiguration.d.ts +2 -2
  79. package/models/configuration/gridRowConfiguration.d.ts +6 -5
  80. package/package.json +3 -3
@@ -1,20 +1,69 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { gridRowTreeSelector, gridRowNodeSelector } from "./gridRowsSelector.js";
4
+ import { gridExpandedSortedRowIndexLookupSelector } from "../filter/gridFilterSelector.js";
4
5
  import { GRID_ROOT_GROUP_ID } from "./gridRowsUtils.js";
5
6
  export const useGridRowsOverridableMethods = apiRef => {
7
+ const setRowPosition = React.useCallback((sourceRowId, targetRowId, position) => {
8
+ const sourceNode = gridRowNodeSelector(apiRef, sourceRowId);
9
+ const targetNode = gridRowNodeSelector(apiRef, targetRowId);
10
+ if (!sourceNode) {
11
+ throw new Error(`MUI X: No row with id #${sourceRowId} found.`);
12
+ }
13
+ if (!targetNode) {
14
+ throw new Error(`MUI X: No row with id #${targetRowId} found.`);
15
+ }
16
+ if (sourceNode.type !== 'leaf') {
17
+ throw new Error(`MUI X: The row reordering does not support reordering of footer or grouping rows.`);
18
+ }
19
+ if (position === 'inside') {
20
+ throw new Error(`MUI X: The 'inside' position is only supported for tree data. Use 'above' or 'below' for flat data.`);
21
+ }
22
+
23
+ // Get the target index from the targetRowId using the lookup selector
24
+ const sortedFilteredRowIndexLookup = gridExpandedSortedRowIndexLookupSelector(apiRef);
25
+ const targetRowIndexUnadjusted = sortedFilteredRowIndexLookup[targetRowId];
26
+ if (targetRowIndexUnadjusted === undefined) {
27
+ throw new Error(`MUI X: Target row with id #${targetRowId} not found in current view.`);
28
+ }
29
+ const sourceRowIndex = sortedFilteredRowIndexLookup[sourceRowId];
30
+ if (sourceRowIndex === undefined) {
31
+ throw new Error(`MUI X: Source row with id #${sourceRowId} not found in current view.`);
32
+ }
33
+ const dragDirection = targetRowIndexUnadjusted < sourceRowIndex ? 'up' : 'down';
34
+ let targetRowIndex;
35
+ if (dragDirection === 'up') {
36
+ targetRowIndex = position === 'above' ? targetRowIndexUnadjusted : targetRowIndexUnadjusted + 1;
37
+ } else {
38
+ targetRowIndex = position === 'above' ? targetRowIndexUnadjusted - 1 : targetRowIndexUnadjusted;
39
+ }
40
+ if (targetRowIndex === sourceRowIndex) {
41
+ return;
42
+ }
43
+ apiRef.current.setState(state => {
44
+ const group = gridRowTreeSelector(apiRef)[GRID_ROOT_GROUP_ID];
45
+ const allRows = group.children;
46
+ const updatedRows = [...allRows];
47
+ updatedRows.splice(targetRowIndex, 0, updatedRows.splice(sourceRowIndex, 1)[0]);
48
+ return _extends({}, state, {
49
+ rows: _extends({}, state.rows, {
50
+ tree: _extends({}, state.rows.tree, {
51
+ [GRID_ROOT_GROUP_ID]: _extends({}, group, {
52
+ children: updatedRows
53
+ })
54
+ })
55
+ })
56
+ });
57
+ });
58
+ apiRef.current.publishEvent('rowsSet');
59
+ }, [apiRef]);
6
60
  const setRowIndex = React.useCallback((rowId, targetIndex) => {
7
61
  const node = gridRowNodeSelector(apiRef, rowId);
8
62
  if (!node) {
9
63
  throw new Error(`MUI X: No row with id #${rowId} found.`);
10
64
  }
11
-
12
- // TODO: Remove irrelevant checks
13
- if (node.parent !== GRID_ROOT_GROUP_ID) {
14
- throw new Error(`MUI X: The row reordering do not support reordering of grouped rows yet.`);
15
- }
16
65
  if (node.type !== 'leaf') {
17
- throw new Error(`MUI X: The row reordering do not support reordering of footer or grouping rows.`);
66
+ throw new Error(`MUI X: The row reordering does not support reordering of footer or grouping rows.`);
18
67
  }
19
68
  apiRef.current.setState(state => {
20
69
  const group = gridRowTreeSelector(apiRef)[GRID_ROOT_GROUP_ID];
@@ -38,6 +87,7 @@ export const useGridRowsOverridableMethods = apiRef => {
38
87
  apiRef.current.publishEvent('rowsSet');
39
88
  }, [apiRef]);
40
89
  return {
41
- setRowIndex
90
+ setRowIndex,
91
+ setRowPosition
42
92
  };
43
93
  };
@@ -3,9 +3,7 @@ import { warnOnce } from '@mui/x-internals/warning';
3
3
  import { gridRowNodeSelector } from "../rows/gridRowsSelector.js";
4
4
  export const sanitizeSortModel = (model, disableMultipleColumnsSorting) => {
5
5
  if (disableMultipleColumnsSorting && model.length > 1) {
6
- if (process.env.NODE_ENV !== 'production') {
7
- warnOnce(['MUI X: The `sortModel` can only contain a single item when the `disableMultipleColumnsSorting` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
8
- }
6
+ warnOnce(['MUI X: The `sortModel` can only contain a single item when the `disableMultipleColumnsSorting` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
9
7
  return [model[0]];
10
8
  }
11
9
  return model;
@@ -1,10 +1,10 @@
1
1
  import { RefObject } from '@mui/x-internals/types';
2
- import { Virtualization } from '@mui/x-virtualizer';
2
+ import { Virtualization, LayoutDataGridLegacy } from '@mui/x-virtualizer';
3
3
  import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
4
4
  import { GridStateInitializer } from "../../utils/useGridInitializeState.js";
5
5
  import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
6
6
  type RootProps = DataGridProcessedProps;
7
- export type GridVirtualizationState = { [K in keyof Virtualization.State['virtualization']]: Virtualization.State['virtualization'][K] };
7
+ export type GridVirtualizationState = { [K in keyof Virtualization.State<LayoutDataGridLegacy>['virtualization']]: Virtualization.State<LayoutDataGridLegacy>['virtualization'][K] };
8
8
  export declare const virtualizationStateInitializer: GridStateInitializer<RootProps>;
9
9
  export declare function useGridVirtualization(apiRef: RefObject<GridPrivateApiCommunity>, rootProps: RootProps): void;
10
10
  export {};
@@ -31,10 +31,8 @@ const createRefs = () => ({
31
31
  const EMPTY = [];
32
32
  const emptyGetSnapshot = () => null;
33
33
  export function useGridSelector(apiRef, selector, args = undefined, equals = defaultCompare) {
34
- if (process.env.NODE_ENV !== 'production') {
35
- if (!apiRef.current.state) {
36
- 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.']);
37
- }
34
+ if (!apiRef.current.state) {
35
+ 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.']);
38
36
  }
39
37
  const refs = useLazyRef(createRefs);
40
38
  const didInit = refs.current.selector !== null;
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v8.19.0
2
+ * @mui/x-data-grid v8.21.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -41,7 +41,7 @@ export { useGridPrintExport } from "../hooks/features/export/useGridPrintExport.
41
41
  export { useGridFilter, filterStateInitializer } from "../hooks/features/filter/useGridFilter.js";
42
42
  export { defaultGridFilterLookup } from "../hooks/features/filter/gridFilterState.js";
43
43
  export { passFilterLogic } from "../hooks/features/filter/gridFilterUtils.js";
44
- export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector, gridExpandedSortedRowIndexLookupSelector, gridFilteredSortedDepthRowEntriesSelector } from "../hooks/features/filter/gridFilterSelector.js";
44
+ export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector, gridFilteredSortedDepthRowEntriesSelector } from "../hooks/features/filter/gridFilterSelector.js";
45
45
  export { isSingleSelectColDef } from "../components/panel/filterPanel/filterPanelUtils.js";
46
46
  export type { GridAggregatedFilterItemApplier, GridAggregatedFilterItemApplierResult } from "../hooks/features/filter/gridFilterState.js";
47
47
  export { useGridFocus, focusStateInitializer } from "../hooks/features/focus/useGridFocus.js";
@@ -54,7 +54,7 @@ export { useGridRows, rowsStateInitializer } from "../hooks/features/rows/useGri
54
54
  export { useGridRowSpanning, rowSpanningStateInitializer } from "../hooks/features/rows/useGridRowSpanning.js";
55
55
  export { useGridAriaAttributes } from "../hooks/utils/useGridAriaAttributes.js";
56
56
  export { useGridRowAriaAttributes } from "../hooks/features/rows/useGridRowAriaAttributes.js";
57
- export { useGridRowsOverridableMethods } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
57
+ export { useGridRowsOverridableMethods as useGridRowsOverridableMethodsCommunity } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
58
58
  export { useGridParamsOverridableMethods } from "../hooks/features/rows/useGridParamsOverridableMethods.js";
59
59
  export { useIsCellEditable } from "../hooks/features/editing/useGridCellEditable.js";
60
60
  export { useGridRowsPreProcessors } from "../hooks/features/rows/useGridRowsPreProcessors.js";
@@ -66,7 +66,7 @@ export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED, getRowValue } from "../hoo
66
66
  export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, gridRowSelector } from "../hooks/features/rows/gridRowsSelector.js";
67
67
  export { headerFilteringStateInitializer, useGridHeaderFiltering } from "../hooks/features/headerFiltering/useGridHeaderFiltering.js";
68
68
  export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.js";
69
- export { gridIsRowDragActiveSelector } from "../hooks/features/rowReorder/gridRowReorderSelector.js";
69
+ export { gridIsRowDragActiveSelector, gridRowDropPositionSelector, gridRowDropTargetRowIdSelector } from "../hooks/features/rowReorder/gridRowReorderSelector.js";
70
70
  export type { GridRowReorderState } from "../hooks/features/rowReorder/gridRowReorderInterfaces.js";
71
71
  export { useGridRowSelectionPreProcessors } from "../hooks/features/rowSelection/useGridRowSelectionPreProcessors.js";
72
72
  export { useGridSorting, sortingStateInitializer } from "../hooks/features/sorting/useGridSorting.js";
@@ -121,4 +121,5 @@ export type { GridConfiguration } from "../models/configuration/gridConfiguratio
121
121
  export type { CellEditableConditionFn } from "../models/configuration/gridCellEditableConfiguration.js";
122
122
  export * from "../hooks/features/pivoting/index.js";
123
123
  export { createSvgIcon } from "../material/icons/createSvgIcon.js";
124
- export { useGridPanelContext } from "../components/panel/GridPanelContext.js";
124
+ export { useGridPanelContext } from "../components/panel/GridPanelContext.js";
125
+ export type { RowReorderDropPosition, RowReorderDragDirection } from "../models/api/gridRowApi.js";
@@ -31,7 +31,7 @@ export { useGridPrintExport } from "../hooks/features/export/useGridPrintExport.
31
31
  export { useGridFilter, filterStateInitializer } from "../hooks/features/filter/useGridFilter.js";
32
32
  export { defaultGridFilterLookup } from "../hooks/features/filter/gridFilterState.js";
33
33
  export { passFilterLogic } from "../hooks/features/filter/gridFilterUtils.js";
34
- export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector, gridExpandedSortedRowIndexLookupSelector, gridFilteredSortedDepthRowEntriesSelector } from "../hooks/features/filter/gridFilterSelector.js";
34
+ export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector, gridFilteredSortedDepthRowEntriesSelector } from "../hooks/features/filter/gridFilterSelector.js";
35
35
  export { isSingleSelectColDef } from "../components/panel/filterPanel/filterPanelUtils.js";
36
36
  export { useGridFocus, focusStateInitializer } from "../hooks/features/focus/useGridFocus.js";
37
37
  export { useGridKeyboardNavigation } from "../hooks/features/keyboardNavigation/useGridKeyboardNavigation.js";
@@ -43,7 +43,7 @@ export { useGridRows, rowsStateInitializer } from "../hooks/features/rows/useGri
43
43
  export { useGridRowSpanning, rowSpanningStateInitializer } from "../hooks/features/rows/useGridRowSpanning.js";
44
44
  export { useGridAriaAttributes } from "../hooks/utils/useGridAriaAttributes.js";
45
45
  export { useGridRowAriaAttributes } from "../hooks/features/rows/useGridRowAriaAttributes.js";
46
- export { useGridRowsOverridableMethods } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
46
+ export { useGridRowsOverridableMethods as useGridRowsOverridableMethodsCommunity } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
47
47
  export { useGridParamsOverridableMethods } from "../hooks/features/rows/useGridParamsOverridableMethods.js";
48
48
  export { useIsCellEditable } from "../hooks/features/editing/useGridCellEditable.js";
49
49
  export { useGridRowsPreProcessors } from "../hooks/features/rows/useGridRowsPreProcessors.js";
@@ -54,7 +54,7 @@ export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED, getRowValue } from "../hoo
54
54
  export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, gridRowSelector } from "../hooks/features/rows/gridRowsSelector.js";
55
55
  export { headerFilteringStateInitializer, useGridHeaderFiltering } from "../hooks/features/headerFiltering/useGridHeaderFiltering.js";
56
56
  export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.js";
57
- export { gridIsRowDragActiveSelector } from "../hooks/features/rowReorder/gridRowReorderSelector.js";
57
+ export { gridIsRowDragActiveSelector, gridRowDropPositionSelector, gridRowDropTargetRowIdSelector } from "../hooks/features/rowReorder/gridRowReorderSelector.js";
58
58
  export { useGridRowSelectionPreProcessors } from "../hooks/features/rowSelection/useGridRowSelectionPreProcessors.js";
59
59
  export { useGridSorting, sortingStateInitializer } from "../hooks/features/sorting/useGridSorting.js";
60
60
  export { gridSortedRowIndexLookupSelector } from "../hooks/features/sorting/gridSortingSelector.js";
@@ -589,10 +589,7 @@ function BasePopper(props) {
589
589
  if (flip) {
590
590
  result.push({
591
591
  name: 'flip',
592
- enabled: true,
593
- options: {
594
- rootBoundary: 'document'
595
- }
592
+ enabled: true
596
593
  });
597
594
  }
598
595
  if (onDidShow || onDidHide) {
@@ -1,4 +1,6 @@
1
1
  import { GridRowModel, GridRowId, GridRowModelUpdate, GridValidRowModel, GridTreeNode } from "../gridRows.js";
2
+ export type RowReorderDropPosition = 'above' | 'below' | 'inside';
3
+ export type RowReorderDragDirection = 'up' | 'down';
2
4
  export interface GridRowGroupChildrenGetterParams {
3
5
  /**
4
6
  * The row id of the group
@@ -96,10 +98,21 @@ export interface GridRowApi {
96
98
  export interface GridRowProApi {
97
99
  /**
98
100
  * Moves a row from its original position to the position given by `targetIndex`.
101
+ * Doesn't support tree data ordering. Use `setRowPosition()` instead.
99
102
  * @param {GridRowId} rowId The row id
100
103
  * @param {number} targetIndex The new position (0-based).
104
+ * @returns {void | Promise<void>} Returns a Promise when async operations are involved (e.g., processRowUpdate)
105
+ * @deprecated Use `setRowPosition()` instead. This method will be removed in the next major version.
101
106
  */
102
- setRowIndex: (rowId: GridRowId, targetIndex: number) => void;
107
+ setRowIndex: (rowId: GridRowId, targetIndex: number) => void | Promise<void>;
108
+ /**
109
+ * Moves a row to a new position relative to another row.
110
+ * @param {GridRowId} sourceRowId The ID of the row to move
111
+ * @param {GridRowId} targetRowId The ID of the row to position relative to
112
+ * @param {DropPosition} position Where to place the source row: 'above', 'below', or 'over' (for tree data)
113
+ * @returns {void | Promise<void>} Returns a Promise when async operations are involved (e.g., processRowUpdate)
114
+ */
115
+ setRowPosition: (sourceRowId: GridRowId, targetRowId: GridRowId, position: RowReorderDropPosition) => void | Promise<void>;
103
116
  /**
104
117
  * Gets the rows of a grouping criteria.
105
118
  * Only contains the rows provided to the grid, not the rows automatically generated by it.
@@ -3,7 +3,7 @@ export type { GridParamsApi } from "./gridParamsApi.js";
3
3
  export type { GridCoreApi } from "./gridCoreApi.js";
4
4
  export * from "./gridColumnApi.js";
5
5
  export * from "./gridDensityApi.js";
6
- export * from "./gridRowApi.js";
6
+ export type { GridRowGroupChildrenGetterParams, GridRowApi, GridRowProApi, GridRowProPrivateApi } from "./gridRowApi.js";
7
7
  export type { GridRowsMetaApi } from "./gridRowsMetaApi.js";
8
8
  export * from "./gridRowSelectionApi.js";
9
9
  export * from "./gridSortApi.js";
@@ -1,6 +1,5 @@
1
1
  export * from "./gridColumnApi.js";
2
2
  export * from "./gridDensityApi.js";
3
- export * from "./gridRowApi.js";
4
3
  export * from "./gridRowSelectionApi.js";
5
4
  export * from "./gridSortApi.js";
6
5
  export * from "./gridCsvExportApi.js";
@@ -3,14 +3,14 @@ import type { GridRowAriaAttributesInternalHook, GridRowsOverridableMethodsInter
3
3
  import type { GridAggregationInternalHooks } from "./gridAggregationConfiguration.js";
4
4
  import type { GridCellEditableInternalHook } from "./gridCellEditableConfiguration.js";
5
5
  import type { GridCSSVariablesInterface } from "../../constants/cssVariables.js";
6
- import { DataGridProcessedProps } from "../props/DataGridProps.js";
7
6
  import type { GridPrivateApiCommon } from "../api/gridApiCommon.js";
8
7
  import type { GridPrivateApiCommunity } from "../api/gridApiCommunity.js";
8
+ import type { DataGridProcessedProps } from "../props/DataGridProps.js";
9
9
  import type { GridParamsOverridableMethodsInternalHook } from "./gridParamsConfiguration.js";
10
10
  export interface GridAriaAttributesInternalHook {
11
11
  useGridAriaAttributes: () => React.HTMLAttributes<HTMLElement>;
12
12
  }
13
- export interface GridInternalHook<Api, Props> extends GridAriaAttributesInternalHook, GridRowAriaAttributesInternalHook, GridCellEditableInternalHook<Api, Props>, GridAggregationInternalHooks<Api, Props>, GridRowsOverridableMethodsInternalHook<Api>, GridParamsOverridableMethodsInternalHook<Api> {
13
+ export interface GridInternalHook<Api, Props> extends GridAriaAttributesInternalHook, GridRowAriaAttributesInternalHook, GridCellEditableInternalHook<Api, Props>, GridAggregationInternalHooks<Api, Props>, GridRowsOverridableMethodsInternalHook<Api, Props>, GridParamsOverridableMethodsInternalHook<Api> {
14
14
  useCSSVariables: () => {
15
15
  id: string;
16
16
  variables: GridCSSVariablesInterface;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { RefObject } from '@mui/x-internals/types';
3
- import { GridTreeNode, GridRowId } from "../gridRows.js";
4
- import { DataGridProcessedProps } from "../props/DataGridProps.js";
3
+ import { GridTreeNode } from "../gridRows.js";
4
+ import { GridRowProApi } from "../api/index.js";
5
5
  /**
6
6
  * Get the ARIA attributes for a row
7
7
  * @param {GridTreeNode} rowNode The row node
@@ -15,8 +15,9 @@ export interface GridRowAriaAttributesInternalHook {
15
15
  /**
16
16
  * Overridable row methods interface, these methods could be overriden in a higher plan package.
17
17
  */
18
- export interface GridRowsOverridableMethodsInternalHook<Api> {
19
- useGridRowsOverridableMethods: (apiRef: RefObject<Api>, props: Pick<DataGridProcessedProps, 'processRowUpdate' | 'onProcessRowUpdateError' | 'dataSource'>) => {
20
- setRowIndex: (rowId: GridRowId, targetIndex: number) => void;
18
+ export interface GridRowsOverridableMethodsInternalHook<Api, Props> {
19
+ useGridRowsOverridableMethods: (apiRef: RefObject<Api>, props: Props) => {
20
+ setRowIndex: GridRowProApi['setRowIndex'];
21
+ setRowPosition: GridRowProApi['setRowPosition'];
21
22
  };
22
23
  }
@@ -8,6 +8,7 @@ import { GridHydrateRowsValue } from "../../features/rows/gridRowsInterfaces.js"
8
8
  import { GridPreferencePanelsValue } from "../../features/preferencesPanel/index.js";
9
9
  import { GridGetRowsParams, GridGetRowsResponse } from "../../../models/gridDataSource.js";
10
10
  import { HeightEntry } from "../../features/rows/gridRowsMetaInterfaces.js";
11
+ import type { RowReorderDropPosition } from "../../../models/api/gridRowApi.js";
11
12
  export type GridPipeProcessorGroup = keyof GridPipeProcessingLookup;
12
13
  export interface GridPipeProcessingLookup {
13
14
  columnMenu: {
@@ -97,12 +98,12 @@ export interface GridPipeProcessingLookup {
97
98
  * - For example before first row is `0` and after the last row is `rows.length`.
98
99
  * If the reorder is invalid, it returns `-1`.
99
100
  */
100
- getRowReorderTargetIndex: {
101
- value: number;
101
+ isRowReorderValid: {
102
+ value: boolean;
102
103
  context: {
103
104
  sourceRowId: GridRowId;
104
105
  targetRowId: GridRowId;
105
- dropPosition: 'above' | 'below';
106
+ dropPosition: RowReorderDropPosition;
106
107
  dragDirection: 'up' | 'down';
107
108
  };
108
109
  };
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
- import { Dimensions, Virtualization } from '@mui/x-virtualizer';
2
+ import { Dimensions, LayoutDataGridLegacy, Virtualization } from '@mui/x-virtualizer';
3
3
  /**
4
4
  * Virtualizer setup
5
5
  */
6
6
  export declare function useGridVirtualizer(): {
7
- store: import("@mui/x-internals/store").Store<Dimensions.State & Virtualization.State & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
7
+ store: import("@mui/x-internals/store").Store<Dimensions.State & Virtualization.State<LayoutDataGridLegacy> & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
8
8
  api: {
9
9
  updateDimensions: (firstUpdate?: boolean) => void;
10
10
  debouncedUpdateDimensions: (((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable) | undefined;
@@ -20,57 +20,13 @@ export declare function useGridVirtualizer(): {
20
20
  resetRowHeights: () => void;
21
21
  };
22
22
  } & {
23
- getters: {
24
- setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
25
- getOffsetTop: () => number;
26
- getRows: (rowParams?: {
27
- rows?: import("@mui/x-virtualizer/models").RowEntry[];
28
- position?: import("@mui/x-virtualizer/models").PinnedRowPosition;
29
- renderContext?: import("@mui/x-virtualizer/models").RenderContext;
30
- }, unstable_rowTree?: Record<import("@mui/x-virtualizer/models").RowId, any>) => React.ReactNode[];
31
- rows: import("@mui/x-virtualizer/models").RowEntry[];
32
- getContainerProps: () => {
33
- ref: (node: HTMLDivElement | null) => (() => void | undefined) | undefined;
34
- };
35
- getScrollerProps: () => {
36
- ref: (node: HTMLDivElement | null) => (() => void | undefined) | undefined;
37
- style: React.CSSProperties;
38
- role: string;
39
- tabIndex: number | undefined;
40
- };
41
- getContentProps: () => {
42
- ref: (node: HTMLDivElement | null) => void;
43
- style: React.CSSProperties;
44
- role: string;
45
- };
46
- getScrollbarVerticalProps: () => {
47
- ref: (node: HTMLDivElement | null) => void;
48
- scrollPosition: React.RefObject<{
49
- top: number;
50
- left: number;
51
- }>;
52
- };
53
- getScrollbarHorizontalProps: () => {
54
- ref: (node: HTMLDivElement | null) => void;
55
- scrollPosition: React.RefObject<{
56
- top: number;
57
- left: number;
58
- }>;
59
- };
60
- getScrollAreaProps: () => {
61
- scrollPosition: React.RefObject<{
62
- top: number;
63
- left: number;
64
- }>;
65
- };
66
- };
67
- useVirtualization: () => import("@mui/x-virtualizer").BaseState;
68
- setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
69
- forceUpdateRenderContext: () => void;
70
- scheduleUpdateRenderContext: () => void;
71
23
  getCellColSpanInfo: (rowId: import("@mui/x-virtualizer/models").RowId, columnIndex: import("@mui/x-internals/types").integer) => import("@mui/x-virtualizer/models").CellColSpanInfo;
72
24
  calculateColSpan: (rowId: import("@mui/x-virtualizer/models").RowId, minFirstColumn: import("@mui/x-internals/types").integer, maxLastColumn: import("@mui/x-internals/types").integer, columns: import("@mui/x-virtualizer/models").ColumnWithWidth[]) => void;
73
25
  getHiddenCellsOrigin: () => Record<import("@mui/x-virtualizer/models").RowId, Record<number, number>>;
26
+ getters: any;
27
+ setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
28
+ forceUpdateRenderContext: () => void;
29
+ scheduleUpdateRenderContext: () => void;
74
30
  } & {
75
31
  resetColSpan: () => void;
76
32
  getCellColSpanInfo: (rowId: import("@mui/x-virtualizer/models").RowId, columnIndex: import("@mui/x-internals/types").integer) => import("@mui/x-virtualizer/models").CellColSpanInfo | undefined;
@@ -99,6 +99,8 @@ function useGridVirtualizer() {
99
99
  rightPinnedWidth,
100
100
  topPinnedHeight: headersTotalHeight,
101
101
  bottomPinnedHeight: 0,
102
+ autoHeight,
103
+ minimalContentHeight: _gridRowsUtils.minimalContentHeight,
102
104
  scrollbarSize: rootProps.scrollbarSize
103
105
  };
104
106
  const addGridDimensions = (0, _useLazyRef.default)(addGridDimensionsCreator).current;
@@ -121,13 +123,14 @@ function useGridVirtualizer() {
121
123
  const focusedVirtualCell = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusedVirtualCellSelector.gridFocusedVirtualCellSelector);
122
124
  // We need it to trigger a new render, but rowsMeta needs access to the latest value, hence we cannot pass it to the focusedVirtualCell callback in the virtualizer params
123
125
  (0, _utils.eslintUseValue)(focusedVirtualCell);
126
+ const layout = (0, _useLazyRef.default)(() => new _xVirtualizer.LayoutDataGridLegacy({
127
+ container: apiRef.current.mainElementRef,
128
+ scroller: apiRef.current.virtualScrollerRef,
129
+ scrollbarVertical: apiRef.current.virtualScrollbarVerticalRef,
130
+ scrollbarHorizontal: apiRef.current.virtualScrollbarHorizontalRef
131
+ })).current;
124
132
  const virtualizer = (0, _xVirtualizer.useVirtualizer)({
125
- refs: {
126
- container: apiRef.current.mainElementRef,
127
- scroller: apiRef.current.virtualScrollerRef,
128
- scrollbarVertical: apiRef.current.virtualScrollbarVerticalRef,
129
- scrollbarHorizontal: apiRef.current.virtualScrollbarHorizontalRef
130
- },
133
+ layout,
131
134
  dimensions: dimensionsParams,
132
135
  virtualization: {
133
136
  isRtl,
@@ -156,10 +159,8 @@ function useGridVirtualizer() {
156
159
  columns: visibleColumns,
157
160
  pinnedRows,
158
161
  pinnedColumns,
159
- autoHeight,
160
162
  disableHorizontalScroll: listView,
161
163
  disableVerticalScroll: overlayState.overlayType === 'noColumnsOverlay' || overlayState.loadingOverlayVariant === 'skeleton',
162
- minimalContentHeight: _gridRowsUtils.minimalContentHeight,
163
164
  getRowHeight: React.useMemo(() => {
164
165
  if (!getRowHeight) {
165
166
  return undefined;
@@ -149,15 +149,24 @@ function extractColumnWidths(apiRef, options, columns) {
149
149
  if (options.includeHeaders) {
150
150
  const header = (0, _domUtils.findGridHeader)(apiRef.current, column.field);
151
151
  if (header) {
152
- const title = header.querySelector(`.${_gridClasses.gridClasses.columnHeaderTitle}`);
153
- const content = header.querySelector(`.${_gridClasses.gridClasses.columnHeaderTitleContainerContent}`);
154
- const iconContainer = header.querySelector(`.${_gridClasses.gridClasses.iconButtonContainer}`);
152
+ const titleContainer = header.querySelector(`.${_gridClasses.gridClasses.columnHeaderTitleContainer}`);
153
+ const children = Array.from(titleContainer.children);
155
154
  const menuContainer = header.querySelector(`.${_gridClasses.gridClasses.menuIcon}`);
156
- const element = title ?? content;
157
- const style = window.getComputedStyle(header, null);
158
- const paddingWidth = parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10);
159
- const contentWidth = element.scrollWidth + 1;
160
- const width = contentWidth + paddingWidth + (iconContainer?.clientWidth ?? 0) + (menuContainer?.clientWidth ?? 0);
155
+ const titleContainerStyle = window.getComputedStyle(titleContainer, null);
156
+ const gap = parseInt(titleContainerStyle.gap, 10) || 0;
157
+ const headerStyle = window.getComputedStyle(header, null);
158
+ const paddingWidth = parseInt(headerStyle.paddingLeft, 10) + parseInt(headerStyle.paddingRight, 10);
159
+ let totalChildren = 0;
160
+ let childrenWidth = 0;
161
+ for (let i = 0; i < children.length; i += 1) {
162
+ const child = children[i];
163
+ if (child.clientWidth > 0) {
164
+ totalChildren += 1;
165
+ childrenWidth += child.scrollWidth;
166
+ }
167
+ }
168
+ childrenWidth += 1;
169
+ const width = childrenWidth + gap * (totalChildren - 1) + paddingWidth + (menuContainer?.clientWidth ?? 0);
161
170
  filteredWidths.push(width);
162
171
  }
163
172
  }
@@ -122,7 +122,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
122
122
  params: fetchParams,
123
123
  cause: originalError
124
124
  }));
125
- } else if (process.env.NODE_ENV !== 'production') {
125
+ } else {
126
126
  (0, _warning.warnOnce)(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
127
127
  }
128
128
  }
@@ -177,7 +177,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
177
177
  params,
178
178
  cause: errorThrown
179
179
  }));
180
- } else if (process.env.NODE_ENV !== 'production') {
180
+ } else {
181
181
  (0, _warning.warnOnce)(['MUI X: A call to `dataSource.updateRow()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
182
182
  }
183
183
  throw errorThrown; // Let the caller handle the error further
@@ -47,7 +47,9 @@ const EMPTY_DIMENSIONS = {
47
47
  rightPinnedWidth: 0,
48
48
  headersTotalHeight: 0,
49
49
  topContainerHeight: 0,
50
- bottomContainerHeight: 0
50
+ bottomContainerHeight: 0,
51
+ autoHeight: false,
52
+ minimalContentHeight: undefined
51
53
  };
52
54
  const dimensionsStateInitializer = (state, props, apiRef) => {
53
55
  const dimensions = EMPTY_DIMENSIONS;
@@ -371,7 +371,7 @@ const useGridCellEditing = (apiRef, props) => {
371
371
  });
372
372
  if (onProcessRowUpdateError) {
373
373
  onProcessRowUpdateError(errorThrown);
374
- } else if (process.env.NODE_ENV !== 'production') {
374
+ } else {
375
375
  (0, _warning.warnOnce)(['MUI X: A call to `processRowUpdate()` threw an error which was not handled because `onProcessRowUpdateError()` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError()` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/persistence/.'], 'error');
376
376
  }
377
377
  };
@@ -455,7 +455,7 @@ const useGridRowEditing = (apiRef, props) => {
455
455
  }
456
456
  if (onProcessRowUpdateError) {
457
457
  onProcessRowUpdateError(errorThrown);
458
- } else if (process.env.NODE_ENV !== 'production') {
458
+ } else {
459
459
  (0, _warning.warnOnce)(['MUI X: A call to `processRowUpdate()` threw an error which was not handled because `onProcessRowUpdateError()` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError()` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/persistence/.'], 'error');
460
460
  }
461
461
  };
@@ -84,10 +84,8 @@ const serializeRow = ({
84
84
  });
85
85
  columns.forEach(column => {
86
86
  const cellParams = getCellParams(id, column.field);
87
- if (process.env.NODE_ENV !== 'production') {
88
- if (String(cellParams.formattedValue) === '[object Object]') {
89
- (0, _warning.warnOnce)(['MUI X: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
90
- }
87
+ if (String(cellParams.formattedValue) === '[object Object]') {
88
+ (0, _warning.warnOnce)(['MUI X: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
91
89
  }
92
90
  row.addValue(serializeCellValue(cellParams, {
93
91
  ignoreValueFormatter,
@@ -49,24 +49,18 @@ const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiRef) =>
49
49
  const hasSeveralItems = model.items.length > 1;
50
50
  let items;
51
51
  if (hasSeveralItems && disableMultipleColumnsFiltering) {
52
- if (process.env.NODE_ENV !== 'production') {
53
- (0, _warning.warnOnce)(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
54
- }
52
+ (0, _warning.warnOnce)(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
55
53
  items = [model.items[0]];
56
54
  } else {
57
55
  items = model.items;
58
56
  }
59
57
  const hasItemsWithoutIds = hasSeveralItems && items.some(item => item.id == null);
60
58
  const hasItemWithoutOperator = items.some(item => item.operator == null);
61
- if (process.env.NODE_ENV !== 'production') {
62
- if (hasItemsWithoutIds) {
63
- (0, _warning.warnOnce)('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.', 'error');
64
- }
59
+ if (hasItemsWithoutIds) {
60
+ (0, _warning.warnOnce)('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.', 'error');
65
61
  }
66
- if (process.env.NODE_ENV !== 'production') {
67
- if (hasItemWithoutOperator) {
68
- (0, _warning.warnOnce)('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.', 'error');
69
- }
62
+ if (hasItemWithoutOperator) {
63
+ (0, _warning.warnOnce)('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.', 'error');
70
64
  }
71
65
  if (hasItemWithoutOperator || hasItemsWithoutIds) {
72
66
  return (0, _extends2.default)({}, model, {
@@ -1,4 +1,4 @@
1
1
  export type { GridFilterState, GridFilterInitialState } from "./gridFilterState.js";
2
2
  export { getDefaultGridFilterModel } from "./gridFilterState.js";
3
- export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector } from "./gridFilterSelector.js";
3
+ export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector, gridExpandedSortedRowIndexLookupSelector } from "./gridFilterSelector.js";
4
4
  export type { GridFilterActiveItemsLookup } from "./gridFilterSelector.js";
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "gridExpandedSortedRowIdsSelector", {
27
27
  return _gridFilterSelector.gridExpandedSortedRowIdsSelector;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "gridExpandedSortedRowIndexLookupSelector", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _gridFilterSelector.gridExpandedSortedRowIndexLookupSelector;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "gridFilterActiveItemsLookupSelector", {
31
37
  enumerable: true,
32
38
  get: function () {
@@ -1,3 +1,5 @@
1
+ import type { GridRowId } from "../../../models/gridRows.js";
2
+ import type { RowReorderDropPosition } from "../../../models/api/gridRowApi.js";
1
3
  /**
2
4
  * The row reorder state.
3
5
  */
@@ -6,4 +8,21 @@ export interface GridRowReorderState {
6
8
  * Whether a row drag operation is currently active.
7
9
  */
8
10
  isActive: boolean;
11
+ /**
12
+ * The row ID being dragged.
13
+ */
14
+ draggedRowId: GridRowId | null;
15
+ /**
16
+ * The current drop target information.
17
+ */
18
+ dropTarget?: {
19
+ /**
20
+ * The row ID where the drop indicator should be shown.
21
+ */
22
+ rowId: GridRowId;
23
+ /**
24
+ * The position of the drop indicator relative to the target row.
25
+ */
26
+ position: RowReorderDropPosition;
27
+ };
9
28
  }