@mui/x-data-grid 6.11.1 → 6.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -1
- package/DataGrid/DataGrid.d.ts +10 -0
- package/DataGrid/DataGrid.js +24 -1
- package/DataGrid/useDataGridProps.js +2 -0
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +0 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +5 -11
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +0 -1
- package/components/panel/filterPanel/GridFilterInputValue.js +16 -18
- package/components/panel/filterPanel/GridFilterPanel.js +1 -3
- package/components/toolbar/GridToolbarQuickFilter.d.ts +1 -1
- package/components/toolbar/GridToolbarQuickFilter.js +5 -5
- package/hooks/features/export/useGridPrintExport.js +0 -5
- package/hooks/features/export/utils.js +7 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +2 -2
- package/hooks/features/filter/gridFilterUtils.js +23 -19
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.js +2 -2
- package/hooks/features/rows/useGridRows.js +11 -0
- package/hooks/utils/useTimeout.d.ts +9 -0
- package/hooks/utils/useTimeout.js +28 -0
- package/index.js +1 -1
- package/legacy/DataGrid/DataGrid.js +24 -1
- package/legacy/DataGrid/useDataGridProps.js +2 -0
- package/legacy/components/panel/filterPanel/GridFilterInputDate.js +5 -11
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +16 -18
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -3
- package/legacy/components/toolbar/GridToolbarQuickFilter.js +5 -5
- package/legacy/hooks/features/export/useGridPrintExport.js +0 -5
- package/legacy/hooks/features/export/utils.js +8 -6
- package/legacy/hooks/features/filter/gridFilterUtils.js +23 -19
- package/legacy/hooks/features/filter/useGridFilter.js +2 -2
- package/legacy/hooks/features/rows/useGridRows.js +11 -0
- package/legacy/hooks/utils/useTimeout.js +38 -0
- package/legacy/index.js +1 -1
- package/legacy/locales/esES.js +26 -28
- package/legacy/locales/zhCN.js +25 -27
- package/legacy/locales/zhTW.js +34 -38
- package/locales/esES.js +26 -28
- package/locales/zhCN.js +25 -27
- package/locales/zhTW.js +34 -38
- package/models/api/gridRowApi.d.ts +6 -0
- package/models/props/DataGridProps.d.ts +11 -0
- package/modern/DataGrid/DataGrid.js +24 -1
- package/modern/DataGrid/useDataGridProps.js +2 -0
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +5 -11
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +15 -17
- package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -3
- package/modern/components/toolbar/GridToolbarQuickFilter.js +5 -5
- package/modern/hooks/features/export/useGridPrintExport.js +0 -5
- package/modern/hooks/features/export/utils.js +7 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +23 -19
- package/modern/hooks/features/filter/useGridFilter.js +2 -2
- package/modern/hooks/features/rows/useGridRows.js +11 -0
- package/modern/hooks/utils/useTimeout.js +28 -0
- package/modern/index.js +1 -1
- package/modern/locales/esES.js +26 -28
- package/modern/locales/zhCN.js +25 -27
- package/modern/locales/zhTW.js +34 -38
- package/node/DataGrid/DataGrid.js +26 -1
- package/node/DataGrid/useDataGridProps.js +2 -0
- package/node/components/panel/filterPanel/GridFilterInputDate.js +5 -13
- package/node/components/panel/filterPanel/GridFilterInputValue.js +15 -19
- package/node/components/panel/filterPanel/GridFilterPanel.js +1 -3
- package/node/components/toolbar/GridToolbarQuickFilter.js +5 -5
- package/node/hooks/features/export/useGridPrintExport.js +0 -5
- package/node/hooks/features/export/utils.js +7 -1
- package/node/hooks/features/filter/gridFilterUtils.js +23 -19
- package/node/hooks/features/filter/useGridFilter.js +2 -2
- package/node/hooks/features/rows/useGridRows.js +11 -0
- package/node/hooks/utils/useTimeout.js +34 -0
- package/node/index.js +1 -1
- package/node/locales/esES.js +26 -28
- package/node/locales/zhCN.js +25 -27
- package/node/locales/zhTW.js +34 -38
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,62 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 6.11.2
|
|
7
|
+
|
|
8
|
+
_Aug 17, 2023_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 8 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🏎️ Lower the filtering delay in the grid
|
|
13
|
+
- 🌍 Improve Spanish (es-ES) locale on the data grid
|
|
14
|
+
- 🐞 Bugfixes
|
|
15
|
+
- 📚 Documentation improvements
|
|
16
|
+
|
|
17
|
+
### Data Grid
|
|
18
|
+
|
|
19
|
+
#### `@mui/x-data-grid@v6.11.2`
|
|
20
|
+
|
|
21
|
+
- [DataGrid] Fix `eval` blocked by CSP (#9863) @romgrk
|
|
22
|
+
- [DataGrid] Fix row id bug (#10051) @romgrk
|
|
23
|
+
- [DataGrid] Honor `disableExport` flag in Print Export (#10044) @MBilalShafi
|
|
24
|
+
- [DataGrid] Lower filter debounce delay (#9712) @romgrk
|
|
25
|
+
- [DataGrid] Unhide potential ref binding issue (#9965) @oliviertassinari
|
|
26
|
+
- [l10n] Improve Chinese (zh-CN) and Chinese(traditional) (zh-TW) locales (#9999) @MyNameIsTakenOMG
|
|
27
|
+
- [l10n] Improve Spanish (es-ES) locale (#10037) @Macampu420
|
|
28
|
+
|
|
29
|
+
#### `@mui/x-data-grid-pro@v6.11.2` [](https://mui.com/r/x-pro-svg-link)
|
|
30
|
+
|
|
31
|
+
Same changes as in `@mui/x-data-grid@v6.11.2`.
|
|
32
|
+
|
|
33
|
+
#### `@mui/x-data-grid-premium@v6.11.2` [](https://mui.com/r/x-premium-svg-link)
|
|
34
|
+
|
|
35
|
+
Same changes as in `@mui/x-data-grid-pro@v6.11.2`.
|
|
36
|
+
|
|
37
|
+
### Date Pickers
|
|
38
|
+
|
|
39
|
+
#### `@mui/x-date-pickers@v6.11.2`
|
|
40
|
+
|
|
41
|
+
- [pickers] Fix month switcher RTL (#10003) @alexfauquette
|
|
42
|
+
- [pickers] Follow-up on using device motion reduction preference (#9858) @LukasTy
|
|
43
|
+
- [pickers] Pass the shortcut information in the `onChange` context (#9985) @flaviendelangle
|
|
44
|
+
- [pickers] Replace `Grid` toolbar component with a styled `div` (#10052) @LukasTy
|
|
45
|
+
|
|
46
|
+
#### `@mui/x-date-pickers-pro@v6.11.2` [](https://mui.com/r/x-pro-svg-link)
|
|
47
|
+
|
|
48
|
+
Same changes as in `@mui/x-date-pickers@v6.11.2`.
|
|
49
|
+
|
|
50
|
+
### Docs
|
|
51
|
+
|
|
52
|
+
- [docs] Add migration guide for the Tree View (#9987) @flaviendelangle
|
|
53
|
+
- [docs] Fix en-US changelog @oliviertassinari
|
|
54
|
+
- [docs] Update column types (#10040) @romgrk
|
|
55
|
+
|
|
56
|
+
### Core
|
|
57
|
+
|
|
58
|
+
- [core] Remove unnecessary Box (#9831) @oliviertassinari
|
|
59
|
+
- [core] Set GitHub Action top level permission @oliviertassinari
|
|
60
|
+
- [core] Split the pickers test utils (#9976) @flaviendelangle
|
|
61
|
+
|
|
6
62
|
## 6.11.1
|
|
7
63
|
|
|
8
64
|
_Aug 11, 2023_
|
|
@@ -2872,7 +2928,7 @@ We'd like to offer a big thanks to the 8 contributors who made this release poss
|
|
|
2872
2928
|
|
|
2873
2929
|
#### Changes
|
|
2874
2930
|
|
|
2875
|
-
- [DateRangePicker] Fix input focused style and mobile
|
|
2931
|
+
- [DateRangePicker] Fix input focused style and mobile behavior (#6645) @LukasTy
|
|
2876
2932
|
- [fields] Update sections when the locale changes (#6649) @flaviendelangle
|
|
2877
2933
|
- [pickers] Add Ukrainian (uk-UA) locale (#6661) @Dufran
|
|
2878
2934
|
- [pickers] Allow non-controlled usage of the calendar components (#6643) @flaviendelangle
|
package/DataGrid/DataGrid.d.ts
CHANGED
|
@@ -6,4 +6,14 @@ interface DataGridComponent {
|
|
|
6
6
|
propTypes?: any;
|
|
7
7
|
}
|
|
8
8
|
export declare const DataGrid: DataGridComponent;
|
|
9
|
+
/**
|
|
10
|
+
* Remove at v7
|
|
11
|
+
* @deprecated
|
|
12
|
+
*/
|
|
13
|
+
export declare const SUBMIT_FILTER_STROKE_TIME: number;
|
|
14
|
+
/**
|
|
15
|
+
* Remove at v7
|
|
16
|
+
* @deprecated
|
|
17
|
+
*/
|
|
18
|
+
export declare const SUBMIT_FILTER_DATE_STROKE_TIME: number;
|
|
9
19
|
export {};
|
package/DataGrid/DataGrid.js
CHANGED
|
@@ -5,7 +5,7 @@ import { chainPropTypes } from '@mui/utils';
|
|
|
5
5
|
import { GridBody, GridFooterPlaceholder, GridHeader, GridRoot } from '../components';
|
|
6
6
|
import { GridContextProvider } from '../context/GridContextProvider';
|
|
7
7
|
import { useDataGridComponent } from './useDataGridComponent';
|
|
8
|
-
import { useDataGridProps } from './useDataGridProps';
|
|
8
|
+
import { useDataGridProps, DATA_GRID_PROPS_DEFAULT_VALUES } from './useDataGridProps';
|
|
9
9
|
import { DataGridVirtualScroller } from '../components/DataGridVirtualScroller';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -28,6 +28,18 @@ const DataGridRaw = /*#__PURE__*/React.forwardRef(function DataGrid(inProps, ref
|
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
export const DataGrid = /*#__PURE__*/React.memo(DataGridRaw);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Remove at v7
|
|
34
|
+
* @deprecated
|
|
35
|
+
*/
|
|
36
|
+
export const SUBMIT_FILTER_STROKE_TIME = DATA_GRID_PROPS_DEFAULT_VALUES.filterDebounceMs;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Remove at v7
|
|
40
|
+
* @deprecated
|
|
41
|
+
*/
|
|
42
|
+
export const SUBMIT_FILTER_DATE_STROKE_TIME = DATA_GRID_PROPS_DEFAULT_VALUES.filterDebounceMs;
|
|
31
43
|
DataGridRaw.propTypes = {
|
|
32
44
|
// ----------------------------- Warning --------------------------------
|
|
33
45
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -141,6 +153,12 @@ DataGridRaw.propTypes = {
|
|
|
141
153
|
* @default false
|
|
142
154
|
*/
|
|
143
155
|
disableDensitySelector: PropTypes.bool,
|
|
156
|
+
/**
|
|
157
|
+
* If `true`, `eval()` is not used for performance optimization.
|
|
158
|
+
* @default false
|
|
159
|
+
* @ignore - do not document
|
|
160
|
+
*/
|
|
161
|
+
disableEval: PropTypes.bool,
|
|
144
162
|
/**
|
|
145
163
|
* If `true`, the selection on click on a row or cell is disabled.
|
|
146
164
|
* @default false
|
|
@@ -165,6 +183,11 @@ DataGridRaw.propTypes = {
|
|
|
165
183
|
columnGrouping: PropTypes.bool,
|
|
166
184
|
warnIfFocusStateIsNotSynced: PropTypes.bool
|
|
167
185
|
}),
|
|
186
|
+
/**
|
|
187
|
+
* The milliseconds delay to wait after a keystroke before triggering filtering.
|
|
188
|
+
* @default 150
|
|
189
|
+
*/
|
|
190
|
+
filterDebounceMs: PropTypes.number,
|
|
168
191
|
/**
|
|
169
192
|
* Filtering can be processed on the server or client-side.
|
|
170
193
|
* Set it to 'server' if you would like to handle filtering on the server-side.
|
|
@@ -37,6 +37,7 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
37
37
|
disableColumnMenu: false,
|
|
38
38
|
disableColumnSelector: false,
|
|
39
39
|
disableDensitySelector: false,
|
|
40
|
+
disableEval: false,
|
|
40
41
|
disableMultipleColumnsFiltering: false,
|
|
41
42
|
disableMultipleRowSelection: false,
|
|
42
43
|
disableMultipleColumnsSorting: false,
|
|
@@ -44,6 +45,7 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
44
45
|
disableVirtualization: false,
|
|
45
46
|
editMode: GridEditModes.Cell,
|
|
46
47
|
filterMode: 'client',
|
|
48
|
+
filterDebounceMs: 150,
|
|
47
49
|
columnHeaderHeight: 56,
|
|
48
50
|
hideFooter: false,
|
|
49
51
|
hideFooterPagination: false,
|
|
@@ -16,7 +16,7 @@ export interface GridPanelProps extends Partial<React.ComponentProps<typeof Grid
|
|
|
16
16
|
open: boolean;
|
|
17
17
|
}
|
|
18
18
|
export declare const gridPanelClasses: Record<keyof GridPanelClasses, string>;
|
|
19
|
-
declare const GridPanelRoot: import("@emotion/styled").StyledComponent<Pick<Omit<import("@mui/base").PopperProps
|
|
19
|
+
declare const GridPanelRoot: import("@emotion/styled").StyledComponent<Pick<Omit<import("@mui/base").PopperProps, "direction"> & {
|
|
20
20
|
component?: React.ElementType<any> | undefined;
|
|
21
21
|
components?: {
|
|
22
22
|
Root?: React.ElementType<any> | undefined;
|
|
@@ -10,7 +10,6 @@ export type GridFilterInputDateProps = GridFilterInputValueProps & TextFieldProp
|
|
|
10
10
|
*/
|
|
11
11
|
isFilterActive?: boolean;
|
|
12
12
|
};
|
|
13
|
-
export declare const SUBMIT_FILTER_DATE_STROKE_TIME = 500;
|
|
14
13
|
declare function GridFilterInputDate(props: GridFilterInputDateProps): React.JSX.Element;
|
|
15
14
|
declare namespace GridFilterInputDate {
|
|
16
15
|
var propTypes: any;
|
|
@@ -4,9 +4,9 @@ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "I
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_useId as useId } from '@mui/utils';
|
|
7
|
+
import { useTimeout } from '../../../hooks/utils/useTimeout';
|
|
7
8
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
export const SUBMIT_FILTER_DATE_STROKE_TIME = 500;
|
|
10
10
|
function GridFilterInputDate(props) {
|
|
11
11
|
var _item$value, _rootProps$slotProps;
|
|
12
12
|
const {
|
|
@@ -21,28 +21,22 @@ function GridFilterInputDate(props) {
|
|
|
21
21
|
disabled
|
|
22
22
|
} = props,
|
|
23
23
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
24
|
-
const filterTimeout =
|
|
24
|
+
const filterTimeout = useTimeout();
|
|
25
25
|
const [filterValueState, setFilterValueState] = React.useState((_item$value = item.value) != null ? _item$value : '');
|
|
26
26
|
const [applying, setIsApplying] = React.useState(false);
|
|
27
27
|
const id = useId();
|
|
28
28
|
const rootProps = useGridRootProps();
|
|
29
29
|
const onFilterChange = React.useCallback(event => {
|
|
30
30
|
const value = event.target.value;
|
|
31
|
-
clearTimeout(filterTimeout.current);
|
|
32
31
|
setFilterValueState(String(value));
|
|
33
32
|
setIsApplying(true);
|
|
34
|
-
filterTimeout.
|
|
33
|
+
filterTimeout.start(rootProps.filterDebounceMs, () => {
|
|
35
34
|
applyValue(_extends({}, item, {
|
|
36
35
|
value
|
|
37
36
|
}));
|
|
38
37
|
setIsApplying(false);
|
|
39
|
-
}
|
|
40
|
-
}, [applyValue, item]);
|
|
41
|
-
React.useEffect(() => {
|
|
42
|
-
return () => {
|
|
43
|
-
clearTimeout(filterTimeout.current);
|
|
44
|
-
};
|
|
45
|
-
}, []);
|
|
38
|
+
});
|
|
39
|
+
}, [applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
|
|
46
40
|
React.useEffect(() => {
|
|
47
41
|
var _item$value2;
|
|
48
42
|
const itemValue = (_item$value2 = item.value) != null ? _item$value2 : '';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TextFieldProps } from '@mui/material/TextField';
|
|
3
3
|
import { GridFilterInputValueProps } from './GridFilterInputValueProps';
|
|
4
|
-
export declare const SUBMIT_FILTER_STROKE_TIME = 500;
|
|
5
4
|
export type GridTypeFilterInputValueProps = GridFilterInputValueProps & TextFieldProps & {
|
|
6
5
|
type?: 'text' | 'number' | 'date' | 'datetime-local';
|
|
7
6
|
clearButton?: React.ReactNode | null;
|
|
@@ -4,9 +4,9 @@ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "t
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_useId as useId } from '@mui/utils';
|
|
7
|
+
import { useTimeout } from '../../../hooks/utils/useTimeout';
|
|
7
8
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
export const SUBMIT_FILTER_STROKE_TIME = 500;
|
|
10
10
|
function GridFilterInputValue(props) {
|
|
11
11
|
var _item$value, _rootProps$slotProps;
|
|
12
12
|
const {
|
|
@@ -21,7 +21,7 @@ function GridFilterInputValue(props) {
|
|
|
21
21
|
InputProps
|
|
22
22
|
} = props,
|
|
23
23
|
others = _objectWithoutPropertiesLoose(props, _excluded);
|
|
24
|
-
const filterTimeout =
|
|
24
|
+
const filterTimeout = useTimeout();
|
|
25
25
|
const [filterValueState, setFilterValueState] = React.useState((_item$value = item.value) != null ? _item$value : '');
|
|
26
26
|
const [applying, setIsApplying] = React.useState(false);
|
|
27
27
|
const id = useId();
|
|
@@ -30,26 +30,24 @@ function GridFilterInputValue(props) {
|
|
|
30
30
|
const {
|
|
31
31
|
value
|
|
32
32
|
} = event.target;
|
|
33
|
-
clearTimeout(filterTimeout.current);
|
|
34
33
|
setFilterValueState(String(value));
|
|
35
34
|
setIsApplying(true);
|
|
36
|
-
filterTimeout.
|
|
37
|
-
|
|
38
|
-
value
|
|
39
|
-
|
|
35
|
+
filterTimeout.start(rootProps.filterDebounceMs, () => {
|
|
36
|
+
const newItem = _extends({}, item, {
|
|
37
|
+
value,
|
|
38
|
+
fromInput: id
|
|
39
|
+
});
|
|
40
|
+
applyValue(newItem);
|
|
40
41
|
setIsApplying(false);
|
|
41
|
-
}
|
|
42
|
-
}, [applyValue, item]);
|
|
42
|
+
});
|
|
43
|
+
}, [id, applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
|
|
43
44
|
React.useEffect(() => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const itemValue = (_item$value2 = item.value) != null ? _item$value2 : '';
|
|
51
|
-
setFilterValueState(String(itemValue));
|
|
52
|
-
}, [item.value]);
|
|
45
|
+
const itemPlusTag = item;
|
|
46
|
+
if (itemPlusTag.fromInput !== id) {
|
|
47
|
+
var _item$value2;
|
|
48
|
+
setFilterValueState(String((_item$value2 = item.value) != null ? _item$value2 : ''));
|
|
49
|
+
}
|
|
50
|
+
}, [id, item]);
|
|
53
51
|
return /*#__PURE__*/_jsx(rootProps.slots.baseTextField, _extends({
|
|
54
52
|
id: id,
|
|
55
53
|
label: apiRef.current.getLocaleText('filterPanelInputLabel'),
|
|
@@ -37,9 +37,7 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
|
|
|
37
37
|
disableRemoveAllButton = false
|
|
38
38
|
} = props,
|
|
39
39
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
40
|
-
const applyFilter =
|
|
41
|
-
apiRef.current.upsertFilterItem(item);
|
|
42
|
-
}, [apiRef]);
|
|
40
|
+
const applyFilter = apiRef.current.upsertFilterItem;
|
|
43
41
|
const applyFilterLogicOperator = React.useCallback(operator => {
|
|
44
42
|
apiRef.current.setFilterLogicOperator(operator);
|
|
45
43
|
}, [apiRef]);
|
|
@@ -16,7 +16,7 @@ export type GridToolbarQuickFilterProps = TextFieldProps & {
|
|
|
16
16
|
quickFilterFormatter?: (values: NonNullable<GridFilterModel['quickFilterValues']>) => string;
|
|
17
17
|
/**
|
|
18
18
|
* The debounce time in milliseconds.
|
|
19
|
-
* @default
|
|
19
|
+
* @default 150
|
|
20
20
|
*/
|
|
21
21
|
debounceMs?: number;
|
|
22
22
|
};
|
|
@@ -46,15 +46,15 @@ const defaultSearchValueParser = searchText => searchText.split(' ').filter(word
|
|
|
46
46
|
const defaultSearchValueFormatter = values => values.join(' ');
|
|
47
47
|
function GridToolbarQuickFilter(props) {
|
|
48
48
|
var _rootProps$slotProps, _rootProps$slotProps2;
|
|
49
|
+
const apiRef = useGridApiContext();
|
|
50
|
+
const rootProps = useGridRootProps();
|
|
51
|
+
const quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
|
|
49
52
|
const {
|
|
50
53
|
quickFilterParser = defaultSearchValueParser,
|
|
51
54
|
quickFilterFormatter = defaultSearchValueFormatter,
|
|
52
|
-
debounceMs =
|
|
55
|
+
debounceMs = rootProps.filterDebounceMs
|
|
53
56
|
} = props,
|
|
54
57
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
55
|
-
const apiRef = useGridApiContext();
|
|
56
|
-
const rootProps = useGridRootProps();
|
|
57
|
-
const quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
|
|
58
58
|
const [searchValue, setSearchValue] = React.useState(() => quickFilterFormatter(quickFilterValues != null ? quickFilterValues : []));
|
|
59
59
|
const prevQuickFilterValuesRef = React.useRef(quickFilterValues);
|
|
60
60
|
React.useEffect(() => {
|
|
@@ -117,7 +117,7 @@ process.env.NODE_ENV !== "production" ? GridToolbarQuickFilter.propTypes = {
|
|
|
117
117
|
// ----------------------------------------------------------------------
|
|
118
118
|
/**
|
|
119
119
|
* The debounce time in milliseconds.
|
|
120
|
-
* @default
|
|
120
|
+
* @default 150
|
|
121
121
|
*/
|
|
122
122
|
debounceMs: PropTypes.number,
|
|
123
123
|
/**
|
|
@@ -46,11 +46,6 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
46
46
|
// Returns a promise because updateColumns triggers state update and
|
|
47
47
|
// the new state needs to be in place before the grid can be sized correctly
|
|
48
48
|
const updateGridColumnsForPrint = React.useCallback((fields, allColumns) => new Promise(resolve => {
|
|
49
|
-
// TODO remove unused Promise
|
|
50
|
-
if (!fields && !allColumns) {
|
|
51
|
-
resolve();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
49
|
const exportedColumnFields = getColumnsToExport({
|
|
55
50
|
apiRef,
|
|
56
51
|
options: {
|
|
@@ -7,7 +7,13 @@ export const getColumnsToExport = ({
|
|
|
7
7
|
}) => {
|
|
8
8
|
const columns = gridColumnDefinitionsSelector(apiRef);
|
|
9
9
|
if (options.fields) {
|
|
10
|
-
return options.fields.
|
|
10
|
+
return options.fields.reduce((currentColumns, field) => {
|
|
11
|
+
const column = columns.find(col => col.field === field);
|
|
12
|
+
if (column) {
|
|
13
|
+
currentColumns.push(column);
|
|
14
|
+
}
|
|
15
|
+
return currentColumns;
|
|
16
|
+
}, []);
|
|
11
17
|
}
|
|
12
18
|
const validColumns = options.allColumns ? columns : gridVisibleColumnDefinitionsSelector(apiRef);
|
|
13
19
|
return validColumns.filter(column => !column.disableExport);
|
|
@@ -21,7 +21,7 @@ export declare const mergeStateWithFilterModel: (filterModel: GridFilterModel, d
|
|
|
21
21
|
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
22
22
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
23
23
|
*/
|
|
24
|
-
export declare const buildAggregatedFilterItemsApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity
|
|
24
|
+
export declare const buildAggregatedFilterItemsApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>, disableEval: boolean) => GridFilterItemApplierNotAggregated | null;
|
|
25
25
|
/**
|
|
26
26
|
* Generates a method to easily check if a row is matching the current quick filter.
|
|
27
27
|
* @param {GridRowIdGetter | undefined} getRowId The getter for row's id.
|
|
@@ -30,7 +30,7 @@ export declare const buildAggregatedFilterItemsApplier: (getRowId: GridRowIdGett
|
|
|
30
30
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
31
31
|
*/
|
|
32
32
|
export declare const buildAggregatedQuickFilterApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridFilterItemApplierNotAggregated | null;
|
|
33
|
-
export declare const buildAggregatedFilterApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity
|
|
33
|
+
export declare const buildAggregatedFilterApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>, disableEval: boolean) => GridAggregatedFilterItemApplier;
|
|
34
34
|
type FilterCache = {
|
|
35
35
|
cleanedFilterItems?: GridFilterItem[];
|
|
36
36
|
};
|
|
@@ -4,6 +4,13 @@ import { GLOBAL_API_REF, isInternalFilter } from '../../../colDef/utils';
|
|
|
4
4
|
import { getDefaultGridFilterModel } from './gridFilterState';
|
|
5
5
|
import { buildWarning } from '../../../utils/warning';
|
|
6
6
|
import { gridColumnFieldsSelector, gridColumnLookupSelector, gridVisibleColumnFieldsSelector } from '../columns';
|
|
7
|
+
let hasEval;
|
|
8
|
+
try {
|
|
9
|
+
// eslint-disable-next-line no-eval
|
|
10
|
+
hasEval = eval('true');
|
|
11
|
+
} catch (_) {
|
|
12
|
+
hasEval = false;
|
|
13
|
+
}
|
|
7
14
|
/**
|
|
8
15
|
* Adds default values to the optional fields of a filter items.
|
|
9
16
|
* @param {GridFilterItem} item The raw filter item.
|
|
@@ -127,7 +134,7 @@ let filterItemsApplierId = 1;
|
|
|
127
134
|
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
128
135
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
129
136
|
*/
|
|
130
|
-
export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef) => {
|
|
137
|
+
export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef, disableEval) => {
|
|
131
138
|
const {
|
|
132
139
|
items
|
|
133
140
|
} = filterModel;
|
|
@@ -135,22 +142,19 @@ export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef)
|
|
|
135
142
|
if (appliers.length === 0) {
|
|
136
143
|
return null;
|
|
137
144
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
//
|
|
152
|
-
// return resultPerItemId;
|
|
153
|
-
// };
|
|
145
|
+
if (!hasEval || disableEval) {
|
|
146
|
+
// This is the original logic, which is used if `eval()` is not supported (aka prevented by CSP).
|
|
147
|
+
return (row, shouldApplyFilter) => {
|
|
148
|
+
const resultPerItemId = {};
|
|
149
|
+
for (let i = 0; i < appliers.length; i += 1) {
|
|
150
|
+
const applier = appliers[i];
|
|
151
|
+
if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
|
|
152
|
+
resultPerItemId[applier.item.id] = applier.v7 ? applier.fn(row) : applier.fn(getRowId ? getRowId(row) : row.id);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return resultPerItemId;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
154
158
|
|
|
155
159
|
// We generate a new function with `eval()` to avoid expensive patterns for JS engines
|
|
156
160
|
// such as a dynamic object assignment, e.g. `{ [dynamicKey]: value }`.
|
|
@@ -260,8 +264,8 @@ export const buildAggregatedQuickFilterApplier = (getRowId, filterModel, apiRef)
|
|
|
260
264
|
return result;
|
|
261
265
|
};
|
|
262
266
|
};
|
|
263
|
-
export const buildAggregatedFilterApplier = (getRowId, filterModel, apiRef) => {
|
|
264
|
-
const isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(getRowId, filterModel, apiRef);
|
|
267
|
+
export const buildAggregatedFilterApplier = (getRowId, filterModel, apiRef, disableEval) => {
|
|
268
|
+
const isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(getRowId, filterModel, apiRef, disableEval);
|
|
265
269
|
const isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(getRowId, filterModel, apiRef);
|
|
266
270
|
return function isRowMatchingFilters(row, shouldApplyFilter, result) {
|
|
267
271
|
var _isRowMatchingFilterI, _isRowMatchingQuickFi;
|
|
@@ -8,4 +8,4 @@ export declare const filterStateInitializer: GridStateInitializer<Pick<DataGridP
|
|
|
8
8
|
* @requires useGridParamsApi (method)
|
|
9
9
|
* @requires useGridRows (event)
|
|
10
10
|
*/
|
|
11
|
-
export declare const useGridFilter: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'rows' | 'initialState' | 'filterModel' | 'getRowId' | 'onFilterModelChange' | 'filterMode' | 'disableMultipleColumnsFiltering' | 'slots' | 'slotProps' | 'disableColumnFilter'>) => void;
|
|
11
|
+
export declare const useGridFilter: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'rows' | 'initialState' | 'filterModel' | 'getRowId' | 'onFilterModelChange' | 'filterMode' | 'disableMultipleColumnsFiltering' | 'slots' | 'slotProps' | 'disableColumnFilter' | 'disableEval'>) => void;
|
|
@@ -61,7 +61,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
61
61
|
const updateFilteredRows = React.useCallback(() => {
|
|
62
62
|
apiRef.current.setState(state => {
|
|
63
63
|
const filterModel = gridFilterModelSelector(state, apiRef.current.instanceId);
|
|
64
|
-
const isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(props.getRowId, filterModel, apiRef) : null;
|
|
64
|
+
const isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(props.getRowId, filterModel, apiRef, props.disableEval) : null;
|
|
65
65
|
const filteringResult = apiRef.current.applyStrategyProcessor('filtering', {
|
|
66
66
|
isRowMatchingFilters,
|
|
67
67
|
filterModel: filterModel != null ? filterModel : getDefaultGridFilterModel()
|
|
@@ -75,7 +75,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
apiRef.current.publishEvent('filteredRowsSet');
|
|
78
|
-
}, [apiRef, props.filterMode, props.getRowId]);
|
|
78
|
+
}, [apiRef, props.filterMode, props.getRowId, props.disableEval]);
|
|
79
79
|
const addColumnMenuItem = React.useCallback((columnMenuItems, colDef) => {
|
|
80
80
|
if (colDef == null || colDef.filterable === false || props.disableColumnFilter) {
|
|
81
81
|
return columnMenuItems;
|
|
@@ -52,6 +52,16 @@ export const useGridRows = (apiRef, props) => {
|
|
|
52
52
|
}
|
|
53
53
|
return null;
|
|
54
54
|
}, [apiRef]);
|
|
55
|
+
const getRowIdProp = props.getRowId;
|
|
56
|
+
const getRowId = React.useCallback(row => {
|
|
57
|
+
if (GRID_ID_AUTOGENERATED in row) {
|
|
58
|
+
return row[GRID_ID_AUTOGENERATED];
|
|
59
|
+
}
|
|
60
|
+
if (getRowIdProp) {
|
|
61
|
+
return getRowIdProp(row);
|
|
62
|
+
}
|
|
63
|
+
return row.id;
|
|
64
|
+
}, [getRowIdProp]);
|
|
55
65
|
const lookup = React.useMemo(() => currentPage.rows.reduce((acc, {
|
|
56
66
|
id
|
|
57
67
|
}, index) => {
|
|
@@ -297,6 +307,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
297
307
|
}, [apiRef, props.signature, props.getRowId]);
|
|
298
308
|
const rowApi = {
|
|
299
309
|
getRow,
|
|
310
|
+
getRowId,
|
|
300
311
|
getRowModels,
|
|
301
312
|
getRowsCount,
|
|
302
313
|
getAllRowIds,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useLazyRef } from './useLazyRef';
|
|
2
|
+
import { useOnMount } from './useOnMount';
|
|
3
|
+
class Timeout {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.currentId = 0;
|
|
6
|
+
this.clear = () => {
|
|
7
|
+
if (this.currentId !== 0) {
|
|
8
|
+
clearTimeout(this.currentId);
|
|
9
|
+
this.currentId = 0;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
this.disposeEffect = () => {
|
|
13
|
+
return this.clear;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
static create() {
|
|
17
|
+
return new Timeout();
|
|
18
|
+
}
|
|
19
|
+
start(delay, fn) {
|
|
20
|
+
this.clear();
|
|
21
|
+
this.currentId = setTimeout(fn, delay);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function useTimeout() {
|
|
25
|
+
const timeout = useLazyRef(Timeout.create).current;
|
|
26
|
+
useOnMount(timeout.disposeEffect);
|
|
27
|
+
return timeout;
|
|
28
|
+
}
|
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { chainPropTypes } from '@mui/utils';
|
|
|
5
5
|
import { GridBody, GridFooterPlaceholder, GridHeader, GridRoot } from '../components';
|
|
6
6
|
import { GridContextProvider } from '../context/GridContextProvider';
|
|
7
7
|
import { useDataGridComponent } from './useDataGridComponent';
|
|
8
|
-
import { useDataGridProps } from './useDataGridProps';
|
|
8
|
+
import { useDataGridProps, DATA_GRID_PROPS_DEFAULT_VALUES } from './useDataGridProps';
|
|
9
9
|
import { DataGridVirtualScroller } from '../components/DataGridVirtualScroller';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -28,6 +28,18 @@ var DataGridRaw = /*#__PURE__*/React.forwardRef(function DataGrid(inProps, ref)
|
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
export var DataGrid = /*#__PURE__*/React.memo(DataGridRaw);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Remove at v7
|
|
34
|
+
* @deprecated
|
|
35
|
+
*/
|
|
36
|
+
export var SUBMIT_FILTER_STROKE_TIME = DATA_GRID_PROPS_DEFAULT_VALUES.filterDebounceMs;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Remove at v7
|
|
40
|
+
* @deprecated
|
|
41
|
+
*/
|
|
42
|
+
export var SUBMIT_FILTER_DATE_STROKE_TIME = DATA_GRID_PROPS_DEFAULT_VALUES.filterDebounceMs;
|
|
31
43
|
DataGridRaw.propTypes = {
|
|
32
44
|
// ----------------------------- Warning --------------------------------
|
|
33
45
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -143,6 +155,12 @@ DataGridRaw.propTypes = {
|
|
|
143
155
|
* @default false
|
|
144
156
|
*/
|
|
145
157
|
disableDensitySelector: PropTypes.bool,
|
|
158
|
+
/**
|
|
159
|
+
* If `true`, `eval()` is not used for performance optimization.
|
|
160
|
+
* @default false
|
|
161
|
+
* @ignore - do not document
|
|
162
|
+
*/
|
|
163
|
+
disableEval: PropTypes.bool,
|
|
146
164
|
/**
|
|
147
165
|
* If `true`, the selection on click on a row or cell is disabled.
|
|
148
166
|
* @default false
|
|
@@ -167,6 +185,11 @@ DataGridRaw.propTypes = {
|
|
|
167
185
|
columnGrouping: PropTypes.bool,
|
|
168
186
|
warnIfFocusStateIsNotSynced: PropTypes.bool
|
|
169
187
|
}),
|
|
188
|
+
/**
|
|
189
|
+
* The milliseconds delay to wait after a keystroke before triggering filtering.
|
|
190
|
+
* @default 150
|
|
191
|
+
*/
|
|
192
|
+
filterDebounceMs: PropTypes.number,
|
|
170
193
|
/**
|
|
171
194
|
* Filtering can be processed on the server or client-side.
|
|
172
195
|
* Set it to 'server' if you would like to handle filtering on the server-side.
|
|
@@ -38,6 +38,7 @@ export var DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
38
38
|
disableColumnMenu: false,
|
|
39
39
|
disableColumnSelector: false,
|
|
40
40
|
disableDensitySelector: false,
|
|
41
|
+
disableEval: false,
|
|
41
42
|
disableMultipleColumnsFiltering: false,
|
|
42
43
|
disableMultipleRowSelection: false,
|
|
43
44
|
disableMultipleColumnsSorting: false,
|
|
@@ -45,6 +46,7 @@ export var DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
45
46
|
disableVirtualization: false,
|
|
46
47
|
editMode: GridEditModes.Cell,
|
|
47
48
|
filterMode: 'client',
|
|
49
|
+
filterDebounceMs: 150,
|
|
48
50
|
columnHeaderHeight: 56,
|
|
49
51
|
hideFooter: false,
|
|
50
52
|
hideFooterPagination: false,
|