@mui/x-data-grid 6.3.1 → 6.5.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 +113 -0
- package/DataGrid/DataGrid.js +20 -1
- package/DataGrid/useDataGridComponent.js +2 -2
- package/DataGrid/useDataGridProps.js +8 -13
- package/colDef/gridBooleanColDef.js +19 -1
- package/colDef/gridDateColDef.js +6 -2
- package/colDef/gridNumericOperators.js +0 -6
- package/colDef/gridSingleSelectColDef.js +21 -1
- package/components/base/GridBody.js +2 -1
- package/components/cell/GridEditInputCell.js +4 -1
- package/components/containers/GridRootStyles.js +1 -0
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +15 -2
- package/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +8 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +8 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +11 -4
- package/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/components/panel/filterPanel/GridFilterPanel.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/components/panel/filterPanel/index.d.ts +3 -1
- package/components/panel/filterPanel/index.js +2 -1
- package/constants/localeTextConstants.js +26 -0
- 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/columnHeaders/useGridColumnHeaders.d.ts +9 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/hooks/features/dimensions/useGridDimensions.js +4 -6
- package/hooks/features/editing/useGridCellEditing.js +7 -3
- package/hooks/features/editing/useGridEditing.js +0 -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/gridFocusState.d.ts +2 -0
- package/hooks/features/focus/gridFocusStateSelector.d.ts +2 -0
- package/hooks/features/focus/gridFocusStateSelector.js +6 -0
- package/hooks/features/focus/useGridFocus.js +55 -9
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +4 -0
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
- package/hooks/features/headerFiltering/index.d.ts +1 -0
- package/hooks/features/headerFiltering/index.js +1 -0
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +6 -0
- package/hooks/features/headerFiltering/useGridHeaderFiltering.js +91 -0
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +2 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +124 -4
- package/hooks/features/rows/useGridRows.js +16 -1
- package/index.js +1 -1
- package/internals/index.d.ts +9 -3
- package/internals/index.js +7 -2
- package/internals/utils/index.d.ts +1 -0
- package/internals/utils/index.js +2 -1
- package/internals/utils/useProps.d.ts +8 -0
- package/internals/utils/useProps.js +13 -0
- 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 +11 -9
- package/legacy/colDef/gridBooleanColDef.js +21 -1
- package/legacy/colDef/gridDateColDef.js +10 -2
- package/legacy/colDef/gridNumericOperators.js +0 -6
- package/legacy/colDef/gridSingleSelectColDef.js +21 -1
- package/legacy/components/base/GridBody.js +2 -1
- package/legacy/components/cell/GridEditInputCell.js +4 -1
- package/legacy/components/containers/GridRootStyles.js +1 -0
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +79 -35
- package/legacy/components/panel/filterPanel/GridFilterInputDate.js +26 -5
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +54 -31
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +28 -5
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/legacy/components/panel/filterPanel/index.js +2 -1
- package/legacy/constants/localeTextConstants.js +26 -0
- package/legacy/hooks/features/clipboard/useGridClipboard.js +44 -26
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -5
- package/legacy/hooks/features/dimensions/useGridDimensions.js +4 -6
- package/legacy/hooks/features/editing/useGridCellEditing.js +7 -3
- package/legacy/hooks/features/editing/useGridEditing.js +0 -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/gridFocusStateSelector.js +10 -0
- package/legacy/hooks/features/focus/useGridFocus.js +58 -9
- package/legacy/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +11 -0
- package/legacy/hooks/features/headerFiltering/index.js +1 -0
- package/legacy/hooks/features/headerFiltering/useGridHeaderFiltering.js +93 -0
- package/legacy/hooks/features/index.js +2 -1
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +123 -4
- package/legacy/hooks/features/rows/useGridRows.js +16 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +7 -2
- package/legacy/internals/utils/index.js +2 -1
- package/legacy/internals/utils/useProps.js +11 -0
- package/legacy/joy/icons.js +432 -0
- package/legacy/joy/joySlots.js +118 -4
- package/legacy/locales/arSD.js +28 -0
- package/legacy/locales/beBY.js +28 -0
- package/legacy/locales/bgBG.js +28 -0
- package/legacy/locales/csCZ.js +36 -8
- package/legacy/locales/daDK.js +28 -0
- package/legacy/locales/deDE.js +30 -2
- package/legacy/locales/elGR.js +27 -0
- package/legacy/locales/esES.js +28 -0
- package/legacy/locales/faIR.js +28 -0
- package/legacy/locales/fiFI.js +28 -0
- package/legacy/locales/frFR.js +34 -6
- package/legacy/locales/heIL.js +30 -2
- package/legacy/locales/huHU.js +28 -0
- package/legacy/locales/itIT.js +28 -0
- package/legacy/locales/jaJP.js +28 -0
- package/legacy/locales/koKR.js +28 -0
- package/legacy/locales/nbNO.js +28 -0
- package/legacy/locales/nlNL.js +28 -0
- package/legacy/locales/plPL.js +28 -0
- package/legacy/locales/ptBR.js +29 -1
- package/legacy/locales/roRO.js +28 -0
- package/legacy/locales/ruRU.js +28 -0
- package/legacy/locales/skSK.js +28 -0
- package/legacy/locales/svSE.js +28 -0
- package/legacy/locales/trTR.js +28 -0
- package/legacy/locales/ukUA.js +36 -9
- package/legacy/locales/urPK.js +28 -0
- package/legacy/locales/viVN.js +27 -0
- package/legacy/locales/zhCN.js +28 -0
- package/legacy/locales/zhTW.js +28 -0
- package/legacy/material/index.js +5 -1
- package/legacy/models/api/index.js +0 -1
- package/legacy/models/index.js +0 -1
- package/legacy/utils/domUtils.js +14 -1
- package/locales/arSD.js +28 -0
- package/locales/beBY.js +28 -0
- package/locales/bgBG.js +28 -0
- package/locales/csCZ.js +36 -8
- package/locales/daDK.js +28 -0
- package/locales/deDE.js +30 -2
- package/locales/elGR.js +27 -0
- package/locales/esES.js +28 -0
- package/locales/faIR.js +28 -0
- package/locales/fiFI.js +28 -0
- package/locales/frFR.js +34 -6
- package/locales/heIL.js +30 -2
- package/locales/huHU.js +28 -0
- package/locales/itIT.js +28 -0
- package/locales/jaJP.js +28 -0
- package/locales/koKR.js +28 -0
- package/locales/nbNO.js +28 -0
- package/locales/nlNL.js +28 -0
- package/locales/plPL.js +28 -0
- package/locales/ptBR.js +29 -1
- package/locales/roRO.js +28 -0
- package/locales/ruRU.js +28 -0
- package/locales/skSK.js +28 -0
- package/locales/svSE.js +28 -0
- package/locales/trTR.js +28 -0
- package/locales/ukUA.js +36 -9
- package/locales/urPK.js +28 -0
- package/locales/viVN.js +27 -0
- package/locales/zhCN.js +28 -0
- package/locales/zhTW.js +28 -0
- package/material/index.d.ts +3 -65
- package/material/index.js +5 -1
- package/models/api/gridApiCommon.d.ts +3 -3
- package/models/api/gridCoreApi.d.ts +8 -0
- package/models/api/gridFocusApi.d.ts +6 -0
- package/models/api/gridHeaderFilteringApi.d.ts +30 -0
- package/models/api/gridLocaleTextApi.d.ts +25 -0
- package/models/api/index.d.ts +0 -1
- package/models/api/index.js +0 -1
- package/models/events/gridEventLookup.d.ts +33 -1
- package/models/gridFilterOperator.d.ts +4 -0
- package/models/gridHeaderFilteringModel.d.ts +5 -0
- package/models/gridHeaderFilteringModel.js +1 -0
- package/models/gridSlotsComponent.d.ts +21 -4
- package/models/gridSlotsComponentsProps.d.ts +4 -0
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/index.d.ts +1 -1
- package/models/index.js +0 -1
- 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 +8 -13
- package/modern/colDef/gridBooleanColDef.js +19 -1
- package/modern/colDef/gridDateColDef.js +6 -2
- package/modern/colDef/gridNumericOperators.js +0 -6
- package/modern/colDef/gridSingleSelectColDef.js +21 -1
- package/modern/components/base/GridBody.js +2 -1
- package/modern/components/cell/GridEditInputCell.js +4 -1
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/modern/components/panel/filterPanel/index.js +2 -1
- package/modern/constants/localeTextConstants.js +26 -0
- package/modern/hooks/features/clipboard/useGridClipboard.js +43 -26
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +3 -5
- package/modern/hooks/features/editing/useGridCellEditing.js +7 -3
- package/modern/hooks/features/editing/useGridEditing.js +0 -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/gridFocusStateSelector.js +6 -0
- package/modern/hooks/features/focus/useGridFocus.js +55 -9
- package/modern/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
- package/modern/hooks/features/headerFiltering/index.js +1 -0
- package/modern/hooks/features/headerFiltering/useGridHeaderFiltering.js +90 -0
- package/modern/hooks/features/index.js +2 -1
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +124 -4
- package/modern/hooks/features/rows/useGridRows.js +16 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +7 -2
- package/modern/internals/utils/index.js +2 -1
- package/modern/internals/utils/useProps.js +13 -0
- package/modern/joy/icons.js +433 -0
- package/modern/joy/joySlots.js +110 -4
- package/modern/locales/arSD.js +28 -0
- package/modern/locales/beBY.js +28 -0
- package/modern/locales/bgBG.js +28 -0
- package/modern/locales/csCZ.js +36 -8
- package/modern/locales/daDK.js +28 -0
- package/modern/locales/deDE.js +30 -2
- package/modern/locales/elGR.js +27 -0
- package/modern/locales/esES.js +28 -0
- package/modern/locales/faIR.js +28 -0
- package/modern/locales/fiFI.js +28 -0
- package/modern/locales/frFR.js +34 -6
- package/modern/locales/heIL.js +30 -2
- package/modern/locales/huHU.js +28 -0
- package/modern/locales/itIT.js +28 -0
- package/modern/locales/jaJP.js +28 -0
- package/modern/locales/koKR.js +28 -0
- package/modern/locales/nbNO.js +28 -0
- package/modern/locales/nlNL.js +28 -0
- package/modern/locales/plPL.js +28 -0
- package/modern/locales/ptBR.js +29 -1
- package/modern/locales/roRO.js +28 -0
- package/modern/locales/ruRU.js +28 -0
- package/modern/locales/skSK.js +28 -0
- package/modern/locales/svSE.js +28 -0
- package/modern/locales/trTR.js +28 -0
- package/modern/locales/ukUA.js +36 -9
- package/modern/locales/urPK.js +28 -0
- package/modern/locales/viVN.js +27 -0
- package/modern/locales/zhCN.js +28 -0
- package/modern/locales/zhTW.js +28 -0
- package/modern/material/index.js +5 -1
- package/modern/models/api/gridHeaderFilteringApi.js +1 -0
- package/modern/models/api/index.js +0 -1
- package/modern/models/gridHeaderFilteringModel.js +1 -0
- package/modern/models/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 +7 -12
- package/node/colDef/gridBooleanColDef.js +19 -1
- package/node/colDef/gridDateColDef.js +6 -2
- package/node/colDef/gridNumericOperators.js +0 -6
- package/node/colDef/gridSingleSelectColDef.js +21 -1
- package/node/components/base/GridBody.js +2 -1
- package/node/components/cell/GridEditInputCell.js +4 -1
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +78 -35
- package/node/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/node/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/node/components/panel/filterPanel/GridFilterPanel.js +2 -1
- package/node/components/panel/filterPanel/index.js +26 -8
- package/node/constants/localeTextConstants.js +26 -0
- package/node/hooks/features/clipboard/useGridClipboard.js +42 -25
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -5
- package/node/hooks/features/editing/useGridCellEditing.js +7 -3
- package/node/hooks/features/editing/useGridEditing.js +0 -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/gridFocusStateSelector.js +9 -1
- package/node/hooks/features/focus/useGridFocus.js +55 -9
- package/node/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +15 -0
- package/node/hooks/features/headerFiltering/index.js +16 -0
- package/node/hooks/features/headerFiltering/useGridHeaderFiltering.js +101 -0
- package/node/hooks/features/index.js +11 -0
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +124 -4
- package/node/hooks/features/rows/useGridRows.js +16 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +69 -1
- package/node/internals/utils/index.js +11 -0
- package/node/internals/utils/useProps.js +22 -0
- package/node/joy/icons.js +471 -0
- package/node/joy/joySlots.js +110 -3
- package/node/locales/arSD.js +28 -0
- package/node/locales/beBY.js +28 -0
- package/node/locales/bgBG.js +28 -0
- package/node/locales/csCZ.js +36 -8
- package/node/locales/daDK.js +28 -0
- package/node/locales/deDE.js +30 -2
- package/node/locales/elGR.js +27 -0
- package/node/locales/esES.js +28 -0
- package/node/locales/faIR.js +28 -0
- package/node/locales/fiFI.js +28 -0
- package/node/locales/frFR.js +34 -6
- package/node/locales/heIL.js +30 -2
- package/node/locales/huHU.js +28 -0
- package/node/locales/itIT.js +28 -0
- package/node/locales/jaJP.js +28 -0
- package/node/locales/koKR.js +28 -0
- package/node/locales/nbNO.js +28 -0
- package/node/locales/nlNL.js +28 -0
- package/node/locales/plPL.js +28 -0
- package/node/locales/ptBR.js +29 -1
- package/node/locales/roRO.js +28 -0
- package/node/locales/ruRU.js +28 -0
- package/node/locales/skSK.js +28 -0
- package/node/locales/svSE.js +28 -0
- package/node/locales/trTR.js +28 -0
- package/node/locales/ukUA.js +36 -9
- package/node/locales/urPK.js +28 -0
- package/node/locales/viVN.js +27 -0
- package/node/locales/zhCN.js +28 -0
- package/node/locales/zhTW.js +28 -0
- package/node/material/index.js +5 -1
- package/node/models/api/index.js +0 -11
- package/node/models/gridHeaderFilteringModel.js +5 -0
- package/node/models/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/models/api/gridClipboardApi.d.ts +0 -11
- /package/legacy/models/api/{gridClipboardApi.js → gridHeaderFilteringApi.js} +0 -0
- /package/{models/api/gridClipboardApi.js → legacy/models/gridHeaderFilteringModel.js} +0 -0
- /package/{modern/models/api/gridClipboardApi.js → models/api/gridHeaderFilteringApi.js} +0 -0
- /package/node/models/api/{gridClipboardApi.js → gridHeaderFilteringApi.js} +0 -0
|
@@ -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
|
const formattedValue = value.replace(/"/g, '""');
|
|
6
6
|
|
|
@@ -11,16 +11,49 @@ const serializeCellValue = (value, delimiterCharacter) => {
|
|
|
11
11
|
return formattedValue;
|
|
12
12
|
}
|
|
13
13
|
return value;
|
|
14
|
+
}
|
|
15
|
+
export const serializeCellValue = (cellParams, options) => {
|
|
16
|
+
const {
|
|
17
|
+
delimiterCharacter,
|
|
18
|
+
ignoreValueFormatter
|
|
19
|
+
} = options;
|
|
20
|
+
let value;
|
|
21
|
+
if (ignoreValueFormatter) {
|
|
22
|
+
var _cellParams$value2;
|
|
23
|
+
const 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);
|
|
14
38
|
};
|
|
15
39
|
const 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.']);
|
|
16
|
-
const serializeRow = (
|
|
40
|
+
const serializeRow = ({
|
|
41
|
+
id,
|
|
42
|
+
columns,
|
|
43
|
+
getCellParams,
|
|
44
|
+
delimiterCharacter,
|
|
45
|
+
ignoreValueFormatter
|
|
46
|
+
}) => columns.map(column => {
|
|
17
47
|
const cellParams = getCellParams(id, column.field);
|
|
18
48
|
if (process.env.NODE_ENV !== 'production') {
|
|
19
49
|
if (String(cellParams.formattedValue) === '[object Object]') {
|
|
20
50
|
objectFormattedValueWarning();
|
|
21
51
|
}
|
|
22
52
|
}
|
|
23
|
-
return serializeCellValue(cellParams
|
|
53
|
+
return serializeCellValue(cellParams, {
|
|
54
|
+
delimiterCharacter,
|
|
55
|
+
ignoreValueFormatter
|
|
56
|
+
});
|
|
24
57
|
});
|
|
25
58
|
export function buildCSV(options) {
|
|
26
59
|
const {
|
|
@@ -28,12 +61,19 @@ export function buildCSV(options) {
|
|
|
28
61
|
rowIds,
|
|
29
62
|
getCellParams,
|
|
30
63
|
delimiterCharacter,
|
|
31
|
-
includeHeaders
|
|
64
|
+
includeHeaders,
|
|
65
|
+
ignoreValueFormatter
|
|
32
66
|
} = options;
|
|
33
|
-
const CSVBody = rowIds.reduce((acc, id) => `${acc}${serializeRow(
|
|
67
|
+
const CSVBody = rowIds.reduce((acc, id) => `${acc}${serializeRow({
|
|
68
|
+
id,
|
|
69
|
+
columns,
|
|
70
|
+
getCellParams,
|
|
71
|
+
delimiterCharacter,
|
|
72
|
+
ignoreValueFormatter
|
|
73
|
+
}).join(delimiterCharacter)}\r\n`, '').trim();
|
|
34
74
|
if (!includeHeaders) {
|
|
35
75
|
return CSVBody;
|
|
36
76
|
}
|
|
37
|
-
const CSVHead = `${columns.filter(column => column.field !== GRID_CHECKBOX_SELECTION_COL_DEF.field).map(column =>
|
|
77
|
+
const CSVHead = `${columns.filter(column => column.field !== GRID_CHECKBOX_SELECTION_COL_DEF.field).map(column => sanitizeCellValue(column.headerName || column.field, delimiterCharacter)).join(delimiterCharacter)}\r\n`;
|
|
38
78
|
return `${CSVHead}${CSVBody}`.trim();
|
|
39
79
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
|
+
import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
3
4
|
/**
|
|
4
5
|
* @requires useGridColumns (state)
|
|
5
6
|
* @requires useGridFilter (state)
|
|
@@ -7,4 +8,4 @@ import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
|
7
8
|
* @requires useGridSelection (state)
|
|
8
9
|
* @requires useGridParamsApi (method)
|
|
9
10
|
*/
|
|
10
|
-
export declare const useGridCsvExport: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>) => void;
|
|
11
|
+
export declare const useGridCsvExport: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'unstable_ignoreValueFormatterDuringExport'>) => void;
|
|
@@ -6,7 +6,7 @@ import { buildCSV } from './serializers/csvSerializer';
|
|
|
6
6
|
import { getColumnsToExport, defaultGetRowsToExport } from './utils';
|
|
7
7
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
8
8
|
import { GridCsvExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
|
|
9
|
-
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
/**
|
|
11
11
|
* @requires useGridColumns (state)
|
|
12
12
|
* @requires useGridFilter (state)
|
|
@@ -14,9 +14,10 @@ import { GridCsvExportMenuItem } from '../../../components/toolbar/GridToolbarEx
|
|
|
14
14
|
* @requires useGridSelection (state)
|
|
15
15
|
* @requires useGridParamsApi (method)
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
export const useGridCsvExport = apiRef => {
|
|
17
|
+
export const useGridCsvExport = (apiRef, props) => {
|
|
19
18
|
const logger = useGridLogger(apiRef, 'useGridCsvExport');
|
|
19
|
+
const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
|
|
20
|
+
const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.csvExport : ignoreValueFormatterProp) || false;
|
|
20
21
|
const getDataAsCsv = React.useCallback((options = {}) => {
|
|
21
22
|
var _options$getRowsToExp, _options$includeHeade;
|
|
22
23
|
logger.debug(`Get data as CSV`);
|
|
@@ -33,9 +34,10 @@ export const useGridCsvExport = apiRef => {
|
|
|
33
34
|
rowIds: exportedRowIds,
|
|
34
35
|
getCellParams: apiRef.current.getCellParams,
|
|
35
36
|
delimiterCharacter: options.delimiter || ',',
|
|
36
|
-
includeHeaders: (_options$includeHeade = options.includeHeaders) != null ? _options$includeHeade : true
|
|
37
|
+
includeHeaders: (_options$includeHeade = options.includeHeaders) != null ? _options$includeHeade : true,
|
|
38
|
+
ignoreValueFormatter
|
|
37
39
|
});
|
|
38
|
-
}, [logger, apiRef]);
|
|
40
|
+
}, [logger, apiRef, ignoreValueFormatter]);
|
|
39
41
|
const exportDataAsCsv = React.useCallback(options => {
|
|
40
42
|
logger.debug(`Export data as CSV`);
|
|
41
43
|
const csv = getDataAsCsv(options);
|
|
@@ -9,10 +9,12 @@ export type GridColumnGroupIdentifier = {
|
|
|
9
9
|
export interface GridFocusState {
|
|
10
10
|
cell: GridCellCoordinates | null;
|
|
11
11
|
columnHeader: GridColumnIdentifier | null;
|
|
12
|
+
columnHeaderFilter: GridColumnIdentifier | null;
|
|
12
13
|
columnGroupHeader: GridColumnGroupIdentifier | null;
|
|
13
14
|
}
|
|
14
15
|
export interface GridTabIndexState {
|
|
15
16
|
cell: GridCellCoordinates | null;
|
|
16
17
|
columnHeader: GridColumnIdentifier | null;
|
|
18
|
+
columnHeaderFilter: GridColumnIdentifier | null;
|
|
17
19
|
columnGroupHeader: GridColumnGroupIdentifier | null;
|
|
18
20
|
}
|
|
@@ -3,8 +3,10 @@ import { GridFocusState, GridTabIndexState } from './gridFocusState';
|
|
|
3
3
|
export declare const gridFocusStateSelector: (state: GridStateCommunity) => GridFocusState;
|
|
4
4
|
export declare const gridFocusCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
|
|
5
5
|
export declare const gridFocusColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
6
|
+
export declare const unstable_gridFocusColumnHeaderFilterSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
6
7
|
export declare const unstable_gridFocusColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
|
|
7
8
|
export declare const gridTabIndexStateSelector: (state: GridStateCommunity) => GridTabIndexState;
|
|
8
9
|
export declare const gridTabIndexCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
|
|
9
10
|
export declare const gridTabIndexColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
11
|
+
export declare const unstable_gridTabIndexColumnHeaderFilterSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
10
12
|
export declare const unstable_gridTabIndexColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
|
|
@@ -3,11 +3,17 @@ export const gridFocusStateSelector = state => state.focus;
|
|
|
3
3
|
export const gridFocusCellSelector = createSelector(gridFocusStateSelector, focusState => focusState.cell);
|
|
4
4
|
export const gridFocusColumnHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeader);
|
|
5
5
|
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const unstable_gridFocusColumnHeaderFilterSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeaderFilter);
|
|
8
|
+
|
|
6
9
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
10
|
export const unstable_gridFocusColumnGroupHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnGroupHeader);
|
|
8
11
|
export const gridTabIndexStateSelector = state => state.tabIndex;
|
|
9
12
|
export const gridTabIndexCellSelector = createSelector(gridTabIndexStateSelector, state => state.cell);
|
|
10
13
|
export const gridTabIndexColumnHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeader);
|
|
11
14
|
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
|
+
export const unstable_gridTabIndexColumnHeaderFilterSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeaderFilter);
|
|
17
|
+
|
|
12
18
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13
19
|
export const unstable_gridTabIndexColumnGroupHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnGroupHeader);
|
|
@@ -9,15 +9,18 @@ import { gridFocusCellSelector, unstable_gridFocusColumnGroupHeaderSelector } fr
|
|
|
9
9
|
import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
|
|
10
10
|
import { getVisibleRows } from '../../utils/useGridVisibleRows';
|
|
11
11
|
import { clamp } from '../../../utils/utils';
|
|
12
|
+
import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
12
13
|
export const focusStateInitializer = state => _extends({}, state, {
|
|
13
14
|
focus: {
|
|
14
15
|
cell: null,
|
|
15
16
|
columnHeader: null,
|
|
17
|
+
columnHeaderFilter: null,
|
|
16
18
|
columnGroupHeader: null
|
|
17
19
|
},
|
|
18
20
|
tabIndex: {
|
|
19
21
|
cell: null,
|
|
20
22
|
columnHeader: null,
|
|
23
|
+
columnHeaderFilter: null,
|
|
21
24
|
columnGroupHeader: null
|
|
22
25
|
}
|
|
23
26
|
});
|
|
@@ -52,6 +55,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
52
55
|
field
|
|
53
56
|
},
|
|
54
57
|
columnHeader: null,
|
|
58
|
+
columnHeaderFilter: null,
|
|
55
59
|
columnGroupHeader: null
|
|
56
60
|
},
|
|
57
61
|
focus: {
|
|
@@ -60,6 +64,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
60
64
|
field
|
|
61
65
|
},
|
|
62
66
|
columnHeader: null,
|
|
67
|
+
columnHeaderFilter: null,
|
|
63
68
|
columnGroupHeader: null
|
|
64
69
|
}
|
|
65
70
|
});
|
|
@@ -87,6 +92,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
87
92
|
columnHeader: {
|
|
88
93
|
field
|
|
89
94
|
},
|
|
95
|
+
columnHeaderFilter: null,
|
|
90
96
|
cell: null,
|
|
91
97
|
columnGroupHeader: null
|
|
92
98
|
},
|
|
@@ -94,6 +100,33 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
94
100
|
columnHeader: {
|
|
95
101
|
field
|
|
96
102
|
},
|
|
103
|
+
columnHeaderFilter: null,
|
|
104
|
+
cell: null,
|
|
105
|
+
columnGroupHeader: null
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
apiRef.current.forceUpdate();
|
|
110
|
+
}, [apiRef, logger, publishCellFocusOut]);
|
|
111
|
+
const setColumnHeaderFilterFocus = React.useCallback((field, event = {}) => {
|
|
112
|
+
const cell = gridFocusCellSelector(apiRef);
|
|
113
|
+
publishCellFocusOut(cell, event);
|
|
114
|
+
apiRef.current.setState(state => {
|
|
115
|
+
logger.debug(`Focusing on column header filter with colIndex=${field}`);
|
|
116
|
+
return _extends({}, state, {
|
|
117
|
+
tabIndex: {
|
|
118
|
+
columnHeader: null,
|
|
119
|
+
columnHeaderFilter: {
|
|
120
|
+
field
|
|
121
|
+
},
|
|
122
|
+
cell: null,
|
|
123
|
+
columnGroupHeader: null
|
|
124
|
+
},
|
|
125
|
+
focus: {
|
|
126
|
+
columnHeader: null,
|
|
127
|
+
columnHeaderFilter: {
|
|
128
|
+
field
|
|
129
|
+
},
|
|
97
130
|
cell: null,
|
|
98
131
|
columnGroupHeader: null
|
|
99
132
|
}
|
|
@@ -114,6 +147,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
114
147
|
depth
|
|
115
148
|
},
|
|
116
149
|
columnHeader: null,
|
|
150
|
+
columnHeaderFilter: null,
|
|
117
151
|
cell: null
|
|
118
152
|
},
|
|
119
153
|
focus: {
|
|
@@ -122,6 +156,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
122
156
|
depth
|
|
123
157
|
},
|
|
124
158
|
columnHeader: null,
|
|
159
|
+
columnHeaderFilter: null,
|
|
125
160
|
cell: null
|
|
126
161
|
}
|
|
127
162
|
});
|
|
@@ -131,8 +166,16 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
131
166
|
const getColumnGroupHeaderFocus = React.useCallback(() => unstable_gridFocusColumnGroupHeaderSelector(apiRef), [apiRef]);
|
|
132
167
|
const moveFocusToRelativeCell = React.useCallback((id, field, direction) => {
|
|
133
168
|
let columnIndexToFocus = apiRef.current.getColumnIndex(field);
|
|
134
|
-
let rowIndexToFocus = apiRef.current.getRowIndexRelativeToVisibleRows(id);
|
|
135
169
|
const visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
|
|
170
|
+
const currentPage = getVisibleRows(apiRef, {
|
|
171
|
+
pagination: props.pagination,
|
|
172
|
+
paginationMode: props.paginationMode
|
|
173
|
+
});
|
|
174
|
+
const pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
175
|
+
|
|
176
|
+
// Include pinned rows as well
|
|
177
|
+
const currentPageRows = [].concat(pinnedRows.top || [], currentPage.rows, pinnedRows.bottom || []);
|
|
178
|
+
let rowIndexToFocus = currentPageRows.findIndex(row => row.id === id);
|
|
136
179
|
if (direction === 'right') {
|
|
137
180
|
columnIndexToFocus += 1;
|
|
138
181
|
} else if (direction === 'left') {
|
|
@@ -140,14 +183,10 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
140
183
|
} else {
|
|
141
184
|
rowIndexToFocus += 1;
|
|
142
185
|
}
|
|
143
|
-
const currentPage = getVisibleRows(apiRef, {
|
|
144
|
-
pagination: props.pagination,
|
|
145
|
-
paginationMode: props.paginationMode
|
|
146
|
-
});
|
|
147
186
|
if (columnIndexToFocus >= visibleColumns.length) {
|
|
148
187
|
// Go to next row if we are after the last column
|
|
149
188
|
rowIndexToFocus += 1;
|
|
150
|
-
if (rowIndexToFocus <
|
|
189
|
+
if (rowIndexToFocus < currentPageRows.length) {
|
|
151
190
|
// Go to first column of the next row if there's one more row
|
|
152
191
|
columnIndexToFocus = 0;
|
|
153
192
|
}
|
|
@@ -159,8 +198,11 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
159
198
|
columnIndexToFocus = visibleColumns.length - 1;
|
|
160
199
|
}
|
|
161
200
|
}
|
|
162
|
-
rowIndexToFocus = clamp(rowIndexToFocus, 0,
|
|
163
|
-
const rowToFocus =
|
|
201
|
+
rowIndexToFocus = clamp(rowIndexToFocus, 0, currentPageRows.length - 1);
|
|
202
|
+
const rowToFocus = currentPageRows[rowIndexToFocus];
|
|
203
|
+
if (!rowToFocus) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
164
206
|
const colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
|
|
165
207
|
if (colSpanInfo && colSpanInfo.spannedByColSpan) {
|
|
166
208
|
if (direction === 'left' || direction === 'below') {
|
|
@@ -214,6 +256,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
214
256
|
focus: {
|
|
215
257
|
cell: null,
|
|
216
258
|
columnHeader: null,
|
|
259
|
+
columnHeaderFilter: null,
|
|
217
260
|
columnGroupHeader: null
|
|
218
261
|
}
|
|
219
262
|
}));
|
|
@@ -252,6 +295,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
252
295
|
focus: {
|
|
253
296
|
cell: null,
|
|
254
297
|
columnHeader: null,
|
|
298
|
+
columnHeaderFilter: null,
|
|
255
299
|
columnGroupHeader: null
|
|
256
300
|
}
|
|
257
301
|
}));
|
|
@@ -280,6 +324,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
280
324
|
focus: {
|
|
281
325
|
cell: null,
|
|
282
326
|
columnHeader: null,
|
|
327
|
+
columnHeaderFilter: null,
|
|
283
328
|
columnGroupHeader: null
|
|
284
329
|
}
|
|
285
330
|
}));
|
|
@@ -287,7 +332,8 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
287
332
|
}, [apiRef]);
|
|
288
333
|
const focusApi = {
|
|
289
334
|
setCellFocus,
|
|
290
|
-
setColumnHeaderFocus
|
|
335
|
+
setColumnHeaderFocus,
|
|
336
|
+
setColumnHeaderFilterFocus
|
|
291
337
|
};
|
|
292
338
|
const focusPrivateApi = {
|
|
293
339
|
moveFocusToRelativeCell,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
|
+
export declare const unstable_gridHeaderFilteringStateSelector: (state: GridStateCommunity) => import("../../../models/gridHeaderFilteringModel").GridHeaderFilteringState;
|
|
3
|
+
export declare const unstable_gridHeaderFilteringEditFieldSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string | null>;
|
|
4
|
+
export declare const unstable_gridHeaderFilteringMenuSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string | null>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import { createSelector } from '../../../utils/createSelector';
|
|
3
|
+
export const unstable_gridHeaderFilteringStateSelector = state => state.headerFiltering;
|
|
4
|
+
export const unstable_gridHeaderFilteringEditFieldSelector = createSelector(unstable_gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.editing);
|
|
5
|
+
export const unstable_gridHeaderFilteringMenuSelector = createSelector(unstable_gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.menuOpen);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridHeaderFilteringSelectors';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridHeaderFilteringSelectors';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
|
+
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
+
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
|
+
export declare const headerFilteringStateInitializer: GridStateInitializer;
|
|
6
|
+
export declare const useGridHeaderFiltering: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'signature'>) => void;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
|
+
import { useGridLogger } from '../../utils';
|
|
5
|
+
import { gridColumnLookupSelector, gridColumnVisibilityModelSelector, gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
6
|
+
export const headerFilteringStateInitializer = state => _extends({}, state, {
|
|
7
|
+
headerFiltering: {
|
|
8
|
+
editing: null,
|
|
9
|
+
menuOpen: null
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
export const useGridHeaderFiltering = (apiRef, props) => {
|
|
13
|
+
const logger = useGridLogger(apiRef, 'useGridHeaderFiltering');
|
|
14
|
+
const setHeaderFilterState = React.useCallback(headerFilterState => {
|
|
15
|
+
apiRef.current.setState(state => {
|
|
16
|
+
var _headerFilterState$ed, _headerFilterState$me;
|
|
17
|
+
// Safety check to avoid MIT users from using it
|
|
18
|
+
// This hook should ultimately be moved to the Pro package
|
|
19
|
+
if (props.signature === 'DataGrid') {
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
22
|
+
return _extends({}, state, {
|
|
23
|
+
headerFiltering: {
|
|
24
|
+
editing: (_headerFilterState$ed = headerFilterState.editing) != null ? _headerFilterState$ed : null,
|
|
25
|
+
menuOpen: (_headerFilterState$me = headerFilterState.menuOpen) != null ? _headerFilterState$me : null
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
apiRef.current.forceUpdate();
|
|
30
|
+
}, [apiRef, props.signature]);
|
|
31
|
+
const startHeaderFilterEditMode = React.useCallback(field => {
|
|
32
|
+
logger.debug(`Starting edit mode on header filter for field: ${field}`);
|
|
33
|
+
apiRef.current.setHeaderFilterState({
|
|
34
|
+
editing: field
|
|
35
|
+
});
|
|
36
|
+
}, [apiRef, logger]);
|
|
37
|
+
const stopHeaderFilterEditMode = React.useCallback(() => {
|
|
38
|
+
logger.debug(`Stopping edit mode on header filter`);
|
|
39
|
+
apiRef.current.setHeaderFilterState({
|
|
40
|
+
editing: null
|
|
41
|
+
});
|
|
42
|
+
}, [apiRef, logger]);
|
|
43
|
+
const showHeaderFilterMenu = React.useCallback(field => {
|
|
44
|
+
logger.debug(`Opening header filter menu for field: ${field}`);
|
|
45
|
+
apiRef.current.setHeaderFilterState({
|
|
46
|
+
menuOpen: field
|
|
47
|
+
});
|
|
48
|
+
}, [apiRef, logger]);
|
|
49
|
+
const hideHeaderFilterMenu = React.useCallback(() => {
|
|
50
|
+
logger.debug(`Hiding header filter menu for active field`);
|
|
51
|
+
let fieldToFocus = apiRef.current.state.headerFiltering.menuOpen;
|
|
52
|
+
if (fieldToFocus) {
|
|
53
|
+
const columnLookup = gridColumnLookupSelector(apiRef);
|
|
54
|
+
const columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
|
|
55
|
+
const orderedFields = gridColumnFieldsSelector(apiRef);
|
|
56
|
+
|
|
57
|
+
// If the column was removed from the grid, we need to find the closest visible field
|
|
58
|
+
if (!columnLookup[fieldToFocus]) {
|
|
59
|
+
fieldToFocus = orderedFields[0];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// If the field to focus is hidden, we need to find the closest visible field
|
|
63
|
+
if (columnVisibilityModel[fieldToFocus] === false) {
|
|
64
|
+
// contains visible column fields + the field that was just hidden
|
|
65
|
+
const visibleOrderedFields = orderedFields.filter(field => {
|
|
66
|
+
if (field === fieldToFocus) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return columnVisibilityModel[field] !== false;
|
|
70
|
+
});
|
|
71
|
+
const fieldIndex = visibleOrderedFields.indexOf(fieldToFocus);
|
|
72
|
+
fieldToFocus = visibleOrderedFields[fieldIndex + 1] || visibleOrderedFields[fieldIndex - 1];
|
|
73
|
+
}
|
|
74
|
+
apiRef.current.setHeaderFilterState({
|
|
75
|
+
menuOpen: null
|
|
76
|
+
});
|
|
77
|
+
apiRef.current.setColumnHeaderFilterFocus(fieldToFocus);
|
|
78
|
+
}
|
|
79
|
+
}, [apiRef, logger]);
|
|
80
|
+
const headerFilterPrivateApi = {
|
|
81
|
+
setHeaderFilterState
|
|
82
|
+
};
|
|
83
|
+
const headerFilterApi = {
|
|
84
|
+
startHeaderFilterEditMode,
|
|
85
|
+
stopHeaderFilterEditMode,
|
|
86
|
+
showHeaderFilterMenu,
|
|
87
|
+
hideHeaderFilterMenu
|
|
88
|
+
};
|
|
89
|
+
useGridApiMethod(apiRef, headerFilterApi, 'public');
|
|
90
|
+
useGridApiMethod(apiRef, headerFilterPrivateApi, 'private');
|
|
91
|
+
};
|
package/hooks/features/index.js
CHANGED
|
@@ -10,4 +10,4 @@ import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
|
10
10
|
* @requires useGridScroll (method) - can be after
|
|
11
11
|
* @requires useGridColumnSpanning (method) - can be after
|
|
12
12
|
*/
|
|
13
|
-
export declare const useGridKeyboardNavigation: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode' | 'getRowId'>) => void;
|
|
13
|
+
export declare const useGridKeyboardNavigation: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode' | 'getRowId' | 'experimentalFeatures' | 'signature'>) => void;
|