@mui/x-data-grid 6.3.0 → 6.4.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 +105 -2
- package/DataGrid/DataGrid.js +20 -1
- package/DataGrid/useDataGridComponent.js +2 -2
- package/DataGrid/useDataGridProps.js +3 -1
- package/colDef/gridBooleanColDef.js +19 -1
- package/colDef/gridDateColDef.js +6 -2
- package/colDef/gridSingleSelectColDef.js +21 -1
- package/components/GridPagination.js +3 -1
- package/components/base/GridBody.d.ts +1 -0
- package/components/base/GridBody.js +6 -3
- package/components/containers/GridRootStyles.js +1 -0
- package/components/panel/GridPanel.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/components/toolbar/GridToolbarFilterButton.js +3 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +12 -1
- package/hooks/features/clipboard/useGridClipboard.d.ts +2 -1
- package/hooks/features/clipboard/useGridClipboard.js +43 -26
- package/hooks/features/dimensions/useGridDimensions.js +2 -4
- package/hooks/features/editing/useGridCellEditing.js +7 -3
- package/hooks/features/editing/useGridRowEditing.js +7 -3
- package/hooks/features/export/serializers/csvSerializer.d.ts +5 -0
- package/hooks/features/export/serializers/csvSerializer.js +46 -6
- package/hooks/features/export/useGridCsvExport.d.ts +2 -1
- package/hooks/features/export/useGridCsvExport.js +7 -5
- package/hooks/features/focus/useGridFocus.js +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
- package/index.js +1 -1
- package/internals/index.d.ts +3 -2
- package/internals/index.js +3 -2
- package/joy/icons.d.ts +33 -0
- package/joy/icons.js +433 -0
- package/joy/joySlots.js +254 -42
- package/legacy/DataGrid/DataGrid.js +20 -1
- package/legacy/DataGrid/useDataGridComponent.js +2 -2
- package/legacy/DataGrid/useDataGridProps.js +3 -1
- package/legacy/colDef/gridBooleanColDef.js +21 -1
- package/legacy/colDef/gridDateColDef.js +10 -2
- package/legacy/colDef/gridSingleSelectColDef.js +21 -1
- package/legacy/components/GridPagination.js +3 -1
- package/legacy/components/base/GridBody.js +6 -3
- package/legacy/components/containers/GridRootStyles.js +1 -0
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/legacy/components/toolbar/GridToolbarFilterButton.js +3 -1
- package/legacy/hooks/features/clipboard/useGridClipboard.js +44 -26
- package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -4
- package/legacy/hooks/features/editing/useGridCellEditing.js +7 -3
- package/legacy/hooks/features/editing/useGridRowEditing.js +7 -3
- package/legacy/hooks/features/export/serializers/csvSerializer.js +43 -6
- package/legacy/hooks/features/export/useGridCsvExport.js +8 -5
- package/legacy/hooks/features/focus/useGridFocus.js +2 -2
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +3 -2
- package/legacy/joy/icons.js +432 -0
- package/legacy/joy/joySlots.js +273 -54
- package/legacy/locales/deDE.js +2 -2
- package/legacy/locales/frFR.js +6 -6
- package/legacy/locales/ptBR.js +1 -1
- package/legacy/locales/ukUA.js +8 -9
- package/legacy/material/index.js +3 -1
- package/legacy/models/api/index.js +0 -1
- package/legacy/utils/domUtils.js +14 -1
- package/locales/deDE.js +2 -2
- package/locales/frFR.js +6 -6
- package/locales/ptBR.js +1 -1
- package/locales/ukUA.js +8 -9
- package/material/index.d.ts +3 -1
- package/material/index.js +3 -1
- package/models/api/gridApiCommon.d.ts +1 -2
- package/models/api/gridCoreApi.d.ts +4 -0
- package/models/api/index.d.ts +0 -1
- package/models/api/index.js +0 -1
- package/models/events/gridEventLookup.d.ts +6 -0
- package/models/gridSlotsComponent.d.ts +5 -0
- package/models/gridSlotsComponentsProps.d.ts +4 -0
- package/models/props/DataGridProps.d.ts +19 -0
- package/modern/DataGrid/DataGrid.js +20 -1
- package/modern/DataGrid/useDataGridComponent.js +2 -2
- package/modern/DataGrid/useDataGridProps.js +3 -1
- package/modern/colDef/gridBooleanColDef.js +19 -1
- package/modern/colDef/gridDateColDef.js +6 -2
- package/modern/colDef/gridSingleSelectColDef.js +21 -1
- package/modern/components/GridPagination.js +2 -1
- package/modern/components/base/GridBody.js +6 -3
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/modern/components/toolbar/GridToolbarFilterButton.js +3 -1
- package/modern/hooks/features/clipboard/useGridClipboard.js +43 -26
- package/modern/hooks/features/dimensions/useGridDimensions.js +1 -3
- package/modern/hooks/features/editing/useGridCellEditing.js +7 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +7 -3
- package/modern/hooks/features/export/serializers/csvSerializer.js +44 -6
- package/modern/hooks/features/export/useGridCsvExport.js +7 -5
- package/modern/hooks/features/focus/useGridFocus.js +2 -2
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +3 -2
- package/modern/joy/icons.js +433 -0
- package/modern/joy/joySlots.js +248 -41
- package/modern/locales/deDE.js +2 -2
- package/modern/locales/frFR.js +6 -6
- package/modern/locales/ptBR.js +1 -1
- package/modern/locales/ukUA.js +8 -9
- package/modern/material/index.js +3 -1
- package/modern/models/api/index.js +0 -1
- package/modern/utils/domUtils.js +13 -1
- package/node/DataGrid/DataGrid.js +20 -1
- package/node/DataGrid/useDataGridComponent.js +2 -2
- package/node/DataGrid/useDataGridProps.js +3 -1
- package/node/colDef/gridBooleanColDef.js +19 -1
- package/node/colDef/gridDateColDef.js +6 -2
- package/node/colDef/gridSingleSelectColDef.js +21 -1
- package/node/components/GridPagination.js +2 -1
- package/node/components/base/GridBody.js +6 -3
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/node/components/toolbar/GridToolbarFilterButton.js +3 -1
- package/node/hooks/features/clipboard/useGridClipboard.js +42 -25
- package/node/hooks/features/dimensions/useGridDimensions.js +1 -3
- package/node/hooks/features/editing/useGridCellEditing.js +7 -3
- package/node/hooks/features/editing/useGridRowEditing.js +7 -3
- package/node/hooks/features/export/serializers/csvSerializer.js +46 -6
- package/node/hooks/features/export/useGridCsvExport.js +6 -3
- package/node/hooks/features/focus/useGridFocus.js +2 -2
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +23 -1
- package/node/joy/icons.js +471 -0
- package/node/joy/joySlots.js +248 -40
- package/node/locales/deDE.js +2 -2
- package/node/locales/frFR.js +6 -6
- package/node/locales/ptBR.js +1 -1
- package/node/locales/ukUA.js +8 -9
- package/node/material/index.js +3 -1
- package/node/models/api/index.js +0 -11
- package/node/utils/domUtils.js +15 -1
- package/package.json +2 -2
- package/utils/domUtils.d.ts +1 -0
- package/utils/domUtils.js +13 -1
- package/legacy/models/api/gridClipboardApi.js +0 -1
- package/models/api/gridClipboardApi.d.ts +0 -11
- package/models/api/gridClipboardApi.js +0 -1
- package/modern/models/api/gridClipboardApi.js +0 -1
- package/node/models/api/gridClipboardApi.js +0 -5
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
+
import { useGridApiOptionHandler, useGridNativeEventListener } from '../../utils';
|
|
4
|
+
import { gridFocusCellSelector } from '../focus/gridFocusStateSelector';
|
|
5
|
+
import { serializeCellValue } from '../export/serializers/csvSerializer';
|
|
3
6
|
function writeToClipboardPolyfill(data) {
|
|
4
7
|
var span = document.createElement('span');
|
|
5
8
|
span.style.whiteSpace = 'pre';
|
|
@@ -18,6 +21,15 @@ function writeToClipboardPolyfill(data) {
|
|
|
18
21
|
document.body.removeChild(span);
|
|
19
22
|
}
|
|
20
23
|
}
|
|
24
|
+
function copyToClipboard(data) {
|
|
25
|
+
if (navigator.clipboard) {
|
|
26
|
+
navigator.clipboard.writeText(data).catch(function () {
|
|
27
|
+
writeToClipboardPolyfill(data);
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
writeToClipboardPolyfill(data);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
21
33
|
function hasNativeSelection(element) {
|
|
22
34
|
var _window$getSelection;
|
|
23
35
|
// When getSelection is called on an <iframe> that is not displayed Firefox will return null.
|
|
@@ -38,24 +50,11 @@ function hasNativeSelection(element) {
|
|
|
38
50
|
* @requires useGridCsvExport (method)
|
|
39
51
|
* @requires useGridSelection (method)
|
|
40
52
|
*/
|
|
41
|
-
export var useGridClipboard = function useGridClipboard(apiRef) {
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var data = apiRef.current.getDataAsCsv({
|
|
47
|
-
includeHeaders: false,
|
|
48
|
-
delimiter: '\t'
|
|
49
|
-
});
|
|
50
|
-
if (navigator.clipboard) {
|
|
51
|
-
navigator.clipboard.writeText(data).catch(function () {
|
|
52
|
-
writeToClipboardPolyfill(data);
|
|
53
|
-
});
|
|
54
|
-
} else {
|
|
55
|
-
writeToClipboardPolyfill(data);
|
|
56
|
-
}
|
|
57
|
-
}, [apiRef]);
|
|
58
|
-
var handleKeydown = React.useCallback(function (event) {
|
|
53
|
+
export var useGridClipboard = function useGridClipboard(apiRef, props) {
|
|
54
|
+
var ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
|
|
55
|
+
var ignoreValueFormatter = (_typeof(ignoreValueFormatterProp) === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.clipboardExport : ignoreValueFormatterProp) || false;
|
|
56
|
+
var clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
|
|
57
|
+
var handleCopy = React.useCallback(function (event) {
|
|
59
58
|
var isModifierKeyPressed = event.ctrlKey || event.metaKey;
|
|
60
59
|
// event.code === 'KeyC' is not enough as event.code assume a QWERTY keyboard layout which would
|
|
61
60
|
// be wrong with a Dvorak keyboard (as if pressing J).
|
|
@@ -67,11 +66,30 @@ export var useGridClipboard = function useGridClipboard(apiRef) {
|
|
|
67
66
|
if (hasNativeSelection(event.target)) {
|
|
68
67
|
return;
|
|
69
68
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
var textToCopy = '';
|
|
70
|
+
var selectedRows = apiRef.current.getSelectedRows();
|
|
71
|
+
if (selectedRows.size > 0) {
|
|
72
|
+
textToCopy = apiRef.current.getDataAsCsv({
|
|
73
|
+
includeHeaders: false,
|
|
74
|
+
// TODO: make it configurable
|
|
75
|
+
delimiter: clipboardCopyCellDelimiter
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
var focusedCell = gridFocusCellSelector(apiRef);
|
|
79
|
+
if (focusedCell) {
|
|
80
|
+
var cellParams = apiRef.current.getCellParams(focusedCell.id, focusedCell.field);
|
|
81
|
+
textToCopy = serializeCellValue(cellParams, {
|
|
82
|
+
delimiterCharacter: clipboardCopyCellDelimiter,
|
|
83
|
+
ignoreValueFormatter: ignoreValueFormatter
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
textToCopy = apiRef.current.unstable_applyPipeProcessors('clipboardCopy', textToCopy);
|
|
88
|
+
if (textToCopy) {
|
|
89
|
+
copyToClipboard(textToCopy);
|
|
90
|
+
apiRef.current.publishEvent('clipboardCopy', textToCopy);
|
|
91
|
+
}
|
|
92
|
+
}, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
|
|
93
|
+
useGridNativeEventListener(apiRef, apiRef.current.rootElementRef, 'keydown', handleCopy);
|
|
94
|
+
useGridApiOptionHandler(apiRef, 'clipboardCopy', props.onClipboardCopy);
|
|
77
95
|
};
|
|
@@ -11,7 +11,6 @@ import { getVisibleRows } from '../../utils/useGridVisibleRows';
|
|
|
11
11
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
12
12
|
import { calculatePinnedRowsHeight } from '../rows/gridRowsUtils';
|
|
13
13
|
import { getTotalHeaderHeight } from '../columns/gridColumnsUtils';
|
|
14
|
-
import { gridClasses } from '../../../constants/gridClasses';
|
|
15
14
|
var isTestEnvironment = process.env.NODE_ENV === 'test';
|
|
16
15
|
var hasScroll = function hasScroll(_ref) {
|
|
17
16
|
var content = _ref.content,
|
|
@@ -158,9 +157,8 @@ export function useGridDimensions(apiRef, props) {
|
|
|
158
157
|
return Math.min(maximumPageSizeWithoutScrollBar, currentPage.rows.length);
|
|
159
158
|
}, [apiRef, props.pagination, props.paginationMode, props.getRowHeight, rowHeight]);
|
|
160
159
|
var computeSizeAndPublishResizeEvent = React.useCallback(function () {
|
|
161
|
-
var _apiRef$current$
|
|
162
|
-
var
|
|
163
|
-
var mainEl = rootEl == null ? void 0 : rootEl.querySelector(".".concat(gridClasses.main));
|
|
160
|
+
var _apiRef$current$mainE, _previousSize$current, _previousSize$current2;
|
|
161
|
+
var mainEl = (_apiRef$current$mainE = apiRef.current.mainElementRef) == null ? void 0 : _apiRef$current$mainE.current;
|
|
164
162
|
if (!mainEl) {
|
|
165
163
|
return;
|
|
166
164
|
}
|
|
@@ -97,10 +97,14 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
97
97
|
}
|
|
98
98
|
} else if (params.isEditable) {
|
|
99
99
|
var _reason;
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
var canStartEditing = apiRef.current.unstable_applyPipeProcessors('canStartEditing', true, {
|
|
101
|
+
event: event,
|
|
102
|
+
cellParams: params,
|
|
103
|
+
editMode: 'cell'
|
|
104
|
+
});
|
|
105
|
+
if (!canStartEditing) {
|
|
106
|
+
return;
|
|
102
107
|
}
|
|
103
|
-
|
|
104
108
|
if (isPrintableKey(event)) {
|
|
105
109
|
_reason = GridCellEditStartReasons.printableKeyDown;
|
|
106
110
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
@@ -153,10 +153,14 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
153
153
|
}
|
|
154
154
|
} else if (params.isEditable) {
|
|
155
155
|
var _reason;
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
var canStartEditing = apiRef.current.unstable_applyPipeProcessors('canStartEditing', true, {
|
|
157
|
+
event: event,
|
|
158
|
+
cellParams: params,
|
|
159
|
+
editMode: 'row'
|
|
160
|
+
});
|
|
161
|
+
if (!canStartEditing) {
|
|
162
|
+
return;
|
|
158
163
|
}
|
|
159
|
-
|
|
160
164
|
if (isPrintableKey(event)) {
|
|
161
165
|
_reason = GridRowEditStartReasons.printableKeyDown;
|
|
162
166
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../../colDef';
|
|
2
2
|
import { buildWarning } from '../../../../utils/warning';
|
|
3
|
-
|
|
3
|
+
function sanitizeCellValue(value, delimiterCharacter) {
|
|
4
4
|
if (typeof value === 'string') {
|
|
5
5
|
var formattedValue = value.replace(/"/g, '""');
|
|
6
6
|
|
|
@@ -13,9 +13,36 @@ var serializeCellValue = function serializeCellValue(value, delimiterCharacter)
|
|
|
13
13
|
return formattedValue;
|
|
14
14
|
}
|
|
15
15
|
return value;
|
|
16
|
+
}
|
|
17
|
+
export var serializeCellValue = function serializeCellValue(cellParams, options) {
|
|
18
|
+
var delimiterCharacter = options.delimiterCharacter,
|
|
19
|
+
ignoreValueFormatter = options.ignoreValueFormatter;
|
|
20
|
+
var value;
|
|
21
|
+
if (ignoreValueFormatter) {
|
|
22
|
+
var _cellParams$value2;
|
|
23
|
+
var columnType = cellParams.colDef.type;
|
|
24
|
+
if (columnType === 'number') {
|
|
25
|
+
value = String(cellParams.value);
|
|
26
|
+
} else if (columnType === 'date' || columnType === 'dateTime') {
|
|
27
|
+
var _cellParams$value;
|
|
28
|
+
value = (_cellParams$value = cellParams.value) == null ? void 0 : _cellParams$value.toISOString();
|
|
29
|
+
} else if (typeof ((_cellParams$value2 = cellParams.value) == null ? void 0 : _cellParams$value2.toString) === 'function') {
|
|
30
|
+
value = cellParams.value.toString();
|
|
31
|
+
} else {
|
|
32
|
+
value = cellParams.value;
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
value = cellParams.formattedValue;
|
|
36
|
+
}
|
|
37
|
+
return sanitizeCellValue(value, delimiterCharacter);
|
|
16
38
|
};
|
|
17
39
|
var objectFormattedValueWarning = buildWarning(['MUI: 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.']);
|
|
18
|
-
var serializeRow = function serializeRow(
|
|
40
|
+
var serializeRow = function serializeRow(_ref) {
|
|
41
|
+
var id = _ref.id,
|
|
42
|
+
columns = _ref.columns,
|
|
43
|
+
getCellParams = _ref.getCellParams,
|
|
44
|
+
delimiterCharacter = _ref.delimiterCharacter,
|
|
45
|
+
ignoreValueFormatter = _ref.ignoreValueFormatter;
|
|
19
46
|
return columns.map(function (column) {
|
|
20
47
|
var cellParams = getCellParams(id, column.field);
|
|
21
48
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -23,7 +50,10 @@ var serializeRow = function serializeRow(id, columns, getCellParams, delimiterCh
|
|
|
23
50
|
objectFormattedValueWarning();
|
|
24
51
|
}
|
|
25
52
|
}
|
|
26
|
-
return serializeCellValue(cellParams
|
|
53
|
+
return serializeCellValue(cellParams, {
|
|
54
|
+
delimiterCharacter: delimiterCharacter,
|
|
55
|
+
ignoreValueFormatter: ignoreValueFormatter
|
|
56
|
+
});
|
|
27
57
|
});
|
|
28
58
|
};
|
|
29
59
|
export function buildCSV(options) {
|
|
@@ -31,9 +61,16 @@ export function buildCSV(options) {
|
|
|
31
61
|
rowIds = options.rowIds,
|
|
32
62
|
getCellParams = options.getCellParams,
|
|
33
63
|
delimiterCharacter = options.delimiterCharacter,
|
|
34
|
-
includeHeaders = options.includeHeaders
|
|
64
|
+
includeHeaders = options.includeHeaders,
|
|
65
|
+
ignoreValueFormatter = options.ignoreValueFormatter;
|
|
35
66
|
var CSVBody = rowIds.reduce(function (acc, id) {
|
|
36
|
-
return "".concat(acc).concat(serializeRow(
|
|
67
|
+
return "".concat(acc).concat(serializeRow({
|
|
68
|
+
id: id,
|
|
69
|
+
columns: columns,
|
|
70
|
+
getCellParams: getCellParams,
|
|
71
|
+
delimiterCharacter: delimiterCharacter,
|
|
72
|
+
ignoreValueFormatter: ignoreValueFormatter
|
|
73
|
+
}).join(delimiterCharacter), "\r\n");
|
|
37
74
|
}, '').trim();
|
|
38
75
|
if (!includeHeaders) {
|
|
39
76
|
return CSVBody;
|
|
@@ -41,7 +78,7 @@ export function buildCSV(options) {
|
|
|
41
78
|
var CSVHead = "".concat(columns.filter(function (column) {
|
|
42
79
|
return column.field !== GRID_CHECKBOX_SELECTION_COL_DEF.field;
|
|
43
80
|
}).map(function (column) {
|
|
44
|
-
return
|
|
81
|
+
return sanitizeCellValue(column.headerName || column.field, delimiterCharacter);
|
|
45
82
|
}).join(delimiterCharacter), "\r\n");
|
|
46
83
|
return "".concat(CSVHead).concat(CSVBody).trim();
|
|
47
84
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
5
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
@@ -7,7 +8,7 @@ import { buildCSV } from './serializers/csvSerializer';
|
|
|
7
8
|
import { getColumnsToExport, defaultGetRowsToExport } from './utils';
|
|
8
9
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
9
10
|
import { GridCsvExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
|
|
10
|
-
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
/**
|
|
12
13
|
* @requires useGridColumns (state)
|
|
13
14
|
* @requires useGridFilter (state)
|
|
@@ -15,9 +16,10 @@ import { GridCsvExportMenuItem } from '../../../components/toolbar/GridToolbarEx
|
|
|
15
16
|
* @requires useGridSelection (state)
|
|
16
17
|
* @requires useGridParamsApi (method)
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
-
export var useGridCsvExport = function useGridCsvExport(apiRef) {
|
|
19
|
+
export var useGridCsvExport = function useGridCsvExport(apiRef, props) {
|
|
20
20
|
var logger = useGridLogger(apiRef, 'useGridCsvExport');
|
|
21
|
+
var ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
|
|
22
|
+
var ignoreValueFormatter = (_typeof(ignoreValueFormatterProp) === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.csvExport : ignoreValueFormatterProp) || false;
|
|
21
23
|
var getDataAsCsv = React.useCallback(function () {
|
|
22
24
|
var _options$getRowsToExp, _options$includeHeade;
|
|
23
25
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -35,9 +37,10 @@ export var useGridCsvExport = function useGridCsvExport(apiRef) {
|
|
|
35
37
|
rowIds: exportedRowIds,
|
|
36
38
|
getCellParams: apiRef.current.getCellParams,
|
|
37
39
|
delimiterCharacter: options.delimiter || ',',
|
|
38
|
-
includeHeaders: (_options$includeHeade = options.includeHeaders) != null ? _options$includeHeade : true
|
|
40
|
+
includeHeaders: (_options$includeHeade = options.includeHeaders) != null ? _options$includeHeade : true,
|
|
41
|
+
ignoreValueFormatter: ignoreValueFormatter
|
|
39
42
|
});
|
|
40
|
-
}, [logger, apiRef]);
|
|
43
|
+
}, [logger, apiRef, ignoreValueFormatter]);
|
|
41
44
|
var exportDataAsCsv = React.useCallback(function (options) {
|
|
42
45
|
logger.debug("Export data as CSV");
|
|
43
46
|
var csv = getDataAsCsv(options);
|
|
@@ -307,9 +307,9 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
307
307
|
useGridApiMethod(apiRef, focusPrivateApi, 'private');
|
|
308
308
|
React.useEffect(function () {
|
|
309
309
|
var doc = ownerDocument(apiRef.current.rootElementRef.current);
|
|
310
|
-
doc.addEventListener('
|
|
310
|
+
doc.addEventListener('mouseup', handleDocumentClick);
|
|
311
311
|
return function () {
|
|
312
|
-
doc.removeEventListener('
|
|
312
|
+
doc.removeEventListener('mouseup', handleDocumentClick);
|
|
313
313
|
};
|
|
314
314
|
}, [apiRef, handleDocumentClick]);
|
|
315
315
|
useGridApiEventHandler(apiRef, 'columnHeaderBlur', handleBlur);
|
|
@@ -15,6 +15,7 @@ import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
|
15
15
|
import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
|
|
16
16
|
import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
|
|
17
17
|
import { useGridSelector } from '../../utils/useGridSelector';
|
|
18
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
18
19
|
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
19
20
|
var pinnedRows = gridPinnedRowsSelector(apiRef) || {};
|
|
20
21
|
return [].concat(_toConsumableArray(pinnedRows.top || []), _toConsumableArray(rows), _toConsumableArray(pinnedRows.bottom || []));
|
|
@@ -450,6 +451,15 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
450
451
|
event.preventDefault();
|
|
451
452
|
}
|
|
452
453
|
}, [apiRef, currentPageRows, theme.direction, getRowIdFromIndex, goToCell, goToHeader]);
|
|
454
|
+
var checkIfCanStartEditing = React.useCallback(function (initialValue, _ref3) {
|
|
455
|
+
var event = _ref3.event;
|
|
456
|
+
if (event.key === ' ') {
|
|
457
|
+
// Space scrolls to the last row
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
return initialValue;
|
|
461
|
+
}, []);
|
|
462
|
+
useGridRegisterPipeProcessor(apiRef, 'canStartEditing', checkIfCanStartEditing);
|
|
453
463
|
useGridApiEventHandler(apiRef, 'columnHeaderKeyDown', handleColumnHeaderKeyDown);
|
|
454
464
|
useGridApiEventHandler(apiRef, 'columnGroupHeaderKeyDown', handleColumnGroupHeaderKeyDown);
|
|
455
465
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
package/legacy/index.js
CHANGED
|
@@ -41,14 +41,15 @@ export { useGridEvents } from '../hooks/features/events/useGridEvents';
|
|
|
41
41
|
export { useGridDimensions } from '../hooks/features/dimensions/useGridDimensions';
|
|
42
42
|
export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
|
|
43
43
|
export { useGridVirtualScroller, getRenderableIndexes } from '../hooks/features/virtualization/useGridVirtualScroller';
|
|
44
|
-
export { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
|
|
44
|
+
export { useGridVisibleRows, getVisibleRows } from '../hooks/utils/useGridVisibleRows';
|
|
45
45
|
export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
|
|
46
46
|
export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
|
|
47
47
|
export { createSelector, unstable_resetCreateSelectorCache } from '../utils/createSelector';
|
|
48
|
-
export { findParentElementFromClassName } from '../utils/domUtils';
|
|
48
|
+
export { findParentElementFromClassName, getActiveElement } from '../utils/domUtils';
|
|
49
49
|
export { isNavigationKey } from '../utils/keyboardUtils';
|
|
50
50
|
export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
|
|
51
51
|
export { buildWarning } from '../utils/warning';
|
|
52
52
|
export { exportAs } from '../utils/exportAs';
|
|
53
53
|
export { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
|
|
54
|
+
export { serializeCellValue } from '../hooks/features/export/serializers/csvSerializer';
|
|
54
55
|
export * from './utils';
|