@mui/x-data-grid 7.7.1 → 7.9.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.
- package/CHANGELOG.md +166 -1
- package/DataGrid/useDataGridComponent.d.ts +0 -1
- package/DataGrid/useDataGridProps.js +9 -2
- package/components/GridFooter.d.ts +1 -1
- package/components/GridLoadingOverlay.d.ts +15 -3
- package/components/GridLoadingOverlay.js +48 -4
- package/components/GridNoResultsOverlay.d.ts +1 -1
- package/components/GridNoRowsOverlay.d.ts +1 -1
- package/components/GridRow.js +2 -1
- package/components/GridRowCount.d.ts +1 -1
- package/components/GridSelectedRowCount.d.ts +1 -1
- package/components/GridSkeletonLoadingOverlay.d.ts +3 -0
- package/components/GridSkeletonLoadingOverlay.js +181 -0
- package/components/base/GridOverlays.d.ts +11 -1
- package/components/base/GridOverlays.js +25 -39
- package/components/cell/GridActionsCellItem.d.ts +3 -3
- package/components/cell/GridSkeletonCell.d.ts +13 -6
- package/components/cell/GridSkeletonCell.js +61 -19
- package/components/columnHeaders/GridColumnHeaderItem.js +3 -3
- package/components/columnHeaders/GridColumnHeaderSortIcon.d.ts +1 -0
- package/components/columnHeaders/GridColumnHeaderSortIcon.js +11 -6
- package/components/containers/GridFooterContainer.d.ts +1 -1
- package/components/containers/GridOverlay.d.ts +1 -1
- package/components/containers/GridRootStyles.d.ts +0 -1
- package/components/containers/GridRootStyles.js +19 -2
- package/components/containers/GridToolbarContainer.d.ts +1 -1
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/toolbar/GridToolbarExportContainer.d.ts +1 -1
- package/components/virtualization/GridMainContainer.d.ts +1 -1
- package/components/virtualization/GridVirtualScroller.js +7 -5
- package/components/virtualization/GridVirtualScrollerContent.d.ts +1 -1
- package/components/virtualization/GridVirtualScrollerRenderZone.d.ts +1 -1
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +14 -0
- package/constants/gridClasses.js +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +2 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +2 -2
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +2 -2
- package/hooks/core/useGridInitialization.d.ts +1 -1
- package/hooks/core/useGridLocaleText.d.ts +1 -1
- package/hooks/core/useGridLoggerFactory.d.ts +1 -1
- package/hooks/features/clipboard/useGridClipboard.d.ts +1 -1
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +1 -1
- package/hooks/features/columnResize/useGridColumnResize.d.ts +1 -1
- package/hooks/features/density/useGridDensity.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +15 -15
- package/hooks/features/editing/useGridCellEditing.d.ts +1 -1
- package/hooks/features/editing/useGridEditing.d.ts +1 -1
- package/hooks/features/editing/useGridRowEditing.d.ts +1 -1
- package/hooks/features/export/serializers/csvSerializer.d.ts +0 -1
- package/hooks/features/export/useGridCsvExport.d.ts +1 -1
- package/hooks/features/export/useGridPrintExport.d.ts +1 -1
- package/hooks/features/export/useGridPrintExport.js +9 -8
- package/hooks/features/filter/gridFilterUtils.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/focus/useGridFocus.d.ts +1 -1
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/overlays/useGridOverlays.d.ts +11 -0
- package/hooks/features/overlays/useGridOverlays.js +35 -0
- package/hooks/features/pagination/gridPaginationUtils.d.ts +1 -1
- package/hooks/features/pagination/index.d.ts +1 -1
- package/hooks/features/pagination/useGridPaginationMeta.d.ts +1 -1
- package/hooks/features/pagination/useGridPaginationModel.d.ts +2 -2
- package/hooks/features/pagination/useGridRowCount.d.ts +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rows/gridRowsInterfaces.d.ts +10 -2
- package/hooks/features/rows/gridRowsSelector.d.ts +2 -1
- package/hooks/features/rows/gridRowsSelector.js +1 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +8 -6
- package/hooks/features/rows/gridRowsUtils.js +30 -6
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +39 -21
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/scroll/useGridScroll.d.ts +1 -1
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/hooks/utils/index.d.ts +0 -1
- package/hooks/utils/index.js +0 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
- package/hooks/utils/useGridApiRef.d.ts +1 -1
- package/hooks/utils/useGridInitializeState.d.ts +1 -1
- package/hooks/utils/useGridRootProps.d.ts +1 -1
- package/hooks/utils/useGridSelector.d.ts +1 -1
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +2 -0
- package/internals/index.js +1 -0
- package/internals/utils/propValidation.js +1 -1
- package/models/api/gridApiCommon.d.ts +2 -2
- package/models/api/gridInfiniteLoaderApi.d.ts +0 -1
- package/models/api/gridRowApi.d.ts +14 -0
- package/models/gridColumnGrouping.d.ts +0 -1
- package/models/gridDataSource.d.ts +87 -0
- package/models/gridDataSource.js +1 -0
- package/models/gridRows.d.ts +10 -0
- package/models/gridSlotsComponent.d.ts +5 -0
- package/models/gridSlotsComponentsProps.d.ts +7 -2
- package/models/props/DataGridProps.d.ts +2 -0
- package/modern/DataGrid/useDataGridProps.js +9 -2
- package/modern/components/GridLoadingOverlay.js +48 -4
- package/modern/components/GridRow.js +2 -1
- package/modern/components/GridSkeletonLoadingOverlay.js +181 -0
- package/modern/components/base/GridOverlays.js +25 -39
- package/modern/components/cell/GridSkeletonCell.js +61 -19
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +3 -3
- package/modern/components/columnHeaders/GridColumnHeaderSortIcon.js +11 -6
- package/modern/components/containers/GridRootStyles.js +19 -2
- package/modern/components/virtualization/GridVirtualScroller.js +7 -5
- package/modern/constants/defaultGridSlotsComponents.js +2 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/dimensions/useGridDimensions.js +15 -15
- package/modern/hooks/features/export/useGridPrintExport.js +9 -8
- package/modern/hooks/features/overlays/useGridOverlays.js +35 -0
- package/modern/hooks/features/rows/gridRowsSelector.js +1 -0
- package/modern/hooks/features/rows/gridRowsUtils.js +30 -6
- package/modern/hooks/features/rows/useGridRows.js +39 -21
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/modern/hooks/utils/index.js +0 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/internals/utils/propValidation.js +1 -1
- package/modern/models/gridDataSource.js +1 -0
- package/modern/utils/utils.js +10 -2
- package/node/DataGrid/useDataGridProps.js +9 -2
- package/node/components/GridLoadingOverlay.js +48 -4
- package/node/components/GridRow.js +2 -1
- package/node/components/GridSkeletonLoadingOverlay.js +189 -0
- package/node/components/base/GridOverlays.js +25 -39
- package/node/components/cell/GridSkeletonCell.js +60 -18
- package/node/components/columnHeaders/GridColumnHeaderItem.js +3 -3
- package/node/components/columnHeaders/GridColumnHeaderSortIcon.js +11 -6
- package/node/components/containers/GridRootStyles.js +19 -2
- package/node/components/virtualization/GridVirtualScroller.js +6 -4
- package/node/constants/defaultGridSlotsComponents.js +1 -0
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/features/dimensions/useGridDimensions.js +15 -15
- package/node/hooks/features/export/useGridPrintExport.js +9 -8
- package/node/hooks/features/overlays/useGridOverlays.js +42 -0
- package/node/hooks/features/rows/gridRowsSelector.js +2 -1
- package/node/hooks/features/rows/gridRowsUtils.js +31 -6
- package/node/hooks/features/rows/useGridRows.js +37 -19
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/node/hooks/utils/index.js +0 -12
- package/node/index.js +1 -1
- package/node/internals/index.js +7 -0
- package/node/internals/utils/propValidation.js +1 -1
- package/node/models/gridDataSource.js +5 -0
- package/node/utils/utils.js +11 -3
- package/package.json +5 -4
- package/utils/cleanupTracking/TimerBasedCleanupTracking.d.ts +0 -1
- package/utils/domUtils.d.ts +0 -1
- package/utils/getPublicApiRef.d.ts +1 -2
- package/utils/keyboardUtils.d.ts +1 -1
- package/utils/utils.d.ts +8 -1
- package/utils/utils.js +10 -2
- package/utils/warning.d.ts +1 -1
- package/hooks/utils/useResizeObserver.d.ts +0 -2
- package/hooks/utils/useResizeObserver.js +0 -36
- package/modern/hooks/utils/useResizeObserver.js +0 -36
- package/node/hooks/utils/useResizeObserver.js +0 -44
|
@@ -60,6 +60,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
60
60
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useResizeContainer');
|
|
61
61
|
const errorShown = React.useRef(false);
|
|
62
62
|
const rootDimensionsRef = React.useRef(EMPTY_SIZE);
|
|
63
|
+
const dimensionsState = (0, _utils2.useGridSelector)(apiRef, _gridDimensionsSelectors.gridDimensionsSelector);
|
|
63
64
|
const rowsMeta = (0, _utils2.useGridSelector)(apiRef, _gridRowsMetaSelector.gridRowsMetaSelector);
|
|
64
65
|
const pinnedColumns = (0, _utils2.useGridSelector)(apiRef, _columns.gridVisiblePinnedColumnDefinitionsSelector);
|
|
65
66
|
const densityFactor = (0, _utils2.useGridSelector)(apiRef, _density.gridDensityFactorSelector);
|
|
@@ -219,26 +220,25 @@ function useGridDimensions(apiRef, props) {
|
|
|
219
220
|
}
|
|
220
221
|
}, [apiRef, savedSize, updateDimensions]);
|
|
221
222
|
const root = apiRef.current.rootElementRef.current;
|
|
222
|
-
const dimensions = apiRef.current.state.dimensions;
|
|
223
223
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
224
224
|
if (!root) {
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
227
|
const set = (k, v) => root.style.setProperty(k, v);
|
|
228
|
-
set('--DataGrid-width', `${
|
|
229
|
-
set('--DataGrid-hasScrollX', `${Number(
|
|
230
|
-
set('--DataGrid-hasScrollY', `${Number(
|
|
231
|
-
set('--DataGrid-scrollbarSize', `${
|
|
232
|
-
set('--DataGrid-rowWidth', `${
|
|
233
|
-
set('--DataGrid-columnsTotalWidth', `${
|
|
234
|
-
set('--DataGrid-leftPinnedWidth', `${
|
|
235
|
-
set('--DataGrid-rightPinnedWidth', `${
|
|
236
|
-
set('--DataGrid-headerHeight', `${
|
|
237
|
-
set('--DataGrid-headersTotalHeight', `${
|
|
238
|
-
set('--DataGrid-topContainerHeight', `${
|
|
239
|
-
set('--DataGrid-bottomContainerHeight', `${
|
|
240
|
-
set('--height', `${
|
|
241
|
-
}, [root,
|
|
228
|
+
set('--DataGrid-width', `${dimensionsState.viewportOuterSize.width}px`);
|
|
229
|
+
set('--DataGrid-hasScrollX', `${Number(dimensionsState.hasScrollX)}`);
|
|
230
|
+
set('--DataGrid-hasScrollY', `${Number(dimensionsState.hasScrollY)}`);
|
|
231
|
+
set('--DataGrid-scrollbarSize', `${dimensionsState.scrollbarSize}px`);
|
|
232
|
+
set('--DataGrid-rowWidth', `${dimensionsState.rowWidth}px`);
|
|
233
|
+
set('--DataGrid-columnsTotalWidth', `${dimensionsState.columnsTotalWidth}px`);
|
|
234
|
+
set('--DataGrid-leftPinnedWidth', `${dimensionsState.leftPinnedWidth}px`);
|
|
235
|
+
set('--DataGrid-rightPinnedWidth', `${dimensionsState.rightPinnedWidth}px`);
|
|
236
|
+
set('--DataGrid-headerHeight', `${dimensionsState.headerHeight}px`);
|
|
237
|
+
set('--DataGrid-headersTotalHeight', `${dimensionsState.headersTotalHeight}px`);
|
|
238
|
+
set('--DataGrid-topContainerHeight', `${dimensionsState.topContainerHeight}px`);
|
|
239
|
+
set('--DataGrid-bottomContainerHeight', `${dimensionsState.bottomContainerHeight}px`);
|
|
240
|
+
set('--height', `${dimensionsState.rowHeight}px`);
|
|
241
|
+
}, [root, dimensionsState]);
|
|
242
242
|
const isFirstSizing = React.useRef(true);
|
|
243
243
|
const handleResize = React.useCallback(size => {
|
|
244
244
|
rootDimensionsRef.current = size;
|
|
@@ -128,14 +128,15 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
128
128
|
gridClone.style.height = `${computedTotalHeight}px`;
|
|
129
129
|
// The height above does not include grid border width, so we need to exclude it
|
|
130
130
|
gridClone.style.boxSizing = 'content-box';
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
131
|
+
if (!normalizeOptions.hideFooter) {
|
|
132
|
+
// the footer is always being placed at the bottom of the page as if all rows are exported
|
|
133
|
+
// so if getRowsToExport is being used to only export a subset of rows then we need to
|
|
134
|
+
// adjust the footer position to be correctly placed at the bottom of the grid
|
|
135
|
+
const gridFooterElement = gridClone.querySelector(`.${_gridClasses.gridClasses.footerContainer}`);
|
|
136
|
+
gridFooterElement.style.position = 'absolute';
|
|
137
|
+
gridFooterElement.style.width = '100%';
|
|
138
|
+
gridFooterElement.style.top = `${computedTotalHeight - gridFooterElementHeight}px`;
|
|
139
|
+
}
|
|
139
140
|
|
|
140
141
|
// printDoc.body.appendChild(gridClone); should be enough but a clone isolation bug in Safari
|
|
141
142
|
// prevents us to do it
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useGridOverlays = void 0;
|
|
7
|
+
var _utils = require("../../utils");
|
|
8
|
+
var _useGridApiContext = require("../../utils/useGridApiContext");
|
|
9
|
+
var _useGridRootProps = require("../../utils/useGridRootProps");
|
|
10
|
+
var _filter = require("../filter");
|
|
11
|
+
var _rows = require("../rows");
|
|
12
|
+
/**
|
|
13
|
+
* Uses the grid state to determine which overlay to display.
|
|
14
|
+
* Returns the active overlay type and the active loading overlay variant.
|
|
15
|
+
*/
|
|
16
|
+
const useGridOverlays = () => {
|
|
17
|
+
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
18
|
+
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
19
|
+
const totalRowCount = (0, _utils.useGridSelector)(apiRef, _rows.gridRowCountSelector);
|
|
20
|
+
const visibleRowCount = (0, _utils.useGridSelector)(apiRef, _filter.gridExpandedRowCountSelector);
|
|
21
|
+
const noRows = totalRowCount === 0;
|
|
22
|
+
const loading = (0, _utils.useGridSelector)(apiRef, _rows.gridRowsLoadingSelector);
|
|
23
|
+
const showNoRowsOverlay = !loading && noRows;
|
|
24
|
+
const showNoResultsOverlay = !loading && totalRowCount > 0 && visibleRowCount === 0;
|
|
25
|
+
let overlayType = null;
|
|
26
|
+
let loadingOverlayVariant = null;
|
|
27
|
+
if (showNoRowsOverlay) {
|
|
28
|
+
overlayType = 'noRowsOverlay';
|
|
29
|
+
}
|
|
30
|
+
if (showNoResultsOverlay) {
|
|
31
|
+
overlayType = 'noResultsOverlay';
|
|
32
|
+
}
|
|
33
|
+
if (loading) {
|
|
34
|
+
overlayType = 'loadingOverlay';
|
|
35
|
+
loadingOverlayVariant = rootProps.slotProps?.loadingOverlay?.[noRows ? 'noRowsVariant' : 'variant'] || null;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
overlayType,
|
|
39
|
+
loadingOverlayVariant
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.useGridOverlays = useGridOverlays;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.gridTopLevelRowCountSelector = exports.gridRowsLookupSelector = exports.gridRowsLoadingSelector = exports.gridRowsDataRowIdToIdLookupSelector = exports.gridRowTreeSelector = exports.gridRowTreeDepthsSelector = exports.gridRowMaximumTreeDepthSelector = exports.gridRowGroupingNameSelector = exports.gridRowCountSelector = exports.gridPinnedRowsSelector = exports.gridPinnedRowsCountSelector = exports.gridDataRowIdsSelector = exports.gridAdditionalRowGroupsSelector = void 0;
|
|
6
|
+
exports.gridTopLevelRowCountSelector = exports.gridRowsLookupSelector = exports.gridRowsLoadingSelector = exports.gridRowsDataRowIdToIdLookupSelector = exports.gridRowTreeSelector = exports.gridRowTreeDepthsSelector = exports.gridRowMaximumTreeDepthSelector = exports.gridRowGroupsToFetchSelector = exports.gridRowGroupingNameSelector = exports.gridRowCountSelector = exports.gridPinnedRowsSelector = exports.gridPinnedRowsCountSelector = exports.gridDataRowIdsSelector = exports.gridAdditionalRowGroupsSelector = void 0;
|
|
7
7
|
var _createSelector = require("../../../utils/createSelector");
|
|
8
8
|
const gridRowsStateSelector = state => state.rows;
|
|
9
9
|
const gridRowCountSelector = exports.gridRowCountSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.totalRowCount);
|
|
@@ -14,6 +14,7 @@ const gridTopLevelRowCountSelector = exports.gridTopLevelRowCountSelector = (0,
|
|
|
14
14
|
const gridRowsLookupSelector = exports.gridRowsLookupSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.dataRowIdToModelLookup);
|
|
15
15
|
const gridRowsDataRowIdToIdLookupSelector = exports.gridRowsDataRowIdToIdLookupSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.dataRowIdToIdLookup);
|
|
16
16
|
const gridRowTreeSelector = exports.gridRowTreeSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.tree);
|
|
17
|
+
const gridRowGroupsToFetchSelector = exports.gridRowGroupsToFetchSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.groupsToFetch);
|
|
17
18
|
const gridRowGroupingNameSelector = exports.gridRowGroupingNameSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.groupingName);
|
|
18
19
|
const gridRowTreeDepthsSelector = exports.gridRowTreeDepthsSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.treeDepths);
|
|
19
20
|
const gridRowMaximumTreeDepthSelector = exports.gridRowMaximumTreeDepthSelector = (0, _createSelector.createSelectorMemoized)(gridRowsStateSelector, rows => {
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.buildRootGroup = exports.GRID_ROOT_GROUP_ID = exports.GRID_ID_AUTOGENERATED = void 0;
|
|
8
8
|
exports.calculatePinnedRowsHeight = calculatePinnedRowsHeight;
|
|
9
9
|
exports.checkGridRowIdIsValid = checkGridRowIdIsValid;
|
|
10
|
+
exports.computeRowsUpdates = computeRowsUpdates;
|
|
10
11
|
exports.createRowsInternalCache = void 0;
|
|
11
12
|
exports.getMinimalContentHeight = getMinimalContentHeight;
|
|
12
13
|
exports.updateCacheWithNewRows = exports.isAutoGeneratedRow = exports.getTreeNodeDescendants = exports.getTopLevelRowCount = exports.getRowsStateFromCache = exports.getRowIdFromRowModel = void 0;
|
|
@@ -88,7 +89,8 @@ const getRowsStateFromCache = ({
|
|
|
88
89
|
rowCountProp = 0,
|
|
89
90
|
loadingProp,
|
|
90
91
|
previousTree,
|
|
91
|
-
previousTreeDepths
|
|
92
|
+
previousTreeDepths,
|
|
93
|
+
previousGroupsToFetch
|
|
92
94
|
}) => {
|
|
93
95
|
const cache = apiRef.current.caches.rows;
|
|
94
96
|
|
|
@@ -97,13 +99,15 @@ const getRowsStateFromCache = ({
|
|
|
97
99
|
tree: unProcessedTree,
|
|
98
100
|
treeDepths: unProcessedTreeDepths,
|
|
99
101
|
dataRowIds: unProcessedDataRowIds,
|
|
100
|
-
groupingName
|
|
102
|
+
groupingName,
|
|
103
|
+
groupsToFetch = []
|
|
101
104
|
} = apiRef.current.applyStrategyProcessor('rowTreeCreation', {
|
|
102
105
|
previousTree,
|
|
103
106
|
previousTreeDepths,
|
|
104
107
|
updates: cache.updates,
|
|
105
108
|
dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
|
|
106
|
-
dataRowIdToModelLookup: cache.dataRowIdToModelLookup
|
|
109
|
+
dataRowIdToModelLookup: cache.dataRowIdToModelLookup,
|
|
110
|
+
previousGroupsToFetch
|
|
107
111
|
});
|
|
108
112
|
|
|
109
113
|
// 2. Apply the "hydrateRows" pipe-processing.
|
|
@@ -132,7 +136,8 @@ const getRowsStateFromCache = ({
|
|
|
132
136
|
rowCountProp
|
|
133
137
|
}),
|
|
134
138
|
groupingName,
|
|
135
|
-
loading: loadingProp
|
|
139
|
+
loading: loadingProp,
|
|
140
|
+
groupsToFetch
|
|
136
141
|
});
|
|
137
142
|
};
|
|
138
143
|
exports.getRowsStateFromCache = getRowsStateFromCache;
|
|
@@ -163,7 +168,8 @@ exports.getTreeNodeDescendants = getTreeNodeDescendants;
|
|
|
163
168
|
const updateCacheWithNewRows = ({
|
|
164
169
|
previousCache,
|
|
165
170
|
getRowId,
|
|
166
|
-
updates
|
|
171
|
+
updates,
|
|
172
|
+
groupKeys
|
|
167
173
|
}) => {
|
|
168
174
|
if (previousCache.updates.type === 'full') {
|
|
169
175
|
throw new Error('MUI X: Unable to prepare a partial update if a full update is not applied yet.');
|
|
@@ -187,7 +193,8 @@ const updateCacheWithNewRows = ({
|
|
|
187
193
|
modify: [...(previousCache.updates.actions.modify ?? [])],
|
|
188
194
|
remove: [...(previousCache.updates.actions.remove ?? [])]
|
|
189
195
|
},
|
|
190
|
-
idToActionLookup: (0, _extends2.default)({}, previousCache.updates.idToActionLookup)
|
|
196
|
+
idToActionLookup: (0, _extends2.default)({}, previousCache.updates.idToActionLookup),
|
|
197
|
+
groupKeys
|
|
191
198
|
};
|
|
192
199
|
const dataRowIdToModelLookup = (0, _extends2.default)({}, previousCache.dataRowIdToModelLookup);
|
|
193
200
|
const dataRowIdToIdLookup = (0, _extends2.default)({}, previousCache.dataRowIdToIdLookup);
|
|
@@ -301,4 +308,22 @@ function calculatePinnedRowsHeight(apiRef) {
|
|
|
301
308
|
function getMinimalContentHeight(apiRef) {
|
|
302
309
|
const dimensions = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state);
|
|
303
310
|
return `var(--DataGrid-overlayHeight, ${2 * dimensions.rowHeight}px)`;
|
|
311
|
+
}
|
|
312
|
+
function computeRowsUpdates(apiRef, updates, getRowId) {
|
|
313
|
+
const nonPinnedRowsUpdates = [];
|
|
314
|
+
updates.forEach(update => {
|
|
315
|
+
const id = getRowIdFromRowModel(update, getRowId, 'A row was provided without id when calling updateRows():');
|
|
316
|
+
const rowNode = apiRef.current.getRowNode(id);
|
|
317
|
+
if (rowNode?.type === 'pinnedRow') {
|
|
318
|
+
// @ts-ignore because otherwise `release:build` doesn't work
|
|
319
|
+
const pinnedRowsCache = apiRef.current.caches.pinnedRows;
|
|
320
|
+
const prevModel = pinnedRowsCache.idLookup[id];
|
|
321
|
+
if (prevModel) {
|
|
322
|
+
pinnedRowsCache.idLookup[id] = (0, _extends2.default)({}, prevModel, update);
|
|
323
|
+
}
|
|
324
|
+
} else {
|
|
325
|
+
nonPinnedRowsUpdates.push(update);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
return nonPinnedRowsUpdates;
|
|
304
329
|
}
|
|
@@ -20,8 +20,9 @@ var _pipeProcessing = require("../../core/pipeProcessing");
|
|
|
20
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
22
|
const rowsStateInitializer = (state, props, apiRef) => {
|
|
23
|
+
const isDataSourceAvailable = !!props.unstable_dataSource;
|
|
23
24
|
apiRef.current.caches.rows = (0, _gridRowsUtils.createRowsInternalCache)({
|
|
24
|
-
rows: props.rows,
|
|
25
|
+
rows: isDataSourceAvailable ? [] : props.rows,
|
|
25
26
|
getRowId: props.getRowId,
|
|
26
27
|
loading: props.loading,
|
|
27
28
|
rowCount: props.rowCount
|
|
@@ -30,7 +31,7 @@ const rowsStateInitializer = (state, props, apiRef) => {
|
|
|
30
31
|
rows: (0, _gridRowsUtils.getRowsStateFromCache)({
|
|
31
32
|
apiRef,
|
|
32
33
|
rowCountProp: props.rowCount,
|
|
33
|
-
loadingProp: props.loading,
|
|
34
|
+
loadingProp: isDataSourceAvailable ? true : props.loading,
|
|
34
35
|
previousTree: null,
|
|
35
36
|
previousTreeDepths: null
|
|
36
37
|
})
|
|
@@ -92,7 +93,8 @@ const useGridRows = (apiRef, props) => {
|
|
|
92
93
|
rowCountProp: props.rowCount,
|
|
93
94
|
loadingProp: props.loading,
|
|
94
95
|
previousTree: (0, _gridRowsSelector.gridRowTreeSelector)(apiRef),
|
|
95
|
-
previousTreeDepths: (0, _gridRowsSelector.gridRowTreeDepthsSelector)(apiRef)
|
|
96
|
+
previousTreeDepths: (0, _gridRowsSelector.gridRowTreeDepthsSelector)(apiRef),
|
|
97
|
+
previousGroupsToFetch: (0, _gridRowsSelector.gridRowGroupsToFetchSelector)(apiRef)
|
|
96
98
|
})
|
|
97
99
|
}));
|
|
98
100
|
apiRef.current.publishEvent('rowsSet');
|
|
@@ -134,21 +136,7 @@ const useGridRows = (apiRef, props) => {
|
|
|
134
136
|
if (props.signature === _useGridApiEventHandler.GridSignature.DataGrid && updates.length > 1) {
|
|
135
137
|
throw new Error(['MUI X: You cannot update several rows at once in `apiRef.current.updateRows` on the DataGrid.', 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n'));
|
|
136
138
|
}
|
|
137
|
-
const nonPinnedRowsUpdates =
|
|
138
|
-
updates.forEach(update => {
|
|
139
|
-
const id = (0, _gridRowsUtils.getRowIdFromRowModel)(update, props.getRowId, 'A row was provided without id when calling updateRows():');
|
|
140
|
-
const rowNode = apiRef.current.getRowNode(id);
|
|
141
|
-
if (rowNode?.type === 'pinnedRow') {
|
|
142
|
-
// @ts-ignore because otherwise `release:build` doesn't work
|
|
143
|
-
const pinnedRowsCache = apiRef.current.caches.pinnedRows;
|
|
144
|
-
const prevModel = pinnedRowsCache.idLookup[id];
|
|
145
|
-
if (prevModel) {
|
|
146
|
-
pinnedRowsCache.idLookup[id] = (0, _extends2.default)({}, prevModel, update);
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
nonPinnedRowsUpdates.push(update);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
139
|
+
const nonPinnedRowsUpdates = (0, _gridRowsUtils.computeRowsUpdates)(apiRef, updates, props.getRowId);
|
|
152
140
|
const cache = (0, _gridRowsUtils.updateCacheWithNewRows)({
|
|
153
141
|
updates: nonPinnedRowsUpdates,
|
|
154
142
|
getRowId: props.getRowId,
|
|
@@ -159,6 +147,31 @@ const useGridRows = (apiRef, props) => {
|
|
|
159
147
|
throttle: true
|
|
160
148
|
});
|
|
161
149
|
}, [props.signature, props.getRowId, throttledRowsChange, apiRef]);
|
|
150
|
+
const updateServerRows = React.useCallback((updates, groupKeys) => {
|
|
151
|
+
const nonPinnedRowsUpdates = (0, _gridRowsUtils.computeRowsUpdates)(apiRef, updates, props.getRowId);
|
|
152
|
+
const cache = (0, _gridRowsUtils.updateCacheWithNewRows)({
|
|
153
|
+
updates: nonPinnedRowsUpdates,
|
|
154
|
+
getRowId: props.getRowId,
|
|
155
|
+
previousCache: apiRef.current.caches.rows,
|
|
156
|
+
groupKeys: groupKeys ?? []
|
|
157
|
+
});
|
|
158
|
+
throttledRowsChange({
|
|
159
|
+
cache,
|
|
160
|
+
throttle: false
|
|
161
|
+
});
|
|
162
|
+
}, [props.getRowId, throttledRowsChange, apiRef]);
|
|
163
|
+
const setLoading = React.useCallback(loading => {
|
|
164
|
+
if (loading === props.loading) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
logger.debug(`Setting loading to ${loading}`);
|
|
168
|
+
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
169
|
+
rows: (0, _extends2.default)({}, state.rows, {
|
|
170
|
+
loading
|
|
171
|
+
})
|
|
172
|
+
}));
|
|
173
|
+
apiRef.current.caches.rows.loadingPropBeforePartialUpdates = loading;
|
|
174
|
+
}, [props.loading, apiRef, logger]);
|
|
162
175
|
const getRowModels = React.useCallback(() => {
|
|
163
176
|
const dataRows = (0, _gridRowsSelector.gridDataRowIdsSelector)(apiRef);
|
|
164
177
|
const idRowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
@@ -313,6 +326,7 @@ const useGridRows = (apiRef, props) => {
|
|
|
313
326
|
}, [apiRef, props.signature, props.getRowId]);
|
|
314
327
|
const rowApi = {
|
|
315
328
|
getRow,
|
|
329
|
+
setLoading,
|
|
316
330
|
getRowId,
|
|
317
331
|
getRowModels,
|
|
318
332
|
getRowsCount,
|
|
@@ -328,6 +342,9 @@ const useGridRows = (apiRef, props) => {
|
|
|
328
342
|
setRowChildrenExpansion,
|
|
329
343
|
getRowGroupChildren
|
|
330
344
|
};
|
|
345
|
+
const rowProPrivateApi = {
|
|
346
|
+
updateServerRows
|
|
347
|
+
};
|
|
331
348
|
|
|
332
349
|
/**
|
|
333
350
|
* EVENTS
|
|
@@ -402,6 +419,7 @@ const useGridRows = (apiRef, props) => {
|
|
|
402
419
|
(0, _pipeProcessing.useGridRegisterPipeApplier)(apiRef, 'hydrateRows', applyHydrateRowsProcessor);
|
|
403
420
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, rowApi, 'public');
|
|
404
421
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, rowProApi, props.signature === _useGridApiEventHandler.GridSignature.DataGrid ? 'private' : 'public');
|
|
422
|
+
(0, _useGridApiMethod.useGridApiMethod)(apiRef, rowProPrivateApi, 'private');
|
|
405
423
|
|
|
406
424
|
// The effect do not track any value defined synchronously during the 1st render by hooks called after `useGridRows`
|
|
407
425
|
// As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one
|
|
@@ -446,7 +464,7 @@ const useGridRows = (apiRef, props) => {
|
|
|
446
464
|
return;
|
|
447
465
|
}
|
|
448
466
|
}
|
|
449
|
-
logger.debug(`Updating all rows, new length ${props.rows
|
|
467
|
+
logger.debug(`Updating all rows, new length ${props.rows?.length}`);
|
|
450
468
|
throttledRowsChange({
|
|
451
469
|
cache: (0, _gridRowsUtils.createRowsInternalCache)({
|
|
452
470
|
rows: props.rows,
|
|
@@ -14,11 +14,11 @@ var ReactDOM = _interopRequireWildcard(require("react-dom"));
|
|
|
14
14
|
var _utils = require("@mui/utils");
|
|
15
15
|
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
16
16
|
var _useTimeout = _interopRequireDefault(require("@mui/utils/useTimeout"));
|
|
17
|
+
var _useResizeObserver = require("@mui/x-internals/useResizeObserver");
|
|
17
18
|
var _styles = require("@mui/material/styles");
|
|
18
19
|
var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
|
|
19
20
|
var _useGridRootProps = require("../../utils/useGridRootProps");
|
|
20
21
|
var _useGridSelector = require("../../utils/useGridSelector");
|
|
21
|
-
var _useResizeObserver = require("../../utils/useResizeObserver");
|
|
22
22
|
var _useRunOnce = require("../../utils/useRunOnce");
|
|
23
23
|
var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
24
24
|
var _gridDimensionsSelectors = require("../dimensions/gridDimensionsSelectors");
|
|
@@ -85,18 +85,6 @@ Object.keys(_useOnMount).forEach(function (key) {
|
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
|
-
var _useResizeObserver = require("./useResizeObserver");
|
|
89
|
-
Object.keys(_useResizeObserver).forEach(function (key) {
|
|
90
|
-
if (key === "default" || key === "__esModule") return;
|
|
91
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
92
|
-
if (key in exports && exports[key] === _useResizeObserver[key]) return;
|
|
93
|
-
Object.defineProperty(exports, key, {
|
|
94
|
-
enumerable: true,
|
|
95
|
-
get: function () {
|
|
96
|
-
return _useResizeObserver[key];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
88
|
var _useRunOnce = require("./useRunOnce");
|
|
101
89
|
Object.keys(_useRunOnce).forEach(function (key) {
|
|
102
90
|
if (key === "default" || key === "__esModule") return;
|
package/node/index.js
CHANGED
package/node/internals/index.js
CHANGED
|
@@ -57,6 +57,7 @@ var _exportNames = {
|
|
|
57
57
|
useGridParamsApi: true,
|
|
58
58
|
gridAdditionalRowGroupsSelector: true,
|
|
59
59
|
gridPinnedRowsSelector: true,
|
|
60
|
+
gridRowGroupsToFetchSelector: true,
|
|
60
61
|
headerFilteringStateInitializer: true,
|
|
61
62
|
useGridHeaderFiltering: true,
|
|
62
63
|
useGridRowSelection: true,
|
|
@@ -313,6 +314,12 @@ Object.defineProperty(exports, "gridPinnedRowsSelector", {
|
|
|
313
314
|
return _gridRowsSelector.gridPinnedRowsSelector;
|
|
314
315
|
}
|
|
315
316
|
});
|
|
317
|
+
Object.defineProperty(exports, "gridRowGroupsToFetchSelector", {
|
|
318
|
+
enumerable: true,
|
|
319
|
+
get: function () {
|
|
320
|
+
return _gridRowsSelector.gridRowGroupsToFetchSelector;
|
|
321
|
+
}
|
|
322
|
+
});
|
|
316
323
|
Object.defineProperty(exports, "headerFilteringStateInitializer", {
|
|
317
324
|
enumerable: true,
|
|
318
325
|
get: function () {
|
|
@@ -8,7 +8,7 @@ exports.propValidatorsDataGrid = void 0;
|
|
|
8
8
|
exports.validateProps = validateProps;
|
|
9
9
|
var _utils = require("../../utils/utils");
|
|
10
10
|
var _useGridApiEventHandler = require("../../hooks/utils/useGridApiEventHandler");
|
|
11
|
-
const propValidatorsDataGrid = exports.propValidatorsDataGrid = [props => props.autoPageSize && props.autoHeight && ['MUI X: `<DataGrid autoPageSize={true} autoHeight={true} />` are not valid props.', 'You cannot use both the `autoPageSize` and `autoHeight` props at the same time because `autoHeight` scales the height of the Data Grid according to the `pageSize`.', '', 'Please remove one of these two props.'].join('\n') || undefined, props => props.paginationMode === 'client' && props.paginationMeta != null && ['MUI X: Usage of the `paginationMeta` prop with client-side pagination (`paginationMode="client"`) has no effect.', '`paginationMeta` is only meant to be used with `paginationMode="server"`.'].join('\n') || undefined, props => props.signature === _useGridApiEventHandler.GridSignature.DataGrid && props.paginationMode === 'client' && (0, _utils.isNumber)(props.rowCount) && ['MUI X: Usage of the `rowCount` prop with client side pagination (`paginationMode="client"`) has no effect.', '`rowCount` is only meant to be used with `paginationMode="server"`.'].join('\n') || undefined, props => props.paginationMode === 'server' && props.rowCount == null && ["MUI X: The `rowCount` prop must be passed using `paginationMode='server'`", 'For more detail, see http://mui.com/components/data-grid/pagination/#index-based-pagination'].join('\n') || undefined];
|
|
11
|
+
const propValidatorsDataGrid = exports.propValidatorsDataGrid = [props => props.autoPageSize && props.autoHeight && ['MUI X: `<DataGrid autoPageSize={true} autoHeight={true} />` are not valid props.', 'You cannot use both the `autoPageSize` and `autoHeight` props at the same time because `autoHeight` scales the height of the Data Grid according to the `pageSize`.', '', 'Please remove one of these two props.'].join('\n') || undefined, props => props.paginationMode === 'client' && props.paginationMeta != null && ['MUI X: Usage of the `paginationMeta` prop with client-side pagination (`paginationMode="client"`) has no effect.', '`paginationMeta` is only meant to be used with `paginationMode="server"`.'].join('\n') || undefined, props => props.signature === _useGridApiEventHandler.GridSignature.DataGrid && props.paginationMode === 'client' && (0, _utils.isNumber)(props.rowCount) && ['MUI X: Usage of the `rowCount` prop with client side pagination (`paginationMode="client"`) has no effect.', '`rowCount` is only meant to be used with `paginationMode="server"`.'].join('\n') || undefined, props => props.paginationMode === 'server' && props.rowCount == null && !props.unstable_dataSource && ["MUI X: The `rowCount` prop must be passed using `paginationMode='server'`", 'For more detail, see http://mui.com/components/data-grid/pagination/#index-based-pagination'].join('\n') || undefined];
|
|
12
12
|
const warnedOnceCache = new Set();
|
|
13
13
|
function warnOnce(message) {
|
|
14
14
|
if (!warnedOnceCache.has(message)) {
|
package/node/utils/utils.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.clamp = void 0;
|
|
7
|
+
exports.createRandomNumberGenerator = createRandomNumberGenerator;
|
|
7
8
|
exports.deepClone = deepClone;
|
|
8
9
|
exports.escapeRegExp = escapeRegExp;
|
|
9
10
|
exports.eslintUseValue = eslintUseValue;
|
|
@@ -12,7 +13,6 @@ exports.isFunction = isFunction;
|
|
|
12
13
|
exports.isNumber = isNumber;
|
|
13
14
|
exports.isObject = isObject;
|
|
14
15
|
exports.localStorageAvailable = localStorageAvailable;
|
|
15
|
-
exports.randomNumberBetween = randomNumberBetween;
|
|
16
16
|
exports.range = range;
|
|
17
17
|
function isNumber(value) {
|
|
18
18
|
return typeof value === 'number' && !Number.isNaN(value);
|
|
@@ -189,9 +189,17 @@ function mulberry32(a) {
|
|
|
189
189
|
/* eslint-enable */
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Create a random number generator from a seed. The seed
|
|
195
|
+
* ensures that the random number generator produces the
|
|
196
|
+
* same sequence of 'random' numbers on every render. It
|
|
197
|
+
* returns a function that generates a random number between
|
|
198
|
+
* a specified min and max.
|
|
199
|
+
*/
|
|
200
|
+
function createRandomNumberGenerator(seed) {
|
|
193
201
|
const random = mulberry32(seed);
|
|
194
|
-
return () => min + (max - min) * random();
|
|
202
|
+
return (min, max) => min + (max - min) * random();
|
|
195
203
|
}
|
|
196
204
|
function deepClone(obj) {
|
|
197
205
|
if (typeof structuredClone === 'function') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.9.0",
|
|
4
4
|
"description": "The Community plan edition of the Data Grid components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -38,11 +38,12 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@babel/runtime": "^7.24.7",
|
|
41
|
-
"@mui/system": "^5.
|
|
42
|
-
"@mui/utils": "^5.
|
|
41
|
+
"@mui/system": "^5.16.0",
|
|
42
|
+
"@mui/utils": "^5.16.0",
|
|
43
43
|
"clsx": "^2.1.1",
|
|
44
44
|
"prop-types": "^15.8.1",
|
|
45
|
-
"reselect": "^4.1.8"
|
|
45
|
+
"reselect": "^4.1.8",
|
|
46
|
+
"@mui/x-internals": "7.9.0"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"@mui/material": "^5.15.14",
|
package/utils/domUtils.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { GridPrivateApiCommunity } from '../models/api/gridApiCommunity';
|
|
3
|
-
export declare function getPublicApiRef<PrivateApi extends GridPrivateApiCommunity>(apiRef: React.MutableRefObject<PrivateApi>):
|
|
2
|
+
export declare function getPublicApiRef<PrivateApi extends GridPrivateApiCommunity>(apiRef: React.MutableRefObject<PrivateApi>): React.MutableRefObject<ReturnType<PrivateApi["getPublicApi"]>>;
|
package/utils/keyboardUtils.d.ts
CHANGED
|
@@ -17,5 +17,5 @@ export declare const isCellExitEditModeKeys: (key: string) => boolean;
|
|
|
17
17
|
export declare const isCellEditCommitKeys: (key: string) => boolean;
|
|
18
18
|
export declare const isNavigationKey: (key: string) => boolean;
|
|
19
19
|
export declare const isKeyboardEvent: (event: any) => event is React.KeyboardEvent<HTMLElement>;
|
|
20
|
-
export declare const isHideMenuKey: (key: React.KeyboardEvent[
|
|
20
|
+
export declare const isHideMenuKey: (key: React.KeyboardEvent["key"]) => boolean;
|
|
21
21
|
export declare function isPasteShortcut(event: React.KeyboardEvent): boolean;
|
package/utils/utils.d.ts
CHANGED
|
@@ -39,7 +39,14 @@ export declare function range(from: number, to: number): number[];
|
|
|
39
39
|
* We only type the public interface to avoid dozens of `as` in the function.
|
|
40
40
|
*/
|
|
41
41
|
export declare function isDeepEqual<T>(actual: any, expected: T): actual is T;
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Create a random number generator from a seed. The seed
|
|
44
|
+
* ensures that the random number generator produces the
|
|
45
|
+
* same sequence of 'random' numbers on every render. It
|
|
46
|
+
* returns a function that generates a random number between
|
|
47
|
+
* a specified min and max.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createRandomNumberGenerator(seed: number): (min: number, max: number) => number;
|
|
43
50
|
export declare function deepClone(obj: Record<string, any>): any;
|
|
44
51
|
/**
|
|
45
52
|
* Mark a value as used so eslint doesn't complain. Use this instead
|
package/utils/utils.js
CHANGED
|
@@ -172,9 +172,17 @@ function mulberry32(a) {
|
|
|
172
172
|
/* eslint-enable */
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Create a random number generator from a seed. The seed
|
|
178
|
+
* ensures that the random number generator produces the
|
|
179
|
+
* same sequence of 'random' numbers on every render. It
|
|
180
|
+
* returns a function that generates a random number between
|
|
181
|
+
* a specified min and max.
|
|
182
|
+
*/
|
|
183
|
+
export function createRandomNumberGenerator(seed) {
|
|
176
184
|
const random = mulberry32(seed);
|
|
177
|
-
return () => min + (max - min) * random();
|
|
185
|
+
return (min, max) => min + (max - min) * random();
|
|
178
186
|
}
|
|
179
187
|
export function deepClone(obj) {
|
|
180
188
|
if (typeof structuredClone === 'function') {
|
package/utils/warning.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const buildWarning: (message: string | string[], gravity?:
|
|
1
|
+
export declare const buildWarning: (message: string | string[], gravity?: "warning" | "error") => () => void;
|
|
2
2
|
export declare const wrapWithWarningOnCall: <F extends Function>(method: F, message: string | string[]) => F | ((...args: any[]) => any);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
3
|
-
const isDevEnvironment = process.env.NODE_ENV === 'development';
|
|
4
|
-
const noop = () => {};
|
|
5
|
-
export function useResizeObserver(ref, fn, enabled) {
|
|
6
|
-
const fnRef = React.useRef(null);
|
|
7
|
-
fnRef.current = fn;
|
|
8
|
-
useEnhancedEffect(() => {
|
|
9
|
-
if (enabled === false || typeof ResizeObserver === 'undefined') {
|
|
10
|
-
return noop;
|
|
11
|
-
}
|
|
12
|
-
let frameID = 0;
|
|
13
|
-
const target = ref.current;
|
|
14
|
-
const observer = new ResizeObserver(entries => {
|
|
15
|
-
// See https://github.com/mui/mui-x/issues/8733
|
|
16
|
-
// In dev, we avoid the React warning by moving the task to the next frame.
|
|
17
|
-
// In prod, we want the task to run in the same frame as to avoid tear.
|
|
18
|
-
if (isDevEnvironment) {
|
|
19
|
-
frameID = requestAnimationFrame(() => {
|
|
20
|
-
fnRef.current(entries);
|
|
21
|
-
});
|
|
22
|
-
} else {
|
|
23
|
-
fnRef.current(entries);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
if (target) {
|
|
27
|
-
observer.observe(target);
|
|
28
|
-
}
|
|
29
|
-
return () => {
|
|
30
|
-
if (frameID) {
|
|
31
|
-
cancelAnimationFrame(frameID);
|
|
32
|
-
}
|
|
33
|
-
observer.disconnect();
|
|
34
|
-
};
|
|
35
|
-
}, [ref, enabled]);
|
|
36
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
3
|
-
const isDevEnvironment = process.env.NODE_ENV === 'development';
|
|
4
|
-
const noop = () => {};
|
|
5
|
-
export function useResizeObserver(ref, fn, enabled) {
|
|
6
|
-
const fnRef = React.useRef(null);
|
|
7
|
-
fnRef.current = fn;
|
|
8
|
-
useEnhancedEffect(() => {
|
|
9
|
-
if (enabled === false || typeof ResizeObserver === 'undefined') {
|
|
10
|
-
return noop;
|
|
11
|
-
}
|
|
12
|
-
let frameID = 0;
|
|
13
|
-
const target = ref.current;
|
|
14
|
-
const observer = new ResizeObserver(entries => {
|
|
15
|
-
// See https://github.com/mui/mui-x/issues/8733
|
|
16
|
-
// In dev, we avoid the React warning by moving the task to the next frame.
|
|
17
|
-
// In prod, we want the task to run in the same frame as to avoid tear.
|
|
18
|
-
if (isDevEnvironment) {
|
|
19
|
-
frameID = requestAnimationFrame(() => {
|
|
20
|
-
fnRef.current(entries);
|
|
21
|
-
});
|
|
22
|
-
} else {
|
|
23
|
-
fnRef.current(entries);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
if (target) {
|
|
27
|
-
observer.observe(target);
|
|
28
|
-
}
|
|
29
|
-
return () => {
|
|
30
|
-
if (frameID) {
|
|
31
|
-
cancelAnimationFrame(frameID);
|
|
32
|
-
}
|
|
33
|
-
observer.disconnect();
|
|
34
|
-
};
|
|
35
|
-
}, [ref, enabled]);
|
|
36
|
-
}
|