All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- N/A
v5.4.1 - 2023-01-30
- #458 Fixed
parseJsonLogic
output when a negated "between", "in", "contains", "beginsWith", or "endsWith" rule is the only operation.
v5.4.0 - 2023-01-06
- #443 Automatically generated
id
s are no longer prefixed with"g-"
or"r-"
. - The default border color has changed from
#7f81a2
to#8081a2
. This difference will almost certainly be imperceptible.
- #443
generateID
no longer tries torequire('crypto')
which should allow its use in more environments and build targets.
- #443 New prop
idGenerator
can be used to override the defaultgenerateID
function.
v5.3.3 - 2022-12-27
- New
jsonLogicOperations
option was causingparseJsonLogic
to return a rule instead of a group if only one JsonLogic rule was passed in.
v5.3.2 - 2022-12-26
- #434 Added
jsonLogicOperations
option toparseJsonLogic
to enable parsing of custom operations.
v5.3.1 - 2022-12-23
- #432 The
crypto
package was used in a way that didn't work in some Node environments.
v5.3.0 - 2022-12-23
- New rule and group
id
s are now generated as valid v4 UUIDs usingcrypto.getRandomValues()
instead ofMath.random()
. ThegenerateID
function used internally is exported. - #418 TypeScript interface
NameLabelPair
has been deprecated and is now an alias for theOption
interface.
- #407 Drag-and-drop will now allow drops on locked rules (which places the dragged rule/group below the drop target) and above locked rules/groups.
- #411 When
showCombinatorsBetweenRules
is enabled, a combinator selector immediately above a locked rule/group will no longer be locked unless the group it belongs to is locked. jsonLogicAdditionalOperators
is exported again (documentation).
- #422 Adding the class
queryBuilder-branches
displays "tree view" branch lines. - #426 Dynamic classnames based on the specific rule/group properties.
- New function props
getRuleClassname
andgetRuleGroupClassname
are passed the rule or group, and the return value will be added as a class to the surroundingdiv
. Field
,Operator
, and new interfaceCombinator
now have an optionalclassName
property that will be applied to rules or groups that specify the appropriate attribute.
- New function props
- #417 Optional
arity
property for operators. Whenarity
is either "unary" or a number less than 2, the value editor will not render when that operator is selected (similar to the standard "null"/"notNull" operators). - #408 The interfaces
Option
(néeNameLabelPair
),Field
, andValueEditorProps
now accept generics forname
and other properties. - #418 A new
OptionList
type covers theoptions
property for all standard selection lists (field, operator, combinator, etc.). Previously this was a union type:NameLabelPair[] | OptionGroup<NameLabelPair>[]
.OptionList
is equivalent to this type, but 1) doesn't require typing the base type twice, and 2) uses the newOption
name instead of the deprecatedNameLabelPair
. - #421 When
independentCombinators
is enabled, customonAddRule
andonAddGroup
callbacks can add acombinatorPreceding
property to the rule/group which will end up being the combinator inserted above the new rule/group (if the parent group is not empty).
v5.2.0 - 2022-11-26
- #403 Add
onRemove
prop and pass rule/group to allActionElement
s (buttons).
v5.1.3 - 2022-11-23
- #387 Support
antd
version 5.
v5.1.2 - 2022-11-21
- #399/#401 When dragging a rule or group over a group header, the
dndOver
class is no longer applied to child group headers.
v5.1.1 - 2022-10-27
parseMongoDB
andparseJsonLogic
now respectindependentCombinators
option.- Narrowed rule group types, like
DefaultRuleGroupType
andDefaultRuleGroupTypeIC
, are respected byconvertFromIC
andconvertToIC
.
Miscellaneous
- v3 documentation was migrated from dedicated README to website versioned docs
v5.1.0 - 2022-10-26
- #394
parseJsonLogic
now handlesnull
values correctly.
v5.0.0 - 2022-10-22
- Internet Explorer is no longer supported.
- The minimum TypeScript version is now 4.5.
- When
defaultQuery
is defined, anid
property will be added to each rule and group in the query hierarchy. This will be reflected in theonQueryChange
callback parameter. In previous versionsdefaultQuery
was not modified by the component itself, butid
is now added because it is a required attribute internally. - Related to the previous bullet, the
prepareRuleGroup
utility function will no longer coerce thenot
property of groups to be aboolean
type (or even defined at all). - #385 MongoDB output has been simplified: The
$eq
and$and
operators are only used when necessary. - #343 Drag-and-drop functionality migrated
- In order to make the
react-dnd
dependency completely optional when theenableDragAndDrop
prop was not set totrue
, drag-and-drop functionality was extracted fromreact-querybuilder
into a new package called@react-querybuilder/dnd
. - The new package has
peerDependencies
ofreact-dnd
andreact-dnd-html5-backend
(each of which can be any version >= 14, as long as they match), but no harddependencies
. The only external dependencies in the main package now areimmer
andclsx
. - Upgrade path: To enable drag-and-drop functionality in v5, nest
<QueryBuilder />
within a<QueryBuilderDnD />
element. TheenableDragAndDrop
prop is implicitlytrue
when usingQueryBuilderDnD
, so you no longer need to set it explicitly unless it should befalse
(which can be set onQueryBuilderDnD
orQueryBuilder
).export function App() { return ( - <QueryBuilder enableDragAndDrop /> + <QueryBuilderDnD> + <QueryBuilder /> + </QueryBuilderDnD> ); }
- If your application already uses
react-dnd
and rendersDndProvider
higher in the component tree, replaceQueryBuilderDnD
withQueryBuilderDndWithoutProvider
.
- In order to make the
- #324 The
@react-querybuilder/material
package now properly inherits the theme configuration from ancestorThemeProvider
s. Note: the@mui/material
components are now loaded asynchronously by default, so the query builder will initially be rendered with the default components. See the documentation or the README to find out how to render the MUI components immediately. parseCEL
now handles strings correctly (including multi-line strings).- #389
AntDValueSelector
properly handles empty string values in multiselect mode.
- Each compatibility package now exports its own context provider that injects the appropriate
controlElements
andcontrolClassnames
properties into any descendantQueryBuilder
components (composition FTW!). This is now the recommended usage for all compatibility packages. - The
onAddRule
andonAddGroup
callback props now receive an optional "context" parameter as the fourth argument. This parameter can be provided by a customaddRuleAction
/addGroupAction
component to itshandleOnClick
prop. This allows users to alter or replace the default rule based on arbitrary data. For example, theaddRuleAction
component could render two "add rule" buttons which add different rules depending on which one was clicked, as long as they provided a differentcontext
parameter. - When drag-and-drop is enabled, rules will be copied instead of moved if the user has a modifier key (
Alt
on Windows/Linux,Option ⌥
on Mac) pressed when the drop occurs. formatQuery
has a newruleProcessor
configuration option applicable to non-SQL query language formats. When provided, the entire rule output will be determined by the function. For the relevant formats,valueProcessor
already behaved this way; the default "value" processors have been renamed todefaultRuleProcessor[Format]
to clarify the behavior. The default processors' original "value" names are deprecated but still available (with no immediate plans to remove them).parseSQL
will now ignore a leadingWHERE
keyword, e.g.parseSQL("WHERE firstName = 'Steve'")
will not fail to produce a query rule like in v4.
Miscellaneous
- The documentation site now has separate documentation for past versions.
- The
controlElements
prop has a new option:inlineCombinator
. By default, this is a small wrapper around thecombinatorSelector
component that is used when eithershowCombinatorsBetweenRules
orindependentCombinators
istrue
. TheinlineCombinator
option was only added to support@react-querybuilder/dnd
, so there is almost certainly no reason to use it directly.
v4.5.3 - 2022-09-28
- #364 The array passed to the
fields
prop was being mutated if it contained duplicates, whether they were duplicate fieldname
s or option grouplabel
s. Thefields
prop is now treated as immutable. - #374
RuleGroup
was using unstable keys to render elements in therules
array. Keys are now stable based onid
properties, which are auto-generated if not provided in thequery
/defaultQuery
prop.
v4.5.2 - 2022-08-19
- Backslashes are now properly escaped when
formatQuery
generatesJSON.parse
-able strings ("mongodb" and "json_without_ids" formats). - The
parse*
import methods properly handle backslashes. - #353 The
moment
package is no longer included in the build for@react-querybuilder/antd
.
- #333 When a rule has an
operator
of "between"/"notBetween" and eithervalueSource: "field"
orvalueEditorType: "select"
, the defaultValueEditor
will display two drop-down lists. The values of the drop-down lists will be joined with a comma when the rule'svalue
property is updated. - #337 In conjunction with the "between"-related enhancements above, a new Boolean prop has been added to
<QueryBuilder />
calledlistsAsArrays
. This prop works in a similar manner to theparse*
option of the same name. When the prop istrue
,ValueEditor
(andValueSelector
formultiple: true
) will store lists of values, including "between" value pairs, as proper arrays instead of comma-separated strings.- Existing, default format:
{ field: "f1", operator: "between", value: "f2,f3", valueSource: "field" }
listsAsArrays
format:{ field: "f1", operator: "between", value: ["f2", "f3"], valueSource: "field" }
- Existing, default format:
v4.5.1 - 2022-06-21
- The type
ValueProcessor
was incorrectly including the newValueProcessorByRule
type.ValueProcessor
is now simply an alias forValueProcessorLegacy
, which should undo a breaking change from v4.5.0.
v4.5.0 - 2022-06-19
TL;DR: These are probably not breaking changes.
While a breaking change in a minor release technically violates semver, the change in question is only "breaking" in a very rare--possibly non-existent--case. The only case where this change will break anything is if you use formatQuery
with a custom valueProcessor
that accepts fewer than three (3) arguments. Click for details...
- #319:
formatQuery
will now invoke customvalueProcessor
functions with different arguments based on the function's.length
property, which is the number of arguments a function accepts excluding those with default values:- If the
valueProcessor
function accepts fewer than three (3) arguments, it will be called like this:
The first argument is thevalueProcessor(rule, { parseNumbers });
RuleType
object directly from the query. The second argument is of typeValueProcessorOptions
, which is a subset ofFormatQueryOptions
(currently{ parseNumbers?: boolean; }
).- To maintain the current behavior (
valueProcessor(field, operator, value, valueSource)
), make sure thevalueProcessor
function accepts at least three arguments with no default values (do not use=
for the first three arguments). For example, the following code will loglength: 1
:
const valueProcessor = (field: string, operator = '=', value = '') => '...'; console.log(`length: ${valueProcessor.length}`);
- If you use TypeScript, these conditions will be enforced automatically.
- If the
- #319: Invoking
valueProcessor
with the fullRuleType
object provides access to much more information about specific rules. Standard properties that were previously unavailable includepath
,id
, anddisabled
, but any custom properties will also be accessible.- The default value processors for "sql", "parameterized", "parameterized_named", "mongodb", "cel", and "spel" formats have not changed, but alternate functions using the new
fn(rule, options)
signature are now available:defaultValueProcessorByRule
defaultValueProcessorCELByRule
defaultValueProcessorMongoDBByRule
defaultValueProcessorSpELByRule
- The default value processors for "sql", "parameterized", "parameterized_named", "mongodb", "cel", and "spel" formats have not changed, but alternate functions using the new
- #320, #323: New parser functions (also available as standalone builds in the
dist
folder). Click the respective "Import from [format]" button in the demo to try them out. - #328 New utility function
transformQuery
recursively processes rule groups and rules with the providedruleProcessor
,ruleGroupProcessor
, and other options (documentation).
- #323:
formatQuery
outputs will now escape quotation marks when appropriate:- For SQL ("sql", "parameterized", "parameterized_named"), single quotes will be doubled up, e.g.
(firstName = 'Ra''s')
- For other formats, double or single quotes will be escaped with a backslash if necessary (
firstName == 'Ra\'s'
orfirstName == "Ra\"s"
).
- For SQL ("sql", "parameterized", "parameterized_named"), single quotes will be doubled up, e.g.
- #323: The standalone builds of
formatQuery
andparseSQL
no longer include React and are not minified.
v4.4.1 - 2022-06-03
- New export format options:
- JsonLogic (
formatQuery
docs, JsonLogic.com) - Spring Expression Language (SpEL) (
formatQuery
docs, docs.spring.io)
- JsonLogic (
- MongoDB export format now supports
RuleGroupTypeIC
(independent combinators).
v4.4.0 - 2022-05-30
(This list may look long, but the breaking changes should only affect a small minority of users.)
- Several utility functions that were trivial or only really useful internal to this package are no longer exported from
react-querybuilder
. To see which ones, check theinternal
folder. All exports from that folder were previously exported from theutils
folder, which is re-exported in its entirety from the main entry point. - The
RuleProps
andRuleGroupProps
interfaces have deprecated the props that were individual properties of rules/groups, and have added a prop containing the full rule or group object. This should only affect users that implement a custom<RuleGroup />
component but use the default<Rule />
component, since<Rule />
now expects arule
prop.- In
RuleProps
:field
,operator
,value
, andvalueSource
are deprecated and replaced byrule: RuleType
. - In
RuleGroupProps
:combinator
,rules
, andnot
are deprecated and replaced byruleGroup: RuleGroupTypeAny
.
- In
- Internal methods for immutably updating queries have been moved from the
schema
prop to the newactions
prop on bothRuleProps
andRuleGroupProps
. Custom<Rule />
and<RuleGroup />
components will need to adjust their prop declarations.
vite-tsconfig-paths
was mistakenly added to thedependencies
list instead ofdevDependencies
for the main package in v4.1.3.
debugMode
now triggers logging when the query or options are updated and when a query update fails for some reason (e.g. the path is disabled).- New
onLog
callback prop is used instead ofconsole.log
whendebugMode
istrue
. - As a consequence of the new properties on
RuleProps
andRuleGroupProps
(rule
andruleGroup
, respectively), custom<Rule />
and<RuleGroup />
components now have access to their full rule/group objects, including any non-standard properties. This can greatly simplify the use of customized query objects. <QueryBuilder />
will detect potential problems with using the component in a controlled vs uncontrolled manner and will log errors to the console (in "development" mode only). This includes the following situations:- Both
query
anddefaultQuery
props are defined (TypeScript will complain about this at compile time, errors will be logged at run time) query
prop is undefined in one render and then defined in the next renderquery
prop is defined in one render and then undefined in the next render
- Both
v4.3.1 - 2022-05-21
- If using TypeScript, custom
operatorSelector
components will now need to accommodateOptionGroup<NameLabelPair>[]
in addition to the normalNameLabelPair[]
.
- #304 Many compatibility components now accept the props of the rendered library component in addition to the standard props (see documentation), allowing customization specific to the style library.
- #306 New prop
autoSelectOperator
(documentation) behaves likeautoSelectField
but for the operator selector.- The
fields
andoperators
properties of thetranslations
prop object now acceptplaceholderName
,placeholderLabel
, andplaceholderGroupLabel
properties (documentation). These translatable strings set the default field and operator values and labels whenautoSelectField
and/orautoSelectOperator
are set tofalse
. - Corresponding options were also added to
formatQuery
, which will now ignore rules where thefield
oroperator
match the placeholder values for most export formats.
- The
- #303 Added support for wildcards concatenated to field names in
parseSQL
. Examples:
SQL |
Generated |
---|---|
|
{
"field": "lastName",
"operator": "beginsWith",
"value": "firstName",
"valueSource": "field"
} |
|
{
"field": "lastName",
"operator": "doesNotContain",
"value": "firstName",
"valueSource": "field"
} |
- #301
react-querybuilder
and the compatibility packages are all built with React v18 now (thepeerDependencies
version is still">=16.8.0"
). Previous 4.x versions were usable within React 18 applications, but now the build and tests explicitly use it. - #308 The CodeSandbox CI template is now located within the repository, and several other CodeSandbox-compatible examples have been added as well (see examples folder).
v4.2.5 - 2022-05-12
- Added two options to the
translations
prop:fields.placeholderLabel
andfields.placeholderGroupLabel
. These will be used in place of the default"------"
when theautoSelectField
prop is set tofalse
. - All translation properties are now optional.
v4.2.4 - 2022-05-12
- Added a
parseNumbers
option forformatQuery
. - Added a
debugMode
prop on<QueryBuilder />
.
v4.2.3 - 2022-04-05
- Common Expression Language (CEL) export format for
formatQuery
.
v4.2.2 - 2022-03-12
- This release fixes the "IC" aka "independent combinator" type exports (
RuleGroupTypeIC
, etc.).
v4.2.1 - 2022-03-03
- This release adds an
operator
parameter to thecomparator
function property of theField
interface.
v4.2.0 - 2022-02-02
- When calling
formatQuery
with the "mongodb" format and a customvalueProcessor
, thevalueProcessor
function will now need to return the full expression object and not just the operator/value portion. For example,defaultMongoDBValueProcessor('firstName', '=', 'Steve')
previously returned{"$eq":"Steve"}
, but now returns{"firstName":{"$eq":"Steve"}}
.
- #276: When using
react-querybuilder
v4 within an application that already implementedreact-dnd
, an error would appear: "Cannot have two HTML5 backends at the same time." This can now be resolved by using the<QueryBuilderWithoutDndProvider />
component instead of<QueryBuilder />
. They are functionally the same, but the former allows (in fact, relies on) areact-dnd
backend (e.g.react-dnd-html5-backend
) to be implemented higher up in the component tree. - Previously, the
parseSQL
method would accept boolean comparison clauses with an identifier (field name) on the left or right of the operator, but not on both sides (at least one side had to be a primitive string, numeric, or boolean). If the identifier was on the right,parseSQL
would flip the clause so that the field name was on the left and the value on the right, but it wouldn't flip the operator (<
should become>
, etc.). The operator will now be flipped when appropriate.
- Compare fields to other fields. The default
<ValueEditor />
component can now display a filterable list of fields from thefields
prop given the right configuration.formatQuery
andparseSQL
have also been updated to support this feature. - Query tools: Several methods are now available to assist with manipulation of query objects outside the context of a
<QueryBuilder />
element:add
- appends a new rule or group (and a preceding independent combinator if appropriate) to the end of a rule group'srules
arrayremove
- removes a rule or group (and the preceding independent combinator if one exists)update
- updates a property of a rule or group, or updates an independent combinatormove
- moves (or clones, with newid
andpath
) a rule or group to a new location in the query tree
- Lock buttons: Use the
showLockButtons
prop to enable locking/unlocking (i.e. disabling/enabling) individual rules and groups (demo). - New
valueEditorType
andinputType
options: In addition to the previously available options ("text", "select", "checkbox", "radio"), the following new options are now officially implemented in the default<ValueEditor />
and all compatibility packages:valueEditorType
- "textarea"
- "multiselect"
inputType
- "date"
- "datetime-local"
- "time"
- A UMD build is now available (demo).
- The
fields
prop can now accept an object of typeRecord<string, Field>
. (Field[]
andOptionGroup<Field>[]
are still supported.) - Each compatibility package now exports an object ready-made for the
controlElements
prop (as well ascontrolClassnames
in the case of Bootstrap). No need to assign each component individually anymore.
v4.1.3 - 2022-01-18
- The path to the CommonJS build was wrong in package.json for the main package. This has been fixed.
- The
RuleGroupArray
type (used for therules
property ofRuleGroupType
) has been simplified to(RuleType | RuleGroupType)[]
. This should make it easier to extend and/or narrowRuleGroupType
.
v4.1.2 - 2022-01-12
parseSQL
was returning conventional rule groups (combinators at the group level) in some situations even when theindependentCombinators
option was set totrue
. The option will now guarantee a return type ofRuleGroupTypeIC
.
- Added
convertQuery
method to toggle a query between the conventional structure with combinators at the group level (RuleGroupType
) and the "independent combinator" structure (RuleGroupTypeIC
, used with theindependentCombinators
prop). For unidirectional conversions,convertToIC
andconvertFromIC
are also available. - The specific return type of the
parseSQL
method (RuleGroupType
orRuleGroupTypeIC
) is now inferred from the parameters.
v4.1.1 - 2022-01-10
- Improved recursive types
RuleGroupType
andRuleGroupTypeIC
to pass down theR
(rule) andC
(combinator) generics to therules
array.
v4.1.0 - 2022-01-09
- Minimum TypeScript version has been lowered to 4.1.2, down from 4.5 in
react-querybuilder
v4.0.0.
- All
ValueSelector
-based components, including field selectors, operator selectors, combinator selectors, and value editors where thetype
is "select" now support option groups. Pass{ label: string; options: NameLabelPair[] }[]
instead ofNameLabelPair[]
. - TypeScript types for rules and groups now use generics which can be used to narrow certain member types more easily.
v4.0.0 - 2021-12-28
- Minimum TypeScript version is now 4.5.0.
- The default styles (
query-builder.css
andquery-builder.scss
) now use flexbox. This should allow greater flexibility and more consistent styling, but you'll need to use a different stylesheet for IE due to poor flexbox support. The new IE-compatible demo page uses styles more suitable for IE. onAddRule
andonAddGroup
callbacks now pass anumber[]
(parentPath
) as the second argument instead of astring
(parentId
).- The exported method
findRule
has been replaced byfindPath
, which is useful in conjunction with the previously mentionedonAddRule
andonAddGroup
callbacks. - A new drag handle element will always be rendered at the front of every rule and rule group header element, regardless of whether you enable the drag-and-drop feature (see Features section below). If drag-and-drop is disabled (the default setting), you should hide the drag handle by either 1) using the default stylesheet which hides it automatically when drag-and-drop is disabled, or 2) hiding it with a style rule like
.queryBuilder-dragHandle { display: none; }
. - Cloning a rule or group will insert the clone immediately after the original item instead of as the last item of the parent group.
Click to show internal changes (shouldn't affect most users)
- Dropped
lodash
dependency. Addedimmer
andreact-dnd
. Rule
andRuleGroup
props now includepath: number[]
, andid
may be undefined.getLevel
has been removed from theschema
prop (internally we just usepath.length
now).- The following functions that are part of the
schema
prop have been refactored to usepath
orparentPath
instead ofid
orparentId
:onGroupAdd
,onGroupRemove
,onPropChange
,onRuleAdd
,onRuleRemove
.
- The default
ValueEditor
component was calling theuseEffect
hook conditionally, which is way against the Rules of Hooks. It is now called unconditionally. - #258 When the
formatQuery
export format is "mongodb", the resulting string can be parsed byJSON.parse
(@mylawacad)
- Shiny new documentation site! https://react-querybuilder.js.org
- We now provide official compatibility components for several popular style frameworks (as seen in the demo), with more to come! Check out the
@react-querybuilder
org on npm. - All props on the
<QueryBuilder />
component are now optional <QueryBuilder />
is now a properly controlled or uncontrolled component depending on which props are passed in. If you pass aquery
prop, the query will not change until a newquery
is passed in. You should use the parameter of theonQueryChange
callback to update thequery
prop. Typically this involves using React'suseState
hook. To render an uncontrolled component, don't pass aquery
prop. You can set the initial query by using the newdefaultQuery
prop, and you can still listen for changes withonQueryChange
.- The
query-builder.scss
file now uses variables instead of hard-coded colors and spacing. Feel free to import it and override the default values with your own theme's colors/styles/etc. - Drag-and-drop! Pass the
enableDragAndDrop
prop to display a drag handle on each rule and group header. Users will be able to reorder and relocate rules and groups. - Independent combinators! Wait...what does that even mean? When the
independentCombinators
prop istrue
,<QueryBuilder />
will insert an independent "and/or" selector between each pair of sibling rules/groups. This new feature shouldn't introduce any breaking changes since it's opt-in, i.e. ifindependentCombinators
is undefined orfalse
, then the<QueryBuilder />
should behave basically the same as it did in v3.x. - New
disabled
prop to prevent changes to the query. All sub-components and form elements get thedisabled
prop as well. Passtrue
to disable the entire query, or pass an array of paths to disable specific rules/groups. parseSQL
method to import queries from SQL (documentation / demo -- click the "Load from SQL" button).formatQuery
accepts a newformat
type: "parameterized_named" (documentation). This new format is similar to "parameterized", but instead of anonymous?
-style bind variables, each parameter is given a unique name based on the field name and the order in the query. A correspondingparamPrefix
option is available in order to use a different character than the default ":" within thesql
string.
v4.0.0-beta.8 - 2021-12-24
- #255 Fix a couple of issues with the "mongodb"
formatQuery
export type (@mylawacad)
- #261
valueProcessor
for "mongodb" export format - #252 Export
RuleGroup
component (@ZigZagT) - #250 Bulma compatibility package and demo
- #248
disabled
prop
v4.0.0-beta.7 - 2021-12-13
- #247 Fix drag-and-drop for
independentCombinators
v4.0.0-beta.6 - 2021-11-27
Maintenance release focused on converting to a monorepo with Vite driving the build process.
- If using
react-querybuilder
with NodeJS, and you only want to use theformatQuery
function, you no longer have to install React on the server as well. Justimport formatQuery from 'react-querybuilder/dist/formatQuery'
. Note: TypeScript types are not available for this export.
v4.0.0-beta.5 - 2021-11-12
- Earlier 4.0 beta releases had an
inlineCombinators
prop. This has been renamed toindependentCombinators
. - Dropped
lodash
dependency. Addedimmer
andreact-dnd
.
- The default styles now use flexbox. This should allow greater flexibility and more consistent styling.
- The
query-builder.scss
file now uses variables instead of hard-coded colors and spacing. Feel free to import it and override the default values with your own theme's colors/styles/etc.
- A new drag handle element sits at the front of every rule and rule group header element. If you are not using the drag-and-drop feature (see Features section below), you should hide the drag handle by using the default stylesheet which hides it automatically when
enableDragAndDrop
isfalse
, or hide it with a rule like.queryBuilder-dragHandle { display: none; }
.
<QueryBuilder />
is now a properly controlled or uncontrolled component depending on which props are passed in. If you pass aquery
prop, the query will not change until a newquery
is passed in. You should use the parameter of theonQueryChange
callback to update thequery
prop. Typically this involves using React'suseState
hook. To render an uncontrolled component, don't pass aquery
prop. You can set the initial query by using the newdefaultQuery
prop, and you can still listen for changes withonQueryChange
.
- #235 Drag-and-drop! Pass the
enableDragAndDrop
prop to display a drag handle on each rule and group header. Users will be able to reorder rules and groups with the click (and drag) of a mouse. - New IE11-compatible demo page.
v4.0.0-beta.4 - 2021-11-03
- v4.0.0-beta.3 had an outdated build
- All props on the
<QueryBuilder />
component are now optional
v4.0.0-beta.3 - 2021-11-03
- #231
inlineCombinators
prop. Whentrue
,<QueryBuilder />
will insert an independent combinator (and/or) selector between each pair of sibling rules/groups. This new feature shouldn't introduce any breaking changes, i.e. ifinlineCombinators
is undefined orfalse
, then the<QueryBuilder />
should behave the same as it did in v4.0.0-beta.2. However, the TypeScript types are significantly more complex in this release so we're going to leave this beta out for a while before releasing v4.0.0 properly.
v4.0.0-beta.2 - 2021-10-29
v4.0.0-beta.1 - 2021-10-23
- #229 Path-based query management
Rule
andRuleGroup
props now includepath: number[]
, andid
may be undefined.getLevel
has been removed from theschema
prop.- The following functions that are part of the
schema
prop have been refactored to usepath
orparentPath
instead ofid
orparentId
:onGroupAdd
,onGroupRemove
,onPropChange
,onRuleAdd
,onRuleRemove
. onAddRule
andonAddGroup
callbacks now pass anumber[]
(parentPath
) as the second argument instead of astring
(parentId
).- The exported method
findRule
has been replaced byfindPath
, which is useful in conjunction with the previously mentioned, refactoredonAddRule
andonAddGroup
callbacks. - The
onQueryChange
callback's argument, the current query object, will include apath
for each rule and group. TheformatQuery
default output format, "json", will also includepath
s. - Rule and group
div
s now include adata-path
attribute.
formatQuery
accepts a newformat
type:"parameterized_named"
. This new format is similar to"parameterized"
, but instead of anonymous?
-style bind variables, each parameter is given a unique name based on the field name and the order in the query. A corresponding optionparamPrefix
is available in order to use a different character than the default ":" within thesql
string.- #228 CodeSandbox CI
v3.12.1 - 2021-10-06
- The default
ValueEditor
will force the<input />
control to havetype="text"
if the field'sinputType
is "number" and theoperator
is "between" or "notBetween". When theoperator
changes to something else, the control will revert totype="number"
and reset thevalue
if thevalue
included a comma (","). - The "parameterized" output of the
formatQuery
function will now include native numbers and boolean values in theparams
array if a rule'svalue
property is a number or boolean. Previously the array included"TRUE"
or"FALSE"
for boolean values, and numbers were converted to strings, e.g. old way ->params:["string","12","14","TRUE"]
, new way ->params:["string",12,14,true]
.
- Several bugs were squashed in the
formatQuery
function when dealing with the "in", "notIn", "between", and "notBetween" operators. - A couple of bugs were fixed in the demo.
v3.12.0 - 2021-10-04
- The only potentially breaking change in the main
<QueryBuilder />
component is the addition of a<div>
in the JSX output that wraps the child rules/groups of each group. It would only affect custom CSS rules like.ruleGroup > .rule
, since.rule
is no longer an immediate child of.ruleGroup
. Now use something like.ruleGroup > .ruleGroup-body > .rule
. - The
formatQuery
function will now ignore invalid rules for "sql", "parameterized", and "mongodb" output types. This includes rules that match one or more of the following criteria:- The rule fails validation (see validation feature below) based on the validation map from the query validator or the result of the field validator.
- The rule's
operator
is "in" or "notIn" and the value is neither a non-empty string nor an array with at least one element. - The rule's
operator
is "between" or "notBetween" and the value is neither an array of length two (rule.value.length === 2
) nor a string with exactly one comma that isn't the first or last character (rule.value.split(',').length === 2
and neither element is an empty string).
- Cleaned up some internal stuff and dropped three dependencies! Lodash is now the only external dependency.
- #225 Validation: pass a
validator
prop to validate the entire query, or include avalidator
attribute on each field in thefields
array to validate each rule based on the selected field.- CSS classes will be added (
"queryBuilder-valid"
or"queryBuilder-invalid"
) to validated rules and groups, and all sub-components will receive the validation result as a prop. - The
formatQuery
function has two new validation-related options: 1)validator
(same signature as the prop mentioned earlier) and 2)fields
(same shape as thefields
prop). Rules and groups deemed invalid will be ignored if the output format is "sql", "parameterized", or "mongodb".
- CSS classes will be added (
- #223 Rule/group cloning: pass the
showCloneButtons
prop to enable duplication of rules and groups. AssociatedcontrolElements
properties are also available for custom clone button components. - #224 Add rule to new groups: pass the
addRuleToNewGroups
prop to add the default rule to all new groups automatically. - #224 Default operator: pass a
getDefaultOperator
function prop to determine which operator is set for new rules (or include adefaultOperator
attribute on objects in thefields
array to set the default operator for specific fields). - #224 Cancel or modify a new rule/group: use the
onAddRule
andonAddGroup
callbacks to return a new rule/group that will be added instead of the default, or returnfalse
to cancel the addition of the new rule/group. (Note: to completely prevent the addition of new groups, you can also passcontrolElements={{ addGroupAction: () => null }}
which will hide the "+Group" button.) - New "between" and "not between" default operators: the
formatQuantity
function has also been updated to handle the new operators properly. - The demo has been updated with all the new features, and now includes tooltips on options and links to relevant documentation.
v3.11.1 - 2021-09-18
- Relaxed and corrected types related to
NameLabelPair
- Simplified
formatQuery
for MongoDB
v3.11.0 - 2021-08-24
- #218
autoSelectField
prop. When set tofalse
, prevents automatic selection of the first field in new rules by adding an "empty" choice as the first option. When the "empty" option is selected, the operator and value components for that rule will not be displayed.
v3.10.1 - 2021-08-19
v3.10.0 - 2021-07-27
- New item in the
translations
prop object:notToggle.label
- #210 Customizable label for "not" toggle component (@jakeboone02)
v3.9.9 - 2021-03-05
field
,fieldData
, andoperator
are now required inValueEditorProps
v3.9.8 - 2021-02-22
- #190 Export default components
ActionElement
,NotToggle
,ValueEditor
, andValueSelector
(@jakeboone02)
v3.9.7 - 2021-02-18
- #188 Any extra attributes in the
query
prop will be persisted (@jakeboone02)
v3.9.6 - 2021-02-15
- Add base CSS to the package
v3.9.5 - 2021-02-08
- Updated README.md for npm
v3.9.4 - 2021-02-06
- Critical bug with v3.9.3 where React wasn't in scope
v3.9.3 - 2021-02-05
- #179 Added
enableMountQueryChange
prop to allow disabling initialonQueryChange
call (@saurabhnemade)
v3.9.2 - 2021-01-24
- #178 Export several default configuration options (@jakeboone02)
defaultCombinators
defaultOperators
defaultTranslations
defaultValueProcessor
v3.9.1 - 2021-01-17
- #175 Replaced
nanoid
withMath.random()
(@jakeboone02)
- This release removes the requirement to re-map the
window.msCrypto
object towindow.crypto
for IE11. Woohoo!
v3.9.0 - 2020-12-07
- #171 Add
context
prop to pass arbitrary data to custom components (@jakeboone02)
v3.8.4 - 2020-11-16
- #167
placeholder
support for text fields (@eddie-xavi)
v3.8.3 - 2020-11-04
- Bug with using false as
defaultValue
v3.8.2 - 2020-11-03
- #164 Fixed setting of default values (@jakeboone02)
v3.8.1 - 2020-10-23
- Gets correct default operator when using field-level config
v3.8.0 - 2020-10-09
- The default operators list has been rearranged so that
"="
is first in the list and therefore the default for new rules. Previously it was"null"
.
- Several options that required the use of functions at the query level can now be configured at the field level:
- Operators: use the
operators
property on a field instead of thegetOperators
prop - Value editor type: use the
valueEditorType
property on a field instead of thegetValueEditorType
prop - Input type: use the
inputType
property on a field instead of thegetInputType
prop - Values: if the value editor type is
select
orradio
, use thevalues
property on a field instead of thegetValues
prop - Default value: use the
defaultValue
property on a field instead of thegetDefaultValue
prop
- Operators: use the
- #160 Added field-level configuration options (@jakeboone02)
v3.7.1 - 2020-10-07
- #158
createRule
was settingname
toundefined
when fields are empty (@saurabhnemade)
v3.7.0 - 2020-10-04
- #157
getDefaultField
andgetDefaultValue
props (@jakeboone02)
- Allow nulls to be returned from getOperators and getValueEditorType
v3.6.0 - 2020-10-01
- #155 Refactored
formatQuery
options (@jakeboone02)valueProcessor
is no longer the third argument offormatQuery
. To use a customvalueProcessor
, pass an options object as the second parameter and includevalueProcessor
as a key in that object.- When the
formatQuery
format is set tosql
(either byformatQuery(query, 'sql')
orformatQuery(query, { format: 'sql' })
), the values will be quoted with single quotes instead of double quotes, e.g.(name = 'Peter Parker')
.
v3.5.1 - 2020-06-22
- Prevent lodash from assigning global
_
variable 74ee1ca
v3.5.0 - 2020-06-20
- #145 Convert source to TypeScript (@jakeboone02)
- #135 Reset
value
onoperator
change (@artenator)
- Option to reset rule on operator change
- #144 IE11 support (@jakeboone02)
v3.4.0 - 2020-06-15
- #142 Customizable
Rule
component (@jakeboone02)
v3.3.0 - 2020-06-12
- Some TypeScript type names have changed, e.g.
Rule
is nowRuleType
sinceRule
is an exported React component.
v3.2.0 - 2020-05-28
- #139
"parameterized"
option forformatQuery
(@jakeboone02)
v3.1.2 - 2020-03-19
"json_without_ids"
option forformatQuery
v3.1.1 - 2020-02-18
- v3.1.0 published files were outdated
v3.1.0 - 2020-02-18
- #122
resetOnFieldChange
prop to controlvalue
andoperator
reset functionality onfield
change (@lakk1)
v3.0.2 - 2019-12-09
- v3.0.1 published files were outdated
v3.0.1 - 2019-12-06
- #117 Rule default value on add/change (@xxsnakerxx)
v3.0.0 - 2019-11-29
- #115 Add
div.ruleGroup-header
(@jakeboone02)- A
div
with classruleGroup-header
now wraps around the rule group header elements to assist with styling those elements as a group. This may affect some custom CSS rules that depend on the particular HTML arrangement in versions earlier than 3.0.0.
- A
v2.5.1 - 2019-11-11
- #113 Passing
not
property to rule groups below root (@RomanLamsal1337)
v2.5.0 - 2019-11-10
- Lowercase operator labels
v2.4.0 - 2019-09-23
- #107
fieldData
prop for customOperatorSelector
andValueEditor
components (@jakeboone02)
v2.3.0 - 2019-09-16
- #104 Inversion (
"not"
) toggle switch for rule groups (@jakeboone02) - #103 Added
level
and ruleid
to DOM elements (@srinivasdamam)
- #102 Replace
uuid
withnanoid
(@srinivasdamam)
v2.2.1 - 2019-08-29
- TypeScript definitions
v2.2.0 - 2019-08-29
- Added missing props to new
ValueEditor
types - Added
title
prop and completedValueEditor
props
v2.1.0 - 2019-08-27
- Enhanced default
ValueEditor
to handle multiple input types (#94)
v2.0.1 - 2019-08-27
- #93 Pass in new root to
_notifyQueryChange
(@pumbor) - #84 Add
className
prop toValueEditor
, pass it on toinput
element (@kkkrist)
v2.0.0 - 2019-08-18
- #87 Hooks rewrite and increased test coverage (@jakeboone02)
- #82 Removed type restrictions on rule
value
s (@jakeboone02)
v1.4.3 - 2018-04-08
- #60 Fixed TypeScript function parameter definitions (@jakeboone02)
v1.4.2 - 2018-03-02
- #55 Add optional
id
information in README (@CharlyJazz)
v1.4.1 - 2018-03-02
- #53 Add optional
id
property tofields
(@CharlyJazz)
v1.4.0 - 2017-12-11
- #46 Types: Added
id
attribute toRuleGroup
(@jakeboone02)
- #47 Add
translations
prop to be able to set translatable texts (@bubenkoff) - #44 Add TypeScript typings (@jakeboone02)
- #42 Converted
Rule
subcomponents to SFCs (@jakeboone02)
v1.3.8 - 2017-07-14
- #37 package updates and making it compatible with codesandbox.io (@pavanpodila)
v1.3.6 - 2017-03-13
- #28 Add
field
to operator selector control element (@SamLoy) - #27 Added more context information to
controlElements
(@SamLoy)
v1.3.5 - 2017-02-06
- #24 README: Update live demo link to use v1.3.4 and React 15 (@mreishus)
- #23 README.md Usage - destructuring removed from import (@mreishus)
v1.3.4 - 2017-01-23
v1.3.0 - 2016-10-12
- #15 Fix test setup (@maniax89)
- #11 Move 'this' binding to
componentWillMount
(@maniax89) - #9 Remove unnecessary imports (@maniax89)
- #13 Rule group tests (@maniax89)
- #12 Add
ActionElement
tests to<Rule />
(@maniax89) - #10 WIP: Add
<Rule />
Tests (@maniax89) - #8 WIP: Added CHANGELOG.md (@maniax89)
- #7 Add in
ActionElement
for custom<button />
elements (@maniax89) - #6 Custom rule controls (@maniax89)
v1.2.0 - 2016-07-11
v1.1.0 - 2016-06-27
controlClassnames
prop- Documentation update
v1.0.10 - 2016-06-26
- Stop event propagation for buttons
- Proper
dist
path
v1.0.9 - 2016-06-20
- Documentation update
v1.0.8 - 2016-06-19
- Documentation update
v1.0.7 - 2016-06-19
- Live demo URL to README
v1.0.6 - 2016-06-19
react
andreact-dom
todevDependencies
v1.0.5 - 2016-06-19
- Documentation update
v1.0.4 - 2016-06-19
- Documentation and demo
v1.0.3 - 2016-06-19
- Include query-builder.scss in
dist
v1.0.2 - 2016-06-19
- "Pending" documentation note
v1.0.1 - 2016-06-19
- Build artifacts moved from
lib
todist
v1.0.0 - 2016-06-19
- Initial publish