react-querybuilder
A QueryBuilder component for React.
Getting Started
Demo
To run a demo of the react-querybuilder being used, go through the following steps.
npm install
Install npm packagesnpm start
Run a local serverhttp://localhost:8080/
Visit your localhost in your browser
Usage
API
<QueryBuilder />
is the only top-level component exposed from this library. It supports the following properties:
fields (Required)
[ {name:String, label:String, id:ID} ]
The array of fields that should be used. Each field should be an object with:
{name:String, label:String, id:ID}
|
The id
is optional, if you do not provide an id for a field then the name will be used.
operators (Optional)
[ {name:String, label:String} ]
The array of operators that should be used. The default operators include:
combinators (Optional)
[ {name:String, label:String} ]
The array of combinators that should be used for RuleGroups. The default set includes:
controlElements (Optional)
This is a custom controls object that allows you to override the control elements used. The following control overrides are supported:
addGroupAction
: By default a<button />
is used. The following props are passed:
removeGroupAction
: By default a<button />
is used. The following props are passed:
addRuleAction
: By default a<button />
is used. The following props are passed:
removeRuleAction
: By default a<button />
is used. The following props are passed:
combinatorSelector
: By default a<select />
is used. The following props are passed:
fieldSelector
: By default a<select />
is used. The following props are passed:
operatorSelector
: By default a<select />
is used. The following props are passed:
valueEditor
: By default a<input type="text" />
is used. The following props are passed:
getOperators (Optional)
function(field):[]
This is a callback function invoked to get the list of allowed operators for the given field.
onQueryChange (Optional)
function(queryJSON):void
This is a notification that is invoked anytime the query configuration changes. The query is provided as a JSON structure, as shown below:
controlClassnames (Optional)
This can be used to assign specific CSS
classes to various controls that are created by the <QueryBuilder />
. This is an object with the following properties:
translations (Optional)
This can be used to override translatable texts applied to various controls that are created by the <QueryBuilder />
. This is an object with the following properties:
Development
Changelog Generation
We are using github-changes to generate the changelog.
To use it:
- tag your commit using semantic versioning
- run
npm run generate-changelog
- enter your github credentials at the prompt
- commit
- push your commit and tags