Skip to content

Commit d240910

Browse files
committed
Add listsAsArrays prop and rule-value-list-item class documentation
1 parent c53d1b1 commit d240910

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

docs/api/classnames.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ import { standardClassnames as sc } from 'react-querybuilder';
4444
label: `.${sc.valueSource}`,
4545
valueSources: ['value', 'field'],
4646
},
47+
{
48+
name: 'fb1',
49+
label: `Value list`,
50+
operators: [{ name: 'between', label: 'between' }],
51+
valueSources: ['field', 'value'],
52+
comparator: f => f.name === 'fb2',
53+
},
54+
{
55+
name: 'fb2',
56+
label: `.${sc.valueListItem}`,
57+
},
4758
]}
4859
combinators={[{ name: 'and', label: `.${sc.combinators}` }]}
4960
getOperators={() => [{ name: '=', label: `.${sc.operators}` }]}
@@ -138,6 +149,7 @@ import { standardClassnames as sc } from 'react-querybuilder';
138149
],
139150
},
140151
{ field: 'f3', operator: '=', value: 'f1' },
152+
{ field: 'fb1', operator: 'between', value: 'fb2,fb2', valueSource: 'field' },
141153
],
142154
}}
143155
/>

docs/api/querybuilder.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,34 @@ Pass `false` to automatically add an "empty" option with value `"~"` and label `
720720

721721
Pass `true` to automatically add a rule to new groups. If a `query` prop is not passed in, a rule will be added to the root group when the component is mounted. If a `query` prop is passed in with an empty `rules` array, no rule will be added automatically.
722722

723+
### `listsAsArrays`
724+
725+
`boolean` (default `false`) [_Click for demo_](https://react-querybuilder.js.org/react-querybuilder/#listsAsArrays=true)
726+
727+
Pass `true` to update rule values that represent lists with proper arrays instead of comma-separated strings. Applies when `valueEditorType` is "multiselect" and when a rule's `operator` is "between", "notBetween", "in", or "notIn".
728+
729+
For example, the default behavior for the "between" operator might produce this rule:
730+
731+
```json {4}
732+
{
733+
"field": "f1",
734+
"operator": "between",
735+
"value": "f2,f3",
736+
"valueSource": "field"
737+
}
738+
```
739+
740+
When `listsAsArrays` is true, the rule's `value` will be an array:
741+
742+
```json {4}
743+
{
744+
"field": "f1",
745+
"operator": "between",
746+
"value": ["f2", "f3"],
747+
"valueSource": "field"
748+
}
749+
```
750+
723751
### `independentCombinators`
724752

725753
`boolean` (default `false`) [_Click for demo_](https://react-querybuilder.js.org/react-querybuilder/#independentCombinators=true)

0 commit comments

Comments
 (0)