@mui/x-data-grid 7.0.0-alpha.9 → 7.0.0-beta.1
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 +386 -38
- package/DataGrid/useDataGridComponent.js +1 -1
- package/README.md +2 -2
- package/colDef/gridBooleanColDef.js +3 -6
- package/colDef/gridCheckboxSelectionColDef.js +4 -3
- package/colDef/gridDateColDef.d.ts +3 -4
- package/colDef/gridDateColDef.js +10 -16
- package/colDef/gridNumericColDef.js +1 -3
- package/colDef/gridSingleSelectColDef.js +7 -12
- package/components/GridRow.js +1 -100
- package/components/cell/GridEditInputCell.js +1 -1
- package/components/columnsManagement/GridColumnsManagement.d.ts +43 -0
- package/components/columnsManagement/GridColumnsManagement.js +265 -0
- package/components/columnsManagement/index.d.ts +1 -0
- package/components/columnsManagement/index.js +1 -0
- package/components/columnsManagement/utils.d.ts +4 -0
- package/components/columnsManagement/utils.js +16 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/panel/GridColumnsPanel.d.ts +0 -28
- package/components/panel/GridColumnsPanel.js +5 -213
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +12 -4
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +4 -6
- package/hooks/core/useGridApiInitialization.js +4 -0
- package/hooks/features/columns/useGridColumnSpanning.js +3 -1
- package/hooks/features/editing/useGridCellEditing.js +2 -5
- package/hooks/features/editing/useGridRowEditing.js +2 -5
- package/hooks/features/filter/gridFilterUtils.js +1 -1
- package/hooks/features/rows/gridRowsUtils.js +4 -1
- package/hooks/features/rows/useGridParamsApi.d.ts +1 -2
- package/hooks/features/rows/useGridParamsApi.js +14 -49
- package/index.js +1 -1
- package/legacy/DataGrid/useDataGridComponent.js +1 -1
- package/legacy/colDef/gridBooleanColDef.js +3 -5
- package/legacy/colDef/gridCheckboxSelectionColDef.js +4 -3
- package/legacy/colDef/gridDateColDef.js +10 -14
- package/legacy/colDef/gridNumericColDef.js +1 -2
- package/legacy/colDef/gridSingleSelectColDef.js +7 -10
- package/legacy/components/GridRow.js +1 -100
- package/legacy/components/cell/GridEditInputCell.js +1 -1
- package/legacy/components/columnsManagement/GridColumnsManagement.js +307 -0
- package/legacy/components/columnsManagement/index.js +1 -0
- package/legacy/components/columnsManagement/utils.js +22 -0
- package/legacy/components/index.js +1 -0
- package/legacy/components/panel/GridColumnsPanel.js +5 -233
- package/legacy/constants/defaultGridSlotsComponents.js +2 -1
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +4 -6
- package/legacy/hooks/core/useGridApiInitialization.js +4 -0
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +3 -1
- package/legacy/hooks/features/editing/useGridCellEditing.js +2 -5
- package/legacy/hooks/features/editing/useGridRowEditing.js +2 -5
- package/legacy/hooks/features/filter/gridFilterUtils.js +2 -2
- package/legacy/hooks/features/rows/gridRowsUtils.js +4 -1
- package/legacy/hooks/features/rows/useGridParamsApi.js +14 -47
- package/legacy/index.js +1 -1
- package/legacy/locales/arSD.js +5 -6
- package/legacy/locales/beBY.js +5 -6
- package/legacy/locales/bgBG.js +5 -6
- package/legacy/locales/csCZ.js +5 -6
- package/legacy/locales/daDK.js +5 -6
- package/legacy/locales/deDE.js +5 -6
- package/legacy/locales/elGR.js +5 -6
- package/legacy/locales/esES.js +5 -6
- package/legacy/locales/faIR.js +5 -6
- package/legacy/locales/fiFI.js +5 -6
- package/legacy/locales/frFR.js +5 -6
- package/legacy/locales/heIL.js +12 -14
- package/legacy/locales/hrHR.js +5 -6
- package/legacy/locales/huHU.js +5 -6
- package/legacy/locales/itIT.js +5 -6
- package/legacy/locales/jaJP.js +5 -6
- package/legacy/locales/koKR.js +5 -6
- package/legacy/locales/nbNO.js +5 -6
- package/legacy/locales/nlNL.js +5 -6
- package/legacy/locales/plPL.js +5 -6
- package/legacy/locales/ptBR.js +5 -6
- package/legacy/locales/ptPT.js +5 -6
- package/legacy/locales/roRO.js +5 -6
- package/legacy/locales/ruRU.js +5 -6
- package/legacy/locales/skSK.js +5 -6
- package/legacy/locales/svSE.js +5 -6
- package/legacy/locales/trTR.js +5 -6
- package/legacy/locales/ukUA.js +5 -6
- package/legacy/locales/urPK.js +5 -6
- package/legacy/locales/viVN.js +5 -6
- package/legacy/locales/zhCN.js +5 -6
- package/legacy/locales/zhHK.js +5 -6
- package/legacy/locales/zhTW.js +5 -6
- package/locales/arSD.js +5 -6
- package/locales/beBY.js +5 -6
- package/locales/bgBG.js +5 -6
- package/locales/csCZ.js +5 -6
- package/locales/daDK.js +5 -6
- package/locales/deDE.js +5 -6
- package/locales/elGR.js +5 -6
- package/locales/esES.js +5 -6
- package/locales/faIR.js +5 -6
- package/locales/fiFI.js +5 -6
- package/locales/frFR.js +5 -6
- package/locales/heIL.js +12 -14
- package/locales/hrHR.js +5 -6
- package/locales/huHU.js +5 -6
- package/locales/itIT.js +5 -6
- package/locales/jaJP.js +5 -6
- package/locales/koKR.js +5 -6
- package/locales/nbNO.js +5 -6
- package/locales/nlNL.js +5 -6
- package/locales/plPL.js +5 -6
- package/locales/ptBR.js +5 -6
- package/locales/ptPT.js +5 -6
- package/locales/roRO.js +5 -6
- package/locales/ruRU.js +5 -6
- package/locales/skSK.js +5 -6
- package/locales/svSE.js +5 -6
- package/locales/trTR.js +5 -6
- package/locales/ukUA.js +5 -6
- package/locales/urPK.js +5 -6
- package/locales/viVN.js +5 -6
- package/locales/zhCN.js +5 -6
- package/locales/zhHK.js +5 -6
- package/locales/zhTW.js +5 -6
- package/models/api/gridLocaleTextApi.d.ts +3 -5
- package/models/colDef/gridColDef.d.ts +11 -17
- package/models/colDef/gridColType.d.ts +11 -2
- package/models/colDef/index.d.ts +1 -1
- package/models/gridSlotsComponent.d.ts +5 -0
- package/models/gridSlotsComponentsProps.d.ts +4 -0
- package/models/params/gridCellParams.d.ts +0 -26
- package/modern/DataGrid/useDataGridComponent.js +1 -1
- package/modern/colDef/gridBooleanColDef.js +3 -6
- package/modern/colDef/gridCheckboxSelectionColDef.js +4 -3
- package/modern/colDef/gridDateColDef.js +10 -16
- package/modern/colDef/gridNumericColDef.js +1 -3
- package/modern/colDef/gridSingleSelectColDef.js +7 -12
- package/modern/components/GridRow.js +1 -100
- package/modern/components/cell/GridEditInputCell.js +1 -1
- package/modern/components/columnsManagement/GridColumnsManagement.js +261 -0
- package/modern/components/columnsManagement/index.js +1 -0
- package/modern/components/columnsManagement/utils.js +16 -0
- package/modern/components/index.js +1 -0
- package/modern/components/panel/GridColumnsPanel.js +4 -209
- package/modern/constants/defaultGridSlotsComponents.js +2 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +4 -6
- package/modern/hooks/core/useGridApiInitialization.js +3 -0
- package/modern/hooks/features/columns/useGridColumnSpanning.js +3 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +2 -5
- package/modern/hooks/features/editing/useGridRowEditing.js +2 -5
- package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +4 -1
- package/modern/hooks/features/rows/useGridParamsApi.js +14 -47
- package/modern/index.js +1 -1
- package/modern/locales/arSD.js +5 -6
- package/modern/locales/beBY.js +5 -6
- package/modern/locales/bgBG.js +5 -6
- package/modern/locales/csCZ.js +5 -6
- package/modern/locales/daDK.js +5 -6
- package/modern/locales/deDE.js +5 -6
- package/modern/locales/elGR.js +5 -6
- package/modern/locales/esES.js +5 -6
- package/modern/locales/faIR.js +5 -6
- package/modern/locales/fiFI.js +5 -6
- package/modern/locales/frFR.js +5 -6
- package/modern/locales/heIL.js +12 -14
- package/modern/locales/hrHR.js +5 -6
- package/modern/locales/huHU.js +5 -6
- package/modern/locales/itIT.js +5 -6
- package/modern/locales/jaJP.js +5 -6
- package/modern/locales/koKR.js +5 -6
- package/modern/locales/nbNO.js +5 -6
- package/modern/locales/nlNL.js +5 -6
- package/modern/locales/plPL.js +5 -6
- package/modern/locales/ptBR.js +5 -6
- package/modern/locales/ptPT.js +5 -6
- package/modern/locales/roRO.js +5 -6
- package/modern/locales/ruRU.js +5 -6
- package/modern/locales/skSK.js +5 -6
- package/modern/locales/svSE.js +5 -6
- package/modern/locales/trTR.js +5 -6
- package/modern/locales/ukUA.js +5 -6
- package/modern/locales/urPK.js +5 -6
- package/modern/locales/viVN.js +5 -6
- package/modern/locales/zhCN.js +5 -6
- package/modern/locales/zhHK.js +5 -6
- package/modern/locales/zhTW.js +5 -6
- package/node/DataGrid/useDataGridComponent.js +1 -1
- package/node/colDef/gridBooleanColDef.js +3 -6
- package/node/colDef/gridCheckboxSelectionColDef.js +4 -3
- package/node/colDef/gridDateColDef.js +13 -19
- package/node/colDef/gridNumericColDef.js +1 -3
- package/node/colDef/gridSingleSelectColDef.js +7 -12
- package/node/components/GridRow.js +1 -100
- package/node/components/cell/GridEditInputCell.js +1 -1
- package/node/components/columnsManagement/GridColumnsManagement.js +269 -0
- package/node/components/columnsManagement/index.js +16 -0
- package/node/components/columnsManagement/utils.js +24 -0
- package/node/components/index.js +11 -0
- package/node/components/panel/GridColumnsPanel.js +4 -208
- package/node/constants/defaultGridSlotsComponents.js +1 -0
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +4 -6
- package/node/hooks/core/useGridApiInitialization.js +3 -0
- package/node/hooks/features/columns/useGridColumnSpanning.js +3 -1
- package/node/hooks/features/editing/useGridCellEditing.js +2 -5
- package/node/hooks/features/editing/useGridRowEditing.js +2 -5
- package/node/hooks/features/filter/gridFilterUtils.js +1 -1
- package/node/hooks/features/rows/gridRowsUtils.js +4 -1
- package/node/hooks/features/rows/useGridParamsApi.js +14 -47
- package/node/index.js +1 -1
- package/node/locales/arSD.js +5 -6
- package/node/locales/beBY.js +5 -6
- package/node/locales/bgBG.js +5 -6
- package/node/locales/csCZ.js +5 -6
- package/node/locales/daDK.js +5 -6
- package/node/locales/deDE.js +5 -6
- package/node/locales/elGR.js +5 -6
- package/node/locales/esES.js +5 -6
- package/node/locales/faIR.js +5 -6
- package/node/locales/fiFI.js +5 -6
- package/node/locales/frFR.js +5 -6
- package/node/locales/heIL.js +12 -14
- package/node/locales/hrHR.js +5 -6
- package/node/locales/huHU.js +5 -6
- package/node/locales/itIT.js +5 -6
- package/node/locales/jaJP.js +5 -6
- package/node/locales/koKR.js +5 -6
- package/node/locales/nbNO.js +5 -6
- package/node/locales/nlNL.js +5 -6
- package/node/locales/plPL.js +5 -6
- package/node/locales/ptBR.js +5 -6
- package/node/locales/ptPT.js +5 -6
- package/node/locales/roRO.js +5 -6
- package/node/locales/ruRU.js +5 -6
- package/node/locales/skSK.js +5 -6
- package/node/locales/svSE.js +5 -6
- package/node/locales/trTR.js +5 -6
- package/node/locales/ukUA.js +5 -6
- package/node/locales/urPK.js +5 -6
- package/node/locales/viVN.js +5 -6
- package/node/locales/zhCN.js +5 -6
- package/node/locales/zhHK.js +5 -6
- package/node/locales/zhTW.js +5 -6
- package/package.json +4 -4
|
@@ -4,12 +4,9 @@ import { renderBooleanCell } from '../components/cell/GridBooleanCell';
|
|
|
4
4
|
import { renderEditBooleanCell } from '../components/cell/GridEditBooleanCell';
|
|
5
5
|
import { gridNumberComparator } from '../hooks/features/sorting/gridSortingUtils';
|
|
6
6
|
import { getGridBooleanOperators } from './gridBooleanOperators';
|
|
7
|
-
|
|
8
|
-
value
|
|
9
|
-
|
|
10
|
-
}) {
|
|
11
|
-
return value ? api.getLocaleText('booleanCellTrueLabel') : api.getLocaleText('booleanCellFalseLabel');
|
|
12
|
-
}
|
|
7
|
+
const gridBooleanFormatter = (value, row, column, apiRef) => {
|
|
8
|
+
return value ? apiRef.current.getLocaleText('booleanCellTrueLabel') : apiRef.current.getLocaleText('booleanCellFalseLabel');
|
|
9
|
+
};
|
|
13
10
|
const stringToBoolean = value => {
|
|
14
11
|
switch (value.toLowerCase().trim()) {
|
|
15
12
|
case 'true':
|
|
@@ -19,9 +19,10 @@ export const GRID_CHECKBOX_SELECTION_COL_DEF = _extends({}, GRID_BOOLEAN_COL_DEF
|
|
|
19
19
|
disableReorder: true,
|
|
20
20
|
disableExport: true,
|
|
21
21
|
getApplyQuickFilterFn: undefined,
|
|
22
|
-
valueGetter:
|
|
23
|
-
const selectionLookup = selectedIdsLookupSelector(
|
|
24
|
-
|
|
22
|
+
valueGetter: (value, row, column, apiRef) => {
|
|
23
|
+
const selectionLookup = selectedIdsLookupSelector(apiRef);
|
|
24
|
+
const rowId = apiRef.current.getRowId(row);
|
|
25
|
+
return selectionLookup[rowId] !== undefined;
|
|
25
26
|
},
|
|
26
27
|
renderHeader: params => /*#__PURE__*/_jsx(GridHeaderCheckbox, _extends({}, params)),
|
|
27
28
|
renderCell: params => /*#__PURE__*/_jsx(GridCellCheckboxRenderer, _extends({}, params))
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { GridColTypeDef } from '../models/colDef/gridColDef';
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export declare function gridDateTimeFormatter({ value, field, id }: GridValueFormatterParams<Date>): string;
|
|
1
|
+
import { GridColTypeDef, GridValueFormatter } from '../models/colDef/gridColDef';
|
|
2
|
+
export declare const gridDateFormatter: GridValueFormatter;
|
|
3
|
+
export declare const gridDateTimeFormatter: GridValueFormatter;
|
|
5
4
|
export declare const GRID_DATE_COL_DEF: GridColTypeDef<Date, string>;
|
|
6
5
|
export declare const GRID_DATETIME_COL_DEF: GridColTypeDef<Date, string>;
|
package/colDef/gridDateColDef.js
CHANGED
|
@@ -13,38 +13,32 @@ function throwIfNotDateObject({
|
|
|
13
13
|
throw new Error([`MUI X: \`${columnType}\` column type only accepts \`Date\` objects as values.`, 'Use `valueGetter` to transform the value into a `Date` object.', `Row ID: ${rowId}, field: "${field}".`].join('\n'));
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
export
|
|
17
|
-
value,
|
|
18
|
-
field,
|
|
19
|
-
id
|
|
20
|
-
}) {
|
|
16
|
+
export const gridDateFormatter = (value, row, column, apiRef) => {
|
|
21
17
|
if (!value) {
|
|
22
18
|
return '';
|
|
23
19
|
}
|
|
20
|
+
const rowId = apiRef.current.getRowId(row);
|
|
24
21
|
throwIfNotDateObject({
|
|
25
22
|
value,
|
|
26
23
|
columnType: 'date',
|
|
27
|
-
rowId
|
|
28
|
-
field
|
|
24
|
+
rowId,
|
|
25
|
+
field: column.field
|
|
29
26
|
});
|
|
30
27
|
return value.toLocaleDateString();
|
|
31
|
-
}
|
|
32
|
-
export
|
|
33
|
-
value,
|
|
34
|
-
field,
|
|
35
|
-
id
|
|
36
|
-
}) {
|
|
28
|
+
};
|
|
29
|
+
export const gridDateTimeFormatter = (value, row, column, apiRef) => {
|
|
37
30
|
if (!value) {
|
|
38
31
|
return '';
|
|
39
32
|
}
|
|
33
|
+
const rowId = apiRef.current.getRowId(row);
|
|
40
34
|
throwIfNotDateObject({
|
|
41
35
|
value,
|
|
42
36
|
columnType: 'dateTime',
|
|
43
|
-
rowId
|
|
44
|
-
field
|
|
37
|
+
rowId,
|
|
38
|
+
field: column.field
|
|
45
39
|
});
|
|
46
40
|
return value.toLocaleString();
|
|
47
|
-
}
|
|
41
|
+
};
|
|
48
42
|
export const GRID_DATE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
49
43
|
type: 'date',
|
|
50
44
|
sortComparator: gridDateComparator,
|
|
@@ -9,9 +9,7 @@ export const GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
9
9
|
headerAlign: 'right',
|
|
10
10
|
sortComparator: gridNumberComparator,
|
|
11
11
|
valueParser: value => value === '' ? null : Number(value),
|
|
12
|
-
valueFormatter: (
|
|
13
|
-
value
|
|
14
|
-
}) => isNumber(value) ? value.toLocaleString() : value || '',
|
|
12
|
+
valueFormatter: value => isNumber(value) ? value.toLocaleString() : value || '',
|
|
15
13
|
filterOperators: getGridNumericOperators(),
|
|
16
14
|
getApplyQuickFilterFn: getGridNumericQuickFilterFn
|
|
17
15
|
});
|
|
@@ -17,20 +17,15 @@ export const GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
17
17
|
type: 'singleSelect',
|
|
18
18
|
getOptionLabel: defaultGetOptionLabel,
|
|
19
19
|
getOptionValue: defaultGetOptionValue,
|
|
20
|
-
valueFormatter(
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
field,
|
|
24
|
-
value,
|
|
25
|
-
api
|
|
26
|
-
} = params;
|
|
27
|
-
const colDef = params.api.getColumn(field);
|
|
20
|
+
valueFormatter(value, row, colDef, apiRef) {
|
|
21
|
+
// const { id, field, value, api } = params;
|
|
22
|
+
const rowId = apiRef.current.getRowId(row);
|
|
28
23
|
if (!isSingleSelectColDef(colDef)) {
|
|
29
24
|
return '';
|
|
30
25
|
}
|
|
31
26
|
const valueOptions = getValueOptions(colDef, {
|
|
32
|
-
id,
|
|
33
|
-
row
|
|
27
|
+
id: rowId,
|
|
28
|
+
row
|
|
34
29
|
});
|
|
35
30
|
if (value == null) {
|
|
36
31
|
return '';
|
|
@@ -47,8 +42,8 @@ export const GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
47
42
|
renderEditCell: renderEditSingleSelectCell,
|
|
48
43
|
filterOperators: getGridSingleSelectOperators(),
|
|
49
44
|
// @ts-ignore
|
|
50
|
-
pastedValueParser: (value,
|
|
51
|
-
const colDef =
|
|
45
|
+
pastedValueParser: (value, row, column) => {
|
|
46
|
+
const colDef = column;
|
|
52
47
|
const valueOptions = getValueOptions(colDef) || [];
|
|
53
48
|
const getOptionValue = colDef.getOptionValue;
|
|
54
49
|
const valueOption = valueOptions.find(option => {
|
package/components/GridRow.js
CHANGED
|
@@ -436,106 +436,7 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
436
436
|
onDoubleClick: PropTypes.func,
|
|
437
437
|
onMouseEnter: PropTypes.func,
|
|
438
438
|
onMouseLeave: PropTypes.func,
|
|
439
|
-
pinnedColumns: PropTypes.
|
|
440
|
-
left: PropTypes.arrayOf(PropTypes.shape({
|
|
441
|
-
align: PropTypes.oneOf(['center', 'left', 'right']),
|
|
442
|
-
cellClassName: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
443
|
-
colSpan: PropTypes.oneOfType([PropTypes.func, PropTypes.number]),
|
|
444
|
-
computedWidth: PropTypes.number.isRequired,
|
|
445
|
-
description: PropTypes.string,
|
|
446
|
-
disableColumnMenu: PropTypes.bool,
|
|
447
|
-
disableExport: PropTypes.bool,
|
|
448
|
-
disableReorder: PropTypes.bool,
|
|
449
|
-
editable: PropTypes.bool,
|
|
450
|
-
field: PropTypes.string.isRequired,
|
|
451
|
-
filterable: PropTypes.bool,
|
|
452
|
-
filterOperators: PropTypes.arrayOf(PropTypes.shape({
|
|
453
|
-
getApplyFilterFn: PropTypes.func.isRequired,
|
|
454
|
-
getValueAsString: PropTypes.func,
|
|
455
|
-
headerLabel: PropTypes.string,
|
|
456
|
-
InputComponent: PropTypes.elementType,
|
|
457
|
-
InputComponentProps: PropTypes.object,
|
|
458
|
-
label: PropTypes.string,
|
|
459
|
-
requiresFilterValue: PropTypes.bool,
|
|
460
|
-
value: PropTypes.string.isRequired
|
|
461
|
-
})),
|
|
462
|
-
flex: PropTypes.number,
|
|
463
|
-
getApplyQuickFilterFn: PropTypes.func,
|
|
464
|
-
groupable: PropTypes.bool,
|
|
465
|
-
hasBeenResized: PropTypes.bool,
|
|
466
|
-
headerAlign: PropTypes.oneOf(['center', 'left', 'right']),
|
|
467
|
-
headerClassName: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
468
|
-
headerName: PropTypes.string,
|
|
469
|
-
hideable: PropTypes.bool,
|
|
470
|
-
hideSortIcons: PropTypes.bool,
|
|
471
|
-
maxWidth: PropTypes.number,
|
|
472
|
-
minWidth: PropTypes.number,
|
|
473
|
-
pinnable: PropTypes.bool,
|
|
474
|
-
preProcessEditCellProps: PropTypes.func,
|
|
475
|
-
renderCell: PropTypes.func,
|
|
476
|
-
renderEditCell: PropTypes.func,
|
|
477
|
-
renderHeader: PropTypes.func,
|
|
478
|
-
resizable: PropTypes.bool,
|
|
479
|
-
sortable: PropTypes.bool,
|
|
480
|
-
sortComparator: PropTypes.func,
|
|
481
|
-
sortingOrder: PropTypes.arrayOf(PropTypes.oneOf(['asc', 'desc'])),
|
|
482
|
-
type: PropTypes.oneOf(['actions', 'boolean', 'custom', 'date', 'dateTime', 'number', 'singleSelect', 'string']),
|
|
483
|
-
valueFormatter: PropTypes.func,
|
|
484
|
-
valueGetter: PropTypes.func,
|
|
485
|
-
valueParser: PropTypes.func,
|
|
486
|
-
valueSetter: PropTypes.func,
|
|
487
|
-
width: PropTypes.number
|
|
488
|
-
})).isRequired,
|
|
489
|
-
right: PropTypes.arrayOf(PropTypes.shape({
|
|
490
|
-
align: PropTypes.oneOf(['center', 'left', 'right']),
|
|
491
|
-
cellClassName: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
492
|
-
colSpan: PropTypes.oneOfType([PropTypes.func, PropTypes.number]),
|
|
493
|
-
computedWidth: PropTypes.number.isRequired,
|
|
494
|
-
description: PropTypes.string,
|
|
495
|
-
disableColumnMenu: PropTypes.bool,
|
|
496
|
-
disableExport: PropTypes.bool,
|
|
497
|
-
disableReorder: PropTypes.bool,
|
|
498
|
-
editable: PropTypes.bool,
|
|
499
|
-
field: PropTypes.string.isRequired,
|
|
500
|
-
filterable: PropTypes.bool,
|
|
501
|
-
filterOperators: PropTypes.arrayOf(PropTypes.shape({
|
|
502
|
-
getApplyFilterFn: PropTypes.func.isRequired,
|
|
503
|
-
getValueAsString: PropTypes.func,
|
|
504
|
-
headerLabel: PropTypes.string,
|
|
505
|
-
InputComponent: PropTypes.elementType,
|
|
506
|
-
InputComponentProps: PropTypes.object,
|
|
507
|
-
label: PropTypes.string,
|
|
508
|
-
requiresFilterValue: PropTypes.bool,
|
|
509
|
-
value: PropTypes.string.isRequired
|
|
510
|
-
})),
|
|
511
|
-
flex: PropTypes.number,
|
|
512
|
-
getApplyQuickFilterFn: PropTypes.func,
|
|
513
|
-
groupable: PropTypes.bool,
|
|
514
|
-
hasBeenResized: PropTypes.bool,
|
|
515
|
-
headerAlign: PropTypes.oneOf(['center', 'left', 'right']),
|
|
516
|
-
headerClassName: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
517
|
-
headerName: PropTypes.string,
|
|
518
|
-
hideable: PropTypes.bool,
|
|
519
|
-
hideSortIcons: PropTypes.bool,
|
|
520
|
-
maxWidth: PropTypes.number,
|
|
521
|
-
minWidth: PropTypes.number,
|
|
522
|
-
pinnable: PropTypes.bool,
|
|
523
|
-
preProcessEditCellProps: PropTypes.func,
|
|
524
|
-
renderCell: PropTypes.func,
|
|
525
|
-
renderEditCell: PropTypes.func,
|
|
526
|
-
renderHeader: PropTypes.func,
|
|
527
|
-
resizable: PropTypes.bool,
|
|
528
|
-
sortable: PropTypes.bool,
|
|
529
|
-
sortComparator: PropTypes.func,
|
|
530
|
-
sortingOrder: PropTypes.arrayOf(PropTypes.oneOf(['asc', 'desc'])),
|
|
531
|
-
type: PropTypes.oneOf(['actions', 'boolean', 'custom', 'date', 'dateTime', 'number', 'singleSelect', 'string']),
|
|
532
|
-
valueFormatter: PropTypes.func,
|
|
533
|
-
valueGetter: PropTypes.func,
|
|
534
|
-
valueParser: PropTypes.func,
|
|
535
|
-
valueSetter: PropTypes.func,
|
|
536
|
-
width: PropTypes.number
|
|
537
|
-
})).isRequired
|
|
538
|
-
}).isRequired,
|
|
439
|
+
pinnedColumns: PropTypes.object.isRequired,
|
|
539
440
|
renderedColumns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
540
441
|
row: PropTypes.object,
|
|
541
442
|
rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
|
|
@@ -57,7 +57,7 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
57
57
|
const column = apiRef.current.getColumn(field);
|
|
58
58
|
let parsedValue = newValue;
|
|
59
59
|
if (column.valueParser) {
|
|
60
|
-
parsedValue = column.valueParser(newValue, apiRef.current.
|
|
60
|
+
parsedValue = column.valueParser(newValue, apiRef.current.getRow(id), column, apiRef);
|
|
61
61
|
}
|
|
62
62
|
setValueState(parsedValue);
|
|
63
63
|
apiRef.current.setEditCellValue({
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { GridColDef } from '../../models/colDef/gridColDef';
|
|
3
|
+
export interface GridColumnsManagementProps {
|
|
4
|
+
sort?: 'asc' | 'desc';
|
|
5
|
+
searchPredicate?: (column: GridColDef, searchValue: string) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* If `true`, the column search field will be focused automatically.
|
|
8
|
+
* If `false`, the first column switch input will be focused automatically.
|
|
9
|
+
* This helps to avoid input keyboard panel to popup automatically on touch devices.
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
autoFocusSearchField?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* If `true`, the `Show/Hide all` toggle checkbox will not be displayed.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
disableShowHideToggle?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* If `true`, the `Reset` button will not be disabled
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
disableResetButton?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Changes the behavior of the `Show/Hide All` toggle when the search field is used:
|
|
25
|
+
* - `all`: Will toggle all columns.
|
|
26
|
+
* - `filteredOnly`: Will only toggle columns that match the search criteria.
|
|
27
|
+
* @default 'all'
|
|
28
|
+
*/
|
|
29
|
+
toggleAllMode?: 'all' | 'filteredOnly';
|
|
30
|
+
/**
|
|
31
|
+
* Returns the list of togglable columns.
|
|
32
|
+
* If used, only those columns will be displayed in the panel
|
|
33
|
+
* which are passed as the return value of the function.
|
|
34
|
+
* @param {GridColDef[]} columns The `ColDef` list of all columns.
|
|
35
|
+
* @returns {GridColDef['field'][]} The list of togglable columns' field names.
|
|
36
|
+
*/
|
|
37
|
+
getTogglableColumns?: (columns: GridColDef[]) => GridColDef['field'][];
|
|
38
|
+
}
|
|
39
|
+
declare function GridColumnsManagement(props: GridColumnsManagementProps): React.JSX.Element;
|
|
40
|
+
declare namespace GridColumnsManagement {
|
|
41
|
+
var propTypes: any;
|
|
42
|
+
}
|
|
43
|
+
export { GridColumnsManagement };
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
6
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
7
|
+
import { styled } from '@mui/material/styles';
|
|
8
|
+
import { gridColumnDefinitionsSelector, gridColumnVisibilityModelSelector } from '../../hooks/features/columns/gridColumnsSelector';
|
|
9
|
+
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
10
|
+
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
11
|
+
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
12
|
+
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
13
|
+
import { useLazyRef } from '../../hooks/utils/useLazyRef';
|
|
14
|
+
import { checkColumnVisibilityModelsSame, defaultSearchPredicate } from './utils';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
const useUtilityClasses = ownerState => {
|
|
18
|
+
const {
|
|
19
|
+
classes
|
|
20
|
+
} = ownerState;
|
|
21
|
+
const slots = {
|
|
22
|
+
root: ['columnsManagement'],
|
|
23
|
+
header: ['columnsManagementHeader'],
|
|
24
|
+
footer: ['columnsManagementFooter'],
|
|
25
|
+
row: ['columnsManagementRow']
|
|
26
|
+
};
|
|
27
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
28
|
+
};
|
|
29
|
+
const collator = new Intl.Collator();
|
|
30
|
+
function GridColumnsManagement(props) {
|
|
31
|
+
var _rootProps$slotProps, _rootProps$slotProps3, _rootProps$slotProps4;
|
|
32
|
+
const apiRef = useGridApiContext();
|
|
33
|
+
const searchInputRef = React.useRef(null);
|
|
34
|
+
const columns = useGridSelector(apiRef, gridColumnDefinitionsSelector);
|
|
35
|
+
const initialColumnVisibilityModel = useLazyRef(() => gridColumnVisibilityModelSelector(apiRef)).current;
|
|
36
|
+
const columnVisibilityModel = useGridSelector(apiRef, gridColumnVisibilityModelSelector);
|
|
37
|
+
const rootProps = useGridRootProps();
|
|
38
|
+
const [searchValue, setSearchValue] = React.useState('');
|
|
39
|
+
const classes = useUtilityClasses(rootProps);
|
|
40
|
+
const {
|
|
41
|
+
sort,
|
|
42
|
+
searchPredicate = defaultSearchPredicate,
|
|
43
|
+
autoFocusSearchField = true,
|
|
44
|
+
disableShowHideToggle = false,
|
|
45
|
+
disableResetButton = false,
|
|
46
|
+
toggleAllMode = 'all',
|
|
47
|
+
getTogglableColumns
|
|
48
|
+
} = props;
|
|
49
|
+
const isResetDisabled = React.useMemo(() => checkColumnVisibilityModelsSame(columnVisibilityModel, initialColumnVisibilityModel), [columnVisibilityModel, initialColumnVisibilityModel]);
|
|
50
|
+
const sortedColumns = React.useMemo(() => {
|
|
51
|
+
switch (sort) {
|
|
52
|
+
case 'asc':
|
|
53
|
+
return [...columns].sort((a, b) => collator.compare(a.headerName || a.field, b.headerName || b.field));
|
|
54
|
+
case 'desc':
|
|
55
|
+
return [...columns].sort((a, b) => -collator.compare(a.headerName || a.field, b.headerName || b.field));
|
|
56
|
+
default:
|
|
57
|
+
return columns;
|
|
58
|
+
}
|
|
59
|
+
}, [columns, sort]);
|
|
60
|
+
const toggleColumn = event => {
|
|
61
|
+
const {
|
|
62
|
+
name: field
|
|
63
|
+
} = event.target;
|
|
64
|
+
apiRef.current.setColumnVisibility(field, columnVisibilityModel[field] === false);
|
|
65
|
+
};
|
|
66
|
+
const currentColumns = React.useMemo(() => {
|
|
67
|
+
const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
|
|
68
|
+
const togglableSortedColumns = togglableColumns ? sortedColumns.filter(({
|
|
69
|
+
field
|
|
70
|
+
}) => togglableColumns.includes(field)) : sortedColumns;
|
|
71
|
+
if (!searchValue) {
|
|
72
|
+
return togglableSortedColumns;
|
|
73
|
+
}
|
|
74
|
+
return togglableSortedColumns.filter(column => searchPredicate(column, searchValue.toLowerCase()));
|
|
75
|
+
}, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
|
|
76
|
+
const toggleAllColumns = React.useCallback(isVisible => {
|
|
77
|
+
const currentModel = gridColumnVisibilityModelSelector(apiRef);
|
|
78
|
+
const newModel = _extends({}, currentModel);
|
|
79
|
+
const togglableColumns = getTogglableColumns ? getTogglableColumns(columns) : null;
|
|
80
|
+
(toggleAllMode === 'filteredOnly' ? currentColumns : columns).forEach(col => {
|
|
81
|
+
if (col.hideable && (togglableColumns == null || togglableColumns.includes(col.field))) {
|
|
82
|
+
if (isVisible) {
|
|
83
|
+
// delete the key from the model instead of setting it to `true`
|
|
84
|
+
delete newModel[col.field];
|
|
85
|
+
} else {
|
|
86
|
+
newModel[col.field] = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return apiRef.current.setColumnVisibilityModel(newModel);
|
|
91
|
+
}, [apiRef, columns, getTogglableColumns, toggleAllMode, currentColumns]);
|
|
92
|
+
const handleSearchValueChange = React.useCallback(event => {
|
|
93
|
+
setSearchValue(event.target.value);
|
|
94
|
+
}, []);
|
|
95
|
+
const hideableColumns = React.useMemo(() => currentColumns.filter(col => col.hideable), [currentColumns]);
|
|
96
|
+
const allHideableColumnsVisible = React.useMemo(() => hideableColumns.every(column => columnVisibilityModel[column.field] == null || columnVisibilityModel[column.field] !== false), [columnVisibilityModel, hideableColumns]);
|
|
97
|
+
const allHideableColumnsHidden = React.useMemo(() => hideableColumns.every(column => columnVisibilityModel[column.field] === false), [columnVisibilityModel, hideableColumns]);
|
|
98
|
+
const firstSwitchRef = React.useRef(null);
|
|
99
|
+
React.useEffect(() => {
|
|
100
|
+
if (autoFocusSearchField) {
|
|
101
|
+
searchInputRef.current.focus();
|
|
102
|
+
} else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
|
|
103
|
+
firstSwitchRef.current.focus();
|
|
104
|
+
}
|
|
105
|
+
}, [autoFocusSearchField]);
|
|
106
|
+
let firstHideableColumnFound = false;
|
|
107
|
+
const isFirstHideableColumn = column => {
|
|
108
|
+
if (firstHideableColumnFound === false && column.hideable !== false) {
|
|
109
|
+
firstHideableColumnFound = true;
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
};
|
|
114
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
115
|
+
children: [/*#__PURE__*/_jsx(GridColumnsManagementHeader, {
|
|
116
|
+
className: classes.header,
|
|
117
|
+
ownerState: rootProps,
|
|
118
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseTextField, _extends({
|
|
119
|
+
placeholder: apiRef.current.getLocaleText('columnsManagementSearchTitle'),
|
|
120
|
+
inputRef: searchInputRef,
|
|
121
|
+
value: searchValue,
|
|
122
|
+
onChange: handleSearchValueChange,
|
|
123
|
+
variant: "outlined",
|
|
124
|
+
size: "small",
|
|
125
|
+
InputProps: {
|
|
126
|
+
startAdornment: /*#__PURE__*/_jsx(rootProps.slots.baseInputAdornment, {
|
|
127
|
+
position: "start",
|
|
128
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.quickFilterIcon, {})
|
|
129
|
+
}),
|
|
130
|
+
sx: {
|
|
131
|
+
pl: 1.5
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
fullWidth: true
|
|
135
|
+
}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseTextField))
|
|
136
|
+
}), /*#__PURE__*/_jsxs(GridColumnsManagementBody, {
|
|
137
|
+
className: classes.root,
|
|
138
|
+
ownerState: rootProps,
|
|
139
|
+
children: [currentColumns.map(column => {
|
|
140
|
+
var _rootProps$slotProps2;
|
|
141
|
+
return /*#__PURE__*/_jsx(FormControlLabel, {
|
|
142
|
+
className: classes.row,
|
|
143
|
+
control: /*#__PURE__*/_jsx(rootProps.slots.baseCheckbox, _extends({
|
|
144
|
+
disabled: column.hideable === false,
|
|
145
|
+
checked: columnVisibilityModel[column.field] !== false,
|
|
146
|
+
onClick: toggleColumn,
|
|
147
|
+
name: column.field,
|
|
148
|
+
sx: {
|
|
149
|
+
p: 0.5
|
|
150
|
+
},
|
|
151
|
+
inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
|
|
152
|
+
}, (_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseCheckbox)),
|
|
153
|
+
label: column.headerName || column.field
|
|
154
|
+
}, column.field);
|
|
155
|
+
}), currentColumns.length === 0 && /*#__PURE__*/_jsx(GridColumnsManagementEmptyText, {
|
|
156
|
+
ownerState: rootProps,
|
|
157
|
+
children: apiRef.current.getLocaleText('columnsManagementNoColumns')
|
|
158
|
+
})]
|
|
159
|
+
}), !disableShowHideToggle && !disableResetButton && currentColumns.length > 0 ? /*#__PURE__*/_jsxs(GridColumnsManagementFooter, {
|
|
160
|
+
ownerState: rootProps,
|
|
161
|
+
className: classes.footer,
|
|
162
|
+
children: [!disableShowHideToggle ? /*#__PURE__*/_jsx(FormControlLabel, {
|
|
163
|
+
control: /*#__PURE__*/_jsx(rootProps.slots.baseCheckbox, _extends({
|
|
164
|
+
disabled: hideableColumns.length === 0,
|
|
165
|
+
checked: allHideableColumnsVisible,
|
|
166
|
+
indeterminate: !allHideableColumnsVisible && !allHideableColumnsHidden,
|
|
167
|
+
onClick: () => toggleAllColumns(!allHideableColumnsVisible),
|
|
168
|
+
name: apiRef.current.getLocaleText('columnsManagementShowHideAllText'),
|
|
169
|
+
sx: {
|
|
170
|
+
p: 0.5
|
|
171
|
+
}
|
|
172
|
+
}, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseCheckbox)),
|
|
173
|
+
label: apiRef.current.getLocaleText('columnsManagementShowHideAllText')
|
|
174
|
+
}) : /*#__PURE__*/_jsx("span", {}), !disableResetButton ? /*#__PURE__*/_jsx(rootProps.slots.baseButton, _extends({
|
|
175
|
+
onClick: () => apiRef.current.setColumnVisibilityModel(initialColumnVisibilityModel),
|
|
176
|
+
disabled: isResetDisabled
|
|
177
|
+
}, (_rootProps$slotProps4 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps4.baseButton, {
|
|
178
|
+
children: "Reset"
|
|
179
|
+
})) : null]
|
|
180
|
+
}) : null]
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
process.env.NODE_ENV !== "production" ? GridColumnsManagement.propTypes = {
|
|
184
|
+
// ----------------------------- Warning --------------------------------
|
|
185
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
186
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
187
|
+
// ----------------------------------------------------------------------
|
|
188
|
+
/**
|
|
189
|
+
* If `true`, the column search field will be focused automatically.
|
|
190
|
+
* If `false`, the first column switch input will be focused automatically.
|
|
191
|
+
* This helps to avoid input keyboard panel to popup automatically on touch devices.
|
|
192
|
+
* @default true
|
|
193
|
+
*/
|
|
194
|
+
autoFocusSearchField: PropTypes.bool,
|
|
195
|
+
/**
|
|
196
|
+
* If `true`, the `Reset` button will not be disabled
|
|
197
|
+
* @default false
|
|
198
|
+
*/
|
|
199
|
+
disableResetButton: PropTypes.bool,
|
|
200
|
+
/**
|
|
201
|
+
* If `true`, the `Show/Hide all` toggle checkbox will not be displayed.
|
|
202
|
+
* @default false
|
|
203
|
+
*/
|
|
204
|
+
disableShowHideToggle: PropTypes.bool,
|
|
205
|
+
/**
|
|
206
|
+
* Returns the list of togglable columns.
|
|
207
|
+
* If used, only those columns will be displayed in the panel
|
|
208
|
+
* which are passed as the return value of the function.
|
|
209
|
+
* @param {GridColDef[]} columns The `ColDef` list of all columns.
|
|
210
|
+
* @returns {GridColDef['field'][]} The list of togglable columns' field names.
|
|
211
|
+
*/
|
|
212
|
+
getTogglableColumns: PropTypes.func,
|
|
213
|
+
searchPredicate: PropTypes.func,
|
|
214
|
+
sort: PropTypes.oneOf(['asc', 'desc']),
|
|
215
|
+
/**
|
|
216
|
+
* Changes the behavior of the `Show/Hide All` toggle when the search field is used:
|
|
217
|
+
* - `all`: Will toggle all columns.
|
|
218
|
+
* - `filteredOnly`: Will only toggle columns that match the search criteria.
|
|
219
|
+
* @default 'all'
|
|
220
|
+
*/
|
|
221
|
+
toggleAllMode: PropTypes.oneOf(['all', 'filteredOnly'])
|
|
222
|
+
} : void 0;
|
|
223
|
+
const GridColumnsManagementBody = styled('div', {
|
|
224
|
+
name: 'MuiDataGrid',
|
|
225
|
+
slot: 'ColumnsManagement',
|
|
226
|
+
overridesResolver: (props, styles) => styles.columnsManagement
|
|
227
|
+
})(({
|
|
228
|
+
theme
|
|
229
|
+
}) => ({
|
|
230
|
+
padding: theme.spacing(0, 3, 1.5),
|
|
231
|
+
display: 'flex',
|
|
232
|
+
flexDirection: 'column',
|
|
233
|
+
overflow: 'auto',
|
|
234
|
+
flex: '1 1',
|
|
235
|
+
maxHeight: 400,
|
|
236
|
+
alignItems: 'flex-start'
|
|
237
|
+
}));
|
|
238
|
+
const GridColumnsManagementHeader = styled('div', {
|
|
239
|
+
name: 'MuiDataGrid',
|
|
240
|
+
slot: 'ColumnsManagementHeader',
|
|
241
|
+
overridesResolver: (props, styles) => styles.columnsManagementHeader
|
|
242
|
+
})(({
|
|
243
|
+
theme
|
|
244
|
+
}) => ({
|
|
245
|
+
padding: theme.spacing(1.5, 3)
|
|
246
|
+
}));
|
|
247
|
+
const GridColumnsManagementFooter = styled('div', {
|
|
248
|
+
name: 'MuiDataGrid',
|
|
249
|
+
slot: 'ColumnsManagementFooter',
|
|
250
|
+
overridesResolver: (props, styles) => styles.columnsManagementFooter
|
|
251
|
+
})(({
|
|
252
|
+
theme
|
|
253
|
+
}) => ({
|
|
254
|
+
padding: theme.spacing(0.5, 1, 0.5, 3),
|
|
255
|
+
display: 'flex',
|
|
256
|
+
justifyContent: 'space-between',
|
|
257
|
+
borderTop: `1px solid ${theme.palette.divider}`
|
|
258
|
+
}));
|
|
259
|
+
const GridColumnsManagementEmptyText = styled('div')(({
|
|
260
|
+
theme
|
|
261
|
+
}) => ({
|
|
262
|
+
padding: theme.spacing(0.5, 0),
|
|
263
|
+
color: theme.palette.grey[500]
|
|
264
|
+
}));
|
|
265
|
+
export { GridColumnsManagement };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GridColumnsManagement';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GridColumnsManagement';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GridColumnVisibilityModel } from '../../hooks/features/columns/gridColumnsInterfaces';
|
|
2
|
+
import { GridColumnsManagementProps } from './GridColumnsManagement';
|
|
3
|
+
export declare const checkColumnVisibilityModelsSame: (a: GridColumnVisibilityModel, b: GridColumnVisibilityModel) => boolean;
|
|
4
|
+
export declare const defaultSearchPredicate: NonNullable<GridColumnsManagementProps['searchPredicate']>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const checkColumnVisibilityModelsSame = (a, b) => {
|
|
2
|
+
// Filter `false` values only, as `true` and not having a key are the same
|
|
3
|
+
const aFalseValues = new Set(Object.keys(a).filter(key => a[key] === false));
|
|
4
|
+
const bFalseValues = new Set(Object.keys(b).filter(key => b[key] === false));
|
|
5
|
+
if (aFalseValues.size !== bFalseValues.size) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
let result = true;
|
|
9
|
+
aFalseValues.forEach(key => {
|
|
10
|
+
if (!bFalseValues.has(key)) {
|
|
11
|
+
result = false;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return result;
|
|
15
|
+
};
|
|
16
|
+
export const defaultSearchPredicate = (column, searchValue) => (column.headerName || column.field).toLowerCase().indexOf(searchValue) > -1;
|
package/components/index.d.ts
CHANGED
package/components/index.js
CHANGED
|
@@ -1,34 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridPanelWrapperProps } from './GridPanelWrapper';
|
|
3
|
-
import type { GridColDef } from '../../models/colDef/gridColDef';
|
|
4
3
|
export interface GridColumnsPanelProps extends GridPanelWrapperProps {
|
|
5
|
-
sort?: 'asc' | 'desc';
|
|
6
|
-
searchPredicate?: (column: GridColDef, searchValue: string) => boolean;
|
|
7
|
-
/**
|
|
8
|
-
* If `true`, the column search field will be focused automatically.
|
|
9
|
-
* If `false`, the first column switch input will be focused automatically.
|
|
10
|
-
* This helps to avoid input keyboard panel to popup automatically on touch devices.
|
|
11
|
-
* @default true
|
|
12
|
-
*/
|
|
13
|
-
autoFocusSearchField?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* If `true`, the `Hide all` button will not be displayed.
|
|
16
|
-
* @default false
|
|
17
|
-
*/
|
|
18
|
-
disableHideAllButton?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* If `true`, the `Show all` button will be disabled
|
|
21
|
-
* @default false
|
|
22
|
-
*/
|
|
23
|
-
disableShowAllButton?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Returns the list of togglable columns.
|
|
26
|
-
* If used, only those columns will be displayed in the panel
|
|
27
|
-
* which are passed as the return value of the function.
|
|
28
|
-
* @param {GridColDef[]} columns The `ColDef` list of all columns.
|
|
29
|
-
* @returns {GridColDef['field'][]} The list of togglable columns' field names.
|
|
30
|
-
*/
|
|
31
|
-
getTogglableColumns?: (columns: GridColDef[]) => GridColDef['field'][];
|
|
32
4
|
}
|
|
33
5
|
declare function GridColumnsPanel(props: GridColumnsPanelProps): React.JSX.Element;
|
|
34
6
|
declare namespace GridColumnsPanel {
|