forked from react-querybuilder/react-querybuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
177 lines (161 loc) · 4.72 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
// Type definitions for react-querybuilder 1.3
// 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 {
field: string;
operator: string;
value: string|number;
}
type AndOr = 'and' | 'or';
interface RuleGroup {
id: string;
combinator: AndOr;
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?: () => 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 QueryBuilderProps {
query?: RuleGroup;
/**
* The array of fields that should be used. Each field should be an object
* with {name: String, label: String}
*/
fields: NameLabelList;
/**
* 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) => NameLabelList;
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;
};
}
export default class QueryBuilder extends React.Component<QueryBuilderProps> {}