Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
react-querybuilder
Advanced tools
This component was inspired by prior work from:
npm install react-querybuilder --save
Open <path-to-project>/node_modules/react-querybuilder/demo/index.html
in your browser.
OR
import {QueryBuilder} from 'react-querybuilder';
const fields = [
{name: 'firstName', label: 'First Name'},
{name: 'lastName', label: 'Last Name'},
{name: 'age', label: 'Age'},
{name: 'address', label: 'Address'},
{name: 'phone', label: 'Phone'},
{name: 'email', label: 'Email'},
{name: 'twitter', label: 'Twitter'},
{name: 'isDev', label: 'Is a Developer?', value: false},
];
const dom = <QueryBuilder fields={fields}
onQueryChange={logQuery}/>
function logQuery(query) {
console.log(query);
}
<QueryBuilder />
is the only top-level component exposed from this library. It supports the following properties:
[ {name:String, label:String} ]
The array of fields that should be used. Each field should be an object with
{name:String, label:String}
|
[ {name:String, label:String} ]
The array of operators that should be used. The default operators include:
[
{name: 'null', label: 'Is Null'},
{name: 'notNull', label: 'Is Not Null'},
{name: 'in', label: 'In'},
{name: 'notIn', label: 'Not In'},
{name: '=', label: '='},
{name: '!=', label: '!='},
{name: '<', label: '<'},
{name: '>', label: '>'},
{name: '<=', label: '<='},
{name: '>=', label: '>='},
]
[ {name:String, label:String} ]
The array of combinators that should be used for RuleGroups. The default set includes:
[
{name: 'and', label: 'AND'},
{name: 'or', label: 'OR'},
]
function({field, operator, value, onChange}):ReactElement
This is a callback function invoked by the internal <Rule />
component to determine the
editor for the field value. By default a <input type="text" />
is used.
function(field):[]
This is a callback function invoked to get the list of allowed operators for the given field
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:
{
"combinator": "and",
"rules": [
{
"field": "firstName",
"operator": "null",
"value": ""
},
{
"field": "lastName",
"operator": "null",
"value": ""
},
{
"combinator": "and",
"rules": [
{
"field": "age",
"operator": ">",
"value": "30"
}
]
}
]
}
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:
{
queryBuilder:String, // Root <div> element
ruleGroup:String, // <div> containing the RuleGroup
combinators:String, // <select> control for combinators
addRule:String, // <button> to add a Rule
addGroup:String, // <button> to add a RuleGroup
removeGroup:String, // <button> to remove a RuleGroup
rule:String, // <div> containing the Rule
fields:String, // <select> control for fields
operators:String, // <select> control for operators
value:String, // <input> for the field value
removeRule:String // <button> to remove a Rule
}
[v1.1.0] - 2016-06-27
controlClassnames
propFAQs
The React <QueryBuilder /> component for constructing queries
The npm package react-querybuilder receives a total of 60,582 weekly downloads. As such, react-querybuilder popularity was classified as popular.
We found that react-querybuilder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.