@mui/x-data-grid 7.7.0 → 7.8.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 +181 -0
- package/DataGrid/useDataGridComponent.d.ts +0 -1
- package/components/GridFooter.d.ts +1 -1
- package/components/GridLoadingOverlay.d.ts +1 -1
- package/components/GridNoResultsOverlay.d.ts +1 -1
- package/components/GridNoRowsOverlay.d.ts +1 -1
- package/components/GridRowCount.d.ts +1 -1
- package/components/GridSelectedRowCount.d.ts +1 -1
- package/components/cell/GridActionsCellItem.d.ts +3 -3
- 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 +8 -0
- 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/GridVirtualScrollerContent.d.ts +1 -1
- package/components/virtualization/GridVirtualScrollerRenderZone.d.ts +1 -1
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +5 -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 +1 -2
- package/hooks/features/export/serializers/csvSerializer.js +13 -15
- 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/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/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/locales/ptPT.js +13 -14
- 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 +5 -1
- package/models/props/DataGridProps.d.ts +2 -0
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +3 -3
- package/modern/components/columnHeaders/GridColumnHeaderSortIcon.js +11 -6
- package/modern/components/containers/GridRootStyles.js +8 -0
- 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/serializers/csvSerializer.js +13 -15
- package/modern/hooks/features/export/useGridPrintExport.js +9 -8
- 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/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/internals/utils/propValidation.js +1 -1
- package/modern/locales/ptPT.js +13 -14
- package/modern/models/gridDataSource.js +1 -0
- package/node/components/columnHeaders/GridColumnHeaderItem.js +3 -3
- package/node/components/columnHeaders/GridColumnHeaderSortIcon.js +11 -6
- package/node/components/containers/GridRootStyles.js +8 -0
- 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/serializers/csvSerializer.js +13 -15
- package/node/hooks/features/export/useGridPrintExport.js +9 -8
- 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/index.js +1 -1
- package/node/internals/index.js +7 -0
- package/node/internals/utils/propValidation.js +1 -1
- package/node/locales/ptPT.js +13 -14
- package/node/models/gridDataSource.js +5 -0
- package/package.json +3 -3
- 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/warning.d.ts +1 -1
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../../colDef';
|
|
2
2
|
import { buildWarning } from '../../../../utils/warning';
|
|
3
3
|
function sanitizeCellValue(value, csvOptions) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
4
|
+
const valueStr = typeof value === 'string' ? value : `${value}`;
|
|
5
|
+
if (csvOptions.shouldAppendQuotes || csvOptions.escapeFormulas) {
|
|
6
|
+
const escapedValue = valueStr.replace(/"/g, '""');
|
|
7
|
+
// Make sure value containing delimiter or line break won't be split into multiple cells
|
|
8
|
+
if ([csvOptions.delimiter, '\n', '\r', '"'].some(delimiter => valueStr.includes(delimiter))) {
|
|
9
|
+
return `"${escapedValue}"`;
|
|
10
|
+
}
|
|
11
|
+
if (csvOptions.escapeFormulas) {
|
|
12
|
+
// See https://owasp.org/www-community/attacks/CSV_Injection
|
|
13
|
+
if (['=', '+', '-', '@', '\t', '\r'].includes(escapedValue[0])) {
|
|
14
|
+
return `'${escapedValue}`;
|
|
16
15
|
}
|
|
17
|
-
return escapedValue;
|
|
18
16
|
}
|
|
19
|
-
return
|
|
17
|
+
return escapedValue;
|
|
20
18
|
}
|
|
21
|
-
return
|
|
19
|
+
return valueStr;
|
|
22
20
|
}
|
|
23
21
|
export const serializeCellValue = (cellParams, options) => {
|
|
24
22
|
const {
|
|
@@ -119,14 +119,15 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
119
119
|
gridClone.style.height = `${computedTotalHeight}px`;
|
|
120
120
|
// The height above does not include grid border width, so we need to exclude it
|
|
121
121
|
gridClone.style.boxSizing = 'content-box';
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
if (!normalizeOptions.hideFooter) {
|
|
123
|
+
// the footer is always being placed at the bottom of the page as if all rows are exported
|
|
124
|
+
// so if getRowsToExport is being used to only export a subset of rows then we need to
|
|
125
|
+
// adjust the footer position to be correctly placed at the bottom of the grid
|
|
126
|
+
const gridFooterElement = gridClone.querySelector(`.${gridClasses.footerContainer}`);
|
|
127
|
+
gridFooterElement.style.position = 'absolute';
|
|
128
|
+
gridFooterElement.style.width = '100%';
|
|
129
|
+
gridFooterElement.style.top = `${computedTotalHeight - gridFooterElementHeight}px`;
|
|
130
|
+
}
|
|
130
131
|
|
|
131
132
|
// printDoc.body.appendChild(gridClone); should be enough but a clone isolation bug in Safari
|
|
132
133
|
// prevents us to do it
|
|
@@ -8,6 +8,7 @@ export const gridTopLevelRowCountSelector = createSelector(gridRowsStateSelector
|
|
|
8
8
|
export const gridRowsLookupSelector = createSelector(gridRowsStateSelector, rows => rows.dataRowIdToModelLookup);
|
|
9
9
|
export const gridRowsDataRowIdToIdLookupSelector = createSelector(gridRowsStateSelector, rows => rows.dataRowIdToIdLookup);
|
|
10
10
|
export const gridRowTreeSelector = createSelector(gridRowsStateSelector, rows => rows.tree);
|
|
11
|
+
export const gridRowGroupsToFetchSelector = createSelector(gridRowsStateSelector, rows => rows.groupsToFetch);
|
|
11
12
|
export const gridRowGroupingNameSelector = createSelector(gridRowsStateSelector, rows => rows.groupingName);
|
|
12
13
|
export const gridRowTreeDepthsSelector = createSelector(gridRowsStateSelector, rows => rows.treeDepths);
|
|
13
14
|
export const gridRowMaximumTreeDepthSelector = createSelectorMemoized(gridRowsStateSelector, rows => {
|
|
@@ -72,7 +72,8 @@ export const getRowsStateFromCache = ({
|
|
|
72
72
|
rowCountProp = 0,
|
|
73
73
|
loadingProp,
|
|
74
74
|
previousTree,
|
|
75
|
-
previousTreeDepths
|
|
75
|
+
previousTreeDepths,
|
|
76
|
+
previousGroupsToFetch
|
|
76
77
|
}) => {
|
|
77
78
|
const cache = apiRef.current.caches.rows;
|
|
78
79
|
|
|
@@ -81,13 +82,15 @@ export const getRowsStateFromCache = ({
|
|
|
81
82
|
tree: unProcessedTree,
|
|
82
83
|
treeDepths: unProcessedTreeDepths,
|
|
83
84
|
dataRowIds: unProcessedDataRowIds,
|
|
84
|
-
groupingName
|
|
85
|
+
groupingName,
|
|
86
|
+
groupsToFetch = []
|
|
85
87
|
} = apiRef.current.applyStrategyProcessor('rowTreeCreation', {
|
|
86
88
|
previousTree,
|
|
87
89
|
previousTreeDepths,
|
|
88
90
|
updates: cache.updates,
|
|
89
91
|
dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
|
|
90
|
-
dataRowIdToModelLookup: cache.dataRowIdToModelLookup
|
|
92
|
+
dataRowIdToModelLookup: cache.dataRowIdToModelLookup,
|
|
93
|
+
previousGroupsToFetch
|
|
91
94
|
});
|
|
92
95
|
|
|
93
96
|
// 2. Apply the "hydrateRows" pipe-processing.
|
|
@@ -116,7 +119,8 @@ export const getRowsStateFromCache = ({
|
|
|
116
119
|
rowCountProp
|
|
117
120
|
}),
|
|
118
121
|
groupingName,
|
|
119
|
-
loading: loadingProp
|
|
122
|
+
loading: loadingProp,
|
|
123
|
+
groupsToFetch
|
|
120
124
|
});
|
|
121
125
|
};
|
|
122
126
|
export const isAutoGeneratedRow = rowNode => rowNode.type === 'skeletonRow' || rowNode.type === 'footer' || rowNode.type === 'group' && rowNode.isAutoGenerated || rowNode.type === 'pinnedRow' && rowNode.isAutoGenerated;
|
|
@@ -144,7 +148,8 @@ export const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) =>
|
|
|
144
148
|
export const updateCacheWithNewRows = ({
|
|
145
149
|
previousCache,
|
|
146
150
|
getRowId,
|
|
147
|
-
updates
|
|
151
|
+
updates,
|
|
152
|
+
groupKeys
|
|
148
153
|
}) => {
|
|
149
154
|
if (previousCache.updates.type === 'full') {
|
|
150
155
|
throw new Error('MUI X: Unable to prepare a partial update if a full update is not applied yet.');
|
|
@@ -168,7 +173,8 @@ export const updateCacheWithNewRows = ({
|
|
|
168
173
|
modify: [...(previousCache.updates.actions.modify ?? [])],
|
|
169
174
|
remove: [...(previousCache.updates.actions.remove ?? [])]
|
|
170
175
|
},
|
|
171
|
-
idToActionLookup: _extends({}, previousCache.updates.idToActionLookup)
|
|
176
|
+
idToActionLookup: _extends({}, previousCache.updates.idToActionLookup),
|
|
177
|
+
groupKeys
|
|
172
178
|
};
|
|
173
179
|
const dataRowIdToModelLookup = _extends({}, previousCache.dataRowIdToModelLookup);
|
|
174
180
|
const dataRowIdToIdLookup = _extends({}, previousCache.dataRowIdToIdLookup);
|
|
@@ -281,4 +287,22 @@ export function calculatePinnedRowsHeight(apiRef) {
|
|
|
281
287
|
export function getMinimalContentHeight(apiRef) {
|
|
282
288
|
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
283
289
|
return `var(--DataGrid-overlayHeight, ${2 * dimensions.rowHeight}px)`;
|
|
290
|
+
}
|
|
291
|
+
export function computeRowsUpdates(apiRef, updates, getRowId) {
|
|
292
|
+
const nonPinnedRowsUpdates = [];
|
|
293
|
+
updates.forEach(update => {
|
|
294
|
+
const id = getRowIdFromRowModel(update, getRowId, 'A row was provided without id when calling updateRows():');
|
|
295
|
+
const rowNode = apiRef.current.getRowNode(id);
|
|
296
|
+
if (rowNode?.type === 'pinnedRow') {
|
|
297
|
+
// @ts-ignore because otherwise `release:build` doesn't work
|
|
298
|
+
const pinnedRowsCache = apiRef.current.caches.pinnedRows;
|
|
299
|
+
const prevModel = pinnedRowsCache.idLookup[id];
|
|
300
|
+
if (prevModel) {
|
|
301
|
+
pinnedRowsCache.idLookup[id] = _extends({}, prevModel, update);
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
nonPinnedRowsUpdates.push(update);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
return nonPinnedRowsUpdates;
|
|
284
308
|
}
|
|
@@ -2,17 +2,18 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
4
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
5
|
-
import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowsDataRowIdToIdLookupSelector, gridRowMaximumTreeDepthSelector } from './gridRowsSelector';
|
|
5
|
+
import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowsDataRowIdToIdLookupSelector, gridRowMaximumTreeDepthSelector, gridRowGroupsToFetchSelector } from './gridRowsSelector';
|
|
6
6
|
import { useTimeout } from '../../utils/useTimeout';
|
|
7
7
|
import { GridSignature, useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
8
8
|
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
9
9
|
import { gridSortedRowIdsSelector } from '../sorting/gridSortingSelector';
|
|
10
10
|
import { gridFilteredRowsLookupSelector } from '../filter/gridFilterSelector';
|
|
11
|
-
import { getTreeNodeDescendants, createRowsInternalCache, getRowsStateFromCache, isAutoGeneratedRow, GRID_ROOT_GROUP_ID, GRID_ID_AUTOGENERATED, updateCacheWithNewRows, getTopLevelRowCount, getRowIdFromRowModel } from './gridRowsUtils';
|
|
11
|
+
import { getTreeNodeDescendants, createRowsInternalCache, getRowsStateFromCache, isAutoGeneratedRow, GRID_ROOT_GROUP_ID, GRID_ID_AUTOGENERATED, updateCacheWithNewRows, getTopLevelRowCount, getRowIdFromRowModel, computeRowsUpdates } from './gridRowsUtils';
|
|
12
12
|
import { useGridRegisterPipeApplier } from '../../core/pipeProcessing';
|
|
13
13
|
export const rowsStateInitializer = (state, props, apiRef) => {
|
|
14
|
+
const isDataSourceAvailable = !!props.unstable_dataSource;
|
|
14
15
|
apiRef.current.caches.rows = createRowsInternalCache({
|
|
15
|
-
rows: props.rows,
|
|
16
|
+
rows: isDataSourceAvailable ? [] : props.rows,
|
|
16
17
|
getRowId: props.getRowId,
|
|
17
18
|
loading: props.loading,
|
|
18
19
|
rowCount: props.rowCount
|
|
@@ -21,7 +22,7 @@ export const rowsStateInitializer = (state, props, apiRef) => {
|
|
|
21
22
|
rows: getRowsStateFromCache({
|
|
22
23
|
apiRef,
|
|
23
24
|
rowCountProp: props.rowCount,
|
|
24
|
-
loadingProp: props.loading,
|
|
25
|
+
loadingProp: isDataSourceAvailable ? true : props.loading,
|
|
25
26
|
previousTree: null,
|
|
26
27
|
previousTreeDepths: null
|
|
27
28
|
})
|
|
@@ -82,7 +83,8 @@ export const useGridRows = (apiRef, props) => {
|
|
|
82
83
|
rowCountProp: props.rowCount,
|
|
83
84
|
loadingProp: props.loading,
|
|
84
85
|
previousTree: gridRowTreeSelector(apiRef),
|
|
85
|
-
previousTreeDepths: gridRowTreeDepthsSelector(apiRef)
|
|
86
|
+
previousTreeDepths: gridRowTreeDepthsSelector(apiRef),
|
|
87
|
+
previousGroupsToFetch: gridRowGroupsToFetchSelector(apiRef)
|
|
86
88
|
})
|
|
87
89
|
}));
|
|
88
90
|
apiRef.current.publishEvent('rowsSet');
|
|
@@ -124,21 +126,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
124
126
|
if (props.signature === GridSignature.DataGrid && updates.length > 1) {
|
|
125
127
|
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'));
|
|
126
128
|
}
|
|
127
|
-
const nonPinnedRowsUpdates =
|
|
128
|
-
updates.forEach(update => {
|
|
129
|
-
const id = getRowIdFromRowModel(update, props.getRowId, 'A row was provided without id when calling updateRows():');
|
|
130
|
-
const rowNode = apiRef.current.getRowNode(id);
|
|
131
|
-
if (rowNode?.type === 'pinnedRow') {
|
|
132
|
-
// @ts-ignore because otherwise `release:build` doesn't work
|
|
133
|
-
const pinnedRowsCache = apiRef.current.caches.pinnedRows;
|
|
134
|
-
const prevModel = pinnedRowsCache.idLookup[id];
|
|
135
|
-
if (prevModel) {
|
|
136
|
-
pinnedRowsCache.idLookup[id] = _extends({}, prevModel, update);
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
nonPinnedRowsUpdates.push(update);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
129
|
+
const nonPinnedRowsUpdates = computeRowsUpdates(apiRef, updates, props.getRowId);
|
|
142
130
|
const cache = updateCacheWithNewRows({
|
|
143
131
|
updates: nonPinnedRowsUpdates,
|
|
144
132
|
getRowId: props.getRowId,
|
|
@@ -149,6 +137,31 @@ export const useGridRows = (apiRef, props) => {
|
|
|
149
137
|
throttle: true
|
|
150
138
|
});
|
|
151
139
|
}, [props.signature, props.getRowId, throttledRowsChange, apiRef]);
|
|
140
|
+
const updateServerRows = React.useCallback((updates, groupKeys) => {
|
|
141
|
+
const nonPinnedRowsUpdates = computeRowsUpdates(apiRef, updates, props.getRowId);
|
|
142
|
+
const cache = updateCacheWithNewRows({
|
|
143
|
+
updates: nonPinnedRowsUpdates,
|
|
144
|
+
getRowId: props.getRowId,
|
|
145
|
+
previousCache: apiRef.current.caches.rows,
|
|
146
|
+
groupKeys: groupKeys ?? []
|
|
147
|
+
});
|
|
148
|
+
throttledRowsChange({
|
|
149
|
+
cache,
|
|
150
|
+
throttle: false
|
|
151
|
+
});
|
|
152
|
+
}, [props.getRowId, throttledRowsChange, apiRef]);
|
|
153
|
+
const setLoading = React.useCallback(loading => {
|
|
154
|
+
if (loading === props.loading) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
logger.debug(`Setting loading to ${loading}`);
|
|
158
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
159
|
+
rows: _extends({}, state.rows, {
|
|
160
|
+
loading
|
|
161
|
+
})
|
|
162
|
+
}));
|
|
163
|
+
apiRef.current.caches.rows.loadingPropBeforePartialUpdates = loading;
|
|
164
|
+
}, [props.loading, apiRef, logger]);
|
|
152
165
|
const getRowModels = React.useCallback(() => {
|
|
153
166
|
const dataRows = gridDataRowIdsSelector(apiRef);
|
|
154
167
|
const idRowsLookup = gridRowsLookupSelector(apiRef);
|
|
@@ -303,6 +316,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
303
316
|
}, [apiRef, props.signature, props.getRowId]);
|
|
304
317
|
const rowApi = {
|
|
305
318
|
getRow,
|
|
319
|
+
setLoading,
|
|
306
320
|
getRowId,
|
|
307
321
|
getRowModels,
|
|
308
322
|
getRowsCount,
|
|
@@ -318,6 +332,9 @@ export const useGridRows = (apiRef, props) => {
|
|
|
318
332
|
setRowChildrenExpansion,
|
|
319
333
|
getRowGroupChildren
|
|
320
334
|
};
|
|
335
|
+
const rowProPrivateApi = {
|
|
336
|
+
updateServerRows
|
|
337
|
+
};
|
|
321
338
|
|
|
322
339
|
/**
|
|
323
340
|
* EVENTS
|
|
@@ -392,6 +409,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
392
409
|
useGridRegisterPipeApplier(apiRef, 'hydrateRows', applyHydrateRowsProcessor);
|
|
393
410
|
useGridApiMethod(apiRef, rowApi, 'public');
|
|
394
411
|
useGridApiMethod(apiRef, rowProApi, props.signature === GridSignature.DataGrid ? 'private' : 'public');
|
|
412
|
+
useGridApiMethod(apiRef, rowProPrivateApi, 'private');
|
|
395
413
|
|
|
396
414
|
// The effect do not track any value defined synchronously during the 1st render by hooks called after `useGridRows`
|
|
397
415
|
// As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one
|
|
@@ -436,7 +454,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
436
454
|
return;
|
|
437
455
|
}
|
|
438
456
|
}
|
|
439
|
-
logger.debug(`Updating all rows, new length ${props.rows
|
|
457
|
+
logger.debug(`Updating all rows, new length ${props.rows?.length}`);
|
|
440
458
|
throttledRowsChange({
|
|
441
459
|
cache: createRowsInternalCache({
|
|
442
460
|
rows: props.rows,
|
package/modern/index.js
CHANGED
|
@@ -55,6 +55,7 @@ export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
|
|
|
55
55
|
export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
|
|
56
56
|
export * from '../utils/createControllablePromise';
|
|
57
57
|
export { createSelector, createSelectorMemoized } from '../utils/createSelector';
|
|
58
|
+
export { gridRowGroupsToFetchSelector } from '../hooks/features/rows/gridRowsSelector';
|
|
58
59
|
export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from '../utils/domUtils';
|
|
59
60
|
export { isNavigationKey, isPasteShortcut } from '../utils/keyboardUtils';
|
|
60
61
|
export * from '../utils/utils';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNumber } from '../../utils/utils';
|
|
2
2
|
import { GridSignature } from '../../hooks/utils/useGridApiEventHandler';
|
|
3
|
-
export const 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 === GridSignature.DataGrid && props.paginationMode === 'client' && 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];
|
|
3
|
+
export const 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 === GridSignature.DataGrid && props.paginationMode === 'client' && 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];
|
|
4
4
|
const warnedOnceCache = new Set();
|
|
5
5
|
function warnOnce(message) {
|
|
6
6
|
if (!warnedOnceCache.has(message)) {
|
package/modern/locales/ptPT.js
CHANGED
|
@@ -26,18 +26,17 @@ const ptPTGrid = {
|
|
|
26
26
|
// Export selector toolbar button text
|
|
27
27
|
toolbarExport: 'Exportar',
|
|
28
28
|
toolbarExportLabel: 'Exportar',
|
|
29
|
-
toolbarExportCSV: '
|
|
29
|
+
toolbarExportCSV: 'Descarregar como CSV',
|
|
30
30
|
toolbarExportPrint: 'Imprimir',
|
|
31
|
-
toolbarExportExcel: '
|
|
31
|
+
toolbarExportExcel: 'Descarregar como Excel',
|
|
32
32
|
// Columns management text
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
columnsManagementSearchTitle: 'Procurar',
|
|
34
|
+
columnsManagementNoColumns: 'Sem colunas',
|
|
35
|
+
columnsManagementShowHideAllText: 'Mostrar/Ocultar Todas',
|
|
36
|
+
columnsManagementReset: 'Repor',
|
|
38
37
|
// Filter panel text
|
|
39
38
|
filterPanelAddFilter: 'Adicionar filtro',
|
|
40
|
-
filterPanelRemoveAll: '
|
|
39
|
+
filterPanelRemoveAll: 'Excluir todos',
|
|
41
40
|
filterPanelDeleteIconLabel: 'Excluir',
|
|
42
41
|
filterPanelLogicOperator: 'Operador lógico',
|
|
43
42
|
filterPanelOperator: 'Operador',
|
|
@@ -91,9 +90,9 @@ const ptPTGrid = {
|
|
|
91
90
|
filterValueTrue: 'verdadeiro',
|
|
92
91
|
filterValueFalse: 'falso',
|
|
93
92
|
// Column menu text
|
|
94
|
-
columnMenuLabel: '
|
|
93
|
+
columnMenuLabel: 'Menu',
|
|
95
94
|
columnMenuShowColumns: 'Mostrar colunas',
|
|
96
|
-
columnMenuManageColumns: '
|
|
95
|
+
columnMenuManageColumns: 'Gerir colunas',
|
|
97
96
|
columnMenuFilter: 'Filtro',
|
|
98
97
|
columnMenuHideColumn: 'Ocultar coluna',
|
|
99
98
|
columnMenuUnsort: 'Desclassificar',
|
|
@@ -123,10 +122,10 @@ const ptPTGrid = {
|
|
|
123
122
|
// Column pinning text
|
|
124
123
|
pinToLeft: 'Fixar à esquerda',
|
|
125
124
|
pinToRight: 'Fixar à direita',
|
|
126
|
-
unpin: '
|
|
125
|
+
unpin: 'Desafixar',
|
|
127
126
|
// Tree Data
|
|
128
|
-
treeDataGroupingHeaderName: '
|
|
129
|
-
treeDataExpand: '
|
|
127
|
+
treeDataGroupingHeaderName: 'Grupo',
|
|
128
|
+
treeDataExpand: 'ver crianças',
|
|
130
129
|
treeDataCollapse: 'esconder crianças',
|
|
131
130
|
// Grouping columns
|
|
132
131
|
groupingColumnHeaderName: 'Grupo',
|
|
@@ -135,7 +134,7 @@ const ptPTGrid = {
|
|
|
135
134
|
// Master/detail
|
|
136
135
|
detailPanelToggle: 'Alternar painel de detalhes',
|
|
137
136
|
expandDetailPanel: 'Expandir',
|
|
138
|
-
collapseDetailPanel: '
|
|
137
|
+
collapseDetailPanel: 'Colapsar',
|
|
139
138
|
// Row reordering text
|
|
140
139
|
rowReorderingHeaderName: 'Reordenação de linhas',
|
|
141
140
|
// Aggregation
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,7 +12,6 @@ var _clsx = _interopRequireDefault(require("clsx"));
|
|
|
12
12
|
var _utils = require("@mui/utils");
|
|
13
13
|
var _fastMemo = require("../../utils/fastMemo");
|
|
14
14
|
var _useGridPrivateApiContext = require("../../hooks/utils/useGridPrivateApiContext");
|
|
15
|
-
var _GridColumnHeaderSortIcon = require("./GridColumnHeaderSortIcon");
|
|
16
15
|
var _ColumnHeaderMenuIcon = require("./ColumnHeaderMenuIcon");
|
|
17
16
|
var _GridColumnHeaderMenu = require("../menu/columnMenu/GridColumnHeaderMenu");
|
|
18
17
|
var _gridClasses = require("../../constants/gridClasses");
|
|
@@ -151,12 +150,13 @@ function GridColumnHeaderItem(props) {
|
|
|
151
150
|
children: [!rootProps.disableColumnFilter && /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.columnHeaderFilterIconButton, (0, _extends2.default)({
|
|
152
151
|
field: colDef.field,
|
|
153
152
|
counter: filterItemsCounter
|
|
154
|
-
}, rootProps.slotProps?.columnHeaderFilterIconButton)), showSortIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
153
|
+
}, rootProps.slotProps?.columnHeaderFilterIconButton)), showSortIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.columnHeaderSortIcon, (0, _extends2.default)({
|
|
154
|
+
field: colDef.field,
|
|
155
155
|
direction: sortDirection,
|
|
156
156
|
index: sortIndex,
|
|
157
157
|
sortingOrder: sortingOrder,
|
|
158
158
|
disabled: !colDef.sortable
|
|
159
|
-
})]
|
|
159
|
+
}, rootProps.slotProps?.columnHeaderSortIcon))]
|
|
160
160
|
});
|
|
161
161
|
React.useLayoutEffect(() => {
|
|
162
162
|
const columnMenuState = apiRef.current.state.columnMenu;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.GridColumnHeaderSortIcon = void 0;
|
|
8
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var React = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -15,6 +16,7 @@ var _gridClasses = require("../../constants/gridClasses");
|
|
|
15
16
|
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
16
17
|
var _GridIconButtonContainer = require("./GridIconButtonContainer");
|
|
17
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
const _excluded = ["direction", "index", "sortingOrder", "disabled"];
|
|
18
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); }
|
|
19
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; }
|
|
20
22
|
const useUtilityClasses = ownerState => {
|
|
@@ -44,11 +46,12 @@ function getIcon(icons, direction, className, sortingOrder) {
|
|
|
44
46
|
}
|
|
45
47
|
function GridColumnHeaderSortIconRaw(props) {
|
|
46
48
|
const {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
direction,
|
|
50
|
+
index,
|
|
51
|
+
sortingOrder,
|
|
52
|
+
disabled
|
|
53
|
+
} = props,
|
|
54
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
52
55
|
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
53
56
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
54
57
|
const ownerState = (0, _extends2.default)({}, props, {
|
|
@@ -65,13 +68,14 @@ function GridColumnHeaderSortIconRaw(props) {
|
|
|
65
68
|
title: apiRef.current.getLocaleText('columnHeaderSortIconLabel'),
|
|
66
69
|
size: "small",
|
|
67
70
|
disabled: disabled
|
|
68
|
-
}, rootProps.slotProps?.baseIconButton, {
|
|
71
|
+
}, rootProps.slotProps?.baseIconButton, other, {
|
|
69
72
|
children: iconElement
|
|
70
73
|
}));
|
|
71
74
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridIconButtonContainer.GridIconButtonContainer, {
|
|
72
75
|
children: [index != null && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Badge.default, {
|
|
73
76
|
badgeContent: index,
|
|
74
77
|
color: "default",
|
|
78
|
+
overlap: "circular",
|
|
75
79
|
children: iconButton
|
|
76
80
|
}), index == null && iconButton]
|
|
77
81
|
});
|
|
@@ -84,6 +88,7 @@ process.env.NODE_ENV !== "production" ? GridColumnHeaderSortIconRaw.propTypes =
|
|
|
84
88
|
// ----------------------------------------------------------------------
|
|
85
89
|
direction: _propTypes.default.oneOf(['asc', 'desc']),
|
|
86
90
|
disabled: _propTypes.default.bool,
|
|
91
|
+
field: _propTypes.default.string.isRequired,
|
|
87
92
|
index: _propTypes.default.number,
|
|
88
93
|
sortingOrder: _propTypes.default.arrayOf(_propTypes.default.oneOf(['asc', 'desc'])).isRequired
|
|
89
94
|
} : void 0;
|
|
@@ -148,6 +148,8 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
|
|
|
148
148
|
[`& .${_gridClasses.gridClasses.treeDataGroupingCell}`]: styles.treeDataGroupingCell
|
|
149
149
|
}, {
|
|
150
150
|
[`& .${_gridClasses.gridClasses.treeDataGroupingCellToggle}`]: styles.treeDataGroupingCellToggle
|
|
151
|
+
}, {
|
|
152
|
+
[`& .${_gridClasses.gridClasses.treeDataGroupingCellLoadingContainer}`]: styles.treeDataGroupingCellLoadingContainer
|
|
151
153
|
}, {
|
|
152
154
|
[`& .${_gridClasses.gridClasses.detailPanelToggleCell}`]: styles.detailPanelToggleCell
|
|
153
155
|
}, {
|
|
@@ -615,6 +617,12 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
|
|
|
615
617
|
alignSelf: 'stretch',
|
|
616
618
|
marginRight: t.spacing(2)
|
|
617
619
|
},
|
|
620
|
+
[`& .${_gridClasses.gridClasses.treeDataGroupingCellLoadingContainer}`]: {
|
|
621
|
+
display: 'flex',
|
|
622
|
+
alignItems: 'center',
|
|
623
|
+
justifyContent: 'center',
|
|
624
|
+
height: '100%'
|
|
625
|
+
},
|
|
618
626
|
[`& .${_gridClasses.gridClasses.groupingCriteriaCell}`]: {
|
|
619
627
|
display: 'flex',
|
|
620
628
|
alignItems: 'center',
|
|
@@ -20,6 +20,7 @@ const DATA_GRID_DEFAULT_SLOTS_COMPONENTS = exports.DATA_GRID_DEFAULT_SLOTS_COMPO
|
|
|
20
20
|
cell: _GridCell.GridCell,
|
|
21
21
|
skeletonCell: _components.GridSkeletonCell,
|
|
22
22
|
columnHeaderFilterIconButton: _components.GridColumnHeaderFilterIconButton,
|
|
23
|
+
columnHeaderSortIcon: _components.GridColumnHeaderSortIcon,
|
|
23
24
|
columnMenu: _GridColumnMenu.GridColumnMenu,
|
|
24
25
|
columnHeaders: _GridColumnHeaders.GridColumnHeaders,
|
|
25
26
|
detailPanels: _GridDetailPanels.GridDetailPanels,
|
|
@@ -9,4 +9,4 @@ var _utils = require("@mui/utils");
|
|
|
9
9
|
function getDataGridUtilityClass(slot) {
|
|
10
10
|
return (0, _utils.unstable_generateUtilityClass)('MuiDataGrid', slot);
|
|
11
11
|
}
|
|
12
|
-
const gridClasses = exports.gridClasses = (0, _utils.unstable_generateUtilityClasses)('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderTop', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
12
|
+
const gridClasses = exports.gridClasses = (0, _utils.unstable_generateUtilityClasses)('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderTop', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
@@ -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;
|
|
@@ -8,24 +8,22 @@ exports.serializeCellValue = void 0;
|
|
|
8
8
|
var _colDef = require("../../../../colDef");
|
|
9
9
|
var _warning = require("../../../../utils/warning");
|
|
10
10
|
function sanitizeCellValue(value, csvOptions) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
11
|
+
const valueStr = typeof value === 'string' ? value : `${value}`;
|
|
12
|
+
if (csvOptions.shouldAppendQuotes || csvOptions.escapeFormulas) {
|
|
13
|
+
const escapedValue = valueStr.replace(/"/g, '""');
|
|
14
|
+
// Make sure value containing delimiter or line break won't be split into multiple cells
|
|
15
|
+
if ([csvOptions.delimiter, '\n', '\r', '"'].some(delimiter => valueStr.includes(delimiter))) {
|
|
16
|
+
return `"${escapedValue}"`;
|
|
17
|
+
}
|
|
18
|
+
if (csvOptions.escapeFormulas) {
|
|
19
|
+
// See https://owasp.org/www-community/attacks/CSV_Injection
|
|
20
|
+
if (['=', '+', '-', '@', '\t', '\r'].includes(escapedValue[0])) {
|
|
21
|
+
return `'${escapedValue}`;
|
|
23
22
|
}
|
|
24
|
-
return escapedValue;
|
|
25
23
|
}
|
|
26
|
-
return
|
|
24
|
+
return escapedValue;
|
|
27
25
|
}
|
|
28
|
-
return
|
|
26
|
+
return valueStr;
|
|
29
27
|
}
|
|
30
28
|
const serializeCellValue = (cellParams, options) => {
|
|
31
29
|
const {
|
|
@@ -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
|