@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,17 +1,17 @@
|
|
|
1
1
|
import { GridFilterInputBoolean } from '../components/panel/filterPanel/GridFilterInputBoolean';
|
|
2
|
+
import { convertLegacyOperators } from './utils';
|
|
2
3
|
export var getGridBooleanOperators = function getGridBooleanOperators() {
|
|
3
|
-
return [{
|
|
4
|
+
return convertLegacyOperators([{
|
|
4
5
|
value: 'is',
|
|
5
|
-
|
|
6
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
6
7
|
if (!filterItem.value) {
|
|
7
8
|
return null;
|
|
8
9
|
}
|
|
9
10
|
var valueAsBoolean = filterItem.value === 'true';
|
|
10
|
-
return function (
|
|
11
|
-
var value = _ref.value;
|
|
11
|
+
return function (value) {
|
|
12
12
|
return Boolean(value) === valueAsBoolean;
|
|
13
13
|
};
|
|
14
14
|
},
|
|
15
15
|
InputComponent: GridFilterInputBoolean
|
|
16
|
-
}];
|
|
16
|
+
}]);
|
|
17
17
|
};
|
|
@@ -19,6 +19,7 @@ export var 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: function valueGetter(params) {
|
|
23
24
|
var selectionLookup = selectedIdsLookupSelector(params.api.state, params.api.instanceId);
|
|
24
25
|
return selectionLookup[params.id] !== undefined;
|
|
@@ -49,6 +49,7 @@ export var GRID_DATE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
49
49
|
filterOperators: getGridDateOperators(),
|
|
50
50
|
renderEditCell: renderEditDateCell,
|
|
51
51
|
getApplyQuickFilterFn: undefined,
|
|
52
|
+
getApplyQuickFilterFnV7: undefined,
|
|
52
53
|
// @ts-ignore
|
|
53
54
|
pastedValueParser: function pastedValueParser(value) {
|
|
54
55
|
return new Date(value);
|
|
@@ -61,6 +62,7 @@ export var GRID_DATETIME_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
61
62
|
filterOperators: getGridDateOperators(true),
|
|
62
63
|
renderEditCell: renderEditDateCell,
|
|
63
64
|
getApplyQuickFilterFn: undefined,
|
|
65
|
+
getApplyQuickFilterFnV7: undefined,
|
|
64
66
|
// @ts-ignore
|
|
65
67
|
pastedValueParser: function pastedValueParser(value) {
|
|
66
68
|
return new Date(value);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import { GridFilterInputDate } from '../components/panel/filterPanel/GridFilterInputDate';
|
|
3
|
+
import { convertLegacyOperators } from './utils';
|
|
3
4
|
var dateRegex = /(\d+)-(\d+)-(\d+)/;
|
|
4
5
|
var dateTimeRegex = /(\d+)-(\d+)-(\d+)T(\d+):(\d+)/;
|
|
5
6
|
function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
|
|
@@ -14,8 +15,7 @@ function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
|
|
|
14
15
|
hour = _slice$map2[3],
|
|
15
16
|
minute = _slice$map2[4];
|
|
16
17
|
var time = new Date(year, month - 1, day, hour || 0, minute || 0).getTime();
|
|
17
|
-
return function (
|
|
18
|
-
var value = _ref.value;
|
|
18
|
+
return function (value) {
|
|
19
19
|
if (!value) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
@@ -30,9 +30,9 @@ function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
export var getGridDateOperators = function getGridDateOperators(showTime) {
|
|
33
|
-
return [{
|
|
33
|
+
return convertLegacyOperators([{
|
|
34
34
|
value: 'is',
|
|
35
|
-
|
|
35
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
36
36
|
return buildApplyFilterFn(filterItem, function (value1, value2) {
|
|
37
37
|
return value1 === value2;
|
|
38
38
|
}, showTime);
|
|
@@ -43,7 +43,7 @@ export var getGridDateOperators = function getGridDateOperators(showTime) {
|
|
|
43
43
|
}
|
|
44
44
|
}, {
|
|
45
45
|
value: 'not',
|
|
46
|
-
|
|
46
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
47
47
|
return buildApplyFilterFn(filterItem, function (value1, value2) {
|
|
48
48
|
return value1 !== value2;
|
|
49
49
|
}, showTime);
|
|
@@ -54,7 +54,7 @@ export var getGridDateOperators = function getGridDateOperators(showTime) {
|
|
|
54
54
|
}
|
|
55
55
|
}, {
|
|
56
56
|
value: 'after',
|
|
57
|
-
|
|
57
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
58
58
|
return buildApplyFilterFn(filterItem, function (value1, value2) {
|
|
59
59
|
return value1 > value2;
|
|
60
60
|
}, showTime);
|
|
@@ -65,7 +65,7 @@ export var getGridDateOperators = function getGridDateOperators(showTime) {
|
|
|
65
65
|
}
|
|
66
66
|
}, {
|
|
67
67
|
value: 'onOrAfter',
|
|
68
|
-
|
|
68
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
69
69
|
return buildApplyFilterFn(filterItem, function (value1, value2) {
|
|
70
70
|
return value1 >= value2;
|
|
71
71
|
}, showTime);
|
|
@@ -76,7 +76,7 @@ export var getGridDateOperators = function getGridDateOperators(showTime) {
|
|
|
76
76
|
}
|
|
77
77
|
}, {
|
|
78
78
|
value: 'before',
|
|
79
|
-
|
|
79
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
80
80
|
return buildApplyFilterFn(filterItem, function (value1, value2) {
|
|
81
81
|
return value1 < value2;
|
|
82
82
|
}, showTime, !showTime);
|
|
@@ -87,7 +87,7 @@ export var getGridDateOperators = function getGridDateOperators(showTime) {
|
|
|
87
87
|
}
|
|
88
88
|
}, {
|
|
89
89
|
value: 'onOrBefore',
|
|
90
|
-
|
|
90
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
91
91
|
return buildApplyFilterFn(filterItem, function (value1, value2) {
|
|
92
92
|
return value1 <= value2;
|
|
93
93
|
}, showTime);
|
|
@@ -98,21 +98,19 @@ export var getGridDateOperators = function getGridDateOperators(showTime) {
|
|
|
98
98
|
}
|
|
99
99
|
}, {
|
|
100
100
|
value: 'isEmpty',
|
|
101
|
-
|
|
102
|
-
return function (
|
|
103
|
-
var value = _ref2.value;
|
|
101
|
+
getApplyFilterFnV7: function getApplyFilterFnV7() {
|
|
102
|
+
return function (value) {
|
|
104
103
|
return value == null;
|
|
105
104
|
};
|
|
106
105
|
},
|
|
107
106
|
requiresFilterValue: false
|
|
108
107
|
}, {
|
|
109
108
|
value: 'isNotEmpty',
|
|
110
|
-
|
|
111
|
-
return function (
|
|
112
|
-
var value = _ref3.value;
|
|
109
|
+
getApplyFilterFnV7: function getApplyFilterFnV7() {
|
|
110
|
+
return function (value) {
|
|
113
111
|
return value != null;
|
|
114
112
|
};
|
|
115
113
|
},
|
|
116
114
|
requiresFilterValue: false
|
|
117
|
-
}];
|
|
115
|
+
}]);
|
|
118
116
|
};
|
|
@@ -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 var GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
7
8
|
type: 'number',
|
|
8
9
|
align: 'right',
|
|
@@ -16,5 +17,6 @@ export var GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
16
17
|
return isNumber(value) ? value.toLocaleString() : value || '';
|
|
17
18
|
},
|
|
18
19
|
filterOperators: getGridNumericOperators(),
|
|
19
|
-
getApplyQuickFilterFn: getGridNumericQuickFilterFn
|
|
20
|
+
getApplyQuickFilterFn: convertQuickFilterV7ToLegacy(getGridNumericQuickFilterFn),
|
|
21
|
+
getApplyQuickFilterFnV7: getGridNumericQuickFilterFn
|
|
20
22
|
});
|
|
@@ -1,29 +1,28 @@
|
|
|
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
|
var parseNumericValue = function parseNumericValue(value) {
|
|
4
5
|
if (value == null) {
|
|
5
6
|
return null;
|
|
6
7
|
}
|
|
7
8
|
return Number(value);
|
|
8
9
|
};
|
|
9
|
-
export var getGridNumericQuickFilterFn = function
|
|
10
|
+
export var getGridNumericQuickFilterFn = tagInternalFilter(function (value) {
|
|
10
11
|
if (value == null || Number.isNaN(value) || value === '') {
|
|
11
12
|
return null;
|
|
12
13
|
}
|
|
13
|
-
return function (
|
|
14
|
-
var columnValue = _ref.value;
|
|
14
|
+
return function (columnValue) {
|
|
15
15
|
return parseNumericValue(columnValue) === parseNumericValue(value);
|
|
16
16
|
};
|
|
17
|
-
};
|
|
17
|
+
});
|
|
18
18
|
export var getGridNumericOperators = function getGridNumericOperators() {
|
|
19
|
-
return [{
|
|
19
|
+
return convertLegacyOperators([{
|
|
20
20
|
value: '=',
|
|
21
|
-
|
|
21
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
22
22
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
return function (
|
|
26
|
-
var value = _ref2.value;
|
|
25
|
+
return function (value) {
|
|
27
26
|
return parseNumericValue(value) === filterItem.value;
|
|
28
27
|
};
|
|
29
28
|
},
|
|
@@ -33,12 +32,11 @@ export var getGridNumericOperators = function getGridNumericOperators() {
|
|
|
33
32
|
}
|
|
34
33
|
}, {
|
|
35
34
|
value: '!=',
|
|
36
|
-
|
|
35
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
37
36
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
38
37
|
return null;
|
|
39
38
|
}
|
|
40
|
-
return function (
|
|
41
|
-
var value = _ref3.value;
|
|
39
|
+
return function (value) {
|
|
42
40
|
return parseNumericValue(value) !== filterItem.value;
|
|
43
41
|
};
|
|
44
42
|
},
|
|
@@ -48,12 +46,11 @@ export var getGridNumericOperators = function getGridNumericOperators() {
|
|
|
48
46
|
}
|
|
49
47
|
}, {
|
|
50
48
|
value: '>',
|
|
51
|
-
|
|
49
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
52
50
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
53
51
|
return null;
|
|
54
52
|
}
|
|
55
|
-
return function (
|
|
56
|
-
var value = _ref4.value;
|
|
53
|
+
return function (value) {
|
|
57
54
|
if (value == null) {
|
|
58
55
|
return false;
|
|
59
56
|
}
|
|
@@ -66,12 +63,11 @@ export var getGridNumericOperators = function getGridNumericOperators() {
|
|
|
66
63
|
}
|
|
67
64
|
}, {
|
|
68
65
|
value: '>=',
|
|
69
|
-
|
|
66
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
70
67
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
71
68
|
return null;
|
|
72
69
|
}
|
|
73
|
-
return function (
|
|
74
|
-
var value = _ref5.value;
|
|
70
|
+
return function (value) {
|
|
75
71
|
if (value == null) {
|
|
76
72
|
return false;
|
|
77
73
|
}
|
|
@@ -84,12 +80,11 @@ export var getGridNumericOperators = function getGridNumericOperators() {
|
|
|
84
80
|
}
|
|
85
81
|
}, {
|
|
86
82
|
value: '<',
|
|
87
|
-
|
|
83
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
88
84
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
89
85
|
return null;
|
|
90
86
|
}
|
|
91
|
-
return function (
|
|
92
|
-
var value = _ref6.value;
|
|
87
|
+
return function (value) {
|
|
93
88
|
if (value == null) {
|
|
94
89
|
return false;
|
|
95
90
|
}
|
|
@@ -102,12 +97,11 @@ export var getGridNumericOperators = function getGridNumericOperators() {
|
|
|
102
97
|
}
|
|
103
98
|
}, {
|
|
104
99
|
value: '<=',
|
|
105
|
-
|
|
100
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
106
101
|
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
|
|
107
102
|
return null;
|
|
108
103
|
}
|
|
109
|
-
return function (
|
|
110
|
-
var value = _ref7.value;
|
|
104
|
+
return function (value) {
|
|
111
105
|
if (value == null) {
|
|
112
106
|
return false;
|
|
113
107
|
}
|
|
@@ -120,30 +114,27 @@ export var getGridNumericOperators = function getGridNumericOperators() {
|
|
|
120
114
|
}
|
|
121
115
|
}, {
|
|
122
116
|
value: 'isEmpty',
|
|
123
|
-
|
|
124
|
-
return function (
|
|
125
|
-
var value = _ref8.value;
|
|
117
|
+
getApplyFilterFnV7: function getApplyFilterFnV7() {
|
|
118
|
+
return function (value) {
|
|
126
119
|
return value == null;
|
|
127
120
|
};
|
|
128
121
|
},
|
|
129
122
|
requiresFilterValue: false
|
|
130
123
|
}, {
|
|
131
124
|
value: 'isNotEmpty',
|
|
132
|
-
|
|
133
|
-
return function (
|
|
134
|
-
var value = _ref9.value;
|
|
125
|
+
getApplyFilterFnV7: function getApplyFilterFnV7() {
|
|
126
|
+
return function (value) {
|
|
135
127
|
return value != null;
|
|
136
128
|
};
|
|
137
129
|
},
|
|
138
130
|
requiresFilterValue: false
|
|
139
131
|
}, {
|
|
140
132
|
value: 'isAnyOf',
|
|
141
|
-
|
|
133
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
142
134
|
if (!Array.isArray(filterItem.value) || filterItem.value.length === 0) {
|
|
143
135
|
return null;
|
|
144
136
|
}
|
|
145
|
-
return function (
|
|
146
|
-
var value = _ref10.value;
|
|
137
|
+
return function (value) {
|
|
147
138
|
return value != null && filterItem.value.includes(Number(value));
|
|
148
139
|
};
|
|
149
140
|
},
|
|
@@ -151,5 +142,5 @@ export var getGridNumericOperators = function getGridNumericOperators() {
|
|
|
151
142
|
InputComponentProps: {
|
|
152
143
|
type: 'number'
|
|
153
144
|
}
|
|
154
|
-
}];
|
|
145
|
+
}]);
|
|
155
146
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
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
|
var parseObjectValue = function parseObjectValue(value) {
|
|
5
6
|
if (value == null || !isObject(value)) {
|
|
6
7
|
return value;
|
|
@@ -8,42 +9,39 @@ var parseObjectValue = function parseObjectValue(value) {
|
|
|
8
9
|
return value.value;
|
|
9
10
|
};
|
|
10
11
|
export var getGridSingleSelectOperators = function getGridSingleSelectOperators() {
|
|
11
|
-
return [{
|
|
12
|
+
return convertLegacyOperators([{
|
|
12
13
|
value: 'is',
|
|
13
|
-
|
|
14
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
14
15
|
if (filterItem.value == null || filterItem.value === '') {
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
|
-
return function (
|
|
18
|
-
var value = _ref.value;
|
|
18
|
+
return function (value) {
|
|
19
19
|
return parseObjectValue(value) === parseObjectValue(filterItem.value);
|
|
20
20
|
};
|
|
21
21
|
},
|
|
22
22
|
InputComponent: GridFilterInputSingleSelect
|
|
23
23
|
}, {
|
|
24
24
|
value: 'not',
|
|
25
|
-
|
|
25
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
26
26
|
if (filterItem.value == null || filterItem.value === '') {
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
return function (
|
|
30
|
-
var value = _ref2.value;
|
|
29
|
+
return function (value) {
|
|
31
30
|
return parseObjectValue(value) !== parseObjectValue(filterItem.value);
|
|
32
31
|
};
|
|
33
32
|
},
|
|
34
33
|
InputComponent: GridFilterInputSingleSelect
|
|
35
34
|
}, {
|
|
36
35
|
value: 'isAnyOf',
|
|
37
|
-
|
|
36
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
38
37
|
if (!Array.isArray(filterItem.value) || filterItem.value.length === 0) {
|
|
39
38
|
return null;
|
|
40
39
|
}
|
|
41
40
|
var filterItemValues = filterItem.value.map(parseObjectValue);
|
|
42
|
-
return function (
|
|
43
|
-
var value = _ref3.value;
|
|
41
|
+
return function (value) {
|
|
44
42
|
return filterItemValues.includes(parseObjectValue(value));
|
|
45
43
|
};
|
|
46
44
|
},
|
|
47
45
|
InputComponent: GridFilterInputMultipleSingleSelect
|
|
48
|
-
}];
|
|
46
|
+
}]);
|
|
49
47
|
};
|
|
@@ -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 var 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,35 @@
|
|
|
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 var getGridStringQuickFilterFn = tagInternalFilter(function (value) {
|
|
5
6
|
if (!value) {
|
|
6
7
|
return null;
|
|
7
8
|
}
|
|
8
9
|
var filterRegex = new RegExp(escapeRegExp(value), 'i');
|
|
9
|
-
return function (
|
|
10
|
-
var columnValue =
|
|
10
|
+
return function (_, row, column, apiRef) {
|
|
11
|
+
var columnValue = apiRef.current.getRowFormattedValue(row, column);
|
|
11
12
|
return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
|
|
12
13
|
};
|
|
13
|
-
};
|
|
14
|
+
});
|
|
14
15
|
export var getGridStringOperators = function getGridStringOperators() {
|
|
15
16
|
var disableTrim = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
16
|
-
return [{
|
|
17
|
+
return convertLegacyOperators([{
|
|
17
18
|
value: 'contains',
|
|
18
|
-
|
|
19
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
19
20
|
if (!filterItem.value) {
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
22
23
|
var filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();
|
|
23
24
|
var filterRegex = new RegExp(escapeRegExp(filterItemValue), 'i');
|
|
24
|
-
return function (
|
|
25
|
-
|
|
26
|
-
return value != null ? filterRegex.test(value.toString()) : false;
|
|
25
|
+
return function (value) {
|
|
26
|
+
return value != null ? filterRegex.test(String(value)) : false;
|
|
27
27
|
};
|
|
28
28
|
},
|
|
29
29
|
InputComponent: GridFilterInputValue
|
|
30
30
|
}, {
|
|
31
31
|
value: 'equals',
|
|
32
|
-
|
|
32
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
33
33
|
if (!filterItem.value) {
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
@@ -38,61 +38,56 @@ export var getGridStringOperators = function getGridStringOperators() {
|
|
|
38
38
|
sensitivity: 'base',
|
|
39
39
|
usage: 'search'
|
|
40
40
|
});
|
|
41
|
-
return function (
|
|
42
|
-
var value = _ref3.value;
|
|
41
|
+
return function (value) {
|
|
43
42
|
return value != null ? collator.compare(filterItemValue, value.toString()) === 0 : false;
|
|
44
43
|
};
|
|
45
44
|
},
|
|
46
45
|
InputComponent: GridFilterInputValue
|
|
47
46
|
}, {
|
|
48
47
|
value: 'startsWith',
|
|
49
|
-
|
|
48
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
50
49
|
if (!filterItem.value) {
|
|
51
50
|
return null;
|
|
52
51
|
}
|
|
53
52
|
var filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();
|
|
54
53
|
var filterRegex = new RegExp("^".concat(escapeRegExp(filterItemValue), ".*$"), 'i');
|
|
55
|
-
return function (
|
|
56
|
-
var value = _ref4.value;
|
|
54
|
+
return function (value) {
|
|
57
55
|
return value != null ? filterRegex.test(value.toString()) : false;
|
|
58
56
|
};
|
|
59
57
|
},
|
|
60
58
|
InputComponent: GridFilterInputValue
|
|
61
59
|
}, {
|
|
62
60
|
value: 'endsWith',
|
|
63
|
-
|
|
61
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
64
62
|
if (!filterItem.value) {
|
|
65
63
|
return null;
|
|
66
64
|
}
|
|
67
65
|
var filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();
|
|
68
66
|
var filterRegex = new RegExp(".*".concat(escapeRegExp(filterItemValue), "$"), 'i');
|
|
69
|
-
return function (
|
|
70
|
-
var value = _ref5.value;
|
|
67
|
+
return function (value) {
|
|
71
68
|
return value != null ? filterRegex.test(value.toString()) : false;
|
|
72
69
|
};
|
|
73
70
|
},
|
|
74
71
|
InputComponent: GridFilterInputValue
|
|
75
72
|
}, {
|
|
76
73
|
value: 'isEmpty',
|
|
77
|
-
|
|
78
|
-
return function (
|
|
79
|
-
var value = _ref6.value;
|
|
74
|
+
getApplyFilterFnV7: function getApplyFilterFnV7() {
|
|
75
|
+
return function (value) {
|
|
80
76
|
return value === '' || value == null;
|
|
81
77
|
};
|
|
82
78
|
},
|
|
83
79
|
requiresFilterValue: false
|
|
84
80
|
}, {
|
|
85
81
|
value: 'isNotEmpty',
|
|
86
|
-
|
|
87
|
-
return function (
|
|
88
|
-
var value = _ref7.value;
|
|
82
|
+
getApplyFilterFnV7: function getApplyFilterFnV7() {
|
|
83
|
+
return function (value) {
|
|
89
84
|
return value !== '' && value != null;
|
|
90
85
|
};
|
|
91
86
|
},
|
|
92
87
|
requiresFilterValue: false
|
|
93
88
|
}, {
|
|
94
89
|
value: 'isAnyOf',
|
|
95
|
-
|
|
90
|
+
getApplyFilterFnV7: function getApplyFilterFnV7(filterItem) {
|
|
96
91
|
if (!Array.isArray(filterItem.value) || filterItem.value.length === 0) {
|
|
97
92
|
return null;
|
|
98
93
|
}
|
|
@@ -103,13 +98,12 @@ export var getGridStringOperators = function getGridStringOperators() {
|
|
|
103
98
|
sensitivity: 'base',
|
|
104
99
|
usage: 'search'
|
|
105
100
|
});
|
|
106
|
-
return function (
|
|
107
|
-
var value = _ref8.value;
|
|
101
|
+
return function (value) {
|
|
108
102
|
return value != null ? filterItemValue.some(function (filterValue) {
|
|
109
103
|
return collator.compare(filterValue, value.toString() || '') === 0;
|
|
110
104
|
}) : false;
|
|
111
105
|
};
|
|
112
106
|
},
|
|
113
107
|
InputComponent: GridFilterInputMultipleValue
|
|
114
|
-
}];
|
|
108
|
+
}]);
|
|
115
109
|
};
|
|
@@ -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 var 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(function (filterItem, column) {
|
|
24
|
+
var filterFn = fn(filterItem, column);
|
|
25
|
+
if (!filterFn) {
|
|
26
|
+
return filterFn;
|
|
27
|
+
}
|
|
28
|
+
return function (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(function (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(function (filterItem, column, apiRef) {
|
|
43
|
+
var filterFn = fn(filterItem, column, apiRef);
|
|
44
|
+
if (!filterFn) {
|
|
45
|
+
return filterFn;
|
|
46
|
+
}
|
|
47
|
+
return function (cellParams) {
|
|
48
|
+
return filterFn(cellParams.value, cellParams.row, column, apiRef);
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -23,7 +23,6 @@ var GridPaginationRoot = styled(TablePagination)(function (_ref) {
|
|
|
23
23
|
})), _ref2;
|
|
24
24
|
});
|
|
25
25
|
export var GridPagination = /*#__PURE__*/React.forwardRef(function GridPagination(props, ref) {
|
|
26
|
-
var _rootProps$pageSizeOp;
|
|
27
26
|
var apiRef = useGridApiContext();
|
|
28
27
|
var rootProps = useGridRootProps();
|
|
29
28
|
var paginationModel = useGridSelector(apiRef, gridPaginationModelSelector);
|
|
@@ -42,22 +41,36 @@ export var GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginatio
|
|
|
42
41
|
var handlePageChange = React.useCallback(function (_, page) {
|
|
43
42
|
apiRef.current.setPage(page);
|
|
44
43
|
}, [apiRef]);
|
|
44
|
+
var isPageSizeIncludedInPageSizeOptions = function isPageSizeIncludedInPageSizeOptions(pageSize) {
|
|
45
|
+
for (var i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
|
|
46
|
+
var 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
|
var warnedOnceMissingInPageSizeOptions = React.useRef(false);
|
|
49
61
|
var 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 `".concat(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
|
+
var 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 _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
var _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 */
|
|
@@ -153,6 +153,7 @@ var GridCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
153
153
|
var _rootProps$experiment;
|
|
154
154
|
var align = props.align,
|
|
155
155
|
childrenProp = props.children,
|
|
156
|
+
editCellState = props.editCellState,
|
|
156
157
|
colIndex = props.colIndex,
|
|
157
158
|
column = props.column,
|
|
158
159
|
cellMode = props.cellMode,
|
|
@@ -151,7 +151,7 @@ function GridEditDateCell(props) {
|
|
|
151
151
|
var meta = apiRef.current.unstable_getEditCellMeta(id, field);
|
|
152
152
|
var handleInputRef = function handleInputRef(el) {
|
|
153
153
|
inputRef.current = el;
|
|
154
|
-
if (meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
|
|
154
|
+
if (meta != null && meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
|
|
155
155
|
var inputValue = inputRef.current.value;
|
|
156
156
|
var parsedDate = parseValueToDate(inputValue);
|
|
157
157
|
setValueState({
|