@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
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.GridColumnsManagement = GridColumnsManagement;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _utils = require("@mui/utils");
|
|
12
|
+
var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
|
|
13
|
+
var _styles = require("@mui/material/styles");
|
|
14
|
+
var _gridColumnsSelector = require("../../hooks/features/columns/gridColumnsSelector");
|
|
15
|
+
var _useGridSelector = require("../../hooks/utils/useGridSelector");
|
|
16
|
+
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
|
|
17
|
+
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
18
|
+
var _gridClasses = require("../../constants/gridClasses");
|
|
19
|
+
var _useLazyRef = require("../../hooks/utils/useLazyRef");
|
|
20
|
+
var _utils2 = require("./utils");
|
|
21
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
24
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
25
|
+
|
|
26
|
+
const useUtilityClasses = ownerState => {
|
|
27
|
+
const {
|
|
28
|
+
classes
|
|
29
|
+
} = ownerState;
|
|
30
|
+
const slots = {
|
|
31
|
+
root: ['columnsManagement'],
|
|
32
|
+
header: ['columnsManagementHeader'],
|
|
33
|
+
footer: ['columnsManagementFooter'],
|
|
34
|
+
row: ['columnsManagementRow']
|
|
35
|
+
};
|
|
36
|
+
return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
|
|
37
|
+
};
|
|
38
|
+
const collator = new Intl.Collator();
|
|
39
|
+
function GridColumnsManagement(props) {
|
|
40
|
+
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
41
|
+
const searchInputRef = React.useRef(null);
|
|
42
|
+
const columns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnDefinitionsSelector);
|
|
43
|
+
const initialColumnVisibilityModel = (0, _useLazyRef.useLazyRef)(() => (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef)).current;
|
|
44
|
+
const columnVisibilityModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnVisibilityModelSelector);
|
|
45
|
+
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
46
|
+
const [searchValue, setSearchValue] = React.useState('');
|
|
47
|
+
const classes = useUtilityClasses(rootProps);
|
|
48
|
+
const {
|
|
49
|
+
sort,
|
|
50
|
+
searchPredicate = _utils2.defaultSearchPredicate,
|
|
51
|
+
autoFocusSearchField = true,
|
|
52
|
+
disableShowHideToggle = false,
|
|
53
|
+
disableResetButton = false,
|
|
54
|
+
toggleAllMode = 'all',
|
|
55
|
+
getTogglableColumns
|
|
56
|
+
} = props;
|
|
57
|
+
const isResetDisabled = React.useMemo(() => (0, _utils2.checkColumnVisibilityModelsSame)(columnVisibilityModel, initialColumnVisibilityModel), [columnVisibilityModel, initialColumnVisibilityModel]);
|
|
58
|
+
const sortedColumns = React.useMemo(() => {
|
|
59
|
+
switch (sort) {
|
|
60
|
+
case 'asc':
|
|
61
|
+
return [...columns].sort((a, b) => collator.compare(a.headerName || a.field, b.headerName || b.field));
|
|
62
|
+
case 'desc':
|
|
63
|
+
return [...columns].sort((a, b) => -collator.compare(a.headerName || a.field, b.headerName || b.field));
|
|
64
|
+
default:
|
|
65
|
+
return columns;
|
|
66
|
+
}
|
|
67
|
+
}, [columns, sort]);
|
|
68
|
+
const toggleColumn = event => {
|
|
69
|
+
const {
|
|
70
|
+
name: field
|
|
71
|
+
} = event.target;
|
|
72
|
+
apiRef.current.setColumnVisibility(field, columnVisibilityModel[field] === false);
|
|
73
|
+
};
|
|
74
|
+
const currentColumns = React.useMemo(() => {
|
|
75
|
+
const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
|
|
76
|
+
const togglableSortedColumns = togglableColumns ? sortedColumns.filter(({
|
|
77
|
+
field
|
|
78
|
+
}) => togglableColumns.includes(field)) : sortedColumns;
|
|
79
|
+
if (!searchValue) {
|
|
80
|
+
return togglableSortedColumns;
|
|
81
|
+
}
|
|
82
|
+
return togglableSortedColumns.filter(column => searchPredicate(column, searchValue.toLowerCase()));
|
|
83
|
+
}, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
|
|
84
|
+
const toggleAllColumns = React.useCallback(isVisible => {
|
|
85
|
+
const currentModel = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef);
|
|
86
|
+
const newModel = (0, _extends2.default)({}, currentModel);
|
|
87
|
+
const togglableColumns = getTogglableColumns ? getTogglableColumns(columns) : null;
|
|
88
|
+
(toggleAllMode === 'filteredOnly' ? currentColumns : columns).forEach(col => {
|
|
89
|
+
if (col.hideable && (togglableColumns == null || togglableColumns.includes(col.field))) {
|
|
90
|
+
if (isVisible) {
|
|
91
|
+
// delete the key from the model instead of setting it to `true`
|
|
92
|
+
delete newModel[col.field];
|
|
93
|
+
} else {
|
|
94
|
+
newModel[col.field] = false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return apiRef.current.setColumnVisibilityModel(newModel);
|
|
99
|
+
}, [apiRef, columns, getTogglableColumns, toggleAllMode, currentColumns]);
|
|
100
|
+
const handleSearchValueChange = React.useCallback(event => {
|
|
101
|
+
setSearchValue(event.target.value);
|
|
102
|
+
}, []);
|
|
103
|
+
const hideableColumns = React.useMemo(() => currentColumns.filter(col => col.hideable), [currentColumns]);
|
|
104
|
+
const allHideableColumnsVisible = React.useMemo(() => hideableColumns.every(column => columnVisibilityModel[column.field] == null || columnVisibilityModel[column.field] !== false), [columnVisibilityModel, hideableColumns]);
|
|
105
|
+
const allHideableColumnsHidden = React.useMemo(() => hideableColumns.every(column => columnVisibilityModel[column.field] === false), [columnVisibilityModel, hideableColumns]);
|
|
106
|
+
const firstSwitchRef = React.useRef(null);
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
if (autoFocusSearchField) {
|
|
109
|
+
searchInputRef.current.focus();
|
|
110
|
+
} else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
|
|
111
|
+
firstSwitchRef.current.focus();
|
|
112
|
+
}
|
|
113
|
+
}, [autoFocusSearchField]);
|
|
114
|
+
let firstHideableColumnFound = false;
|
|
115
|
+
const isFirstHideableColumn = column => {
|
|
116
|
+
if (firstHideableColumnFound === false && column.hideable !== false) {
|
|
117
|
+
firstHideableColumnFound = true;
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
};
|
|
122
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
123
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(GridColumnsManagementHeader, {
|
|
124
|
+
className: classes.header,
|
|
125
|
+
ownerState: rootProps,
|
|
126
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTextField, (0, _extends2.default)({
|
|
127
|
+
placeholder: apiRef.current.getLocaleText('columnsManagementSearchTitle'),
|
|
128
|
+
inputRef: searchInputRef,
|
|
129
|
+
value: searchValue,
|
|
130
|
+
onChange: handleSearchValueChange,
|
|
131
|
+
variant: "outlined",
|
|
132
|
+
size: "small",
|
|
133
|
+
InputProps: {
|
|
134
|
+
startAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseInputAdornment, {
|
|
135
|
+
position: "start",
|
|
136
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.quickFilterIcon, {})
|
|
137
|
+
}),
|
|
138
|
+
sx: {
|
|
139
|
+
pl: 1.5
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
fullWidth: true
|
|
143
|
+
}, rootProps.slotProps?.baseTextField))
|
|
144
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridColumnsManagementBody, {
|
|
145
|
+
className: classes.root,
|
|
146
|
+
ownerState: rootProps,
|
|
147
|
+
children: [currentColumns.map(column => /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
|
|
148
|
+
className: classes.row,
|
|
149
|
+
control: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseCheckbox, (0, _extends2.default)({
|
|
150
|
+
disabled: column.hideable === false,
|
|
151
|
+
checked: columnVisibilityModel[column.field] !== false,
|
|
152
|
+
onClick: toggleColumn,
|
|
153
|
+
name: column.field,
|
|
154
|
+
sx: {
|
|
155
|
+
p: 0.5
|
|
156
|
+
},
|
|
157
|
+
inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
|
|
158
|
+
}, rootProps.slotProps?.baseCheckbox)),
|
|
159
|
+
label: column.headerName || column.field
|
|
160
|
+
}, column.field)), currentColumns.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(GridColumnsManagementEmptyText, {
|
|
161
|
+
ownerState: rootProps,
|
|
162
|
+
children: apiRef.current.getLocaleText('columnsManagementNoColumns')
|
|
163
|
+
})]
|
|
164
|
+
}), !disableShowHideToggle && !disableResetButton && currentColumns.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridColumnsManagementFooter, {
|
|
165
|
+
ownerState: rootProps,
|
|
166
|
+
className: classes.footer,
|
|
167
|
+
children: [!disableShowHideToggle ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
|
|
168
|
+
control: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseCheckbox, (0, _extends2.default)({
|
|
169
|
+
disabled: hideableColumns.length === 0,
|
|
170
|
+
checked: allHideableColumnsVisible,
|
|
171
|
+
indeterminate: !allHideableColumnsVisible && !allHideableColumnsHidden,
|
|
172
|
+
onClick: () => toggleAllColumns(!allHideableColumnsVisible),
|
|
173
|
+
name: apiRef.current.getLocaleText('columnsManagementShowHideAllText'),
|
|
174
|
+
sx: {
|
|
175
|
+
p: 0.5
|
|
176
|
+
}
|
|
177
|
+
}, rootProps.slotProps?.baseCheckbox)),
|
|
178
|
+
label: apiRef.current.getLocaleText('columnsManagementShowHideAllText')
|
|
179
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}), !disableResetButton ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
|
|
180
|
+
onClick: () => apiRef.current.setColumnVisibilityModel(initialColumnVisibilityModel),
|
|
181
|
+
disabled: isResetDisabled
|
|
182
|
+
}, rootProps.slotProps?.baseButton, {
|
|
183
|
+
children: "Reset"
|
|
184
|
+
})) : null]
|
|
185
|
+
}) : null]
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
process.env.NODE_ENV !== "production" ? GridColumnsManagement.propTypes = {
|
|
189
|
+
// ----------------------------- Warning --------------------------------
|
|
190
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
191
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
192
|
+
// ----------------------------------------------------------------------
|
|
193
|
+
/**
|
|
194
|
+
* If `true`, the column search field will be focused automatically.
|
|
195
|
+
* If `false`, the first column switch input will be focused automatically.
|
|
196
|
+
* This helps to avoid input keyboard panel to popup automatically on touch devices.
|
|
197
|
+
* @default true
|
|
198
|
+
*/
|
|
199
|
+
autoFocusSearchField: _propTypes.default.bool,
|
|
200
|
+
/**
|
|
201
|
+
* If `true`, the `Reset` button will not be disabled
|
|
202
|
+
* @default false
|
|
203
|
+
*/
|
|
204
|
+
disableResetButton: _propTypes.default.bool,
|
|
205
|
+
/**
|
|
206
|
+
* If `true`, the `Show/Hide all` toggle checkbox will not be displayed.
|
|
207
|
+
* @default false
|
|
208
|
+
*/
|
|
209
|
+
disableShowHideToggle: _propTypes.default.bool,
|
|
210
|
+
/**
|
|
211
|
+
* Returns the list of togglable columns.
|
|
212
|
+
* If used, only those columns will be displayed in the panel
|
|
213
|
+
* which are passed as the return value of the function.
|
|
214
|
+
* @param {GridColDef[]} columns The `ColDef` list of all columns.
|
|
215
|
+
* @returns {GridColDef['field'][]} The list of togglable columns' field names.
|
|
216
|
+
*/
|
|
217
|
+
getTogglableColumns: _propTypes.default.func,
|
|
218
|
+
searchPredicate: _propTypes.default.func,
|
|
219
|
+
sort: _propTypes.default.oneOf(['asc', 'desc']),
|
|
220
|
+
/**
|
|
221
|
+
* Changes the behavior of the `Show/Hide All` toggle when the search field is used:
|
|
222
|
+
* - `all`: Will toggle all columns.
|
|
223
|
+
* - `filteredOnly`: Will only toggle columns that match the search criteria.
|
|
224
|
+
* @default 'all'
|
|
225
|
+
*/
|
|
226
|
+
toggleAllMode: _propTypes.default.oneOf(['all', 'filteredOnly'])
|
|
227
|
+
} : void 0;
|
|
228
|
+
const GridColumnsManagementBody = (0, _styles.styled)('div', {
|
|
229
|
+
name: 'MuiDataGrid',
|
|
230
|
+
slot: 'ColumnsManagement',
|
|
231
|
+
overridesResolver: (props, styles) => styles.columnsManagement
|
|
232
|
+
})(({
|
|
233
|
+
theme
|
|
234
|
+
}) => ({
|
|
235
|
+
padding: theme.spacing(0, 3, 1.5),
|
|
236
|
+
display: 'flex',
|
|
237
|
+
flexDirection: 'column',
|
|
238
|
+
overflow: 'auto',
|
|
239
|
+
flex: '1 1',
|
|
240
|
+
maxHeight: 400,
|
|
241
|
+
alignItems: 'flex-start'
|
|
242
|
+
}));
|
|
243
|
+
const GridColumnsManagementHeader = (0, _styles.styled)('div', {
|
|
244
|
+
name: 'MuiDataGrid',
|
|
245
|
+
slot: 'ColumnsManagementHeader',
|
|
246
|
+
overridesResolver: (props, styles) => styles.columnsManagementHeader
|
|
247
|
+
})(({
|
|
248
|
+
theme
|
|
249
|
+
}) => ({
|
|
250
|
+
padding: theme.spacing(1.5, 3)
|
|
251
|
+
}));
|
|
252
|
+
const GridColumnsManagementFooter = (0, _styles.styled)('div', {
|
|
253
|
+
name: 'MuiDataGrid',
|
|
254
|
+
slot: 'ColumnsManagementFooter',
|
|
255
|
+
overridesResolver: (props, styles) => styles.columnsManagementFooter
|
|
256
|
+
})(({
|
|
257
|
+
theme
|
|
258
|
+
}) => ({
|
|
259
|
+
padding: theme.spacing(0.5, 1, 0.5, 3),
|
|
260
|
+
display: 'flex',
|
|
261
|
+
justifyContent: 'space-between',
|
|
262
|
+
borderTop: `1px solid ${theme.palette.divider}`
|
|
263
|
+
}));
|
|
264
|
+
const GridColumnsManagementEmptyText = (0, _styles.styled)('div')(({
|
|
265
|
+
theme
|
|
266
|
+
}) => ({
|
|
267
|
+
padding: theme.spacing(0.5, 0),
|
|
268
|
+
color: theme.palette.grey[500]
|
|
269
|
+
}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _GridColumnsManagement = require("./GridColumnsManagement");
|
|
7
|
+
Object.keys(_GridColumnsManagement).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _GridColumnsManagement[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _GridColumnsManagement[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultSearchPredicate = exports.checkColumnVisibilityModelsSame = void 0;
|
|
7
|
+
const checkColumnVisibilityModelsSame = (a, b) => {
|
|
8
|
+
// Filter `false` values only, as `true` and not having a key are the same
|
|
9
|
+
const aFalseValues = new Set(Object.keys(a).filter(key => a[key] === false));
|
|
10
|
+
const bFalseValues = new Set(Object.keys(b).filter(key => b[key] === false));
|
|
11
|
+
if (aFalseValues.size !== bFalseValues.size) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
let result = true;
|
|
15
|
+
aFalseValues.forEach(key => {
|
|
16
|
+
if (!bFalseValues.has(key)) {
|
|
17
|
+
result = false;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
exports.checkColumnVisibilityModelsSame = checkColumnVisibilityModelsSame;
|
|
23
|
+
const defaultSearchPredicate = (column, searchValue) => (column.headerName || column.field).toLowerCase().indexOf(searchValue) > -1;
|
|
24
|
+
exports.defaultSearchPredicate = defaultSearchPredicate;
|
package/node/components/index.js
CHANGED
|
@@ -91,6 +91,17 @@ Object.keys(_panel).forEach(function (key) {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
|
+
var _columnsManagement = require("./columnsManagement");
|
|
95
|
+
Object.keys(_columnsManagement).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _columnsManagement[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _columnsManagement[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
94
105
|
var _toolbar = require("./toolbar");
|
|
95
106
|
Object.keys(_toolbar).forEach(function (key) {
|
|
96
107
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -6,195 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.GridColumnsPanel = GridColumnsPanel;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
9
|
var React = _interopRequireWildcard(require("react"));
|
|
11
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _utils = require("@mui/utils");
|
|
13
|
-
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
14
|
-
var _Switch = require("@mui/material/Switch");
|
|
15
|
-
var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
|
|
16
|
-
var _styles = require("@mui/material/styles");
|
|
17
|
-
var _gridColumnsSelector = require("../../hooks/features/columns/gridColumnsSelector");
|
|
18
|
-
var _useGridSelector = require("../../hooks/utils/useGridSelector");
|
|
19
|
-
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
|
|
20
|
-
var _GridPanelContent = require("./GridPanelContent");
|
|
21
|
-
var _GridPanelFooter = require("./GridPanelFooter");
|
|
22
|
-
var _GridPanelHeader = require("./GridPanelHeader");
|
|
23
11
|
var _GridPanelWrapper = require("./GridPanelWrapper");
|
|
24
|
-
var
|
|
12
|
+
var _columnsManagement = require("../columnsManagement");
|
|
25
13
|
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
26
|
-
var _gridClasses = require("../../constants/gridClasses");
|
|
27
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
-
const _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton", "getTogglableColumns"];
|
|
29
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
30
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
31
|
-
const useUtilityClasses = ownerState => {
|
|
32
|
-
const {
|
|
33
|
-
classes
|
|
34
|
-
} = ownerState;
|
|
35
|
-
const slots = {
|
|
36
|
-
root: ['columnsPanel'],
|
|
37
|
-
columnsPanelRow: ['columnsPanelRow']
|
|
38
|
-
};
|
|
39
|
-
return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
|
|
40
|
-
};
|
|
41
|
-
const GridColumnsPanelRoot = (0, _styles.styled)('div', {
|
|
42
|
-
name: 'MuiDataGrid',
|
|
43
|
-
slot: 'ColumnsPanel',
|
|
44
|
-
overridesResolver: (props, styles) => styles.columnsPanel
|
|
45
|
-
})({
|
|
46
|
-
padding: '8px 0px 8px 8px'
|
|
47
|
-
});
|
|
48
|
-
const GridColumnsPanelRowRoot = (0, _styles.styled)('div', {
|
|
49
|
-
name: 'MuiDataGrid',
|
|
50
|
-
slot: 'ColumnsPanelRow',
|
|
51
|
-
overridesResolver: (props, styles) => styles.columnsPanelRow
|
|
52
|
-
})(({
|
|
53
|
-
theme
|
|
54
|
-
}) => ({
|
|
55
|
-
display: 'flex',
|
|
56
|
-
justifyContent: 'space-between',
|
|
57
|
-
padding: '1px 8px 1px 7px',
|
|
58
|
-
[`& .${_Switch.switchClasses.root}`]: {
|
|
59
|
-
marginRight: theme.spacing(0.5)
|
|
60
|
-
}
|
|
61
|
-
}));
|
|
62
|
-
const GridIconButtonRoot = (0, _styles.styled)(_IconButton.default)({
|
|
63
|
-
justifyContent: 'flex-end'
|
|
64
|
-
});
|
|
65
|
-
const collator = new Intl.Collator();
|
|
66
|
-
const defaultSearchPredicate = (column, searchValue) => {
|
|
67
|
-
return (column.headerName || column.field).toLowerCase().indexOf(searchValue) > -1;
|
|
68
|
-
};
|
|
69
17
|
function GridColumnsPanel(props) {
|
|
70
|
-
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
71
|
-
const searchInputRef = React.useRef(null);
|
|
72
|
-
const columns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnDefinitionsSelector);
|
|
73
|
-
const columnVisibilityModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnVisibilityModelSelector);
|
|
74
18
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const {
|
|
78
|
-
sort,
|
|
79
|
-
searchPredicate = defaultSearchPredicate,
|
|
80
|
-
autoFocusSearchField = true,
|
|
81
|
-
disableHideAllButton = false,
|
|
82
|
-
disableShowAllButton = false,
|
|
83
|
-
getTogglableColumns
|
|
84
|
-
} = props,
|
|
85
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
86
|
-
const sortedColumns = React.useMemo(() => {
|
|
87
|
-
switch (sort) {
|
|
88
|
-
case 'asc':
|
|
89
|
-
return [...columns].sort((a, b) => collator.compare(a.headerName || a.field, b.headerName || b.field));
|
|
90
|
-
case 'desc':
|
|
91
|
-
return [...columns].sort((a, b) => -collator.compare(a.headerName || a.field, b.headerName || b.field));
|
|
92
|
-
default:
|
|
93
|
-
return columns;
|
|
94
|
-
}
|
|
95
|
-
}, [columns, sort]);
|
|
96
|
-
const toggleColumn = event => {
|
|
97
|
-
const {
|
|
98
|
-
name: field
|
|
99
|
-
} = event.target;
|
|
100
|
-
apiRef.current.setColumnVisibility(field, columnVisibilityModel[field] === false);
|
|
101
|
-
};
|
|
102
|
-
const toggleAllColumns = React.useCallback(isVisible => {
|
|
103
|
-
const currentModel = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef);
|
|
104
|
-
const newModel = (0, _extends2.default)({}, currentModel);
|
|
105
|
-
const togglableColumns = getTogglableColumns ? getTogglableColumns(columns) : null;
|
|
106
|
-
columns.forEach(col => {
|
|
107
|
-
if (col.hideable && (togglableColumns == null || togglableColumns.includes(col.field))) {
|
|
108
|
-
if (isVisible) {
|
|
109
|
-
// delete the key from the model instead of setting it to `true`
|
|
110
|
-
delete newModel[col.field];
|
|
111
|
-
} else {
|
|
112
|
-
newModel[col.field] = false;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
return apiRef.current.setColumnVisibilityModel(newModel);
|
|
117
|
-
}, [apiRef, columns, getTogglableColumns]);
|
|
118
|
-
const handleSearchValueChange = React.useCallback(event => {
|
|
119
|
-
setSearchValue(event.target.value);
|
|
120
|
-
}, []);
|
|
121
|
-
const currentColumns = React.useMemo(() => {
|
|
122
|
-
const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
|
|
123
|
-
const togglableSortedColumns = togglableColumns ? sortedColumns.filter(({
|
|
124
|
-
field
|
|
125
|
-
}) => togglableColumns.includes(field)) : sortedColumns;
|
|
126
|
-
if (!searchValue) {
|
|
127
|
-
return togglableSortedColumns;
|
|
128
|
-
}
|
|
129
|
-
return togglableSortedColumns.filter(column => searchPredicate(column, searchValue.toLowerCase()));
|
|
130
|
-
}, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
|
|
131
|
-
const firstSwitchRef = React.useRef(null);
|
|
132
|
-
React.useEffect(() => {
|
|
133
|
-
if (autoFocusSearchField) {
|
|
134
|
-
searchInputRef.current.focus();
|
|
135
|
-
} else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
|
|
136
|
-
firstSwitchRef.current.focus();
|
|
137
|
-
}
|
|
138
|
-
}, [autoFocusSearchField]);
|
|
139
|
-
let firstHideableColumnFound = false;
|
|
140
|
-
const isFirstHideableColumn = column => {
|
|
141
|
-
if (firstHideableColumnFound === false && column.hideable !== false) {
|
|
142
|
-
firstHideableColumnFound = true;
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
return false;
|
|
146
|
-
};
|
|
147
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridPanelWrapper.GridPanelWrapper, (0, _extends2.default)({}, other, {
|
|
148
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GridPanelHeader.GridPanelHeader, {
|
|
149
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTextField, (0, _extends2.default)({
|
|
150
|
-
label: apiRef.current.getLocaleText('columnsPanelTextFieldLabel'),
|
|
151
|
-
placeholder: apiRef.current.getLocaleText('columnsPanelTextFieldPlaceholder'),
|
|
152
|
-
inputRef: searchInputRef,
|
|
153
|
-
value: searchValue,
|
|
154
|
-
onChange: handleSearchValueChange,
|
|
155
|
-
variant: "standard",
|
|
156
|
-
fullWidth: true
|
|
157
|
-
}, rootProps.slotProps?.baseTextField))
|
|
158
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridPanelContent.GridPanelContent, {
|
|
159
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GridColumnsPanelRoot, {
|
|
160
|
-
className: classes.root,
|
|
161
|
-
ownerState: rootProps,
|
|
162
|
-
children: currentColumns.map(column => /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridColumnsPanelRowRoot, {
|
|
163
|
-
className: classes.columnsPanelRow,
|
|
164
|
-
ownerState: rootProps,
|
|
165
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
|
|
166
|
-
control: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSwitch, (0, _extends2.default)({
|
|
167
|
-
disabled: column.hideable === false,
|
|
168
|
-
checked: columnVisibilityModel[column.field] !== false,
|
|
169
|
-
onClick: toggleColumn,
|
|
170
|
-
name: column.field,
|
|
171
|
-
size: "small",
|
|
172
|
-
inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
|
|
173
|
-
}, rootProps.slotProps?.baseSwitch)),
|
|
174
|
-
label: column.headerName || column.field
|
|
175
|
-
}), !rootProps.disableColumnReorder && _envConstants.GRID_EXPERIMENTAL_ENABLED && /*#__PURE__*/(0, _jsxRuntime.jsx)(GridIconButtonRoot, {
|
|
176
|
-
draggable: true,
|
|
177
|
-
"aria-label": apiRef.current.getLocaleText('columnsPanelDragIconLabel'),
|
|
178
|
-
title: apiRef.current.getLocaleText('columnsPanelDragIconLabel'),
|
|
179
|
-
size: "small",
|
|
180
|
-
disabled: true,
|
|
181
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.columnReorderIcon, {})
|
|
182
|
-
})]
|
|
183
|
-
}, column.field))
|
|
184
|
-
})
|
|
185
|
-
}), disableShowAllButton && disableHideAllButton ? null : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridPanelFooter.GridPanelFooter, {
|
|
186
|
-
children: [!disableHideAllButton ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
|
|
187
|
-
onClick: () => toggleAllColumns(false)
|
|
188
|
-
}, rootProps.slotProps?.baseButton, {
|
|
189
|
-
disabled: disableHideAllButton,
|
|
190
|
-
children: apiRef.current.getLocaleText('columnsPanelHideAllButton')
|
|
191
|
-
})) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}), !disableShowAllButton ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
|
|
192
|
-
onClick: () => toggleAllColumns(true)
|
|
193
|
-
}, rootProps.slotProps?.baseButton, {
|
|
194
|
-
disabled: disableShowAllButton,
|
|
195
|
-
children: apiRef.current.getLocaleText('columnsPanelShowAllButton')
|
|
196
|
-
})) : null]
|
|
197
|
-
})]
|
|
19
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridPanelWrapper.GridPanelWrapper, (0, _extends2.default)({}, props, {
|
|
20
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_columnsManagement.GridColumnsManagement, (0, _extends2.default)({}, rootProps.slotProps?.columnsManagement))
|
|
198
21
|
}));
|
|
199
22
|
}
|
|
200
23
|
process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
@@ -202,32 +25,5 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
|
202
25
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
203
26
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
204
27
|
// ----------------------------------------------------------------------
|
|
205
|
-
|
|
206
|
-
* If `true`, the column search field will be focused automatically.
|
|
207
|
-
* If `false`, the first column switch input will be focused automatically.
|
|
208
|
-
* This helps to avoid input keyboard panel to popup automatically on touch devices.
|
|
209
|
-
* @default true
|
|
210
|
-
*/
|
|
211
|
-
autoFocusSearchField: _propTypes.default.bool,
|
|
212
|
-
/**
|
|
213
|
-
* If `true`, the `Hide all` button will not be displayed.
|
|
214
|
-
* @default false
|
|
215
|
-
*/
|
|
216
|
-
disableHideAllButton: _propTypes.default.bool,
|
|
217
|
-
/**
|
|
218
|
-
* If `true`, the `Show all` button will be disabled
|
|
219
|
-
* @default false
|
|
220
|
-
*/
|
|
221
|
-
disableShowAllButton: _propTypes.default.bool,
|
|
222
|
-
/**
|
|
223
|
-
* Returns the list of togglable columns.
|
|
224
|
-
* If used, only those columns will be displayed in the panel
|
|
225
|
-
* which are passed as the return value of the function.
|
|
226
|
-
* @param {GridColDef[]} columns The `ColDef` list of all columns.
|
|
227
|
-
* @returns {GridColDef['field'][]} The list of togglable columns' field names.
|
|
228
|
-
*/
|
|
229
|
-
getTogglableColumns: _propTypes.default.func,
|
|
230
|
-
searchPredicate: _propTypes.default.func,
|
|
231
|
-
slotProps: _propTypes.default.object,
|
|
232
|
-
sort: _propTypes.default.oneOf(['asc', 'desc'])
|
|
28
|
+
slotProps: _propTypes.default.object
|
|
233
29
|
} : void 0;
|
|
@@ -33,6 +33,7 @@ const DATA_GRID_DEFAULT_SLOTS_COMPONENTS = exports.DATA_GRID_DEFAULT_SLOTS_COMPO
|
|
|
33
33
|
pagination: _components.GridPagination,
|
|
34
34
|
filterPanel: _components.GridFilterPanel,
|
|
35
35
|
columnsPanel: _components.GridColumnsPanel,
|
|
36
|
+
columnsManagement: _components.GridColumnsManagement,
|
|
36
37
|
panel: _components.GridPanel,
|
|
37
38
|
row: _components.GridRow
|
|
38
39
|
});
|
|
@@ -9,4 +9,4 @@ var _utils = require("@mui/utils");
|
|
|
9
9
|
function getDataGridUtilityClass(slot) {
|
|
10
10
|
return (0, _utils.unstable_generateUtilityClass)('MuiDataGrid', slot);
|
|
11
11
|
}
|
|
12
|
-
const gridClasses = exports.gridClasses = (0, _utils.unstable_generateUtilityClasses)('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellContent', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnGroupHeader', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeader--showColumnBorder', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', '
|
|
12
|
+
const gridClasses = exports.gridClasses = (0, _utils.unstable_generateUtilityClasses)('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellContent', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnGroupHeader', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeader--showColumnBorder', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
@@ -33,12 +33,10 @@ const GRID_DEFAULT_LOCALE_TEXT = exports.GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
33
33
|
toolbarExportCSV: 'Download as CSV',
|
|
34
34
|
toolbarExportPrint: 'Print',
|
|
35
35
|
toolbarExportExcel: 'Download as Excel',
|
|
36
|
-
// Columns
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
columnsPanelShowAllButton: 'Show all',
|
|
41
|
-
columnsPanelHideAllButton: 'Hide all',
|
|
36
|
+
// Columns management text
|
|
37
|
+
columnsManagementSearchTitle: 'Search',
|
|
38
|
+
columnsManagementNoColumns: 'No columns',
|
|
39
|
+
columnsManagementShowHideAllText: 'Show/Hide All',
|
|
42
40
|
// Filter panel text
|
|
43
41
|
filterPanelAddFilter: 'Add filter',
|
|
44
42
|
filterPanelRemoveAll: 'Remove all',
|
|
@@ -107,6 +107,9 @@ function useGridApiInitialization(inputApiRef, props) {
|
|
|
107
107
|
subscribeEvent,
|
|
108
108
|
publishEvent
|
|
109
109
|
}, 'public');
|
|
110
|
+
if (inputApiRef && !inputApiRef.current?.state) {
|
|
111
|
+
inputApiRef.current = publicApiRef.current;
|
|
112
|
+
}
|
|
110
113
|
React.useImperativeHandle(inputApiRef, () => publicApiRef.current, [publicApiRef]);
|
|
111
114
|
React.useEffect(() => {
|
|
112
115
|
const api = privateApiRef.current;
|
|
@@ -68,7 +68,9 @@ function calculateCellColSpan(params) {
|
|
|
68
68
|
} = params;
|
|
69
69
|
const columnsLength = columns.length;
|
|
70
70
|
const column = columns[columnIndex];
|
|
71
|
-
const
|
|
71
|
+
const row = apiRef.current.getRow(rowId);
|
|
72
|
+
const value = apiRef.current.getRowValue(row, column);
|
|
73
|
+
const colSpan = typeof column.colSpan === 'function' ? column.colSpan(value, row, column, apiRef) : column.colSpan;
|
|
72
74
|
if (!colSpan || colSpan === 1) {
|
|
73
75
|
setCellColSpanInfo(lookup, rowId, columnIndex, {
|
|
74
76
|
spannedByColSpan: false,
|
|
@@ -343,7 +343,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
343
343
|
const row = apiRef.current.getRow(id);
|
|
344
344
|
let parsedValue = value;
|
|
345
345
|
if (column.valueParser && !skipValueParser) {
|
|
346
|
-
parsedValue = column.valueParser(value,
|
|
346
|
+
parsedValue = column.valueParser(value, row, column, apiRef);
|
|
347
347
|
}
|
|
348
348
|
let editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
349
349
|
let newProps = (0, _extends2.default)({}, editingState[id][field], {
|
|
@@ -391,10 +391,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
391
391
|
const {
|
|
392
392
|
value
|
|
393
393
|
} = editingState[id][field];
|
|
394
|
-
return column.valueSetter ? column.valueSetter({
|
|
395
|
-
value,
|
|
396
|
-
row
|
|
397
|
-
}) : (0, _extends2.default)({}, row, {
|
|
394
|
+
return column.valueSetter ? column.valueSetter(value, row, column, apiRef) : (0, _extends2.default)({}, row, {
|
|
398
395
|
[field]: value
|
|
399
396
|
});
|
|
400
397
|
}, [apiRef]);
|