You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/querybuilder.mdx
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,16 @@ import TypeScriptAdmonition from './_ts_admonition.md';
9
9
10
10
The default export of `react-querybuilder` is the `<QueryBuilder />` React component.
11
11
12
-
## Props
12
+
All props are optional, but as stated in the [getting started guide](../intro), the query builder is really only useful when, at a minimum, the `fields` prop is defined.
13
13
14
14
:::note
15
15
16
-
All props are optional, but as stated in the [getting started guide](../intro), the query builder is really only useful when, at a minimum, the `fields` propis defined.
16
+
When you see `RuleGroupTypeAny` below (e.g. for [query](#query), [defaultQuery](#defaultquery), and [onQueryChange](#onquerychange)), that means the type must either be `RuleGroupType` or `RuleGroupTypeIC`. However, if the type is `RuleGroupTypeIC`, then the [`independentCombinators` prop](#independentcombinators) must be set to `true`. Likewise, if the type is `RuleGroupType` then `independentCombinators` must be `false` or `undefined`.
Copy file name to clipboardExpand all lines: docs/typescript.mdx
+48-10Lines changed: 48 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
---
2
-
title: TypeScript
2
+
title: TypeScript reference
3
3
---
4
4
5
-
These are some of the [TypeScript](https://www.typescriptlang.org/) types and interfaces you'll see throughout the documentation. Even if you are not using TypeScript (you really should! 😊), you can use the information below to understand the required shape of the props and function parameters. To see the full type definitions for the `react-querybuilder` library, [click here](https://github.com/react-querybuilder/react-querybuilder/blob/master/src/types.ts).
5
+
These are some of the [TypeScript](https://www.typescriptlang.org/) types and interfaces you'll see throughout the documentation. Even if you are not using TypeScript (you really should! 😊), you can use the information below to understand the required shape of the props and function parameters. To see the full type definitions for the `react-querybuilder` library, [click here](https://github.com/react-querybuilder/react-querybuilder/tree/master/packages/react-querybuilder/src/types).
6
6
7
7
## Fields
8
8
@@ -25,34 +25,72 @@ interface Field {
25
25
## Rules and groups
26
26
27
27
```ts
28
-
interfaceRuleType {
28
+
typeRuleType= {
29
29
path?:number[];
30
30
id?:string;
31
31
field:string;
32
32
operator:string;
33
33
value:any;
34
-
}
34
+
};
35
35
36
-
interfaceRuleGroupType {
36
+
typeRuleGroupType= {
37
37
path?:number[];
38
38
id?:string;
39
39
combinator:string;
40
40
rules: (RuleType|RuleGroupType)[];
41
41
not?:boolean;
42
-
}
42
+
};
43
43
44
-
interfaceRuleGroupTypeIC {
44
+
typeRuleGroupTypeIC= {
45
45
path?:number[];
46
46
id?:string;
47
-
rules: (RuleType|RuleGroupTypeIC|string)[];
47
+
rules: (RuleType|RuleGroupTypeIC|string)[];// see note below
`RuleGroupTypeIC` is greatly simplified here for brevity. In reality:
59
+
60
+
- Only even-numbered indexes in the `rules` array can be `RuleType | RuleGroupTypeIC`
61
+
- Only odd-numbered indexes can be `string`
62
+
- The `rules` array length must be odd or zero
63
+
64
+
For example, the following would be invalid because the first element (the `0`th index, which should be `RuleType | RuleGroupTypeIC`) is a `string` and the second element (the `1`st index, which should be a `string`) is a `RuleType`. Also the length (2) is even.
0 commit comments