Skip to content

Commit

Permalink
avoid typing function arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii committed Nov 9, 2023
1 parent ab1b35e commit b30a765
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/grid/x-data-grid/src/colDef/gridNumericOperators.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GridFilterInputValue } from '../components/panel/filterPanel/GridFilterInputValue';
import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
import { GridFilterOperator } from '../models/gridFilterOperator';
import type { GridApplyQuickFilter } from '../models/colDef/gridColDef';
import type { GetApplyQuickFilterFn } from '../models/colDef/gridColDef';

const parseNumericValue = (value: unknown) => {
if (value == null) {
Expand All @@ -11,12 +11,14 @@ const parseNumericValue = (value: unknown) => {
return Number(value);
};

export const getGridNumericQuickFilterFn = (value: any): GridApplyQuickFilter | null => {
export const getGridNumericQuickFilterFn: GetApplyQuickFilterFn<any, number | string | null> = (
value,
) => {
if (value == null || Number.isNaN(value) || value === '') {
return null;
}

return (columnValue): boolean => {
return (columnValue) => {
return parseNumericValue(columnValue) === parseNumericValue(value);
};
};
Expand Down
6 changes: 3 additions & 3 deletions packages/grid/x-data-grid/src/colDef/gridStringOperators.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { GridFilterInputValue } from '../components/panel/filterPanel/GridFilterInputValue';
import { escapeRegExp } from '../utils/utils';
import type { GridApplyQuickFilter } from '../models/colDef/gridColDef';
import type { GetApplyQuickFilterFn } from '../models/colDef/gridColDef';
import { GridFilterItem } from '../models/gridFilterItem';
import { GridFilterOperator } from '../models/gridFilterOperator';
import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
import { removeDiacritics } from '../hooks/features/filter/gridFilterUtils';

export const getGridStringQuickFilterFn = (value: any): GridApplyQuickFilter | null => {
export const getGridStringQuickFilterFn: GetApplyQuickFilterFn<any, unknown> = (value) => {
if (!value) {
return null;
}
const filterRegex = new RegExp(escapeRegExp(value), 'i');
return (_, row, column, apiRef): boolean => {
return (_, row, column, apiRef) => {
let columnValue = apiRef.current.getRowFormattedValue(row, column);
if (apiRef.current.ignoreDiacritics) {
columnValue = removeDiacritics(columnValue);
Expand Down

0 comments on commit b30a765

Please sign in to comment.