@mui/x-data-grid 6.11.1 → 6.12.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 +154 -31
- package/DataGrid/DataGrid.d.ts +10 -0
- package/DataGrid/DataGrid.js +24 -1
- package/DataGrid/useDataGridProps.js +2 -0
- package/README.md +1 -1
- package/components/cell/GridActionsCell.js +1 -1
- package/components/cell/GridEditSingleSelectCell.js +1 -1
- package/components/columnHeaders/GridColumnGroupHeader.js +1 -1
- package/components/columnHeaders/GridColumnHeaderItem.js +1 -1
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -1
- package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterForm.js +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/GridToolbarColumnsButton.js +1 -1
- package/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/components/toolbar/GridToolbarExport.js +2 -2
- package/components/toolbar/GridToolbarExportContainer.js +1 -1
- package/components/toolbar/GridToolbarFilterButton.js +1 -1
- package/components/toolbar/GridToolbarQuickFilter.d.ts +1 -1
- package/components/toolbar/GridToolbarQuickFilter.js +5 -5
- package/hooks/features/export/useGridPrintExport.js +11 -8
- 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/pagination/useGridPagination.d.ts +5 -0
- package/hooks/features/pagination/useGridPagination.js +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/hooks/features/rows/useGridRows.js +11 -0
- package/hooks/features/rows/useGridRowsMeta.js +2 -2
- package/hooks/utils/useGridApiEventHandler.js +5 -5
- package/hooks/utils/useLazyRef.js +2 -0
- package/hooks/utils/useTimeout.d.ts +9 -0
- package/hooks/utils/useTimeout.js +28 -0
- package/index.js +1 -1
- package/joy/joySlots.js +2 -2
- package/legacy/DataGrid/DataGrid.js +24 -1
- package/legacy/DataGrid/useDataGridProps.js +2 -0
- package/legacy/components/cell/GridActionsCell.js +1 -1
- package/legacy/components/cell/GridEditSingleSelectCell.js +1 -1
- package/legacy/components/columnHeaders/GridColumnGroupHeader.js +1 -1
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +1 -1
- package/legacy/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -1
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/legacy/components/panel/filterPanel/GridFilterForm.js +1 -1
- 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/GridToolbarColumnsButton.js +1 -1
- package/legacy/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/legacy/components/toolbar/GridToolbarExport.js +2 -2
- package/legacy/components/toolbar/GridToolbarExportContainer.js +1 -1
- package/legacy/components/toolbar/GridToolbarFilterButton.js +1 -1
- package/legacy/components/toolbar/GridToolbarQuickFilter.js +5 -5
- package/legacy/hooks/features/export/useGridPrintExport.js +12 -9
- 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/pagination/useGridPagination.js +1 -1
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/legacy/hooks/features/rows/useGridRows.js +11 -0
- package/legacy/hooks/features/rows/useGridRowsMeta.js +2 -2
- package/legacy/hooks/utils/useGridApiEventHandler.js +5 -5
- package/legacy/hooks/utils/useLazyRef.js +2 -0
- package/legacy/hooks/utils/useTimeout.js +38 -0
- package/legacy/index.js +1 -1
- package/legacy/joy/joySlots.js +2 -2
- package/legacy/locales/esES.js +26 -28
- package/legacy/locales/ukUA.js +25 -27
- package/legacy/locales/zhCN.js +25 -27
- package/legacy/locales/zhTW.js +34 -38
- package/legacy/utils/createSelector.js +1 -1
- package/locales/esES.js +26 -28
- package/locales/ukUA.js +25 -27
- 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 +9 -6
- 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/pagination/useGridPagination.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +11 -0
- package/modern/hooks/utils/useLazyRef.js +2 -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/ukUA.js +25 -27
- 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 +9 -6
- 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/pagination/useGridPagination.js +2 -1
- package/node/hooks/features/rows/useGridRows.js +11 -0
- package/node/hooks/utils/useLazyRef.js +2 -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/ukUA.js +25 -27
- package/node/locales/zhCN.js +25 -27
- package/node/locales/zhTW.js +34 -38
- package/package.json +3 -3
- package/utils/createSelector.js +1 -1
|
@@ -162,6 +162,12 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
162
162
|
* @default false
|
|
163
163
|
*/
|
|
164
164
|
disableDensitySelector: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* If `true`, `eval()` is not used for performance optimization.
|
|
167
|
+
* @default false
|
|
168
|
+
* @ignore - do not document
|
|
169
|
+
*/
|
|
170
|
+
disableEval: boolean;
|
|
165
171
|
/**
|
|
166
172
|
* If `true`, filtering with multiple columns is disabled.
|
|
167
173
|
* @default false
|
|
@@ -198,6 +204,11 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
198
204
|
* @default "client"
|
|
199
205
|
*/
|
|
200
206
|
filterMode: GridFeatureMode;
|
|
207
|
+
/**
|
|
208
|
+
* The milliseconds delay to wait after a keystroke before triggering filtering.
|
|
209
|
+
* @default 150
|
|
210
|
+
*/
|
|
211
|
+
filterDebounceMs: number;
|
|
201
212
|
/**
|
|
202
213
|
* Sets the height in pixel of the column headers in the grid.
|
|
203
214
|
* @default 56
|
|
@@ -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,
|
|
@@ -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
|
const {
|
|
12
12
|
item,
|
|
@@ -20,28 +20,22 @@ function GridFilterInputDate(props) {
|
|
|
20
20
|
disabled
|
|
21
21
|
} = props,
|
|
22
22
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
23
|
-
const filterTimeout =
|
|
23
|
+
const filterTimeout = useTimeout();
|
|
24
24
|
const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
|
|
25
25
|
const [applying, setIsApplying] = React.useState(false);
|
|
26
26
|
const id = useId();
|
|
27
27
|
const rootProps = useGridRootProps();
|
|
28
28
|
const onFilterChange = React.useCallback(event => {
|
|
29
29
|
const value = event.target.value;
|
|
30
|
-
clearTimeout(filterTimeout.current);
|
|
31
30
|
setFilterValueState(String(value));
|
|
32
31
|
setIsApplying(true);
|
|
33
|
-
filterTimeout.
|
|
32
|
+
filterTimeout.start(rootProps.filterDebounceMs, () => {
|
|
34
33
|
applyValue(_extends({}, item, {
|
|
35
34
|
value
|
|
36
35
|
}));
|
|
37
36
|
setIsApplying(false);
|
|
38
|
-
}
|
|
39
|
-
}, [applyValue, item]);
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
return () => {
|
|
42
|
-
clearTimeout(filterTimeout.current);
|
|
43
|
-
};
|
|
44
|
-
}, []);
|
|
37
|
+
});
|
|
38
|
+
}, [applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
|
|
45
39
|
React.useEffect(() => {
|
|
46
40
|
const itemValue = item.value ?? '';
|
|
47
41
|
setFilterValueState(String(itemValue));
|
|
@@ -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
|
const {
|
|
12
12
|
item,
|
|
@@ -20,7 +20,7 @@ function GridFilterInputValue(props) {
|
|
|
20
20
|
InputProps
|
|
21
21
|
} = props,
|
|
22
22
|
others = _objectWithoutPropertiesLoose(props, _excluded);
|
|
23
|
-
const filterTimeout =
|
|
23
|
+
const filterTimeout = useTimeout();
|
|
24
24
|
const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
|
|
25
25
|
const [applying, setIsApplying] = React.useState(false);
|
|
26
26
|
const id = useId();
|
|
@@ -29,25 +29,23 @@ function GridFilterInputValue(props) {
|
|
|
29
29
|
const {
|
|
30
30
|
value
|
|
31
31
|
} = event.target;
|
|
32
|
-
clearTimeout(filterTimeout.current);
|
|
33
32
|
setFilterValueState(String(value));
|
|
34
33
|
setIsApplying(true);
|
|
35
|
-
filterTimeout.
|
|
36
|
-
|
|
37
|
-
value
|
|
38
|
-
|
|
34
|
+
filterTimeout.start(rootProps.filterDebounceMs, () => {
|
|
35
|
+
const newItem = _extends({}, item, {
|
|
36
|
+
value,
|
|
37
|
+
fromInput: id
|
|
38
|
+
});
|
|
39
|
+
applyValue(newItem);
|
|
39
40
|
setIsApplying(false);
|
|
40
|
-
}
|
|
41
|
-
}, [applyValue, item]);
|
|
41
|
+
});
|
|
42
|
+
}, [id, applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
|
|
42
43
|
React.useEffect(() => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const itemValue = item.value ?? '';
|
|
49
|
-
setFilterValueState(String(itemValue));
|
|
50
|
-
}, [item.value]);
|
|
44
|
+
const itemPlusTag = item;
|
|
45
|
+
if (itemPlusTag.fromInput !== id) {
|
|
46
|
+
setFilterValueState(String(item.value ?? ''));
|
|
47
|
+
}
|
|
48
|
+
}, [id, item]);
|
|
51
49
|
return /*#__PURE__*/_jsx(rootProps.slots.baseTextField, _extends({
|
|
52
50
|
id: id,
|
|
53
51
|
label: apiRef.current.getLocaleText('filterPanelInputLabel'),
|
|
@@ -36,9 +36,7 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
|
|
|
36
36
|
disableRemoveAllButton = false
|
|
37
37
|
} = props,
|
|
38
38
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
39
|
-
const applyFilter =
|
|
40
|
-
apiRef.current.upsertFilterItem(item);
|
|
41
|
-
}, [apiRef]);
|
|
39
|
+
const applyFilter = apiRef.current.upsertFilterItem;
|
|
42
40
|
const applyFilterLogicOperator = React.useCallback(operator => {
|
|
43
41
|
apiRef.current.setFilterLogicOperator(operator);
|
|
44
42
|
}, [apiRef]);
|
|
@@ -45,15 +45,15 @@ const GridToolbarQuickFilterRoot = styled(TextField, {
|
|
|
45
45
|
const defaultSearchValueParser = searchText => searchText.split(' ').filter(word => word !== '');
|
|
46
46
|
const defaultSearchValueFormatter = values => values.join(' ');
|
|
47
47
|
function GridToolbarQuickFilter(props) {
|
|
48
|
+
const apiRef = useGridApiContext();
|
|
49
|
+
const rootProps = useGridRootProps();
|
|
50
|
+
const quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
|
|
48
51
|
const {
|
|
49
52
|
quickFilterParser = defaultSearchValueParser,
|
|
50
53
|
quickFilterFormatter = defaultSearchValueFormatter,
|
|
51
|
-
debounceMs =
|
|
54
|
+
debounceMs = rootProps.filterDebounceMs
|
|
52
55
|
} = props,
|
|
53
56
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
54
|
-
const apiRef = useGridApiContext();
|
|
55
|
-
const rootProps = useGridRootProps();
|
|
56
|
-
const quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
|
|
57
57
|
const [searchValue, setSearchValue] = React.useState(() => quickFilterFormatter(quickFilterValues ?? []));
|
|
58
58
|
const prevQuickFilterValuesRef = React.useRef(quickFilterValues);
|
|
59
59
|
React.useEffect(() => {
|
|
@@ -116,7 +116,7 @@ process.env.NODE_ENV !== "production" ? GridToolbarQuickFilter.propTypes = {
|
|
|
116
116
|
// ----------------------------------------------------------------------
|
|
117
117
|
/**
|
|
118
118
|
* The debounce time in milliseconds.
|
|
119
|
-
* @default
|
|
119
|
+
* @default 150
|
|
120
120
|
*/
|
|
121
121
|
debounceMs: PropTypes.number,
|
|
122
122
|
/**
|
|
@@ -8,6 +8,7 @@ import { gridClasses } from '../../../constants/gridClasses';
|
|
|
8
8
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
9
9
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
10
10
|
import { getColumnsToExport } from './utils';
|
|
11
|
+
import { mergeStateWithPaginationModel } from '../pagination/useGridPagination';
|
|
11
12
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
12
13
|
import { GridPrintExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
|
|
13
14
|
import { getTotalHeaderHeight } from '../columns/gridColumnsUtils';
|
|
@@ -46,11 +47,6 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
46
47
|
// Returns a promise because updateColumns triggers state update and
|
|
47
48
|
// the new state needs to be in place before the grid can be sized correctly
|
|
48
49
|
const updateGridColumnsForPrint = React.useCallback((fields, allColumns) => new Promise(resolve => {
|
|
49
|
-
// TODO remove unused Promise
|
|
50
|
-
if (!fields && !allColumns) {
|
|
51
|
-
resolve();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
50
|
const exportedColumnFields = getColumnsToExport({
|
|
55
51
|
apiRef,
|
|
56
52
|
options: {
|
|
@@ -193,7 +189,14 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
193
189
|
previousColumnVisibility.current = gridColumnVisibilityModelSelector(apiRef);
|
|
194
190
|
if (props.pagination) {
|
|
195
191
|
const visibleRowCount = gridExpandedRowCountSelector(apiRef);
|
|
196
|
-
|
|
192
|
+
const paginationModel = {
|
|
193
|
+
page: 0,
|
|
194
|
+
pageSize: visibleRowCount
|
|
195
|
+
};
|
|
196
|
+
apiRef.current.updateControlState('pagination',
|
|
197
|
+
// Using signature `DataGridPro` to allow more than 100 rows in the print export
|
|
198
|
+
mergeStateWithPaginationModel(visibleRowCount, 'DataGridPro', paginationModel));
|
|
199
|
+
apiRef.current.forceUpdate();
|
|
197
200
|
}
|
|
198
201
|
await updateGridColumnsForPrint(options?.fields, options?.allColumns);
|
|
199
202
|
apiRef.current.unstable_disableVirtualization();
|
|
@@ -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);
|
|
@@ -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.
|
|
@@ -126,7 +133,7 @@ let filterItemsApplierId = 1;
|
|
|
126
133
|
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
127
134
|
* @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.
|
|
128
135
|
*/
|
|
129
|
-
export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef) => {
|
|
136
|
+
export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef, disableEval) => {
|
|
130
137
|
const {
|
|
131
138
|
items
|
|
132
139
|
} = filterModel;
|
|
@@ -134,22 +141,19 @@ export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef)
|
|
|
134
141
|
if (appliers.length === 0) {
|
|
135
142
|
return null;
|
|
136
143
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
//
|
|
151
|
-
// return resultPerItemId;
|
|
152
|
-
// };
|
|
144
|
+
if (!hasEval || disableEval) {
|
|
145
|
+
// This is the original logic, which is used if `eval()` is not supported (aka prevented by CSP).
|
|
146
|
+
return (row, shouldApplyFilter) => {
|
|
147
|
+
const resultPerItemId = {};
|
|
148
|
+
for (let i = 0; i < appliers.length; i += 1) {
|
|
149
|
+
const applier = appliers[i];
|
|
150
|
+
if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
|
|
151
|
+
resultPerItemId[applier.item.id] = applier.v7 ? applier.fn(row) : applier.fn(getRowId ? getRowId(row) : row.id);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return resultPerItemId;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
153
157
|
|
|
154
158
|
// We generate a new function with `eval()` to avoid expensive patterns for JS engines
|
|
155
159
|
// such as a dynamic object assignment, e.g. `{ [dynamicKey]: value }`.
|
|
@@ -257,8 +261,8 @@ export const buildAggregatedQuickFilterApplier = (getRowId, filterModel, apiRef)
|
|
|
257
261
|
return result;
|
|
258
262
|
};
|
|
259
263
|
};
|
|
260
|
-
export const buildAggregatedFilterApplier = (getRowId, filterModel, apiRef) => {
|
|
261
|
-
const isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(getRowId, filterModel, apiRef);
|
|
264
|
+
export const buildAggregatedFilterApplier = (getRowId, filterModel, apiRef, disableEval) => {
|
|
265
|
+
const isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(getRowId, filterModel, apiRef, disableEval);
|
|
262
266
|
const isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(getRowId, filterModel, apiRef);
|
|
263
267
|
return function isRowMatchingFilters(row, shouldApplyFilter, result) {
|
|
264
268
|
result.passingFilterItems = isRowMatchingFilterItems?.(row, shouldApplyFilter) ?? null;
|
|
@@ -59,7 +59,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
59
59
|
const updateFilteredRows = React.useCallback(() => {
|
|
60
60
|
apiRef.current.setState(state => {
|
|
61
61
|
const filterModel = gridFilterModelSelector(state, apiRef.current.instanceId);
|
|
62
|
-
const isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(props.getRowId, filterModel, apiRef) : null;
|
|
62
|
+
const isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(props.getRowId, filterModel, apiRef, props.disableEval) : null;
|
|
63
63
|
const filteringResult = apiRef.current.applyStrategyProcessor('filtering', {
|
|
64
64
|
isRowMatchingFilters,
|
|
65
65
|
filterModel: filterModel ?? getDefaultGridFilterModel()
|
|
@@ -73,7 +73,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
apiRef.current.publishEvent('filteredRowsSet');
|
|
76
|
-
}, [apiRef, props.filterMode, props.getRowId]);
|
|
76
|
+
}, [apiRef, props.filterMode, props.getRowId, props.disableEval]);
|
|
77
77
|
const addColumnMenuItem = React.useCallback((columnMenuItems, colDef) => {
|
|
78
78
|
if (colDef == null || colDef.filterable === false || props.disableColumnFilter) {
|
|
79
79
|
return columnMenuItems;
|
|
@@ -16,7 +16,7 @@ export const paginationStateInitializer = (state, props) => {
|
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
|
-
const mergeStateWithPaginationModel = (rowCount, signature, paginationModelProp) => paginationState => {
|
|
19
|
+
export const mergeStateWithPaginationModel = (rowCount, signature, paginationModelProp) => paginationState => {
|
|
20
20
|
let paginationModel = paginationState.paginationModel;
|
|
21
21
|
const pageSize = paginationModelProp?.pageSize ?? paginationModel.pageSize;
|
|
22
22
|
const pageCount = getPageCount(rowCount, pageSize);
|
|
@@ -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) => {
|
|
@@ -291,6 +301,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
291
301
|
}, [apiRef, props.signature, props.getRowId]);
|
|
292
302
|
const rowApi = {
|
|
293
303
|
getRow,
|
|
304
|
+
getRowId,
|
|
294
305
|
getRowModels,
|
|
295
306
|
getRowsCount,
|
|
296
307
|
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/modern/index.js
CHANGED
package/modern/locales/esES.js
CHANGED
|
@@ -57,37 +57,35 @@ const esESGrid = {
|
|
|
57
57
|
filterOperatorOnOrAfter: 'es en o posterior',
|
|
58
58
|
filterOperatorBefore: 'es anterior',
|
|
59
59
|
filterOperatorOnOrBefore: 'es en o anterior',
|
|
60
|
-
filterOperatorIsEmpty: '
|
|
60
|
+
filterOperatorIsEmpty: 'esta vacío',
|
|
61
61
|
filterOperatorIsNotEmpty: 'no esta vacío',
|
|
62
62
|
filterOperatorIsAnyOf: 'es cualquiera de',
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
'filterOperator=': '=',
|
|
64
|
+
'filterOperator!=': '!=',
|
|
65
|
+
'filterOperator>': '>',
|
|
66
|
+
'filterOperator>=': '>=',
|
|
67
|
+
'filterOperator<': '<',
|
|
68
|
+
'filterOperator<=': '<=',
|
|
70
69
|
// Header filter operators text
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
70
|
+
headerFilterOperatorContains: 'Contiene',
|
|
71
|
+
headerFilterOperatorEquals: 'Es igual a',
|
|
72
|
+
headerFilterOperatorStartsWith: 'Comienza con',
|
|
73
|
+
headerFilterOperatorEndsWith: 'Termina con',
|
|
74
|
+
headerFilterOperatorIs: 'Es',
|
|
75
|
+
headerFilterOperatorNot: 'No es',
|
|
76
|
+
headerFilterOperatorAfter: 'Esta después de',
|
|
77
|
+
headerFilterOperatorOnOrAfter: 'Esta en o después de',
|
|
78
|
+
headerFilterOperatorBefore: 'Esta antes de',
|
|
79
|
+
headerFilterOperatorOnOrBefore: 'Esta en o antes de',
|
|
80
|
+
headerFilterOperatorIsEmpty: 'Esta vacío',
|
|
81
|
+
headerFilterOperatorIsNotEmpty: 'No esta vacío',
|
|
82
|
+
headerFilterOperatorIsAnyOf: 'Es cualquiera de',
|
|
83
|
+
'headerFilterOperator=': 'Es igual a',
|
|
84
|
+
'headerFilterOperator!=': 'Es diferente a',
|
|
85
|
+
'headerFilterOperator>': 'Es mayor que',
|
|
86
|
+
'headerFilterOperator>=': 'Es mayor o igual que',
|
|
87
|
+
'headerFilterOperator<': 'Es menor que',
|
|
88
|
+
'headerFilterOperator<=': 'Es menor o igual que',
|
|
91
89
|
// Filter values text
|
|
92
90
|
filterValueAny: 'cualquiera',
|
|
93
91
|
filterValueTrue: 'verdadero',
|
package/modern/locales/ukUA.js
CHANGED
|
@@ -74,34 +74,32 @@ const ukUAGrid = {
|
|
|
74
74
|
filterOperatorIsEmpty: 'порожній',
|
|
75
75
|
filterOperatorIsNotEmpty: 'не порожній',
|
|
76
76
|
filterOperatorIsAnyOf: 'будь-що із',
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
'filterOperator=': '=',
|
|
78
|
+
'filterOperator!=': '!=',
|
|
79
|
+
'filterOperator>': '>',
|
|
80
|
+
'filterOperator>=': '>=',
|
|
81
|
+
'filterOperator<': '<',
|
|
82
|
+
'filterOperator<=': '<=',
|
|
84
83
|
// Header filter operators text
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
84
|
+
headerFilterOperatorContains: 'Містить',
|
|
85
|
+
headerFilterOperatorEquals: 'Дорівнює',
|
|
86
|
+
headerFilterOperatorStartsWith: 'Починається з',
|
|
87
|
+
headerFilterOperatorEndsWith: 'Закінчується на',
|
|
88
|
+
headerFilterOperatorIs: 'Дорівнює',
|
|
89
|
+
headerFilterOperatorNot: 'Не дорівнює',
|
|
90
|
+
headerFilterOperatorAfter: 'Після',
|
|
91
|
+
headerFilterOperatorOnOrAfter: 'Після (включаючи)',
|
|
92
|
+
headerFilterOperatorBefore: 'Раніше',
|
|
93
|
+
headerFilterOperatorOnOrBefore: 'Раніше (включаючи)',
|
|
94
|
+
headerFilterOperatorIsEmpty: 'Порожнє',
|
|
95
|
+
headerFilterOperatorIsNotEmpty: 'Не порожнє',
|
|
96
|
+
headerFilterOperatorIsAnyOf: 'Будь-що із',
|
|
97
|
+
'headerFilterOperator=': 'Дорівнює',
|
|
98
|
+
'headerFilterOperator!=': 'Не дорівнює',
|
|
99
|
+
'headerFilterOperator>': 'Більше ніж',
|
|
100
|
+
'headerFilterOperator>=': 'Більше або дорівнює',
|
|
101
|
+
'headerFilterOperator<': 'Менше ніж',
|
|
102
|
+
'headerFilterOperator<=': 'Менше або дорівнює',
|
|
105
103
|
// Filter values text
|
|
106
104
|
filterValueAny: 'будь-який',
|
|
107
105
|
filterValueTrue: 'так',
|