@mui/x-data-grid 7.5.0 → 7.6.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 +148 -5418
- package/DataGrid/DataGrid.js +2 -2
- package/components/GridColumnHeaders.js +1 -1
- package/components/GridFooter.js +1 -1
- package/components/GridLoadingOverlay.js +1 -1
- package/components/GridNoRowsOverlay.js +1 -1
- package/components/GridPagination.js +1 -1
- package/components/GridRow.js +1 -1
- package/components/GridRowCount.js +1 -1
- package/components/GridScrollArea.d.ts +2 -5
- package/components/GridScrollArea.js +1 -10
- package/components/GridSelectedRowCount.js +1 -1
- package/components/base/GridOverlays.js +1 -1
- package/components/cell/GridActionsCell.js +1 -1
- package/components/cell/GridActionsCellItem.js +1 -1
- package/components/cell/GridBooleanCell.js +1 -1
- package/components/cell/GridCell.js +2 -2
- package/components/cell/GridEditBooleanCell.js +1 -1
- package/components/cell/GridEditDateCell.js +1 -1
- package/components/cell/GridEditInputCell.js +1 -1
- package/components/cell/GridEditSingleSelectCell.js +1 -1
- package/components/cell/GridSkeletonCell.js +1 -1
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +1 -1
- package/components/columnHeaders/GridColumnHeaderItem.js +1 -1
- package/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
- package/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -1
- package/components/columnHeaders/GridColumnHeaderTitle.js +1 -1
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +0 -7
- package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/components/columnSelection/GridHeaderCheckbox.js +1 -1
- package/components/columnsManagement/GridColumnsManagement.js +1 -1
- package/components/containers/GridFooterContainer.js +1 -1
- package/components/containers/GridOverlay.js +1 -1
- package/components/containers/GridRoot.js +1 -1
- package/components/containers/GridToolbarContainer.js +1 -1
- package/components/menu/GridMenu.js +1 -1
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/components/menu/columnMenu/GridColumnMenu.js +1 -1
- package/components/menu/columnMenu/GridColumnMenuContainer.js +1 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.js +1 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +1 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +1 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +1 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +1 -1
- package/components/panel/GridColumnsPanel.js +1 -1
- package/components/panel/GridPanel.js +1 -1
- package/components/panel/GridPanelContent.js +1 -1
- package/components/panel/GridPanelFooter.js +1 -1
- package/components/panel/GridPanelHeader.js +1 -1
- package/components/panel/GridPanelWrapper.js +1 -1
- package/components/panel/filterPanel/GridFilterForm.js +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +1 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
- package/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/components/toolbar/GridToolbar.js +1 -1
- package/components/toolbar/GridToolbarColumnsButton.js +1 -1
- package/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/components/toolbar/GridToolbarExport.js +1 -1
- package/components/toolbar/GridToolbarExportContainer.js +1 -1
- package/components/toolbar/GridToolbarFilterButton.js +1 -1
- package/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/hooks/features/clipboard/useGridClipboard.js +8 -5
- package/hooks/features/columnResize/useGridColumnResize.js +5 -26
- package/hooks/features/columns/gridColumnsUtils.js +18 -13
- package/hooks/features/columns/useGridColumnSpanning.js +5 -5
- package/hooks/features/export/serializers/csvSerializer.d.ts +3 -6
- package/hooks/features/export/serializers/csvSerializer.js +28 -32
- package/hooks/features/export/useGridCsvExport.js +8 -5
- package/hooks/features/virtualization/useGridVirtualScroller.js +8 -1
- package/index.d.ts +1 -0
- package/index.js +1 -2
- package/locales/faIR.js +4 -4
- package/locales/fiFI.js +4 -5
- package/models/api/gridColumnSpanning.d.ts +2 -0
- package/models/gridExport.d.ts +7 -0
- package/models/gridSlotsComponent.d.ts +1 -1
- package/models/props/DataGridProps.d.ts +1 -1
- package/modern/DataGrid/DataGrid.js +2 -2
- package/modern/components/GridColumnHeaders.js +1 -1
- package/modern/components/GridFooter.js +1 -1
- package/modern/components/GridLoadingOverlay.js +1 -1
- package/modern/components/GridNoRowsOverlay.js +1 -1
- package/modern/components/GridPagination.js +1 -1
- package/modern/components/GridRow.js +1 -1
- package/modern/components/GridRowCount.js +1 -1
- package/modern/components/GridScrollArea.js +1 -10
- package/modern/components/GridSelectedRowCount.js +1 -1
- package/modern/components/base/GridOverlays.js +1 -1
- package/modern/components/cell/GridActionsCell.js +1 -1
- package/modern/components/cell/GridActionsCellItem.js +1 -1
- package/modern/components/cell/GridBooleanCell.js +1 -1
- package/modern/components/cell/GridCell.js +2 -2
- package/modern/components/cell/GridEditBooleanCell.js +1 -1
- package/modern/components/cell/GridEditDateCell.js +1 -1
- package/modern/components/cell/GridEditInputCell.js +1 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +1 -1
- package/modern/components/cell/GridSkeletonCell.js +1 -1
- package/modern/components/columnHeaders/GridColumnHeaderFilterIconButton.js +1 -1
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +1 -1
- package/modern/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
- package/modern/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -1
- package/modern/components/columnHeaders/GridColumnHeaderTitle.js +1 -1
- package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +0 -7
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/modern/components/columnSelection/GridHeaderCheckbox.js +1 -1
- package/modern/components/columnsManagement/GridColumnsManagement.js +1 -1
- package/modern/components/containers/GridFooterContainer.js +1 -1
- package/modern/components/containers/GridOverlay.js +1 -1
- package/modern/components/containers/GridRoot.js +1 -1
- package/modern/components/containers/GridToolbarContainer.js +1 -1
- package/modern/components/menu/GridMenu.js +1 -1
- package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/modern/components/menu/columnMenu/GridColumnMenu.js +1 -1
- package/modern/components/menu/columnMenu/GridColumnMenuContainer.js +1 -1
- package/modern/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.js +1 -1
- package/modern/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +1 -1
- package/modern/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +1 -1
- package/modern/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +1 -1
- package/modern/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +1 -1
- package/modern/components/panel/GridColumnsPanel.js +1 -1
- package/modern/components/panel/GridPanel.js +1 -1
- package/modern/components/panel/GridPanelContent.js +1 -1
- package/modern/components/panel/GridPanelFooter.js +1 -1
- package/modern/components/panel/GridPanelHeader.js +1 -1
- package/modern/components/panel/GridPanelWrapper.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterForm.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/modern/components/toolbar/GridToolbar.js +1 -1
- package/modern/components/toolbar/GridToolbarColumnsButton.js +1 -1
- package/modern/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/modern/components/toolbar/GridToolbarExport.js +1 -1
- package/modern/components/toolbar/GridToolbarExportContainer.js +1 -1
- package/modern/components/toolbar/GridToolbarFilterButton.js +1 -1
- package/modern/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/modern/hooks/features/clipboard/useGridClipboard.js +8 -5
- package/modern/hooks/features/columnResize/useGridColumnResize.js +5 -26
- package/modern/hooks/features/columns/gridColumnsUtils.js +18 -13
- package/modern/hooks/features/columns/useGridColumnSpanning.js +5 -5
- package/modern/hooks/features/export/serializers/csvSerializer.js +28 -32
- package/modern/hooks/features/export/useGridCsvExport.js +8 -5
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +8 -1
- package/modern/index.js +1 -2
- package/modern/locales/faIR.js +4 -4
- package/modern/locales/fiFI.js +4 -5
- package/modern/utils/domUtils.js +1 -2
- package/node/DataGrid/DataGrid.js +2 -2
- package/node/components/GridColumnHeaders.js +1 -1
- package/node/components/GridFooter.js +1 -1
- package/node/components/GridLoadingOverlay.js +1 -1
- package/node/components/GridNoRowsOverlay.js +1 -1
- package/node/components/GridPagination.js +1 -1
- package/node/components/GridRow.js +1 -1
- package/node/components/GridRowCount.js +1 -1
- package/node/components/GridScrollArea.js +0 -8
- package/node/components/GridSelectedRowCount.js +1 -1
- package/node/components/base/GridOverlays.js +1 -1
- package/node/components/cell/GridActionsCell.js +1 -1
- package/node/components/cell/GridActionsCellItem.js +1 -1
- package/node/components/cell/GridBooleanCell.js +1 -1
- package/node/components/cell/GridCell.js +2 -2
- package/node/components/cell/GridEditBooleanCell.js +1 -1
- package/node/components/cell/GridEditDateCell.js +1 -1
- package/node/components/cell/GridEditInputCell.js +1 -1
- package/node/components/cell/GridEditSingleSelectCell.js +1 -1
- package/node/components/cell/GridSkeletonCell.js +1 -1
- package/node/components/columnHeaders/GridColumnHeaderFilterIconButton.js +1 -1
- package/node/components/columnHeaders/GridColumnHeaderItem.js +1 -1
- package/node/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
- package/node/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -1
- package/node/components/columnHeaders/GridColumnHeaderTitle.js +1 -1
- package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +0 -7
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/node/components/columnSelection/GridHeaderCheckbox.js +1 -1
- package/node/components/columnsManagement/GridColumnsManagement.js +1 -1
- package/node/components/containers/GridFooterContainer.js +1 -1
- package/node/components/containers/GridOverlay.js +1 -1
- package/node/components/containers/GridRoot.js +1 -1
- package/node/components/containers/GridToolbarContainer.js +1 -1
- package/node/components/menu/GridMenu.js +1 -1
- package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/node/components/menu/columnMenu/GridColumnMenu.js +1 -1
- package/node/components/menu/columnMenu/GridColumnMenuContainer.js +1 -1
- package/node/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.js +1 -1
- package/node/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +1 -1
- package/node/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +1 -1
- package/node/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +1 -1
- package/node/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +1 -1
- package/node/components/panel/GridColumnsPanel.js +1 -1
- package/node/components/panel/GridPanel.js +1 -1
- package/node/components/panel/GridPanelContent.js +1 -1
- package/node/components/panel/GridPanelFooter.js +1 -1
- package/node/components/panel/GridPanelHeader.js +1 -1
- package/node/components/panel/GridPanelWrapper.js +1 -1
- package/node/components/panel/filterPanel/GridFilterForm.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputDate.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/node/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/node/components/toolbar/GridToolbar.js +1 -1
- package/node/components/toolbar/GridToolbarColumnsButton.js +1 -1
- package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/node/components/toolbar/GridToolbarExport.js +1 -1
- package/node/components/toolbar/GridToolbarExportContainer.js +1 -1
- package/node/components/toolbar/GridToolbarFilterButton.js +1 -1
- package/node/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/node/hooks/features/clipboard/useGridClipboard.js +8 -5
- package/node/hooks/features/columnResize/useGridColumnResize.js +5 -26
- package/node/hooks/features/columns/gridColumnsUtils.js +18 -13
- package/node/hooks/features/columns/useGridColumnSpanning.js +5 -5
- package/node/hooks/features/export/serializers/csvSerializer.js +28 -32
- package/node/hooks/features/export/useGridCsvExport.js +8 -5
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +8 -1
- package/node/index.js +1 -1
- package/node/locales/faIR.js +4 -4
- package/node/locales/fiFI.js +4 -5
- package/node/utils/domUtils.js +1 -2
- package/package.json +4 -3
- package/utils/domUtils.js +1 -2
|
@@ -22,27 +22,6 @@ var _gridColumnsInterfaces = require("../columns/gridColumnsInterfaces");
|
|
|
22
22
|
var _columns = require("../columns");
|
|
23
23
|
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); }
|
|
24
24
|
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; }
|
|
25
|
-
// TODO: remove support for Safari < 13.
|
|
26
|
-
// https://caniuse.com/#search=touch-action
|
|
27
|
-
//
|
|
28
|
-
// Safari, on iOS, supports touch action since v13.
|
|
29
|
-
// Over 80% of the iOS phones are compatible
|
|
30
|
-
// in August 2020.
|
|
31
|
-
// Utilizing the CSS.supports method to check if touch-action is supported.
|
|
32
|
-
// Since CSS.supports is supported on all but Edge@12 and IE and touch-action
|
|
33
|
-
// is supported on both Edge@12 and IE if CSS.supports is not available that means that
|
|
34
|
-
// touch-action will be supported
|
|
35
|
-
let cachedSupportsTouchActionNone = false;
|
|
36
|
-
function doesSupportTouchActionNone() {
|
|
37
|
-
if (cachedSupportsTouchActionNone === undefined) {
|
|
38
|
-
if (typeof CSS !== 'undefined' && typeof CSS.supports === 'function') {
|
|
39
|
-
cachedSupportsTouchActionNone = CSS.supports('touch-action', 'none');
|
|
40
|
-
} else {
|
|
41
|
-
cachedSupportsTouchActionNone = true;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return cachedSupportsTouchActionNone;
|
|
45
|
-
}
|
|
46
25
|
function trackFinger(event, currentTouchId) {
|
|
47
26
|
if (currentTouchId !== undefined && event.changedTouches) {
|
|
48
27
|
for (let i = 0; i < event.changedTouches.length; i += 1) {
|
|
@@ -304,6 +283,10 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
304
283
|
if (refs.colDef) {
|
|
305
284
|
apiRef.current.setColumnWidth(refs.colDef.field, refs.colDef.width);
|
|
306
285
|
logger.debug(`Updating col ${refs.colDef.field} with new width: ${refs.colDef.width}`);
|
|
286
|
+
|
|
287
|
+
// Since during resizing we update the columns width outside of React, React is unable to
|
|
288
|
+
// reapply the right style properties. We need to sync the state manually.
|
|
289
|
+
// So we reapply the same logic as in https://github.com/mui/mui-x/blob/0511bf65543ca05d2602a5a3e0a6156f2fc8e759/packages/x-data-grid/src/hooks/features/columnHeaders/useGridColumnHeaders.tsx#L405
|
|
307
290
|
const columnsState = (0, _columns.gridColumnsStateSelector)(apiRef.current.state);
|
|
308
291
|
refs.groupHeaderElements.forEach(element => {
|
|
309
292
|
const fields = (0, _domUtils.getFieldsFromGroupHeaderElem)(element);
|
|
@@ -397,10 +380,6 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
397
380
|
if (!cellSeparator) {
|
|
398
381
|
return;
|
|
399
382
|
}
|
|
400
|
-
// If touch-action: none; is not supported we need to prevent the scroll manually.
|
|
401
|
-
if (!doesSupportTouchActionNone()) {
|
|
402
|
-
event.preventDefault();
|
|
403
|
-
}
|
|
404
383
|
const touch = event.changedTouches[0];
|
|
405
384
|
if (touch != null) {
|
|
406
385
|
// A number that uniquely identifies the current finger in the touch session.
|
|
@@ -572,7 +551,7 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
572
551
|
}
|
|
573
552
|
});
|
|
574
553
|
(0, _utils2.useGridNativeEventListener)(apiRef, () => apiRef.current.columnHeadersContainerRef?.current, 'touchstart', handleTouchStart, {
|
|
575
|
-
passive:
|
|
554
|
+
passive: true
|
|
576
555
|
});
|
|
577
556
|
(0, _utils2.useGridApiMethod)(apiRef, {
|
|
578
557
|
autosizeColumns
|
|
@@ -129,24 +129,29 @@ const hydrateColumnsWidth = (rawState, dimensions) => {
|
|
|
129
129
|
const flexColumns = [];
|
|
130
130
|
|
|
131
131
|
// For the non-flex columns, compute their width
|
|
132
|
-
// For the flex columns, compute
|
|
132
|
+
// For the flex columns, compute their minimum width and how much width must be allocated during the flex allocation
|
|
133
133
|
rawState.orderedFields.forEach(columnField => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
computedWidth = 0;
|
|
142
|
-
flexColumns.push(newColumn);
|
|
134
|
+
let column = rawState.lookup[columnField];
|
|
135
|
+
let computedWidth = 0;
|
|
136
|
+
let isFlex = false;
|
|
137
|
+
if (rawState.columnVisibilityModel[columnField] !== false) {
|
|
138
|
+
if (column.flex && column.flex > 0) {
|
|
139
|
+
totalFlexUnits += column.flex;
|
|
140
|
+
isFlex = true;
|
|
143
141
|
} else {
|
|
144
|
-
computedWidth = (0, _utils.clamp)(
|
|
142
|
+
computedWidth = (0, _utils.clamp)(column.width || _colDef.GRID_STRING_COL_DEF.width, column.minWidth || _colDef.GRID_STRING_COL_DEF.minWidth, column.maxWidth || _colDef.GRID_STRING_COL_DEF.maxWidth);
|
|
145
143
|
}
|
|
146
144
|
widthAllocatedBeforeFlex += computedWidth;
|
|
147
|
-
newColumn.computedWidth = computedWidth;
|
|
148
145
|
}
|
|
149
|
-
|
|
146
|
+
if (column.computedWidth !== computedWidth) {
|
|
147
|
+
column = (0, _extends2.default)({}, column, {
|
|
148
|
+
computedWidth
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if (isFlex) {
|
|
152
|
+
flexColumns.push(column);
|
|
153
|
+
}
|
|
154
|
+
columnsLookup[columnField] = column;
|
|
150
155
|
});
|
|
151
156
|
const availableWidth = dimensions === undefined ? 0 : dimensions.viewportOuterSize.width - (dimensions.hasScrollY ? dimensions.scrollbarSize : 0);
|
|
152
157
|
const initialFreeSpace = Math.max(availableWidth - widthAllocatedBeforeFlex, 0);
|
|
@@ -18,6 +18,9 @@ const useGridColumnSpanning = apiRef => {
|
|
|
18
18
|
const getCellColSpanInfo = (rowId, columnIndex) => {
|
|
19
19
|
return lookup.current[rowId]?.[columnIndex];
|
|
20
20
|
};
|
|
21
|
+
const resetColSpan = () => {
|
|
22
|
+
lookup.current = {};
|
|
23
|
+
};
|
|
21
24
|
|
|
22
25
|
// Calculate `colSpan` for each cell in the row
|
|
23
26
|
const calculateColSpan = React.useCallback(({
|
|
@@ -45,15 +48,12 @@ const useGridColumnSpanning = apiRef => {
|
|
|
45
48
|
unstable_getCellColSpanInfo: getCellColSpanInfo
|
|
46
49
|
};
|
|
47
50
|
const columnSpanningPrivateApi = {
|
|
51
|
+
resetColSpan,
|
|
48
52
|
calculateColSpan
|
|
49
53
|
};
|
|
50
54
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, columnSpanningPublicApi, 'public');
|
|
51
55
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, columnSpanningPrivateApi, 'private');
|
|
52
|
-
|
|
53
|
-
// `colSpan` needs to be recalculated after column reordering
|
|
54
|
-
lookup.current = {};
|
|
55
|
-
}, []);
|
|
56
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnOrderChange', handleColumnReorderChange);
|
|
56
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnOrderChange', resetColSpan);
|
|
57
57
|
};
|
|
58
58
|
exports.useGridColumnSpanning = useGridColumnSpanning;
|
|
59
59
|
function calculateCellColSpan(params) {
|
|
@@ -7,14 +7,20 @@ exports.buildCSV = buildCSV;
|
|
|
7
7
|
exports.serializeCellValue = void 0;
|
|
8
8
|
var _colDef = require("../../../../colDef");
|
|
9
9
|
var _warning = require("../../../../utils/warning");
|
|
10
|
-
function sanitizeCellValue(value,
|
|
10
|
+
function sanitizeCellValue(value, csvOptions) {
|
|
11
11
|
if (typeof value === 'string') {
|
|
12
|
-
if (shouldAppendQuotes) {
|
|
12
|
+
if (csvOptions.shouldAppendQuotes || csvOptions.escapeFormulas) {
|
|
13
13
|
const escapedValue = value.replace(/"/g, '""');
|
|
14
|
-
// Make sure value containing delimiter or line break won't be split into multiple
|
|
15
|
-
if ([
|
|
14
|
+
// Make sure value containing delimiter or line break won't be split into multiple cells
|
|
15
|
+
if ([csvOptions.delimiter, '\n', '\r', '"'].some(delimiter => value.includes(delimiter))) {
|
|
16
16
|
return `"${escapedValue}"`;
|
|
17
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}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
18
24
|
return escapedValue;
|
|
19
25
|
}
|
|
20
26
|
return value;
|
|
@@ -23,9 +29,8 @@ function sanitizeCellValue(value, delimiterCharacter, shouldAppendQuotes) {
|
|
|
23
29
|
}
|
|
24
30
|
const serializeCellValue = (cellParams, options) => {
|
|
25
31
|
const {
|
|
26
|
-
|
|
27
|
-
ignoreValueFormatter
|
|
28
|
-
shouldAppendQuotes
|
|
32
|
+
csvOptions,
|
|
33
|
+
ignoreValueFormatter
|
|
29
34
|
} = options;
|
|
30
35
|
let value;
|
|
31
36
|
if (ignoreValueFormatter) {
|
|
@@ -42,7 +47,7 @@ const serializeCellValue = (cellParams, options) => {
|
|
|
42
47
|
} else {
|
|
43
48
|
value = cellParams.formattedValue;
|
|
44
49
|
}
|
|
45
|
-
return sanitizeCellValue(value,
|
|
50
|
+
return sanitizeCellValue(value, csvOptions);
|
|
46
51
|
};
|
|
47
52
|
exports.serializeCellValue = serializeCellValue;
|
|
48
53
|
const objectFormattedValueWarning = (0, _warning.buildWarning)(['MUI X: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
|
|
@@ -55,12 +60,12 @@ class CSVRow {
|
|
|
55
60
|
}
|
|
56
61
|
addValue(value) {
|
|
57
62
|
if (!this.isEmpty) {
|
|
58
|
-
this.rowString += this.options.
|
|
63
|
+
this.rowString += this.options.csvOptions.delimiter;
|
|
59
64
|
}
|
|
60
65
|
if (value === null || value === undefined) {
|
|
61
66
|
this.rowString += '';
|
|
62
67
|
} else if (typeof this.options.sanitizeCellValue === 'function') {
|
|
63
|
-
this.rowString += this.options.sanitizeCellValue(value, this.options.
|
|
68
|
+
this.rowString += this.options.sanitizeCellValue(value, this.options.csvOptions);
|
|
64
69
|
} else {
|
|
65
70
|
this.rowString += value;
|
|
66
71
|
}
|
|
@@ -74,13 +79,11 @@ const serializeRow = ({
|
|
|
74
79
|
id,
|
|
75
80
|
columns,
|
|
76
81
|
getCellParams,
|
|
77
|
-
|
|
78
|
-
ignoreValueFormatter
|
|
79
|
-
shouldAppendQuotes
|
|
82
|
+
csvOptions,
|
|
83
|
+
ignoreValueFormatter
|
|
80
84
|
}) => {
|
|
81
85
|
const row = new CSVRow({
|
|
82
|
-
|
|
83
|
-
shouldAppendQuotes
|
|
86
|
+
csvOptions
|
|
84
87
|
});
|
|
85
88
|
columns.forEach(column => {
|
|
86
89
|
const cellParams = getCellParams(id, column.field);
|
|
@@ -90,9 +93,8 @@ const serializeRow = ({
|
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
row.addValue(serializeCellValue(cellParams, {
|
|
93
|
-
delimiterCharacter,
|
|
94
96
|
ignoreValueFormatter,
|
|
95
|
-
|
|
97
|
+
csvOptions
|
|
96
98
|
}));
|
|
97
99
|
});
|
|
98
100
|
return row.getRowString();
|
|
@@ -101,27 +103,23 @@ function buildCSV(options) {
|
|
|
101
103
|
const {
|
|
102
104
|
columns,
|
|
103
105
|
rowIds,
|
|
104
|
-
|
|
105
|
-
includeHeaders,
|
|
106
|
-
includeColumnGroupsHeaders,
|
|
106
|
+
csvOptions,
|
|
107
107
|
ignoreValueFormatter,
|
|
108
|
-
apiRef
|
|
109
|
-
shouldAppendQuotes
|
|
108
|
+
apiRef
|
|
110
109
|
} = options;
|
|
111
110
|
const CSVBody = rowIds.reduce((acc, id) => `${acc}${serializeRow({
|
|
112
111
|
id,
|
|
113
112
|
columns,
|
|
114
113
|
getCellParams: apiRef.current.getCellParams,
|
|
115
|
-
delimiterCharacter,
|
|
116
114
|
ignoreValueFormatter,
|
|
117
|
-
|
|
115
|
+
csvOptions
|
|
118
116
|
})}\r\n`, '').trim();
|
|
119
|
-
if (!includeHeaders) {
|
|
117
|
+
if (!csvOptions.includeHeaders) {
|
|
120
118
|
return CSVBody;
|
|
121
119
|
}
|
|
122
120
|
const filteredColumns = columns.filter(column => column.field !== _colDef.GRID_CHECKBOX_SELECTION_COL_DEF.field);
|
|
123
121
|
const headerRows = [];
|
|
124
|
-
if (includeColumnGroupsHeaders) {
|
|
122
|
+
if (csvOptions.includeColumnGroupsHeaders) {
|
|
125
123
|
const columnGroupLookup = apiRef.current.getAllGroupDetails();
|
|
126
124
|
let maxColumnGroupsDepth = 0;
|
|
127
125
|
const columnGroupPathsLookup = filteredColumns.reduce((acc, column) => {
|
|
@@ -132,9 +130,8 @@ function buildCSV(options) {
|
|
|
132
130
|
}, {});
|
|
133
131
|
for (let i = 0; i < maxColumnGroupsDepth; i += 1) {
|
|
134
132
|
const headerGroupRow = new CSVRow({
|
|
135
|
-
|
|
136
|
-
sanitizeCellValue
|
|
137
|
-
shouldAppendQuotes
|
|
133
|
+
csvOptions,
|
|
134
|
+
sanitizeCellValue
|
|
138
135
|
});
|
|
139
136
|
headerRows.push(headerGroupRow);
|
|
140
137
|
filteredColumns.forEach(column => {
|
|
@@ -145,9 +142,8 @@ function buildCSV(options) {
|
|
|
145
142
|
}
|
|
146
143
|
}
|
|
147
144
|
const mainHeaderRow = new CSVRow({
|
|
148
|
-
|
|
149
|
-
sanitizeCellValue
|
|
150
|
-
shouldAppendQuotes
|
|
145
|
+
csvOptions,
|
|
146
|
+
sanitizeCellValue
|
|
151
147
|
});
|
|
152
148
|
filteredColumns.forEach(column => {
|
|
153
149
|
mainHeaderRow.addValue(column.headerName || column.field);
|
|
@@ -39,12 +39,15 @@ const useGridCsvExport = (apiRef, props) => {
|
|
|
39
39
|
return (0, _csvSerializer.buildCSV)({
|
|
40
40
|
columns: exportedColumns,
|
|
41
41
|
rowIds: exportedRowIds,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
csvOptions: {
|
|
43
|
+
delimiter: options.delimiter || ',',
|
|
44
|
+
shouldAppendQuotes: options.shouldAppendQuotes ?? true,
|
|
45
|
+
includeHeaders: options.includeHeaders ?? true,
|
|
46
|
+
includeColumnGroupsHeaders: options.includeColumnGroupsHeaders ?? true,
|
|
47
|
+
escapeFormulas: options.escapeFormulas ?? true
|
|
48
|
+
},
|
|
45
49
|
ignoreValueFormatter,
|
|
46
|
-
apiRef
|
|
47
|
-
shouldAppendQuotes: options.shouldAppendQuotes ?? true
|
|
50
|
+
apiRef
|
|
48
51
|
});
|
|
49
52
|
}, [logger, apiRef, ignoreValueFormatter]);
|
|
50
53
|
const exportDataAsCsv = React.useCallback(options => {
|
|
@@ -54,7 +54,14 @@ const createScrollCache = (mode, rowBufferPx, columnBufferPx, verticalBuffer, ho
|
|
|
54
54
|
direction: ScrollDirection.NONE,
|
|
55
55
|
buffer: bufferForDirection(mode, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
|
|
56
56
|
});
|
|
57
|
-
|
|
57
|
+
let isJSDOM = false;
|
|
58
|
+
try {
|
|
59
|
+
if (typeof window !== 'undefined') {
|
|
60
|
+
isJSDOM = /jsdom/.test(window.navigator.userAgent);
|
|
61
|
+
}
|
|
62
|
+
} catch (_) {
|
|
63
|
+
/* ignore */
|
|
64
|
+
}
|
|
58
65
|
const useGridVirtualScroller = () => {
|
|
59
66
|
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
60
67
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
package/node/index.js
CHANGED
package/node/locales/faIR.js
CHANGED
|
@@ -9,7 +9,7 @@ var _getGridLocalization = require("../utils/getGridLocalization");
|
|
|
9
9
|
const faIRGrid = {
|
|
10
10
|
// Root
|
|
11
11
|
noRowsLabel: 'بدون سطر',
|
|
12
|
-
noResultsOverlayLabel: '
|
|
12
|
+
noResultsOverlayLabel: 'نتیجهای پیدا نشد.',
|
|
13
13
|
// Density selector toolbar button text
|
|
14
14
|
toolbarDensity: 'تراکم',
|
|
15
15
|
toolbarDensityLabel: 'تراکم',
|
|
@@ -103,12 +103,12 @@ const faIRGrid = {
|
|
|
103
103
|
columnMenuFilter: 'فیلتر',
|
|
104
104
|
columnMenuHideColumn: 'مخفی',
|
|
105
105
|
columnMenuUnsort: 'نامرتبکردن',
|
|
106
|
-
columnMenuSortAsc: '
|
|
107
|
-
columnMenuSortDesc: '
|
|
106
|
+
columnMenuSortAsc: 'مرتبسازی صعودی',
|
|
107
|
+
columnMenuSortDesc: 'مرتبسازی نزولی',
|
|
108
108
|
// Column header text
|
|
109
109
|
columnHeaderFiltersTooltipActive: count => count !== 1 ? `${count} فیلترهای فعال` : `${count} فیلتر فعال`,
|
|
110
110
|
columnHeaderFiltersLabel: 'نمایش فیلترها',
|
|
111
|
-
columnHeaderSortIconLabel: '
|
|
111
|
+
columnHeaderSortIconLabel: 'مرتبسازی',
|
|
112
112
|
// Rows selected footer text
|
|
113
113
|
footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} سطرهای انتخاب شده` : `${count.toLocaleString()} سطر انتخاب شده`,
|
|
114
114
|
// Total row amount footer text
|
package/node/locales/fiFI.js
CHANGED
|
@@ -36,11 +36,10 @@ const fiFIGrid = {
|
|
|
36
36
|
toolbarExportPrint: 'Tulosta',
|
|
37
37
|
toolbarExportExcel: 'Lataa Excel-muodossa',
|
|
38
38
|
// Columns management text
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
columnsManagementSearchTitle: 'Hae',
|
|
40
|
+
columnsManagementNoColumns: 'Ei sarakkeita näytettäväksi',
|
|
41
|
+
columnsManagementShowHideAllText: 'Näytä/Piilota kaikki',
|
|
42
|
+
columnsManagementReset: 'Palauta',
|
|
44
43
|
// Filter panel text
|
|
45
44
|
filterPanelAddFilter: 'Lisää suodatin',
|
|
46
45
|
filterPanelRemoveAll: 'Poista kaikki',
|
package/node/utils/domUtils.js
CHANGED
|
@@ -79,8 +79,7 @@ function findHeaderElementFromField(elem, field) {
|
|
|
79
79
|
return elem.querySelector(`[data-field="${field}"]`);
|
|
80
80
|
}
|
|
81
81
|
function getFieldsFromGroupHeaderElem(colCellEl) {
|
|
82
|
-
|
|
83
|
-
return fieldsString?.startsWith('|-') ? fieldsString.slice(2, -2).split('-|-') : [];
|
|
82
|
+
return colCellEl.getAttribute('data-fields').slice(2, -2).split('-|-');
|
|
84
83
|
}
|
|
85
84
|
function findGroupHeaderElementsFromField(elem, field) {
|
|
86
85
|
return Array.from(elem.querySelectorAll(`[data-fields*="|-${field}-|"]`) ?? []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.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",
|
|
@@ -37,8 +37,9 @@
|
|
|
37
37
|
"directory": "packages/x-data-grid"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@babel/runtime": "^7.24.
|
|
41
|
-
"@mui/
|
|
40
|
+
"@babel/runtime": "^7.24.6",
|
|
41
|
+
"@mui/internal-test-utils": "1.0.0-dev.20240529-082515-213b5e33ab",
|
|
42
|
+
"@mui/system": "^5.15.15",
|
|
42
43
|
"@mui/utils": "^5.15.14",
|
|
43
44
|
"clsx": "^2.1.1",
|
|
44
45
|
"prop-types": "^15.8.1",
|
package/utils/domUtils.js
CHANGED
|
@@ -54,8 +54,7 @@ export function findHeaderElementFromField(elem, field) {
|
|
|
54
54
|
return elem.querySelector(`[data-field="${field}"]`);
|
|
55
55
|
}
|
|
56
56
|
export function getFieldsFromGroupHeaderElem(colCellEl) {
|
|
57
|
-
|
|
58
|
-
return fieldsString?.startsWith('|-') ? fieldsString.slice(2, -2).split('-|-') : [];
|
|
57
|
+
return colCellEl.getAttribute('data-fields').slice(2, -2).split('-|-');
|
|
59
58
|
}
|
|
60
59
|
export function findGroupHeaderElementsFromField(elem, field) {
|
|
61
60
|
return Array.from(elem.querySelectorAll(`[data-fields*="|-${field}-|"]`) ?? []);
|