@mui/x-data-grid 8.0.0-alpha.13 → 8.0.0-alpha.14
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 +131 -0
- package/colDef/gridActionsColDef.js +1 -1
- package/colDef/gridBooleanColDef.js +1 -1
- package/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/components/columnsManagement/GridColumnsManagement.js +1 -0
- package/components/columnsPanel/ColumnsPanelTrigger.d.ts +33 -0
- package/components/columnsPanel/ColumnsPanelTrigger.js +209 -0
- package/components/columnsPanel/index.d.ts +1 -0
- package/components/columnsPanel/index.js +16 -0
- package/components/export/ExportCsv.d.ts +30 -0
- package/components/export/ExportCsv.js +196 -0
- package/components/export/ExportPrint.d.ts +30 -0
- package/components/export/ExportPrint.js +196 -0
- package/components/export/index.d.ts +2 -0
- package/components/export/index.js +27 -0
- package/components/filterPanel/FilterPanelTrigger.d.ts +37 -0
- package/components/filterPanel/FilterPanelTrigger.js +212 -0
- package/components/filterPanel/index.d.ts +1 -0
- package/components/filterPanel/index.js +16 -0
- package/components/index.d.ts +6 -1
- package/components/index.js +60 -0
- package/components/quickFilter/QuickFilter.d.ts +41 -0
- package/components/quickFilter/QuickFilter.js +110 -0
- package/components/quickFilter/QuickFilterClear.d.ts +28 -0
- package/components/quickFilter/QuickFilterClear.js +161 -0
- package/components/quickFilter/QuickFilterContext.d.ts +13 -0
- package/components/quickFilter/QuickFilterContext.js +17 -0
- package/components/quickFilter/QuickFilterControl.d.ts +28 -0
- package/components/quickFilter/QuickFilterControl.js +104 -0
- package/components/quickFilter/index.d.ts +3 -0
- package/components/quickFilter/index.js +38 -0
- package/components/toolbar/GridToolbar.d.ts +1 -1
- package/components/toolbar/GridToolbar.js +2 -2
- package/components/toolbar/GridToolbarQuickFilter.js +54 -87
- package/components/toolbarV8/GridToolbar.d.ts +11 -0
- package/components/toolbarV8/GridToolbar.js +142 -0
- package/components/toolbarV8/Toolbar.d.ts +32 -0
- package/components/toolbarV8/Toolbar.js +132 -0
- package/components/toolbarV8/ToolbarButton.d.ts +23 -0
- package/components/toolbarV8/ToolbarButton.js +179 -0
- package/components/toolbarV8/ToolbarContext.d.ts +9 -0
- package/components/toolbarV8/ToolbarContext.js +17 -0
- package/components/toolbarV8/index.d.ts +2 -0
- package/components/toolbarV8/index.js +27 -0
- package/components/virtualization/GridVirtualScrollbar.js +7 -1
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +4 -0
- package/esm/colDef/gridActionsColDef.js +1 -1
- package/esm/colDef/gridBooleanColDef.js +1 -1
- package/esm/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/esm/components/columnsManagement/GridColumnsManagement.js +1 -0
- package/esm/components/columnsPanel/ColumnsPanelTrigger.d.ts +33 -0
- package/esm/components/columnsPanel/ColumnsPanelTrigger.js +202 -0
- package/esm/components/columnsPanel/index.d.ts +1 -0
- package/esm/components/columnsPanel/index.js +1 -0
- package/esm/components/export/ExportCsv.d.ts +30 -0
- package/esm/components/export/ExportCsv.js +189 -0
- package/esm/components/export/ExportPrint.d.ts +30 -0
- package/esm/components/export/ExportPrint.js +189 -0
- package/esm/components/export/index.d.ts +2 -0
- package/esm/components/export/index.js +2 -0
- package/esm/components/filterPanel/FilterPanelTrigger.d.ts +37 -0
- package/esm/components/filterPanel/FilterPanelTrigger.js +205 -0
- package/esm/components/filterPanel/index.d.ts +1 -0
- package/esm/components/filterPanel/index.js +1 -0
- package/esm/components/index.d.ts +6 -1
- package/esm/components/index.js +6 -1
- package/esm/components/quickFilter/QuickFilter.d.ts +41 -0
- package/esm/components/quickFilter/QuickFilter.js +103 -0
- package/esm/components/quickFilter/QuickFilterClear.d.ts +28 -0
- package/esm/components/quickFilter/QuickFilterClear.js +154 -0
- package/esm/components/quickFilter/QuickFilterContext.d.ts +13 -0
- package/esm/components/quickFilter/QuickFilterContext.js +9 -0
- package/esm/components/quickFilter/QuickFilterControl.d.ts +28 -0
- package/esm/components/quickFilter/QuickFilterControl.js +97 -0
- package/esm/components/quickFilter/index.d.ts +3 -0
- package/esm/components/quickFilter/index.js +3 -0
- package/esm/components/toolbar/GridToolbar.d.ts +1 -1
- package/esm/components/toolbar/GridToolbar.js +2 -2
- package/esm/components/toolbar/GridToolbarQuickFilter.js +56 -87
- package/esm/components/toolbarV8/GridToolbar.d.ts +11 -0
- package/esm/components/toolbarV8/GridToolbar.js +135 -0
- package/esm/components/toolbarV8/Toolbar.d.ts +32 -0
- package/esm/components/toolbarV8/Toolbar.js +125 -0
- package/esm/components/toolbarV8/ToolbarButton.d.ts +23 -0
- package/esm/components/toolbarV8/ToolbarButton.js +172 -0
- package/esm/components/toolbarV8/ToolbarContext.d.ts +9 -0
- package/esm/components/toolbarV8/ToolbarContext.js +9 -0
- package/esm/components/toolbarV8/index.d.ts +2 -0
- package/esm/components/toolbarV8/index.js +2 -0
- package/esm/components/virtualization/GridVirtualScrollbar.js +7 -1
- package/esm/constants/defaultGridSlotsComponents.js +2 -1
- package/esm/constants/gridClasses.d.ts +4 -0
- package/esm/hooks/features/rows/useGridRowsMeta.js +8 -0
- package/esm/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -2
- package/esm/hooks/features/virtualization/useGridVirtualScroller.js +0 -2
- package/esm/hooks/utils/index.d.ts +2 -1
- package/esm/hooks/utils/useGridComponentRenderer.d.ts +12 -0
- package/esm/hooks/utils/useGridComponentRenderer.js +36 -0
- package/esm/index.js +1 -1
- package/esm/internals/demo/TailwindDemoContainer.d.ts +11 -0
- package/esm/internals/demo/TailwindDemoContainer.js +55 -0
- package/esm/internals/demo/index.d.ts +1 -0
- package/esm/internals/demo/index.js +1 -0
- package/esm/internals/index.d.ts +4 -0
- package/esm/internals/index.js +3 -0
- package/esm/material/icons/index.d.ts +3 -3
- package/esm/material/icons/index.js +6 -6
- package/esm/material/index.js +3 -3
- package/esm/models/gridBaseSlots.d.ts +5 -1
- package/esm/models/gridIconSlotsComponent.d.ts +1 -1
- package/esm/models/gridSlotsComponent.d.ts +1 -2
- package/hooks/features/rows/useGridRowsMeta.js +8 -0
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -2
- package/hooks/features/virtualization/useGridVirtualScroller.js +0 -2
- package/hooks/utils/index.d.ts +2 -1
- package/hooks/utils/useGridComponentRenderer.d.ts +12 -0
- package/hooks/utils/useGridComponentRenderer.js +44 -0
- package/index.js +1 -1
- package/internals/demo/TailwindDemoContainer.d.ts +11 -0
- package/internals/demo/TailwindDemoContainer.js +63 -0
- package/internals/demo/index.d.ts +1 -0
- package/internals/demo/index.js +12 -0
- package/internals/index.d.ts +4 -0
- package/internals/index.js +28 -0
- package/material/icons/index.d.ts +3 -3
- package/material/icons/index.js +7 -7
- package/material/index.js +2 -2
- package/models/gridBaseSlots.d.ts +5 -1
- package/models/gridIconSlotsComponent.d.ts +1 -1
- package/models/gridSlotsComponent.d.ts +1 -2
- package/modern/colDef/gridActionsColDef.js +1 -1
- package/modern/colDef/gridBooleanColDef.js +1 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/modern/components/columnsManagement/GridColumnsManagement.js +1 -0
- package/modern/components/columnsPanel/ColumnsPanelTrigger.d.ts +33 -0
- package/modern/components/columnsPanel/ColumnsPanelTrigger.js +202 -0
- package/modern/components/columnsPanel/index.d.ts +1 -0
- package/modern/components/columnsPanel/index.js +1 -0
- package/modern/components/export/ExportCsv.d.ts +30 -0
- package/modern/components/export/ExportCsv.js +189 -0
- package/modern/components/export/ExportPrint.d.ts +30 -0
- package/modern/components/export/ExportPrint.js +189 -0
- package/modern/components/export/index.d.ts +2 -0
- package/modern/components/export/index.js +2 -0
- package/modern/components/filterPanel/FilterPanelTrigger.d.ts +37 -0
- package/modern/components/filterPanel/FilterPanelTrigger.js +205 -0
- package/modern/components/filterPanel/index.d.ts +1 -0
- package/modern/components/filterPanel/index.js +1 -0
- package/modern/components/index.d.ts +6 -1
- package/modern/components/index.js +6 -1
- package/modern/components/quickFilter/QuickFilter.d.ts +41 -0
- package/modern/components/quickFilter/QuickFilter.js +103 -0
- package/modern/components/quickFilter/QuickFilterClear.d.ts +28 -0
- package/modern/components/quickFilter/QuickFilterClear.js +154 -0
- package/modern/components/quickFilter/QuickFilterContext.d.ts +13 -0
- package/modern/components/quickFilter/QuickFilterContext.js +9 -0
- package/modern/components/quickFilter/QuickFilterControl.d.ts +28 -0
- package/modern/components/quickFilter/QuickFilterControl.js +97 -0
- package/modern/components/quickFilter/index.d.ts +3 -0
- package/modern/components/quickFilter/index.js +3 -0
- package/modern/components/toolbar/GridToolbar.d.ts +1 -1
- package/modern/components/toolbar/GridToolbar.js +2 -2
- package/modern/components/toolbar/GridToolbarQuickFilter.js +56 -87
- package/modern/components/toolbarV8/GridToolbar.d.ts +11 -0
- package/modern/components/toolbarV8/GridToolbar.js +135 -0
- package/modern/components/toolbarV8/Toolbar.d.ts +32 -0
- package/modern/components/toolbarV8/Toolbar.js +125 -0
- package/modern/components/toolbarV8/ToolbarButton.d.ts +23 -0
- package/modern/components/toolbarV8/ToolbarButton.js +172 -0
- package/modern/components/toolbarV8/ToolbarContext.d.ts +9 -0
- package/modern/components/toolbarV8/ToolbarContext.js +9 -0
- package/modern/components/toolbarV8/index.d.ts +2 -0
- package/modern/components/toolbarV8/index.js +2 -0
- package/modern/components/virtualization/GridVirtualScrollbar.js +7 -1
- package/modern/constants/defaultGridSlotsComponents.js +2 -1
- package/modern/constants/gridClasses.d.ts +4 -0
- package/modern/hooks/features/rows/useGridRowsMeta.js +8 -0
- package/modern/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +0 -2
- package/modern/hooks/utils/index.d.ts +2 -1
- package/modern/hooks/utils/useGridComponentRenderer.d.ts +12 -0
- package/modern/hooks/utils/useGridComponentRenderer.js +36 -0
- package/modern/index.js +1 -1
- package/modern/internals/demo/TailwindDemoContainer.d.ts +11 -0
- package/modern/internals/demo/TailwindDemoContainer.js +55 -0
- package/modern/internals/demo/index.d.ts +1 -0
- package/modern/internals/demo/index.js +1 -0
- package/modern/internals/index.d.ts +4 -0
- package/modern/internals/index.js +3 -0
- package/modern/material/icons/index.d.ts +3 -3
- package/modern/material/icons/index.js +6 -6
- package/modern/material/index.js +3 -3
- package/modern/models/gridBaseSlots.d.ts +5 -1
- package/modern/models/gridIconSlotsComponent.d.ts +1 -1
- package/modern/models/gridSlotsComponent.d.ts +1 -2
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { GridFilterModel } from '../../models';
|
|
3
|
+
export type QuickFilterProps = {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* Function responsible for parsing text input in an array of independent values for quick filtering.
|
|
7
|
+
* @param {string} input The value entered by the user
|
|
8
|
+
* @returns {any[]} The array of value on which quick filter is applied
|
|
9
|
+
* @default (searchText: string) => searchText.split(' ').filter((word) => word !== '')
|
|
10
|
+
*/
|
|
11
|
+
parser?: (input: string) => any[];
|
|
12
|
+
/**
|
|
13
|
+
* Function responsible for formatting values of quick filter in a string when the model is modified
|
|
14
|
+
* @param {any[]} values The new values passed to the quick filter model
|
|
15
|
+
* @returns {string} The string to display in the text field
|
|
16
|
+
* @default (values: string[]) => values.join(' ')
|
|
17
|
+
*/
|
|
18
|
+
formatter?: (values: NonNullable<GridFilterModel['quickFilterValues']>) => string;
|
|
19
|
+
/**
|
|
20
|
+
* The debounce time in milliseconds.
|
|
21
|
+
* @default 150
|
|
22
|
+
*/
|
|
23
|
+
debounceMs?: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The top level Quick Filter component that provides context to child components.
|
|
27
|
+
* It does not render any DOM elements.
|
|
28
|
+
*
|
|
29
|
+
* Demos:
|
|
30
|
+
*
|
|
31
|
+
* - [Quick Filter](https://mui.com/x/react-data-grid/components/quick-filter/)
|
|
32
|
+
*
|
|
33
|
+
* API:
|
|
34
|
+
*
|
|
35
|
+
* - [QuickFilter API](https://mui.com/x/api/data-grid/quick-filter/)
|
|
36
|
+
*/
|
|
37
|
+
declare function QuickFilter(props: QuickFilterProps): React.JSX.Element;
|
|
38
|
+
declare namespace QuickFilter {
|
|
39
|
+
var propTypes: any;
|
|
40
|
+
}
|
|
41
|
+
export { QuickFilter };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { unstable_debounce as debounce } from '@mui/utils';
|
|
4
|
+
import { QuickFilterContext } from "./QuickFilterContext.js";
|
|
5
|
+
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
6
|
+
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
7
|
+
import { gridQuickFilterValuesSelector } from "../../hooks/features/filter/index.js";
|
|
8
|
+
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
9
|
+
import { isDeepEqual } from "../../utils/utils.js";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
const DEFAULT_PARSER = searchText => searchText.split(' ').filter(word => word !== '');
|
|
12
|
+
const DEFAULT_FORMATTER = values => values.join(' ');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The top level Quick Filter component that provides context to child components.
|
|
16
|
+
* It does not render any DOM elements.
|
|
17
|
+
*
|
|
18
|
+
* Demos:
|
|
19
|
+
*
|
|
20
|
+
* - [Quick Filter](https://mui.com/x/react-data-grid/components/quick-filter/)
|
|
21
|
+
*
|
|
22
|
+
* API:
|
|
23
|
+
*
|
|
24
|
+
* - [QuickFilter API](https://mui.com/x/api/data-grid/quick-filter/)
|
|
25
|
+
*/
|
|
26
|
+
function QuickFilter(props) {
|
|
27
|
+
const rootProps = useGridRootProps();
|
|
28
|
+
const {
|
|
29
|
+
parser = DEFAULT_PARSER,
|
|
30
|
+
formatter = DEFAULT_FORMATTER,
|
|
31
|
+
debounceMs = rootProps.filterDebounceMs,
|
|
32
|
+
children
|
|
33
|
+
} = props;
|
|
34
|
+
const apiRef = useGridApiContext();
|
|
35
|
+
const controlRef = React.useRef(null);
|
|
36
|
+
const triggerRef = React.useRef(null);
|
|
37
|
+
const quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
|
|
38
|
+
const [value, setValue] = React.useState(formatter(quickFilterValues ?? []));
|
|
39
|
+
const prevQuickFilterValuesRef = React.useRef(quickFilterValues);
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
if (!isDeepEqual(prevQuickFilterValuesRef.current, quickFilterValues)) {
|
|
42
|
+
// The model of quick filter value has been updated
|
|
43
|
+
prevQuickFilterValuesRef.current = quickFilterValues;
|
|
44
|
+
|
|
45
|
+
// Update the input value if needed to match the new model
|
|
46
|
+
setValue(prevSearchValue => isDeepEqual(parser(prevSearchValue), quickFilterValues) ? prevSearchValue : formatter(quickFilterValues ?? []));
|
|
47
|
+
}
|
|
48
|
+
}, [quickFilterValues, formatter, parser]);
|
|
49
|
+
const setQuickFilterValueDebounced = React.useMemo(() => debounce(newValue => {
|
|
50
|
+
apiRef.current.setQuickFilterValues(parser(newValue));
|
|
51
|
+
}, debounceMs), [apiRef, debounceMs, parser]);
|
|
52
|
+
React.useEffect(() => setQuickFilterValueDebounced.clear, [setQuickFilterValueDebounced]);
|
|
53
|
+
const handleValueChange = React.useCallback(event => {
|
|
54
|
+
const newValue = event.target.value;
|
|
55
|
+
setValue(newValue);
|
|
56
|
+
setQuickFilterValueDebounced(newValue);
|
|
57
|
+
}, [setQuickFilterValueDebounced]);
|
|
58
|
+
const handleClear = React.useCallback(() => {
|
|
59
|
+
setValue('');
|
|
60
|
+
apiRef.current.setQuickFilterValues([]);
|
|
61
|
+
controlRef.current?.focus();
|
|
62
|
+
}, [apiRef, controlRef]);
|
|
63
|
+
const contextValue = React.useMemo(() => ({
|
|
64
|
+
controlRef,
|
|
65
|
+
triggerRef,
|
|
66
|
+
state: {
|
|
67
|
+
value
|
|
68
|
+
},
|
|
69
|
+
clearValue: handleClear,
|
|
70
|
+
onValueChange: handleValueChange
|
|
71
|
+
}), [value, handleValueChange, handleClear]);
|
|
72
|
+
return /*#__PURE__*/_jsx(QuickFilterContext.Provider, {
|
|
73
|
+
value: contextValue,
|
|
74
|
+
children: children
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
process.env.NODE_ENV !== "production" ? QuickFilter.propTypes = {
|
|
78
|
+
// ----------------------------- Warning --------------------------------
|
|
79
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
80
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
81
|
+
// ----------------------------------------------------------------------
|
|
82
|
+
children: PropTypes.node,
|
|
83
|
+
/**
|
|
84
|
+
* The debounce time in milliseconds.
|
|
85
|
+
* @default 150
|
|
86
|
+
*/
|
|
87
|
+
debounceMs: PropTypes.number,
|
|
88
|
+
/**
|
|
89
|
+
* Function responsible for formatting values of quick filter in a string when the model is modified
|
|
90
|
+
* @param {any[]} values The new values passed to the quick filter model
|
|
91
|
+
* @returns {string} The string to display in the text field
|
|
92
|
+
* @default (values: string[]) => values.join(' ')
|
|
93
|
+
*/
|
|
94
|
+
formatter: PropTypes.func,
|
|
95
|
+
/**
|
|
96
|
+
* Function responsible for parsing text input in an array of independent values for quick filtering.
|
|
97
|
+
* @param {string} input The value entered by the user
|
|
98
|
+
* @returns {any[]} The array of value on which quick filter is applied
|
|
99
|
+
* @default (searchText: string) => searchText.split(' ').filter((word) => word !== '')
|
|
100
|
+
*/
|
|
101
|
+
parser: PropTypes.func
|
|
102
|
+
} : void 0;
|
|
103
|
+
export { QuickFilter };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { RenderProp } from "../../hooks/utils/useGridComponentRenderer.js";
|
|
3
|
+
import type { GridSlotProps } from '../../models';
|
|
4
|
+
import { QuickFilterState } from "./QuickFilterContext.js";
|
|
5
|
+
export type QuickFilterClearProps = Omit<GridSlotProps['baseIconButton'], 'className'> & {
|
|
6
|
+
/**
|
|
7
|
+
* A function to customize rendering of the component.
|
|
8
|
+
*/
|
|
9
|
+
render?: RenderProp<GridSlotProps['baseIconButton'], QuickFilterState>;
|
|
10
|
+
/**
|
|
11
|
+
* Override or extend the styles applied to the component.
|
|
12
|
+
*/
|
|
13
|
+
className?: string | ((state: QuickFilterState) => string);
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A button that resets the filter value.
|
|
17
|
+
* It renders the `baseIconButton` slot.
|
|
18
|
+
*
|
|
19
|
+
* Demos:
|
|
20
|
+
*
|
|
21
|
+
* - [Quick Filter](https://mui.com/x/react-data-grid/components/quick-filter/)
|
|
22
|
+
*
|
|
23
|
+
* API:
|
|
24
|
+
*
|
|
25
|
+
* - [QuickFilterClear API](https://mui.com/x/api/data-grid/quick-filter-clear/)
|
|
26
|
+
*/
|
|
27
|
+
declare const QuickFilterClear: React.ForwardRefExoticComponent<QuickFilterClearProps> | React.ForwardRefExoticComponent<Omit<QuickFilterClearProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
28
|
+
export { QuickFilterClear };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["render", "className"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
7
|
+
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
8
|
+
import { useGridComponentRenderer } from "../../hooks/utils/useGridComponentRenderer.js";
|
|
9
|
+
import { useQuickFilterContext } from "./QuickFilterContext.js";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* A button that resets the filter value.
|
|
13
|
+
* It renders the `baseIconButton` slot.
|
|
14
|
+
*
|
|
15
|
+
* Demos:
|
|
16
|
+
*
|
|
17
|
+
* - [Quick Filter](https://mui.com/x/react-data-grid/components/quick-filter/)
|
|
18
|
+
*
|
|
19
|
+
* API:
|
|
20
|
+
*
|
|
21
|
+
* - [QuickFilterClear API](https://mui.com/x/api/data-grid/quick-filter-clear/)
|
|
22
|
+
*/
|
|
23
|
+
const QuickFilterClear = forwardRef(function QuickFilterClear(props, ref) {
|
|
24
|
+
const {
|
|
25
|
+
render,
|
|
26
|
+
className
|
|
27
|
+
} = props,
|
|
28
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
29
|
+
const rootProps = useGridRootProps();
|
|
30
|
+
const {
|
|
31
|
+
state,
|
|
32
|
+
clearValue
|
|
33
|
+
} = useQuickFilterContext();
|
|
34
|
+
const resolvedClassName = typeof className === 'function' ? className(state) : className;
|
|
35
|
+
const element = useGridComponentRenderer(rootProps.slots.baseIconButton, render, _extends({}, rootProps.slotProps?.baseIconButton, {
|
|
36
|
+
onClick: clearValue,
|
|
37
|
+
className: resolvedClassName
|
|
38
|
+
}, other, {
|
|
39
|
+
ref
|
|
40
|
+
}), state);
|
|
41
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
42
|
+
children: element
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
process.env.NODE_ENV !== "production" ? QuickFilterClear.propTypes = {
|
|
46
|
+
// ----------------------------- Warning --------------------------------
|
|
47
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
48
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
49
|
+
// ----------------------------------------------------------------------
|
|
50
|
+
/**
|
|
51
|
+
* A ref for imperative actions.
|
|
52
|
+
* It currently only supports `focusVisible()` action.
|
|
53
|
+
*/
|
|
54
|
+
action: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
55
|
+
current: PropTypes.shape({
|
|
56
|
+
focusVisible: PropTypes.func.isRequired
|
|
57
|
+
})
|
|
58
|
+
})]),
|
|
59
|
+
/**
|
|
60
|
+
* If `true`, the ripples are centered.
|
|
61
|
+
* They won't start at the cursor interaction position.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
centerRipple: PropTypes.bool,
|
|
65
|
+
/**
|
|
66
|
+
* Override or extend the styles applied to the component.
|
|
67
|
+
*/
|
|
68
|
+
className: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
69
|
+
/**
|
|
70
|
+
* The color of the component.
|
|
71
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
72
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
|
73
|
+
*/
|
|
74
|
+
color: PropTypes.oneOf(['default', 'inherit', 'primary']),
|
|
75
|
+
component: PropTypes.elementType,
|
|
76
|
+
/**
|
|
77
|
+
* If `true`, the component is disabled.
|
|
78
|
+
*/
|
|
79
|
+
disabled: PropTypes.bool,
|
|
80
|
+
/**
|
|
81
|
+
* If `true`, the keyboard focus ripple is disabled.
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
disableFocusRipple: PropTypes.bool,
|
|
85
|
+
/**
|
|
86
|
+
* If `true`, the ripple effect is disabled.
|
|
87
|
+
*
|
|
88
|
+
* ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure
|
|
89
|
+
* to highlight the element by applying separate styles with the `.Mui-focusVisible` class.
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
disableRipple: PropTypes.bool,
|
|
93
|
+
/**
|
|
94
|
+
* If `true`, the touch ripple effect is disabled.
|
|
95
|
+
* @default false
|
|
96
|
+
*/
|
|
97
|
+
disableTouchRipple: PropTypes.bool,
|
|
98
|
+
/**
|
|
99
|
+
* If given, uses a negative margin to counteract the padding on one
|
|
100
|
+
* side (this is often helpful for aligning the left or right
|
|
101
|
+
* side of the icon with content above or below, without ruining the border
|
|
102
|
+
* size and shape).
|
|
103
|
+
*/
|
|
104
|
+
edge: PropTypes.oneOf(['end', 'start', false]),
|
|
105
|
+
/**
|
|
106
|
+
* If `true`, the base button will have a keyboard focus ripple.
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
focusRipple: PropTypes.bool,
|
|
110
|
+
/**
|
|
111
|
+
* This prop can help identify which element has keyboard focus.
|
|
112
|
+
* The class name will be applied when the element gains the focus through keyboard interaction.
|
|
113
|
+
* It's a polyfill for the [CSS :focus-visible selector](https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo).
|
|
114
|
+
* The rationale for using this feature [is explained here](https://github.com/WICG/focus-visible/blob/HEAD/explainer.md).
|
|
115
|
+
* A [polyfill can be used](https://github.com/WICG/focus-visible) to apply a `focus-visible` class to other components
|
|
116
|
+
* if needed.
|
|
117
|
+
*/
|
|
118
|
+
focusVisibleClassName: PropTypes.string,
|
|
119
|
+
label: PropTypes.string,
|
|
120
|
+
/**
|
|
121
|
+
* The component used to render a link when the `href` prop is provided.
|
|
122
|
+
* @default 'a'
|
|
123
|
+
*/
|
|
124
|
+
LinkComponent: PropTypes.elementType,
|
|
125
|
+
/**
|
|
126
|
+
* Callback fired when the component is focused with a keyboard.
|
|
127
|
+
* We trigger a `onFocus` callback too.
|
|
128
|
+
*/
|
|
129
|
+
onFocusVisible: PropTypes.func,
|
|
130
|
+
/**
|
|
131
|
+
* A function to customize rendering of the component.
|
|
132
|
+
*/
|
|
133
|
+
render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
|
134
|
+
/**
|
|
135
|
+
* The size of the component.
|
|
136
|
+
* `small` is equivalent to the dense button styling.
|
|
137
|
+
*/
|
|
138
|
+
size: PropTypes.oneOf(['large', 'medium', 'small']),
|
|
139
|
+
style: PropTypes.object,
|
|
140
|
+
/**
|
|
141
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
142
|
+
*/
|
|
143
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
144
|
+
tabIndex: PropTypes.number,
|
|
145
|
+
/**
|
|
146
|
+
* Props applied to the `TouchRipple` element.
|
|
147
|
+
*/
|
|
148
|
+
TouchRippleProps: PropTypes.object,
|
|
149
|
+
/**
|
|
150
|
+
* A ref that points to the `TouchRipple` element.
|
|
151
|
+
*/
|
|
152
|
+
touchRippleRef: PropTypes.any
|
|
153
|
+
} : void 0;
|
|
154
|
+
export { QuickFilterClear };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface QuickFilterState {
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
export interface QuickFilterContextValue {
|
|
6
|
+
state: QuickFilterState;
|
|
7
|
+
controlRef: React.RefObject<HTMLInputElement | null>;
|
|
8
|
+
triggerRef: React.RefObject<HTMLButtonElement | null>;
|
|
9
|
+
onValueChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
|
+
clearValue: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const QuickFilterContext: React.Context<QuickFilterContextValue | undefined>;
|
|
13
|
+
export declare function useQuickFilterContext(): QuickFilterContextValue;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export const QuickFilterContext = /*#__PURE__*/React.createContext(undefined);
|
|
3
|
+
export function useQuickFilterContext() {
|
|
4
|
+
const context = React.useContext(QuickFilterContext);
|
|
5
|
+
if (context === undefined) {
|
|
6
|
+
throw new Error('MUI X: Missing context. Quick Filter subcomponents must be placed within a <QuickFilter /> component.');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { RenderProp } from "../../hooks/utils/useGridComponentRenderer.js";
|
|
3
|
+
import type { GridSlotProps } from '../../models';
|
|
4
|
+
import { QuickFilterState } from "./QuickFilterContext.js";
|
|
5
|
+
export type QuickFilterControlProps = Omit<GridSlotProps['baseTextField'], 'className'> & {
|
|
6
|
+
/**
|
|
7
|
+
* A function to customize rendering of the component.
|
|
8
|
+
*/
|
|
9
|
+
render?: RenderProp<GridSlotProps['baseTextField'], QuickFilterState>;
|
|
10
|
+
/**
|
|
11
|
+
* Override or extend the styles applied to the component.
|
|
12
|
+
*/
|
|
13
|
+
className?: string | ((state: QuickFilterState) => string);
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A component that takes user input and filters row data.
|
|
17
|
+
* It renders the `baseTextField` slot.
|
|
18
|
+
*
|
|
19
|
+
* Demos:
|
|
20
|
+
*
|
|
21
|
+
* - [Quick Filter](https://mui.com/x/react-data-grid/components/quick-filter/)
|
|
22
|
+
*
|
|
23
|
+
* API:
|
|
24
|
+
*
|
|
25
|
+
* - [QuickFilterControl API](https://mui.com/x/api/data-grid/quick-filter-control/)
|
|
26
|
+
*/
|
|
27
|
+
declare const QuickFilterControl: React.ForwardRefExoticComponent<QuickFilterControlProps> | React.ForwardRefExoticComponent<Omit<QuickFilterControlProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
28
|
+
export { QuickFilterControl };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["render", "className"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
|
7
|
+
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
8
|
+
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
9
|
+
import { useGridComponentRenderer } from "../../hooks/utils/useGridComponentRenderer.js";
|
|
10
|
+
import { useQuickFilterContext } from "./QuickFilterContext.js";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
/**
|
|
13
|
+
* A component that takes user input and filters row data.
|
|
14
|
+
* It renders the `baseTextField` slot.
|
|
15
|
+
*
|
|
16
|
+
* Demos:
|
|
17
|
+
*
|
|
18
|
+
* - [Quick Filter](https://mui.com/x/react-data-grid/components/quick-filter/)
|
|
19
|
+
*
|
|
20
|
+
* API:
|
|
21
|
+
*
|
|
22
|
+
* - [QuickFilterControl API](https://mui.com/x/api/data-grid/quick-filter-control/)
|
|
23
|
+
*/
|
|
24
|
+
const QuickFilterControl = forwardRef(function QuickFilterControl(props, ref) {
|
|
25
|
+
const {
|
|
26
|
+
render,
|
|
27
|
+
className
|
|
28
|
+
} = props,
|
|
29
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
30
|
+
const rootProps = useGridRootProps();
|
|
31
|
+
const {
|
|
32
|
+
state,
|
|
33
|
+
controlRef,
|
|
34
|
+
onValueChange,
|
|
35
|
+
clearValue
|
|
36
|
+
} = useQuickFilterContext();
|
|
37
|
+
const resolvedClassName = typeof className === 'function' ? className(state) : className;
|
|
38
|
+
const handleRef = useForkRef(controlRef, ref);
|
|
39
|
+
const handleKeyDown = event => {
|
|
40
|
+
if (event.key === 'Escape') {
|
|
41
|
+
clearValue();
|
|
42
|
+
}
|
|
43
|
+
props.onKeyDown?.(event);
|
|
44
|
+
};
|
|
45
|
+
const element = useGridComponentRenderer(rootProps.slots.baseTextField, render, _extends({}, rootProps.slotProps?.baseTextField, {
|
|
46
|
+
slotProps: _extends({
|
|
47
|
+
htmlInput: _extends({
|
|
48
|
+
role: 'searchbox'
|
|
49
|
+
}, props.slotProps?.htmlInput)
|
|
50
|
+
}, props.slotProps),
|
|
51
|
+
value: state.value,
|
|
52
|
+
className: resolvedClassName,
|
|
53
|
+
onChange: onValueChange,
|
|
54
|
+
onKeyDown: handleKeyDown
|
|
55
|
+
}, other, {
|
|
56
|
+
ref: handleRef
|
|
57
|
+
}), state);
|
|
58
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
59
|
+
children: element
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
process.env.NODE_ENV !== "production" ? QuickFilterControl.propTypes = {
|
|
63
|
+
// ----------------------------- Warning --------------------------------
|
|
64
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
65
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
66
|
+
// ----------------------------------------------------------------------
|
|
67
|
+
autoComplete: PropTypes.string,
|
|
68
|
+
/**
|
|
69
|
+
* Override or extend the styles applied to the component.
|
|
70
|
+
*/
|
|
71
|
+
className: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
72
|
+
color: PropTypes.oneOf(['error', 'primary']),
|
|
73
|
+
disabled: PropTypes.bool,
|
|
74
|
+
error: PropTypes.bool,
|
|
75
|
+
fullWidth: PropTypes.bool,
|
|
76
|
+
helperText: PropTypes.string,
|
|
77
|
+
id: PropTypes.string,
|
|
78
|
+
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
79
|
+
current: PropTypes.object
|
|
80
|
+
})]),
|
|
81
|
+
label: PropTypes.node,
|
|
82
|
+
onChange: PropTypes.func,
|
|
83
|
+
onKeyDown: PropTypes.func,
|
|
84
|
+
placeholder: PropTypes.string,
|
|
85
|
+
/**
|
|
86
|
+
* A function to customize rendering of the component.
|
|
87
|
+
*/
|
|
88
|
+
render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
|
89
|
+
role: PropTypes.string,
|
|
90
|
+
size: PropTypes.oneOf(['medium', 'small']),
|
|
91
|
+
slotProps: PropTypes.object,
|
|
92
|
+
style: PropTypes.object,
|
|
93
|
+
tabIndex: PropTypes.number,
|
|
94
|
+
type: PropTypes.oneOfType([PropTypes.oneOf(['button', 'checkbox', 'color', 'date', 'datetime-local', 'email', 'file', 'hidden', 'image', 'month', 'number', 'password', 'radio', 'range', 'reset', 'search', 'submit', 'tel', 'text', 'time', 'url', 'week']), PropTypes.object]),
|
|
95
|
+
value: PropTypes.string
|
|
96
|
+
} : void 0;
|
|
97
|
+
export { QuickFilterControl };
|
|
@@ -5,7 +5,7 @@ import { GridToolbarQuickFilterProps } from "./GridToolbarQuickFilter.js";
|
|
|
5
5
|
export interface GridToolbarProps extends GridToolbarContainerProps, GridToolbarExportProps {
|
|
6
6
|
/**
|
|
7
7
|
* Show the quick filter component.
|
|
8
|
-
* @default
|
|
8
|
+
* @default true
|
|
9
9
|
*/
|
|
10
10
|
showQuickFilter?: boolean;
|
|
11
11
|
/**
|
|
@@ -20,7 +20,7 @@ const GridToolbar = forwardRef(function GridToolbar(props, ref) {
|
|
|
20
20
|
csvOptions,
|
|
21
21
|
printOptions,
|
|
22
22
|
excelOptions,
|
|
23
|
-
showQuickFilter =
|
|
23
|
+
showQuickFilter = true,
|
|
24
24
|
quickFilterProps = {}
|
|
25
25
|
} = _ref,
|
|
26
26
|
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -62,7 +62,7 @@ process.env.NODE_ENV !== "production" ? GridToolbar.propTypes = {
|
|
|
62
62
|
}),
|
|
63
63
|
/**
|
|
64
64
|
* Show the quick filter component.
|
|
65
|
-
* @default
|
|
65
|
+
* @default true
|
|
66
66
|
*/
|
|
67
67
|
showQuickFilter: PropTypes.bool,
|
|
68
68
|
/**
|