@react-querybuilder/antd 7.8.0-alpha.0 → 8.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -17
- package/dist/cjs/react-querybuilder_antd.cjs.development.js +915 -462
- package/dist/cjs/react-querybuilder_antd.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_antd.cjs.production.js +2 -1
- package/dist/cjs/react-querybuilder_antd.cjs.production.js.map +1 -1
- package/dist/react-querybuilder_antd.legacy-esm.js +721 -513
- package/dist/react-querybuilder_antd.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_antd.mjs +917 -471
- package/dist/react-querybuilder_antd.mjs.map +1 -1
- package/dist/react-querybuilder_antd.production.mjs +2 -1
- package/dist/react-querybuilder_antd.production.mjs.map +1 -1
- package/package.json +22 -9
package/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
## @react-querybuilder/antd
|
|
2
2
|
|
|
3
|
-
Official [react-querybuilder](https://npmjs.com/package/react-querybuilder)
|
|
3
|
+
Official [react-querybuilder](https://npmjs.com/package/react-querybuilder) compatibility package for [Ant Design](https://ant.design/).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- [Demo](https://react-querybuilder.js.org/demo/antd)
|
|
6
|
+
- [Full documentation](https://react-querybuilder.js.org/)
|
|
7
|
+
- [CodeSandbox](https://react-querybuilder.js.org/sandbox?t=antd) / [StackBlitz](https://react-querybuilder.js.org/sandbox?p=stackblitz&t=antd) example projects
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+

|
|
8
10
|
|
|
9
11
|
## Installation
|
|
10
12
|
|
|
@@ -15,36 +17,56 @@ npm i react-querybuilder @react-querybuilder/antd @ant-design/icons antd
|
|
|
15
17
|
|
|
16
18
|
## Usage
|
|
17
19
|
|
|
18
|
-
To
|
|
20
|
+
To configure the query builder to use Ant Design-compatible components, place `QueryBuilderAntD` above `QueryBuilder` in the component hierarchy.
|
|
19
21
|
|
|
20
22
|
```tsx
|
|
21
23
|
import { QueryBuilderAntD } from '@react-querybuilder/antd';
|
|
22
|
-
import {
|
|
24
|
+
import { useState } from 'react';
|
|
25
|
+
import { type Field, QueryBuilder, type RuleGroupType } from 'react-querybuilder';
|
|
23
26
|
|
|
24
|
-
const fields = [
|
|
27
|
+
const fields: Field[] = [
|
|
25
28
|
{ name: 'firstName', label: 'First Name' },
|
|
26
29
|
{ name: 'lastName', label: 'Last Name' },
|
|
27
30
|
];
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
export function App() {
|
|
30
33
|
const [query, setQuery] = useState<RuleGroupType>({ combinator: 'and', rules: [] });
|
|
31
34
|
|
|
32
35
|
return (
|
|
33
36
|
<QueryBuilderAntD>
|
|
34
|
-
<QueryBuilder fields={fields}
|
|
37
|
+
<QueryBuilder fields={fields} defaultQuery={query} onQueryChange={setQuery} />
|
|
35
38
|
</QueryBuilderAntD>
|
|
36
39
|
);
|
|
37
|
-
}
|
|
40
|
+
}
|
|
38
41
|
```
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
> [!NOTE]
|
|
44
|
+
>
|
|
45
|
+
> You may also want to reduce the width of the value editor component (which is 100% by default) with the following CSS rule.
|
|
46
|
+
>
|
|
47
|
+
> ```css
|
|
48
|
+
> .queryBuilder .ant-input {
|
|
49
|
+
> width: auto;
|
|
50
|
+
> }
|
|
51
|
+
> ```
|
|
41
52
|
|
|
42
|
-
|
|
53
|
+
`QueryBuilderAntD` is a React context provider that assigns the following props to all descendant `QueryBuilder` elements. The props can be overridden on the `QueryBuilder` or used directly without the context provider.
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
| Export | `QueryBuilder` prop |
|
|
56
|
+
| --------------------- | ------------------------------- |
|
|
57
|
+
| `antdControlElements` | `controlElements` |
|
|
58
|
+
| `antdTranslations` | `translations` |
|
|
59
|
+
| `AntDActionElement` | `controlElements.actionElement` |
|
|
60
|
+
| `AntDDragHandle` | `controlElements.dragHandle` |
|
|
61
|
+
| `AntDNotToggle` | `controlElements.notToggle` |
|
|
62
|
+
| `AntDShiftActions` | `controlElements.shiftActions` |
|
|
63
|
+
| `AntDValueEditor` | `controlElements.valueEditor` |
|
|
64
|
+
| `AntDValueSelector` | `controlElements.valueSelector` |
|
|
49
65
|
|
|
50
|
-
|
|
66
|
+
> [!TIP]
|
|
67
|
+
>
|
|
68
|
+
> By default, this package uses icons from `@ant-design/icons` for button labels. To reset button labels to their default strings, use `defaultTranslations` from `react-querybuilder`.
|
|
69
|
+
>
|
|
70
|
+
> ```tsx
|
|
71
|
+
> <QueryBuilderAntD translations={defaultTranslations}>
|
|
72
|
+
> ```
|