Skip to content

Commit 098253c

Browse files
author
Alyar
committed
Add type for popupOptions
1 parent 5671f11 commit 098253c

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

packages/devextreme/js/__internal/grids/new/grid_core/filtering/header_filter/legacy_header_filter.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import { updateHeaderFilterItemSelectionState } from '@ts/grids/grid_core/header
2525
import gridCoreUtils from '@ts/grids/grid_core/m_utils';
2626
import type { Column } from '@ts/grids/new/grid_core/columns_controller/types';
2727

28+
import type { HeaderFilterListType } from './types';
29+
2830
export const getHeaderItemText = (
2931
displayValue,
3032
column,
@@ -211,9 +213,9 @@ export const getDataSourceOptions = (
211213
return options.dataSource;
212214
};
213215

214-
export const getFilterType = (
216+
export const getHeaderFilterListType = (
215217
column: Column,
216-
): 'tree' | 'list' => {
218+
): HeaderFilterListType => {
217219
const groupInterval = filteringUtils.getGroupInterval(column);
218220
return groupInterval && groupInterval.length > 1 ? 'tree' : 'list';
219221
};

packages/devextreme/js/__internal/grids/new/grid_core/filtering/header_filter/types.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1+
import type { FilterType } from '@js/common/grids';
12
import type { DataSourceLike } from '@js/data/data_source';
23

4+
import type { Column } from '../../columns_controller/types';
5+
36
export type HeaderFilterSearchMode = 'contains' | 'startswith' | 'equals';
47
export type HeaderFilterType = 'include' | 'exclude';
8+
export type HeaderFilterListType = 'tree' | 'list';
9+
10+
export interface PopupOptions {
11+
type: HeaderFilterListType;
12+
column: Column;
13+
headerFilter: HeaderFilterColumnOptions;
14+
dataSource?: DataSourceLike<unknown>;
15+
isFilterBuilder?: boolean;
16+
filterType?: FilterType;
17+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
18+
filterValues?: any[];
19+
apply: () => void;
20+
hidePopupCallback: () => void;
21+
}
522

623
export type PopupState = {
724
element: Element;
8-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9-
options: Record<string, any>;
25+
options: PopupOptions;
1026
} | null;
1127

1228
export interface HeaderFilterTextOptions {

packages/devextreme/js/__internal/grids/new/grid_core/filtering/header_filter/view.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('HeaderFilter', () => {
114114
{ popupState } as any,
115115
);
116116

117-
popupState.value = { element: {} as any, options: expectedOptions };
117+
popupState.value = { element: {} as any, options: expectedOptions as any };
118118

119119
expect(oldHeaderFilterMock.showHeaderFilterMenu)
120120
.toHaveBeenCalledTimes(1);
@@ -130,7 +130,7 @@ describe('HeaderFilter', () => {
130130
{ popupState } as any,
131131
);
132132

133-
popupState.value = { element: {} as any, options: {} };
133+
popupState.value = { element: {} as any, options: {} as any };
134134
popupState.value = null;
135135

136136
expect(oldHeaderFilterMock.showHeaderFilterMenu)

packages/devextreme/js/__internal/grids/new/grid_core/filtering/header_filter/view_controller.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ describe('HeaderFilter', () => {
156156

157157
const state = viewController.popupState.peek();
158158

159-
expect(typeof state?.options.dataSource.load).toBe('function');
160-
expect(typeof state?.options.dataSource.postProcess).toBe('function');
159+
expect(typeof (state?.options.dataSource as any).load).toBe('function');
160+
expect(typeof (state?.options.dataSource as any).postProcess).toBe('function');
161161
});
162162

163163
// NOTE: Unfortunately, we cannot test perfectly local group functions here
@@ -195,8 +195,8 @@ describe('HeaderFilter', () => {
195195

196196
const state = viewController.popupState.peek();
197197

198-
expect(state?.options.dataSource.group).toBeTruthy();
199-
expect(checkFn(state?.options.dataSource.group)).toBeTruthy();
198+
expect((state?.options.dataSource as any).group).toBeTruthy();
199+
expect(checkFn((state?.options.dataSource as any).group)).toBeTruthy();
200200
});
201201
});
202202
});

packages/devextreme/js/__internal/grids/new/grid_core/filtering/header_filter/view_controller.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { OptionsController } from '../../options_controller/options_controller';
1212
import { FilterController } from '../filter_controller';
1313
import type { AppliedFilters } from '../types';
1414
import { getAppliedFilterExpressions } from '../utils';
15-
import { getDataSourceOptions, getFilterType } from './legacy_header_filter';
16-
import type { PopupState } from './types';
15+
import { getDataSourceOptions, getHeaderFilterListType } from './legacy_header_filter';
16+
import type { PopupOptions, PopupState } from './types';
1717
import { getColumnIdentifier } from './utils';
1818

1919
export class HeaderFilterViewController {
@@ -45,10 +45,9 @@ export class HeaderFilterViewController {
4545
const rootDataSource = this.dataController.getStoreLoadAdapter();
4646
const rootHeaderFilterOptions = this.options.oneWay('headerFilter').peek();
4747
const filterExpression = this.getFilterExpressionWithoutCurrentColumn(column);
48-
const type = getFilterType(column);
48+
const type = getHeaderFilterListType(column);
4949
const { columnsController } = this;
50-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
51-
const popupOptions: any = {
50+
const popupOptions: PopupOptions = {
5251
type,
5352
column: { ...column },
5453
isFilterBuilder,

0 commit comments

Comments
 (0)