@mui/x-data-grid 5.11.1 → 5.12.2
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 +199 -20
- package/DataGrid/DataGrid.js +26 -1
- package/README.md +2 -2
- package/colDef/gridCheckboxSelectionColDef.d.ts +1 -0
- package/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/colDef/gridDateOperators.d.ts +1 -1
- package/colDef/gridNumericColDef.js +1 -1
- package/components/GridRow.d.ts +1 -1
- package/components/GridRow.js +51 -12
- package/components/cell/GridActionsCellItem.d.ts +1 -1
- package/components/cell/GridCell.d.ts +2 -1
- package/components/cell/GridCell.js +12 -7
- package/components/columnHeaders/GridColumnHeaderItem.js +9 -6
- package/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/components/containers/GridRootStyles.js +8 -3
- package/components/menu/GridMenu.js +9 -2
- package/components/panel/GridColumnsPanel.js +12 -7
- package/components/panel/GridPanelWrapper.d.ts +1 -1
- package/components/panel/GridPanelWrapper.js +3 -3
- package/components/panel/filterPanel/GridFilterForm.d.ts +61 -4
- package/components/panel/filterPanel/GridFilterForm.js +88 -8
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/components/panel/filterPanel/GridFilterPanel.d.ts +8 -5
- package/components/panel/filterPanel/GridFilterPanel.js +26 -11
- package/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
- package/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/components/toolbar/GridToolbarQuickFilter.d.ts +7 -0
- package/components/toolbar/GridToolbarQuickFilter.js +57 -4
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +4 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +1 -0
- package/hooks/core/useGridStateInitialization.js +19 -6
- package/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -0
- package/hooks/features/columns/useGridColumnSpanning.d.ts +1 -1
- package/hooks/features/columns/useGridColumnSpanning.js +1 -1
- package/hooks/features/columns/useGridColumns.d.ts +1 -1
- package/hooks/features/columns/useGridColumns.js +13 -15
- package/hooks/features/dimensions/gridDimensionsApi.d.ts +5 -0
- package/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/hooks/features/editRows/useGridCellEditing.new.js +11 -4
- package/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +10 -4
- package/hooks/features/events/useGridEvents.d.ts +1 -1
- package/hooks/features/events/useGridEvents.js +2 -0
- package/hooks/features/filter/gridFilterSelector.d.ts +5 -0
- package/hooks/features/filter/gridFilterSelector.js +6 -0
- package/hooks/features/filter/gridFilterState.d.ts +1 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +10 -2
- package/hooks/features/filter/gridFilterUtils.js +3 -6
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.js +29 -12
- package/hooks/features/pagination/useGridPage.js +1 -1
- package/hooks/features/pagination/useGridPageSize.js +1 -1
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +133 -67
- package/hooks/features/selection/useGridSelection.js +1 -1
- package/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/sorting/useGridSorting.js +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +2 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +65 -11
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/legacy/DataGrid/DataGrid.js +26 -1
- package/legacy/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/legacy/colDef/gridNumericColDef.js +1 -1
- package/legacy/components/GridRow.js +56 -12
- package/legacy/components/cell/GridCell.js +12 -7
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +11 -6
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/legacy/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/legacy/components/containers/GridRootStyles.js +10 -7
- package/legacy/components/menu/GridMenu.js +9 -2
- package/legacy/components/panel/GridColumnsPanel.js +14 -7
- package/legacy/components/panel/GridPanelWrapper.js +3 -3
- package/legacy/components/panel/filterPanel/GridFilterForm.js +89 -8
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +28 -12
- package/legacy/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/legacy/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/legacy/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/legacy/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/legacy/components/toolbar/GridToolbarQuickFilter.js +67 -6
- package/legacy/constants/defaultGridSlotsComponents.js +2 -1
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +1 -0
- package/legacy/hooks/core/useGridStateInitialization.js +18 -6
- package/legacy/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +1 -1
- package/legacy/hooks/features/columns/useGridColumns.js +13 -15
- package/legacy/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +14 -7
- package/legacy/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +10 -4
- package/legacy/hooks/features/events/useGridEvents.js +2 -0
- package/legacy/hooks/features/filter/gridFilterSelector.js +8 -0
- package/legacy/hooks/features/filter/gridFilterUtils.js +4 -7
- package/legacy/hooks/features/filter/useGridFilter.js +33 -12
- package/legacy/hooks/features/pagination/useGridPage.js +1 -1
- package/legacy/hooks/features/pagination/useGridPageSize.js +1 -1
- package/legacy/hooks/features/rows/useGridRowsMeta.js +133 -66
- package/legacy/hooks/features/selection/useGridSelection.js +1 -1
- package/legacy/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
- package/legacy/hooks/features/sorting/useGridSorting.js +1 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +84 -26
- package/legacy/index.js +1 -1
- package/legacy/locales/arSD.js +1 -0
- package/legacy/locales/bgBG.js +1 -0
- package/legacy/locales/csCZ.js +1 -0
- package/legacy/locales/daDK.js +1 -0
- package/legacy/locales/deDE.js +1 -0
- package/legacy/locales/elGR.js +1 -0
- package/legacy/locales/esES.js +1 -0
- package/legacy/locales/faIR.js +1 -0
- package/legacy/locales/fiFI.js +1 -0
- package/legacy/locales/frFR.js +1 -0
- package/legacy/locales/heIL.js +10 -9
- package/legacy/locales/huHU.js +1 -0
- package/legacy/locales/itIT.js +1 -0
- package/legacy/locales/jaJP.js +29 -24
- package/legacy/locales/koKR.js +1 -0
- package/legacy/locales/nbNO.js +128 -0
- package/legacy/locales/nlNL.js +1 -0
- package/legacy/locales/plPL.js +1 -0
- package/legacy/locales/ptBR.js +1 -0
- package/legacy/locales/ruRU.js +7 -6
- package/legacy/locales/skSK.js +1 -0
- package/legacy/locales/trTR.js +8 -7
- package/legacy/locales/ukUA.js +1 -0
- package/legacy/locales/viVN.js +1 -0
- package/legacy/locales/zhCN.js +1 -0
- package/legacy/models/events/gridEvents.js +2 -0
- package/legacy/models/gridApiCaches.js +1 -0
- package/legacy/models/params/gridMenuParams.js +1 -0
- package/legacy/models/params/index.js +2 -1
- package/locales/arSD.js +1 -0
- package/locales/bgBG.js +1 -0
- package/locales/csCZ.js +1 -0
- package/locales/daDK.js +1 -0
- package/locales/deDE.js +1 -0
- package/locales/elGR.js +1 -0
- package/locales/esES.js +1 -0
- package/locales/faIR.js +1 -0
- package/locales/fiFI.js +1 -0
- package/locales/frFR.js +1 -0
- package/locales/heIL.js +10 -9
- package/locales/huHU.js +1 -0
- package/locales/itIT.js +1 -0
- package/locales/jaJP.js +25 -24
- package/locales/koKR.js +1 -0
- package/locales/nbNO.d.ts +2 -0
- package/locales/nbNO.js +116 -0
- package/locales/nlNL.js +1 -0
- package/locales/plPL.js +1 -0
- package/locales/ptBR.js +1 -0
- package/locales/ruRU.js +7 -6
- package/locales/skSK.js +1 -0
- package/locales/trTR.js +8 -7
- package/locales/ukUA.js +1 -0
- package/locales/viVN.js +1 -0
- package/locales/zhCN.js +1 -0
- package/models/api/gridCallbackDetails.d.ts +6 -1
- package/models/api/gridCoreApi.d.ts +2 -6
- package/models/api/gridFilterApi.d.ts +8 -1
- package/models/api/gridLocaleTextApi.d.ts +1 -0
- package/models/api/gridRowsMetaApi.d.ts +24 -0
- package/models/api/gridStateApi.d.ts +14 -3
- package/models/colDef/gridColDef.d.ts +4 -4
- package/models/events/gridEventLookup.d.ts +16 -1
- package/models/events/gridEvents.d.ts +3 -1
- package/models/events/gridEvents.js +2 -0
- package/models/gridApiCaches.d.ts +6 -0
- package/models/gridApiCaches.js +1 -0
- package/models/gridIconSlotsComponent.d.ts +5 -0
- package/models/params/gridMenuParams.d.ts +7 -0
- package/models/params/gridMenuParams.js +1 -0
- package/models/params/gridRowParams.d.ts +1 -1
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +2 -1
- package/models/props/DataGridProps.d.ts +24 -2
- package/modern/DataGrid/DataGrid.js +26 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/modern/colDef/gridNumericColDef.js +1 -1
- package/modern/components/GridRow.js +51 -12
- package/modern/components/cell/GridCell.js +12 -7
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +9 -6
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/modern/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/modern/components/containers/GridRootStyles.js +8 -3
- package/modern/components/menu/GridMenu.js +9 -2
- package/modern/components/panel/GridColumnsPanel.js +12 -7
- package/modern/components/panel/GridPanelWrapper.js +3 -3
- package/modern/components/panel/filterPanel/GridFilterForm.js +88 -8
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/modern/components/panel/filterPanel/GridFilterPanel.js +26 -11
- package/modern/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/modern/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/modern/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/modern/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/modern/components/toolbar/GridToolbarQuickFilter.js +57 -4
- package/modern/constants/defaultGridSlotsComponents.js +2 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +1 -0
- package/modern/hooks/core/useGridStateInitialization.js +19 -6
- package/modern/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
- package/modern/hooks/features/columns/useGridColumnSpanning.js +1 -1
- package/modern/hooks/features/columns/useGridColumns.js +12 -14
- package/modern/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +10 -3
- package/modern/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +9 -3
- package/modern/hooks/features/events/useGridEvents.js +2 -0
- package/modern/hooks/features/filter/gridFilterSelector.js +6 -0
- package/modern/hooks/features/filter/gridFilterUtils.js +3 -6
- package/modern/hooks/features/filter/useGridFilter.js +29 -12
- package/modern/hooks/features/pagination/useGridPage.js +1 -1
- package/modern/hooks/features/pagination/useGridPageSize.js +1 -1
- package/modern/hooks/features/rows/useGridRowsMeta.js +129 -59
- package/modern/hooks/features/selection/useGridSelection.js +1 -1
- package/modern/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
- package/modern/hooks/features/sorting/useGridSorting.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +65 -11
- package/modern/index.js +1 -1
- package/modern/locales/arSD.js +1 -0
- package/modern/locales/bgBG.js +1 -0
- package/modern/locales/csCZ.js +1 -0
- package/modern/locales/daDK.js +1 -0
- package/modern/locales/deDE.js +1 -0
- package/modern/locales/elGR.js +1 -0
- package/modern/locales/esES.js +1 -0
- package/modern/locales/faIR.js +1 -0
- package/modern/locales/fiFI.js +1 -0
- package/modern/locales/frFR.js +1 -0
- package/modern/locales/heIL.js +10 -9
- package/modern/locales/huHU.js +1 -0
- package/modern/locales/itIT.js +1 -0
- package/modern/locales/jaJP.js +25 -24
- package/modern/locales/koKR.js +1 -0
- package/modern/locales/nbNO.js +116 -0
- package/modern/locales/nlNL.js +1 -0
- package/modern/locales/plPL.js +1 -0
- package/modern/locales/ptBR.js +1 -0
- package/modern/locales/ruRU.js +7 -6
- package/modern/locales/skSK.js +1 -0
- package/modern/locales/trTR.js +8 -7
- package/modern/locales/ukUA.js +1 -0
- package/modern/locales/viVN.js +1 -0
- package/modern/locales/zhCN.js +1 -0
- package/modern/models/events/gridEvents.js +2 -0
- package/modern/models/gridApiCaches.js +1 -0
- package/modern/models/params/gridMenuParams.js +1 -0
- package/modern/models/params/index.js +2 -1
- package/node/DataGrid/DataGrid.js +26 -1
- package/node/colDef/gridCheckboxSelectionColDef.js +4 -2
- package/node/colDef/gridNumericColDef.js +1 -1
- package/node/components/GridRow.js +53 -12
- package/node/components/cell/GridCell.js +12 -7
- package/node/components/columnHeaders/GridColumnHeaderItem.js +9 -6
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/node/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/node/components/containers/GridRootStyles.js +8 -3
- package/node/components/menu/GridMenu.js +10 -2
- package/node/components/panel/GridColumnsPanel.js +12 -7
- package/node/components/panel/GridPanelWrapper.js +5 -3
- package/node/components/panel/filterPanel/GridFilterForm.js +91 -9
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/node/components/panel/filterPanel/GridFilterPanel.js +28 -11
- package/node/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/node/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/node/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/node/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/node/components/toolbar/GridToolbarQuickFilter.js +61 -4
- package/node/constants/defaultGridSlotsComponents.js +2 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +1 -0
- package/node/hooks/core/useGridStateInitialization.js +19 -6
- package/node/hooks/features/columnMenu/useGridColumnMenu.js +23 -0
- package/node/hooks/features/columns/useGridColumnSpanning.js +11 -16
- package/node/hooks/features/columns/useGridColumns.js +13 -15
- package/node/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/node/hooks/features/editRows/useGridCellEditing.new.js +11 -4
- package/node/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/node/hooks/features/editRows/useGridRowEditing.new.js +10 -4
- package/node/hooks/features/events/useGridEvents.js +2 -0
- package/node/hooks/features/filter/gridFilterSelector.js +9 -2
- package/node/hooks/features/filter/gridFilterUtils.js +4 -5
- package/node/hooks/features/filter/useGridFilter.js +28 -11
- package/node/hooks/features/pagination/useGridPage.js +1 -1
- package/node/hooks/features/pagination/useGridPageSize.js +1 -1
- package/node/hooks/features/rows/useGridRowsMeta.js +136 -69
- package/node/hooks/features/selection/useGridSelection.js +1 -1
- package/node/hooks/features/selection/useGridSelectionPreProcessors.js +7 -5
- package/node/hooks/features/sorting/useGridSorting.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +65 -12
- package/node/index.js +1 -1
- package/node/locales/arSD.js +1 -0
- package/node/locales/bgBG.js +1 -0
- package/node/locales/csCZ.js +1 -0
- package/node/locales/daDK.js +1 -0
- package/node/locales/deDE.js +1 -0
- package/node/locales/elGR.js +1 -0
- package/node/locales/esES.js +1 -0
- package/node/locales/faIR.js +1 -0
- package/node/locales/fiFI.js +1 -0
- package/node/locales/frFR.js +1 -0
- package/node/locales/heIL.js +10 -9
- package/node/locales/huHU.js +1 -0
- package/node/locales/itIT.js +1 -0
- package/node/locales/jaJP.js +25 -24
- package/node/locales/koKR.js +1 -0
- package/node/locales/nbNO.js +126 -0
- package/node/locales/nlNL.js +1 -0
- package/node/locales/plPL.js +1 -0
- package/node/locales/ptBR.js +1 -0
- package/node/locales/ruRU.js +7 -6
- package/node/locales/skSK.js +1 -0
- package/node/locales/trTR.js +8 -7
- package/node/locales/ukUA.js +1 -0
- package/node/locales/viVN.js +1 -0
- package/node/locales/zhCN.js +1 -0
- package/node/models/events/gridEvents.js +2 -0
- package/node/models/gridApiCaches.js +5 -0
- package/node/models/params/gridMenuParams.js +5 -0
- package/node/models/params/index.js +13 -0
- package/package.json +6 -5
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["item", "hasMultipleFilters", "deleteFilter", "applyFilterChanges", "multiFilterOperator", "showMultiFilterOperators", "disableMultiFilterOperator", "applyMultiFilterOperatorChanges", "focusElementRef", "linkOperators", "columnsSort", "deleteIconProps", "linkOperatorInputProps", "operatorInputProps", "columnInputProps", "valueInputProps", "children"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import PropTypes from 'prop-types';
|
|
4
6
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
@@ -102,8 +104,7 @@ const getLinkOperatorLocaleKey = linkOperator => {
|
|
|
102
104
|
const getColumnLabel = col => col.headerName || col.field;
|
|
103
105
|
|
|
104
106
|
const collator = new Intl.Collator();
|
|
105
|
-
|
|
106
|
-
function GridFilterForm(props) {
|
|
107
|
+
const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(props, ref) {
|
|
107
108
|
const {
|
|
108
109
|
item,
|
|
109
110
|
hasMultipleFilters,
|
|
@@ -121,7 +122,9 @@ function GridFilterForm(props) {
|
|
|
121
122
|
operatorInputProps = {},
|
|
122
123
|
columnInputProps = {},
|
|
123
124
|
valueInputProps = {}
|
|
124
|
-
} = props
|
|
125
|
+
} = props,
|
|
126
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
127
|
+
|
|
125
128
|
const apiRef = useGridApiContext();
|
|
126
129
|
const filterableColumns = useGridSelector(apiRef, gridFilterableColumnDefinitionsSelector);
|
|
127
130
|
const columnSelectId = useId();
|
|
@@ -217,8 +220,10 @@ function GridFilterForm(props) {
|
|
|
217
220
|
}
|
|
218
221
|
}
|
|
219
222
|
}), [currentOperator]);
|
|
220
|
-
return /*#__PURE__*/_jsxs(GridFilterFormRoot, {
|
|
221
|
-
|
|
223
|
+
return /*#__PURE__*/_jsxs(GridFilterFormRoot, _extends({
|
|
224
|
+
ref: ref,
|
|
225
|
+
className: classes.root
|
|
226
|
+
}, other, {
|
|
222
227
|
children: [/*#__PURE__*/_jsx(FilterFormDeleteIcon, _extends({
|
|
223
228
|
variant: "standard",
|
|
224
229
|
as: rootProps.components.BaseFormControl
|
|
@@ -313,36 +318,111 @@ function GridFilterForm(props) {
|
|
|
313
318
|
focusElementRef: valueRef
|
|
314
319
|
}, currentOperator.InputComponentProps)) : null
|
|
315
320
|
}))]
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
|
|
321
|
+
}));
|
|
322
|
+
});
|
|
319
323
|
process.env.NODE_ENV !== "production" ? GridFilterForm.propTypes = {
|
|
320
324
|
// ----------------------------- Warning --------------------------------
|
|
321
325
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
322
326
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
323
327
|
// ----------------------------------------------------------------------
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Callback called when the operator, column field or value is changed.
|
|
331
|
+
* @param {GridFilterItem} item The updated [[GridFilterItem]].
|
|
332
|
+
*/
|
|
324
333
|
applyFilterChanges: PropTypes.func.isRequired,
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Callback called when the logic operator is changed.
|
|
337
|
+
* @param {GridLinkOperator} operator The new logic operator.
|
|
338
|
+
*/
|
|
325
339
|
applyMultiFilterOperatorChanges: PropTypes.func.isRequired,
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Props passed to the column input component.
|
|
343
|
+
* @default {}
|
|
344
|
+
*/
|
|
326
345
|
columnInputProps: PropTypes.any,
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Changes how the options in the columns selector should be ordered.
|
|
349
|
+
* If not specified, the order is derived from the `columns` prop.
|
|
350
|
+
*/
|
|
327
351
|
columnsSort: PropTypes.oneOf(['asc', 'desc']),
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Callback called when the delete button is clicked.
|
|
355
|
+
* @param {GridFilterItem} item The deleted [[GridFilterItem]].
|
|
356
|
+
*/
|
|
328
357
|
deleteFilter: PropTypes.func.isRequired,
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Props passed to the delete icon.
|
|
361
|
+
* @default {}
|
|
362
|
+
*/
|
|
329
363
|
deleteIconProps: PropTypes.any,
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* If `true`, disables the logic operator field but still renders it.
|
|
367
|
+
*/
|
|
330
368
|
disableMultiFilterOperator: PropTypes.bool,
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* A ref allowing to set imperative focus.
|
|
372
|
+
* It can be passed to the el
|
|
373
|
+
*/
|
|
331
374
|
focusElementRef: PropTypes
|
|
332
375
|
/* @typescript-to-proptypes-ignore */
|
|
333
376
|
.oneOfType([PropTypes.func, PropTypes.object]),
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* If `true`, the logic operator field is rendered.
|
|
380
|
+
* The field will be invisible if `showMultiFilterOperators` is also `true`.
|
|
381
|
+
*/
|
|
334
382
|
hasMultipleFilters: PropTypes.bool.isRequired,
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* The [[GridFilterItem]] representing this form.
|
|
386
|
+
*/
|
|
335
387
|
item: PropTypes.shape({
|
|
336
388
|
columnField: PropTypes.string.isRequired,
|
|
337
389
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
338
390
|
operatorValue: PropTypes.string,
|
|
339
391
|
value: PropTypes.any
|
|
340
392
|
}).isRequired,
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Props passed to the logic operator input component.
|
|
396
|
+
* @default {}
|
|
397
|
+
*/
|
|
341
398
|
linkOperatorInputProps: PropTypes.any,
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Sets the available logic operators.
|
|
402
|
+
* @default [GridLinkOperator.And, GridLinkOperator.Or]
|
|
403
|
+
*/
|
|
342
404
|
linkOperators: PropTypes.arrayOf(PropTypes.oneOf(['and', 'or']).isRequired),
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* The current logic operator applied.
|
|
408
|
+
*/
|
|
343
409
|
multiFilterOperator: PropTypes.oneOf(['and', 'or']),
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Props passed to the operator input component.
|
|
413
|
+
* @default {}
|
|
414
|
+
*/
|
|
344
415
|
operatorInputProps: PropTypes.any,
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* If `true`, the logic operator field is visible.
|
|
419
|
+
*/
|
|
345
420
|
showMultiFilterOperators: PropTypes.bool,
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Props passed to the value input component.
|
|
424
|
+
* @default {}
|
|
425
|
+
*/
|
|
346
426
|
valueInputProps: PropTypes.any
|
|
347
427
|
} : void 0;
|
|
348
428
|
export { GridFilterForm };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["linkOperators", "columnsSort", "filterFormProps"];
|
|
3
|
+
const _excluded = ["linkOperators", "columnsSort", "filterFormProps", "children"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { GridLinkOperator } from '../../../models/gridFilterItem';
|
|
@@ -16,8 +16,7 @@ import { gridFilterModelSelector } from '../../../hooks/features/filter/gridFilt
|
|
|
16
16
|
import { gridFilterableColumnDefinitionsSelector } from '../../../hooks/features/columns/gridColumnsSelector';
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
-
|
|
20
|
-
function GridFilterPanel(props) {
|
|
19
|
+
const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(props, ref) {
|
|
21
20
|
const apiRef = useGridApiContext();
|
|
22
21
|
const rootProps = useGridRootProps();
|
|
23
22
|
const filterModel = useGridSelector(apiRef, gridFilterModelSelector);
|
|
@@ -67,9 +66,7 @@ function GridFilterPanel(props) {
|
|
|
67
66
|
return;
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
apiRef.current.
|
|
71
|
-
items: [...items, defaultItem]
|
|
72
|
-
}));
|
|
69
|
+
apiRef.current.upsertFilterItems([...items, defaultItem]);
|
|
73
70
|
};
|
|
74
71
|
|
|
75
72
|
const deleteFilter = React.useCallback(item => {
|
|
@@ -90,7 +87,9 @@ function GridFilterPanel(props) {
|
|
|
90
87
|
lastFilterRef.current.focus();
|
|
91
88
|
}
|
|
92
89
|
}, [items.length]);
|
|
93
|
-
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({
|
|
90
|
+
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({
|
|
91
|
+
ref: ref
|
|
92
|
+
}, other, {
|
|
94
93
|
children: [/*#__PURE__*/_jsx(GridPanelContent, {
|
|
95
94
|
children: items.map((item, index) => /*#__PURE__*/_jsx(GridFilterForm, _extends({
|
|
96
95
|
item: item,
|
|
@@ -108,21 +107,28 @@ function GridFilterPanel(props) {
|
|
|
108
107
|
}), !rootProps.disableMultipleColumnsFiltering && /*#__PURE__*/_jsx(GridPanelFooter, {
|
|
109
108
|
children: /*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
|
|
110
109
|
onClick: addNewFilter,
|
|
111
|
-
startIcon: /*#__PURE__*/_jsx(GridAddIcon, {})
|
|
112
|
-
color: "primary"
|
|
110
|
+
startIcon: /*#__PURE__*/_jsx(GridAddIcon, {})
|
|
113
111
|
}, rootProps.componentsProps?.baseButton, {
|
|
114
112
|
children: apiRef.current.getLocaleText('filterPanelAddFilter')
|
|
115
113
|
}))
|
|
116
114
|
})]
|
|
117
115
|
}));
|
|
118
|
-
}
|
|
119
|
-
|
|
116
|
+
});
|
|
120
117
|
process.env.NODE_ENV !== "production" ? GridFilterPanel.propTypes = {
|
|
121
118
|
// ----------------------------- Warning --------------------------------
|
|
122
119
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
123
120
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
124
121
|
// ----------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Changes how the options in the columns selector should be ordered.
|
|
125
|
+
* If not specified, the order is derived from the `columns` prop.
|
|
126
|
+
*/
|
|
125
127
|
columnsSort: PropTypes.oneOf(['asc', 'desc']),
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Props passed to each filter form.
|
|
131
|
+
*/
|
|
126
132
|
filterFormProps: PropTypes.shape({
|
|
127
133
|
columnInputProps: PropTypes.any,
|
|
128
134
|
columnsSort: PropTypes.oneOf(['asc', 'desc']),
|
|
@@ -131,7 +137,16 @@ process.env.NODE_ENV !== "production" ? GridFilterPanel.propTypes = {
|
|
|
131
137
|
operatorInputProps: PropTypes.any,
|
|
132
138
|
valueInputProps: PropTypes.any
|
|
133
139
|
}),
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Sets the available logic operators.
|
|
143
|
+
* @default [GridLinkOperator.And, GridLinkOperator.Or]
|
|
144
|
+
*/
|
|
134
145
|
linkOperators: PropTypes.arrayOf(PropTypes.oneOf(['and', 'or']).isRequired),
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
149
|
+
*/
|
|
135
150
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
136
151
|
} : void 0;
|
|
137
152
|
export { GridFilterPanel };
|
|
@@ -39,7 +39,6 @@ export const GridToolbarColumnsButton = /*#__PURE__*/React.forwardRef(function G
|
|
|
39
39
|
return /*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
|
|
40
40
|
ref: ref,
|
|
41
41
|
size: "small",
|
|
42
|
-
color: "primary",
|
|
43
42
|
"aria-label": apiRef.current.getLocaleText('toolbarColumnsLabel'),
|
|
44
43
|
startIcon: /*#__PURE__*/_jsx(rootProps.components.ColumnSelectorIcon, {})
|
|
45
44
|
}, other, {
|
|
@@ -93,7 +93,6 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
|
|
|
93
93
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
94
94
|
children: [/*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
|
|
95
95
|
ref: handleRef,
|
|
96
|
-
color: "primary",
|
|
97
96
|
size: "small",
|
|
98
97
|
startIcon: startIcon,
|
|
99
98
|
"aria-label": apiRef.current.getLocaleText('toolbarDensityLabel'),
|
|
@@ -50,7 +50,6 @@ export const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function
|
|
|
50
50
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
51
51
|
children: [/*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
|
|
52
52
|
ref: handleRef,
|
|
53
|
-
color: "primary",
|
|
54
53
|
size: "small",
|
|
55
54
|
startIcon: /*#__PURE__*/_jsx(rootProps.components.ExportIcon, {}),
|
|
56
55
|
"aria-expanded": open ? 'true' : undefined,
|
|
@@ -104,7 +104,6 @@ const GridToolbarFilterButton = /*#__PURE__*/React.forwardRef(function GridToolb
|
|
|
104
104
|
children: /*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
|
|
105
105
|
ref: ref,
|
|
106
106
|
size: "small",
|
|
107
|
-
color: "primary",
|
|
108
107
|
"aria-label": apiRef.current.getLocaleText('toolbarFiltersLabel'),
|
|
109
108
|
startIcon: /*#__PURE__*/_jsx(Badge, {
|
|
110
109
|
badgeContent: activeFilters.length,
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["quickFilterParser", "debounceMs"];
|
|
3
|
+
const _excluded = ["quickFilterParser", "quickFilterFormatter", "debounceMs"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import TextField from '@mui/material/TextField';
|
|
7
|
+
import IconButton from '@mui/material/IconButton';
|
|
7
8
|
import { styled } from '@mui/material/styles';
|
|
8
9
|
import { debounce } from '@mui/material/utils';
|
|
9
10
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
10
11
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
12
|
+
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
13
|
+
import { gridQuickFilterValuesSelector } from '../../hooks/features/filter';
|
|
14
|
+
import { isDeepEqual } from '../../utils/utils';
|
|
11
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
16
|
const GridToolbarQuickFilterRoot = styled(TextField, {
|
|
13
17
|
name: 'MuiDataGrid',
|
|
@@ -18,26 +22,53 @@ const GridToolbarQuickFilterRoot = styled(TextField, {
|
|
|
18
22
|
}) => ({
|
|
19
23
|
width: 'auto',
|
|
20
24
|
paddingBottom: theme.spacing(0.5),
|
|
21
|
-
'&
|
|
22
|
-
|
|
25
|
+
'& input': {
|
|
26
|
+
marginLeft: theme.spacing(0.5)
|
|
23
27
|
},
|
|
24
28
|
'& .MuiInput-underline:before': {
|
|
25
29
|
borderBottom: `1px solid ${theme.palette.divider}`
|
|
30
|
+
},
|
|
31
|
+
[`& input[type=search]::-ms-clear,
|
|
32
|
+
& input[type=search]::-ms-reveal`]: {
|
|
33
|
+
/* clears the 'X' icon from IE */
|
|
34
|
+
display: 'none',
|
|
35
|
+
width: 0,
|
|
36
|
+
height: 0
|
|
37
|
+
},
|
|
38
|
+
[`& input[type="search"]::-webkit-search-decoration,
|
|
39
|
+
& input[type="search"]::-webkit-search-cancel-button,
|
|
40
|
+
& input[type="search"]::-webkit-search-results-button,
|
|
41
|
+
& input[type="search"]::-webkit-search-results-decoration`]: {
|
|
42
|
+
/* clears the 'X' icon from Chrome */
|
|
43
|
+
display: 'none'
|
|
26
44
|
}
|
|
27
45
|
}));
|
|
28
46
|
|
|
29
47
|
const defaultSearchValueParser = searchText => searchText.split(' ').filter(word => word !== '');
|
|
30
48
|
|
|
49
|
+
const defaultSearchValueFormatter = values => values.join(' ');
|
|
50
|
+
|
|
31
51
|
function GridToolbarQuickFilter(props) {
|
|
32
52
|
const {
|
|
33
53
|
quickFilterParser = defaultSearchValueParser,
|
|
54
|
+
quickFilterFormatter = defaultSearchValueFormatter,
|
|
34
55
|
debounceMs = 500
|
|
35
56
|
} = props,
|
|
36
57
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
37
58
|
|
|
38
59
|
const apiRef = useGridApiContext();
|
|
39
60
|
const rootProps = useGridRootProps();
|
|
40
|
-
const
|
|
61
|
+
const quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
|
|
62
|
+
const [searchValue, setSearchValue] = React.useState(() => quickFilterFormatter(quickFilterValues ?? []));
|
|
63
|
+
const [prevQuickFilterValues, setPrevQuickFilterValues] = React.useState(quickFilterValues);
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
if (!isDeepEqual(prevQuickFilterValues, quickFilterValues)) {
|
|
66
|
+
// The model of quick filter value has been updated
|
|
67
|
+
setPrevQuickFilterValues(quickFilterValues); // Update the input value if needed to match the new model
|
|
68
|
+
|
|
69
|
+
setSearchValue(prevSearchValue => isDeepEqual(quickFilterParser(prevSearchValue), quickFilterValues) ? prevSearchValue : quickFilterFormatter(quickFilterValues ?? []));
|
|
70
|
+
}
|
|
71
|
+
}, [prevQuickFilterValues, quickFilterValues, quickFilterFormatter, quickFilterParser]);
|
|
41
72
|
const updateSearchValue = React.useCallback(newSearchValue => {
|
|
42
73
|
apiRef.current.setQuickFilterValues(quickFilterParser(newSearchValue));
|
|
43
74
|
}, [apiRef, quickFilterParser]);
|
|
@@ -47,6 +78,10 @@ function GridToolbarQuickFilter(props) {
|
|
|
47
78
|
setSearchValue(newSearchValue);
|
|
48
79
|
debouncedUpdateSearchValue(newSearchValue);
|
|
49
80
|
}, [debouncedUpdateSearchValue]);
|
|
81
|
+
const handleSearchReset = React.useCallback(() => {
|
|
82
|
+
setSearchValue('');
|
|
83
|
+
updateSearchValue('');
|
|
84
|
+
}, [updateSearchValue]);
|
|
50
85
|
return /*#__PURE__*/_jsx(GridToolbarQuickFilterRoot, _extends({
|
|
51
86
|
as: rootProps.components.BaseTextField,
|
|
52
87
|
variant: "standard",
|
|
@@ -58,6 +93,17 @@ function GridToolbarQuickFilter(props) {
|
|
|
58
93
|
InputProps: {
|
|
59
94
|
startAdornment: /*#__PURE__*/_jsx(rootProps.components.QuickFilterIcon, {
|
|
60
95
|
fontSize: "small"
|
|
96
|
+
}),
|
|
97
|
+
endAdornment: /*#__PURE__*/_jsx(IconButton, {
|
|
98
|
+
"aria-label": apiRef.current.getLocaleText('toolbarQuickFilterDeleteIconLabel'),
|
|
99
|
+
size: "small",
|
|
100
|
+
sx: {
|
|
101
|
+
visibility: searchValue ? 'visible' : 'hidden'
|
|
102
|
+
},
|
|
103
|
+
onClick: handleSearchReset,
|
|
104
|
+
children: /*#__PURE__*/_jsx(rootProps.components.QuickFilterClearIcon, {
|
|
105
|
+
fontSize: "small"
|
|
106
|
+
})
|
|
61
107
|
})
|
|
62
108
|
}
|
|
63
109
|
}, other, rootProps.componentsProps?.baseTextField));
|
|
@@ -75,6 +121,13 @@ process.env.NODE_ENV !== "production" ? GridToolbarQuickFilter.propTypes = {
|
|
|
75
121
|
*/
|
|
76
122
|
debounceMs: PropTypes.number,
|
|
77
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Function responsible for formatting values of quick filter in a string when the model is modified
|
|
126
|
+
* @param {any[]} values The new values passed to the quick filter model
|
|
127
|
+
* @returns {string} The string to display in the text field
|
|
128
|
+
*/
|
|
129
|
+
quickFilterFormatter: PropTypes.func,
|
|
130
|
+
|
|
78
131
|
/**
|
|
79
132
|
* Function responsible for parsing text input in an array of independent values for quick filtering.
|
|
80
133
|
* @param {string} input The value entered by the user
|
|
@@ -35,7 +35,8 @@ const DEFAULT_GRID_ICON_SLOTS_COMPONENTS = {
|
|
|
35
35
|
DetailPanelExpandIcon: GridAddIcon,
|
|
36
36
|
DetailPanelCollapseIcon: GridRemoveIcon,
|
|
37
37
|
RowReorderIcon: GridDragIcon,
|
|
38
|
-
QuickFilterIcon: GridSearchIcon
|
|
38
|
+
QuickFilterIcon: GridSearchIcon,
|
|
39
|
+
QuickFilterClearIcon: GridCloseIcon
|
|
39
40
|
};
|
|
40
41
|
/**
|
|
41
42
|
* TODO: Differentiate community and pro value and interface
|
|
@@ -2,4 +2,4 @@ import { generateUtilityClasses, generateUtilityClass } from '@mui/material';
|
|
|
2
2
|
export function getDataGridUtilityClass(slot) {
|
|
3
3
|
return generateUtilityClass('MuiDataGrid', slot);
|
|
4
4
|
}
|
|
5
|
-
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', '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', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle']);
|
|
5
|
+
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', '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', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle']);
|
|
@@ -105,6 +105,7 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
105
105
|
groupColumn: name => `Group by ${name}`,
|
|
106
106
|
unGroupColumn: name => `Stop grouping by ${name}`,
|
|
107
107
|
// Master/detail
|
|
108
|
+
detailPanelToggle: 'Detail panel toggle',
|
|
108
109
|
expandDetailPanel: 'Expand',
|
|
109
110
|
collapseDetailPanel: 'Collapse',
|
|
110
111
|
// Used core components translation keys
|
|
@@ -8,7 +8,7 @@ import { isFunction } from '../../utils/utils';
|
|
|
8
8
|
export const useGridStateInitialization = (apiRef, props) => {
|
|
9
9
|
const controlStateMapRef = React.useRef({});
|
|
10
10
|
const [, rawForceUpdate] = React.useState();
|
|
11
|
-
const
|
|
11
|
+
const registerControlState = React.useCallback(controlStateItem => {
|
|
12
12
|
const {
|
|
13
13
|
stateId
|
|
14
14
|
} = controlStateItem,
|
|
@@ -18,7 +18,7 @@ export const useGridStateInitialization = (apiRef, props) => {
|
|
|
18
18
|
stateId
|
|
19
19
|
});
|
|
20
20
|
}, []);
|
|
21
|
-
const setState = React.useCallback(state => {
|
|
21
|
+
const setState = React.useCallback((state, reason) => {
|
|
22
22
|
let newState;
|
|
23
23
|
|
|
24
24
|
if (isFunction(state)) {
|
|
@@ -79,23 +79,36 @@ export const useGridStateInitialization = (apiRef, props) => {
|
|
|
79
79
|
|
|
80
80
|
if (controlState.propOnChange && hasPropChanged) {
|
|
81
81
|
const details = props.signature === GridSignature.DataGridPro ? {
|
|
82
|
-
api: apiRef.current
|
|
83
|
-
|
|
82
|
+
api: apiRef.current,
|
|
83
|
+
reason
|
|
84
|
+
} : {
|
|
85
|
+
reason
|
|
86
|
+
};
|
|
84
87
|
controlState.propOnChange(model, details);
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
if (!ignoreSetState) {
|
|
88
|
-
apiRef.current.publishEvent(controlState.changeEvent, model
|
|
91
|
+
apiRef.current.publishEvent(controlState.changeEvent, model, {
|
|
92
|
+
reason
|
|
93
|
+
});
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
return !ignoreSetState;
|
|
93
98
|
}, [apiRef, props.signature]);
|
|
99
|
+
const updateControlState = React.useCallback((key, state, reason) => {
|
|
100
|
+
return apiRef.current.setState(previousState => {
|
|
101
|
+
return _extends({}, previousState, {
|
|
102
|
+
[key]: state(previousState[key])
|
|
103
|
+
});
|
|
104
|
+
}, reason);
|
|
105
|
+
}, [apiRef]);
|
|
94
106
|
const forceUpdate = React.useCallback(() => rawForceUpdate(() => apiRef.current.state), [apiRef]);
|
|
95
107
|
const stateApi = {
|
|
96
108
|
setState,
|
|
97
109
|
forceUpdate,
|
|
98
|
-
unstable_updateControlState: updateControlState
|
|
110
|
+
unstable_updateControlState: updateControlState,
|
|
111
|
+
unstable_registerControlState: registerControlState
|
|
99
112
|
};
|
|
100
113
|
useGridApiMethod(apiRef, stateApi, 'GridStateApi');
|
|
101
114
|
};
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useGridLogger, useGridApiMethod, useGridApiEventHandler } from '../../utils';
|
|
4
4
|
import { gridColumnMenuSelector } from './columnMenuSelector';
|
|
5
|
+
import { gridClasses } from '../../../constants/gridClasses';
|
|
5
6
|
export const columnMenuStateInitializer = state => _extends({}, state, {
|
|
6
7
|
columnMenu: {
|
|
7
8
|
open: false
|
|
@@ -77,7 +78,28 @@ export const useGridColumnMenu = apiRef => {
|
|
|
77
78
|
* EVENTS
|
|
78
79
|
*/
|
|
79
80
|
|
|
81
|
+
const handleColumnHeaderFocus = React.useCallback((params, event) => {
|
|
82
|
+
// Check if the column menu button received focus
|
|
83
|
+
if (!event.target.classList.contains(gridClasses.menuIconButton)) {
|
|
84
|
+
return;
|
|
85
|
+
} // Check if there's an element which lost focus
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
if (!event.relatedTarget) {
|
|
89
|
+
return;
|
|
90
|
+
} // `true` if the focus was on the column menu itself, not on any item
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
const columnMenuLostFocus = event.relatedTarget.classList.contains(gridClasses.menuList); // `true` if the focus was on an item from the column menu
|
|
94
|
+
|
|
95
|
+
const columnMenuItemLostFocus = event.relatedTarget.getAttribute('role') === 'menuitem';
|
|
96
|
+
|
|
97
|
+
if (columnMenuLostFocus || columnMenuItemLostFocus) {
|
|
98
|
+
apiRef.current.setColumnHeaderFocus(params.field);
|
|
99
|
+
}
|
|
100
|
+
}, [apiRef]);
|
|
80
101
|
useGridApiEventHandler(apiRef, 'columnResizeStart', hideColumnMenu);
|
|
102
|
+
useGridApiEventHandler(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
|
|
81
103
|
useGridApiEventHandler(apiRef, 'virtualScrollerWheel', apiRef.current.hideColumnMenu);
|
|
82
104
|
useGridApiEventHandler(apiRef, 'virtualScrollerTouchMove', apiRef.current.hideColumnMenu);
|
|
83
105
|
};
|
|
@@ -10,6 +10,9 @@ import { GridPreferencePanelsValue } from '../preferencesPanel';
|
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
export const columnsStateInitializer = (state, props, apiRef) => {
|
|
12
12
|
const isUsingColumnVisibilityModel = !!props.columnVisibilityModel || !!props.initialState?.columns?.columnVisibilityModel;
|
|
13
|
+
apiRef.current.unstable_caches.columns = {
|
|
14
|
+
isUsingColumnVisibilityModel
|
|
15
|
+
};
|
|
13
16
|
const columnsTypes = computeColumnTypes(props.columnTypes);
|
|
14
17
|
const columnsState = createColumnsState({
|
|
15
18
|
apiRef,
|
|
@@ -35,13 +38,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
35
38
|
const columnTypes = React.useMemo(() => computeColumnTypes(props.columnTypes), [props.columnTypes]);
|
|
36
39
|
const previousColumnsProp = React.useRef(props.columns);
|
|
37
40
|
const previousColumnTypesProp = React.useRef(columnTypes);
|
|
38
|
-
|
|
39
|
-
* If `initialState.columns.columnVisibilityModel` or `columnVisibilityModel` was defined during the 1st render, we are directly updating the model
|
|
40
|
-
* If not, we keep the old behavior and update the `GridColDef.hide` option (which will update the state model through the `GridColDef.hide` => `columnVisibilityModel` sync in `createColumnsState`
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
const isUsingColumnVisibilityModel = React.useRef(!!props.columnVisibilityModel || !!props.initialState?.columns?.columnVisibilityModel);
|
|
44
|
-
apiRef.current.unstable_updateControlState({
|
|
41
|
+
apiRef.current.unstable_registerControlState({
|
|
45
42
|
stateId: 'visibleColumns',
|
|
46
43
|
propModel: props.columnVisibilityModel,
|
|
47
44
|
propOnChange: props.onColumnVisibilityModelChange,
|
|
@@ -104,7 +101,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
104
101
|
// We keep updating the `hide` option of `GridColDef` when not controlling the model to avoid any breaking change.
|
|
105
102
|
// `updateColumns` take care of updating the model itself if needs be.
|
|
106
103
|
// TODO v6: stop using the `hide` field even when the model is not defined
|
|
107
|
-
if (
|
|
104
|
+
if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
|
|
108
105
|
const columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
|
|
109
106
|
const isCurrentlyVisible = columnVisibilityModel[field] ?? true;
|
|
110
107
|
|
|
@@ -141,7 +138,8 @@ export function useGridColumns(apiRef, props) {
|
|
|
141
138
|
|
|
142
139
|
logger.debug(`Moving column ${field} to index ${targetIndexPosition}`);
|
|
143
140
|
const updatedColumns = [...allColumns];
|
|
144
|
-
|
|
141
|
+
const fieldRemoved = updatedColumns.splice(oldIndexPosition, 1)[0];
|
|
142
|
+
updatedColumns.splice(targetIndexPosition, 0, fieldRemoved);
|
|
145
143
|
setGridColumnsState(_extends({}, gridColumnsSelector(apiRef.current.state), {
|
|
146
144
|
all: updatedColumns
|
|
147
145
|
}));
|
|
@@ -191,7 +189,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
191
189
|
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
192
190
|
const columnsStateToExport = {};
|
|
193
191
|
|
|
194
|
-
if (
|
|
192
|
+
if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
|
|
195
193
|
const columnVisibilityModelToExport = gridColumnVisibilityModelSelector(apiRef);
|
|
196
194
|
const hasHiddenColumns = Object.values(columnVisibilityModelToExport).some(value => value === false);
|
|
197
195
|
|
|
@@ -228,7 +226,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
228
226
|
});
|
|
229
227
|
}, [apiRef]);
|
|
230
228
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
231
|
-
const columnVisibilityModelToImport =
|
|
229
|
+
const columnVisibilityModelToImport = apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel ? context.stateToRestore.columns?.columnVisibilityModel : undefined;
|
|
232
230
|
const initialState = context.stateToRestore.columns;
|
|
233
231
|
|
|
234
232
|
if (columnVisibilityModelToImport == null && initialState == null) {
|
|
@@ -240,7 +238,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
240
238
|
columnTypes,
|
|
241
239
|
columnsToUpsert: [],
|
|
242
240
|
initialState,
|
|
243
|
-
shouldRegenColumnVisibilityModelFromColumns: !
|
|
241
|
+
shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
|
|
244
242
|
currentColumnVisibilityModel: columnVisibilityModelToImport,
|
|
245
243
|
keepOnlyColumnsToUpsert: false
|
|
246
244
|
});
|
|
@@ -289,7 +287,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
289
287
|
columnTypes,
|
|
290
288
|
columnsToUpsert: [],
|
|
291
289
|
initialState: undefined,
|
|
292
|
-
shouldRegenColumnVisibilityModelFromColumns: !
|
|
290
|
+
shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
|
|
293
291
|
keepOnlyColumnsToUpsert: false
|
|
294
292
|
});
|
|
295
293
|
setGridColumnsState(columnsState);
|
|
@@ -319,7 +317,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
319
317
|
columnTypes,
|
|
320
318
|
initialState: undefined,
|
|
321
319
|
// If the user provides a model, we don't want to set it in the state here because it has it's dedicated `useEffect` which calls `setColumnVisibilityModel`
|
|
322
|
-
shouldRegenColumnVisibilityModelFromColumns: !
|
|
320
|
+
shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
|
|
323
321
|
columnsToUpsert: props.columns,
|
|
324
322
|
keepOnlyColumnsToUpsert: true
|
|
325
323
|
});
|