forked from react-querybuilder/react-querybuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
218 lines (202 loc) · 5.62 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// Type definitions for react-querybuilder 1.4.2
// Project: https://github.com/sapientglobalmarkets/react-querybuilder/
// Definitions by: Jake Boone <https://github.com/jakeboone02>
import * as React from 'react';
interface NameLabelPair {
name: string;
label: string;
}
type NameLabelList = NameLabelPair[];
interface Rule {
id: string;
field: string;
operator: string;
value: string|number;
}
interface RuleGroup {
id: string;
combinator: string;
rules: (Rule | RuleGroup)[];
}
interface CommonCustomControlProps {
/**
* CSS classNames to be applied
*/
className: string;
/**
* The level of the current group
*/
level: number;
}
interface ActionCustomControlProps extends CommonCustomControlProps {
label?: string;
handleOnClick?(): void;
}
interface ActionWithRulesCustomControlProps extends ActionCustomControlProps {
/**
* Rules already present for this group
*/
rules?: Rule[];
}
interface SelectorEditorCustomControlProps extends CommonCustomControlProps {
value?: string;
handleOnChange?(value: any): void;
}
interface CombinatorSelectorCustomControlProps extends SelectorEditorCustomControlProps {
options: NameLabelList;
rules?: Rule[];
}
interface FieldSelectorCustomControlProps extends SelectorEditorCustomControlProps {
options: NameLabelList;
}
interface OperatorSelectorCustomControlProps extends SelectorEditorCustomControlProps {
field?: string;
options: NameLabelList;
}
interface ValueEditorCustomControlProps extends SelectorEditorCustomControlProps {
field?: string;
operator?: string;
}
interface Field extends NameLabelPair {
id?: string;
}
interface QueryBuilderProps {
query?: RuleGroup;
/**
* The array of fields that should be used. Each field should be an object
* with {name: String, label: String}
*/
fields: Field[];
/**
* The array of operators that should be used.
* @default
* [
* {name: 'null', label: 'Is Null'},
* {name: 'notNull', label: 'Is Not Null'},
* {name: 'in', label: 'In'},
* {name: 'notIn', label: 'Not In'},
* {name: '=', label: '='},
* {name: '!=', label: '!='},
* {name: '<', label: '<'},
* {name: '>', label: '>'},
* {name: '<=', label: '<='},
* {name: '>=', label: '>='},
* ]
*/
operators?: NameLabelList;
/**
* The array of combinators that should be used for RuleGroups.
* @default
* [
* {name: 'and', label: 'AND'},
* {name: 'or', label: 'OR'},
* ]
*/
combinators?: NameLabelList;
controlElements?: {
addGroupAction?: React.ComponentType<ActionWithRulesCustomControlProps>;
removeGroupAction?: React.ComponentType<ActionWithRulesCustomControlProps>;
addRuleAction?: React.ComponentType<ActionWithRulesCustomControlProps>;
removeRuleAction?: React.ComponentType<ActionCustomControlProps>;
combinatorSelector?: React.ComponentType<CombinatorSelectorCustomControlProps>;
fieldSelector?: React.ComponentType<FieldSelectorCustomControlProps>;
operatorSelector?: React.ComponentType<OperatorSelectorCustomControlProps>;
valueEditor?: React.ComponentType<ValueEditorCustomControlProps>;
};
/**
* This is a callback function invoked to get the list of allowed
* operators for the given field
* @param field
*/
getOperators?(field: string): Field[];
/**
* This is a notification that is invoked anytime the query configuration changes.
* @param query
*/
onQueryChange(query: RuleGroup): void;
/**
* This can be used to assign specific CSS classes to various controls
* that are created by the `<QueryBuilder />`.
*/
controlClassnames?: {
/**
* Root `<div>` element
*/
queryBuilder?: string;
/**
* `<div>` containing the RuleGroup
*/
ruleGroup?: string;
/**
* `<select>` control for combinators
*/
combinators?: string;
/**
* `<button>` to add a Rule
*/
addRule?: string;
/**
* `<button>` to add a RuleGroup
*/
addGroup?: string;
/**
* `<button>` to remove a RuleGroup
*/
removeGroup?: string;
/**
* `<div>` containing the Rule
*/
rule?: string;
/**
* `<select>` control for fields
*/
fields?: string;
/**
* `<select>` control for operators
*/
operators?: string;
/**
* `<input>` for the field value
*/
value?: string;
/**
* `<button>` to remove a Rule
*/
removeRule?: string;
};
/**
* This can be used to override translatable texts applied to various
* controls that are created by the `<QueryBuilder />`.
*/
translations?: {
fields?: {
title: string;
};
operators?: {
title: string;
};
value?: {
title: string;
};
removeRule?: {
label: string;
title: string;
};
removeGroup?: {
label: string;
title: string;
};
addRule?: {
label: string;
title: string;
};
addGroup?: {
label: string;
title: string;
};
combinators?: {
title: string;
};
}
}
export default class QueryBuilder extends React.Component<QueryBuilderProps> {}