Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Filtering performance: V7 API #9254

Merged
merged 46 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
fb1ea84
perf: v7 filters
romgrk Jun 7, 2023
9830c58
lint
romgrk Jun 7, 2023
9608d9d
fix: aggregation filtering
romgrk Jun 7, 2023
fad4bb2
lint
romgrk Jun 7, 2023
030f2a5
fix: some tests
romgrk Jun 7, 2023
1b063cb
Merge branch 'master' into perf-filtering-v7-filters
romgrk Jun 9, 2023
64ba858
fix: some tests
romgrk Jun 9, 2023
2c4d970
fix: rows list
romgrk Jun 9, 2023
40e05b4
fix: quickfilter
romgrk Jun 9, 2023
c24143a
lint
romgrk Jun 9, 2023
e8a8aec
lint
romgrk Jun 9, 2023
a7483b4
lint
romgrk Jun 9, 2023
6fd694f
lint
romgrk Jun 9, 2023
d1be29a
fix: restore column fields
romgrk Jun 12, 2023
3e0a6bc
Merge branch 'master' into perf-filtering-v7-filters
romgrk Jun 14, 2023
b04cb1e
refactor
romgrk Jun 14, 2023
f7cb7b6
docs
romgrk Jun 14, 2023
9fdbe9a
lint
romgrk Jun 14, 2023
5706be9
doc: update
romgrk Jun 14, 2023
3a084e6
doc
romgrk Jun 14, 2023
03e6cd8
Update docs/data/data-grid/filtering/customization.md
romgrk Jun 14, 2023
c66cd40
Update docs/data/data-grid/filtering/customization.md
romgrk Jun 14, 2023
adc8027
fix: missed v7 refactor
romgrk Jun 14, 2023
6223641
Merge branch 'perf-filtering-v7-filters' of github.com:romgrk/mui-x i…
romgrk Jun 14, 2023
f7b30d4
refactor: typings
romgrk Jun 14, 2023
f7b19c6
lint
romgrk Jun 14, 2023
6f5fb73
lint
romgrk Jun 14, 2023
c285417
Merge branch 'master' into perf-filtering-v7-filters
romgrk Jun 20, 2023
1372ed9
refactor: compatibility changes
romgrk Jun 20, 2023
08a3223
doc: update
romgrk Jun 20, 2023
d59889f
lint
romgrk Jun 20, 2023
5c26f45
lint
romgrk Jun 20, 2023
343c385
lint
romgrk Jun 20, 2023
c9146f5
lint
romgrk Jun 21, 2023
dca10c7
fix: quickfilter compatibility
romgrk Jun 21, 2023
cde04ba
lint
romgrk Jun 21, 2023
ff9d602
Update packages/grid/x-data-grid/src/models/api/gridParamsApi.ts
romgrk Jun 21, 2023
441ee98
Update packages/grid/x-data-grid/src/models/api/gridParamsApi.ts
romgrk Jun 21, 2023
3eb9812
lint
romgrk Jun 28, 2023
2dda132
refactor
romgrk Jun 28, 2023
725139e
test: add v7 compat
romgrk Jun 28, 2023
2c6f402
Merge branch 'perf-filtering-v7-filters' of github.com:romgrk/mui-x i…
romgrk Jun 28, 2023
0af6482
test: add v7 qf tests
romgrk Jun 28, 2023
3cbac8f
lint
romgrk Jun 28, 2023
52482e5
lint
romgrk Jun 28, 2023
ffa0250
docs: api
romgrk Jun 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
  • Loading branch information
romgrk committed Jun 14, 2023
commit 9fdbe9a1428eab8500ffb8a427b63ed3440081da
11 changes: 0 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,6 @@ module.exports = {
rules: {
...baseline.rules,
'import/prefer-default-export': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
// TODO move rule into the main repo once it has upgraded
'@typescript-eslint/return-await': 'off',
'no-restricted-imports': 'off',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getGridBooleanOperators = (): GridFilterOperator<any, boolean | nul
}

const valueAsBoolean = filterItem.value === 'true';
return (value, _, __, ___): boolean => {
return (value): boolean => {
return Boolean(value) === valueAsBoolean;
};
},
Expand Down
6 changes: 3 additions & 3 deletions packages/grid/x-data-grid/src/colDef/gridDateOperators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function buildApplyFilterFn(

const time = new Date(year, month - 1, day, hour || 0, minute || 0).getTime();

return (value, _, __, ___): boolean => {
return (value): boolean => {
if (!value) {
return false;
}
Expand Down Expand Up @@ -102,7 +102,7 @@ export const getGridDateOperators = (showTime?: boolean): GridFilterOperator<any
{
value: 'isEmpty',
getApplyFilterFnV7: () => {
return (value, _, __, ___): boolean => {
return (value): boolean => {
return value == null;
};
},
Expand All @@ -111,7 +111,7 @@ export const getGridDateOperators = (showTime?: boolean): GridFilterOperator<any
{
value: 'isNotEmpty',
getApplyFilterFnV7: () => {
return (value, _, __, ___): boolean => {
return (value): boolean => {
return value != null;
};
},
Expand Down
20 changes: 10 additions & 10 deletions packages/grid/x-data-grid/src/colDef/gridNumericOperators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const getGridNumericQuickFilterFn = (value: any): GridApplyQuickFilterV7
return null;
}

return (columnValue, _, __, ___): boolean => {
return (columnValue): boolean => {
return parseNumericValue(columnValue) === parseNumericValue(value);
};
};
Expand All @@ -31,7 +31,7 @@ export const getGridNumericOperators = (): GridFilterOperator<any, number | stri
return null;
}

return (value, _, __, ___): boolean => {
return (value): boolean => {
return parseNumericValue(value) === filterItem.value;
};
},
Expand All @@ -45,7 +45,7 @@ export const getGridNumericOperators = (): GridFilterOperator<any, number | stri
return null;
}

return (value, _, __, ___): boolean => {
return (value): boolean => {
return parseNumericValue(value) !== filterItem.value;
};
},
Expand All @@ -59,7 +59,7 @@ export const getGridNumericOperators = (): GridFilterOperator<any, number | stri
return null;
}

return (value, _, __, ___): boolean => {
return (value): boolean => {
if (value == null) {
return false;
}
Expand All @@ -77,7 +77,7 @@ export const getGridNumericOperators = (): GridFilterOperator<any, number | stri
return null;
}

return (value, _, __, ___): boolean => {
return (value): boolean => {
if (value == null) {
return false;
}
Expand All @@ -95,7 +95,7 @@ export const getGridNumericOperators = (): GridFilterOperator<any, number | stri
return null;
}

return (value, _, __, ___): boolean => {
return (value): boolean => {
if (value == null) {
return false;
}
Expand All @@ -113,7 +113,7 @@ export const getGridNumericOperators = (): GridFilterOperator<any, number | stri
return null;
}

return (value, _, __, ___): boolean => {
return (value): boolean => {
if (value == null) {
return false;
}
Expand All @@ -127,7 +127,7 @@ export const getGridNumericOperators = (): GridFilterOperator<any, number | stri
{
value: 'isEmpty',
getApplyFilterFnV7: () => {
return (value, _, __, ___): boolean => {
return (value): boolean => {
return value == null;
};
},
Expand All @@ -136,7 +136,7 @@ export const getGridNumericOperators = (): GridFilterOperator<any, number | stri
{
value: 'isNotEmpty',
getApplyFilterFnV7: () => {
return (value, _, __, ___): boolean => {
return (value): boolean => {
return value != null;
};
},
Expand All @@ -149,7 +149,7 @@ export const getGridNumericOperators = (): GridFilterOperator<any, number | stri
return null;
}

return (value, _, __, ___): boolean => {
return (value): boolean => {
return value != null && filterItem.value.includes(Number(value));
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export const getGridSingleSelectOperators = (): GridFilterOperator[] =>
if (filterItem.value == null || filterItem.value === '') {
return null;
}
return (value, _, __, ___): boolean =>
parseObjectValue(value) === parseObjectValue(filterItem.value);
return (value): boolean => parseObjectValue(value) === parseObjectValue(filterItem.value);
},
InputComponent: GridFilterInputSingleSelect,
},
Expand All @@ -30,8 +29,7 @@ export const getGridSingleSelectOperators = (): GridFilterOperator[] =>
if (filterItem.value == null || filterItem.value === '') {
return null;
}
return (value, _, __, ___): boolean =>
parseObjectValue(value) !== parseObjectValue(filterItem.value);
return (value): boolean => parseObjectValue(value) !== parseObjectValue(filterItem.value);
},
InputComponent: GridFilterInputSingleSelect,
},
Expand All @@ -42,7 +40,7 @@ export const getGridSingleSelectOperators = (): GridFilterOperator[] =>
return null;
}
const filterItemValues = filterItem.value.map(parseObjectValue);
return (value, _, __, ___): boolean => filterItemValues.includes(parseObjectValue(value));
return (value): boolean => filterItemValues.includes(parseObjectValue(value));
},
InputComponent: GridFilterInputMultipleSingleSelect,
},
Expand Down
14 changes: 7 additions & 7 deletions packages/grid/x-data-grid/src/colDef/gridStringOperators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const getGridStringOperators = (
const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();

const filterRegex = new RegExp(escapeRegExp(filterItemValue), 'i');
return (value, _, __, ___): boolean => {
return (value): boolean => {
return value != null ? filterRegex.test(String(value)) : false;
};
},
Expand All @@ -45,7 +45,7 @@ export const getGridStringOperators = (
const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();

const collator = new Intl.Collator(undefined, { sensitivity: 'base', usage: 'search' });
return (value, _, __, ___): boolean => {
return (value): boolean => {
return value != null ? collator.compare(filterItemValue, value.toString()) === 0 : false;
};
},
Expand All @@ -60,7 +60,7 @@ export const getGridStringOperators = (
const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();

const filterRegex = new RegExp(`^${escapeRegExp(filterItemValue)}.*$`, 'i');
return (value, _, __, ___): boolean => {
return (value): boolean => {
return value != null ? filterRegex.test(value.toString()) : false;
};
},
Expand All @@ -75,7 +75,7 @@ export const getGridStringOperators = (
const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();

const filterRegex = new RegExp(`.*${escapeRegExp(filterItemValue)}$`, 'i');
return (value, _, __, ___): boolean => {
return (value): boolean => {
return value != null ? filterRegex.test(value.toString()) : false;
};
},
Expand All @@ -84,7 +84,7 @@ export const getGridStringOperators = (
{
value: 'isEmpty',
getApplyFilterFnV7: () => {
return (value, _, __, ___): boolean => {
return (value): boolean => {
return value === '' || value == null;
};
},
Expand All @@ -93,7 +93,7 @@ export const getGridStringOperators = (
{
value: 'isNotEmpty',
getApplyFilterFnV7: () => {
return (value, _, __, ___): boolean => {
return (value): boolean => {
return value !== '' && value != null;
};
},
Expand All @@ -110,7 +110,7 @@ export const getGridStringOperators = (
: filterItem.value.map((val) => val.trim());
const collator = new Intl.Collator(undefined, { sensitivity: 'base', usage: 'search' });

return (value, _, __, ___): boolean =>
return (value): boolean =>
value != null
? filterItemValue.some((filterValue: GridFilterItem['value']) => {
return collator.compare(filterValue, value.toString() || '') === 0;
Expand Down