@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,16 +1,15 @@
|
|
|
1
1
|
import { GridFilterInputBoolean } from '../components/panel/filterPanel/GridFilterInputBoolean';
|
|
2
|
-
|
|
2
|
+
import { convertLegacyOperators } from './utils';
|
|
3
|
+
export const getGridBooleanOperators = () => convertLegacyOperators([{
|
|
3
4
|
value: 'is',
|
|
4
|
-
|
|
5
|
+
getApplyFilterFnV7: filterItem => {
|
|
5
6
|
if (!filterItem.value) {
|
|
6
7
|
return null;
|
|
7
8
|
}
|
|
8
9
|
const valueAsBoolean = filterItem.value === 'true';
|
|
9
|
-
return
|
|
10
|
-
value
|
|
11
|
-
}) => {
|
|
10
|
+
return value => {
|
|
12
11
|
return Boolean(value) === valueAsBoolean;
|
|
13
12
|
};
|
|
14
13
|
},
|
|
15
14
|
InputComponent: GridFilterInputBoolean
|
|
16
|
-
}];
|
|
15
|
+
}]);
|
|
@@ -19,6 +19,7 @@ export const GRID_CHECKBOX_SELECTION_COL_DEF = _extends({}, GRID_BOOLEAN_COL_DEF
|
|
|
19
19
|
disableReorder: true,
|
|
20
20
|
disableExport: true,
|
|
21
21
|
getApplyQuickFilterFn: undefined,
|
|
22
|
+
getApplyQuickFilterFnV7: undefined,
|
|
22
23
|
valueGetter: params => {
|
|
23
24
|
const selectionLookup = selectedIdsLookupSelector(params.api.state, params.api.instanceId);
|
|
24
25
|
return selectionLookup[params.id] !== undefined;
|
|
@@ -52,6 +52,7 @@ export const GRID_DATE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
52
52
|
filterOperators: getGridDateOperators(),
|
|
53
53
|
renderEditCell: renderEditDateCell,
|
|
54
54
|
getApplyQuickFilterFn: undefined,
|
|
55
|
+
getApplyQuickFilterFnV7: undefined,
|
|
55
56
|
// @ts-ignore
|
|
56
57
|
pastedValueParser: value => new Date(value)
|
|
57
58
|
});
|
|
@@ -62,6 +63,7 @@ export const GRID_DATETIME_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
62
63
|
filterOperators: getGridDateOperators(true),
|
|
63
64
|
renderEditCell: renderEditDateCell,
|
|
64
65
|
getApplyQuickFilterFn: undefined,
|
|
66
|
+
getApplyQuickFilterFnV7: undefined,
|
|
65
67
|
// @ts-ignore
|
|
66
68
|
pastedValueParser: value => new Date(value)
|
|
67
69
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GridFilterInputDate } from '../components/panel/filterPanel/GridFilterInputDate';
|
|
2
|
+
import { convertLegacyOperators } from './utils';
|
|
2
3
|
const dateRegex = /(\d+)-(\d+)-(\d+)/;
|
|
3
4
|
const dateTimeRegex = /(\d+)-(\d+)-(\d+)T(\d+):(\d+)/;
|
|
4
5
|
function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
|
|
@@ -7,9 +8,7 @@ function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
|
|
|
7
8
|
}
|
|
8
9
|
const [year, month, day, hour, minute] = filterItem.value.match(showTime ? dateTimeRegex : dateRegex).slice(1).map(Number);
|
|
9
10
|
const time = new Date(year, month - 1, day, hour || 0, minute || 0).getTime();
|
|
10
|
-
return
|
|
11
|
-
value
|
|
12
|
-
}) => {
|
|
11
|
+
return value => {
|
|
13
12
|
if (!value) {
|
|
14
13
|
return false;
|
|
15
14
|
}
|
|
@@ -23,9 +22,9 @@ function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
|
|
|
23
22
|
return compareFn(timeToCompare, time);
|
|
24
23
|
};
|
|
25
24
|
}
|
|
26
|
-
export const getGridDateOperators = showTime => [{
|
|
25
|
+
export const getGridDateOperators = showTime => convertLegacyOperators([{
|
|
27
26
|
value: 'is',
|
|
28
|
-
|
|
27
|
+
getApplyFilterFnV7: filterItem => {
|
|
29
28
|
return buildApplyFilterFn(filterItem, (value1, value2) => value1 === value2, showTime);
|
|
30
29
|
},
|
|
31
30
|
InputComponent: GridFilterInputDate,
|
|
@@ -34,7 +33,7 @@ export const getGridDateOperators = showTime => [{
|
|
|
34
33
|
}
|
|
35
34
|
}, {
|
|
36
35
|
value: 'not',
|
|
37
|
-
|
|
36
|
+
getApplyFilterFnV7: filterItem => {
|
|
38
37
|
return buildApplyFilterFn(filterItem, (value1, value2) => value1 !== value2, showTime);
|
|
39
38
|
},
|
|
40
39
|
InputComponent: GridFilterInputDate,
|
|
@@ -43,7 +42,7 @@ export const getGridDateOperators = showTime => [{
|
|
|
43
42
|
}
|
|
44
43
|
}, {
|
|
45
44
|
value: 'after',
|
|
46
|
-
|
|
45
|
+
getApplyFilterFnV7: filterItem => {
|
|
47
46
|
return buildApplyFilterFn(filterItem, (value1, value2) => value1 > value2, showTime);
|
|
48
47
|
},
|
|
49
48
|
InputComponent: GridFilterInputDate,
|
|
@@ -52,7 +51,7 @@ export const getGridDateOperators = showTime => [{
|
|
|
52
51
|
}
|
|
53
52
|
}, {
|
|
54
53
|
value: 'onOrAfter',
|
|
55
|
-
|
|
54
|
+
getApplyFilterFnV7: filterItem => {
|
|
56
55
|
return buildApplyFilterFn(filterItem, (value1, value2) => value1 >= value2, showTime);
|
|
57
56
|
},
|
|
58
57
|
InputComponent: GridFilterInputDate,
|
|
@@ -61,7 +60,7 @@ export const getGridDateOperators = showTime => [{
|
|
|
61
60
|
}
|
|
62
61
|
}, {
|
|
63
62
|
value: 'before',
|
|
64
|
-
|
|
63
|
+
getApplyFilterFnV7: filterItem => {
|
|
65
64
|
return buildApplyFilterFn(filterItem, (value1, value2) => value1 < value2, showTime, !showTime);
|
|
66
65
|
},
|
|
67
66
|
InputComponent: GridFilterInputDate,
|
|
@@ -70,7 +69,7 @@ export const getGridDateOperators = showTime => [{
|
|
|
70
69
|
}
|
|
71
70
|
}, {
|
|
72
71
|
value: 'onOrBefore',
|
|
73
|
-
|
|
72
|
+
getApplyFilterFnV7: filterItem => {
|
|
74
73
|
return buildApplyFilterFn(filterItem, (value1, value2) => value1 <= value2, showTime);
|
|
75
74
|
},
|
|
76
75
|
InputComponent: GridFilterInputDate,
|
|
@@ -79,22 +78,18 @@ export const getGridDateOperators = showTime => [{
|
|
|
79
78
|
}
|
|
80
79
|
}, {
|
|
81
80
|
value: 'isEmpty',
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
-
value
|
|
85
|
-
}) => {
|
|
81
|
+
getApplyFilterFnV7: () => {
|
|
82
|
+
return value => {
|
|
86
83
|
return value == null;
|
|
87
84
|
};
|
|
88
85
|
},
|
|
89
86
|
requiresFilterValue: false
|
|
90
87
|
}, {
|
|
91
88
|
value: 'isNotEmpty',
|
|
92
|
-
|
|
93
|
-
return
|
|
94
|
-
value
|
|
95
|
-
}) => {
|
|
89
|
+
getApplyFilterFnV7: () => {
|
|
90
|
+
return value => {
|
|
96
91
|
return value != null;
|
|
97
92
|
};
|
|
98
93
|
},
|
|
99
94
|
requiresFilterValue: false
|
|
100
|
-
}];
|
|
95
|
+
}]);
|
|
@@ -3,6 +3,7 @@ import { gridNumberComparator } from '../hooks/features/sorting/gridSortingUtils
|
|
|
3
3
|
import { isNumber } from '../utils/utils';
|
|
4
4
|
import { getGridNumericOperators, getGridNumericQuickFilterFn } from './gridNumericOperators';
|
|
5
5
|
import { GRID_STRING_COL_DEF } from './gridStringColDef';
|
|
6
|
+
import { convertQuickFilterV7ToLegacy } from './utils';
|
|
6
7
|
export const GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
7
8
|
type: 'number',
|
|
8
9
|
align: 'right',
|
|
@@ -13,5 +14,6 @@ export const GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
13
14
|
value
|
|
14
15
|
}) => isNumber(value) ? value.toLocaleString() : value || '',
|
|
15
16
|
filterOperators: getGridNumericOperators(),
|
|
16
|
-
getApplyQuickFilterFn: getGridNumericQuickFilterFn
|
|
17
|
+
getApplyQuickFilterFn: convertQuickFilterV7ToLegacy(getGridNumericQuickFilterFn),
|
|
18
|
+
getApplyQuickFilterFnV7: getGridNumericQuickFilterFn
|
|
17
19
|
});
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import { GridFilterInputValue } from '../components/panel/filterPanel/GridFilterInputValue';
|
|
2
2
|
import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
|
|
3
|
+
import { convertLegacyOperators, tagInternalFilter } from './utils';
|
|
3
4
|
const parseNumericValue = value => {
|
|
4
5
|
if (value == null) {
|
|
5
6
|
return null;
|
|
6
7
|
}
|
|
7
8
|
return Number(value);
|
|
8
9
|
};
|
|
9
|
-
export const getGridNumericQuickFilterFn = value => {
|
|
10
|
+
export const getGridNumericQuickFilterFn = tagInternalFilter(value => {
|
|
10
11
|
if (value == null || Number.isNaN(value) || value === '') {
|
|
11
12
|
return null;
|
|
12
13
|
}
|
|
13
|
-
return
|
|
14
|
-
value: columnValue
|
|
15
|
-
}) => {
|
|
14
|
+
return columnValue => {
|
|
16
15
|
return parseNumericValue(columnValue) === parseNumericValue(value);
|
|
17
16
|
};
|
|
18
|
-
};
|
|
19
|
-
export const getGridNumericOperators = () => [{
|
|
17
|
+
});
|
|
18
|
+
export const getGridNumericOperators = () => convertLegacyOperators([{
|
|
20
19
|
value: '=',
|
|
21
|
-
|
|
20
|
+
getApplyFilterFnV7: filterItem => {
|
|
22
21
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
23
22
|
return null;
|
|
24
23
|
}
|
|
25
|
-
return
|
|
26
|
-
value
|
|
27
|
-
}) => {
|
|
24
|
+
return value => {
|
|
28
25
|
return parseNumericValue(value) === filterItem.value;
|
|
29
26
|
};
|
|
30
27
|
},
|
|
@@ -34,13 +31,11 @@ export const getGridNumericOperators = () => [{
|
|
|
34
31
|
}
|
|
35
32
|
}, {
|
|
36
33
|
value: '!=',
|
|
37
|
-
|
|
34
|
+
getApplyFilterFnV7: filterItem => {
|
|
38
35
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
39
36
|
return null;
|
|
40
37
|
}
|
|
41
|
-
return
|
|
42
|
-
value
|
|
43
|
-
}) => {
|
|
38
|
+
return value => {
|
|
44
39
|
return parseNumericValue(value) !== filterItem.value;
|
|
45
40
|
};
|
|
46
41
|
},
|
|
@@ -50,13 +45,11 @@ export const getGridNumericOperators = () => [{
|
|
|
50
45
|
}
|
|
51
46
|
}, {
|
|
52
47
|
value: '>',
|
|
53
|
-
|
|
48
|
+
getApplyFilterFnV7: filterItem => {
|
|
54
49
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
55
50
|
return null;
|
|
56
51
|
}
|
|
57
|
-
return
|
|
58
|
-
value
|
|
59
|
-
}) => {
|
|
52
|
+
return value => {
|
|
60
53
|
if (value == null) {
|
|
61
54
|
return false;
|
|
62
55
|
}
|
|
@@ -69,13 +62,11 @@ export const getGridNumericOperators = () => [{
|
|
|
69
62
|
}
|
|
70
63
|
}, {
|
|
71
64
|
value: '>=',
|
|
72
|
-
|
|
65
|
+
getApplyFilterFnV7: filterItem => {
|
|
73
66
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
74
67
|
return null;
|
|
75
68
|
}
|
|
76
|
-
return
|
|
77
|
-
value
|
|
78
|
-
}) => {
|
|
69
|
+
return value => {
|
|
79
70
|
if (value == null) {
|
|
80
71
|
return false;
|
|
81
72
|
}
|
|
@@ -88,13 +79,11 @@ export const getGridNumericOperators = () => [{
|
|
|
88
79
|
}
|
|
89
80
|
}, {
|
|
90
81
|
value: '<',
|
|
91
|
-
|
|
82
|
+
getApplyFilterFnV7: filterItem => {
|
|
92
83
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
93
84
|
return null;
|
|
94
85
|
}
|
|
95
|
-
return
|
|
96
|
-
value
|
|
97
|
-
}) => {
|
|
86
|
+
return value => {
|
|
98
87
|
if (value == null) {
|
|
99
88
|
return false;
|
|
100
89
|
}
|
|
@@ -107,13 +96,11 @@ export const getGridNumericOperators = () => [{
|
|
|
107
96
|
}
|
|
108
97
|
}, {
|
|
109
98
|
value: '<=',
|
|
110
|
-
|
|
99
|
+
getApplyFilterFnV7: filterItem => {
|
|
111
100
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
112
101
|
return null;
|
|
113
102
|
}
|
|
114
|
-
return
|
|
115
|
-
value
|
|
116
|
-
}) => {
|
|
103
|
+
return value => {
|
|
117
104
|
if (value == null) {
|
|
118
105
|
return false;
|
|
119
106
|
}
|
|
@@ -126,33 +113,27 @@ export const getGridNumericOperators = () => [{
|
|
|
126
113
|
}
|
|
127
114
|
}, {
|
|
128
115
|
value: 'isEmpty',
|
|
129
|
-
|
|
130
|
-
return
|
|
131
|
-
value
|
|
132
|
-
}) => {
|
|
116
|
+
getApplyFilterFnV7: () => {
|
|
117
|
+
return value => {
|
|
133
118
|
return value == null;
|
|
134
119
|
};
|
|
135
120
|
},
|
|
136
121
|
requiresFilterValue: false
|
|
137
122
|
}, {
|
|
138
123
|
value: 'isNotEmpty',
|
|
139
|
-
|
|
140
|
-
return
|
|
141
|
-
value
|
|
142
|
-
}) => {
|
|
124
|
+
getApplyFilterFnV7: () => {
|
|
125
|
+
return value => {
|
|
143
126
|
return value != null;
|
|
144
127
|
};
|
|
145
128
|
},
|
|
146
129
|
requiresFilterValue: false
|
|
147
130
|
}, {
|
|
148
131
|
value: 'isAnyOf',
|
|
149
|
-
|
|
132
|
+
getApplyFilterFnV7: filterItem => {
|
|
150
133
|
if (!Array.isArray(filterItem.value) || filterItem.value.length === 0) {
|
|
151
134
|
return null;
|
|
152
135
|
}
|
|
153
|
-
return
|
|
154
|
-
value
|
|
155
|
-
}) => {
|
|
136
|
+
return value => {
|
|
156
137
|
return value != null && filterItem.value.includes(Number(value));
|
|
157
138
|
};
|
|
158
139
|
},
|
|
@@ -160,4 +141,4 @@ export const getGridNumericOperators = () => [{
|
|
|
160
141
|
InputComponentProps: {
|
|
161
142
|
type: 'number'
|
|
162
143
|
}
|
|
163
|
-
}];
|
|
144
|
+
}]);
|
|
@@ -1,44 +1,39 @@
|
|
|
1
1
|
import { GridFilterInputSingleSelect } from '../components/panel/filterPanel/GridFilterInputSingleSelect';
|
|
2
2
|
import { GridFilterInputMultipleSingleSelect } from '../components/panel/filterPanel/GridFilterInputMultipleSingleSelect';
|
|
3
3
|
import { isObject } from '../utils/utils';
|
|
4
|
+
import { convertLegacyOperators } from './utils';
|
|
4
5
|
const parseObjectValue = value => {
|
|
5
6
|
if (value == null || !isObject(value)) {
|
|
6
7
|
return value;
|
|
7
8
|
}
|
|
8
9
|
return value.value;
|
|
9
10
|
};
|
|
10
|
-
export const getGridSingleSelectOperators = () => [{
|
|
11
|
+
export const getGridSingleSelectOperators = () => convertLegacyOperators([{
|
|
11
12
|
value: 'is',
|
|
12
|
-
|
|
13
|
+
getApplyFilterFnV7: filterItem => {
|
|
13
14
|
if (filterItem.value == null || filterItem.value === '') {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
16
|
-
return (
|
|
17
|
-
value
|
|
18
|
-
}) => parseObjectValue(value) === parseObjectValue(filterItem.value);
|
|
17
|
+
return value => parseObjectValue(value) === parseObjectValue(filterItem.value);
|
|
19
18
|
},
|
|
20
19
|
InputComponent: GridFilterInputSingleSelect
|
|
21
20
|
}, {
|
|
22
21
|
value: 'not',
|
|
23
|
-
|
|
22
|
+
getApplyFilterFnV7: filterItem => {
|
|
24
23
|
if (filterItem.value == null || filterItem.value === '') {
|
|
25
24
|
return null;
|
|
26
25
|
}
|
|
27
|
-
return (
|
|
28
|
-
value
|
|
29
|
-
}) => parseObjectValue(value) !== parseObjectValue(filterItem.value);
|
|
26
|
+
return value => parseObjectValue(value) !== parseObjectValue(filterItem.value);
|
|
30
27
|
},
|
|
31
28
|
InputComponent: GridFilterInputSingleSelect
|
|
32
29
|
}, {
|
|
33
30
|
value: 'isAnyOf',
|
|
34
|
-
|
|
31
|
+
getApplyFilterFnV7: filterItem => {
|
|
35
32
|
if (!Array.isArray(filterItem.value) || filterItem.value.length === 0) {
|
|
36
33
|
return null;
|
|
37
34
|
}
|
|
38
35
|
const filterItemValues = filterItem.value.map(parseObjectValue);
|
|
39
|
-
return (
|
|
40
|
-
value
|
|
41
|
-
}) => filterItemValues.includes(parseObjectValue(value));
|
|
36
|
+
return value => filterItemValues.includes(parseObjectValue(value));
|
|
42
37
|
},
|
|
43
38
|
InputComponent: GridFilterInputMultipleSingleSelect
|
|
44
|
-
}];
|
|
39
|
+
}]);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { renderEditInputCell } from '../components/cell/GridEditInputCell';
|
|
2
2
|
import { gridStringOrNumberComparator } from '../hooks/features/sorting/gridSortingUtils';
|
|
3
3
|
import { getGridStringOperators, getGridStringQuickFilterFn } from './gridStringOperators';
|
|
4
|
+
import { convertQuickFilterV7ToLegacy } from './utils';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* TODO: Move pro and premium properties outside of this Community file
|
|
@@ -23,5 +24,6 @@ export const GRID_STRING_COL_DEF = {
|
|
|
23
24
|
align: 'left',
|
|
24
25
|
filterOperators: getGridStringOperators(),
|
|
25
26
|
renderEditCell: renderEditInputCell,
|
|
26
|
-
getApplyQuickFilterFn: getGridStringQuickFilterFn
|
|
27
|
+
getApplyQuickFilterFn: convertQuickFilterV7ToLegacy(getGridStringQuickFilterFn),
|
|
28
|
+
getApplyQuickFilterFnV7: getGridStringQuickFilterFn
|
|
27
29
|
};
|
|
@@ -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,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
|
+
}
|
|
@@ -38,21 +38,35 @@ export const GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginat
|
|
|
38
38
|
const handlePageChange = React.useCallback((_, page) => {
|
|
39
39
|
apiRef.current.setPage(page);
|
|
40
40
|
}, [apiRef]);
|
|
41
|
+
const isPageSizeIncludedInPageSizeOptions = pageSize => {
|
|
42
|
+
for (let i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
|
|
43
|
+
const option = rootProps.pageSizeOptions[i];
|
|
44
|
+
if (typeof option === 'number') {
|
|
45
|
+
if (option === pageSize) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
} else if (option.value === pageSize) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
};
|
|
41
54
|
if (process.env.NODE_ENV !== 'production') {
|
|
42
55
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
43
56
|
const warnedOnceMissingInPageSizeOptions = React.useRef(false);
|
|
44
57
|
const pageSize = rootProps.paginationModel?.pageSize ?? paginationModel.pageSize;
|
|
45
|
-
if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !
|
|
58
|
+
if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !isPageSizeIncludedInPageSizeOptions(pageSize)) {
|
|
46
59
|
console.warn([`MUI: The page size \`${paginationModel.pageSize}\` is not preset in the \`pageSizeOptions\``, `Add it to show the pagination select.`].join('\n'));
|
|
47
60
|
warnedOnceMissingInPageSizeOptions.current = true;
|
|
48
61
|
}
|
|
49
62
|
}
|
|
63
|
+
const pageSizeOptions = isPageSizeIncludedInPageSizeOptions(paginationModel.pageSize) ? rootProps.pageSizeOptions : [];
|
|
50
64
|
return /*#__PURE__*/_jsx(GridPaginationRoot, _extends({
|
|
51
65
|
ref: ref,
|
|
52
66
|
component: "div",
|
|
53
67
|
count: rowCount,
|
|
54
68
|
page: paginationModel.page <= lastPage ? paginationModel.page : lastPage,
|
|
55
|
-
rowsPerPageOptions:
|
|
69
|
+
rowsPerPageOptions: pageSizeOptions,
|
|
56
70
|
rowsPerPage: paginationModel.pageSize,
|
|
57
71
|
onPageChange: handlePageChange,
|
|
58
72
|
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 */
|
|
@@ -111,7 +111,7 @@ function GridEditDateCell(props) {
|
|
|
111
111
|
const meta = apiRef.current.unstable_getEditCellMeta(id, field);
|
|
112
112
|
const handleInputRef = el => {
|
|
113
113
|
inputRef.current = el;
|
|
114
|
-
if (meta
|
|
114
|
+
if (meta?.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
|
|
115
115
|
const inputValue = inputRef.current.value;
|
|
116
116
|
const parsedDate = parseValueToDate(inputValue);
|
|
117
117
|
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
|
|
73
|
+
if (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();
|