Changelog
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.
Unreleased
Added
- #975
useAsyncOptionListand its corresponding Redux slice have been decoupled from the main bundle. They will now be loaded only when explicitly imported from"react-querybuilder/async". - #976 Redux DevTools can be enabled for the internal store by setting
globalThis.__RQB_DEVTOOLS__ = truebefore imports. Previously this required changing allreact-querybuilderimports toreact-querybuilder/debug. The/debugentry point is now deprecated (still works, but may be removed in a future major version).
Fixed
react-querybuilder/debugentry point and all@react-querybuilder/datetime/*entry points now work for "node10" module resolution.
v8.12.0 - 2025-11-06
Added
- #961 New hook
useAsyncOptionListwhich augments aValueSelectorPropsorValueEditorPropsobject with async option list loading and caching.
Fixed
- #974
parseCELcorrectly handles custom expressions in subqueries.
v8.11.2 - 2025-11-06
Fixed
- #967
prepareRuleGroupandprepareRulenow generateids for subqueries. - #969
parseCELcorrectly handles subqueries (.all()/.exists()) and dynamic property accessors (bracket notation).
v8.11.1 - 2025-10-23
Fixed
- #960 Issues with type and dependencies
v8.11.0 - 2025-10-21
Added
- #957 New
hideDefaultDragPreviewprop forQueryBuilderDnDhides the browser's default drag preview, enabling custom drag layers and components. - #954 Default styles now apply
{ cursor: not-allowed; opacity: 0.5; }to drag handles of locked/disabled rules and groups, visually clarifying the inability to drag the elements. - All pure
booleanprops are now assignable onQueryBuilderContext.
v8.10.0 - 2025-10-09
Added
- #947
showInputLabelsprop forQueryBuilderMaterialdisplays thetitleas a label above/within each input component rendered byMaterialValueEditorandMaterialValueSelector. - #950
customExpressionHandleroption forparseCEL. - #950
parseCELtypes, type guard functions, and other utilities are exported. - #948 Support for "muting" rules and groups.
showMuteButtonsprop will display a button with 🔊 or 🔇 depending on the booleanmutedproperty of the rule/group. As with rules/groups deemed invalid,formatQuerywill skip over rules/groups withmuted: true.
Fixed
- #947 Default titles for field, operator, and combinator selectors are now singular ("Fields"→"Field", "Operators"→"Operator", "Combinators"→"Combinator").
useMergedContexthandlesmatchModeandmatchThresholdtranslations.- Default styles for
queryBuilder-justifiedandqueryBuilder-brancheswork properly for RTL languages (dir="rtl"). - #951
formatQueryproperly handles invalid rules and groups in queries with independent combinators.
v8.9.2 - 2025-09-22
Fixed
- Build configuration for core and main packages
v8.9.1 - 2025-09-20
Fixed
- Publish configuration for core package
v8.9.0 - 2025-09-20
Added
- #942 Core features moved to new package
@react-querybuilder/core. All exports are re-exported byreact-querybuilder, so no breaking changes. - #935 New class
dndDropNotAllowedadded to elements that cannot accept a drop from the hovering element. Default style iscursor: not-allowed.
v8.8.4 - 2025-08-27
Added
- #932 New
useOptionListProphook to standardize option list prop normalization.
Fixed
- #937 The
matchproperty is now removed when a rule'sfieldis updated to a field that does not support match modes.
v8.8.3 - 2025-08-13
Fixed
- #931 In multi-select mode,
FluentValueSelectornow displays a comma-separated list of option labels instead of values.
v8.8.2 - 2025-08-07
Fixed
- #926 The
ruleGroupprop is now destructured and ignored on all*ValueSelectorcomponents, preventing it from being passed to DOM elements. - Deprecated unnecessary interfaces
ActionWithRulesPropsandActionWithRulesAndAddersProps.
v8.8.1 - 2025-07-09
Fixed
- #916 Corrected "sources" paths in CSS source maps.
v8.8.0 - 2025-07-09
Added
- #900 Support for matching elements of a nested array.
- New optional
RuleTypepropertymatch?: { mode: MatchMode, threshold?: number }type MatchMode = 'all' | 'some' | 'none' | 'atLeast' | 'atMost' | 'exactly'- In most contexts, a rule's
operatorwill be ignored whenmatchis present and valid.
- New component
MatchModeEditor, which renders when a field is determined to have one or more match modes. The mode selector is the configuredvalueSelectorand—when a threshold is appropriate—the threshold editor is the configuredvalueEditorwithinputType: "number". - New props
getMatchModesandgetSubQueryBuilderPropsto manage these configurations at the top level. - New
FieldpropertiesmatchModesandsubpropertiesto manage these configurations at the field level. parseJsonLogicsupport for "all", "none", and "some" operations.formatQuery(partial) support for thematchrule property.- Supported formats include "sql", "parameterized", "drizzle", "natural_language", "mongodb_query", "jsonlogic", "jsonata", "spel", and "cel".
- To avoid invalid syntax, the SQL-based formats only work with
preset: "postgresql", and only with nested arrays of primitives like strings or numbers.
- New optional
- #903 New parser option
bigIntOnOverflow. When true, abigintwill be generated for parsed tokens that represent valid integers outside the safe boundaries of thenumbertype. (This currently only applies toparseSQL.) - #911 Support for
inputType: "bigint"in all value editors, which will render an input withtype="text"but will store the value as abigintif a valid integer is entered. - #900 Extracted
fieldsprop processing logic to newuseFieldshook. - #900 "Justified layout" styles from the demo (to push the "+ Rule", "+ Group", clone, lock, and remove buttons to the right edge) are now included in the default stylesheet. To apply the styles, add the
queryBuilder-justifiedclass to the query builder using thecontrolClassnamesprop, or to any ancestor element. - #900 All components that render
<label>elements now havehtmlForattributes linking their corresponding<input>elements using anidgenerated withuseId(). - #900 The
getValueSourcesprop and theField#valueSourcesproperty can now evaluate to a full option list instead of a simple array of value source strings. This enables translations of the value sources through thelabelproperty. - #914 Option list props (including
fields,operators,combinators,getOperators, andgetValues) can now include strings in addition to—or instead of—Optionobjects (e.g.["=", "between"]). The string itself will be used as both the identifier and label, except in the case of operators and combinators where the default labels will be used if the string matches a value from the default set.
Fixed
- #903
parseSQLmaintains precision for large integers by generating abigintinstead of anumberwhen necessary. - #900 Preact compatibility improved by using
React.Fragmentexplicitly instead of the shorthand<>...</>. - #900 If the
presetoption forformatQueryis one fromsqlDialectPresets, it will only apply if theformatis undefined or one of the SQL-based formats.
v8.7.1 - 2025-06-09
Added
- CSS/SCSS variable
rqb-base-color.rqb-background-colorisrqb-base-colorwith 20% opacity (effectively the same color as before, just calculated differently). maxLevelsprop to limit the addition of new rule groups beyond the specified nesting level. Default isInfinity(allows unlimited levels), and values other than 1 or greater will be ignored.
v8.7.0 - 2025-05-13
Added
- #891 Support for several ORM query formats:
- New "prisma" format for Prisma ORM.
- New "sequelize" format for Sequelize.
- New "drizzle" format for Drizzle relational queries API.
- Can also be used for the Drizzle query builder API, which eliminates the need for the
@react-querybuilder/drizzlepackage.
- Can also be used for the Drizzle query builder API, which eliminates the need for the
v8.6.2 - 2025-05-12
Fixed
- #893 ESM import errors with certain build tools when using
@react-querybuilder/material.
v8.6.1 - 2025-05-06
Fixed
- #890 Escape forward slash in JSONata export format.
- #890 Correct information in Drizzle package README.
v8.6.0 - 2025-05-05
Added
- #885 New package
@react-querybuilder/drizzlefor integration with the Drizzle ORM query builder API. - #885 LDAP export format.
- #885 New
formatQueryoptionruleGroupProcessorenabling development of custom output formats without completely reimplementingformatQuery.- The rule group processors for each of the existing formats have been extracted from
formatQueryand can be used independently or as fallbacks from custom processors.
- The rule group processors for each of the existing formats have been extracted from
- #883 Query tools
add,update,remove,move, andgroupcan now accept astringorPathwhere they previously accepted onlyPath-type arguments. Astringwould represent theidproperty of the subject rule/group, but otherwise the functionality of each tool is the same. - #883 New utility methods:
findIDreturns the rule or group with the givenidproperty within a query hierarchy (similar tofindPath), andgetPathOfIDreturns thepathof the rule or group with the givenid. - #885 Confirmed Mantine v8 support (no changes).
Fixed
- #885
parseSQLwas translatingNOT LIKE '[...]'(no leading or trailing wildcards) tooperator: "="instead ofoperator: "!=". - #885 Importing from
react-querybuilder/formatQueryno longer has a dependency onreact.
v8.5.0 - 2025-04-07
Added
- #873 New prop
autoSelectValue(documentation) behaves likeautoSelectField/autoSelectOperatorbut for the value editor when it renders a select list.- The
translationsprop object has a new propertyvaluesthat acceptsplaceholderName,placeholderLabel, andplaceholderGroupLabelproperties (documentation). These translatable strings set the default values and labels whenautoSelectValueis set tofalse. - A corresponding
placeholderValueNameoption was added toformatQuery, which will now ignore rules where thevaluematches the placeholder value as long asplaceholderValueNameis defined (this behavior differs fromplaceholderFieldNameandplaceholderOperatorName, which do not need to be defined).
- The
- #876 Miscellaneous i18n enhancements for the "natural_language" export format:
translationsoption: Map of the words "and", "or", "true", and "false" to their translated equivalents. Also covers prefix and suffix options for rule groups.wordOrderoption: Based on the linguistic concept of constituent word order, this option accepts all permutations of "SVO" ("SOV", "VSO", etc.) and outputs the field, operator, and value in the corresponding order (S = field, V = operator, O = value).operatorMapoption: Map of operators to their natural language equivalents. If the result can differ based on thevalueSource, the key should map to an array where the second element represents the string to be used whenvalueSourceis "field". The first element will be used in all other cases.- Date/time formatting support: The
@react-querybuilder/datetimepackage now supports the "natural_language" format for date-type rules. Formatting can be customized by passinglocales,dateFormat, ordateTimeFormatas properties of thecontextparameter. These options are passed to aIntl.DateTimeFormatconstructor.
Fixed
- #877 Dynamic imports of
react-dndand related packages are now obfuscated to discourage bundlers like webpack from pre-processing those imports.
v8.4.1 - 2025-03-24
Fixed
- #868 Using
QueryBuilderDndWithoutProvideron its own now correctly impliesenableDragAndDrop={true}for each descendantQueryBuilder.
v8.4.0 - 2025-03-18
Fixed
- #860 The
idGeneratorprop is respected for all operations that create new rules or groups.
Added
- #860
@react-querybuilder/dndnow supportsreact-dnd-touch-backendas a drop-in replacement forreact-dnd-html5-backend. If both are provided, the touch backend will be preferred when a touch device is detected. - #860 "Group" feature of
@react-querybuilder/dnd. Pressing the Ctrl key while dragging a rule/group will form a new group at the target path with the target rule/group and the dragged rule/group in itsrulesarray. Pressing the Alt/⌥ Option key at the same time will leave the rule/group in its original location and clone it for the new group. - #860 Modifier keys used during drag-and-drop to indicate cloning and grouping (by default Alt/⌥ Option and Ctrl, respectively) are now configurable on the
QueryBuilderDnDcomponent with thecopyModeModifierKeyandgroupModeModifierKeyprops. - #860 New
groupquery tool which creates a new group at a target path with itsrulesarray containing the objects from a source path and the target path.
v8.3.1 - 2025-02-27
Fixed
- #858 The
type-festlibrary has been (partially) vendored intoreact-querybuilderto avoid requiring it as a dependency. - #858
UseMergedContextPropsrenamed toUseMergedContextParams(technically a breaking change, but probably won't affect anyone). - #858 All
Parse*Optionstypes have been removed from the main export. They are now only available on their respectivereact-querybuilder/parse*exports (another technically breaking change that probably won't affect anyone).
v8.3.0 - 2025-02-21
Added
- #855 CSS variables, enabling customization of the default stylesheet without using SCSS.
- #855 New option
generateIDsfor allparse*methods. When true, the output query object will be processed throughprepareRuleGroupto addids.
v8.2.0 - 2025-01-28
Added
- #845 New
formatQueryoptionoperatorProcessor. Currently only applies to "sql", "parameterized", "parameterized_named", and "natural_language" formats. - #846 New
formatQueryoptionpreserveValueOrder. Preserves the order of values when exporting rules with "between"/"notBetween" operators, even if the larger value comes first.
Fixed
- #844 The
formatQuery"elasticsearch" export format now includes the.valueproperty when outputting Painless scripts. - #845
formatQueryhandlescombinatorandoperatorvalues case-insensitively. - #846
convertQuery,convertToIC, andconvertFromICnow support the "xor" combinator, as does the "natural_language" export format.
v8.1.1 - 2025-01-20
Fixed
- #840 The behavior and list of valid values for the
formatQueryoptionparseNumbersnow aligns with the correspondingQueryBuilderprop, as long as afieldsarray is also provided. - #836
AntDValueSelectornow filters on thelabelproperty and defines options with theoptionsprop instead of achildrenarray of<Select.OptGroup>/<Select.Option>. - #836 Utilities that determine whether arrays are valid option lists (
isFullOptionArray,isFlexibleOptionArray,isFullOptionGroupArray,isFlexibleOptionGroupArray) are now more strict: All leaf elements must conform to the operative type, not just the first element. - The "mssql"
formatQuerypreset now setsparamPrefix: '@'.
v8.1.0 - 2025-01-09
Added
- #820 New
@react-querybuilder/datetimepackage with enhanced functionality for managing date/time data. Includes rule/value processors forformatQuerytailored to different database platforms and date/time libraries. - #820
formatQuerywill assume a format of "sql" if no format is provided as long aspresetmatches one of the supported values. - #820 New
formatQueryoptionwrapValueWith, an array of two strings to act as a prefix and suffix for values (outside of any quotes). - #820
formatQueryvalue processors now accept an optionalcontextparameter, which can be used to pass additional information to the processor. - #820 New "mongodb_query" export format. This format is exactly the same as "mongodb" except it returns an actual JSON object instead of a
JSON.stringifyd version. The "mongodb" format is deprecated, but will not be removed. - #820 Default SCSS stylesheet
query-builder.scssnow uses@useinstead of the deprecated@import. - #834 React 19 support (verification only, no meaningful code changes were necessary).
v8.0.0 - 2024-11-08
Changed
- #805
@react-querybuilder/chakranow supports Chakra UI version 3 and no longer supports version 2. For Chakra UI version 2 support, use@react-querybuilder/chakra2. - #805
ChakraDragHandlehas been removed. In Chakra UI version 3 environments, the defaultDragHandlecomponent works without augmentation.
Added
- #814 Debug build which registers the internal Redux store with Redux DevTools (more "debug" functionality may be added in the future). To use the debug build, update all
"react-querybuilder"imports to"react-querybuilder/debug".
Fixed
- #814 The internal Redux store is no longer registered with Redux DevTools by default.
bootstrapClassnamesno longer includesvalue: "form-control form-control-sm". The classes are added byBootstrapValueEditoronly when necessary.- #812
@react-querybuilder/bulmaproperly indicates compatibility with Bulma v1 in itspeerDependencies, and the website demo now uses Bulma v1.
v7.7.1 - 2024-10-21
Changed
- #791 The
@react-querybuilder/materialpackage uses theTextFieldcomponent from@mui/material(previous versions usedInput). Implementations that preload MUI components may need to be updated.
Fixed
- #791 The
extraPropsprop ofMaterialValueEditorworks properly. - #796
FluentShiftActionsandTremorShiftActionsare now applied by default in their respective compatibility packages.
v7.7.0 - 2024-10-08
Changed
- The
useValueEditorhook now requires the entireValueEditorPropsobject instead of only requiring a subset of the props.
Added
- #755 New
controlElementspropertiesruleGroupHeaderElementsandruleGroupBodyElements, enabling customization/replacement/augmentation of the subcomponents within the rule group header and body wrappers without needing to reimplement the entireRuleGroupcomponent. - #785 New prop
suppressStandardClassnames. Whentrue, no classes will be added automatically to any elements (custom classes defined incontrolClassnameswill still be applied). This includes conditional and event-based classes for validation, drag-and-drop, etc. - #785 A "dndCopy" class will be added when drag-and-drop is enabled and the modifier key (Alt/⌥ Option) is pressed while the drag phase begins. When using the default styles, the drag-and-drop indicator line will be green (
#669933) instead ofrebeccapurple(#663399). - #755 New
useQueryBuilderNativehook. Works the same asuseQueryBuilder, but tailored for React Native implementations. - #769 The
parseNumbersprop now accepts an optional "-limited" suffix on existingstringconfig values "enhanced", "strict", and "native". When the "-limited" suffix is used (e.g.,parseNumbers="strict-limited"), values will only be parsed for numericity when theinputTypeis"number". - #769
formatQuerynow accepts an optionalconcatOperatorparameter to support non-standard concatenation methods in the various SQL dialects. The default is the ANSI standard"||", which is supported by PostgreSQL, Oracle, SQLite, and various others, while SQL Server uses"+". A value of"CONCAT"will enable MySQL compatibility by using theCONCATfunction (do not use this for Oracle as itsCONCATfunction is limited). - #769 The
toArraymethod now accepts an optional configuration parameter. If theretainEmptyStringsproperty of that object istrue, the function will not filter out string elements that are empty or purely whitespace. - #769 The object returned from
useValueEditornow includes aparseNumberMethodproperty, which is a processed version of theparseNumbersprop. - #769
formatQuerynow accepts an optionalpresetoption as a shortcut to configure the output for improved compatibility with different query language dialects. Options include "ansi", "mssql", "mysql", "oracle", "postgres", and "sqlite". - #769
formatQuerynow accepts an optionalfieldIdentifierSeparatorstring. When used in conjunction with thequoteFieldNamesWithoption, field names will be separated by this string and bracketed individually per thequoteFieldNamesWithconfiguration (e.g.,[table name].[field name] = 'value'instead of[table name.field name] = 'value'). - #786 New
formatQueryexport format "natural_language", similar to the "sql" or "cel" formats but with English-language operators.
Fixed
- #769 On rules using a "between"/"notBetween" operator, the second value no longer shifts into the first input when the first value is removed.
- #769 Type
ParseNumbersMethodrenamed toParseNumberMethod(singular) to better reflect its assocation with theparseNumbermethod as opposed to theparseNumbersprop. - #769 Internally, the default MongoDB rule processor for
formatQueryuses actual JSON objects instead of manually constructingJSON.parse-able strings. This should lead to more reliably valid results. - #769 When generating SQL for a rule where (1) the
operatoris "between" or "notBetween", (2) the values are numeric, and (3)parseNumbersistrue,formatQuerywill place the smaller value first and the larger value second, regardless of their order in the rule'svalueproperty. - #779 When
parseJSONataencounters an expression group where only two conditions exist for the same field, one greater-than and one less-than, a single "between"/"notBetween" rule will be generated. Previously a rule group with two separate rules would be generated. - #783
MantineValueSelectorno longer sets the value to""when clicking the selected option again.
v7.6.1 - 2024-08-02
Fixed
- Drag-and-drop hooks (
useReactDnD,useRuleDnD,useRuleGroupDnD, anduseInlineCombinatorDnD) are now exported from@react-querybuilder/dnd. - #748
formatQuerycorrectly handles values that are lists of numbers whenparseNumbersistrue.
v7.6.0 - 2024-07-11
Added
- #734 New callback props
onMoveRuleandonMoveGroup, called before a rule or group is moved (via drag-and-drop) or shifted. If the result of the callback isfalse, the move will be cancelled. Iftrue, the move will proceed as normal. Alternatively, a full query object can be returned representing the new state if some other modifications were necessary. - #734
onAddRuleandonAddGroupcallbacks can now returntrueinstead of the entire rule/group to allow the addition to proceed as normal.
Fixed
- #733
parseSpELwas not handling thematchesoperator correctly when its value was a single character. - #733 Improved
formatQuery"elasticsearch" output for "contains" and "doesNotContain" operators.
v7.5.2 - 2024-06-27
Fixed
- #730
parseMongoDBwas not handling the$regexoperator correctly when its value was a single character.
v7.5.1 - 2024-06-25
Changed
- #727
useMergedContextno longer returns values that are not explicitly typed inUseMergedContextProps. - #727
keyis no longer required in the parameter passed togetCompatContextProvider.
Fixed
- #727 Overall memoization strategy and implementation is improved.
- #727 Option group utility functions are better at identifying what is and isn't an option group list.
- #727 The
draggingproperty of the object passed tocanDropis no longer a stale reference to the rule/group being dragged.
v7.5.0 - 2024-06-15
Changed
- #716 The React Native compatibility package uses
gapfor layout spacing, which means the minimumreact-nativeversion is now0.71.0.
Added
- #723 The
useQueryBuilderhook has been reinstated. It does nothing more than calluseQueryBuilderSetupanduseQueryBuilderSchema, which no longer need to be called from separate components. - #723
useQueryBuilderQueryhook to retrieve the full, current query object during the render pass of a custom component. It requires no parameters and should be used in place of the previously recommended hookuseQueryBuilderSelector, which requires a selector function generated withgetQuerySelectorById(props.schema.qbId). WhileuseQueryBuilderSelectoris not deprecated, it is no longer recommended except in very special circumstances.
Fixed
- #723
useQueryBuilderSelectorno longer returnsundefinedduring the first render pass (and neither does the new hookuseQueryBuilderQuery). - #716
parse*methods properly escape commas in string values for "between" and "in" operators.
v7.4.4 - 2024-06-10
Fixed
- #719 The "mongodb" export format stringifies values using
JSON.stringify.
v7.4.3 - 2024-06-06
Fixed
- Compatibility packages now specify the correct
react-querybuilderdependency version.
v7.4.2 - 2024-06-06
Added
- #713
insertutility method to insert a new rule or group anywhere in the query hierarchy.insertis similar toaddexcept that the new rule or group can be inserted at any path (addcan only append a rule or group to the end of a group'srulesarray). The optionreplace: truewill replace the rule or group at the specified path.
Fixed
- #713
@react-querybuilder/dndnow supports dragging and dropping rules and groups across separate query builders. As with drag-and-drop within a single query builder, holding the modifier key (Alt on Windows/Linux, ⌥ Option on Mac) when dropping the rule/group will copy it instead of move it. - #713
debugModenow logs the query builder'sqbId. - #714
parseJsonLogiccan now override group operations ("and", "or", "!", and "!!") with thejsonLogicOperationsoption.
v7.4.1 - 2024-06-04
Fixed
- #706
parseJsonLogicno longer nests negated groups unnecessarily.
v7.4.0 - 2024-05-27
Changed
- #703 The
independentCombinatorsproperty has been removed from theInlineCombinatorPropsinterface. The value can be still be retrieved from theschemaprop. - #703 Distributed CSS files are compressed (comments and unnecessary whitespace removed).
Added
- #699 Most properties of the
controlElementsprop can be set tonull. Properties set tonullwill be rendered as() => null.
Fixed
- #700
parseCELno longer creates a rule group withnot: truewhen parsing a single rule in a negated parenthetical group. Instead, the rule operator is inverted. - #703 When
enableDragAndDropistrueand a rule or group is dragged over an inline combinator (such as generated whenshowCombinatorsBetweenRulesis enabled or the query uses independent combinators), the "drop location" indicator (a dashed, purple line by default) will appear above the inline combinator. Previously the styles placed the indicator line below the inline combinator, which could be misleading, particularly for independent combinators.
v7.3.0 - 2024-05-13
Changed
displayNameis no longer explicitly declared for any components.
Added
- #696
baseField,baseOperator,baseCombinatorprops. Properties defined in these props will be applied to each option in thefields,operators, andcombinatorslists, respectively. Corresponding properties defined for individual options will override the "base" properties. - #688
parseJSONata, an experimental JSONata parser. - #697
quoteValuesWithoption forformatQuery(applicable to "sql" format only). Values will be bracketed by the provided string, e.g. double quotes ('"'), instead of the default single quotes.
v7.2.1 - 2024-05-06
Fixed
- #682
parseCELprocesses "like" operators ("contains"/"startsWith"/"endsWith") that are negated without parentheses, like!f1.contains(f2). - #692
formatQueryupdates (these are probably technically breaking changes, but the logic itself is equivalent to the previous version so we're considering them bug fixes):- For the "jsonlogic" export format, the entire group structure is retained even if only one top-level child object exists.
- For the "jsonlogic", "mongodb", and "cel" formats, rules where the operator is "in" or "notIn" and the value evaluates to an empty array are retained.
- The "jsonata" format now respects the
quoteFieldNamesWithoption.
- #692 Custom field selectors can set their rule's
fieldproperty to an arbitrary value without throwing an error, even if the value is not included in thefieldsprop list.
v7.2.0 - 2024-04-15
Added
Fixed
- #677 A bug in the default SpEL and CEL rule processors for
formatQuerycaused rules to be ignored when the operator was "between" or "notBetween" and one of the values was falsey without beingnullorundefined(e.g,0or"").
v7.1.0 - 2024-04-01
Changed
- To avoid confusion with the recommended query selector and update methods (
useQueryBuilderSelector,props.schema.getQuery(), andprops.schema.dispatchQuery()), the hooksuseQueryBuilderDispatchanduseQueryBuilderStoreare no longer exported.
Added
- New "bulk add"
controlClassnamesproperties. These classnames augment—rather than replace—the classnames defined for specific controls.actionElement: Applied to all action elements likeaddRuleAction,addGroupAction, etc.valueSelector: Applied to all selection elements likecombinatorSelector,fieldSelector, etc.
- New
numberedParamsoption forformatQuery. When the format is"parameterized", parameter placeholders within the generated SQL string will begin with the configuredparamPrefix(default ":") followed by a numbered index beginning with1instead of using "?" as the placeholder for all parameters. This option was added primarily to reduce the code necessary for generating PostgreSQL-compatible SQL.formatQuerynow passes a third parameter to customruleProcessorfunctions when the format is "parameterized" or "parameterized_named". Currently the parameter is an object with a single property,processedParams, which represents the current state of theparamsarray (for the "parameterized" format) or object (for the "parameterized_named" format) at the point the rule processor is invoked during query processing. The defaultruleProcessorfor the parameterized formats uses this parameter when thenumberedParamsoption istrue.
Fixed
- Improved performance of
generateIDwhencrypto.randomUUIDis not available. This led to performance improvements in initial<QueryBuilder />rendering and query update functions.
v7.0.2 - 2024-03-12
Changed
@react-querybuilder/antduses AntD'sInputNumberinAntDValueEditorwhenvalueEditorType === "number".
Added
- #671
formatQuerynow respects theruleProcessoroption for "parameterized" and "parameterized_named" export formats.
Fixed
- Mantine and Tremor versions are no longer pinned to a specific patch version.
start:*scripts for compatibility packages now correctly load their particular dependencies (does not affect execution).
v7.0.1 - 2024-03-07
Fixed
- Corrected node10/node16 module resolution for
react-querybuilder/parseSpEL.
v7.0.0 - 2024-03-06
Changed
- The minimum React version is now 18, due to the new
react-reduxv9 dependency. - #654 The minimum TypeScript version is now 5.1.
- #595 The parser functions have been removed from the main export, and are only available as separate exports. This change reduces the main bundle size by roughly 50%.
Function New importrequirementparseCELimport { parseCEL } from "react-querybuilder/parseCEL"parseJsonLogicimport { parseJsonLogic } from "react-querybuilder/parseJsonLogic"parseMongoDBimport { parseMongoDB } from "react-querybuilder/parseMongoDB"parseSQLimport { parseSQL } from "react-querybuilder/parseSQL" - #537 Some of the default labels have been updated per the table below.
Key Old New Notes translations.addRule.label"+Rule""+ Rule"Space added between "+" and "Rule" translations.addGroup.label"+Group""+ Group"Space added between "+" and "Group" translations.removeRule.label"x""⨯"HTML entity ✗/⨯translations.removeGroup.label"x""⨯"HTML entity ✗/⨯ - #589 The
independentCombinatorsprop has been deprecated and will be ignored if used. To enable the independent combinators functionality, useRuleGroupTypeICfor thequeryordefaultQueryprop. The query builder will detect the query type and behave accordingly. If theindependentCombinatorsprop is present, a warning will be logged to the console (in "development" mode only). - #523
parseMongoDBnow generates more concise queries when it encounters$notoperators that specify a single, boolean condition. Whereas previously that would yield a group withnot: true, it will now generate a rule with a inverted/negated operator ("="inverted is"!=","contains"inverted is"doesNotContain", etc.). To prevent this behavior, set thepreventOperatorNegationoption totrue(#653). - #589 The
disabledprop has been un-deprecated. Disabling the entire query with the prop and settingdisabled: trueas a property of the root group now produce different behaviors. Specifically, the root group's lock/unlock button will always be enabled if thedisabledprop is nottrue. - #555 Value editors for compatibility packages that render components specific to their respective library now accept an
extraPropsprop that will be passed directly to the library component, spread like{...extraProps}. The type ofextraPropsisanybecause each value editor can render one of several library components that accept different props. - #637 The
"json_without_ids"export format now explicitly removes theidandpathproperties from the output, leaving all other properties unchanged. Previously this format would only include specific properties which had the effect of removing any non-standard properties. - The first generic argument of
ValueEditorProps,ValueSelectorProps, andFieldSelectorPropsmust extend the newFullOptioninterface instead ofOption.
Compatibility packages
- #537 Several compatibility packages now override the default labels for non-text components (
lock*,clone*,remove*, anddragHandle) with SVGs from official icon packages. This brings them more in line with their respective design systems by default.@react-querybuilder/antd:@ant-design/icons@react-querybuilder/bootstrap:bootstrap-icons@react-querybuilder/chakra:@chakra-ui/icons@react-querybuilder/fluent:@fluentui/react-icons-mdl2@react-querybuilder/material:@mui/icons-material
- #537
@react-querybuilder/mantinenow requires Mantine v7. - #537
@react-querybuilder/bootstrapcomponentBootstrapDragHandlehas been removed. It is redundant sincedragHandle.labelcan now be aReactNode.
Low-impact changes
- #537 The
useQueryBuilderhook has been split intouseQueryBuilderSetupanduseQueryBuilderSchema. Each hook takes the fullQueryBuilderprops object as its first parameter (asuseQueryBuilderdid), anduseQueryBuilderSchemaaccepts the return value ofuseQueryBuilderSetupas its second parameter. - #537 The
useStopEventPropagationhook now takes a single function as its parameter instead of an object map of functions, so it must be run for each wrapped function individually. - #537 Paths are now declared with a new type alias
Pathinstead ofnumber[]. The actual type is the same:type Path = number[]. - #537 The
RuleGroupTypeICtype now includescombinator?: undefinedto ensure that query objects intended for use in query builders whereindependentCombinatorsis enabled do not containcombinatorproperties. - #663 Whereever the native
parseFloatwas used internally,parseNumberis now used.parseNumbernow delegates parsing to the more versatilenumeric-quantitypackage. The default behavior has not changed, but a new "enhanced" option will ignore trailing invalid characters (e.g., "abc" in "123abc") just like the nativeparseFloatmethod, with the only difference being it won't returnNaNwhen parsing fails. Additionally, thenumericRegexexport is now adapted from (but largely identical to) the export of the same name fromnumeric-quantity. - The logic to prefer a field's
valueEditorTypeover thegetValueEditorTypeprop has moved from theuseRulehook to theuseQueryBuilderSetuphook.
Added
- Default structural styles (flex direction, alignment, spacing, etc.) are now available in a standalone stylesheet
query-builder-layout.css/query-builder-layout.scss. The default stylesheet,query-builder.css/query-builder.scss, still contains structural styles but also includes more decorative styles like colors and border styles. The effective styles of the default stylesheet have not changed from version 6. - #586 Options in list-type props can now use
valueas the identifier property in lieu ofname. Additionally, allOptions withinOptionLists passed down to subcomponents (fields,fieldData,combinators,operators,values, etc.) are guaranteed to have bothnameandvalue. This makes it easier to use libraries likereact-selectthat expect a list of type{ value: string; label: string; }[]and not{ name: string; label: string; }[].- #654 Relatedly, field identifier types (
name/valueproperties) will now be inferred from thefieldsprop if they have been narrowed fromstring. These narrowed types will be applied to subcomponents and other props that take fields or field identifiers as arguments/props. - #663 The
Field,Operator, andCombinatorinterfaces each have correspondingFull*and*ByValuecounterparts. Bothnameandvalueare required in theFull*interfaces; onlyvalueis required in the*ByValueinterfaces.
- #654 Relatedly, field identifier types (
- #595 Two "bulk override" properties have been added to the
controlElementsprop:actionElementandvalueSelector. WhenactionElementis defined, it will be used for each component that defaults toActionElement(as long as that component is not explicitly overridden in thecontrolElementsprop). Same forvalueSelectorand components that default toValueSelector(includingValueEditorin cases where it renders a value selector). This makes it possible to define replacement components for all buttons and selectors at once instead of one-by-one.controlElementspropertySets default for valueSelectorcombinatorSelector,fieldSelector,operatorSelector,valueSourceSelector,valueEditor(when rendering a value selector)actionElementaddGroupAction,addRuleAction,cloneGroupAction,cloneRuleAction,lockGroupAction,lockRuleAction,removeGroupAction,removeRuleAction - #577 A new
showShiftActionsprop provides first-class support for rearranging rules within a query without enabling drag-and-drop. WhenshowShiftActionsistrue, two buttons will appear at the front of each rule and group (except the root group), stacked vertically by default. The first/upper button will shift the rule or group one spot higher, while the second/lower button will shift it one spot lower. Pressing the modifier key (Alt on Windows/Linux, ⌥ Option on Mac) while clicking a shift action will clone the rule or group instead of just moving it. AShiftActionscomponent has been added, along with a corresponding component for each compatibility package. NewtranslationspropertiesshiftActionUpandshiftActionDownallow configuration of the label and title of each button within the new component. - #512 Accessibility is improved with the addition of a
titleattribute to the outermost<div>of each rule group. The text of this attribute can be customized with theaccessibleDescriptionGeneratorfunction prop. - #537/#589 Three new methods make it easier to manage arbitrary query updates from custom components. (Previously we recommended including the query object as a property of the
contextprop, but that workaround is no longer necessary.) The first two methods are available from theschemaprop passed to every component, and should only be used in event handlers. The third is a React Hook and should follow the appropriate rules.getQuery(): returns the current root query object.dispatchQuery(query): updates the internal query state and then calls theonQueryChangecallback.useQueryBuilderSelector(selector): returns the current root query object using the provided selector function, which can be generated withgetQuerySelectorById(props.schema.qbId).
- Most of the
get*callback props now receive an additional "meta" parameter with afieldDataproperty (more properties may be added to the "meta" object in the future).fieldDatais the fullFieldobject from thefieldsarray for the givenfieldname, including any custom properties (a common one isdatatype). This eliminates the need to find the field object based solely on the field'snamewithin theget*functions themselves. The following callback props provide the new "meta" parameter:getDefaultOperator,getDefaultValue,getInputType,getOperators,getRuleClassname,getValueEditorSeparator,getValueEditorType,getValues, andgetValueSources. - #537
<QueryBuilderDnD />and<QueryBuilderDndWithoutProvider />from@react-querybuilder/dndnow accept acanDropcallback prop. If provided, the function will be called when dragging a rule or group. The only parameter will be an object containingdraggingandhoveringproperties, representing the rule/group being dragged and the rule/group over which it is hovered, respectively. The objects will also contain thepathof each item. IfcanDropreturnsfalse, dropping the item at its current position will have no effect on the query. Otherwise the normal drag-and-drop rules will apply. - #537 All
labelprops andtranslations.*.labelproperties now acceptReactNode. This includes all action elements (buttons), "not" toggles, and drag handles. Previouslylabelwas limited tostring. This enables, for example, the assignment of SVG elements as labels. - #537 The
translationsprop can now be passed down through the compatibility context providers like<QueryBuilderBootstrap />and<QueryBuilderMaterial />. The object will be merged with thetranslationsprop of descendantQueryBuildercomponents. - #589 Custom rule processors for
formatQuerynow receive the fullFieldobject in the options parameter, as long as thefieldsarray is provided alongsideruleProcessor. In TypeScript, the member type of thefieldsarray now requires alabel: stringproperty. Previously, onlynamewas required. - #595
parseMongoDBnow supports custom operators through theadditionalOperatorsoption. - #589 New utility function
uniqByIdentifierreplacesuniqByName, which has been deprecated.uniqByIdentifierwill remove duplicates based on thevalueproperty, ornameifvalueis undefined (see #586). - #526 Experimental support for ElasticSearch export format in
formatQuery. - #606 New compatibility package for Tremor,
@react-querybuilder/tremor. - #537 New API documentation, generated directly from the source code, at https://react-querybuilder.js.org/api. In support of this, many types and functions now have better JSDoc comments which should provide a better developer experience in modern IDEs.
- #638 Value selectors now respect the
disabledproperty of individual options in option lists. - #663 The
formatoption set during a call toformatQuerywill be passed to custom rule processors as a property of the options object in the second parameter. - #663
parseSpELmethod for importing SpEL expressions.
Fixed
- #537 Performance is improved (especially for large queries), as long as each prop except for
queryhas a stable reference. The most common violation of that rule is probably inline arrow function declarations in theonQueryChangeprop, a problem which can usually be addressed withuseCallback. - #589 Fixed issue where locking the root group would prevent unlocking the query.
- #595
MantineValueSelectornow correctly renders option group headers. - #619 The package.json#types location has been corrected for all packages. This (probably) only affected legacy build systems that don't support/respect package.json#exports.
- #623 Fixed an issue where Next triggered the "uncontrolled to controlled" warning unnecessarily. Removed a
useEffectcall fromusePreviousand a ref that tracked "first render" fromuseQueryBuilderSchema. - #625 A default value will not be selected unnecessarily when
valueEditorTypeevaluates to"multiselect". - Refactored custom hooks to avoid unnecessary
useEffectcalls. - #663
formatQueryfor "jsonlogic" will no longer collapse subgroups that only contain one rule into a single JsonLogic rule. Full query objects that contain only one rule will still be collapsed. - #663 When a
valueslist is defined for a field, and the value is reset due toresetOnFieldChangeorresetOnOperatorChangebeingtrue, the rulevaluewill no longer be set to the first value in the list unless thevalueEditorTypeevaluates to "select" or "radio". - #663
formatQuerynow renders the fallback expression for subgroups where all rules are invalid. Previously this could result in"()", which is invalid SQL.
v6.5.5 - 2024-01-15
Fixed
- #632 The
useValueEditorhook no longer updates values that are arrays tovalue[0]whenvalueEditorType === "multiselect".
v6.5.4 - 2023-11-04
Fixed
- #585 Avoid React warning about unique
keyprops. - #585 Fixed invalid reference to
generatePickerin@react-querybuilder/antd.
v6.5.3 - 2023-10-20
Added
- #574
transformQueryenhancements:rulesproperties are no longer retained unconditionally. Therulesproperty can be copied or renamed like any other property using thepropertyMapoption.propertyMapkeys can now havefalsevalues. Properties matching apropertyMapkey with a value offalsewill be removed without further processing (including therulesproperty, which would avoid recursion through the hierarchy altogether).- New boolean option
omitPath. Whentrue, apathproperty will not be added to each rule and group in the query hierarchy.
Fixed
paramsKeepPrefixwas not applying to bind variables generated from rules with anoperatorof "between", "notBetween", "in", or "notIn".
v6.5.2 - 2023-10-19
Changed
- The
useValueEditorhook will now update all values that are arrays (Array.isArray(value)) to the first element of the array (value[0]) whenoperatoris anything except "between", "notBetween", "in", or "notIn". Previously this logic only applied wheninputTypewas "number". (To bypass this logic, pass{ skipHook: true }.)
Added
- New
paramsKeepPrefixoption forformatQuery, which enables compatibility with SQLite. When used in conjunction with the"parameterized_named"export format, theparamsobject keys will maintain theparamPrefixstring as it appears in thesqlstring (e.g.{ '$param_1': 'val' }instead of{ param_1: 'val' }).
Fixed
- #523
parseMongoDBnow properly handles objects in the form of{ fieldName: { $not: { /* ...rule */ } } }. This problem was particularly evident for$regexoperators that should have generated rules with"doesNot[Contain/BeginWith/EndWith]"operators, sinceformatQuery(query, 'mongodb')produces this structure andparseMongoDBwas not handling the inverse operation. isRuleGroupwill not error when the argument isnull.- #572
parseSQLnow recognizes signed numeric values like-12or+14.
v6.5.1 - 2023-06-26
Fixed
AntDValueEditorcallsgeneratePickerfrom the correct import.- Packages no longer "masquerade as CJS" when imported from ESM under
"node16"module resolution.
v6.5.0 - 2023-06-13
Changed
- #529 Drag handle components will no longer be rendered unless drag-and-drop is enabled. Previously, drag handle components were rendered unconditionally. Accordingly, the default stylesheet no longer applies
display: noneto thequeryBuilder-dragHandleclass when drag-and-drop is disabled since the components will not be rendered anyway.
Added
- #529 New props for several sub-components:
- The parent
ruleobject will now be provided tofieldSelector,operatorSelector,valueSourceSelector, andvalueEditorcomponents. - The parent
ruleGroupobject will now be provided tonotTogglecomponents. - The parent
ruleOrGroupobject will now be provided todragHandlecomponents.
- The parent
Fixed
- #529 The full rule object will now be passed to field-based
validatorfunctions. Previously, the parameter object only included thefield,operator,valueSource, andvalueproperties of the rule.
v6.4.1 - 2023-05-23
Fixed
- The custom JsonLogic operators
startsWithandendsWith(properties ofjsonLogicAdditionalOperators) now check the type of the first parameter before calling the respective methods. This avoids errors like "Uncaught TypeError: Cannot read properties of null (reading 'startsWith')" when a field in the object being evaluated isnull.
v6.4.0 - 2023-05-20
Changed
- #517
@react-querybuilder/mantinenow requires Mantine v6. React Query Builder v6.3.0 is compatible with Mantine v5.
Added
- #519 Extracted event default/propagation code from
RuleandRuleGroupinto a newuseStopEventPropagationhook.
Fixed
transformQueryno longer reassigns or remaps properties that don't already exist in the source query object.
v6.3.0 - 2023-05-03
Changed
- #503 Merged
@react-querybuilder/ctxand@react-querybuilder/tsback into the mainreact-querybuilderpackage.
Fixed
- #503 Resolved dependency issues in some environments.
- #503 Corrected
query-builder.css.map"sources" path.
v6.2.0 - 2023-04-28
Changed
- #499
@react-querybuilder/materialno longer loads MUI components asynchronously. Therefore, the components no longer need to be preloaded to avoid a flash of unstyled content.
Fixed
transformQuerywith thedeleteRemappedPropertiesoption set totrue(which is the default) will not attempt todeleteproperties that do not exist on the object (perObject.hasOwn()).
v6.1.4 - 2023-03-27
Fixed
- Subpath exports for utility functions (
formatQuery,transformQuery, and theparse*functions) now map to their TypeScript types and work for all module resolution strategies.
v6.1.3 - 2023-03-24
Fixed
- #491 Chakra UI components no longer have hardcoded style-related props like
size,variant, andcolorScheme. - #491 The
schemaprop will no longer be passed down to Ant Design and Chakra UI components.
v6.1.2 - 2023-03-21
Fixed
parseCELnow recognizes dot-separated identifiers correctly.
v6.1.0 - 2023-03-16
Fixed
- #488 The
formatQueryoptionquoteFieldNamesWithnow applies to values that represent field names (i.e.valueSource: 'field') when exporting to a SQL-based format.
Added
- #488 The
formatQueryoptionruleProcessornow applies to the "sql" format (though notably not the other SQL-based formats, "parameterized" and "parameterized_named"), allowing complete control over each rule's translation to SQL. The default rule processor for "sql" is exported asdefaultRuleProcessorSQL.
v6.0.7 - 2023-03-10
Fixed
- #486 Custom, non-legacy
valueProcessorfunctions called fromformatQuerywill now receive all relevant options, not onlyparseNumbers.
v6.0.6 - 2023-03-07
Fixed
- #483 The regular expression behind
parseSQLin the previous version was capturing too many characters when field names were wrapped in delimiters.
v6.0.5 - 2023-03-06
Fixed
- #479
parseSQLis now much more permissive of valid characters within strings and identifiers (whether they are delimited or plain). (#478 only added recognition of spaces within delimited identifiers.)
v6.0.4 - 2023-03-05
Fixed
- #478
parseSQLnow recognizes field names wrapped in square brackets, like[field name]. (The corresponding update toformatQuerywas made in #463 as part of v6.0.0).
v6.0.3 - 2023-03-02
Fixed
- #472 All development-mode console error messages have been (temporarily) removed to avoid the
process is not definedissue. BulmaValueSelectornow adds the"is-multiple"class to the wrapperdivwhen themultipleprop istrue.
v6.0.2 - 2023-02-25
Fixed
- #470
parseSQLnow handles escaped single quotes within strings
v6.0.1 - 2023-02-22
Added
v6.0.0 - 2023-02-18
Changed
- #455 A UMD build is no longer provided. See new instructions for buildless environments using ESM.
- #431 Major
ValueEditorupdate--including theValueEditors in the compatibility packages--for "between"/"notBetween" operators. When theoperatorfor a rule is "between" or "notBetween", two inputs will be displayed. Each will have the class "rule-value-list-item". They will manage thevalueas a comma-separated list unlesslistsAsArraysistrue, in which case a proper array will be used. - #431 The default border radius on rule groups and branch lines (SCSS variable
$rqb-border-radius) is now0.25rem(previously4px). Visually, this should be the same for most users since16pxis the defaultfont-sizeon most browsers, and $16 \times 0.25 = 4$. - #431 Utility function
chas been removed. Use a package likeclsx(what RQB uses internally) instead. - #431 Bulma compatibility components no longer specify the
is-smallclass, so they will be rendered at their default size.
Fixed
- #452 All packages now use the
"exports"field in theirpackage.jsonfor better ESM compatibility.
Added
- #452 New
ValueEditorpropselectorComponent(optional) enables the replacement of only the selector component in the value editor without recreating the logic in the default value editor. E.g.,const MyValueEditor = (props: ValueEditorProps) => (<ValueEditor {...props} selectorComponent={MyValueSelector} />)will use the default value editor logic and presentation except when it would normally display the defaultValueSelector. - #452 New React Native-compatible package
@react-querybuilder/nativeand associated example showcasing multiple UI libraries. - #452 New exports:
useQueryBuilder: All logic and configuration formerly internal to theQueryBuildercomponent has been extracted into a custom Hook, making it easy to implement one's own presentation layer without reproducing or copy-pasting the official component code.useRuleGroup: AsuseQueryBuilderis to theQueryBuildercomponent, theuseRuleGroupHook is to theRuleGroupcomponent.useRule: AsuseRuleGroupis to theRuleGroupcomponent, theuseRuleHook is to theRulecomponent.RuleGroupHeaderComponents/RuleGroupBodyComponents: These JSX fragments have been extracted from theRuleGroupcomponent and exposed as named exports, enabling the creation of a customRuleGroupwrapper without recreating the "innards" of the defaultRuleGroup. (For example, the new@react-querybuilder/nativepackage wraps these fragments inViewelements fromreact-native).
- #431 New props and Hook returns to support
ValueEditors new behavior for "between"/"notBetween" operators.- New
QueryBuilderpropgetValueEditorSeparator: Takes afieldname and anoperatorname and should return aReactNode(string, element, etc.) that will be placed between the two editors whenoperatoris "between" or "notBetween". E.g.,getValueEditorSeparator={() => "and"}. - New
QueryBuilderpropparseNumbers: Whentrue, the defaultValueEditorwill update its rule with an actual number instead of the string representation whenever possible. - New
ValueEditorpropskipHook: Whentrue, theuseValueEditorhook call within the defaultValueEditorcomponent will not make query updates. Enables safer rendering of the defaultValueEditoras a fallback to a custom value editor. - The
useValueEditorhook now returns an object withvalueAsArrayandmultiValueHandlerproperties. SeeValueEditorcode for usage.
- New
- #455
regenerateIDsworks for any object, not just rule groups. - #455 Query tools (
add,remove,update, andmove) will fail gracefully and return the original query if the providedpathorparentPathpoints to an invalid location in the query hierarchy. - #463 The
formatQueryoptionquoteFieldNamesWithnow accepts an array of strings with two elements. The first element will precede each field name and the second will succeed each field name. E.g.,['[', ']']would result in`[Field name] ...`.
v5.4.1 - 2023-01-30
Fixed
- #458 Fixed
parseJsonLogicoutput when a negated "between", "in", "contains", "beginsWith", or "endsWith" rule is the only operation.
v5.4.0 - 2023-01-06
Changed
- #443 Automatically generated
ids are no longer prefixed with"g-"or"r-". - The default border color has changed from
#7f81a2to#8081a2. This difference will almost certainly be imperceptible.
Fixed
- #443
generateIDno longer tries torequire('crypto')which should allow its use in more environments and build targets.
Added
- #443 New prop
idGeneratorcan be used to override the defaultgenerateIDfunction.
v5.3.3 - 2022-12-27
Fixed
- New
jsonLogicOperationsoption was causingparseJsonLogicto return a rule instead of a group if only one JsonLogic rule was passed in.
v5.3.2 - 2022-12-26
Added
- #434 Added
jsonLogicOperationsoption toparseJsonLogicto enable parsing of custom operations.
v5.3.1 - 2022-12-23
Fixed
- #432 The
cryptopackage was used in a way that didn't work in some Node environments.
v5.3.0 - 2022-12-23
Changed
- New rule and group
ids are now generated as valid v4 UUIDs usingcrypto.getRandomValues()instead ofMath.random(). ThegenerateIDfunction used internally is exported. - #418 TypeScript interface
NameLabelPairhas been deprecated and is now an alias for theOptioninterface.
Fixed
- #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
showCombinatorsBetweenRulesis enabled, a combinator selector immediately above a locked rule/group will no longer be locked unless the group it belongs to is locked. jsonLogicAdditionalOperatorsis exported again (documentation).
Added
- #422 Adding the class
queryBuilder-branchesdisplays "tree view" branch lines. - #426 Dynamic classnames based on the specific rule/group properties.
- New function props
getRuleClassnameandgetRuleGroupClassnameare passed the rule or group, and the return value will be added as a class to the surroundingdiv. Field,Operator, and new interfaceCombinatornow have an optionalclassNameproperty that will be applied to rules or groups that specify the appropriate attribute.
- New function props
- #417 Optional
arityproperty for operators. Whenarityis 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, andValueEditorPropsnow accept generics fornameand other properties. - #418 A new
OptionListtype covers theoptionsproperty for all standard selection lists (field, operator, combinator, etc.). Previously this was a union type:NameLabelPair[] | OptionGroup<NameLabelPair>[].OptionListis equivalent to this type, but 1) doesn't require typing the base type twice, and 2) uses the newOptionname instead of the deprecatedNameLabelPair. - #421 When
independentCombinatorsis enabled, customonAddRuleandonAddGroupcallbacks can add acombinatorPrecedingproperty 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
Added
- #403 Add
onRemoveprop and pass rule/group to allActionElements (buttons).
v5.1.3 - 2022-11-23
Fixed
- #387 Support
antdversion 5.
v5.1.2 - 2022-11-21
Fixed
- #399/#401 When dragging a rule or group over a group header, the
dndOverclass is no longer applied to child group headers.
v5.1.1 - 2022-10-27
Fixed
parseMongoDBandparseJsonLogicnow respectindependentCombinatorsoption.- Narrowed rule group types, like
DefaultRuleGroupTypeandDefaultRuleGroupTypeIC, are respected byconvertFromICandconvertToIC.
Miscellaneous
- v3 documentation was migrated from dedicated README to website versioned docs
v5.1.0 - 2022-10-26
Fixed
- #394
parseJsonLogicnow handlesnullvalues correctly.
Added
v5.0.0 - 2022-10-22
Changed
- Internet Explorer is no longer supported.
- The minimum TypeScript version is now 4.5.
- When
defaultQueryis defined, anidproperty will be added to each rule and group in the query hierarchy. This will be reflected in theonQueryChangecallback parameter. In previous versionsdefaultQuerywas not modified by the component itself, butidis now added because it is a required attribute internally. - Related to the previous bullet, the
prepareRuleGrouputility function will no longer coerce thenotproperty of groups to be abooleantype (or even defined at all). - #385 MongoDB output has been simplified: The
$eqand$andoperators are only used when necessary. - #343 Drag-and-drop functionality migrated
- In order to make the
react-dnddependency completely optional when theenableDragAndDropprop was not set totrue, drag-and-drop functionality was extracted fromreact-querybuilderinto a new package called@react-querybuilder/dnd. - The new package has
peerDependenciesofreact-dndandreact-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 areimmerandclsx. - Upgrade path: To enable drag-and-drop functionality in v5, nest
<QueryBuilder />within a<QueryBuilderDnD />element. TheenableDragAndDropprop is implicitlytruewhen usingQueryBuilderDnD, so you no longer need to set it explicitly unless it should befalse(which can be set onQueryBuilderDnDorQueryBuilder).export function App() {
return (
- <QueryBuilder enableDragAndDrop />
+ <QueryBuilderDnD>
+ <QueryBuilder />
+ </QueryBuilderDnD>
);
} - If your application already uses
react-dndand rendersDndProviderhigher in the component tree, replaceQueryBuilderDnDwithQueryBuilderDndWithoutProvider.
- In order to make the
Fixed
- #324 The
@react-querybuilder/materialpackage now properly inherits the theme configuration from ancestorThemeProviders. Note: the@mui/materialcomponents 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. parseCELnow handles strings correctly (including multi-line strings).- #389
AntDValueSelectorproperly handles empty string values in multiselect mode.
Added
- Each compatibility package now exports its own context provider that injects the appropriate
controlElementsandcontrolClassnamesproperties into any descendantQueryBuildercomponents (composition FTW!). This is now the recommended usage for all compatibility packages. - The
onAddRuleandonAddGroupcallback props now receive an optional "context" parameter as the fourth argument. This parameter can be provided by a customaddRuleAction/addGroupActioncomponent to itshandleOnClickprop. This allows users to alter or replace the default rule based on arbitrary data. For example, theaddRuleActioncomponent could render two "add rule" buttons which add different rules depending on which one was clicked, as long as they provided a differentcontextparameter. - 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.
formatQueryhas a newruleProcessorconfiguration option applicable to non-SQL query language formats. When provided, the entire rule output will be determined by the function. For the relevant formats,valueProcessoralready 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).parseSQLwill now ignore a leadingWHEREkeyword, 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
controlElementsprop has a new option:inlineCombinator. By default, this is a small wrapper around thecombinatorSelectorcomponent that is used when eithershowCombinatorsBetweenRulesorindependentCombinatorsistrue. TheinlineCombinatoroption 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
Fixed
- #364 The array passed to the
fieldsprop was being mutated if it contained duplicates, whether they were duplicate fieldnames or option grouplabels. Thefieldsprop is now treated as immutable. - #374
RuleGroupwas using unstable keys to render elements in therulesarray. Keys are now stable based onidproperties, which are auto-generated if not provided in thequery/defaultQueryprop.
v4.5.2 - 2022-08-19
Fixed
- Backslashes are now properly escaped when
formatQuerygeneratesJSON.parse-able strings ("mongodb" and "json_without_ids" formats). - The
parse*import methods properly handle backslashes. - #353 The
momentpackage is no longer included in the build for@react-querybuilder/antd.
Added
- #333 When a rule has an
operatorof "between"/"notBetween" and eithervalueSource: "field"orvalueEditorType: "select", the defaultValueEditorwill display two drop-down lists. The values of the drop-down lists will be joined with a comma when the rule'svalueproperty 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(andValueSelectorformultiple: 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" }
listsAsArraysformat:{ field: "f1", operator: "between", value: ["f2", "f3"], valueSource: "field" }
- Existing, default format:
v4.5.1 - 2022-06-21
Fixed
- The type
ValueProcessorwas incorrectly including the newValueProcessorByRuletype.ValueProcessoris now simply an alias forValueProcessorLegacy, which should undo a breaking change from v4.5.0.
v4.5.0 - 2022-06-19
Changed
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
formatQuerywill now invoke customvalueProcessorfunctions with different arguments based on the function's.lengthproperty, which is the number of arguments a function accepts excluding those with default values:- If the
valueProcessorfunction accepts fewer than three (3) arguments, it will be called like this:
valueProcessor(rule, { parseNumbers });The first argument is the
RuleTypeobject 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 thevalueProcessorfunction 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
Added
- #319 Invoking
valueProcessorwith the fullRuleTypeobject 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:defaultValueProcessorByRuledefaultValueProcessorCELByRuledefaultValueProcessorMongoDBByRuledefaultValueProcessorSpELByRule
- 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
distfolder). Click the respective "Import from [format]" button in the demo to try them out. - #328 New utility function
transformQueryrecursively processes rule groups and rules with the providedruleProcessor,ruleGroupProcessor, and other options (documentation).
Fixed
- #323
formatQueryoutputs 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
formatQueryandparseSQLno longer include React and are not minified.
v4.4.1 - 2022-06-03
Added
- New export format options:
- JsonLogic (
formatQuerydocs, JsonLogic.com) - Spring Expression Language (SpEL) (
formatQuerydocs, docs.spring.io)
- JsonLogic (
- MongoDB export format now supports
RuleGroupTypeIC(independent combinators).
v4.4.0 - 2022-05-30
Changed
(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 theinternalfolder. All exports from that folder were previously exported from theutilsfolder, which is re-exported in its entirety from the main entry point. - The
RulePropsandRuleGroupPropsinterfaces 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 aruleprop.- In
RuleProps:field,operator,value, andvalueSourceare deprecated and replaced byrule: RuleType. - In
RuleGroupProps:combinator,rules, andnotare deprecated and replaced byruleGroup: RuleGroupTypeAny.
- In
- Internal methods for immutably updating queries have been moved from the
schemaprop to the newactionsprop on bothRulePropsandRuleGroupProps. Custom<Rule />and<RuleGroup />components will need to adjust their prop declarations.
Fixed
vite-tsconfig-pathswas mistakenly added to thedependencieslist instead ofdevDependenciesfor the main package in v4.1.3.
Added
debugModenow 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
onLogcallback prop is used instead ofconsole.logwhendebugModeistrue. - As a consequence of the new properties on
RulePropsandRuleGroupProps(ruleandruleGroup, 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
queryanddefaultQueryprops are defined (TypeScript will complain about this at compile time, errors will be logged at run time) queryprop is undefined in one render and then defined in the next renderqueryprop is defined in one render and then undefined in the next render
- Both
v4.3.1 - 2022-05-21
Changed
- If using TypeScript, custom
operatorSelectorcomponents will now need to accommodateOptionGroup<NameLabelPair>[]in addition to the normalNameLabelPair[].
Added
- #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 likeautoSelectFieldbut for the operator selector.- The
fieldsandoperatorsproperties of thetranslationsprop object now acceptplaceholderName,placeholderLabel, andplaceholderGroupLabelproperties (documentation). These translatable strings set the default field and operator values and labels whenautoSelectFieldand/orautoSelectOperatorare set tofalse. - Corresponding options were also added to
formatQuery, which will now ignore rules where thefieldoroperatormatch the placeholder values for most export formats.
- The
- #303 Added support for wildcards concatenated to field names in
parseSQL. Examples:- SQL
"lastName LIKE firstName || '%'"would generateRuleTypeobject:{
"field": "lastName",
"operator": "beginsWith",
"value": "firstName",
"valueSource": "field"
} - SQL
"lastName NOT LIKE '%' || firstName || '%'"would generateRuleTypeobject:{
"field": "lastName",
"operator": "doesNotContain",
"value": "firstName",
"valueSource": "field"
}
- SQL
Fixed
- #301
react-querybuilderand the compatibility packages are all built with React v18 now (thepeerDependenciesversion 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
- Added two options to the
translationsprop:fields.placeholderLabelandfields.placeholderGroupLabel. These will be used in place of the default"------"when theautoSelectFieldprop is set tofalse. - All translation properties are now optional.
v4.2.4 - 2022-05-12
Added
- Added a
parseNumbersoption forformatQuery. - Added a
debugModeprop on<QueryBuilder />.
v4.2.3 - 2022-04-05
Added
- Common Expression Language (CEL) export format for
formatQuery.
v4.2.2 - 2022-03-12
Fixed
- This release fixes the "IC" aka "independent combinator" type exports (
RuleGroupTypeIC, etc.).
v4.2.1 - 2022-03-03
Added
- This release adds an
operatorparameter to thecomparatorfunction property of theFieldinterface.
v4.2.0 - 2022-02-02
Changed
- When calling
formatQuerywith the "mongodb" format and a customvalueProcessor, thevalueProcessorfunction 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"}}.
Fixed
- #276 When using
react-querybuilderv4 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-dndbackend (e.g.react-dnd-html5-backend) to be implemented higher up in the component tree. - Previously, the
parseSQLmethod 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,parseSQLwould 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.
Added
- Compare fields to other fields. The default
<ValueEditor />component can now display a filterable list of fields from thefieldsprop given the right configuration.formatQueryandparseSQLhave 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'srulesarrayremove- 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 newidandpath) a rule or group to a new location in the query tree
- Lock buttons: Use the
showLockButtonsprop to enable locking/unlocking (i.e. disabling/enabling) individual rules and groups (demo). - New
valueEditorTypeandinputTypeoptions: 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
fieldsprop 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
controlElementsprop (as well ascontrolClassnamesin the case of Bootstrap). No need to assign each component individually anymore.
v4.1.3 - 2022-01-18
Fixed
- The path to the CommonJS build was wrong in package.json for the main package. This has been fixed.
- The
RuleGroupArraytype (used for therulesproperty ofRuleGroupType) has been simplified to(RuleType | RuleGroupType)[]. This should make it easier to extend and/or narrowRuleGroupType.
v4.1.2 - 2022-01-12
Fixed
parseSQLwas returning conventional rule groups (combinators at the group level) in some situations even when theindependentCombinatorsoption was set totrue. The option will now guarantee a return type ofRuleGroupTypeIC.
Added
- Added
convertQuerymethod to toggle a query between the conventional structure with combinators at the group level (RuleGroupType) and the "independent combinator" structure (RuleGroupTypeIC, used with theindependentCombinatorsprop). For unidirectional conversions,convertToICandconvertFromICare also available. - The specific return type of the
parseSQLmethod (RuleGroupTypeorRuleGroupTypeIC) is now inferred from the parameters.
v4.1.1 - 2022-01-10
Fixed
- Improved recursive types
RuleGroupTypeandRuleGroupTypeICto pass down theR(rule) andC(combinator) generics to therulesarray.
v4.1.0 - 2022-01-09
Fixed
- Minimum TypeScript version has been lowered to 4.1.2, down from 4.5 in
react-querybuilderv4.0.0.
Added
- All
ValueSelector-based components, including field selectors, operator selectors, combinator selectors, and value editors where thetypeis "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
Changed
- Minimum TypeScript version is now 4.5.0.
- The default styles (
query-builder.cssandquery-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. onAddRuleandonAddGroupcallbacks now pass anumber[](parentPath) as the second argument instead of astring(parentId).- The exported method
findRulehas been replaced byfindPath, which is useful in conjunction with the previously mentionedonAddRuleandonAddGroupcallbacks. - 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
lodashdependency. Addedimmerandreact-dnd. RuleandRuleGroupprops now includepath: number[], andidmay be undefined.getLevelhas been removed from theschemaprop (internally we just usepath.lengthnow).- The following functions that are part of the
schemaprop have been refactored to usepathorparentPathinstead ofidorparentId:onGroupAdd,onGroupRemove,onPropChange,onRuleAdd,onRuleRemove.
Fixed
- The default
ValueEditorcomponent was calling theuseEffecthook conditionally, which is way against the Rules of Hooks. It is now called unconditionally. - #258 When the
formatQueryexport format is "mongodb", the resulting string can be parsed byJSON.parse(@mylawacad)
Added
- 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-querybuilderorg 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 aqueryprop, the query will not change until a newqueryis passed in. You should use the parameter of theonQueryChangecallback to update thequeryprop. Typically this involves using React'suseStatehook. To render an uncontrolled component, don't pass aqueryprop. You can set the initial query by using the newdefaultQueryprop, and you can still listen for changes withonQueryChange.- The
query-builder.scssfile 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
enableDragAndDropprop 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
independentCombinatorsprop 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. ifindependentCombinatorsis undefined orfalse, then the<QueryBuilder />should behave basically the same as it did in v3.x. - New
disabledprop to prevent changes to the query. All sub-components and form elements get thedisabledprop as well. Passtrueto disable the entire query, or pass an array of paths to disable specific rules/groups. parseSQLmethod to import queries from SQL (documentation / demo -- click the "Load from SQL" button).formatQueryaccepts a newformattype: "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 correspondingparamPrefixoption is available in order to use a different character than the default ":" within thesqlstring.
Miscellaneous
v4.0.0-beta.* releases
v4.0.0-beta.8 - 2021-12-24
Fixed
- #255 Fix a couple of issues with the "mongodb"
formatQueryexport type (@mylawacad)
Added
- #261
valueProcessorfor "mongodb" export format - #252 Export
RuleGroupcomponent (@ZigZagT) - #250 Bulma compatibility package and demo
- #248
disabledprop
v4.0.0-beta.7 - 2021-12-13
Fixed
- #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.
Added
- If using
react-querybuilderwith NodeJS, and you only want to use theformatQueryfunction, 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
Changed
- Earlier 4.0 beta releases had an
inlineCombinatorsprop. This has been renamed toindependentCombinators. - Dropped
lodashdependency. Addedimmerandreact-dnd. - Styles
- The default styles now use flexbox. This should allow greater flexibility and more consistent styling.
- The
query-builder.scssfile 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.
- Structure
- 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
enableDragAndDropisfalse, or hide it with a rule like.queryBuilder-dragHandle { display: none; }.
- 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
- Behavior
<QueryBuilder />is now a properly controlled or uncontrolled component depending on which props are passed in. If you pass aqueryprop, the query will not change until a newqueryis passed in. You should use the parameter of theonQueryChangecallback to update thequeryprop. Typically this involves using React'suseStatehook. To render an uncontrolled component, don't pass aqueryprop. You can set the initial query by using the newdefaultQueryprop, and you can still listen for changes withonQueryChange.
Added
- #235 Drag-and-drop! Pass the
enableDragAndDropprop 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
Fixed
- v4.0.0-beta.3 had an outdated build
Added
- All props on the
<QueryBuilder />component are now optional
v4.0.0-beta.3 - 2021-11-03
Added
- #231
inlineCombinatorsprop. 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. ifinlineCombinatorsis 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
Added
v4.0.0-beta.1 - 2021-10-23
Changed
- #229 Path-based query management
RuleandRuleGroupprops now includepath: number[], andidmay be undefined.getLevelhas been removed from theschemaprop.- The following functions that are part of the
schemaprop have been refactored to usepathorparentPathinstead ofidorparentId:onGroupAdd,onGroupRemove,onPropChange,onRuleAdd,onRuleRemove. onAddRuleandonAddGroupcallbacks now pass anumber[](parentPath) as the second argument instead of astring(parentId).- The exported method
findRulehas been replaced byfindPath, which is useful in conjunction with the previously mentioned, refactoredonAddRuleandonAddGroupcallbacks. - The
onQueryChangecallback's argument, the current query object, will include apathfor each rule and group. TheformatQuerydefault output format, "json", will also includepaths. - Rule and group
divs now include adata-pathattribute.
Added
formatQueryaccepts a newformattype:"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 optionparamPrefixis available in order to use a different character than the default ":" within thesqlstring.- #228 CodeSandbox CI
v3.12.1 - 2021-10-06
Changed
- The default
ValueEditorwill force the<input />control to havetype="text"if the field'sinputTypeis "number" and theoperatoris "between" or "notBetween". When theoperatorchanges to something else, the control will revert totype="number"and reset thevalueif thevalueincluded a comma (","). - The "parameterized" output of the
formatQueryfunction will now include native numbers and boolean values in theparamsarray if a rule'svalueproperty 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].
Fixed
- Several bugs were squashed in the
formatQueryfunction 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
Changed
- 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.ruleis no longer an immediate child of.ruleGroup. Now use something like.ruleGroup > .ruleGroup-body > .rule. - The
formatQueryfunction 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
operatoris "in" or "notIn" and the value is neither a non-empty string nor an array with at least one element. - The rule's
operatoris "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 === 2and neither element is an empty string).
- Cleaned up some internal stuff and dropped three dependencies! Lodash is now the only external dependency.
Added
- #225 Validation: pass a
validatorprop to validate the entire query, or include avalidatorattribute on each field in thefieldsarray 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
formatQueryfunction has two new validation-related options: (1)validator(same signature as the prop mentioned earlier) and (2)fields(same shape as thefieldsprop). 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
showCloneButtonsprop to enable duplication of rules and groups. AssociatedcontrolElementsproperties are also available for custom clone button components. - #224 Add rule to new groups: pass the
addRuleToNewGroupsprop to add the default rule to all new groups automatically. - #224 Default operator: pass a
getDefaultOperatorfunction prop to determine which operator is set for new rules (or include adefaultOperatorattribute on objects in thefieldsarray to set the default operator for specific fields). - #224 Cancel or modify a new rule/group: use the
onAddRuleandonAddGroupcallbacks to return a new rule/group that will be added instead of the default, or returnfalseto 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
formatQuantityfunction 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
Changed
- Relaxed and corrected types related to
NameLabelPair - Simplified
formatQueryfor MongoDB
v3.11.0 - 2021-08-24
Added
- #218
autoSelectFieldprop. 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
Added
v3.10.0 - 2021-07-27
Added
- New item in the
translationsprop object:notToggle.label - #210 Customizable label for "not" toggle component (@jakeboone02)
v3.9.9 - 2021-03-05
Changed
field,fieldData, andoperatorare now required inValueEditorProps
v3.9.8 - 2021-02-22
Added
- #190 Export default components
ActionElement,NotToggle,ValueEditor, andValueSelector(@jakeboone02)
v3.9.7 - 2021-02-18
Fixed
- #188 Any extra attributes in the
queryprop will be persisted (@jakeboone02)
v3.9.6 - 2021-02-15
Fixed
- Add base CSS to the package
v3.9.5 - 2021-02-08
Fixed
- Updated README.md for npm
v3.9.4 - 2021-02-06
Fixed
- Critical bug with v3.9.3 where React wasn't in scope
v3.9.3 - 2021-02-05
Added
- #179 Added
enableMountQueryChangeprop to allow disabling initialonQueryChangecall (@saurabhnemade)
v3.9.2 - 2021-01-24
Added
- #178 Export several default configuration options (@jakeboone02)
defaultCombinatorsdefaultOperatorsdefaultTranslationsdefaultValueProcessor
v3.9.1 - 2021-01-17
Changed
- #175 Replaced
nanoidwithMath.random()(@jakeboone02)
Fixed
- This release removes the requirement to re-map the
window.msCryptoobject towindow.cryptofor IE11. Woohoo!
v3.9.0 - 2020-12-07
Added
- #171 Add
contextprop to pass arbitrary data to custom components (@jakeboone02)
v3.8.4 - 2020-11-16
Added
- #167
placeholdersupport for text fields (@eddie-xavi)
v3.8.3 - 2020-11-04
Fixed
- Bug with using false as
defaultValue
v3.8.2 - 2020-11-03
Fixed
- #164 Fixed setting of default values (@jakeboone02)
v3.8.1 - 2020-10-23
Fixed
- Gets correct default operator when using field-level config
v3.8.0 - 2020-10-09
Changed
- 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".
Added
- Several options that required the use of functions at the query level can now be configured at the field level:
- Operators: use the
operatorsproperty on a field instead of thegetOperatorsprop - Value editor type: use the
valueEditorTypeproperty on a field instead of thegetValueEditorTypeprop - Input type: use the
inputTypeproperty on a field instead of thegetInputTypeprop - Values: if the value editor type is
selectorradio, use thevaluesproperty on a field instead of thegetValuesprop - Default value: use the
defaultValueproperty on a field instead of thegetDefaultValueprop
- Operators: use the
- #160 Added field-level configuration options (@jakeboone02)
v3.7.1 - 2020-10-07
Fixed
- #158
createRulewas settingnametoundefinedwhen fields are empty (@saurabhnemade)
v3.7.0 - 2020-10-04
Added
- #157
getDefaultFieldandgetDefaultValueprops (@jakeboone02)
Fixed
- Allow nulls to be returned from getOperators and getValueEditorType
v3.6.0 - 2020-10-01
Changed
- #155 Refactored
formatQueryoptions (@jakeboone02)valueProcessoris no longer the third argument offormatQuery. To use a customvalueProcessor, pass an options object as the second parameter and includevalueProcessoras a key in that object.- When the
formatQueryformat 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
Fixed
- Prevent lodash from assigning global
_variable 74ee1ca
v3.5.0 - 2020-06-20
Changed
- #145 Convert source to TypeScript (@jakeboone02)
- #135 Reset
valueonoperatorchange (@artenator)
Added
- Option to reset rule on operator change
- #144 IE11 support (@jakeboone02)
v3.4.0 - 2020-06-15
Added
- #142 Customizable
Rulecomponent (@jakeboone02)
v3.3.0 - 2020-06-12
Added
Changed
- Some TypeScript type names have changed, e.g.
Ruleis nowRuleTypesinceRuleis an exported React component.
v3.2.0 - 2020-05-28
Added
- #139
"parameterized"option forformatQuery(@jakeboone02)
v3.1.2 - 2020-03-19
Added
"json_without_ids"option forformatQuery
v3.1.1 - 2020-02-18
Fixed
- v3.1.0 published files were outdated
v3.1.0 - 2020-02-18
Added
- #122
resetOnFieldChangeprop to controlvalueandoperatorreset functionality onfieldchange (@lakk1)
v3.0.2 - 2019-12-09
Fixed
- v3.0.1 published files were outdated
v3.0.1 - 2019-12-06
Fixed
- #117 Rule default value on add/change (@xxsnakerxx)
v3.0.0 - 2019-11-29
Added
- #115 Add
div.ruleGroup-header(@jakeboone02)- A
divwith classruleGroup-headernow 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
Fixed
- #113 Passing
notproperty to rule groups below root (@RomanLamsal1337)
v2.5.0 - 2019-11-10
Changed
- Lowercase operator labels
Fixed
v2.4.0 - 2019-09-23
Added
- #107
fieldDataprop for customOperatorSelectorandValueEditorcomponents (@jakeboone02)
v2.3.0 - 2019-09-16
Added
- #104 Inversion (
"not") toggle switch for rule groups (@jakeboone02) - #103 Added
leveland ruleidto DOM elements (@srinivasdamam)
Changed
- #102 Replace
uuidwithnanoid(@srinivasdamam)
v2.2.1 - 2019-08-29
Fixed
- TypeScript definitions
v2.2.0 - 2019-08-29
Added
Fixed
- Added missing props to new
ValueEditortypes - Added
titleprop and completedValueEditorprops
v2.1.0 - 2019-08-27
Added
- Enhanced default
ValueEditorto handle multiple input types (#94)
v2.0.1 - 2019-08-27
Added
- #93 Pass in new root to
_notifyQueryChange(@pumbor) - #84 Add
classNameprop toValueEditor, pass it on toinputelement (@kkkrist)
v2.0.0 - 2019-08-18
Changed
- #87 Hooks rewrite and increased test coverage (@jakeboone02)
Fixed
- #82 Removed type restrictions on rule
values (@jakeboone02)
v1.4.3 - 2018-04-08
Fixed
- #60 Fixed TypeScript function parameter definitions (@jakeboone02)
v1.4.2 - 2018-03-02
Added
- #55 Add optional
idinformation in README (@CharlyJazz)
v1.4.1 - 2018-03-02
Added
- #53 Add optional
idproperty tofields(@CharlyJazz)
v1.4.0 - 2017-12-11
Fixed
- #46 Types: Added
idattribute toRuleGroup(@jakeboone02)
Added
- #47 Add
translationsprop to be able to set translatable texts (@bubenkoff) - #44 Add TypeScript typings (@jakeboone02)
- #42 Converted
Rulesubcomponents to SFCs (@jakeboone02)
v1.3.8 - 2017-07-14
Fixed
- #37 package updates and making it compatible with codesandbox.io (@pavanpodila)
v1.3.6 - 2017-03-13
Added
- #28 Add
fieldto operator selector control element (@SamLoy) - #27 Added more context information to
controlElements(@SamLoy)
v1.3.5 - 2017-02-06
Fixed
- #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
Added
v1.3.0 - 2016-10-12
Fixed
- #15 Fix test setup (@maniax89)
- #11 Move 'this' binding to
componentWillMount(@maniax89) - #9 Remove unnecessary imports (@maniax89)
Added
- #13 Rule group tests (@maniax89)
- #12 Add
ActionElementtests to<Rule />(@maniax89) - #10 WIP: Add
<Rule />Tests (@maniax89) - #8 WIP: Added CHANGELOG.md (@maniax89)
- #7 Add in
ActionElementfor custom<button />elements (@maniax89) - #6 Custom rule controls (@maniax89)
v1.2.0 - 2016-07-11
Fixed
v1.1.0 - 2016-06-27
Added
controlClassnamesprop- Documentation update
v1.0.10 - 2016-06-26
Fixed
- Stop event propagation for buttons
- Proper
distpath
v1.0.9 - 2016-06-20
Added
- Documentation update
v1.0.8 - 2016-06-19
Added
- Documentation update
v1.0.7 - 2016-06-19
Added
- Live demo URL to README
v1.0.6 - 2016-06-19
Added
reactandreact-domtodevDependencies
v1.0.5 - 2016-06-19
Fixed
- Documentation update
v1.0.4 - 2016-06-19
Added
- Documentation and demo
v1.0.3 - 2016-06-19
Added
- Include query-builder.scss in
dist
v1.0.2 - 2016-06-19
Added
- "Pending" documentation note
v1.0.1 - 2016-06-19
Changed
- Build artifacts moved from
libtodist
v1.0.0 - 2016-06-19
Added
- Initial publish