Skip to content

Commit 2cb9762

Browse files
authored
Merge pull request react-querybuilder#60 from jakeboone02/fix-type-functions
Fixed typescript function parameter definitions
2 parents 43d1cf5 + 044d951 commit 2cb9762

File tree

1 file changed

+51
-10
lines changed

1 file changed

+51
-10
lines changed

index.d.ts

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definitions for react-querybuilder 1.3
1+
// Type definitions for react-querybuilder 1.4.2
22
// Project: https://github.com/sapientglobalmarkets/react-querybuilder/
33
// Definitions by: Jake Boone <https://github.com/jakeboone02>
44

@@ -12,17 +12,16 @@ interface NameLabelPair {
1212
type NameLabelList = NameLabelPair[];
1313

1414
interface Rule {
15+
id: string;
1516
field: string;
1617
operator: string;
1718
value: string|number;
1819
}
1920

20-
type AndOr = 'and' | 'or';
21-
2221
interface RuleGroup {
2322
id: string;
24-
combinator: AndOr;
25-
rules: Rule[] | RuleGroup;
23+
combinator: string;
24+
rules: (Rule | RuleGroup)[];
2625
}
2726

2827
interface CommonCustomControlProps {
@@ -38,7 +37,7 @@ interface CommonCustomControlProps {
3837

3938
interface ActionCustomControlProps extends CommonCustomControlProps {
4039
label?: string;
41-
handleOnClick?: () => void;
40+
handleOnClick?(): void;
4241
}
4342

4443
interface ActionWithRulesCustomControlProps extends ActionCustomControlProps {
@@ -50,7 +49,7 @@ interface ActionWithRulesCustomControlProps extends ActionCustomControlProps {
5049

5150
interface SelectorEditorCustomControlProps extends CommonCustomControlProps {
5251
value?: string;
53-
handleOnChange?: () => void;
52+
handleOnChange?(value: any): void;
5453
}
5554

5655
interface CombinatorSelectorCustomControlProps extends SelectorEditorCustomControlProps {
@@ -72,13 +71,17 @@ interface ValueEditorCustomControlProps extends SelectorEditorCustomControlProps
7271
operator?: string;
7372
}
7473

74+
interface Field extends NameLabelPair {
75+
id?: string;
76+
}
77+
7578
interface QueryBuilderProps {
7679
query?: RuleGroup;
7780
/**
7881
* The array of fields that should be used. Each field should be an object
7982
* with {name: String, label: String}
8083
*/
81-
fields: NameLabelList;
84+
fields: Field[];
8285
/**
8386
* The array of operators that should be used.
8487
* @default
@@ -120,8 +123,12 @@ interface QueryBuilderProps {
120123
* operators for the given field
121124
* @param field
122125
*/
123-
getOperators?: (field: string) => NameLabelList;
124-
onQueryChange: (query: RuleGroup) => void;
126+
getOperators?(field: string): Field[];
127+
/**
128+
* This is a notification that is invoked anytime the query configuration changes.
129+
* @param query
130+
*/
131+
onQueryChange(query: RuleGroup): void;
125132
/**
126133
* This can be used to assign specific CSS classes to various controls
127134
* that are created by the `<QueryBuilder />`.
@@ -172,6 +179,40 @@ interface QueryBuilderProps {
172179
*/
173180
removeRule?: string;
174181
};
182+
/**
183+
* This can be used to override translatable texts applied to various
184+
* controls that are created by the `<QueryBuilder />`.
185+
*/
186+
translations?: {
187+
fields?: {
188+
title: string;
189+
};
190+
operators?: {
191+
title: string;
192+
};
193+
value?: {
194+
title: string;
195+
};
196+
removeRule?: {
197+
label: string;
198+
title: string;
199+
};
200+
removeGroup?: {
201+
label: string;
202+
title: string;
203+
};
204+
addRule?: {
205+
label: string;
206+
title: string;
207+
};
208+
addGroup?: {
209+
label: string;
210+
title: string;
211+
};
212+
combinators?: {
213+
title: string;
214+
};
215+
}
175216
}
176217

177218
export default class QueryBuilder extends React.Component<QueryBuilderProps> {}

0 commit comments

Comments
 (0)