@mui/x-data-grid 6.3.1 → 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 +57 -0
- 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/base/GridBody.js +2 -1
- package/components/containers/GridRootStyles.js +1 -0
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- 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/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 +114 -4
- 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/base/GridBody.js +2 -1
- 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/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/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 +118 -4
- 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 +1 -0
- 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/base/GridBody.js +2 -1
- 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/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/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 +110 -4
- 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/base/GridBody.js +2 -1
- 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/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/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 +110 -3
- 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 +1 -1
- 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
package/modern/joy/joySlots.js
CHANGED
|
@@ -18,7 +18,13 @@ import JoyIconButton from '@mui/joy/IconButton';
|
|
|
18
18
|
import JoySwitch from '@mui/joy/Switch';
|
|
19
19
|
import JoySelect from '@mui/joy/Select';
|
|
20
20
|
import JoyOption from '@mui/joy/Option';
|
|
21
|
+
import JoyBox from '@mui/joy/Box';
|
|
22
|
+
import JoyTypography from '@mui/joy/Typography';
|
|
21
23
|
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
|
24
|
+
import joyIconSlots, { GridKeyboardArrowRight, GridKeyboardArrowLeft } from './icons';
|
|
25
|
+
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
26
|
+
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
27
|
+
import { gridFilteredTopLevelRowCountSelector, gridPaginationModelSelector } from '../hooks';
|
|
22
28
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
29
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
30
|
function convertColor(color) {
|
|
@@ -261,7 +267,107 @@ const InputLabel = /*#__PURE__*/React.forwardRef((_ref8, ref) => {
|
|
|
261
267
|
sx: sx
|
|
262
268
|
}));
|
|
263
269
|
});
|
|
264
|
-
|
|
270
|
+
function labelDisplayedRows({
|
|
271
|
+
from,
|
|
272
|
+
to,
|
|
273
|
+
count
|
|
274
|
+
}) {
|
|
275
|
+
return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;
|
|
276
|
+
}
|
|
277
|
+
const getLabelDisplayedRowsTo = ({
|
|
278
|
+
page,
|
|
279
|
+
pageSize,
|
|
280
|
+
rowCount
|
|
281
|
+
}) => {
|
|
282
|
+
if (rowCount === -1) {
|
|
283
|
+
return (page + 1) * pageSize;
|
|
284
|
+
}
|
|
285
|
+
return pageSize === -1 ? rowCount : Math.min(rowCount, (page + 1) * pageSize);
|
|
286
|
+
};
|
|
287
|
+
const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
288
|
+
const apiRef = useGridApiContext();
|
|
289
|
+
const rootProps = useGridRootProps();
|
|
290
|
+
const paginationModel = gridPaginationModelSelector(apiRef);
|
|
291
|
+
const visibleTopLevelRowCount = gridFilteredTopLevelRowCountSelector(apiRef);
|
|
292
|
+
const rowCount = React.useMemo(() => rootProps.rowCount ?? visibleTopLevelRowCount ?? 0, [rootProps.rowCount, visibleTopLevelRowCount]);
|
|
293
|
+
const lastPage = React.useMemo(() => Math.floor(rowCount / (paginationModel.pageSize || 1)), [rowCount, paginationModel.pageSize]);
|
|
294
|
+
const handlePageChange = React.useCallback(page => {
|
|
295
|
+
apiRef.current.setPage(page);
|
|
296
|
+
}, [apiRef]);
|
|
297
|
+
const page = paginationModel.page <= lastPage ? paginationModel.page : lastPage;
|
|
298
|
+
const pageSize = paginationModel.pageSize;
|
|
299
|
+
const pageSizeOptions = rootProps.pageSizeOptions?.includes(pageSize) ? rootProps.pageSizeOptions : [];
|
|
300
|
+
const handleChangeRowsPerPage = (event, newValue) => {
|
|
301
|
+
const newPageSize = Number(newValue);
|
|
302
|
+
apiRef.current.setPageSize(newPageSize);
|
|
303
|
+
};
|
|
304
|
+
return /*#__PURE__*/_jsxs(JoyBox, {
|
|
305
|
+
sx: {
|
|
306
|
+
display: 'flex',
|
|
307
|
+
alignItems: 'center',
|
|
308
|
+
gap: 2,
|
|
309
|
+
justifyContent: 'flex-end',
|
|
310
|
+
px: 2
|
|
311
|
+
},
|
|
312
|
+
ref: ref,
|
|
313
|
+
children: [/*#__PURE__*/_jsxs(JoyFormControl, {
|
|
314
|
+
orientation: "horizontal",
|
|
315
|
+
size: "sm",
|
|
316
|
+
children: [/*#__PURE__*/_jsx(JoyFormLabel, {
|
|
317
|
+
children: "Rows per page:"
|
|
318
|
+
}), /*#__PURE__*/_jsx(JoySelect, {
|
|
319
|
+
onChange: handleChangeRowsPerPage,
|
|
320
|
+
value: pageSize,
|
|
321
|
+
children: pageSizeOptions.map(option => {
|
|
322
|
+
return /*#__PURE__*/_jsx(Option, {
|
|
323
|
+
value: option,
|
|
324
|
+
children: option
|
|
325
|
+
}, option);
|
|
326
|
+
})
|
|
327
|
+
})]
|
|
328
|
+
}), /*#__PURE__*/_jsx(JoyTypography, {
|
|
329
|
+
textAlign: "center",
|
|
330
|
+
fontSize: "xs",
|
|
331
|
+
fontWeight: "md",
|
|
332
|
+
children: labelDisplayedRows({
|
|
333
|
+
from: rowCount === 0 ? 0 : page * pageSize + 1,
|
|
334
|
+
to: getLabelDisplayedRowsTo({
|
|
335
|
+
page,
|
|
336
|
+
pageSize,
|
|
337
|
+
rowCount
|
|
338
|
+
}),
|
|
339
|
+
count: rowCount === -1 ? -1 : rowCount
|
|
340
|
+
})
|
|
341
|
+
}), /*#__PURE__*/_jsxs(JoyBox, {
|
|
342
|
+
sx: {
|
|
343
|
+
display: 'flex',
|
|
344
|
+
gap: 0.5
|
|
345
|
+
},
|
|
346
|
+
children: [/*#__PURE__*/_jsx(JoyIconButton, {
|
|
347
|
+
size: "sm",
|
|
348
|
+
color: "neutral",
|
|
349
|
+
variant: "outlined",
|
|
350
|
+
disabled: page === 0,
|
|
351
|
+
onClick: () => handlePageChange(page - 1),
|
|
352
|
+
sx: {
|
|
353
|
+
bgcolor: 'background.surface'
|
|
354
|
+
},
|
|
355
|
+
children: /*#__PURE__*/_jsx(GridKeyboardArrowLeft, {})
|
|
356
|
+
}), /*#__PURE__*/_jsx(JoyIconButton, {
|
|
357
|
+
size: "sm",
|
|
358
|
+
color: "neutral",
|
|
359
|
+
variant: "outlined",
|
|
360
|
+
disabled: rowCount !== -1 ? page >= Math.ceil(rowCount / pageSize) - 1 : false,
|
|
361
|
+
onClick: () => handlePageChange(page + 1),
|
|
362
|
+
sx: {
|
|
363
|
+
bgcolor: 'background.surface'
|
|
364
|
+
},
|
|
365
|
+
children: /*#__PURE__*/_jsx(GridKeyboardArrowRight, {})
|
|
366
|
+
})]
|
|
367
|
+
})]
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
const joySlots = _extends({}, joyIconSlots, {
|
|
265
371
|
baseCheckbox: Checkbox,
|
|
266
372
|
baseTextField: TextField,
|
|
267
373
|
baseButton: Button,
|
|
@@ -270,9 +376,9 @@ const joySlots = {
|
|
|
270
376
|
baseSelect: Select,
|
|
271
377
|
baseSelectOption: Option,
|
|
272
378
|
baseInputLabel: InputLabel,
|
|
273
|
-
baseFormControl: JoyFormControl
|
|
379
|
+
baseFormControl: JoyFormControl,
|
|
274
380
|
// BaseTooltip: MUITooltip,
|
|
275
381
|
// BasePopper: MUIPopper,
|
|
276
|
-
|
|
277
|
-
|
|
382
|
+
pagination: Pagination
|
|
383
|
+
});
|
|
278
384
|
export default joySlots;
|
package/modern/locales/deDE.js
CHANGED
|
@@ -37,7 +37,7 @@ const deDEGrid = {
|
|
|
37
37
|
columnsPanelHideAllButton: 'Verberge alle',
|
|
38
38
|
// Filter panel text
|
|
39
39
|
filterPanelAddFilter: 'Filter hinzufügen',
|
|
40
|
-
|
|
40
|
+
filterPanelRemoveAll: 'Alle entfernen',
|
|
41
41
|
filterPanelDeleteIconLabel: 'Löschen',
|
|
42
42
|
filterPanelLogicOperator: 'Logische Operatoren',
|
|
43
43
|
filterPanelOperator: 'Operatoren',
|
|
@@ -67,7 +67,7 @@ const deDEGrid = {
|
|
|
67
67
|
// Column menu text
|
|
68
68
|
columnMenuLabel: 'Menü',
|
|
69
69
|
columnMenuShowColumns: 'Zeige alle Spalten',
|
|
70
|
-
|
|
70
|
+
columnMenuManageColumns: 'Spalten verwalten',
|
|
71
71
|
columnMenuFilter: 'Filter',
|
|
72
72
|
columnMenuHideColumn: 'Verbergen',
|
|
73
73
|
columnMenuUnsort: 'Sortierung deaktivieren',
|
package/modern/locales/frFR.js
CHANGED
|
@@ -7,7 +7,7 @@ const frFRGrid = {
|
|
|
7
7
|
// Density selector toolbar button text
|
|
8
8
|
toolbarDensity: 'Densité',
|
|
9
9
|
toolbarDensityLabel: 'Densité',
|
|
10
|
-
toolbarDensityCompact: '
|
|
10
|
+
toolbarDensityCompact: 'Compacte',
|
|
11
11
|
toolbarDensityStandard: 'Standard',
|
|
12
12
|
toolbarDensityComfortable: 'Confortable',
|
|
13
13
|
// Columns selector toolbar button text
|
|
@@ -20,7 +20,7 @@ const frFRGrid = {
|
|
|
20
20
|
toolbarFiltersTooltipShow: 'Afficher les filtres',
|
|
21
21
|
toolbarFiltersTooltipActive: count => count > 1 ? `${count} filtres actifs` : `${count} filtre actif`,
|
|
22
22
|
// Quick filter toolbar field
|
|
23
|
-
toolbarQuickFilterPlaceholder: '
|
|
23
|
+
toolbarQuickFilterPlaceholder: 'Rechercher…',
|
|
24
24
|
toolbarQuickFilterLabel: 'Recherche',
|
|
25
25
|
toolbarQuickFilterDeleteIconLabel: 'Supprimer',
|
|
26
26
|
// Export selector toolbar button text
|
|
@@ -30,7 +30,7 @@ const frFRGrid = {
|
|
|
30
30
|
toolbarExportPrint: 'Imprimer',
|
|
31
31
|
toolbarExportExcel: 'Télécharger pour Excel',
|
|
32
32
|
// Columns panel text
|
|
33
|
-
columnsPanelTextFieldLabel: 'Chercher colonne',
|
|
33
|
+
columnsPanelTextFieldLabel: 'Chercher une colonne',
|
|
34
34
|
columnsPanelTextFieldPlaceholder: 'Titre de la colonne',
|
|
35
35
|
columnsPanelDragIconLabel: 'Réorganiser la colonne',
|
|
36
36
|
columnsPanelShowAllButton: 'Tout afficher',
|
|
@@ -43,12 +43,12 @@ const frFRGrid = {
|
|
|
43
43
|
filterPanelOperator: 'Opérateur',
|
|
44
44
|
filterPanelOperatorAnd: 'Et',
|
|
45
45
|
filterPanelOperatorOr: 'Ou',
|
|
46
|
-
filterPanelColumns: '
|
|
46
|
+
filterPanelColumns: 'Colonne',
|
|
47
47
|
filterPanelInputLabel: 'Valeur',
|
|
48
48
|
filterPanelInputPlaceholder: 'Filtrer la valeur',
|
|
49
49
|
// Filter operators text
|
|
50
50
|
filterOperatorContains: 'contient',
|
|
51
|
-
filterOperatorEquals: 'égal à',
|
|
51
|
+
filterOperatorEquals: 'est égal à',
|
|
52
52
|
filterOperatorStartsWith: 'commence par',
|
|
53
53
|
filterOperatorEndsWith: 'se termine par',
|
|
54
54
|
filterOperatorIs: 'est',
|
|
@@ -80,7 +80,7 @@ const frFRGrid = {
|
|
|
80
80
|
// Rows selected footer text
|
|
81
81
|
footerRowSelected: count => count > 1 ? `${count.toLocaleString()} lignes sélectionnées` : `${count.toLocaleString()} ligne sélectionnée`,
|
|
82
82
|
// Total row amount footer text
|
|
83
|
-
footerTotalRows: '
|
|
83
|
+
footerTotalRows: 'Total de lignes :',
|
|
84
84
|
// Total visible row amount footer text
|
|
85
85
|
footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} sur ${totalCount.toLocaleString()}`,
|
|
86
86
|
// Checkbox selection text
|
package/modern/locales/ptBR.js
CHANGED
|
@@ -37,7 +37,7 @@ const ptBRGrid = {
|
|
|
37
37
|
columnsPanelHideAllButton: 'Ocultar todas',
|
|
38
38
|
// Filter panel text
|
|
39
39
|
filterPanelAddFilter: 'Adicionar filtro',
|
|
40
|
-
|
|
40
|
+
filterPanelRemoveAll: 'Remover todos',
|
|
41
41
|
filterPanelDeleteIconLabel: 'Excluir',
|
|
42
42
|
filterPanelLogicOperator: 'Operador lógico',
|
|
43
43
|
filterPanelOperator: 'Operador',
|
package/modern/locales/ukUA.js
CHANGED
|
@@ -51,7 +51,7 @@ const ukUAGrid = {
|
|
|
51
51
|
columnsPanelHideAllButton: 'Приховати всі',
|
|
52
52
|
// Filter panel text
|
|
53
53
|
filterPanelAddFilter: 'Додати фільтр',
|
|
54
|
-
|
|
54
|
+
filterPanelRemoveAll: 'Видалити всі',
|
|
55
55
|
filterPanelDeleteIconLabel: 'Видалити',
|
|
56
56
|
filterPanelLogicOperator: 'Логічна функція',
|
|
57
57
|
filterPanelOperator: 'Оператори',
|
|
@@ -81,7 +81,7 @@ const ukUAGrid = {
|
|
|
81
81
|
// Column menu text
|
|
82
82
|
columnMenuLabel: 'Меню',
|
|
83
83
|
columnMenuShowColumns: 'Показати стовпці',
|
|
84
|
-
|
|
84
|
+
columnMenuManageColumns: 'Керування стовпцями',
|
|
85
85
|
columnMenuFilter: 'Фільтр',
|
|
86
86
|
columnMenuHideColumn: 'Приховати',
|
|
87
87
|
columnMenuUnsort: 'Скасувати сортування',
|
|
@@ -135,12 +135,11 @@ const ukUAGrid = {
|
|
|
135
135
|
// Row reordering text
|
|
136
136
|
rowReorderingHeaderName: 'Порядок рядків',
|
|
137
137
|
// Aggregation
|
|
138
|
-
aggregationMenuItemHeader: 'Агрегація'
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
aggregationMenuItemHeader: 'Агрегація',
|
|
139
|
+
aggregationFunctionLabelSum: 'сума',
|
|
140
|
+
aggregationFunctionLabelAvg: 'сер',
|
|
141
|
+
aggregationFunctionLabelMin: 'мін',
|
|
142
|
+
aggregationFunctionLabelMax: 'макс',
|
|
143
|
+
aggregationFunctionLabelSize: 'кількість'
|
|
144
144
|
};
|
|
145
|
-
|
|
146
145
|
export const ukUA = getGridLocalization(ukUAGrid, ukUACore);
|
package/modern/material/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import MUIIconButton from '@mui/material/IconButton';
|
|
|
9
9
|
import MUITooltip from '@mui/material/Tooltip';
|
|
10
10
|
import MUIPopper from '@mui/material/Popper';
|
|
11
11
|
import MUIInputLabel from '@mui/material/InputLabel';
|
|
12
|
+
import MUIChip from '@mui/material/Chip';
|
|
12
13
|
import { GridColumnUnsortedIcon } from './icons/GridColumnUnsortedIcon';
|
|
13
14
|
import { GridAddIcon, GridArrowDownwardIcon, GridArrowUpwardIcon, GridCheckIcon, GridCloseIcon, GridColumnIcon, GridDragIcon, GridExpandMoreIcon, GridFilterAltIcon, GridFilterListIcon, GridKeyboardArrowRight, GridMoreVertIcon, GridRemoveIcon, GridSaveAltIcon, GridSearchIcon, GridSeparatorIcon, GridTableRowsIcon, GridTripleDotsVerticalIcon, GridViewHeadlineIcon, GridViewStreamIcon, GridVisibilityOffIcon, GridViewColumnIcon, GridClearIcon, GridLoadIcon, GridDeleteForeverIcon } from './icons';
|
|
14
15
|
import MUISelectOption from './components/MUISelectOption';
|
|
@@ -60,6 +61,7 @@ const materialSlots = _extends({}, iconSlots, {
|
|
|
60
61
|
BaseTooltip: MUITooltip,
|
|
61
62
|
BasePopper: MUIPopper,
|
|
62
63
|
BaseInputLabel: MUIInputLabel,
|
|
63
|
-
BaseSelectOption: MUISelectOption
|
|
64
|
+
BaseSelectOption: MUISelectOption,
|
|
65
|
+
BaseChip: MUIChip
|
|
64
66
|
});
|
|
65
67
|
export default materialSlots;
|
|
@@ -11,7 +11,6 @@ export * from './gridColumnMenuApi';
|
|
|
11
11
|
export * from './gridPreferencesPanelApi';
|
|
12
12
|
export * from './gridPrintExportApi';
|
|
13
13
|
export * from './gridDisableVirtualizationApi';
|
|
14
|
-
export * from './gridClipboardApi';
|
|
15
14
|
export * from './gridCallbackDetails';
|
|
16
15
|
export * from './gridScrollApi';
|
|
17
16
|
export * from './gridVirtualScrollerApi';
|
package/modern/utils/domUtils.js
CHANGED
|
@@ -39,4 +39,16 @@ export function getGridCellElement(root, {
|
|
|
39
39
|
const cellSelector = `.${gridClasses.cell}[data-field="${escapeOperandAttributeSelector(field)}"]`;
|
|
40
40
|
const selector = `${rowSelector} ${cellSelector}`;
|
|
41
41
|
return root.querySelector(selector);
|
|
42
|
-
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// https://www.abeautifulsite.net/posts/finding-the-active-element-in-a-shadow-root/
|
|
45
|
+
export const getActiveElement = (root = document) => {
|
|
46
|
+
const activeEl = root.activeElement;
|
|
47
|
+
if (!activeEl) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if (activeEl.shadowRoot) {
|
|
51
|
+
return getActiveElement(activeEl.shadowRoot);
|
|
52
|
+
}
|
|
53
|
+
return activeEl;
|
|
54
|
+
};
|
|
@@ -77,6 +77,11 @@ DataGridRaw.propTypes = {
|
|
|
77
77
|
* Override or extend the styles applied to the component.
|
|
78
78
|
*/
|
|
79
79
|
classes: _propTypes.default.object,
|
|
80
|
+
/**
|
|
81
|
+
* The character used to separate cell values when copying to the clipboard.
|
|
82
|
+
* @default '\t'
|
|
83
|
+
*/
|
|
84
|
+
clipboardCopyCellDelimiter: _propTypes.default.string,
|
|
80
85
|
/**
|
|
81
86
|
* Number of extra columns to be rendered before/after the visible slice.
|
|
82
87
|
* @default 3
|
|
@@ -335,6 +340,11 @@ DataGridRaw.propTypes = {
|
|
|
335
340
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
336
341
|
*/
|
|
337
342
|
onCellModesModelChange: _propTypes.default.func,
|
|
343
|
+
/**
|
|
344
|
+
* Callback called when the data is copied to the clipboard.
|
|
345
|
+
* @param {string} data The data copied to the clipboard.
|
|
346
|
+
*/
|
|
347
|
+
onClipboardCopy: _propTypes.default.func,
|
|
338
348
|
/**
|
|
339
349
|
* Callback fired when a click event comes from a column header element.
|
|
340
350
|
* @param {GridColumnHeaderParams} params With all properties from [[GridColumnHeaderParams]].
|
|
@@ -620,5 +630,14 @@ DataGridRaw.propTypes = {
|
|
|
620
630
|
/**
|
|
621
631
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
622
632
|
*/
|
|
623
|
-
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
|
|
633
|
+
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
|
|
634
|
+
/**
|
|
635
|
+
* If `true`, the grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
|
|
636
|
+
* If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
|
|
637
|
+
* @default: false
|
|
638
|
+
*/
|
|
639
|
+
unstable_ignoreValueFormatterDuringExport: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
640
|
+
clipboardExport: _propTypes.default.bool,
|
|
641
|
+
csvExport: _propTypes.default.bool
|
|
642
|
+
}), _propTypes.default.bool])
|
|
624
643
|
};
|
|
@@ -73,9 +73,9 @@ const useDataGridComponent = (inputApiRef, props) => {
|
|
|
73
73
|
(0, _useGridRowsMeta.useGridRowsMeta)(privateApiRef, props);
|
|
74
74
|
(0, _useGridScroll.useGridScroll)(privateApiRef, props);
|
|
75
75
|
(0, _useGridColumnMenu.useGridColumnMenu)(privateApiRef);
|
|
76
|
-
(0, _useGridCsvExport.useGridCsvExport)(privateApiRef);
|
|
76
|
+
(0, _useGridCsvExport.useGridCsvExport)(privateApiRef, props);
|
|
77
77
|
(0, _useGridPrintExport.useGridPrintExport)(privateApiRef, props);
|
|
78
|
-
(0, _useGridClipboard.useGridClipboard)(privateApiRef);
|
|
78
|
+
(0, _useGridClipboard.useGridClipboard)(privateApiRef, props);
|
|
79
79
|
(0, _useGridDimensions.useGridDimensions)(privateApiRef, props);
|
|
80
80
|
(0, _useGridEvents.useGridEvents)(privateApiRef, props);
|
|
81
81
|
(0, _useGridStatePersistence.useGridStatePersistence)(privateApiRef);
|
|
@@ -75,7 +75,9 @@ const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
75
75
|
disableColumnReorder: false,
|
|
76
76
|
disableColumnResize: false,
|
|
77
77
|
keepNonExistentRowsSelected: false,
|
|
78
|
-
keepColumnPositionIfDraggedOutside: false
|
|
78
|
+
keepColumnPositionIfDraggedOutside: false,
|
|
79
|
+
unstable_ignoreValueFormatterDuringExport: false,
|
|
80
|
+
clipboardCopyCellDelimiter: '\t'
|
|
79
81
|
};
|
|
80
82
|
exports.DATA_GRID_PROPS_DEFAULT_VALUES = DATA_GRID_PROPS_DEFAULT_VALUES;
|
|
81
83
|
const defaultSlots = (0, _utils.uncapitalizeObjectKeys)(_defaultGridSlotsComponents.DATA_GRID_DEFAULT_SLOTS_COMPONENTS);
|
|
@@ -17,6 +17,22 @@ function gridBooleanFormatter({
|
|
|
17
17
|
}) {
|
|
18
18
|
return value ? api.getLocaleText('booleanCellTrueLabel') : api.getLocaleText('booleanCellFalseLabel');
|
|
19
19
|
}
|
|
20
|
+
const stringToBoolean = value => {
|
|
21
|
+
switch (value.toLowerCase().trim()) {
|
|
22
|
+
case 'true':
|
|
23
|
+
case 'yes':
|
|
24
|
+
case '1':
|
|
25
|
+
return true;
|
|
26
|
+
case 'false':
|
|
27
|
+
case 'no':
|
|
28
|
+
case '0':
|
|
29
|
+
case 'null':
|
|
30
|
+
case 'undefined':
|
|
31
|
+
return false;
|
|
32
|
+
default:
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
20
36
|
const GRID_BOOLEAN_COL_DEF = (0, _extends2.default)({}, _gridStringColDef.GRID_STRING_COL_DEF, {
|
|
21
37
|
type: 'boolean',
|
|
22
38
|
align: 'center',
|
|
@@ -28,6 +44,8 @@ const GRID_BOOLEAN_COL_DEF = (0, _extends2.default)({}, _gridStringColDef.GRID_S
|
|
|
28
44
|
filterOperators: (0, _gridBooleanOperators.getGridBooleanOperators)(),
|
|
29
45
|
getApplyQuickFilterFn: undefined,
|
|
30
46
|
// @ts-ignore
|
|
31
|
-
aggregable: false
|
|
47
|
+
aggregable: false,
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
pastedValueParser: value => stringToBoolean(value)
|
|
32
50
|
});
|
|
33
51
|
exports.GRID_BOOLEAN_COL_DEF = GRID_BOOLEAN_COL_DEF;
|
|
@@ -60,7 +60,9 @@ const GRID_DATE_COL_DEF = (0, _extends2.default)({}, _gridStringColDef.GRID_STRI
|
|
|
60
60
|
valueFormatter: gridDateFormatter,
|
|
61
61
|
filterOperators: (0, _gridDateOperators.getGridDateOperators)(),
|
|
62
62
|
renderEditCell: _GridEditDateCell.renderEditDateCell,
|
|
63
|
-
getApplyQuickFilterFn: undefined
|
|
63
|
+
getApplyQuickFilterFn: undefined,
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
pastedValueParser: value => new Date(value)
|
|
64
66
|
});
|
|
65
67
|
exports.GRID_DATE_COL_DEF = GRID_DATE_COL_DEF;
|
|
66
68
|
const GRID_DATETIME_COL_DEF = (0, _extends2.default)({}, _gridStringColDef.GRID_STRING_COL_DEF, {
|
|
@@ -69,6 +71,8 @@ const GRID_DATETIME_COL_DEF = (0, _extends2.default)({}, _gridStringColDef.GRID_
|
|
|
69
71
|
valueFormatter: gridDateTimeFormatter,
|
|
70
72
|
filterOperators: (0, _gridDateOperators.getGridDateOperators)(true),
|
|
71
73
|
renderEditCell: _GridEditDateCell.renderEditDateCell,
|
|
72
|
-
getApplyQuickFilterFn: undefined
|
|
74
|
+
getApplyQuickFilterFn: undefined,
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
pastedValueParser: value => new Date(value)
|
|
73
77
|
});
|
|
74
78
|
exports.GRID_DATETIME_COL_DEF = GRID_DATETIME_COL_DEF;
|
|
@@ -58,6 +58,26 @@ const GRID_SINGLE_SELECT_COL_DEF = (0, _extends2.default)({}, _gridStringColDef.
|
|
|
58
58
|
return valueOption ? colDef.getOptionLabel(valueOption) : '';
|
|
59
59
|
},
|
|
60
60
|
renderEditCell: _GridEditSingleSelectCell.renderEditSingleSelectCell,
|
|
61
|
-
filterOperators: (0, _gridSingleSelectOperators.getGridSingleSelectOperators)()
|
|
61
|
+
filterOperators: (0, _gridSingleSelectOperators.getGridSingleSelectOperators)(),
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
pastedValueParser: (value, params) => {
|
|
64
|
+
const colDef = params.colDef;
|
|
65
|
+
const colDefValueOptions = colDef.valueOptions;
|
|
66
|
+
const valueOptions = typeof colDefValueOptions === 'function' ? colDefValueOptions({
|
|
67
|
+
field: colDef.field
|
|
68
|
+
}) : colDefValueOptions || [];
|
|
69
|
+
const getOptionValue = colDef.getOptionValue;
|
|
70
|
+
const valueOption = valueOptions.find(option => {
|
|
71
|
+
if (getOptionValue(option) === value) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
});
|
|
76
|
+
if (valueOption) {
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
// do not paste the value if it is not in the valueOptions
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
62
82
|
});
|
|
63
83
|
exports.GRID_SINGLE_SELECT_COL_DEF = GRID_SINGLE_SELECT_COL_DEF;
|
|
@@ -97,7 +97,8 @@ function GridBody(props) {
|
|
|
97
97
|
apiRef.current.register('private', {
|
|
98
98
|
columnHeadersContainerElementRef: columnsContainerRef,
|
|
99
99
|
columnHeadersElementRef: columnHeadersRef,
|
|
100
|
-
virtualScrollerRef
|
|
100
|
+
virtualScrollerRef,
|
|
101
|
+
mainElementRef: rootRef
|
|
101
102
|
});
|
|
102
103
|
const hasDimensions = !!apiRef.current.getRootDimensions();
|
|
103
104
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridMainContainer.GridMainContainer, {
|
|
@@ -10,7 +10,6 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _Autocomplete = _interopRequireWildcard(require("@mui/material/Autocomplete"));
|
|
13
|
-
var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
|
|
14
13
|
var _utils = require("@mui/utils");
|
|
15
14
|
var _filterPanelUtils = require("./filterPanelUtils");
|
|
16
15
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
@@ -105,7 +104,7 @@ function GridFilterInputMultipleSingleSelect(props) {
|
|
|
105
104
|
value: filteredValues,
|
|
106
105
|
onChange: handleChange,
|
|
107
106
|
getOptionLabel: getOptionLabel,
|
|
108
|
-
renderTags: (value, getTagProps) => value.map((option, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
107
|
+
renderTags: (value, getTagProps) => value.map((option, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseChip, (0, _extends2.default)({
|
|
109
108
|
variant: "outlined",
|
|
110
109
|
size: "small",
|
|
111
110
|
label: getOptionLabel(option)
|
|
@@ -10,7 +10,6 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _Autocomplete = _interopRequireDefault(require("@mui/material/Autocomplete"));
|
|
13
|
-
var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
|
|
14
13
|
var _utils = require("@mui/utils");
|
|
15
14
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
16
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -64,7 +63,7 @@ function GridFilterInputMultipleValue(props) {
|
|
|
64
63
|
id: id,
|
|
65
64
|
value: filterValueState,
|
|
66
65
|
onChange: handleChange,
|
|
67
|
-
renderTags: (value, getTagProps) => value.map((option, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
66
|
+
renderTags: (value, getTagProps) => value.map((option, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseChip, (0, _extends2.default)({
|
|
68
67
|
variant: "outlined",
|
|
69
68
|
size: "small",
|
|
70
69
|
label: option
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useGridClipboard = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
|
+
var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
|
|
10
|
+
var _csvSerializer = require("../export/serializers/csvSerializer");
|
|
9
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
13
|
function writeToClipboardPolyfill(data) {
|
|
@@ -26,6 +28,15 @@ function writeToClipboardPolyfill(data) {
|
|
|
26
28
|
document.body.removeChild(span);
|
|
27
29
|
}
|
|
28
30
|
}
|
|
31
|
+
function copyToClipboard(data) {
|
|
32
|
+
if (navigator.clipboard) {
|
|
33
|
+
navigator.clipboard.writeText(data).catch(() => {
|
|
34
|
+
writeToClipboardPolyfill(data);
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
writeToClipboardPolyfill(data);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
29
40
|
function hasNativeSelection(element) {
|
|
30
41
|
// When getSelection is called on an <iframe> that is not displayed Firefox will return null.
|
|
31
42
|
if (window.getSelection()?.toString()) {
|
|
@@ -45,24 +56,11 @@ function hasNativeSelection(element) {
|
|
|
45
56
|
* @requires useGridCsvExport (method)
|
|
46
57
|
* @requires useGridSelection (method)
|
|
47
58
|
*/
|
|
48
|
-
const useGridClipboard = apiRef => {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const data = apiRef.current.getDataAsCsv({
|
|
54
|
-
includeHeaders: false,
|
|
55
|
-
delimiter: '\t'
|
|
56
|
-
});
|
|
57
|
-
if (navigator.clipboard) {
|
|
58
|
-
navigator.clipboard.writeText(data).catch(() => {
|
|
59
|
-
writeToClipboardPolyfill(data);
|
|
60
|
-
});
|
|
61
|
-
} else {
|
|
62
|
-
writeToClipboardPolyfill(data);
|
|
63
|
-
}
|
|
64
|
-
}, [apiRef]);
|
|
65
|
-
const handleKeydown = React.useCallback(event => {
|
|
59
|
+
const useGridClipboard = (apiRef, props) => {
|
|
60
|
+
const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
|
|
61
|
+
const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.clipboardExport : ignoreValueFormatterProp) || false;
|
|
62
|
+
const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
|
|
63
|
+
const handleCopy = React.useCallback(event => {
|
|
66
64
|
const isModifierKeyPressed = event.ctrlKey || event.metaKey;
|
|
67
65
|
// event.code === 'KeyC' is not enough as event.code assume a QWERTY keyboard layout which would
|
|
68
66
|
// be wrong with a Dvorak keyboard (as if pressing J).
|
|
@@ -74,12 +72,31 @@ const useGridClipboard = apiRef => {
|
|
|
74
72
|
if (hasNativeSelection(event.target)) {
|
|
75
73
|
return;
|
|
76
74
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
let textToCopy = '';
|
|
76
|
+
const selectedRows = apiRef.current.getSelectedRows();
|
|
77
|
+
if (selectedRows.size > 0) {
|
|
78
|
+
textToCopy = apiRef.current.getDataAsCsv({
|
|
79
|
+
includeHeaders: false,
|
|
80
|
+
// TODO: make it configurable
|
|
81
|
+
delimiter: clipboardCopyCellDelimiter
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
const focusedCell = (0, _gridFocusStateSelector.gridFocusCellSelector)(apiRef);
|
|
85
|
+
if (focusedCell) {
|
|
86
|
+
const cellParams = apiRef.current.getCellParams(focusedCell.id, focusedCell.field);
|
|
87
|
+
textToCopy = (0, _csvSerializer.serializeCellValue)(cellParams, {
|
|
88
|
+
delimiterCharacter: clipboardCopyCellDelimiter,
|
|
89
|
+
ignoreValueFormatter
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
textToCopy = apiRef.current.unstable_applyPipeProcessors('clipboardCopy', textToCopy);
|
|
94
|
+
if (textToCopy) {
|
|
95
|
+
copyToClipboard(textToCopy);
|
|
96
|
+
apiRef.current.publishEvent('clipboardCopy', textToCopy);
|
|
97
|
+
}
|
|
98
|
+
}, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
|
|
99
|
+
(0, _utils.useGridNativeEventListener)(apiRef, apiRef.current.rootElementRef, 'keydown', handleCopy);
|
|
100
|
+
(0, _utils.useGridApiOptionHandler)(apiRef, 'clipboardCopy', props.onClipboardCopy);
|
|
84
101
|
};
|
|
85
102
|
exports.useGridClipboard = useGridClipboard;
|
|
@@ -16,7 +16,6 @@ var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
|
16
16
|
var _gridRowsMetaSelector = require("../rows/gridRowsMetaSelector");
|
|
17
17
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
18
18
|
var _gridColumnsUtils = require("../columns/gridColumnsUtils");
|
|
19
|
-
var _gridClasses = require("../../../constants/gridClasses");
|
|
20
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
21
|
const isTestEnvironment = process.env.NODE_ENV === 'test';
|
|
@@ -158,8 +157,7 @@ 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
|
const computeSizeAndPublishResizeEvent = React.useCallback(() => {
|
|
161
|
-
const
|
|
162
|
-
const mainEl = rootEl?.querySelector(`.${_gridClasses.gridClasses.main}`);
|
|
160
|
+
const mainEl = apiRef.current.mainElementRef?.current;
|
|
163
161
|
if (!mainEl) {
|
|
164
162
|
return;
|
|
165
163
|
}
|
|
@@ -99,10 +99,14 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
99
99
|
}
|
|
100
100
|
} else if (params.isEditable) {
|
|
101
101
|
let reason;
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
const canStartEditing = apiRef.current.unstable_applyPipeProcessors('canStartEditing', true, {
|
|
103
|
+
event,
|
|
104
|
+
cellParams: params,
|
|
105
|
+
editMode: 'cell'
|
|
106
|
+
});
|
|
107
|
+
if (!canStartEditing) {
|
|
108
|
+
return;
|
|
104
109
|
}
|
|
105
|
-
|
|
106
110
|
if ((0, _keyboardUtils.isPrintableKey)(event)) {
|
|
107
111
|
reason = _gridEditCellParams.GridCellEditStartReasons.printableKeyDown;
|
|
108
112
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
@@ -152,10 +152,14 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
152
152
|
}
|
|
153
153
|
} else if (params.isEditable) {
|
|
154
154
|
let reason;
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
const canStartEditing = apiRef.current.unstable_applyPipeProcessors('canStartEditing', true, {
|
|
156
|
+
event,
|
|
157
|
+
cellParams: params,
|
|
158
|
+
editMode: 'row'
|
|
159
|
+
});
|
|
160
|
+
if (!canStartEditing) {
|
|
161
|
+
return;
|
|
157
162
|
}
|
|
158
|
-
|
|
159
163
|
if ((0, _keyboardUtils.isPrintableKey)(event)) {
|
|
160
164
|
reason = _gridRowParams.GridRowEditStartReasons.printableKeyDown;
|
|
161
165
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|