@mui/x-data-grid 9.8.0 → 9.10.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 +230 -0
- package/DataGrid/DataGrid.js +7 -0
- package/DataGrid/DataGrid.mjs +7 -0
- package/colDef/gridNumericOperators.d.mts +1 -1
- package/colDef/gridNumericOperators.d.ts +1 -1
- 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/GridSkeletonLoadingOverlay.d.mts +1 -1
- package/components/GridSkeletonLoadingOverlay.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.d.mts +10 -10
- package/components/cell/GridActionsCellItem.d.ts +10 -10
- package/components/cell/GridActionsCellItem.js +1 -58
- package/components/cell/GridActionsCellItem.mjs +1 -58
- package/components/cell/GridBooleanCell.d.mts +1 -4
- package/components/cell/GridBooleanCell.d.ts +1 -4
- 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 -4
- package/components/cell/GridSkeletonCell.d.ts +1 -4
- 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 -4
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +1 -4
- package/components/columnHeaders/GridColumnHeaderSeparator.d.mts +1 -4
- package/components/columnHeaders/GridColumnHeaderSeparator.d.ts +1 -4
- package/components/columnHeaders/GridColumnHeaderSortIcon.d.mts +1 -4
- package/components/columnHeaders/GridColumnHeaderSortIcon.d.ts +1 -4
- 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/toolbarV8/utils.d.mts +1 -1
- package/components/toolbarV8/utils.d.ts +1 -1
- 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/cssVariables.d.mts +120 -120
- package/constants/cssVariables.d.ts +120 -120
- 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/core/useGridLocaleText.d.mts +1 -1
- package/hooks/core/useGridLocaleText.d.ts +1 -1
- package/hooks/core/useGridLoggerFactory.d.mts +1 -1
- package/hooks/core/useGridLoggerFactory.d.ts +1 -1
- package/hooks/features/clipboard/useGridClipboard.d.mts +1 -1
- package/hooks/features/clipboard/useGridClipboard.d.ts +1 -1
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.mts +1 -1
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.mts +4 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +4 -4
- package/hooks/features/columnResize/useGridColumnResize.d.mts +1 -1
- package/hooks/features/columnResize/useGridColumnResize.d.ts +1 -1
- package/hooks/features/columns/gridColumnsUtils.d.mts +1 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.d.mts +2 -2
- package/hooks/features/dataSource/useGridDataSourceBase.d.ts +2 -2
- package/hooks/features/dataSource/useGridDataSourceBase.js +39 -10
- package/hooks/features/dataSource/useGridDataSourceBase.mjs +39 -10
- package/hooks/features/density/useGridDensity.d.mts +1 -1
- package/hooks/features/density/useGridDensity.d.ts +1 -1
- package/hooks/features/editing/useGridCellEditing.d.mts +1 -1
- package/hooks/features/editing/useGridCellEditing.d.ts +1 -1
- package/hooks/features/editing/useGridEditing.d.mts +1 -1
- package/hooks/features/editing/useGridEditing.d.ts +1 -1
- package/hooks/features/editing/useGridRowEditing.d.mts +1 -1
- package/hooks/features/editing/useGridRowEditing.d.ts +1 -1
- package/hooks/features/editing/utils.d.mts +1 -1
- package/hooks/features/editing/utils.d.ts +1 -1
- package/hooks/features/export/useGridCsvExport.d.mts +1 -1
- package/hooks/features/export/useGridCsvExport.d.ts +1 -1
- package/hooks/features/export/useGridPrintExport.d.mts +1 -1
- package/hooks/features/export/useGridPrintExport.d.ts +1 -1
- package/hooks/features/filter/gridFilterUtils.d.mts +13 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +13 -1
- package/hooks/features/filter/gridFilterUtils.js +56 -1
- package/hooks/features/filter/gridFilterUtils.mjs +52 -0
- package/hooks/features/filter/useGridFilter.d.mts +1 -1
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.js +4 -35
- package/hooks/features/filter/useGridFilter.mjs +5 -36
- package/hooks/features/focus/useGridFocus.d.mts +1 -1
- package/hooks/features/focus/useGridFocus.d.ts +1 -1
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.mts +1 -1
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.mts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/overlays/useGridOverlays.d.mts +1 -1
- package/hooks/features/overlays/useGridOverlays.d.ts +1 -1
- package/hooks/features/pagination/gridPaginationUtils.d.mts +1 -1
- package/hooks/features/pagination/gridPaginationUtils.d.ts +1 -1
- package/hooks/features/pagination/useGridPaginationMeta.d.mts +1 -1
- package/hooks/features/pagination/useGridPaginationMeta.d.ts +1 -1
- package/hooks/features/pagination/useGridPaginationModel.d.mts +2 -2
- package/hooks/features/pagination/useGridPaginationModel.d.ts +2 -2
- package/hooks/features/pagination/useGridRowCount.d.mts +1 -1
- package/hooks/features/pagination/useGridRowCount.d.ts +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.mts +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.d.mts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.d.mts +4 -4
- package/hooks/features/rows/gridRowsUtils.d.ts +4 -4
- package/hooks/features/rows/useGridRowSpanning.d.mts +1 -1
- package/hooks/features/rows/useGridRowSpanning.d.ts +1 -1
- package/hooks/features/rows/useGridRows.d.mts +1 -1
- package/hooks/features/rows/useGridRows.d.ts +1 -1
- package/hooks/features/rows/useGridRowsMeta.d.mts +1 -1
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/scroll/useGridScroll.d.mts +1 -1
- package/hooks/features/scroll/useGridScroll.d.ts +1 -1
- package/hooks/features/sorting/useGridSorting.d.mts +1 -1
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.d.mts +2 -2
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.d.ts +2 -2
- package/hooks/utils/useGridEvent.d.mts +1 -1
- package/hooks/utils/useGridEvent.d.ts +1 -1
- package/hooks/utils/useGridVisibleRows.d.mts +2 -2
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- 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/models/api/gridApiCommon.d.mts +1 -1
- package/models/api/gridApiCommon.d.ts +1 -1
- 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 +5 -5
- package/utils/cellBorderUtils.d.mts +2 -2
- package/utils/cellBorderUtils.d.ts +2 -2
- package/utils/css/context.d.mts +3 -3
- package/utils/css/context.d.ts +3 -3
- package/utils/getPublicApiRef.d.mts +1 -1
- package/utils/getPublicApiRef.d.ts +1 -1
- package/utils/keyboardUtils.d.mts +1 -1
- package/utils/keyboardUtils.d.ts +1 -1
- package/utils/rtlFlipSide.d.mts +1 -1
- package/utils/rtlFlipSide.d.ts +1 -1
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
6
|
+
const _excluded = ["item", "hasMultipleFilters", "deleteFilter", "applyFilterChanges", "showMultiFilterOperators", "disableMultiFilterOperator", "applyMultiFilterOperatorChanges", "focusElementRef", "logicOperators", "columnsSort", "filterColumns", "deleteIconProps", "logicOperatorInputProps", "operatorInputProps", "columnInputProps", "valueInputProps", "disableDebounce", "readOnly", "filterModel", "children"],
|
|
7
|
+
_excluded2 = ["InputComponentProps"];
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import clsx from 'clsx';
|
|
11
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
12
|
+
import useId from '@mui/utils/useId';
|
|
13
|
+
import capitalize from '@mui/utils/capitalize';
|
|
14
|
+
import { styled } from '@mui/material/styles';
|
|
15
|
+
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
16
|
+
import { vars } from "../../../constants/cssVariables.mjs";
|
|
17
|
+
import { gridFilterableColumnDefinitionsSelector, gridColumnLookupSelector } from "../../../hooks/features/columns/gridColumnsSelector.mjs";
|
|
18
|
+
import { useGridSelector } from "../../../hooks/utils/useGridSelector.mjs";
|
|
19
|
+
import { GridLogicOperator } from "../../../models/gridFilterItem.mjs";
|
|
20
|
+
import { useGridApiContext } from "../../../hooks/utils/useGridApiContext.mjs";
|
|
21
|
+
import { useGridRootProps } from "../../../hooks/utils/useGridRootProps.mjs";
|
|
22
|
+
import { getDataGridUtilityClass } from "../../../constants/gridClasses.mjs";
|
|
23
|
+
import { getValueFromValueOptions, getValueOptions } from "./filterPanelUtils.mjs";
|
|
24
|
+
import { gridPivotActiveSelector, gridPivotInitialColumnsSelector } from "../../../hooks/features/pivoting/index.mjs";
|
|
25
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
|
+
import { createElement as _createElement } from "react";
|
|
27
|
+
const useUtilityClasses = ownerState => {
|
|
28
|
+
const {
|
|
29
|
+
classes
|
|
30
|
+
} = ownerState;
|
|
31
|
+
const slots = {
|
|
32
|
+
root: ['filterForm'],
|
|
33
|
+
deleteIcon: ['filterFormDeleteIcon'],
|
|
34
|
+
logicOperatorInput: ['filterFormLogicOperatorInput'],
|
|
35
|
+
columnInput: ['filterFormColumnInput'],
|
|
36
|
+
operatorInput: ['filterFormOperatorInput'],
|
|
37
|
+
valueInput: ['filterFormValueInput']
|
|
38
|
+
};
|
|
39
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
40
|
+
};
|
|
41
|
+
const GridFilterFormRoot = styled('div', {
|
|
42
|
+
name: 'MuiDataGrid',
|
|
43
|
+
slot: 'FilterForm'
|
|
44
|
+
})({
|
|
45
|
+
display: 'flex',
|
|
46
|
+
gap: vars.spacing(1.5)
|
|
47
|
+
});
|
|
48
|
+
const FilterFormDeleteIcon = styled('div', {
|
|
49
|
+
name: 'MuiDataGrid',
|
|
50
|
+
slot: 'FilterFormDeleteIcon'
|
|
51
|
+
})({
|
|
52
|
+
flexShrink: 0,
|
|
53
|
+
display: 'flex',
|
|
54
|
+
justifyContent: 'center',
|
|
55
|
+
alignItems: 'center'
|
|
56
|
+
});
|
|
57
|
+
const FilterFormLogicOperatorInput = styled('div', {
|
|
58
|
+
name: 'MuiDataGrid',
|
|
59
|
+
slot: 'FilterFormLogicOperatorInput'
|
|
60
|
+
})({
|
|
61
|
+
minWidth: 75,
|
|
62
|
+
justifyContent: 'end'
|
|
63
|
+
});
|
|
64
|
+
const FilterFormColumnInput = styled('div', {
|
|
65
|
+
name: 'MuiDataGrid',
|
|
66
|
+
slot: 'FilterFormColumnInput'
|
|
67
|
+
})({
|
|
68
|
+
width: 150
|
|
69
|
+
});
|
|
70
|
+
const FilterFormOperatorInput = styled('div', {
|
|
71
|
+
name: 'MuiDataGrid',
|
|
72
|
+
slot: 'FilterFormOperatorInput'
|
|
73
|
+
})({
|
|
74
|
+
width: 150
|
|
75
|
+
});
|
|
76
|
+
const FilterFormValueInput = styled('div', {
|
|
77
|
+
name: 'MuiDataGrid',
|
|
78
|
+
slot: 'FilterFormValueInput'
|
|
79
|
+
})({
|
|
80
|
+
width: 190
|
|
81
|
+
});
|
|
82
|
+
const getLogicOperatorLocaleKey = logicOperator => {
|
|
83
|
+
switch (logicOperator) {
|
|
84
|
+
case GridLogicOperator.And:
|
|
85
|
+
return 'filterPanelOperatorAnd';
|
|
86
|
+
case GridLogicOperator.Or:
|
|
87
|
+
return 'filterPanelOperatorOr';
|
|
88
|
+
default:
|
|
89
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X: Invalid `logicOperator` property in the `GridFilterPanel`.' : _formatErrorMessage(71));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const getColumnLabel = col => col.headerName || col.field;
|
|
93
|
+
const collator = new Intl.Collator();
|
|
94
|
+
const GridFilterFormBase = forwardRef(function GridFilterFormBase(props, ref) {
|
|
95
|
+
const {
|
|
96
|
+
item,
|
|
97
|
+
hasMultipleFilters,
|
|
98
|
+
deleteFilter,
|
|
99
|
+
applyFilterChanges,
|
|
100
|
+
showMultiFilterOperators,
|
|
101
|
+
disableMultiFilterOperator,
|
|
102
|
+
applyMultiFilterOperatorChanges,
|
|
103
|
+
focusElementRef,
|
|
104
|
+
logicOperators = [GridLogicOperator.And, GridLogicOperator.Or],
|
|
105
|
+
columnsSort,
|
|
106
|
+
filterColumns,
|
|
107
|
+
deleteIconProps = {},
|
|
108
|
+
logicOperatorInputProps = {},
|
|
109
|
+
operatorInputProps = {},
|
|
110
|
+
columnInputProps = {},
|
|
111
|
+
valueInputProps = {},
|
|
112
|
+
disableDebounce = false,
|
|
113
|
+
readOnly,
|
|
114
|
+
filterModel
|
|
115
|
+
} = props,
|
|
116
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
117
|
+
const apiRef = useGridApiContext();
|
|
118
|
+
const columnLookup = useGridSelector(apiRef, gridColumnLookupSelector);
|
|
119
|
+
const filterableColumns = useGridSelector(apiRef, gridFilterableColumnDefinitionsSelector);
|
|
120
|
+
const columnSelectId = useId();
|
|
121
|
+
const columnSelectLabelId = useId();
|
|
122
|
+
const operatorSelectId = useId();
|
|
123
|
+
const operatorSelectLabelId = useId();
|
|
124
|
+
const rootProps = useGridRootProps();
|
|
125
|
+
const classes = useUtilityClasses(rootProps);
|
|
126
|
+
const valueRef = React.useRef(null);
|
|
127
|
+
const filterSelectorRef = React.useRef(null);
|
|
128
|
+
const multiFilterOperator = filterModel.logicOperator ?? GridLogicOperator.And;
|
|
129
|
+
const hasLogicOperatorColumn = hasMultipleFilters && logicOperators.length > 0;
|
|
130
|
+
const baseSelectProps = rootProps.slotProps?.baseSelect || {};
|
|
131
|
+
const isBaseSelectNative = baseSelectProps.native ?? false;
|
|
132
|
+
const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
|
|
133
|
+
const {
|
|
134
|
+
InputComponentProps
|
|
135
|
+
} = valueInputProps,
|
|
136
|
+
valueInputPropsOther = _objectWithoutPropertiesLoose(valueInputProps, _excluded2);
|
|
137
|
+
const pivotActive = useGridSelector(apiRef, gridPivotActiveSelector);
|
|
138
|
+
const initialColumns = useGridSelector(apiRef, gridPivotInitialColumnsSelector);
|
|
139
|
+
const {
|
|
140
|
+
filteredColumns,
|
|
141
|
+
selectedField
|
|
142
|
+
} = React.useMemo(() => {
|
|
143
|
+
let itemField = item.field;
|
|
144
|
+
|
|
145
|
+
// Yields a valid value if the current filter belongs to a column that is not filterable
|
|
146
|
+
const selectedNonFilterableColumn = columnLookup[item.field].filterable === false ? columnLookup[item.field] : null;
|
|
147
|
+
if (selectedNonFilterableColumn) {
|
|
148
|
+
return {
|
|
149
|
+
filteredColumns: [selectedNonFilterableColumn],
|
|
150
|
+
selectedField: itemField
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (pivotActive) {
|
|
154
|
+
return {
|
|
155
|
+
filteredColumns: filterableColumns.filter(column => initialColumns.get(column.field) !== undefined),
|
|
156
|
+
selectedField: itemField
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (filterColumns === undefined || typeof filterColumns !== 'function') {
|
|
160
|
+
return {
|
|
161
|
+
filteredColumns: filterableColumns,
|
|
162
|
+
selectedField: itemField
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const filteredFields = filterColumns({
|
|
166
|
+
field: item.field,
|
|
167
|
+
columns: filterableColumns,
|
|
168
|
+
currentFilters: filterModel?.items || []
|
|
169
|
+
});
|
|
170
|
+
return {
|
|
171
|
+
filteredColumns: filterableColumns.filter(column => {
|
|
172
|
+
const isFieldIncluded = filteredFields.includes(column.field);
|
|
173
|
+
if (column.field === item.field && !isFieldIncluded) {
|
|
174
|
+
itemField = undefined;
|
|
175
|
+
}
|
|
176
|
+
return isFieldIncluded;
|
|
177
|
+
}),
|
|
178
|
+
selectedField: itemField
|
|
179
|
+
};
|
|
180
|
+
}, [item.field, columnLookup, pivotActive, filterColumns, filterableColumns, filterModel?.items, initialColumns]);
|
|
181
|
+
const sortedFilteredColumns = React.useMemo(() => {
|
|
182
|
+
switch (columnsSort) {
|
|
183
|
+
case 'asc':
|
|
184
|
+
return filteredColumns.sort((a, b) => collator.compare(getColumnLabel(a), getColumnLabel(b)));
|
|
185
|
+
case 'desc':
|
|
186
|
+
return filteredColumns.sort((a, b) => -collator.compare(getColumnLabel(a), getColumnLabel(b)));
|
|
187
|
+
default:
|
|
188
|
+
return filteredColumns;
|
|
189
|
+
}
|
|
190
|
+
}, [filteredColumns, columnsSort]);
|
|
191
|
+
const currentColumn = item.field ? apiRef.current.getColumn(item.field) : null;
|
|
192
|
+
const currentOperator = React.useMemo(() => {
|
|
193
|
+
if (!item.operator || !currentColumn) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
return currentColumn.filterOperators?.find(operator => operator.value === item.operator);
|
|
197
|
+
}, [item, currentColumn]);
|
|
198
|
+
const changeColumn = React.useCallback(event => {
|
|
199
|
+
const field = event.target.value;
|
|
200
|
+
const column = apiRef.current.getColumn(field);
|
|
201
|
+
if (column.field === currentColumn.field) {
|
|
202
|
+
// column did not change
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// try to keep the same operator when column change
|
|
207
|
+
const newOperator = column.filterOperators.find(operator => operator.value === item.operator) || column.filterOperators[0];
|
|
208
|
+
|
|
209
|
+
// Erase filter value if the input component or filtered column type is modified
|
|
210
|
+
const eraseFilterValue = !newOperator.InputComponent || newOperator.InputComponent !== currentOperator?.InputComponent || column.type !== currentColumn.type;
|
|
211
|
+
let filterValue = eraseFilterValue ? undefined : item.value;
|
|
212
|
+
|
|
213
|
+
// Check filter value against the new valueOptions
|
|
214
|
+
if (column.type === 'singleSelect' && filterValue !== undefined) {
|
|
215
|
+
const colDef = column;
|
|
216
|
+
const valueOptions = getValueOptions(colDef);
|
|
217
|
+
if (Array.isArray(filterValue)) {
|
|
218
|
+
filterValue = filterValue.filter(val => {
|
|
219
|
+
return (
|
|
220
|
+
// Only keep values that are in the new value options
|
|
221
|
+
getValueFromValueOptions(val, valueOptions, colDef?.getOptionValue) !== undefined
|
|
222
|
+
);
|
|
223
|
+
});
|
|
224
|
+
} else if (getValueFromValueOptions(item.value, valueOptions, colDef?.getOptionValue) === undefined) {
|
|
225
|
+
// Reset the filter value if it is not in the new value options
|
|
226
|
+
filterValue = undefined;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
applyFilterChanges(_extends({}, item, {
|
|
230
|
+
field,
|
|
231
|
+
operator: newOperator.value,
|
|
232
|
+
value: filterValue
|
|
233
|
+
}));
|
|
234
|
+
}, [apiRef, applyFilterChanges, item, currentColumn, currentOperator]);
|
|
235
|
+
const changeOperator = React.useCallback(event => {
|
|
236
|
+
const operator = event.target.value;
|
|
237
|
+
const newOperator = currentColumn?.filterOperators.find(op => op.value === operator);
|
|
238
|
+
const eraseItemValue = !newOperator?.InputComponent || newOperator?.InputComponent !== currentOperator?.InputComponent;
|
|
239
|
+
applyFilterChanges(_extends({}, item, {
|
|
240
|
+
operator,
|
|
241
|
+
value: eraseItemValue ? undefined : item.value
|
|
242
|
+
}));
|
|
243
|
+
}, [applyFilterChanges, item, currentColumn, currentOperator]);
|
|
244
|
+
const changeLogicOperator = React.useCallback(event => {
|
|
245
|
+
const logicOperator = event.target.value === GridLogicOperator.And.toString() ? GridLogicOperator.And : GridLogicOperator.Or;
|
|
246
|
+
applyMultiFilterOperatorChanges(logicOperator);
|
|
247
|
+
}, [applyMultiFilterOperatorChanges]);
|
|
248
|
+
const handleDeleteFilter = () => {
|
|
249
|
+
deleteFilter(item);
|
|
250
|
+
};
|
|
251
|
+
React.useImperativeHandle(focusElementRef, () => ({
|
|
252
|
+
focus: () => {
|
|
253
|
+
if (currentOperator?.InputComponent) {
|
|
254
|
+
valueRef?.current?.focus();
|
|
255
|
+
} else {
|
|
256
|
+
filterSelectorRef.current.focus();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}), [currentOperator]);
|
|
260
|
+
return /*#__PURE__*/_jsxs(GridFilterFormRoot, _extends({
|
|
261
|
+
className: classes.root,
|
|
262
|
+
"data-id": item.id,
|
|
263
|
+
ownerState: rootProps
|
|
264
|
+
}, other, {
|
|
265
|
+
ref: ref,
|
|
266
|
+
children: [/*#__PURE__*/_jsx(FilterFormDeleteIcon, _extends({}, deleteIconProps, {
|
|
267
|
+
className: clsx(classes.deleteIcon, deleteIconProps.className),
|
|
268
|
+
ownerState: rootProps,
|
|
269
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
|
|
270
|
+
"aria-label": apiRef.current.getLocaleText('filterPanelDeleteIconLabel'),
|
|
271
|
+
title: apiRef.current.getLocaleText('filterPanelDeleteIconLabel'),
|
|
272
|
+
onClick: handleDeleteFilter,
|
|
273
|
+
size: "small",
|
|
274
|
+
disabled: readOnly
|
|
275
|
+
}, rootProps.slotProps?.baseIconButton, {
|
|
276
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.filterPanelDeleteIcon, {
|
|
277
|
+
fontSize: "small"
|
|
278
|
+
})
|
|
279
|
+
}))
|
|
280
|
+
})), /*#__PURE__*/_jsx(FilterFormLogicOperatorInput, _extends({
|
|
281
|
+
as: rootProps.slots.baseSelect,
|
|
282
|
+
sx: [hasLogicOperatorColumn ? {
|
|
283
|
+
display: 'flex'
|
|
284
|
+
} : {
|
|
285
|
+
display: 'none'
|
|
286
|
+
}, showMultiFilterOperators ? {
|
|
287
|
+
visibility: 'visible'
|
|
288
|
+
} : {
|
|
289
|
+
visibility: 'hidden'
|
|
290
|
+
}, logicOperatorInputProps.sx],
|
|
291
|
+
className: clsx(classes.logicOperatorInput, logicOperatorInputProps.className),
|
|
292
|
+
ownerState: rootProps
|
|
293
|
+
}, logicOperatorInputProps, {
|
|
294
|
+
size: "small",
|
|
295
|
+
slotProps: {
|
|
296
|
+
htmlInput: {
|
|
297
|
+
'aria-label': apiRef.current.getLocaleText('filterPanelLogicOperator')
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
value: multiFilterOperator ?? '',
|
|
301
|
+
onChange: changeLogicOperator,
|
|
302
|
+
disabled: !!disableMultiFilterOperator || logicOperators.length === 1,
|
|
303
|
+
native: isBaseSelectNative
|
|
304
|
+
}, rootProps.slotProps?.baseSelect, {
|
|
305
|
+
children: logicOperators.map(logicOperator => /*#__PURE__*/_createElement(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
|
|
306
|
+
native: isBaseSelectNative,
|
|
307
|
+
key: logicOperator.toString(),
|
|
308
|
+
value: logicOperator.toString()
|
|
309
|
+
}), apiRef.current.getLocaleText(getLogicOperatorLocaleKey(logicOperator))))
|
|
310
|
+
})), /*#__PURE__*/_jsx(FilterFormColumnInput, _extends({
|
|
311
|
+
as: rootProps.slots.baseSelect
|
|
312
|
+
}, columnInputProps, {
|
|
313
|
+
className: clsx(classes.columnInput, columnInputProps.className),
|
|
314
|
+
ownerState: rootProps,
|
|
315
|
+
size: "small",
|
|
316
|
+
labelId: columnSelectLabelId,
|
|
317
|
+
id: columnSelectId,
|
|
318
|
+
label: apiRef.current.getLocaleText('filterPanelColumn'),
|
|
319
|
+
value: selectedField ?? '',
|
|
320
|
+
onChange: changeColumn,
|
|
321
|
+
native: isBaseSelectNative,
|
|
322
|
+
disabled: readOnly
|
|
323
|
+
}, rootProps.slotProps?.baseSelect, {
|
|
324
|
+
children: sortedFilteredColumns.map(col => /*#__PURE__*/_createElement(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
|
|
325
|
+
native: isBaseSelectNative,
|
|
326
|
+
key: col.field,
|
|
327
|
+
value: col.field
|
|
328
|
+
}), getColumnLabel(col)))
|
|
329
|
+
})), /*#__PURE__*/_jsx(FilterFormOperatorInput, _extends({
|
|
330
|
+
as: rootProps.slots.baseSelect,
|
|
331
|
+
size: "small"
|
|
332
|
+
}, operatorInputProps, {
|
|
333
|
+
className: clsx(classes.operatorInput, operatorInputProps.className),
|
|
334
|
+
ownerState: rootProps,
|
|
335
|
+
labelId: operatorSelectLabelId,
|
|
336
|
+
label: apiRef.current.getLocaleText('filterPanelOperator'),
|
|
337
|
+
id: operatorSelectId,
|
|
338
|
+
value: item.operator,
|
|
339
|
+
onChange: changeOperator,
|
|
340
|
+
native: isBaseSelectNative,
|
|
341
|
+
inputRef: filterSelectorRef,
|
|
342
|
+
disabled: readOnly
|
|
343
|
+
}, rootProps.slotProps?.baseSelect, {
|
|
344
|
+
children: currentColumn?.filterOperators?.map(operator => /*#__PURE__*/_createElement(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
|
|
345
|
+
native: isBaseSelectNative,
|
|
346
|
+
key: operator.value,
|
|
347
|
+
value: operator.value
|
|
348
|
+
}), operator.label || apiRef.current.getLocaleText(`filterOperator${capitalize(operator.value)}`)))
|
|
349
|
+
})), /*#__PURE__*/_jsx(FilterFormValueInput, _extends({}, valueInputPropsOther, {
|
|
350
|
+
className: clsx(classes.valueInput, valueInputPropsOther.className),
|
|
351
|
+
ownerState: rootProps,
|
|
352
|
+
children: currentOperator?.InputComponent ? /*#__PURE__*/_jsx(currentOperator.InputComponent, _extends({
|
|
353
|
+
apiRef: apiRef,
|
|
354
|
+
item: item,
|
|
355
|
+
applyValue: applyFilterChanges,
|
|
356
|
+
focusElementRef: valueRef,
|
|
357
|
+
disabled: readOnly,
|
|
358
|
+
disableDebounce: disableDebounce,
|
|
359
|
+
slotProps: {
|
|
360
|
+
root: {
|
|
361
|
+
size: 'small'
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}, currentOperator.InputComponentProps, InputComponentProps), item.field) : null
|
|
365
|
+
}))]
|
|
366
|
+
}));
|
|
367
|
+
});
|
|
368
|
+
if (process.env.NODE_ENV !== "production") GridFilterFormBase.displayName = "GridFilterFormBase";
|
|
369
|
+
process.env.NODE_ENV !== "production" ? GridFilterFormBase.propTypes /* remove-proptypes */ = {
|
|
370
|
+
// ----------------------------- Warning --------------------------------
|
|
371
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
372
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
373
|
+
// ----------------------------------------------------------------------
|
|
374
|
+
/**
|
|
375
|
+
* Callback called when the operator, column field or value is changed.
|
|
376
|
+
* @param {GridFilterItem} item The updated [[GridFilterItem]].
|
|
377
|
+
*/
|
|
378
|
+
applyFilterChanges: PropTypes.func.isRequired,
|
|
379
|
+
/**
|
|
380
|
+
* Callback called when the logic operator is changed.
|
|
381
|
+
* @param {GridLogicOperator} operator The new logic operator.
|
|
382
|
+
*/
|
|
383
|
+
applyMultiFilterOperatorChanges: PropTypes.func.isRequired,
|
|
384
|
+
/**
|
|
385
|
+
* @ignore - do not document.
|
|
386
|
+
*/
|
|
387
|
+
children: PropTypes.node,
|
|
388
|
+
/**
|
|
389
|
+
* Props passed to the column input component.
|
|
390
|
+
* @default {}
|
|
391
|
+
*/
|
|
392
|
+
columnInputProps: PropTypes.any,
|
|
393
|
+
/**
|
|
394
|
+
* Changes how the options in the columns selector should be ordered.
|
|
395
|
+
* If not specified, the order is derived from the `columns` prop.
|
|
396
|
+
*/
|
|
397
|
+
columnsSort: PropTypes.oneOf(['asc', 'desc']),
|
|
398
|
+
/**
|
|
399
|
+
* Callback called when the delete button is clicked.
|
|
400
|
+
* @param {GridFilterItem} item The deleted [[GridFilterItem]].
|
|
401
|
+
*/
|
|
402
|
+
deleteFilter: PropTypes.func.isRequired,
|
|
403
|
+
/**
|
|
404
|
+
* Props passed to the delete icon.
|
|
405
|
+
* @default {}
|
|
406
|
+
*/
|
|
407
|
+
deleteIconProps: PropTypes.any,
|
|
408
|
+
/**
|
|
409
|
+
* If `true`, disables the logic operator field but still renders it.
|
|
410
|
+
*/
|
|
411
|
+
disableMultiFilterOperator: PropTypes.bool,
|
|
412
|
+
/**
|
|
413
|
+
* Allows to filter the columns displayed in the filter form.
|
|
414
|
+
* @param {FilterColumnsArgs} args The columns of the grid and name of field.
|
|
415
|
+
* @returns {GridColDef['field'][]} The filtered fields array.
|
|
416
|
+
*/
|
|
417
|
+
filterColumns: PropTypes.func,
|
|
418
|
+
/**
|
|
419
|
+
* The filter model that populates the form.
|
|
420
|
+
* Its `logicOperator` drives the logic operator field and its `items` are used to compute the
|
|
421
|
+
* columns available in the column selector (e.g. via the `filterColumns` callback).
|
|
422
|
+
*/
|
|
423
|
+
filterModel: PropTypes.shape({
|
|
424
|
+
items: PropTypes.arrayOf(PropTypes.shape({
|
|
425
|
+
field: PropTypes.string.isRequired,
|
|
426
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
427
|
+
operator: PropTypes.string.isRequired,
|
|
428
|
+
value: PropTypes.any
|
|
429
|
+
})).isRequired,
|
|
430
|
+
logicOperator: PropTypes.oneOf(['and', 'or']),
|
|
431
|
+
quickFilterExcludeHiddenColumns: PropTypes.bool,
|
|
432
|
+
quickFilterLogicOperator: PropTypes.oneOf(['and', 'or']),
|
|
433
|
+
quickFilterValues: PropTypes.array
|
|
434
|
+
}).isRequired,
|
|
435
|
+
/**
|
|
436
|
+
* A ref allowing to set imperative focus.
|
|
437
|
+
* It can be passed to the el
|
|
438
|
+
*/
|
|
439
|
+
focusElementRef: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.func, PropTypes.object]),
|
|
440
|
+
/**
|
|
441
|
+
* If `true`, the logic operator field is rendered.
|
|
442
|
+
* The field will be invisible if `showMultiFilterOperators` is also `true`.
|
|
443
|
+
*/
|
|
444
|
+
hasMultipleFilters: PropTypes.bool.isRequired,
|
|
445
|
+
/**
|
|
446
|
+
* The [[GridFilterItem]] representing this form.
|
|
447
|
+
*/
|
|
448
|
+
item: PropTypes.shape({
|
|
449
|
+
field: PropTypes.string.isRequired,
|
|
450
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
451
|
+
operator: PropTypes.string.isRequired,
|
|
452
|
+
value: PropTypes.any
|
|
453
|
+
}).isRequired,
|
|
454
|
+
/**
|
|
455
|
+
* Props passed to the logic operator input component.
|
|
456
|
+
* @default {}
|
|
457
|
+
*/
|
|
458
|
+
logicOperatorInputProps: PropTypes.any,
|
|
459
|
+
/**
|
|
460
|
+
* Sets the available logic operators.
|
|
461
|
+
* @default [GridLogicOperator.And, GridLogicOperator.Or]
|
|
462
|
+
*/
|
|
463
|
+
logicOperators: PropTypes.arrayOf(PropTypes.oneOf(['and', 'or']).isRequired),
|
|
464
|
+
/**
|
|
465
|
+
* Props passed to the operator input component.
|
|
466
|
+
* @default {}
|
|
467
|
+
*/
|
|
468
|
+
operatorInputProps: PropTypes.any,
|
|
469
|
+
/**
|
|
470
|
+
* `true` if the filter is disabled/read only.
|
|
471
|
+
* i.e. `colDef.fiterable = false` but passed in `filterModel`
|
|
472
|
+
* @default false
|
|
473
|
+
*/
|
|
474
|
+
readOnly: PropTypes.bool,
|
|
475
|
+
/**
|
|
476
|
+
* If `true`, the logic operator field is visible.
|
|
477
|
+
*/
|
|
478
|
+
showMultiFilterOperators: PropTypes.bool,
|
|
479
|
+
/**
|
|
480
|
+
* Props passed to the value input component.
|
|
481
|
+
* @default {}
|
|
482
|
+
*/
|
|
483
|
+
valueInputProps: PropTypes.any
|
|
484
|
+
} : void 0;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* The lower-level filter form rendered by `GridFilterForm` and `GridFilterPanelBase`.
|
|
488
|
+
* It is controlled through the `filterModel` prop instead of reading the grid filter state.
|
|
489
|
+
* This is an internal component that is not part of the public API.
|
|
490
|
+
*/
|
|
491
|
+
export { GridFilterFormBase };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import type { TextFieldProps } from "../../../models/gridBaseSlots.mjs";
|
|
2
3
|
import type { GridFilterInputValueProps } from "../../../models/gridFilterInputComponent.mjs";
|
|
3
4
|
export type GridFilterInputBooleanProps = GridFilterInputValueProps<TextFieldProps>;
|
|
4
|
-
declare function GridFilterInputBoolean(props: GridFilterInputBooleanProps):
|
|
5
|
+
declare function GridFilterInputBoolean(props: GridFilterInputBooleanProps): React.JSX.Element;
|
|
5
6
|
declare namespace GridFilterInputBoolean {
|
|
6
7
|
var propTypes: any;
|
|
7
8
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import type { TextFieldProps } from "../../../models/gridBaseSlots.js";
|
|
2
3
|
import type { GridFilterInputValueProps } from "../../../models/gridFilterInputComponent.js";
|
|
3
4
|
export type GridFilterInputBooleanProps = GridFilterInputValueProps<TextFieldProps>;
|
|
4
|
-
declare function GridFilterInputBoolean(props: GridFilterInputBooleanProps):
|
|
5
|
+
declare function GridFilterInputBoolean(props: GridFilterInputBooleanProps): React.JSX.Element;
|
|
5
6
|
declare namespace GridFilterInputBoolean {
|
|
6
7
|
var propTypes: any;
|
|
7
8
|
}
|
|
@@ -17,7 +17,7 @@ var _refType = _interopRequireDefault(require("@mui/utils/refType"));
|
|
|
17
17
|
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
18
18
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
const _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "headerFilterMenu", "clearButton", "tabIndex", "slotProps"];
|
|
20
|
+
const _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "headerFilterMenu", "clearButton", "tabIndex", "slotProps", "disableDebounce"];
|
|
21
21
|
function GridFilterInputBoolean(props) {
|
|
22
22
|
const {
|
|
23
23
|
item,
|
|
@@ -102,6 +102,11 @@ process.env.NODE_ENV !== "production" ? GridFilterInputBoolean.propTypes /* remo
|
|
|
102
102
|
className: _propTypes.default.string,
|
|
103
103
|
clearButton: _propTypes.default.node,
|
|
104
104
|
disabled: _propTypes.default.bool,
|
|
105
|
+
/**
|
|
106
|
+
* If `true`, filter value changes are applied immediately without debouncing.
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
disableDebounce: _propTypes.default.bool,
|
|
105
110
|
focusElementRef: _refType.default,
|
|
106
111
|
headerFilterMenu: _propTypes.default.node,
|
|
107
112
|
inputRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
5
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
6
|
-
const _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "headerFilterMenu", "clearButton", "tabIndex", "slotProps"];
|
|
6
|
+
const _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "headerFilterMenu", "clearButton", "tabIndex", "slotProps", "disableDebounce"];
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import refType from '@mui/utils/refType';
|
|
@@ -94,6 +94,11 @@ process.env.NODE_ENV !== "production" ? GridFilterInputBoolean.propTypes /* remo
|
|
|
94
94
|
className: PropTypes.string,
|
|
95
95
|
clearButton: PropTypes.node,
|
|
96
96
|
disabled: PropTypes.bool,
|
|
97
|
+
/**
|
|
98
|
+
* If `true`, filter value changes are applied immediately without debouncing.
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
disableDebounce: PropTypes.bool,
|
|
97
102
|
focusElementRef: refType,
|
|
98
103
|
headerFilterMenu: PropTypes.node,
|
|
99
104
|
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import type { GridFilterInputValueProps } from "../../../models/gridFilterInputComponent.mjs";
|
|
2
3
|
import type { TextFieldProps } from "../../../models/gridBaseSlots.mjs";
|
|
3
4
|
export type GridFilterInputDateProps = GridFilterInputValueProps<TextFieldProps> & {
|
|
4
5
|
type?: 'date' | 'datetime-local';
|
|
5
6
|
};
|
|
6
|
-
declare function GridFilterInputDate(props: GridFilterInputDateProps):
|
|
7
|
+
declare function GridFilterInputDate(props: GridFilterInputDateProps): React.JSX.Element;
|
|
7
8
|
declare namespace GridFilterInputDate {
|
|
8
9
|
var propTypes: any;
|
|
9
10
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import type { GridFilterInputValueProps } from "../../../models/gridFilterInputComponent.js";
|
|
2
3
|
import type { TextFieldProps } from "../../../models/gridBaseSlots.js";
|
|
3
4
|
export type GridFilterInputDateProps = GridFilterInputValueProps<TextFieldProps> & {
|
|
4
5
|
type?: 'date' | 'datetime-local';
|
|
5
6
|
};
|
|
6
|
-
declare function GridFilterInputDate(props: GridFilterInputDateProps):
|
|
7
|
+
declare function GridFilterInputDate(props: GridFilterInputDateProps): React.JSX.Element;
|
|
7
8
|
declare namespace GridFilterInputDate {
|
|
8
9
|
var propTypes: any;
|
|
9
10
|
}
|
|
@@ -16,7 +16,7 @@ var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
|
16
16
|
var _useTimeout = require("../../../hooks/utils/useTimeout");
|
|
17
17
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "slotProps", "isFilterActive", "headerFilterMenu", "clearButton", "tabIndex", "disabled"];
|
|
19
|
+
const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "slotProps", "isFilterActive", "headerFilterMenu", "clearButton", "tabIndex", "disabled", "disableDebounce"];
|
|
20
20
|
function convertFilterItemValueToInputValue(itemValue, inputType) {
|
|
21
21
|
if (itemValue == null) {
|
|
22
22
|
return '';
|
|
@@ -48,7 +48,8 @@ function GridFilterInputDate(props) {
|
|
|
48
48
|
headerFilterMenu,
|
|
49
49
|
clearButton,
|
|
50
50
|
tabIndex,
|
|
51
|
-
disabled
|
|
51
|
+
disabled,
|
|
52
|
+
disableDebounce = false
|
|
52
53
|
} = props,
|
|
53
54
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
54
55
|
const rootSlotProps = slotProps?.root.slotProps;
|
|
@@ -57,19 +58,25 @@ function GridFilterInputDate(props) {
|
|
|
57
58
|
const [applying, setIsApplying] = React.useState(false);
|
|
58
59
|
const id = (0, _useId.default)();
|
|
59
60
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
61
|
+
const debounceMs = disableDebounce ? 0 : rootProps.filterDebounceMs;
|
|
60
62
|
const onFilterChange = React.useCallback(event => {
|
|
61
63
|
filterTimeout.clear();
|
|
62
64
|
const value = event.target.value;
|
|
63
65
|
setFilterValueState(value);
|
|
66
|
+
const date = new Date(value);
|
|
67
|
+
const newItem = (0, _extends2.default)({}, item, {
|
|
68
|
+
value: Number.isNaN(date.getTime()) ? undefined : date
|
|
69
|
+
});
|
|
70
|
+
if (debounceMs === 0) {
|
|
71
|
+
applyValue(newItem);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
64
74
|
setIsApplying(true);
|
|
65
|
-
filterTimeout.start(
|
|
66
|
-
|
|
67
|
-
applyValue((0, _extends2.default)({}, item, {
|
|
68
|
-
value: Number.isNaN(date.getTime()) ? undefined : date
|
|
69
|
-
}));
|
|
75
|
+
filterTimeout.start(debounceMs, () => {
|
|
76
|
+
applyValue(newItem);
|
|
70
77
|
setIsApplying(false);
|
|
71
78
|
});
|
|
72
|
-
}, [applyValue, item,
|
|
79
|
+
}, [applyValue, item, debounceMs, filterTimeout]);
|
|
73
80
|
React.useEffect(() => {
|
|
74
81
|
const value = convertFilterItemValueToInputValue(item.value, type);
|
|
75
82
|
setFilterValueState(value);
|
|
@@ -87,7 +94,7 @@ function GridFilterInputDate(props) {
|
|
|
87
94
|
inputRef: focusElementRef,
|
|
88
95
|
slotProps: (0, _extends2.default)({}, rootSlotProps, {
|
|
89
96
|
input: (0, _extends2.default)({
|
|
90
|
-
endAdornment: applying ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.loadIcon, {
|
|
97
|
+
endAdornment: applying && debounceMs > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.loadIcon, {
|
|
91
98
|
fontSize: "small",
|
|
92
99
|
color: "action"
|
|
93
100
|
}) : null
|
|
@@ -112,6 +119,11 @@ process.env.NODE_ENV !== "production" ? GridFilterInputDate.propTypes /* remove-
|
|
|
112
119
|
className: _propTypes.default.string,
|
|
113
120
|
clearButton: _propTypes.default.node,
|
|
114
121
|
disabled: _propTypes.default.bool,
|
|
122
|
+
/**
|
|
123
|
+
* If `true`, filter value changes are applied immediately without debouncing.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
disableDebounce: _propTypes.default.bool,
|
|
115
127
|
focusElementRef: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
|
116
128
|
headerFilterMenu: _propTypes.default.node,
|
|
117
129
|
inputRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|