@mui/x-data-grid 9.7.0 → 9.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +249 -1
- package/DataGrid/DataGrid.js +7 -0
- package/DataGrid/DataGrid.mjs +7 -0
- package/components/GridColumnSortButton.d.mts +1 -1
- package/components/GridColumnSortButton.d.ts +1 -1
- package/components/GridColumnUnsortedIcon.d.mts +2 -1
- package/components/GridColumnUnsortedIcon.d.ts +2 -1
- package/components/GridHeader.d.mts +2 -1
- package/components/GridHeader.d.ts +2 -1
- package/components/GridHeaders.d.mts +1 -1
- package/components/GridHeaders.d.ts +1 -1
- package/components/GridPagination.d.mts +2 -1
- package/components/GridPagination.d.ts +2 -1
- package/components/GridRowDragAndDropOverlay.d.mts +1 -1
- package/components/GridRowDragAndDropOverlay.d.ts +1 -1
- package/components/GridScrollArea.d.mts +2 -1
- package/components/GridScrollArea.d.ts +2 -1
- package/components/GridScrollShadows.d.mts +2 -1
- package/components/GridScrollShadows.d.ts +2 -1
- package/components/GridScrollbarFillerCell.d.mts +1 -1
- package/components/GridScrollbarFillerCell.d.ts +1 -1
- package/components/base/GridFooterPlaceholder.d.mts +1 -1
- package/components/base/GridFooterPlaceholder.d.ts +1 -1
- package/components/base/GridFooterPlaceholder.js +1 -1
- package/components/base/GridFooterPlaceholder.mjs +1 -1
- package/components/base/GridOverlays.d.mts +1 -1
- package/components/base/GridOverlays.d.ts +1 -1
- package/components/cell/GridActionsCell.d.mts +2 -2
- package/components/cell/GridActionsCell.d.ts +2 -2
- package/components/cell/GridActionsCellItem.js +1 -58
- package/components/cell/GridActionsCellItem.mjs +1 -58
- package/components/cell/GridBooleanCell.d.mts +1 -1
- package/components/cell/GridBooleanCell.d.ts +1 -1
- package/components/cell/GridEditBooleanCell.d.mts +2 -2
- package/components/cell/GridEditBooleanCell.d.ts +2 -2
- package/components/cell/GridEditDateCell.d.mts +2 -2
- package/components/cell/GridEditDateCell.d.ts +2 -2
- package/components/cell/GridEditInputCell.d.mts +1 -1
- package/components/cell/GridEditInputCell.d.ts +1 -1
- package/components/cell/GridEditLongTextCell.d.mts +2 -2
- package/components/cell/GridEditLongTextCell.d.ts +2 -2
- package/components/cell/GridEditSingleSelectCell.d.mts +3 -2
- package/components/cell/GridEditSingleSelectCell.d.ts +3 -2
- package/components/cell/GridFooterCell.d.mts +1 -1
- package/components/cell/GridFooterCell.d.ts +1 -1
- package/components/cell/GridLongTextCell.d.mts +2 -2
- package/components/cell/GridLongTextCell.d.ts +2 -2
- package/components/cell/GridSkeletonCell.d.mts +1 -1
- package/components/cell/GridSkeletonCell.d.ts +1 -1
- package/components/columnHeaders/ColumnHeaderMenuIcon.d.mts +1 -1
- package/components/columnHeaders/ColumnHeaderMenuIcon.d.ts +1 -1
- package/components/columnHeaders/GridColumnGroupHeader.d.mts +1 -1
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +1 -1
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.mts +1 -1
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +1 -1
- package/components/columnHeaders/GridColumnHeaderItem.d.mts +1 -1
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +1 -1
- package/components/columnHeaders/GridColumnHeaderSeparator.d.mts +1 -1
- package/components/columnHeaders/GridColumnHeaderSeparator.d.ts +1 -1
- package/components/columnHeaders/GridColumnHeaderSortIcon.d.mts +1 -1
- package/components/columnHeaders/GridColumnHeaderSortIcon.d.ts +1 -1
- package/components/columnHeaders/GridColumnHeaderTitle.d.mts +1 -1
- package/components/columnHeaders/GridColumnHeaderTitle.d.ts +1 -1
- package/components/columnsManagement/GridColumnsManagement.d.mts +2 -1
- package/components/columnsManagement/GridColumnsManagement.d.ts +2 -1
- package/components/menu/GridMenu.d.mts +1 -1
- package/components/menu/GridMenu.d.ts +1 -1
- package/components/menu/columnMenu/GridColumnHeaderMenu.d.mts +1 -1
- package/components/menu/columnMenu/GridColumnHeaderMenu.d.ts +1 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.d.mts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.d.ts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.d.mts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.d.ts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.d.mts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.d.ts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.d.mts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.d.ts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.d.mts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.d.ts +2 -1
- package/components/panel/GridColumnsPanel.d.mts +1 -1
- package/components/panel/GridColumnsPanel.d.ts +1 -1
- package/components/panel/GridPanelContent.d.mts +1 -1
- package/components/panel/GridPanelContent.d.ts +1 -1
- package/components/panel/GridPanelContext.d.mts +1 -1
- package/components/panel/GridPanelContext.d.ts +1 -1
- package/components/panel/GridPanelFooter.d.mts +1 -1
- package/components/panel/GridPanelFooter.d.ts +1 -1
- package/components/panel/GridPanelHeader.d.mts +1 -1
- package/components/panel/GridPanelHeader.d.ts +1 -1
- package/components/panel/GridPreferencesPanel.d.mts +1 -1
- package/components/panel/GridPreferencesPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterForm.d.mts +1 -98
- package/components/panel/filterPanel/GridFilterForm.d.ts +1 -98
- package/components/panel/filterPanel/GridFilterForm.js +9 -355
- package/components/panel/filterPanel/GridFilterForm.mjs +8 -354
- package/components/panel/filterPanel/GridFilterFormBase.d.mts +119 -0
- package/components/panel/filterPanel/GridFilterFormBase.d.ts +119 -0
- package/components/panel/filterPanel/GridFilterFormBase.js +497 -0
- package/components/panel/filterPanel/GridFilterFormBase.mjs +491 -0
- package/components/panel/filterPanel/GridFilterInputBoolean.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +6 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.mjs +6 -1
- package/components/panel/filterPanel/GridFilterInputDate.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +21 -9
- package/components/panel/filterPanel/GridFilterInputDate.mjs +21 -9
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +6 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.mjs +6 -1
- package/components/panel/filterPanel/GridFilterInputMultipleValue.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +6 -1
- package/components/panel/filterPanel/GridFilterInputMultipleValue.mjs +6 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +6 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.mjs +6 -1
- package/components/panel/filterPanel/GridFilterInputValue.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputValue.js +19 -8
- package/components/panel/filterPanel/GridFilterInputValue.mjs +19 -8
- package/components/panel/filterPanel/GridFilterPanel.d.mts +3 -40
- package/components/panel/filterPanel/GridFilterPanel.d.ts +3 -40
- package/components/panel/filterPanel/GridFilterPanel.js +19 -174
- package/components/panel/filterPanel/GridFilterPanel.mjs +14 -173
- package/components/panel/filterPanel/GridFilterPanelBase.d.mts +79 -0
- package/components/panel/filterPanel/GridFilterPanelBase.d.ts +79 -0
- package/components/panel/filterPanel/GridFilterPanelBase.js +304 -0
- package/components/panel/filterPanel/GridFilterPanelBase.mjs +297 -0
- package/components/panel/filterPanel/index.d.mts +3 -1
- package/components/panel/filterPanel/index.d.ts +3 -1
- package/components/panel/filterPanel/index.js +9 -1
- package/components/panel/filterPanel/index.mjs +3 -0
- package/components/quickFilter/QuickFilter.d.mts +1 -1
- package/components/quickFilter/QuickFilter.d.ts +1 -1
- package/components/toolbar/GridToolbarExport.d.mts +2 -2
- package/components/toolbar/GridToolbarExport.d.ts +2 -2
- package/components/toolbar/GridToolbarQuickFilter.d.mts +1 -1
- package/components/toolbar/GridToolbarQuickFilter.d.ts +1 -1
- package/components/toolbarV8/GridToolbar.d.mts +3 -3
- package/components/toolbarV8/GridToolbar.d.ts +3 -3
- package/components/virtualization/GridBottomContainer.d.mts +1 -1
- package/components/virtualization/GridBottomContainer.d.ts +1 -1
- package/components/virtualization/GridTopContainer.d.mts +1 -1
- package/components/virtualization/GridTopContainer.d.ts +1 -1
- package/components/virtualization/GridVirtualScroller.d.mts +1 -1
- package/components/virtualization/GridVirtualScroller.d.ts +1 -1
- package/components/virtualization/GridVirtualScrollerFiller.d.mts +2 -1
- package/components/virtualization/GridVirtualScrollerFiller.d.ts +2 -1
- package/constants/dataGridPropsDefaultValues.js +1 -0
- package/constants/dataGridPropsDefaultValues.mjs +1 -0
- package/context/GridContextProvider.d.mts +1 -1
- package/context/GridContextProvider.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.mts +2 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +2 -2
- package/hooks/features/dataSource/useGridDataSourceBase.d.mts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.js +39 -10
- package/hooks/features/dataSource/useGridDataSourceBase.mjs +39 -10
- package/hooks/features/editing/useGridCellEditing.js +14 -7
- package/hooks/features/editing/useGridCellEditing.mjs +14 -7
- package/hooks/features/filter/gridFilterUtils.d.mts +12 -0
- package/hooks/features/filter/gridFilterUtils.d.ts +12 -0
- package/hooks/features/filter/gridFilterUtils.js +56 -1
- package/hooks/features/filter/gridFilterUtils.mjs +52 -0
- package/hooks/features/filter/useGridFilter.js +4 -35
- package/hooks/features/filter/useGridFilter.mjs +5 -36
- package/hooks/features/rows/gridRowsUtils.js +1 -1
- package/hooks/features/rows/gridRowsUtils.mjs +1 -1
- package/hooks/utils/useGridEvent.js +1 -1
- package/hooks/utils/useGridEvent.mjs +1 -1
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/demo/TailwindDemoContainer.d.mts +1 -1
- package/internals/demo/TailwindDemoContainer.d.ts +1 -1
- package/locales/jaJP.js +4 -5
- package/locales/jaJP.mjs +4 -5
- package/models/gridFilterInputComponent.d.mts +5 -0
- package/models/gridFilterInputComponent.d.ts +5 -0
- package/models/gridSlotsComponentsProps.d.mts +1 -1
- package/models/gridSlotsComponentsProps.d.ts +1 -1
- package/models/props/DataGridProps.d.mts +7 -0
- package/models/props/DataGridProps.d.ts +7 -0
- package/package.json +4 -4
- package/utils/css/context.d.mts +3 -3
- package/utils/css/context.d.ts +3 -3
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.getGridFilter = exports.GridFilterPanelBase = void 0;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
+
var _forwardRef = require("@mui/x-internals/forwardRef");
|
|
15
|
+
var _gridFilterItem = require("../../../models/gridFilterItem");
|
|
16
|
+
var _useGridApiContext = require("../../../hooks/utils/useGridApiContext");
|
|
17
|
+
var _GridPanelContent = require("../GridPanelContent");
|
|
18
|
+
var _GridPanelFooter = require("../GridPanelFooter");
|
|
19
|
+
var _GridPanelWrapper = require("../GridPanelWrapper");
|
|
20
|
+
var _GridFilterFormBase = require("./GridFilterFormBase");
|
|
21
|
+
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
22
|
+
var _useGridSelector = require("../../../hooks/utils/useGridSelector");
|
|
23
|
+
var _gridColumnsSelector = require("../../../hooks/features/columns/gridColumnsSelector");
|
|
24
|
+
var _gridFilterUtils = require("../../../hooks/features/filter/gridFilterUtils");
|
|
25
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
+
const _excluded = ["logicOperators", "columnsSort", "filterFormProps", "getColumnForNewFilter", "children", "disableAddFilterButton", "disableRemoveAllButton", "disableDebounce", "filterModel", "onFilterModelChange", "onClose"];
|
|
27
|
+
const getGridFilter = col => ({
|
|
28
|
+
field: col.field,
|
|
29
|
+
operator: col.filterOperators[0].value,
|
|
30
|
+
id: Math.round(Math.random() * 1e5)
|
|
31
|
+
});
|
|
32
|
+
exports.getGridFilter = getGridFilter;
|
|
33
|
+
const GridFilterPanelBase = exports.GridFilterPanelBase = (0, _forwardRef.forwardRef)(function GridFilterPanelBase(props, ref) {
|
|
34
|
+
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
35
|
+
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
36
|
+
const filterableColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridFilterableColumnDefinitionsSelector);
|
|
37
|
+
const filterableColumnsLookup = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridFilterableColumnLookupSelector);
|
|
38
|
+
const lastFilterRef = React.useRef(null);
|
|
39
|
+
const placeholderFilter = React.useRef(null);
|
|
40
|
+
const {
|
|
41
|
+
logicOperators = [_gridFilterItem.GridLogicOperator.And, _gridFilterItem.GridLogicOperator.Or],
|
|
42
|
+
columnsSort,
|
|
43
|
+
filterFormProps,
|
|
44
|
+
getColumnForNewFilter,
|
|
45
|
+
disableAddFilterButton = false,
|
|
46
|
+
disableRemoveAllButton = false,
|
|
47
|
+
disableDebounce = true,
|
|
48
|
+
filterModel,
|
|
49
|
+
onFilterModelChange,
|
|
50
|
+
onClose
|
|
51
|
+
} = props,
|
|
52
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
53
|
+
const applyFilter = React.useCallback(item => {
|
|
54
|
+
onFilterModelChange((0, _gridFilterUtils.upsertFilterItemInModel)(filterModel, item), 'upsertFilterItem');
|
|
55
|
+
}, [filterModel, onFilterModelChange]);
|
|
56
|
+
const applyFilterLogicOperator = React.useCallback(operator => {
|
|
57
|
+
onFilterModelChange((0, _gridFilterUtils.setFilterLogicOperatorInModel)(filterModel, operator), 'changeLogicOperator');
|
|
58
|
+
}, [filterModel, onFilterModelChange]);
|
|
59
|
+
const getDefaultFilter = React.useCallback(() => {
|
|
60
|
+
let nextColumnWithOperator;
|
|
61
|
+
if (getColumnForNewFilter && typeof getColumnForNewFilter === 'function') {
|
|
62
|
+
// To allow override the column for default (first) filter
|
|
63
|
+
const nextFieldName = getColumnForNewFilter({
|
|
64
|
+
currentFilters: filterModel?.items || [],
|
|
65
|
+
columns: filterableColumns
|
|
66
|
+
});
|
|
67
|
+
if (nextFieldName === null) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
nextColumnWithOperator = filterableColumns.find(({
|
|
71
|
+
field
|
|
72
|
+
}) => field === nextFieldName);
|
|
73
|
+
} else {
|
|
74
|
+
nextColumnWithOperator = filterableColumns.find(colDef => colDef.filterOperators?.length);
|
|
75
|
+
}
|
|
76
|
+
if (!nextColumnWithOperator) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return getGridFilter(nextColumnWithOperator);
|
|
80
|
+
}, [filterModel?.items, filterableColumns, getColumnForNewFilter]);
|
|
81
|
+
const getNewFilter = React.useCallback(() => {
|
|
82
|
+
if (getColumnForNewFilter === undefined || typeof getColumnForNewFilter !== 'function') {
|
|
83
|
+
return getDefaultFilter();
|
|
84
|
+
}
|
|
85
|
+
const currentFilters = filterModel.items.length ? filterModel.items : [getDefaultFilter()].filter(Boolean);
|
|
86
|
+
|
|
87
|
+
// If no items are there in filterModel, we have to pass defaultFilter
|
|
88
|
+
const nextColumnFieldName = getColumnForNewFilter({
|
|
89
|
+
currentFilters: currentFilters,
|
|
90
|
+
columns: filterableColumns
|
|
91
|
+
});
|
|
92
|
+
if (nextColumnFieldName === null) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const nextColumnWithOperator = filterableColumns.find(({
|
|
96
|
+
field
|
|
97
|
+
}) => field === nextColumnFieldName);
|
|
98
|
+
if (!nextColumnWithOperator) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return getGridFilter(nextColumnWithOperator);
|
|
102
|
+
}, [filterModel.items, filterableColumns, getColumnForNewFilter, getDefaultFilter]);
|
|
103
|
+
const items = React.useMemo(() => {
|
|
104
|
+
if (filterModel.items.length) {
|
|
105
|
+
return filterModel.items;
|
|
106
|
+
}
|
|
107
|
+
if (!placeholderFilter.current) {
|
|
108
|
+
placeholderFilter.current = getDefaultFilter();
|
|
109
|
+
}
|
|
110
|
+
return placeholderFilter.current ? [placeholderFilter.current] : [];
|
|
111
|
+
}, [filterModel.items, getDefaultFilter]);
|
|
112
|
+
const hasMultipleFilters = items.length > 1;
|
|
113
|
+
const {
|
|
114
|
+
readOnlyFilters,
|
|
115
|
+
validFilters
|
|
116
|
+
} = React.useMemo(() => items.reduce((acc, item) => {
|
|
117
|
+
if (filterableColumnsLookup[item.field]) {
|
|
118
|
+
acc.validFilters.push(item);
|
|
119
|
+
} else {
|
|
120
|
+
acc.readOnlyFilters.push(item);
|
|
121
|
+
}
|
|
122
|
+
return acc;
|
|
123
|
+
}, {
|
|
124
|
+
readOnlyFilters: [],
|
|
125
|
+
validFilters: []
|
|
126
|
+
}), [items, filterableColumnsLookup]);
|
|
127
|
+
const addNewFilter = React.useCallback(() => {
|
|
128
|
+
const newFilter = getNewFilter();
|
|
129
|
+
if (!newFilter) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
onFilterModelChange((0, _gridFilterUtils.upsertFilterItemsInModel)(filterModel, [...items, newFilter]), 'upsertFilterItems');
|
|
133
|
+
}, [filterModel, onFilterModelChange, getNewFilter, items]);
|
|
134
|
+
const deleteFilter = React.useCallback(item => {
|
|
135
|
+
const shouldCloseFilterPanel = validFilters.length === 1;
|
|
136
|
+
onFilterModelChange((0, _gridFilterUtils.deleteFilterItemFromModel)(filterModel, item), 'deleteFilterItem');
|
|
137
|
+
if (shouldCloseFilterPanel) {
|
|
138
|
+
onClose?.();
|
|
139
|
+
}
|
|
140
|
+
}, [filterModel, onFilterModelChange, onClose, validFilters.length]);
|
|
141
|
+
const handleRemoveAll = React.useCallback(() => {
|
|
142
|
+
if (validFilters.length === 1 && validFilters[0].value === undefined) {
|
|
143
|
+
onFilterModelChange((0, _gridFilterUtils.deleteFilterItemFromModel)(filterModel, validFilters[0]), 'deleteFilterItem');
|
|
144
|
+
onClose?.();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
onFilterModelChange((0, _extends2.default)({}, filterModel, {
|
|
148
|
+
items: readOnlyFilters
|
|
149
|
+
}), 'removeAllFilterItems');
|
|
150
|
+
}, [filterModel, onFilterModelChange, onClose, readOnlyFilters, validFilters]);
|
|
151
|
+
React.useEffect(() => {
|
|
152
|
+
if (logicOperators.length > 0 && filterModel.logicOperator && !logicOperators.includes(filterModel.logicOperator)) {
|
|
153
|
+
applyFilterLogicOperator(logicOperators[0]);
|
|
154
|
+
}
|
|
155
|
+
}, [logicOperators, applyFilterLogicOperator, filterModel.logicOperator]);
|
|
156
|
+
React.useEffect(() => {
|
|
157
|
+
if (validFilters.length > 0) {
|
|
158
|
+
lastFilterRef.current.focus();
|
|
159
|
+
}
|
|
160
|
+
}, [validFilters.length]);
|
|
161
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridPanelWrapper.GridPanelWrapper, (0, _extends2.default)({}, other, {
|
|
162
|
+
ref: ref,
|
|
163
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridPanelContent.GridPanelContent, {
|
|
164
|
+
children: [readOnlyFilters.map((item, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridFilterFormBase.GridFilterFormBase, (0, _extends2.default)({
|
|
165
|
+
item: item,
|
|
166
|
+
filterModel: filterModel,
|
|
167
|
+
applyFilterChanges: applyFilter,
|
|
168
|
+
deleteFilter: deleteFilter,
|
|
169
|
+
hasMultipleFilters: hasMultipleFilters,
|
|
170
|
+
showMultiFilterOperators: index > 0,
|
|
171
|
+
disableMultiFilterOperator: index !== 1,
|
|
172
|
+
applyMultiFilterOperatorChanges: applyFilterLogicOperator,
|
|
173
|
+
focusElementRef: null,
|
|
174
|
+
readOnly: true,
|
|
175
|
+
logicOperators: logicOperators,
|
|
176
|
+
columnsSort: columnsSort,
|
|
177
|
+
disableDebounce: disableDebounce
|
|
178
|
+
}, filterFormProps), item.id == null ? index : item.id)), validFilters.map((item, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridFilterFormBase.GridFilterFormBase, (0, _extends2.default)({
|
|
179
|
+
item: item,
|
|
180
|
+
filterModel: filterModel,
|
|
181
|
+
applyFilterChanges: applyFilter,
|
|
182
|
+
deleteFilter: deleteFilter,
|
|
183
|
+
hasMultipleFilters: hasMultipleFilters,
|
|
184
|
+
showMultiFilterOperators: readOnlyFilters.length + index > 0,
|
|
185
|
+
disableMultiFilterOperator: readOnlyFilters.length + index !== 1,
|
|
186
|
+
applyMultiFilterOperatorChanges: applyFilterLogicOperator,
|
|
187
|
+
focusElementRef: index === validFilters.length - 1 ? lastFilterRef : null,
|
|
188
|
+
logicOperators: logicOperators,
|
|
189
|
+
columnsSort: columnsSort,
|
|
190
|
+
disableDebounce: disableDebounce
|
|
191
|
+
}, filterFormProps), item.id == null ? index + readOnlyFilters.length : item.id))]
|
|
192
|
+
}), !rootProps.disableMultipleColumnsFiltering && !(disableAddFilterButton && disableRemoveAllButton) ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridPanelFooter.GridPanelFooter, {
|
|
193
|
+
children: [!disableAddFilterButton ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
|
|
194
|
+
onClick: addNewFilter,
|
|
195
|
+
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.filterPanelAddIcon, {})
|
|
196
|
+
}, rootProps.slotProps?.baseButton, {
|
|
197
|
+
children: apiRef.current.getLocaleText('filterPanelAddFilter')
|
|
198
|
+
})) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}), !disableRemoveAllButton && validFilters.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
|
|
199
|
+
onClick: handleRemoveAll,
|
|
200
|
+
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.filterPanelRemoveAllIcon, {})
|
|
201
|
+
}, rootProps.slotProps?.baseButton, {
|
|
202
|
+
children: apiRef.current.getLocaleText('filterPanelRemoveAll')
|
|
203
|
+
})) : null]
|
|
204
|
+
}) : null]
|
|
205
|
+
}));
|
|
206
|
+
});
|
|
207
|
+
if (process.env.NODE_ENV !== "production") GridFilterPanelBase.displayName = "GridFilterPanelBase";
|
|
208
|
+
process.env.NODE_ENV !== "production" ? GridFilterPanelBase.propTypes /* remove-proptypes */ = {
|
|
209
|
+
// ----------------------------- Warning --------------------------------
|
|
210
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
211
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
212
|
+
// ----------------------------------------------------------------------
|
|
213
|
+
/**
|
|
214
|
+
* @ignore - do not document.
|
|
215
|
+
*/
|
|
216
|
+
children: _propTypes.default.node,
|
|
217
|
+
/**
|
|
218
|
+
* Changes how the options in the columns selector should be ordered.
|
|
219
|
+
* If not specified, the order is derived from the `columns` prop.
|
|
220
|
+
*/
|
|
221
|
+
columnsSort: _propTypes.default.oneOf(['asc', 'desc']),
|
|
222
|
+
/**
|
|
223
|
+
* If `true`, the `Add filter` button will not be displayed.
|
|
224
|
+
* @default false
|
|
225
|
+
*/
|
|
226
|
+
disableAddFilterButton: _propTypes.default.bool,
|
|
227
|
+
/**
|
|
228
|
+
* If `true`, filter value changes are applied immediately without debouncing.
|
|
229
|
+
* @default true
|
|
230
|
+
*/
|
|
231
|
+
disableDebounce: _propTypes.default.bool,
|
|
232
|
+
/**
|
|
233
|
+
* If `true`, the `Remove all` button will be disabled
|
|
234
|
+
* @default false
|
|
235
|
+
*/
|
|
236
|
+
disableRemoveAllButton: _propTypes.default.bool,
|
|
237
|
+
/**
|
|
238
|
+
* Props passed to each filter form.
|
|
239
|
+
*/
|
|
240
|
+
filterFormProps: _propTypes.default.shape({
|
|
241
|
+
columnInputProps: _propTypes.default.any,
|
|
242
|
+
columnsSort: _propTypes.default.oneOf(['asc', 'desc']),
|
|
243
|
+
deleteIconProps: _propTypes.default.any,
|
|
244
|
+
filterColumns: _propTypes.default.func,
|
|
245
|
+
logicOperatorInputProps: _propTypes.default.any,
|
|
246
|
+
operatorInputProps: _propTypes.default.any,
|
|
247
|
+
valueInputProps: _propTypes.default.any
|
|
248
|
+
}),
|
|
249
|
+
/**
|
|
250
|
+
* The filter model edited by the panel.
|
|
251
|
+
*/
|
|
252
|
+
filterModel: _propTypes.default.shape({
|
|
253
|
+
items: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
254
|
+
field: _propTypes.default.string.isRequired,
|
|
255
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
256
|
+
operator: _propTypes.default.string.isRequired,
|
|
257
|
+
value: _propTypes.default.any
|
|
258
|
+
})).isRequired,
|
|
259
|
+
logicOperator: _propTypes.default.oneOf(['and', 'or']),
|
|
260
|
+
quickFilterExcludeHiddenColumns: _propTypes.default.bool,
|
|
261
|
+
quickFilterLogicOperator: _propTypes.default.oneOf(['and', 'or']),
|
|
262
|
+
quickFilterValues: _propTypes.default.array
|
|
263
|
+
}).isRequired,
|
|
264
|
+
/**
|
|
265
|
+
* Function that returns the next filter item to be picked as default filter.
|
|
266
|
+
* @param {GetColumnForNewFilterArgs} args Currently configured filters and columns.
|
|
267
|
+
* @returns {GridColDef['field']} The field to be used for the next filter or `null` to prevent adding a filter.
|
|
268
|
+
*/
|
|
269
|
+
getColumnForNewFilter: _propTypes.default.func,
|
|
270
|
+
/**
|
|
271
|
+
* Sets the available logic operators.
|
|
272
|
+
* @default [GridLogicOperator.And, GridLogicOperator.Or]
|
|
273
|
+
*/
|
|
274
|
+
logicOperators: _propTypes.default.arrayOf(_propTypes.default.oneOf(['and', 'or']).isRequired),
|
|
275
|
+
/**
|
|
276
|
+
* Callback fired when the panel requests to be closed, e.g. after the last filter is removed.
|
|
277
|
+
* In `GridFilterPanel` it hides the grid filter panel; for standalone usage it is a no-op
|
|
278
|
+
* unless provided.
|
|
279
|
+
*/
|
|
280
|
+
onClose: _propTypes.default.func,
|
|
281
|
+
/**
|
|
282
|
+
* Callback fired when the filter model is changed through the panel.
|
|
283
|
+
* @param {GridFilterModel} model The new filter model.
|
|
284
|
+
* @param {GridControlledStateReasonLookup['filter']} reason The reason for the model to have changed.
|
|
285
|
+
*/
|
|
286
|
+
onFilterModelChange: _propTypes.default.func.isRequired,
|
|
287
|
+
/**
|
|
288
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
289
|
+
*/
|
|
290
|
+
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
|
|
291
|
+
} : void 0;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* The lower-level filter panel used by `GridFilterPanel`.
|
|
295
|
+
* Unlike `GridFilterPanel`, it does not read or mutate the grid filter state — the model is
|
|
296
|
+
* provided through the `filterModel` prop and edits are reported through `onFilterModelChange`,
|
|
297
|
+
* which makes it usable with a controlled (draft) filter model.
|
|
298
|
+
*
|
|
299
|
+
* Demos:
|
|
300
|
+
* - [Filtering - overview](https://mui.com/x/react-data-grid/filtering/)
|
|
301
|
+
*
|
|
302
|
+
* API:
|
|
303
|
+
* - [GridFilterPanelBase API](https://mui.com/x/api/data-grid/grid-filter-panel-base/)
|
|
304
|
+
*/
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["logicOperators", "columnsSort", "filterFormProps", "getColumnForNewFilter", "children", "disableAddFilterButton", "disableRemoveAllButton", "disableDebounce", "filterModel", "onFilterModelChange", "onClose"];
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
9
|
+
import { GridLogicOperator } from "../../../models/gridFilterItem.mjs";
|
|
10
|
+
import { useGridApiContext } from "../../../hooks/utils/useGridApiContext.mjs";
|
|
11
|
+
import { GridPanelContent } from "../GridPanelContent.mjs";
|
|
12
|
+
import { GridPanelFooter } from "../GridPanelFooter.mjs";
|
|
13
|
+
import { GridPanelWrapper } from "../GridPanelWrapper.mjs";
|
|
14
|
+
import { GridFilterFormBase } from "./GridFilterFormBase.mjs";
|
|
15
|
+
import { useGridRootProps } from "../../../hooks/utils/useGridRootProps.mjs";
|
|
16
|
+
import { useGridSelector } from "../../../hooks/utils/useGridSelector.mjs";
|
|
17
|
+
import { gridFilterableColumnDefinitionsSelector, gridFilterableColumnLookupSelector } from "../../../hooks/features/columns/gridColumnsSelector.mjs";
|
|
18
|
+
import { upsertFilterItemInModel, upsertFilterItemsInModel, deleteFilterItemFromModel, setFilterLogicOperatorInModel } from "../../../hooks/features/filter/gridFilterUtils.mjs";
|
|
19
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
+
const getGridFilter = col => ({
|
|
21
|
+
field: col.field,
|
|
22
|
+
operator: col.filterOperators[0].value,
|
|
23
|
+
id: Math.round(Math.random() * 1e5)
|
|
24
|
+
});
|
|
25
|
+
const GridFilterPanelBase = forwardRef(function GridFilterPanelBase(props, ref) {
|
|
26
|
+
const apiRef = useGridApiContext();
|
|
27
|
+
const rootProps = useGridRootProps();
|
|
28
|
+
const filterableColumns = useGridSelector(apiRef, gridFilterableColumnDefinitionsSelector);
|
|
29
|
+
const filterableColumnsLookup = useGridSelector(apiRef, gridFilterableColumnLookupSelector);
|
|
30
|
+
const lastFilterRef = React.useRef(null);
|
|
31
|
+
const placeholderFilter = React.useRef(null);
|
|
32
|
+
const {
|
|
33
|
+
logicOperators = [GridLogicOperator.And, GridLogicOperator.Or],
|
|
34
|
+
columnsSort,
|
|
35
|
+
filterFormProps,
|
|
36
|
+
getColumnForNewFilter,
|
|
37
|
+
disableAddFilterButton = false,
|
|
38
|
+
disableRemoveAllButton = false,
|
|
39
|
+
disableDebounce = true,
|
|
40
|
+
filterModel,
|
|
41
|
+
onFilterModelChange,
|
|
42
|
+
onClose
|
|
43
|
+
} = props,
|
|
44
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
45
|
+
const applyFilter = React.useCallback(item => {
|
|
46
|
+
onFilterModelChange(upsertFilterItemInModel(filterModel, item), 'upsertFilterItem');
|
|
47
|
+
}, [filterModel, onFilterModelChange]);
|
|
48
|
+
const applyFilterLogicOperator = React.useCallback(operator => {
|
|
49
|
+
onFilterModelChange(setFilterLogicOperatorInModel(filterModel, operator), 'changeLogicOperator');
|
|
50
|
+
}, [filterModel, onFilterModelChange]);
|
|
51
|
+
const getDefaultFilter = React.useCallback(() => {
|
|
52
|
+
let nextColumnWithOperator;
|
|
53
|
+
if (getColumnForNewFilter && typeof getColumnForNewFilter === 'function') {
|
|
54
|
+
// To allow override the column for default (first) filter
|
|
55
|
+
const nextFieldName = getColumnForNewFilter({
|
|
56
|
+
currentFilters: filterModel?.items || [],
|
|
57
|
+
columns: filterableColumns
|
|
58
|
+
});
|
|
59
|
+
if (nextFieldName === null) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
nextColumnWithOperator = filterableColumns.find(({
|
|
63
|
+
field
|
|
64
|
+
}) => field === nextFieldName);
|
|
65
|
+
} else {
|
|
66
|
+
nextColumnWithOperator = filterableColumns.find(colDef => colDef.filterOperators?.length);
|
|
67
|
+
}
|
|
68
|
+
if (!nextColumnWithOperator) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return getGridFilter(nextColumnWithOperator);
|
|
72
|
+
}, [filterModel?.items, filterableColumns, getColumnForNewFilter]);
|
|
73
|
+
const getNewFilter = React.useCallback(() => {
|
|
74
|
+
if (getColumnForNewFilter === undefined || typeof getColumnForNewFilter !== 'function') {
|
|
75
|
+
return getDefaultFilter();
|
|
76
|
+
}
|
|
77
|
+
const currentFilters = filterModel.items.length ? filterModel.items : [getDefaultFilter()].filter(Boolean);
|
|
78
|
+
|
|
79
|
+
// If no items are there in filterModel, we have to pass defaultFilter
|
|
80
|
+
const nextColumnFieldName = getColumnForNewFilter({
|
|
81
|
+
currentFilters: currentFilters,
|
|
82
|
+
columns: filterableColumns
|
|
83
|
+
});
|
|
84
|
+
if (nextColumnFieldName === null) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const nextColumnWithOperator = filterableColumns.find(({
|
|
88
|
+
field
|
|
89
|
+
}) => field === nextColumnFieldName);
|
|
90
|
+
if (!nextColumnWithOperator) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return getGridFilter(nextColumnWithOperator);
|
|
94
|
+
}, [filterModel.items, filterableColumns, getColumnForNewFilter, getDefaultFilter]);
|
|
95
|
+
const items = React.useMemo(() => {
|
|
96
|
+
if (filterModel.items.length) {
|
|
97
|
+
return filterModel.items;
|
|
98
|
+
}
|
|
99
|
+
if (!placeholderFilter.current) {
|
|
100
|
+
placeholderFilter.current = getDefaultFilter();
|
|
101
|
+
}
|
|
102
|
+
return placeholderFilter.current ? [placeholderFilter.current] : [];
|
|
103
|
+
}, [filterModel.items, getDefaultFilter]);
|
|
104
|
+
const hasMultipleFilters = items.length > 1;
|
|
105
|
+
const {
|
|
106
|
+
readOnlyFilters,
|
|
107
|
+
validFilters
|
|
108
|
+
} = React.useMemo(() => items.reduce((acc, item) => {
|
|
109
|
+
if (filterableColumnsLookup[item.field]) {
|
|
110
|
+
acc.validFilters.push(item);
|
|
111
|
+
} else {
|
|
112
|
+
acc.readOnlyFilters.push(item);
|
|
113
|
+
}
|
|
114
|
+
return acc;
|
|
115
|
+
}, {
|
|
116
|
+
readOnlyFilters: [],
|
|
117
|
+
validFilters: []
|
|
118
|
+
}), [items, filterableColumnsLookup]);
|
|
119
|
+
const addNewFilter = React.useCallback(() => {
|
|
120
|
+
const newFilter = getNewFilter();
|
|
121
|
+
if (!newFilter) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
onFilterModelChange(upsertFilterItemsInModel(filterModel, [...items, newFilter]), 'upsertFilterItems');
|
|
125
|
+
}, [filterModel, onFilterModelChange, getNewFilter, items]);
|
|
126
|
+
const deleteFilter = React.useCallback(item => {
|
|
127
|
+
const shouldCloseFilterPanel = validFilters.length === 1;
|
|
128
|
+
onFilterModelChange(deleteFilterItemFromModel(filterModel, item), 'deleteFilterItem');
|
|
129
|
+
if (shouldCloseFilterPanel) {
|
|
130
|
+
onClose?.();
|
|
131
|
+
}
|
|
132
|
+
}, [filterModel, onFilterModelChange, onClose, validFilters.length]);
|
|
133
|
+
const handleRemoveAll = React.useCallback(() => {
|
|
134
|
+
if (validFilters.length === 1 && validFilters[0].value === undefined) {
|
|
135
|
+
onFilterModelChange(deleteFilterItemFromModel(filterModel, validFilters[0]), 'deleteFilterItem');
|
|
136
|
+
onClose?.();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
onFilterModelChange(_extends({}, filterModel, {
|
|
140
|
+
items: readOnlyFilters
|
|
141
|
+
}), 'removeAllFilterItems');
|
|
142
|
+
}, [filterModel, onFilterModelChange, onClose, readOnlyFilters, validFilters]);
|
|
143
|
+
React.useEffect(() => {
|
|
144
|
+
if (logicOperators.length > 0 && filterModel.logicOperator && !logicOperators.includes(filterModel.logicOperator)) {
|
|
145
|
+
applyFilterLogicOperator(logicOperators[0]);
|
|
146
|
+
}
|
|
147
|
+
}, [logicOperators, applyFilterLogicOperator, filterModel.logicOperator]);
|
|
148
|
+
React.useEffect(() => {
|
|
149
|
+
if (validFilters.length > 0) {
|
|
150
|
+
lastFilterRef.current.focus();
|
|
151
|
+
}
|
|
152
|
+
}, [validFilters.length]);
|
|
153
|
+
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
|
|
154
|
+
ref: ref,
|
|
155
|
+
children: [/*#__PURE__*/_jsxs(GridPanelContent, {
|
|
156
|
+
children: [readOnlyFilters.map((item, index) => /*#__PURE__*/_jsx(GridFilterFormBase, _extends({
|
|
157
|
+
item: item,
|
|
158
|
+
filterModel: filterModel,
|
|
159
|
+
applyFilterChanges: applyFilter,
|
|
160
|
+
deleteFilter: deleteFilter,
|
|
161
|
+
hasMultipleFilters: hasMultipleFilters,
|
|
162
|
+
showMultiFilterOperators: index > 0,
|
|
163
|
+
disableMultiFilterOperator: index !== 1,
|
|
164
|
+
applyMultiFilterOperatorChanges: applyFilterLogicOperator,
|
|
165
|
+
focusElementRef: null,
|
|
166
|
+
readOnly: true,
|
|
167
|
+
logicOperators: logicOperators,
|
|
168
|
+
columnsSort: columnsSort,
|
|
169
|
+
disableDebounce: disableDebounce
|
|
170
|
+
}, filterFormProps), item.id == null ? index : item.id)), validFilters.map((item, index) => /*#__PURE__*/_jsx(GridFilterFormBase, _extends({
|
|
171
|
+
item: item,
|
|
172
|
+
filterModel: filterModel,
|
|
173
|
+
applyFilterChanges: applyFilter,
|
|
174
|
+
deleteFilter: deleteFilter,
|
|
175
|
+
hasMultipleFilters: hasMultipleFilters,
|
|
176
|
+
showMultiFilterOperators: readOnlyFilters.length + index > 0,
|
|
177
|
+
disableMultiFilterOperator: readOnlyFilters.length + index !== 1,
|
|
178
|
+
applyMultiFilterOperatorChanges: applyFilterLogicOperator,
|
|
179
|
+
focusElementRef: index === validFilters.length - 1 ? lastFilterRef : null,
|
|
180
|
+
logicOperators: logicOperators,
|
|
181
|
+
columnsSort: columnsSort,
|
|
182
|
+
disableDebounce: disableDebounce
|
|
183
|
+
}, filterFormProps), item.id == null ? index + readOnlyFilters.length : item.id))]
|
|
184
|
+
}), !rootProps.disableMultipleColumnsFiltering && !(disableAddFilterButton && disableRemoveAllButton) ? /*#__PURE__*/_jsxs(GridPanelFooter, {
|
|
185
|
+
children: [!disableAddFilterButton ? /*#__PURE__*/_jsx(rootProps.slots.baseButton, _extends({
|
|
186
|
+
onClick: addNewFilter,
|
|
187
|
+
startIcon: /*#__PURE__*/_jsx(rootProps.slots.filterPanelAddIcon, {})
|
|
188
|
+
}, rootProps.slotProps?.baseButton, {
|
|
189
|
+
children: apiRef.current.getLocaleText('filterPanelAddFilter')
|
|
190
|
+
})) : /*#__PURE__*/_jsx("span", {}), !disableRemoveAllButton && validFilters.length > 0 ? /*#__PURE__*/_jsx(rootProps.slots.baseButton, _extends({
|
|
191
|
+
onClick: handleRemoveAll,
|
|
192
|
+
startIcon: /*#__PURE__*/_jsx(rootProps.slots.filterPanelRemoveAllIcon, {})
|
|
193
|
+
}, rootProps.slotProps?.baseButton, {
|
|
194
|
+
children: apiRef.current.getLocaleText('filterPanelRemoveAll')
|
|
195
|
+
})) : null]
|
|
196
|
+
}) : null]
|
|
197
|
+
}));
|
|
198
|
+
});
|
|
199
|
+
if (process.env.NODE_ENV !== "production") GridFilterPanelBase.displayName = "GridFilterPanelBase";
|
|
200
|
+
process.env.NODE_ENV !== "production" ? GridFilterPanelBase.propTypes /* remove-proptypes */ = {
|
|
201
|
+
// ----------------------------- Warning --------------------------------
|
|
202
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
203
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
204
|
+
// ----------------------------------------------------------------------
|
|
205
|
+
/**
|
|
206
|
+
* @ignore - do not document.
|
|
207
|
+
*/
|
|
208
|
+
children: PropTypes.node,
|
|
209
|
+
/**
|
|
210
|
+
* Changes how the options in the columns selector should be ordered.
|
|
211
|
+
* If not specified, the order is derived from the `columns` prop.
|
|
212
|
+
*/
|
|
213
|
+
columnsSort: PropTypes.oneOf(['asc', 'desc']),
|
|
214
|
+
/**
|
|
215
|
+
* If `true`, the `Add filter` button will not be displayed.
|
|
216
|
+
* @default false
|
|
217
|
+
*/
|
|
218
|
+
disableAddFilterButton: PropTypes.bool,
|
|
219
|
+
/**
|
|
220
|
+
* If `true`, filter value changes are applied immediately without debouncing.
|
|
221
|
+
* @default true
|
|
222
|
+
*/
|
|
223
|
+
disableDebounce: PropTypes.bool,
|
|
224
|
+
/**
|
|
225
|
+
* If `true`, the `Remove all` button will be disabled
|
|
226
|
+
* @default false
|
|
227
|
+
*/
|
|
228
|
+
disableRemoveAllButton: PropTypes.bool,
|
|
229
|
+
/**
|
|
230
|
+
* Props passed to each filter form.
|
|
231
|
+
*/
|
|
232
|
+
filterFormProps: PropTypes.shape({
|
|
233
|
+
columnInputProps: PropTypes.any,
|
|
234
|
+
columnsSort: PropTypes.oneOf(['asc', 'desc']),
|
|
235
|
+
deleteIconProps: PropTypes.any,
|
|
236
|
+
filterColumns: PropTypes.func,
|
|
237
|
+
logicOperatorInputProps: PropTypes.any,
|
|
238
|
+
operatorInputProps: PropTypes.any,
|
|
239
|
+
valueInputProps: PropTypes.any
|
|
240
|
+
}),
|
|
241
|
+
/**
|
|
242
|
+
* The filter model edited by the panel.
|
|
243
|
+
*/
|
|
244
|
+
filterModel: PropTypes.shape({
|
|
245
|
+
items: PropTypes.arrayOf(PropTypes.shape({
|
|
246
|
+
field: PropTypes.string.isRequired,
|
|
247
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
248
|
+
operator: PropTypes.string.isRequired,
|
|
249
|
+
value: PropTypes.any
|
|
250
|
+
})).isRequired,
|
|
251
|
+
logicOperator: PropTypes.oneOf(['and', 'or']),
|
|
252
|
+
quickFilterExcludeHiddenColumns: PropTypes.bool,
|
|
253
|
+
quickFilterLogicOperator: PropTypes.oneOf(['and', 'or']),
|
|
254
|
+
quickFilterValues: PropTypes.array
|
|
255
|
+
}).isRequired,
|
|
256
|
+
/**
|
|
257
|
+
* Function that returns the next filter item to be picked as default filter.
|
|
258
|
+
* @param {GetColumnForNewFilterArgs} args Currently configured filters and columns.
|
|
259
|
+
* @returns {GridColDef['field']} The field to be used for the next filter or `null` to prevent adding a filter.
|
|
260
|
+
*/
|
|
261
|
+
getColumnForNewFilter: PropTypes.func,
|
|
262
|
+
/**
|
|
263
|
+
* Sets the available logic operators.
|
|
264
|
+
* @default [GridLogicOperator.And, GridLogicOperator.Or]
|
|
265
|
+
*/
|
|
266
|
+
logicOperators: PropTypes.arrayOf(PropTypes.oneOf(['and', 'or']).isRequired),
|
|
267
|
+
/**
|
|
268
|
+
* Callback fired when the panel requests to be closed, e.g. after the last filter is removed.
|
|
269
|
+
* In `GridFilterPanel` it hides the grid filter panel; for standalone usage it is a no-op
|
|
270
|
+
* unless provided.
|
|
271
|
+
*/
|
|
272
|
+
onClose: PropTypes.func,
|
|
273
|
+
/**
|
|
274
|
+
* Callback fired when the filter model is changed through the panel.
|
|
275
|
+
* @param {GridFilterModel} model The new filter model.
|
|
276
|
+
* @param {GridControlledStateReasonLookup['filter']} reason The reason for the model to have changed.
|
|
277
|
+
*/
|
|
278
|
+
onFilterModelChange: PropTypes.func.isRequired,
|
|
279
|
+
/**
|
|
280
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
281
|
+
*/
|
|
282
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
283
|
+
} : void 0;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The lower-level filter panel used by `GridFilterPanel`.
|
|
287
|
+
* Unlike `GridFilterPanel`, it does not read or mutate the grid filter state — the model is
|
|
288
|
+
* provided through the `filterModel` prop and edits are reported through `onFilterModelChange`,
|
|
289
|
+
* which makes it usable with a controlled (draft) filter model.
|
|
290
|
+
*
|
|
291
|
+
* Demos:
|
|
292
|
+
* - [Filtering - overview](https://mui.com/x/react-data-grid/filtering/)
|
|
293
|
+
*
|
|
294
|
+
* API:
|
|
295
|
+
* - [GridFilterPanelBase API](https://mui.com/x/api/data-grid/grid-filter-panel-base/)
|
|
296
|
+
*/
|
|
297
|
+
export { GridFilterPanelBase, getGridFilter };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export * from "./GridFilterForm.mjs";
|
|
2
|
+
export type { FilterColumnsArgs, GridFilterFormProps } from "./GridFilterFormBase.mjs";
|
|
2
3
|
export { GridFilterInputValue, type GridTypeFilterInputValueProps } from "./GridFilterInputValue.mjs";
|
|
3
4
|
export * from "./GridFilterInputDate.mjs";
|
|
4
5
|
export * from "./GridFilterInputSingleSelect.mjs";
|
|
5
6
|
export { GridFilterInputBoolean } from "./GridFilterInputBoolean.mjs";
|
|
6
7
|
export type { GridFilterInputBooleanProps } from "./GridFilterInputBoolean.mjs";
|
|
7
8
|
export { GridFilterPanel } from "./GridFilterPanel.mjs";
|
|
8
|
-
export
|
|
9
|
+
export { GridFilterPanelBase } from "./GridFilterPanelBase.mjs";
|
|
10
|
+
export type { GetColumnForNewFilterArgs, GridFilterPanelBaseProps, GridFilterPanelProps } from "./GridFilterPanelBase.mjs";
|
|
9
11
|
export * from "./GridFilterInputMultipleValue.mjs";
|
|
10
12
|
export * from "./GridFilterInputMultipleSingleSelect.mjs";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export * from "./GridFilterForm.js";
|
|
2
|
+
export type { FilterColumnsArgs, GridFilterFormProps } from "./GridFilterFormBase.js";
|
|
2
3
|
export { GridFilterInputValue, type GridTypeFilterInputValueProps } from "./GridFilterInputValue.js";
|
|
3
4
|
export * from "./GridFilterInputDate.js";
|
|
4
5
|
export * from "./GridFilterInputSingleSelect.js";
|
|
5
6
|
export { GridFilterInputBoolean } from "./GridFilterInputBoolean.js";
|
|
6
7
|
export type { GridFilterInputBooleanProps } from "./GridFilterInputBoolean.js";
|
|
7
8
|
export { GridFilterPanel } from "./GridFilterPanel.js";
|
|
8
|
-
export
|
|
9
|
+
export { GridFilterPanelBase } from "./GridFilterPanelBase.js";
|
|
10
|
+
export type { GetColumnForNewFilterArgs, GridFilterPanelBaseProps, GridFilterPanelProps } from "./GridFilterPanelBase.js";
|
|
9
11
|
export * from "./GridFilterInputMultipleValue.js";
|
|
10
12
|
export * from "./GridFilterInputMultipleSingleSelect.js";
|
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
GridFilterInputValue: true,
|
|
8
8
|
GridFilterInputBoolean: true,
|
|
9
|
-
GridFilterPanel: true
|
|
9
|
+
GridFilterPanel: true,
|
|
10
|
+
GridFilterPanelBase: true
|
|
10
11
|
};
|
|
11
12
|
Object.defineProperty(exports, "GridFilterInputBoolean", {
|
|
12
13
|
enumerable: true,
|
|
@@ -26,6 +27,12 @@ Object.defineProperty(exports, "GridFilterPanel", {
|
|
|
26
27
|
return _GridFilterPanel.GridFilterPanel;
|
|
27
28
|
}
|
|
28
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "GridFilterPanelBase", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _GridFilterPanelBase.GridFilterPanelBase;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
29
36
|
var _GridFilterForm = require("./GridFilterForm");
|
|
30
37
|
Object.keys(_GridFilterForm).forEach(function (key) {
|
|
31
38
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -65,6 +72,7 @@ Object.keys(_GridFilterInputSingleSelect).forEach(function (key) {
|
|
|
65
72
|
});
|
|
66
73
|
var _GridFilterInputBoolean = require("./GridFilterInputBoolean");
|
|
67
74
|
var _GridFilterPanel = require("./GridFilterPanel");
|
|
75
|
+
var _GridFilterPanelBase = require("./GridFilterPanelBase");
|
|
68
76
|
var _GridFilterInputMultipleValue = require("./GridFilterInputMultipleValue");
|
|
69
77
|
Object.keys(_GridFilterInputMultipleValue).forEach(function (key) {
|
|
70
78
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from "./GridFilterForm.mjs";
|
|
2
|
+
// `GridFilterFormBase` is an internal component: only its public-facing prop types are re-exported.
|
|
3
|
+
|
|
2
4
|
export { GridFilterInputValue } from "./GridFilterInputValue.mjs";
|
|
3
5
|
export * from "./GridFilterInputDate.mjs";
|
|
4
6
|
export * from "./GridFilterInputSingleSelect.mjs";
|
|
5
7
|
export { GridFilterInputBoolean } from "./GridFilterInputBoolean.mjs";
|
|
6
8
|
export { GridFilterPanel } from "./GridFilterPanel.mjs";
|
|
9
|
+
export { GridFilterPanelBase } from "./GridFilterPanelBase.mjs";
|
|
7
10
|
export * from "./GridFilterInputMultipleValue.mjs";
|
|
8
11
|
export * from "./GridFilterInputMultipleSingleSelect.mjs";
|