@mui/x-data-grid 6.9.0 → 6.9.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 +136 -8
- package/DataGrid/DataGrid.js +4 -1
- package/DataGrid/useDataGridComponent.js +1 -1
- package/README.md +1 -1
- package/colDef/gridActionsColDef.js +2 -1
- package/colDef/gridBooleanColDef.js +1 -0
- package/colDef/gridBooleanOperators.js +5 -6
- package/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/colDef/gridDateColDef.js +2 -0
- package/colDef/gridDateOperators.js +14 -19
- package/colDef/gridNumericColDef.js +3 -1
- package/colDef/gridNumericOperators.d.ts +2 -2
- package/colDef/gridNumericOperators.js +24 -43
- package/colDef/gridSingleSelectOperators.js +9 -14
- package/colDef/gridStringColDef.js +3 -1
- package/colDef/gridStringOperators.d.ts +2 -2
- package/colDef/gridStringOperators.js +22 -36
- package/colDef/utils.d.ts +21 -0
- package/colDef/utils.js +51 -0
- package/components/GridPagination.js +16 -3
- package/components/cell/GridCell.js +1 -1
- package/components/cell/GridEditDateCell.js +1 -1
- package/components/cell/GridEditInputCell.js +3 -3
- package/hooks/features/columns/gridColumnsUtils.js +2 -1
- package/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/hooks/features/editing/useGridEditing.js +2 -1
- package/hooks/features/editing/useGridRowEditing.js +2 -2
- package/hooks/features/filter/gridFilterState.d.ts +6 -5
- package/hooks/features/filter/gridFilterUtils.d.ts +8 -6
- package/hooks/features/filter/gridFilterUtils.js +115 -57
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.js +34 -25
- package/hooks/features/pagination/gridPaginationSelector.js +10 -5
- package/hooks/features/rows/gridRowsUtils.d.ts +1 -0
- package/hooks/features/rows/gridRowsUtils.js +1 -0
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -1
- package/hooks/features/rows/useGridParamsApi.js +31 -1
- package/hooks/features/rows/useGridRows.js +4 -3
- package/index.js +1 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +1 -0
- package/joy/joySlots.js +29 -8
- package/legacy/DataGrid/DataGrid.js +4 -1
- package/legacy/DataGrid/useDataGridComponent.js +1 -1
- package/legacy/colDef/gridActionsColDef.js +2 -1
- package/legacy/colDef/gridBooleanColDef.js +1 -0
- package/legacy/colDef/gridBooleanOperators.js +5 -5
- package/legacy/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/legacy/colDef/gridDateColDef.js +2 -0
- package/legacy/colDef/gridDateOperators.js +14 -16
- package/legacy/colDef/gridNumericColDef.js +3 -1
- package/legacy/colDef/gridNumericOperators.js +24 -33
- package/legacy/colDef/gridSingleSelectOperators.js +9 -11
- package/legacy/colDef/gridStringColDef.js +3 -1
- package/legacy/colDef/gridStringOperators.js +22 -28
- package/legacy/colDef/utils.js +51 -0
- package/legacy/components/GridPagination.js +16 -3
- package/legacy/components/cell/GridCell.js +2 -1
- package/legacy/components/cell/GridEditDateCell.js +1 -1
- package/legacy/components/cell/GridEditInputCell.js +3 -3
- package/legacy/hooks/features/columns/gridColumnsUtils.js +4 -1
- package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/legacy/hooks/features/editing/useGridEditing.js +2 -1
- package/legacy/hooks/features/editing/useGridRowEditing.js +2 -2
- package/legacy/hooks/features/filter/gridFilterUtils.js +115 -65
- package/legacy/hooks/features/filter/useGridFilter.js +32 -24
- package/legacy/hooks/features/pagination/gridPaginationSelector.js +10 -5
- package/legacy/hooks/features/rows/gridRowsUtils.js +1 -0
- package/legacy/hooks/features/rows/useGridParamsApi.js +29 -1
- package/legacy/hooks/features/rows/useGridRows.js +15 -16
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -0
- package/legacy/joy/joySlots.js +29 -8
- package/legacy/locales/esES.js +3 -3
- package/legacy/locales/huHU.js +23 -25
- package/legacy/locales/roRO.js +34 -38
- package/locales/esES.js +3 -3
- package/locales/huHU.js +23 -25
- package/locales/roRO.js +34 -38
- package/models/api/gridEditingApi.d.ts +1 -1
- package/models/api/gridParamsApi.d.ts +22 -1
- package/models/colDef/gridColDef.d.ts +13 -1
- package/models/gridFilterOperator.d.ts +17 -2
- package/models/gridRows.d.ts +1 -1
- package/models/props/DataGridProps.d.ts +4 -1
- package/modern/DataGrid/DataGrid.js +4 -1
- package/modern/DataGrid/useDataGridComponent.js +1 -1
- package/modern/colDef/gridActionsColDef.js +2 -1
- package/modern/colDef/gridBooleanColDef.js +1 -0
- package/modern/colDef/gridBooleanOperators.js +5 -6
- package/modern/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/modern/colDef/gridDateColDef.js +2 -0
- package/modern/colDef/gridDateOperators.js +14 -19
- package/modern/colDef/gridNumericColDef.js +3 -1
- package/modern/colDef/gridNumericOperators.js +24 -43
- package/modern/colDef/gridSingleSelectOperators.js +9 -14
- package/modern/colDef/gridStringColDef.js +3 -1
- package/modern/colDef/gridStringOperators.js +22 -36
- package/modern/colDef/utils.js +51 -0
- package/modern/components/GridPagination.js +16 -2
- package/modern/components/cell/GridCell.js +1 -1
- package/modern/components/cell/GridEditDateCell.js +1 -1
- package/modern/components/cell/GridEditInputCell.js +3 -3
- package/modern/hooks/features/columns/gridColumnsUtils.js +2 -1
- package/modern/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/modern/hooks/features/editing/useGridEditing.js +1 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +2 -2
- package/modern/hooks/features/filter/gridFilterUtils.js +110 -54
- package/modern/hooks/features/filter/useGridFilter.js +34 -25
- package/modern/hooks/features/pagination/gridPaginationSelector.js +9 -5
- package/modern/hooks/features/rows/gridRowsUtils.js +1 -0
- package/modern/hooks/features/rows/useGridParamsApi.js +29 -1
- package/modern/hooks/features/rows/useGridRows.js +4 -3
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/joy/joySlots.js +29 -7
- package/modern/locales/esES.js +3 -3
- package/modern/locales/huHU.js +23 -25
- package/modern/locales/roRO.js +34 -38
- package/node/DataGrid/DataGrid.js +4 -1
- package/node/DataGrid/useDataGridComponent.js +1 -1
- package/node/colDef/gridActionsColDef.js +2 -1
- package/node/colDef/gridBooleanColDef.js +1 -0
- package/node/colDef/gridBooleanOperators.js +5 -6
- package/node/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/node/colDef/gridDateColDef.js +2 -0
- package/node/colDef/gridDateOperators.js +14 -19
- package/node/colDef/gridNumericColDef.js +3 -1
- package/node/colDef/gridNumericOperators.js +24 -43
- package/node/colDef/gridSingleSelectOperators.js +9 -14
- package/node/colDef/gridStringColDef.js +3 -1
- package/node/colDef/gridStringOperators.js +22 -36
- package/node/colDef/utils.js +64 -0
- package/node/components/GridPagination.js +16 -2
- package/node/components/cell/GridCell.js +1 -1
- package/node/components/cell/GridEditDateCell.js +1 -1
- package/node/components/cell/GridEditInputCell.js +3 -3
- package/node/hooks/features/columns/gridColumnsUtils.js +2 -1
- package/node/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/node/hooks/features/editing/useGridEditing.js +1 -1
- package/node/hooks/features/editing/useGridRowEditing.js +1 -1
- package/node/hooks/features/filter/gridFilterUtils.js +110 -54
- package/node/hooks/features/filter/useGridFilter.js +33 -24
- package/node/hooks/features/pagination/gridPaginationSelector.js +9 -5
- package/node/hooks/features/rows/gridRowsUtils.js +3 -1
- package/node/hooks/features/rows/useGridParamsApi.js +29 -1
- package/node/hooks/features/rows/useGridRows.js +3 -2
- package/node/index.js +1 -1
- package/node/internals/index.js +13 -1
- package/node/joy/joySlots.js +29 -7
- package/node/locales/esES.js +3 -3
- package/node/locales/huHU.js +23 -25
- package/node/locales/roRO.js +34 -38
- package/package.json +2 -2
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
import { GridFilterInputValue } from '../components/panel/filterPanel/GridFilterInputValue';
|
|
2
2
|
import { escapeRegExp } from '../utils/utils';
|
|
3
3
|
import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
|
|
4
|
-
|
|
4
|
+
import { convertLegacyOperators, tagInternalFilter } from './utils';
|
|
5
|
+
export const getGridStringQuickFilterFn = tagInternalFilter(value => {
|
|
5
6
|
if (!value) {
|
|
6
7
|
return null;
|
|
7
8
|
}
|
|
8
9
|
const filterRegex = new RegExp(escapeRegExp(value), 'i');
|
|
9
|
-
return ({
|
|
10
|
-
|
|
11
|
-
}) => {
|
|
10
|
+
return (_, row, column, apiRef) => {
|
|
11
|
+
const columnValue = apiRef.current.getRowFormattedValue(row, column);
|
|
12
12
|
return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
|
|
13
13
|
};
|
|
14
|
-
};
|
|
15
|
-
export const getGridStringOperators = (disableTrim = false) => [{
|
|
14
|
+
});
|
|
15
|
+
export const getGridStringOperators = (disableTrim = false) => convertLegacyOperators([{
|
|
16
16
|
value: 'contains',
|
|
17
|
-
|
|
17
|
+
getApplyFilterFnV7: filterItem => {
|
|
18
18
|
if (!filterItem.value) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
21
|
const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();
|
|
22
22
|
const filterRegex = new RegExp(escapeRegExp(filterItemValue), 'i');
|
|
23
|
-
return
|
|
24
|
-
value
|
|
25
|
-
}) => {
|
|
26
|
-
return value != null ? filterRegex.test(value.toString()) : false;
|
|
23
|
+
return value => {
|
|
24
|
+
return value != null ? filterRegex.test(String(value)) : false;
|
|
27
25
|
};
|
|
28
26
|
},
|
|
29
27
|
InputComponent: GridFilterInputValue
|
|
30
28
|
}, {
|
|
31
29
|
value: 'equals',
|
|
32
|
-
|
|
30
|
+
getApplyFilterFnV7: filterItem => {
|
|
33
31
|
if (!filterItem.value) {
|
|
34
32
|
return null;
|
|
35
33
|
}
|
|
@@ -38,66 +36,56 @@ export const getGridStringOperators = (disableTrim = false) => [{
|
|
|
38
36
|
sensitivity: 'base',
|
|
39
37
|
usage: 'search'
|
|
40
38
|
});
|
|
41
|
-
return
|
|
42
|
-
value
|
|
43
|
-
}) => {
|
|
39
|
+
return value => {
|
|
44
40
|
return value != null ? collator.compare(filterItemValue, value.toString()) === 0 : false;
|
|
45
41
|
};
|
|
46
42
|
},
|
|
47
43
|
InputComponent: GridFilterInputValue
|
|
48
44
|
}, {
|
|
49
45
|
value: 'startsWith',
|
|
50
|
-
|
|
46
|
+
getApplyFilterFnV7: filterItem => {
|
|
51
47
|
if (!filterItem.value) {
|
|
52
48
|
return null;
|
|
53
49
|
}
|
|
54
50
|
const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();
|
|
55
51
|
const filterRegex = new RegExp(`^${escapeRegExp(filterItemValue)}.*$`, 'i');
|
|
56
|
-
return
|
|
57
|
-
value
|
|
58
|
-
}) => {
|
|
52
|
+
return value => {
|
|
59
53
|
return value != null ? filterRegex.test(value.toString()) : false;
|
|
60
54
|
};
|
|
61
55
|
},
|
|
62
56
|
InputComponent: GridFilterInputValue
|
|
63
57
|
}, {
|
|
64
58
|
value: 'endsWith',
|
|
65
|
-
|
|
59
|
+
getApplyFilterFnV7: filterItem => {
|
|
66
60
|
if (!filterItem.value) {
|
|
67
61
|
return null;
|
|
68
62
|
}
|
|
69
63
|
const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();
|
|
70
64
|
const filterRegex = new RegExp(`.*${escapeRegExp(filterItemValue)}$`, 'i');
|
|
71
|
-
return
|
|
72
|
-
value
|
|
73
|
-
}) => {
|
|
65
|
+
return value => {
|
|
74
66
|
return value != null ? filterRegex.test(value.toString()) : false;
|
|
75
67
|
};
|
|
76
68
|
},
|
|
77
69
|
InputComponent: GridFilterInputValue
|
|
78
70
|
}, {
|
|
79
71
|
value: 'isEmpty',
|
|
80
|
-
|
|
81
|
-
return
|
|
82
|
-
value
|
|
83
|
-
}) => {
|
|
72
|
+
getApplyFilterFnV7: () => {
|
|
73
|
+
return value => {
|
|
84
74
|
return value === '' || value == null;
|
|
85
75
|
};
|
|
86
76
|
},
|
|
87
77
|
requiresFilterValue: false
|
|
88
78
|
}, {
|
|
89
79
|
value: 'isNotEmpty',
|
|
90
|
-
|
|
91
|
-
return
|
|
92
|
-
value
|
|
93
|
-
}) => {
|
|
80
|
+
getApplyFilterFnV7: () => {
|
|
81
|
+
return value => {
|
|
94
82
|
return value !== '' && value != null;
|
|
95
83
|
};
|
|
96
84
|
},
|
|
97
85
|
requiresFilterValue: false
|
|
98
86
|
}, {
|
|
99
87
|
value: 'isAnyOf',
|
|
100
|
-
|
|
88
|
+
getApplyFilterFnV7: filterItem => {
|
|
101
89
|
if (!Array.isArray(filterItem.value) || filterItem.value.length === 0) {
|
|
102
90
|
return null;
|
|
103
91
|
}
|
|
@@ -106,11 +94,9 @@ export const getGridStringOperators = (disableTrim = false) => [{
|
|
|
106
94
|
sensitivity: 'base',
|
|
107
95
|
usage: 'search'
|
|
108
96
|
});
|
|
109
|
-
return ({
|
|
110
|
-
value
|
|
111
|
-
}) => value != null ? filterItemValue.some(filterValue => {
|
|
97
|
+
return value => value != null ? filterItemValue.some(filterValue => {
|
|
112
98
|
return collator.compare(filterValue, value.toString() || '') === 0;
|
|
113
99
|
}) : false;
|
|
114
100
|
},
|
|
115
101
|
InputComponent: GridFilterInputMultipleValue
|
|
116
|
-
}];
|
|
102
|
+
}]);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridApiCommunity } from '../models/api/gridApiCommunity';
|
|
3
|
+
import { GetApplyFilterFnV7, GetApplyFilterFnLegacy, GridFilterOperator } from '../models';
|
|
4
|
+
import { GetApplyQuickFilterFnV7, GetApplyQuickFilterFnLegacy } from '../models/colDef/gridColDef';
|
|
5
|
+
/**
|
|
6
|
+
* A global API ref, for v7-to-legacy converter
|
|
7
|
+
*/
|
|
8
|
+
export declare const GLOBAL_API_REF: {
|
|
9
|
+
current: React.MutableRefObject<GridApiCommunity> | null;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A tagger to determine if the filter is internal or custom user-supplied.
|
|
13
|
+
* To be a valid internal filter, the V7 function *must* be defined/redefined at
|
|
14
|
+
* the same time as the legacy one.
|
|
15
|
+
* https://github.com/mui/mui-x/pull/9254#discussion_r1231095551
|
|
16
|
+
*/
|
|
17
|
+
export declare function tagInternalFilter<T>(fn: T): T;
|
|
18
|
+
export declare function isInternalFilter(fn: Function | undefined): boolean;
|
|
19
|
+
export declare function convertFilterV7ToLegacy(fn: GetApplyFilterFnV7): GetApplyFilterFnLegacy;
|
|
20
|
+
export declare function convertLegacyOperators(ops: Omit<GridFilterOperator, 'getApplyFilterFn'>[]): GridFilterOperator[];
|
|
21
|
+
export declare function convertQuickFilterV7ToLegacy(fn: GetApplyQuickFilterFnV7): GetApplyQuickFilterFnLegacy<any, any, any>;
|
package/colDef/utils.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
/**
|
|
3
|
+
* A global API ref, for v7-to-legacy converter
|
|
4
|
+
*/
|
|
5
|
+
export const GLOBAL_API_REF = {
|
|
6
|
+
current: null
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A tagger to determine if the filter is internal or custom user-supplied.
|
|
11
|
+
* To be a valid internal filter, the V7 function *must* be defined/redefined at
|
|
12
|
+
* the same time as the legacy one.
|
|
13
|
+
* https://github.com/mui/mui-x/pull/9254#discussion_r1231095551
|
|
14
|
+
*/
|
|
15
|
+
export function tagInternalFilter(fn) {
|
|
16
|
+
fn.isInternal = true;
|
|
17
|
+
return fn;
|
|
18
|
+
}
|
|
19
|
+
export function isInternalFilter(fn) {
|
|
20
|
+
return fn !== undefined && fn.isInternal === true;
|
|
21
|
+
}
|
|
22
|
+
export function convertFilterV7ToLegacy(fn) {
|
|
23
|
+
return tagInternalFilter((filterItem, column) => {
|
|
24
|
+
const filterFn = fn(filterItem, column);
|
|
25
|
+
if (!filterFn) {
|
|
26
|
+
return filterFn;
|
|
27
|
+
}
|
|
28
|
+
return cellParams => {
|
|
29
|
+
return filterFn(cellParams.value, cellParams.row, column, GLOBAL_API_REF.current);
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function convertLegacyOperators(ops) {
|
|
34
|
+
return ops.map(op => {
|
|
35
|
+
return _extends({}, op, {
|
|
36
|
+
getApplyFilterFn: convertFilterV7ToLegacy(op.getApplyFilterFnV7),
|
|
37
|
+
getApplyFilterFnV7: tagInternalFilter(op.getApplyFilterFnV7)
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export function convertQuickFilterV7ToLegacy(fn) {
|
|
42
|
+
return tagInternalFilter((filterItem, column, apiRef) => {
|
|
43
|
+
const filterFn = fn(filterItem, column, apiRef);
|
|
44
|
+
if (!filterFn) {
|
|
45
|
+
return filterFn;
|
|
46
|
+
}
|
|
47
|
+
return cellParams => {
|
|
48
|
+
return filterFn(cellParams.value, cellParams.row, column, apiRef);
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -25,7 +25,6 @@ const GridPaginationRoot = styled(TablePagination)(({
|
|
|
25
25
|
}
|
|
26
26
|
}));
|
|
27
27
|
export const GridPagination = /*#__PURE__*/React.forwardRef(function GridPagination(props, ref) {
|
|
28
|
-
var _rootProps$pageSizeOp;
|
|
29
28
|
const apiRef = useGridApiContext();
|
|
30
29
|
const rootProps = useGridRootProps();
|
|
31
30
|
const paginationModel = useGridSelector(apiRef, gridPaginationModelSelector);
|
|
@@ -42,22 +41,36 @@ export const GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginat
|
|
|
42
41
|
const handlePageChange = React.useCallback((_, page) => {
|
|
43
42
|
apiRef.current.setPage(page);
|
|
44
43
|
}, [apiRef]);
|
|
44
|
+
const isPageSizeIncludedInPageSizeOptions = pageSize => {
|
|
45
|
+
for (let i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
|
|
46
|
+
const option = rootProps.pageSizeOptions[i];
|
|
47
|
+
if (typeof option === 'number') {
|
|
48
|
+
if (option === pageSize) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
} else if (option.value === pageSize) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
45
57
|
if (process.env.NODE_ENV !== 'production') {
|
|
46
58
|
var _rootProps$pagination, _rootProps$pagination2;
|
|
47
59
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
48
60
|
const warnedOnceMissingInPageSizeOptions = React.useRef(false);
|
|
49
61
|
const pageSize = (_rootProps$pagination = (_rootProps$pagination2 = rootProps.paginationModel) == null ? void 0 : _rootProps$pagination2.pageSize) != null ? _rootProps$pagination : paginationModel.pageSize;
|
|
50
|
-
if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !
|
|
62
|
+
if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !isPageSizeIncludedInPageSizeOptions(pageSize)) {
|
|
51
63
|
console.warn([`MUI: The page size \`${paginationModel.pageSize}\` is not preset in the \`pageSizeOptions\``, `Add it to show the pagination select.`].join('\n'));
|
|
52
64
|
warnedOnceMissingInPageSizeOptions.current = true;
|
|
53
65
|
}
|
|
54
66
|
}
|
|
67
|
+
const pageSizeOptions = isPageSizeIncludedInPageSizeOptions(paginationModel.pageSize) ? rootProps.pageSizeOptions : [];
|
|
55
68
|
return /*#__PURE__*/_jsx(GridPaginationRoot, _extends({
|
|
56
69
|
ref: ref,
|
|
57
70
|
component: "div",
|
|
58
71
|
count: rowCount,
|
|
59
72
|
page: paginationModel.page <= lastPage ? paginationModel.page : lastPage,
|
|
60
|
-
rowsPerPageOptions:
|
|
73
|
+
rowsPerPageOptions: pageSizeOptions,
|
|
61
74
|
rowsPerPage: paginationModel.pageSize,
|
|
62
75
|
onPageChange: handlePageChange,
|
|
63
76
|
onRowsPerPageChange: handlePageSizeChange
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["changeReason", "unstable_updateValueOnRender"],
|
|
4
|
-
_excluded2 = ["align", "children", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
|
|
4
|
+
_excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
|
|
5
5
|
_excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
|
|
6
6
|
_excluded4 = ["changeReason", "unstable_updateValueOnRender"];
|
|
7
7
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
@@ -112,7 +112,7 @@ function GridEditDateCell(props) {
|
|
|
112
112
|
const meta = apiRef.current.unstable_getEditCellMeta(id, field);
|
|
113
113
|
const handleInputRef = el => {
|
|
114
114
|
inputRef.current = el;
|
|
115
|
-
if (meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
|
|
115
|
+
if (meta != null && meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
|
|
116
116
|
const inputValue = inputRef.current.value;
|
|
117
117
|
const parsedDate = parseValueToDate(inputValue);
|
|
118
118
|
setValueState({
|
|
@@ -68,12 +68,12 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
68
68
|
unstable_skipValueParser: true
|
|
69
69
|
}, event);
|
|
70
70
|
}, [apiRef, debounceMs, field, id, onValueChange]);
|
|
71
|
-
const meta = apiRef.current.unstable_getEditCellMeta
|
|
71
|
+
const meta = apiRef.current.unstable_getEditCellMeta(id, field);
|
|
72
72
|
React.useEffect(() => {
|
|
73
|
-
if (meta.changeReason !== 'debouncedSetEditCellValue') {
|
|
73
|
+
if ((meta == null ? void 0 : meta.changeReason) !== 'debouncedSetEditCellValue') {
|
|
74
74
|
setValueState(value);
|
|
75
75
|
}
|
|
76
|
-
}, [meta
|
|
76
|
+
}, [meta, value]);
|
|
77
77
|
useEnhancedEffect(() => {
|
|
78
78
|
if (hasFocus) {
|
|
79
79
|
inputRef.current.focus();
|
|
@@ -15,6 +15,7 @@ export function computeFlexColumnsWidth({
|
|
|
15
15
|
totalFlexUnits,
|
|
16
16
|
flexColumns
|
|
17
17
|
}) {
|
|
18
|
+
const uniqueFlexColumns = new Set(flexColumns.map(col => col.field));
|
|
18
19
|
const flexColumnsLookup = {
|
|
19
20
|
all: {},
|
|
20
21
|
frozenFields: [],
|
|
@@ -30,7 +31,7 @@ export function computeFlexColumnsWidth({
|
|
|
30
31
|
// Step 5 of https://drafts.csswg.org/css-flexbox-1/#resolve-flexible-lengths
|
|
31
32
|
function loopOverFlexItems() {
|
|
32
33
|
// 5a: If all the flex items on the line are frozen, free space has been distributed.
|
|
33
|
-
if (flexColumnsLookup.frozenFields.length ===
|
|
34
|
+
if (flexColumnsLookup.frozenFields.length === uniqueFlexColumns.size) {
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
37
|
const violationsLookup = {
|
|
@@ -73,7 +73,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
73
73
|
let hasScrollY;
|
|
74
74
|
if (props.autoHeight) {
|
|
75
75
|
hasScrollY = false;
|
|
76
|
-
hasScrollX = Math.round(columnsTotalWidth) > rootDimensionsRef.current.width;
|
|
76
|
+
hasScrollX = Math.round(columnsTotalWidth) > Math.round(rootDimensionsRef.current.width);
|
|
77
77
|
viewportOuterSize = {
|
|
78
78
|
width: rootDimensionsRef.current.width,
|
|
79
79
|
height: rowsMeta.currentPageTotalHeight + (hasScrollX ? scrollBarSize : 0)
|
|
@@ -89,7 +89,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
89
89
|
height: rowsMeta.currentPageTotalHeight
|
|
90
90
|
},
|
|
91
91
|
container: {
|
|
92
|
-
width: viewportOuterSize.width,
|
|
92
|
+
width: Math.round(viewportOuterSize.width),
|
|
93
93
|
height: viewportOuterSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom
|
|
94
94
|
},
|
|
95
95
|
scrollBarSize
|
|
@@ -106,8 +106,9 @@ export const useGridEditing = (apiRef, props) => {
|
|
|
106
106
|
return props.editMode === GridEditModes.Cell ? apiRef.current.getRowWithUpdatedValuesFromCellEditing(id, field) : apiRef.current.getRowWithUpdatedValuesFromRowEditing(id);
|
|
107
107
|
}, [apiRef, props.editMode]);
|
|
108
108
|
const getEditCellMeta = React.useCallback((id, field) => {
|
|
109
|
+
var _editingState$id$fiel, _editingState$id;
|
|
109
110
|
const editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
110
|
-
return editingState[id][field];
|
|
111
|
+
return (_editingState$id$fiel = (_editingState$id = editingState[id]) == null ? void 0 : _editingState$id[field]) != null ? _editingState$id$fiel : null;
|
|
111
112
|
}, [apiRef]);
|
|
112
113
|
const editingSharedApi = {
|
|
113
114
|
isCellEditable,
|
|
@@ -10,7 +10,7 @@ import { GridEditModes, GridRowModes } from '../../../models/gridEditRowModel';
|
|
|
10
10
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
11
11
|
import { gridEditRowsStateSelector } from './gridEditingSelectors';
|
|
12
12
|
import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
13
|
-
import { gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
13
|
+
import { gridColumnFieldsSelector, gridVisibleColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
14
14
|
import { buildWarning } from '../../../utils/warning';
|
|
15
15
|
import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
16
16
|
import { deepClone } from '../../../utils/utils';
|
|
@@ -115,7 +115,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
115
115
|
} else if (event.key === 'Enter') {
|
|
116
116
|
reason = GridRowEditStopReasons.enterKeyDown;
|
|
117
117
|
} else if (event.key === 'Tab') {
|
|
118
|
-
const columnFields =
|
|
118
|
+
const columnFields = gridVisibleColumnFieldsSelector(apiRef).filter(field => {
|
|
119
119
|
const column = apiRef.current.getColumn(field);
|
|
120
120
|
if (column.type === GRID_ACTIONS_COLUMN_TYPE) {
|
|
121
121
|
return true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GridFilterItem } from '../../../models/gridFilterItem';
|
|
2
2
|
import { GridFilterModel } from '../../../models/gridFilterModel';
|
|
3
|
-
import { GridRowId } from '../../../models/gridRows';
|
|
3
|
+
import { GridRowId, GridValidRowModel } from '../../../models/gridRows';
|
|
4
4
|
export type GridFilterItemResult = {
|
|
5
5
|
[key: Required<GridFilterItem>['id']]: boolean;
|
|
6
6
|
};
|
|
@@ -28,14 +28,15 @@ export interface GridFilterState {
|
|
|
28
28
|
export interface GridFilterInitialState {
|
|
29
29
|
filterModel?: GridFilterModel;
|
|
30
30
|
}
|
|
31
|
+
export interface GridAggregatedFilterItemApplierResult {
|
|
32
|
+
passingFilterItems: null | GridFilterItemResult;
|
|
33
|
+
passingQuickFilterValues: null | GridQuickFilterValueResult;
|
|
34
|
+
}
|
|
31
35
|
/**
|
|
32
36
|
* @param {GridRowId} rowId The id of the row we want to filter.
|
|
33
37
|
* @param {(filterItem: GridFilterItem) => boolean} shouldApplyItem An optional callback to allow the filtering engine to only apply some items.
|
|
34
38
|
*/
|
|
35
|
-
export type GridAggregatedFilterItemApplier = (
|
|
36
|
-
passingFilterItems: null | GridFilterItemResult;
|
|
37
|
-
passingQuickFilterValues: null | GridQuickFilterValueResult;
|
|
38
|
-
};
|
|
39
|
+
export type GridAggregatedFilterItemApplier = (row: GridValidRowModel, shouldApplyItem: ((field: string) => boolean) | undefined, result: GridAggregatedFilterItemApplierResult) => void;
|
|
39
40
|
export interface GridFilteringMethodParams {
|
|
40
41
|
isRowMatchingFilters: GridAggregatedFilterItemApplier | null;
|
|
41
42
|
filterModel: GridFilterModel;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { GridFilterItem, GridFilterModel,
|
|
2
|
+
import { GridFilterItem, GridFilterModel, GridRowIdGetter, GridValidRowModel } from '../../../models';
|
|
3
3
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
4
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
5
5
|
import { GridAggregatedFilterItemApplier, GridFilterItemResult, GridQuickFilterValueResult } from './gridFilterState';
|
|
6
|
-
type GridFilterItemApplierNotAggregated = (
|
|
6
|
+
type GridFilterItemApplierNotAggregated = (row: GridValidRowModel, shouldApplyItem?: (field: string) => boolean) => GridFilterItemResult;
|
|
7
7
|
/**
|
|
8
8
|
* Adds default values to the optional fields of a filter items.
|
|
9
9
|
* @param {GridFilterItem} item The raw filter item.
|
|
@@ -16,19 +16,21 @@ export declare const sanitizeFilterModel: (model: GridFilterModel, disableMultip
|
|
|
16
16
|
export declare const mergeStateWithFilterModel: (filterModel: GridFilterModel, disableMultipleColumnsFiltering: boolean, apiRef: React.MutableRefObject<GridApiCommunity>) => (filteringState: GridStateCommunity['filter']) => GridStateCommunity['filter'];
|
|
17
17
|
/**
|
|
18
18
|
* Generates a method to easily check if a row is matching the current filter model.
|
|
19
|
+
* @param {GridRowIdGetter | undefined} getRowId The getter for row's id.
|
|
19
20
|
* @param {GridFilterModel} filterModel The model with which we want to filter the rows.
|
|
20
21
|
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
21
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.
|
|
22
23
|
*/
|
|
23
|
-
export declare const buildAggregatedFilterItemsApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridFilterItemApplierNotAggregated | null;
|
|
24
|
+
export declare const buildAggregatedFilterItemsApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridFilterItemApplierNotAggregated | null;
|
|
24
25
|
/**
|
|
25
26
|
* Generates a method to easily check if a row is matching the current quick filter.
|
|
26
|
-
* @param {
|
|
27
|
+
* @param {GridRowIdGetter | undefined} getRowId The getter for row's id.
|
|
28
|
+
* @param {any[]} filterModel The model with which we want to filter the rows.
|
|
27
29
|
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
28
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.
|
|
29
31
|
*/
|
|
30
|
-
export declare const buildAggregatedQuickFilterApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridFilterItemApplierNotAggregated | null;
|
|
31
|
-
export declare const buildAggregatedFilterApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridAggregatedFilterItemApplier;
|
|
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>) => GridAggregatedFilterItemApplier;
|
|
32
34
|
type FilterCache = {
|
|
33
35
|
cleanedFilterItems?: GridFilterItem[];
|
|
34
36
|
};
|