UNPKG

5.51 kBTypeScriptView Raw
1// Type definitions for ag-grid v18.1.2
2// Project: http://www.ag-grid.com/
3// Definitions by: Niall Crosby <https://github.com/ag-grid/>
4import { Component } from "../widgets/component";
5import { IDoesFilterPassParams, IFilterComp, IFilterParams } from "../interfaces/iFilter";
6import { Context } from "../context/context";
7import { GridOptionsWrapper } from "../gridOptionsWrapper";
8import { FloatingFilterChange } from "./floatingFilter";
9import { INumberFilterParams, ITextFilterParams } from "./textFilter";
10export interface Comparator<T> {
11 (left: T, right: T): number;
12}
13export declare enum FilterConditionType {
14 MAIN = 0,
15 CONDITION = 1,
16}
17export interface CombinedFilter<T> {
18 operator: string;
19 condition1: T;
20 condition2: T;
21}
22/**
23 * T(ype) The type of this filter. ie in DateFilter T=Date
24 * P(arams) The params that this filter can take
25 * M(model getModel/setModel) The object that this filter serializes to
26 * F Floating filter params
27 *
28 * Contains common logic to ALL filters.. Translation, apply and clear button
29 * get/setModel context wiring....
30 */
31export declare abstract class BaseFilter<T, P extends IFilterParams, M> extends Component implements IFilterComp {
32 static EQUALS: string;
33 static NOT_EQUAL: string;
34 static LESS_THAN: string;
35 static LESS_THAN_OR_EQUAL: string;
36 static GREATER_THAN: string;
37 static GREATER_THAN_OR_EQUAL: string;
38 static IN_RANGE: string;
39 static CONTAINS: string;
40 static NOT_CONTAINS: string;
41 static STARTS_WITH: string;
42 static ENDS_WITH: string;
43 private newRowsActionKeep;
44 filterParams: P;
45 clearActive: boolean;
46 applyActive: boolean;
47 defaultFilter: string;
48 filter: string;
49 filterCondition: string;
50 private eButtonsPanel;
51 private eFilterBodyWrapper;
52 private eApplyButton;
53 private eClearButton;
54 context: Context;
55 private eConditionWrapper;
56 conditionValue: string;
57 gridOptionsWrapper: GridOptionsWrapper;
58 init(params: P): void;
59 onClearButton(): void;
60 abstract customInit(): void;
61 abstract isFilterActive(): boolean;
62 abstract modelFromFloatingFilter(from: string): M;
63 abstract doesFilterPass(params: IDoesFilterPassParams): boolean;
64 abstract bodyTemplate(type: FilterConditionType): string;
65 abstract resetState(): void;
66 abstract serialize(type: FilterConditionType): M;
67 abstract parse(toParse: M, type: FilterConditionType): void;
68 abstract refreshFilterBodyUi(type: FilterConditionType): void;
69 abstract initialiseFilterBodyUi(type: FilterConditionType): void;
70 abstract isFilterConditionActive(type: FilterConditionType): boolean;
71 floatingFilter(from: string): void;
72 onNewRowsLoaded(): void;
73 getModel(): M | CombinedFilter<M>;
74 getNullableModel(): M | CombinedFilter<M>;
75 setModel(model: M | CombinedFilter<M>): void;
76 private doOnFilterChanged(applyNow?);
77 onFilterChanged(applyNow?: boolean): void;
78 private redrawCondition();
79 private refreshOperatorUi();
80 onFloatingFilterChanged(change: FloatingFilterChange): boolean;
81 generateFilterHeader(type: FilterConditionType): string;
82 private generateTemplate();
83 acceptsBooleanLogic(): boolean;
84 wrapCondition(mainCondition: string): string;
85 private createConditionTemplate(type);
86 private createConditionBody(type);
87 translate(toTranslate: string): string;
88 getDebounceMs(filterParams: ITextFilterParams | INumberFilterParams): number;
89}
90/**
91 * Every filter with a dropdown where the user can specify a comparing type against the filter values
92 */
93export declare abstract class ComparableBaseFilter<T, P extends IComparableFilterParams, M> extends BaseFilter<T, P, M> {
94 private eTypeSelector;
95 private eTypeConditionSelector;
96 private suppressAndOrCondition;
97 abstract getApplicableFilterTypes(): string[];
98 abstract filterValues(type: FilterConditionType): T | T[];
99 abstract individualFilterPasses(params: IDoesFilterPassParams, type: FilterConditionType): boolean;
100 doesFilterPass(params: IDoesFilterPassParams): boolean;
101 init(params: P): void;
102 customInit(): void;
103 acceptsBooleanLogic(): boolean;
104 generateFilterHeader(type: FilterConditionType): string;
105 initialiseFilterBodyUi(type: FilterConditionType): void;
106 abstract getDefaultType(): string;
107 private onFilterTypeChanged(type);
108 isFilterActive(): boolean;
109 setFilterType(filterType: string, type: FilterConditionType): void;
110 isFilterConditionActive(type: FilterConditionType): boolean;
111}
112export interface NullComparator {
113 equals?: boolean;
114 lessThan?: boolean;
115 greaterThan?: boolean;
116}
117export interface IComparableFilterParams extends IFilterParams {
118 suppressAndOrCondition: boolean;
119}
120export interface IScalarFilterParams extends IComparableFilterParams {
121 inRangeInclusive?: boolean;
122 nullComparator?: NullComparator;
123}
124/**
125 * Comparable filter with scalar underlying values (ie numbers and dates. Strings are not scalar so have to extend
126 * ComparableBaseFilter)
127 */
128export declare abstract class ScalarBaseFilter<T, P extends IScalarFilterParams, M> extends ComparableBaseFilter<T, P, M> {
129 static readonly DEFAULT_NULL_COMPARATOR: NullComparator;
130 abstract comparator(): Comparator<T>;
131 private nullComparator(type);
132 getDefaultType(): string;
133 private translateNull(type);
134 individualFilterPasses(params: IDoesFilterPassParams, type: FilterConditionType): boolean;
135 private doIndividualFilterPasses(params, type, filter);
136}