@react-querybuilder/core 8.9.2 → 8.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/{arrayUtils-BF1P8iHS.mjs → arrayUtils-A_OXU9W1.mjs} +3 -75
  2. package/dist/arrayUtils-A_OXU9W1.mjs.map +1 -0
  3. package/dist/arrayUtils-QxZOZTf6.js +73 -0
  4. package/dist/arrayUtils-QxZOZTf6.js.map +1 -0
  5. package/dist/basic-DEc65Kng.d.mts +363 -0
  6. package/dist/basic-Dd_M2f3M.d.ts +363 -0
  7. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +806 -1366
  8. package/dist/cjs/react-querybuilder_core.cjs.development.js +455 -116
  9. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  10. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +806 -1366
  11. package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
  12. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
  13. package/dist/{convertQuery-H7RhQiIc.mjs → convertQuery-CqX3rPvj.mjs} +3 -3
  14. package/dist/{convertQuery-H7RhQiIc.mjs.map → convertQuery-CqX3rPvj.mjs.map} +1 -1
  15. package/dist/{export-DyrnTh6K.d.ts → export-Dy4FckB-.d.ts} +7 -6
  16. package/dist/{export-r-V7bU31.d.mts → export-t1V2N8pz.d.mts} +7 -6
  17. package/dist/formatQuery.d.mts +3 -2
  18. package/dist/formatQuery.d.ts +3 -2
  19. package/dist/formatQuery.js +217 -87
  20. package/dist/formatQuery.js.map +1 -1
  21. package/dist/formatQuery.mjs +217 -87
  22. package/dist/formatQuery.mjs.map +1 -1
  23. package/dist/{import-Cksobmln.d.ts → import-Cz8canKo.d.mts} +3 -3
  24. package/dist/{import-BwbbP4oU.d.mts → import-DtS9Ocx5.d.ts} +3 -3
  25. package/dist/{isRuleGroup-CnhYpLOM.mjs → isRuleGroup-CYcfPgbg.mjs} +2 -2
  26. package/dist/{isRuleGroup-CnhYpLOM.mjs.map → isRuleGroup-CYcfPgbg.mjs.map} +1 -1
  27. package/dist/lexer-C53tqS2p.js +406 -0
  28. package/dist/lexer-C53tqS2p.js.map +1 -0
  29. package/dist/{optGroupUtils-CXLgyg2i.js → optGroupUtils-B0hTpodo.js} +114 -1
  30. package/dist/optGroupUtils-B0hTpodo.js.map +1 -0
  31. package/dist/{optGroupUtils-Duv-M8rf.mjs → optGroupUtils-VeZ3k7-1.mjs} +86 -3
  32. package/dist/optGroupUtils-VeZ3k7-1.mjs.map +1 -0
  33. package/dist/parseCEL.d.mts +292 -11
  34. package/dist/parseCEL.d.ts +292 -11
  35. package/dist/parseCEL.js +874 -1125
  36. package/dist/parseCEL.js.map +1 -1
  37. package/dist/parseCEL.mjs +828 -1126
  38. package/dist/parseCEL.mjs.map +1 -1
  39. package/dist/parseJSONata.d.mts +3 -2
  40. package/dist/parseJSONata.d.ts +3 -2
  41. package/dist/parseJSONata.js +49 -77
  42. package/dist/parseJSONata.js.map +1 -1
  43. package/dist/parseJSONata.mjs +4 -5
  44. package/dist/parseJSONata.mjs.map +1 -1
  45. package/dist/parseJsonLogic.d.mts +4 -3
  46. package/dist/parseJsonLogic.d.ts +4 -3
  47. package/dist/parseJsonLogic.js +5 -6
  48. package/dist/parseJsonLogic.js.map +1 -1
  49. package/dist/parseJsonLogic.mjs +5 -6
  50. package/dist/parseJsonLogic.mjs.map +1 -1
  51. package/dist/parseMongoDB.d.mts +3 -2
  52. package/dist/parseMongoDB.d.ts +3 -2
  53. package/dist/parseMongoDB.js +15 -16
  54. package/dist/parseMongoDB.js.map +1 -1
  55. package/dist/parseMongoDB.mjs +5 -6
  56. package/dist/parseMongoDB.mjs.map +1 -1
  57. package/dist/{parseNumber-BtGKa58z.mjs → parseNumber-CXdMVNFx.mjs} +2 -2
  58. package/dist/{parseNumber-BtGKa58z.mjs.map → parseNumber-CXdMVNFx.mjs.map} +1 -1
  59. package/dist/{parseNumber-Bcys1kOH.js → parseNumber-D4iQDxK-.js} +1 -1
  60. package/dist/{parseNumber-Bcys1kOH.js.map → parseNumber-D4iQDxK-.js.map} +1 -1
  61. package/dist/parseSQL.d.mts +3 -2
  62. package/dist/parseSQL.d.ts +3 -2
  63. package/dist/parseSQL.js +2691 -3036
  64. package/dist/parseSQL.js.map +1 -1
  65. package/dist/parseSQL.mjs +2691 -3037
  66. package/dist/parseSQL.mjs.map +1 -1
  67. package/dist/parseSpEL.d.mts +3 -2
  68. package/dist/parseSpEL.d.ts +3 -2
  69. package/dist/parseSpEL.js +7 -9
  70. package/dist/parseSpEL.js.map +1 -1
  71. package/dist/parseSpEL.mjs +5 -6
  72. package/dist/parseSpEL.mjs.map +1 -1
  73. package/dist/{prepareQueryObjects-BqFEs4eV.js → prepareQueryObjects-BOUWfel5.js} +4 -5
  74. package/dist/prepareQueryObjects-BOUWfel5.js.map +1 -0
  75. package/dist/{prepareQueryObjects-CS6Wmhmf.mjs → prepareQueryObjects-DPCC-iHp.mjs} +6 -7
  76. package/dist/prepareQueryObjects-DPCC-iHp.mjs.map +1 -0
  77. package/dist/query-builder-layout.css +1 -1
  78. package/dist/query-builder-layout.css.map +1 -1
  79. package/dist/query-builder.css +1 -1
  80. package/dist/query-builder.css.map +1 -1
  81. package/dist/react-querybuilder_core.d.mts +806 -1366
  82. package/dist/react-querybuilder_core.legacy-esm.d.ts +806 -1366
  83. package/dist/react-querybuilder_core.legacy-esm.js +455 -114
  84. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  85. package/dist/react-querybuilder_core.mjs +448 -117
  86. package/dist/react-querybuilder_core.mjs.map +1 -1
  87. package/dist/react-querybuilder_core.production.d.mts +806 -1366
  88. package/dist/react-querybuilder_core.production.mjs +1 -1
  89. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  90. package/dist/styles/_layout.scss +61 -17
  91. package/dist/styles/_main.scss +22 -4
  92. package/dist/{transformQuery-FL_nlpp5.js → transformQuery-CWDPogO5.js} +1 -1
  93. package/dist/{transformQuery-FL_nlpp5.js.map → transformQuery-CWDPogO5.js.map} +1 -1
  94. package/dist/{transformQuery-DdMvmrCh.mjs → transformQuery-DCCpjtyq.mjs} +3 -3
  95. package/dist/{transformQuery-DdMvmrCh.mjs.map → transformQuery-DCCpjtyq.mjs.map} +1 -1
  96. package/dist/transformQuery.d.mts +1 -1
  97. package/dist/transformQuery.d.ts +1 -1
  98. package/dist/transformQuery.js +1 -1
  99. package/dist/transformQuery.mjs +2 -2
  100. package/package.json +14 -12
  101. package/dist/arrayUtils-BF1P8iHS.mjs.map +0 -1
  102. package/dist/arrayUtils-D5EoIsKP.js +0 -164
  103. package/dist/arrayUtils-D5EoIsKP.js.map +0 -1
  104. package/dist/basic-BfD-7CN3.d.mts +0 -1235
  105. package/dist/basic-C8xXKHIA.d.ts +0 -1235
  106. package/dist/objectUtils-BBZSfZJz.js +0 -17
  107. package/dist/objectUtils-BBZSfZJz.js.map +0 -1
  108. package/dist/objectUtils-BtWdcZVG.mjs +0 -11
  109. package/dist/objectUtils-BtWdcZVG.mjs.map +0 -1
  110. package/dist/optGroupUtils-CXLgyg2i.js.map +0 -1
  111. package/dist/optGroupUtils-Duv-M8rf.mjs.map +0 -1
  112. package/dist/prepareQueryObjects-BqFEs4eV.js.map +0 -1
  113. package/dist/prepareQueryObjects-CS6Wmhmf.mjs.map +0 -1
@@ -90,6 +90,108 @@ const defaultPlaceholderValueLabel = defaultPlaceholderLabel;
90
90
  */
91
91
  const defaultPlaceholderValueGroupLabel = defaultPlaceholderLabel;
92
92
  /**
93
+ * Default configuration of translatable strings.
94
+ *
95
+ * @group Defaults
96
+ */
97
+ const defaultTranslations = {
98
+ fields: {
99
+ title: "Field",
100
+ placeholderName: defaultPlaceholderFieldName,
101
+ placeholderLabel: defaultPlaceholderFieldLabel,
102
+ placeholderGroupLabel: defaultPlaceholderFieldGroupLabel
103
+ },
104
+ operators: {
105
+ title: "Operator",
106
+ placeholderName: defaultPlaceholderOperatorName,
107
+ placeholderLabel: defaultPlaceholderOperatorLabel,
108
+ placeholderGroupLabel: defaultPlaceholderOperatorGroupLabel
109
+ },
110
+ values: {
111
+ title: "Values",
112
+ placeholderName: defaultPlaceholderValueName,
113
+ placeholderLabel: defaultPlaceholderValueLabel,
114
+ placeholderGroupLabel: defaultPlaceholderValueGroupLabel
115
+ },
116
+ matchMode: { title: "Match mode" },
117
+ matchThreshold: { title: "Match threshold" },
118
+ value: { title: "Value" },
119
+ removeRule: {
120
+ label: "⨯",
121
+ title: "Remove rule"
122
+ },
123
+ removeGroup: {
124
+ label: "⨯",
125
+ title: "Remove group"
126
+ },
127
+ addRule: {
128
+ label: "+ Rule",
129
+ title: "Add rule"
130
+ },
131
+ addGroup: {
132
+ label: "+ Group",
133
+ title: "Add group"
134
+ },
135
+ combinators: { title: "Combinator" },
136
+ notToggle: {
137
+ label: "Not",
138
+ title: "Invert this group"
139
+ },
140
+ cloneRule: {
141
+ label: "⧉",
142
+ title: "Clone rule"
143
+ },
144
+ cloneRuleGroup: {
145
+ label: "⧉",
146
+ title: "Clone group"
147
+ },
148
+ shiftActionUp: {
149
+ label: "˄",
150
+ title: "Shift up"
151
+ },
152
+ shiftActionDown: {
153
+ label: "˅",
154
+ title: "Shift down"
155
+ },
156
+ dragHandle: {
157
+ label: "⁞⁞",
158
+ title: "Drag handle"
159
+ },
160
+ lockRule: {
161
+ label: "🔓",
162
+ title: "Lock rule"
163
+ },
164
+ lockGroup: {
165
+ label: "🔓",
166
+ title: "Lock group"
167
+ },
168
+ lockRuleDisabled: {
169
+ label: "🔒",
170
+ title: "Unlock rule"
171
+ },
172
+ lockGroupDisabled: {
173
+ label: "🔒",
174
+ title: "Unlock group"
175
+ },
176
+ muteRule: {
177
+ label: "🔊",
178
+ title: "Mute rule"
179
+ },
180
+ muteGroup: {
181
+ label: "🔊",
182
+ title: "Mute group"
183
+ },
184
+ unmuteRule: {
185
+ label: "🔇",
186
+ title: "Unmute rule"
187
+ },
188
+ unmuteGroup: {
189
+ label: "🔇",
190
+ title: "Unmute group"
191
+ },
192
+ valueSourceSelector: { title: "Value source" }
193
+ };
194
+ /**
93
195
  * Default character used to `.join` and `.split` arrays.
94
196
  *
95
197
  * @group Defaults
@@ -338,8 +440,11 @@ const standardClassnames = {
338
440
  dndDropNotAllowed: "dndDropNotAllowed",
339
441
  dragHandle: "queryBuilder-dragHandle",
340
442
  disabled: "queryBuilder-disabled",
443
+ muted: "queryBuilder-muted",
341
444
  lockRule: "rule-lock",
342
445
  lockGroup: "ruleGroup-lock",
446
+ muteRule: "rule-mute",
447
+ muteGroup: "ruleGroup-mute",
343
448
  valueSource: "rule-valueSource",
344
449
  valueListItem: "rule-value-list-item",
345
450
  branches: "queryBuilder-branches",
@@ -374,6 +479,9 @@ const defaultControlClassnames = {
374
479
  dragHandle: "",
375
480
  lockRule: "",
376
481
  lockGroup: "",
482
+ muteRule: "",
483
+ muteGroup: "",
484
+ muted: "",
377
485
  valueSource: "",
378
486
  actionElement: "",
379
487
  valueSelector: "",
@@ -424,6 +532,8 @@ const TestID = {
424
532
  dragHandle: "drag-handle",
425
533
  lockRule: "lock-rule",
426
534
  lockGroup: "lock-group",
535
+ muteRule: "mute-rule",
536
+ muteGroup: "mute-group",
427
537
  valueSourceSelector: "value-source-selector",
428
538
  matchModeEditor: "match-mode-editor"
429
539
  };
@@ -450,6 +560,31 @@ const LogType = {
450
560
  * @group Defaults
451
561
  */
452
562
  const rootPath = [];
563
+ /**
564
+ * Default values for all `boolean`
565
+ * {@link react-querybuilder!QueryBuilder QueryBuilder} options.
566
+ *
567
+ * @group Defaults
568
+ */
569
+ const queryBuilderFlagDefaults = {
570
+ addRuleToNewGroups: false,
571
+ autoSelectField: true,
572
+ autoSelectOperator: true,
573
+ autoSelectValue: false,
574
+ debugMode: false,
575
+ enableDragAndDrop: false,
576
+ enableMountQueryChange: true,
577
+ listsAsArrays: false,
578
+ resetOnFieldChange: true,
579
+ resetOnOperatorChange: false,
580
+ showCloneButtons: false,
581
+ showCombinatorsBetweenRules: false,
582
+ showLockButtons: false,
583
+ showMuteButtons: false,
584
+ showNotToggle: false,
585
+ showShiftActions: false,
586
+ suppressStandardClassnames: false
587
+ };
453
588
 
454
589
  //#endregion
455
590
  //#region src/utils/arrayUtils.ts
@@ -658,7 +793,7 @@ function convertQuery(query) {
658
793
  //#endregion
659
794
  //#region src/utils/defaultValidator.ts
660
795
  /**
661
- * This is an example validation function you can pass to {@link QueryBuilder} in the
796
+ * This is an example validation function you can pass to {@link react-querybuilder!QueryBuilder QueryBuilder} in the
662
797
  * `validator` prop. It assumes that you want to validate groups, and has a no-op
663
798
  * for validating rules which you can replace with your own implementation.
664
799
  */
@@ -692,6 +827,21 @@ const defaultValidator = (query) => {
692
827
  return result;
693
828
  };
694
829
 
830
+ //#endregion
831
+ //#region src/utils/objectUtils.ts
832
+ /**
833
+ * A strongly-typed version of `Object.keys()`.
834
+ *
835
+ * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
836
+ */
837
+ const objectKeys = Object.keys;
838
+ /**
839
+ * A strongly-typed version of `Object.entries()`.
840
+ *
841
+ * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)
842
+ */
843
+ const objectEntries = Object.entries;
844
+
695
845
  //#endregion
696
846
  //#region src/utils/optGroupUtils.ts
697
847
  const isOptionWithName = (opt) => isPojo(opt) && "name" in opt && typeof opt.name === "string";
@@ -868,6 +1018,42 @@ const uniqOptList = (originalArray) => {
868
1018
  if (isFlexibleOptionGroupArray(originalArray)) return uniqOptGroups(originalArray);
869
1019
  return uniqByIdentifier(originalArray.map((o) => toFullOption(o)));
870
1020
  };
1021
+ const prepareOptionList = (props) => {
1022
+ // istanbul ignore next
1023
+ const { optionList: optionListPropOriginal, baseOption = {}, labelMap = {}, placeholder: { placeholderName = defaultPlaceholderName, placeholderLabel = defaultPlaceholderLabel, placeholderGroupLabel = defaultPlaceholderLabel } = {}, autoSelectOption = true } = props;
1024
+ const defaultOption = {
1025
+ id: placeholderName,
1026
+ name: placeholderName,
1027
+ value: placeholderName,
1028
+ label: placeholderLabel
1029
+ };
1030
+ const optionsProp = optionListPropOriginal ?? [defaultOption];
1031
+ let optionList = [];
1032
+ const opts = Array.isArray(optionsProp) ? toFullOptionList(optionsProp, baseOption, labelMap) : objectKeys(toFullOptionMap(optionsProp, baseOption)).map((opt) => ({
1033
+ ...optionsProp[opt],
1034
+ name: opt,
1035
+ value: opt
1036
+ })).sort((a, b) => a.label.localeCompare(b.label));
1037
+ if (isFlexibleOptionGroupArray(opts)) optionList = autoSelectOption ? uniqOptGroups(opts) : uniqOptGroups([{
1038
+ label: placeholderGroupLabel,
1039
+ options: [defaultOption]
1040
+ }, ...opts]);
1041
+ else optionList = autoSelectOption ? uniqByIdentifier(opts) : uniqByIdentifier([defaultOption, ...opts]);
1042
+ let optionsMap = {};
1043
+ if (!Array.isArray(optionsProp)) {
1044
+ const op = toFullOptionMap(optionsProp, baseOption);
1045
+ optionsMap = autoSelectOption ? op : {
1046
+ ...op,
1047
+ [placeholderName]: defaultOption
1048
+ };
1049
+ } else if (isFlexibleOptionGroupArray(optionList)) for (const og of optionList) for (const opt of og.options) optionsMap[opt.value ?? opt.name] = toFullOption(opt, baseOption);
1050
+ else for (const opt of optionList) optionsMap[opt.value ?? opt.name] = toFullOption(opt, baseOption);
1051
+ return {
1052
+ defaultOption,
1053
+ optionList,
1054
+ optionsMap
1055
+ };
1056
+ };
871
1057
 
872
1058
  //#endregion
873
1059
  //#region src/utils/filterFieldsByComparator.ts
@@ -969,9 +1155,11 @@ function transformQuery(query, options = {}) {
969
1155
  const isValidationResult = (vr) => isPojo(vr) && typeof vr.valid === "boolean";
970
1156
  /**
971
1157
  * Determines if a rule or group is valid based on a validation result (if defined)
972
- * or a validator function. Returns `true` if neither are defined.
1158
+ * or a validator function. Returns `true` if neither are defined and the `muted`
1159
+ * property is not `true`.
973
1160
  */
974
1161
  const isRuleOrGroupValid = (rg, validationResult, validator) => {
1162
+ if (rg.muted) return false;
975
1163
  if (typeof validationResult === "boolean") return validationResult;
976
1164
  if (isValidationResult(validationResult)) return validationResult.valid;
977
1165
  if (typeof validator === "function" && !isRuleGroup(rg)) {
@@ -1245,19 +1433,45 @@ const defaultRuleGroupProcessorCEL = (ruleGroup, options) => {
1245
1433
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1246
1434
  const processRuleGroup = (rg, outermost) => {
1247
1435
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermost ? fallbackExpression : "";
1248
- const expression = rg.rules.map((rule) => {
1249
- if (typeof rule === "string") return celCombinatorMap[rule];
1250
- if (isRuleGroup(rule)) return processRuleGroup(rule);
1436
+ const processedRules = [];
1437
+ let precedingCombinator = "";
1438
+ let firstRule = true;
1439
+ for (const rule of rg.rules) {
1440
+ if (typeof rule === "string") {
1441
+ precedingCombinator = celCombinatorMap[rule];
1442
+ continue;
1443
+ }
1444
+ if (isRuleGroup(rule)) {
1445
+ const processedGroup = processRuleGroup(rule);
1446
+ if (processedGroup) {
1447
+ if (!firstRule && precedingCombinator) {
1448
+ processedRules.push(precedingCombinator);
1449
+ precedingCombinator = "";
1450
+ }
1451
+ firstRule = false;
1452
+ processedRules.push(processedGroup);
1453
+ }
1454
+ continue;
1455
+ }
1251
1456
  const [validationResult, fieldValidator] = validateRule(rule);
1252
- if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return "";
1457
+ if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
1253
1458
  const fieldData = getOption(fields, rule.field);
1254
- return ruleProcessor(rule, {
1459
+ const processedRule = ruleProcessor(rule, {
1255
1460
  ...options,
1256
1461
  parseNumbers: getParseNumberBoolean(fieldData?.inputType),
1257
1462
  escapeQuotes: (rule.valueSource ?? "value") === "value",
1258
1463
  fieldData
1259
1464
  });
1260
- }).filter(Boolean).join(isRuleGroupType(rg) ? ` ${celCombinatorMap[rg.combinator]} ` : " ");
1465
+ if (processedRule) {
1466
+ if (!firstRule && precedingCombinator) {
1467
+ processedRules.push(precedingCombinator);
1468
+ precedingCombinator = "";
1469
+ }
1470
+ firstRule = false;
1471
+ processedRules.push(processedRule);
1472
+ }
1473
+ }
1474
+ const expression = processedRules.join(isRuleGroupType(rg) ? ` ${celCombinatorMap[rg.combinator]} ` : " ");
1261
1475
  const [prefix, suffix] = rg.not || !outermost ? [`${rg.not ? "!" : ""}(`, ")"] : ["", ""];
1262
1476
  return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
1263
1477
  };
@@ -1284,11 +1498,10 @@ const defaultRuleProcessorCEL = (rule, opts = {}) => {
1284
1498
  else if (matchEval) {
1285
1499
  const { mode, threshold } = matchEval;
1286
1500
  const arrayElementAlias = "elem_alias";
1287
- const celQuery = transformQuery(rule.value, { ruleProcessor: (r) => ({
1501
+ const nestedArrayFilter = defaultRuleGroupProcessorCEL(transformQuery(rule.value, { ruleProcessor: (r) => ({
1288
1502
  ...r,
1289
1503
  field: `${arrayElementAlias}${r.field ? `.${r.field}` : ""}`
1290
- }) });
1291
- const nestedArrayFilter = defaultRuleGroupProcessorCEL(celQuery, opts);
1504
+ }) }), opts);
1292
1505
  switch (mode) {
1293
1506
  case "all": return `${field}.all(${arrayElementAlias}, ${nestedArrayFilter})`;
1294
1507
  case "none":
@@ -1322,8 +1535,7 @@ const defaultRuleProcessorCEL = (rule, opts = {}) => {
1322
1535
  case "in":
1323
1536
  case "notin": {
1324
1537
  const [prefix, suffix] = shouldNegate$2(operatorTL) ? ["!(", ")"] : ["", ""];
1325
- const valueAsArray = toArray(value);
1326
- return `${prefix}${field} in [${valueAsArray.map((val) => valueIsField || shouldRenderAsNumber(val, parseNumbers) ? `${trimIfString(val)}` : `"${escapeDoubleQuotes(val, escapeQuotes)}"`).join(", ")}]${suffix}`;
1538
+ return `${prefix}${field} in [${toArray(value).map((val) => valueIsField || shouldRenderAsNumber(val, parseNumbers) ? `${trimIfString(val)}` : `"${escapeDoubleQuotes(val, escapeQuotes)}"`).join(", ")}]${suffix}`;
1327
1539
  }
1328
1540
  case "between":
1329
1541
  case "notbetween": {
@@ -1543,19 +1755,45 @@ const defaultRuleGroupProcessorSpEL = (ruleGroup, options) => {
1543
1755
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1544
1756
  const processRuleGroup = (rg, outermost) => {
1545
1757
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermost ? fallbackExpression : "";
1546
- const expression = rg.rules.map((rule) => {
1547
- if (typeof rule === "string") return rule;
1548
- if (isRuleGroup(rule)) return processRuleGroup(rule);
1758
+ const processedRules = [];
1759
+ let precedingCombinator = "";
1760
+ let firstRule = true;
1761
+ for (const rule of rg.rules) {
1762
+ if (typeof rule === "string") {
1763
+ precedingCombinator = rule;
1764
+ continue;
1765
+ }
1766
+ if (isRuleGroup(rule)) {
1767
+ const processedGroup = processRuleGroup(rule);
1768
+ if (processedGroup) {
1769
+ if (!firstRule && precedingCombinator) {
1770
+ processedRules.push(precedingCombinator);
1771
+ precedingCombinator = "";
1772
+ }
1773
+ firstRule = false;
1774
+ processedRules.push(processedGroup);
1775
+ }
1776
+ continue;
1777
+ }
1549
1778
  const [validationResult, fieldValidator] = validateRule(rule);
1550
- if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return "";
1779
+ if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
1551
1780
  const fieldData = getOption(fields, rule.field);
1552
- return ruleProcessor(rule, {
1781
+ const processedRule = ruleProcessor(rule, {
1553
1782
  ...options,
1554
1783
  parseNumbers: getParseNumberBoolean(fieldData?.inputType),
1555
1784
  escapeQuotes: (rule.valueSource ?? "value") === "value",
1556
1785
  fieldData
1557
1786
  });
1558
- }).filter(Boolean).join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ");
1787
+ if (processedRule) {
1788
+ if (!firstRule && precedingCombinator) {
1789
+ processedRules.push(precedingCombinator);
1790
+ precedingCombinator = "";
1791
+ }
1792
+ firstRule = false;
1793
+ processedRules.push(processedRule);
1794
+ }
1795
+ }
1796
+ const expression = processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ");
1559
1797
  const [prefix, suffix] = rg.not || !outermost ? [`${rg.not ? "!" : ""}(`, ")"] : ["", ""];
1560
1798
  return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
1561
1799
  };
@@ -1611,15 +1849,9 @@ const defaultRuleProcessorSpEL = (rule, opts = {}) => {
1611
1849
  case "contains":
1612
1850
  case "doesnotcontain": return wrapInNegation(`${field} matches ${valueIsField || useBareValue ? trimIfString(value) : `'${escapeSingleQuotes(value, escapeQuotes)}'`}`, shouldNegate$1(operatorTL));
1613
1851
  case "beginswith":
1614
- case "doesnotbeginwith": {
1615
- const valueTL = valueIsField ? `'^'.concat(${trimIfString(value)})` : `'${typeof value === "string" && !value.startsWith("^") || useBareValue ? "^" : ""}${escapeSingleQuotes(value, escapeQuotes)}'`;
1616
- return wrapInNegation(`${field} matches ${valueTL}`, shouldNegate$1(operatorTL));
1617
- }
1852
+ case "doesnotbeginwith": return wrapInNegation(`${field} matches ${valueIsField ? `'^'.concat(${trimIfString(value)})` : `'${typeof value === "string" && !value.startsWith("^") || useBareValue ? "^" : ""}${escapeSingleQuotes(value, escapeQuotes)}'`}`, shouldNegate$1(operatorTL));
1618
1853
  case "endswith":
1619
- case "doesnotendwith": {
1620
- const valueTL = valueIsField ? `${trimIfString(value)}.concat('$')` : `'${escapeSingleQuotes(value, escapeQuotes)}${typeof value === "string" && !value.endsWith("$") || useBareValue ? "$" : ""}'`;
1621
- return wrapInNegation(`${field} matches ${valueTL}`, shouldNegate$1(operatorTL));
1622
- }
1854
+ case "doesnotendwith": return wrapInNegation(`${field} matches ${valueIsField ? `${trimIfString(value)}.concat('$')` : `'${escapeSingleQuotes(value, escapeQuotes)}${typeof value === "string" && !value.endsWith("$") || useBareValue ? "$" : ""}'`}`, shouldNegate$1(operatorTL));
1623
1855
  case "null": return `${field} == null`;
1624
1856
  case "notnull": return `${field} != null`;
1625
1857
  case "in":
@@ -1732,11 +1964,10 @@ const defaultRuleProcessorDrizzle = (rule, _options) => {
1732
1964
  if (opts.preset !== "postgresql") return;
1733
1965
  const { mode, threshold } = matchEval;
1734
1966
  const arrayElementAlias = "elem_alias";
1735
- const sqlQuery = transformQuery(rule.value, { ruleProcessor: (r) => ({
1967
+ const nestedArrayFilter = defaultRuleGroupProcessorDrizzle(transformQuery(rule.value, { ruleProcessor: (r) => ({
1736
1968
  ...r,
1737
1969
  field: arrayElementAlias
1738
- }) });
1739
- const nestedArrayFilter = defaultRuleGroupProcessorDrizzle(sqlQuery, {
1970
+ }) }), {
1740
1971
  ...opts,
1741
1972
  context: {
1742
1973
  ...opts.context,
@@ -1822,7 +2053,6 @@ const defaultRuleGroupProcessorDrizzle = (ruleGroup, options, _meta) => (columns
1822
2053
  const { fields, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, validateRule, validationMap } = options;
1823
2054
  if (!columns || !drizzleOperators) return;
1824
2055
  const { and, not, or } = drizzleOperators;
1825
- const query = isRuleGroupType(ruleGroup) ? ruleGroup : convertFromIC(ruleGroup);
1826
2056
  const ruleProcessor = defaultRuleProcessorDrizzle;
1827
2057
  const processRuleGroup = (rg, _outermost) => {
1828
2058
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return;
@@ -1846,7 +2076,7 @@ const defaultRuleGroupProcessorDrizzle = (ruleGroup, options, _meta) => (columns
1846
2076
  const ruleGroupSQL = rg.combinator === "or" ? or(...processedRules) : and(...processedRules);
1847
2077
  return rg.not ? not(ruleGroupSQL) : ruleGroupSQL;
1848
2078
  };
1849
- return processRuleGroup(query, true);
2079
+ return processRuleGroup(convertFromIC(ruleGroup), true);
1850
2080
  };
1851
2081
 
1852
2082
  //#endregion
@@ -1858,7 +2088,6 @@ const defaultRuleGroupProcessorDrizzle = (ruleGroup, options, _meta) => (columns
1858
2088
  */
1859
2089
  const defaultRuleGroupProcessorElasticSearch = (ruleGroup, options) => {
1860
2090
  const { fields, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1861
- const query = convertFromIC(ruleGroup);
1862
2091
  const processRuleGroup = (rg) => {
1863
2092
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return false;
1864
2093
  const processedRules = rg.rules.map((rule) => {
@@ -1875,7 +2104,7 @@ const defaultRuleGroupProcessorElasticSearch = (ruleGroup, options) => {
1875
2104
  if (processedRules.length === 0) return false;
1876
2105
  return { bool: rg.not ? { must_not: /^or$/i.test(rg.combinator) ? { bool: { should: processedRules } } : processedRules } : { [/^or$/i.test(rg.combinator) ? "should" : "must"]: processedRules } };
1877
2106
  };
1878
- const processedRuleGroup = processRuleGroup(query);
2107
+ const processedRuleGroup = processRuleGroup(convertFromIC(ruleGroup));
1879
2108
  return processedRuleGroup === false ? {} : processedRuleGroup;
1880
2109
  };
1881
2110
 
@@ -1890,19 +2119,45 @@ const defaultRuleGroupProcessorJSONata = (ruleGroup, options) => {
1890
2119
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1891
2120
  const processRuleGroup = (rg, outermost) => {
1892
2121
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermost ? fallbackExpression : "";
1893
- const expression = rg.rules.map((rule) => {
1894
- if (typeof rule === "string") return rule;
1895
- if (isRuleGroup(rule)) return processRuleGroup(rule);
2122
+ const processedRules = [];
2123
+ let precedingCombinator = "";
2124
+ let firstRule = true;
2125
+ for (const rule of rg.rules) {
2126
+ if (typeof rule === "string") {
2127
+ precedingCombinator = rule;
2128
+ continue;
2129
+ }
2130
+ if (isRuleGroup(rule)) {
2131
+ const processedGroup = processRuleGroup(rule);
2132
+ if (processedGroup) {
2133
+ if (!firstRule && precedingCombinator) {
2134
+ processedRules.push(precedingCombinator);
2135
+ precedingCombinator = "";
2136
+ }
2137
+ firstRule = false;
2138
+ processedRules.push(processedGroup);
2139
+ }
2140
+ continue;
2141
+ }
1896
2142
  const [validationResult, fieldValidator] = validateRule(rule);
1897
- if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return "";
2143
+ if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
1898
2144
  const fieldData = getOption(fields, rule.field);
1899
- return ruleProcessor(rule, {
2145
+ const processedRule = ruleProcessor(rule, {
1900
2146
  ...options,
1901
2147
  parseNumbers: getParseNumberBoolean(fieldData?.inputType),
1902
2148
  escapeQuotes: (rule.valueSource ?? "value") === "value",
1903
2149
  fieldData
1904
2150
  });
1905
- }).filter(Boolean).join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ");
2151
+ if (processedRule) {
2152
+ if (!firstRule && precedingCombinator) {
2153
+ processedRules.push(precedingCombinator);
2154
+ precedingCombinator = "";
2155
+ }
2156
+ firstRule = false;
2157
+ processedRules.push(processedRule);
2158
+ }
2159
+ }
2160
+ const expression = processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ");
1906
2161
  const [prefix, suffix] = rg.not || !outermost ? [`${rg.not ? "$not" : ""}(`, ")"] : ["", ""];
1907
2162
  return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
1908
2163
  };
@@ -1948,7 +2203,6 @@ const defaultRuleGroupProcessorJsonLogic = (ruleGroup, options) => {
1948
2203
  */
1949
2204
  const defaultRuleGroupProcessorLDAP = (ruleGroup, options) => {
1950
2205
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1951
- const query = convertFromIC(ruleGroup);
1952
2206
  const processRuleGroup = (rg, outermost) => {
1953
2207
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermost ? fallbackExpression : "";
1954
2208
  const rules = rg.rules.map((rule) => {
@@ -1968,7 +2222,7 @@ const defaultRuleGroupProcessorLDAP = (ruleGroup, options) => {
1968
2222
  const [prefix, suffix] = rules.length > 1 ? [`${notPrefix}(${rg.combinator === "or" ? "|" : "&"}`, `)${notSuffix}`] : [notPrefix, notSuffix];
1969
2223
  return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
1970
2224
  };
1971
- return processRuleGroup(query, true);
2225
+ return processRuleGroup(convertFromIC(ruleGroup), true);
1972
2226
  };
1973
2227
 
1974
2228
  //#endregion
@@ -2023,20 +2277,46 @@ const defaultRuleGroupProcessorNL = (ruleGroup, options) => {
2023
2277
  const processRuleGroup = (rg, outermostOrLonelyInGroup) => {
2024
2278
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
2025
2279
  const rg2 = isRuleGroupTypeIC(rg) && rg.rules.some((r) => typeof r === "string" && lc(r) === "xor") ? convertFromIC(rg) : rg;
2026
- const processedRules = rg2.rules.map((rule) => {
2027
- if (typeof rule === "string") return `, ${translations[rule] ?? rule} `;
2028
- if (isRuleGroup(rule)) return processRuleGroup(rule, rg2.rules.length === 1 && !(rg2.not || /^xor$/i.test(rg2.combinator ?? "")));
2280
+ const processedRules = [];
2281
+ let precedingCombinator = "";
2282
+ let firstRule = true;
2283
+ for (const rule of rg2.rules) {
2284
+ if (typeof rule === "string") {
2285
+ precedingCombinator = `, ${translations[rule] ?? rule} `;
2286
+ continue;
2287
+ }
2288
+ if (isRuleGroup(rule)) {
2289
+ const processedGroup = processRuleGroup(rule, rg2.rules.length === 1 && !(rg2.not || /^xor$/i.test(rg2.combinator ?? "")));
2290
+ // istanbul ignore else
2291
+ if (processedGroup) {
2292
+ if (!firstRule && precedingCombinator) {
2293
+ processedRules.push(precedingCombinator);
2294
+ precedingCombinator = "";
2295
+ }
2296
+ firstRule = false;
2297
+ processedRules.push(processedGroup);
2298
+ }
2299
+ continue;
2300
+ }
2029
2301
  const [validationResult, fieldValidator] = validateRule(rule);
2030
- if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return "";
2302
+ if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
2031
2303
  const escapeQuotes = (rule.valueSource ?? "value") === "value";
2032
2304
  const fieldData = getOption(fields, rule.field);
2033
- return ruleProcessor(rule, {
2305
+ const processedRule = ruleProcessor(rule, {
2034
2306
  ...options,
2035
2307
  parseNumbers: getParseNumberBoolean(fieldData?.inputType),
2036
2308
  escapeQuotes,
2037
2309
  fieldData
2038
2310
  });
2039
- });
2311
+ if (processedRule) {
2312
+ if (!firstRule && precedingCombinator) {
2313
+ processedRules.push(precedingCombinator);
2314
+ precedingCombinator = "";
2315
+ }
2316
+ firstRule = false;
2317
+ processedRules.push(processedRule);
2318
+ }
2319
+ }
2040
2320
  if (processedRules.length === 0) return fallbackExpression;
2041
2321
  const isXOR = lc(rg2.combinator ?? "") === "xor";
2042
2322
  const combinator = isXOR ? rg2.combinator.slice(1) : rg2.combinator;
@@ -2044,7 +2324,7 @@ const defaultRuleGroupProcessorNL = (ruleGroup, options) => {
2044
2324
  const [prefixTL, suffixTL] = ["groupPrefix", "groupSuffix"].map((key) => rg2.not ? isXOR ? getNLTranslataion(key, translations, ["not", "xor"]) : getNLTranslataion(key, translations, ["not"]) : isXOR ? getNLTranslataion(key, translations, ["xor"]) : getNLTranslataion(key, translations));
2045
2325
  const prefix = mustWrap ? `${prefixTL} (`.trim() : "";
2046
2326
  const suffix = mustWrap ? `) ${suffixTL}`.trim() : "";
2047
- return `${prefix}${processedRules.filter(Boolean).join(isRuleGroupType(rg2) ? `, ${translations[combinator] ?? combinator} ` : "")}${suffix}`;
2327
+ return `${prefix}${processedRules.join(isRuleGroupType(rg2) ? `, ${translations[combinator] ?? combinator} ` : "")}${suffix}`;
2048
2328
  };
2049
2329
  return processRuleGroup(ruleGroup, true);
2050
2330
  };
@@ -2094,11 +2374,37 @@ const defaultRuleGroupProcessorParameterized = (ruleGroup, options) => {
2094
2374
  };
2095
2375
  const processRuleGroup = (rg, outermostOrLonelyInGroup) => {
2096
2376
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
2097
- const processedRules = rg.rules.map((rule) => {
2098
- if (typeof rule === "string") return rule;
2099
- if (isRuleGroup(rule)) return processRuleGroup(rule, rg.rules.length === 1);
2100
- return processRule(rule);
2101
- }).filter(Boolean);
2377
+ const processedRules = [];
2378
+ let precedingCombinator = "";
2379
+ let firstRule = true;
2380
+ for (const rule of rg.rules) {
2381
+ if (typeof rule === "string") {
2382
+ precedingCombinator = rule;
2383
+ continue;
2384
+ }
2385
+ if (isRuleGroup(rule)) {
2386
+ const processedGroup = processRuleGroup(rule, rg.rules.length === 1);
2387
+ // istanbul ignore else
2388
+ if (processedGroup) {
2389
+ if (!firstRule && precedingCombinator) {
2390
+ processedRules.push(precedingCombinator);
2391
+ precedingCombinator = "";
2392
+ }
2393
+ firstRule = false;
2394
+ processedRules.push(processedGroup);
2395
+ }
2396
+ continue;
2397
+ }
2398
+ const processedRule = processRule(rule);
2399
+ if (processedRule) {
2400
+ if (!firstRule && precedingCombinator) {
2401
+ processedRules.push(precedingCombinator);
2402
+ precedingCombinator = "";
2403
+ }
2404
+ firstRule = false;
2405
+ processedRules.push(processedRule);
2406
+ }
2407
+ }
2102
2408
  if (processedRules.length === 0) return fallbackExpression;
2103
2409
  return `${rg.not ? "NOT " : ""}(${processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ")})`;
2104
2410
  };
@@ -2207,20 +2513,46 @@ const defaultRuleGroupProcessorSQL = (ruleGroup, options) => {
2207
2513
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
2208
2514
  const processRuleGroup = (rg, outermostOrLonelyInGroup) => {
2209
2515
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
2210
- const processedRules = rg.rules.map((rule) => {
2211
- if (typeof rule === "string") return rule;
2212
- if (isRuleGroup(rule)) return processRuleGroup(rule, rg.rules.length === 1);
2516
+ const processedRules = [];
2517
+ let precedingCombinator = "";
2518
+ let firstRule = true;
2519
+ for (const rule of rg.rules) {
2520
+ if (typeof rule === "string") {
2521
+ precedingCombinator = rule;
2522
+ continue;
2523
+ }
2524
+ if (isRuleGroup(rule)) {
2525
+ const processedGroup = processRuleGroup(rule, rg.rules.length === 1);
2526
+ // istanbul ignore else
2527
+ if (processedGroup) {
2528
+ if (!firstRule && precedingCombinator) {
2529
+ processedRules.push(precedingCombinator);
2530
+ precedingCombinator = "";
2531
+ }
2532
+ firstRule = false;
2533
+ processedRules.push(processedGroup);
2534
+ }
2535
+ continue;
2536
+ }
2213
2537
  const [validationResult, fieldValidator] = validateRule(rule);
2214
- if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return "";
2538
+ if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
2215
2539
  const escapeQuotes = (rule.valueSource ?? "value") === "value";
2216
2540
  const fieldData = getOption(fields, rule.field);
2217
- return ruleProcessor(rule, {
2541
+ const processedRule = ruleProcessor(rule, {
2218
2542
  ...options,
2219
2543
  parseNumbers: getParseNumberBoolean(fieldData?.inputType),
2220
2544
  escapeQuotes,
2221
2545
  fieldData
2222
2546
  });
2223
- }).filter(Boolean);
2547
+ if (processedRule) {
2548
+ if (!firstRule && precedingCombinator) {
2549
+ processedRules.push(precedingCombinator);
2550
+ precedingCombinator = "";
2551
+ }
2552
+ firstRule = false;
2553
+ processedRules.push(processedRule);
2554
+ }
2555
+ }
2224
2556
  if (processedRules.length === 0) return fallbackExpression;
2225
2557
  return `${rg.not ? "NOT " : ""}(${processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ")})`;
2226
2558
  };
@@ -2498,10 +2830,7 @@ const defaultRuleProcessorJsonLogic = (rule, options = {}) => {
2498
2830
  case "null":
2499
2831
  case "notnull": return { [`${operatorLC === "notnull" ? "!" : "="}=`]: [fieldObject, null] };
2500
2832
  case "in":
2501
- case "notin": {
2502
- const valueAsArray = toArray(value).map((v) => fieldOrNumberRenderer(v));
2503
- return negateIfNotOp(operatorLC, { in: [fieldObject, valueAsArray] });
2504
- }
2833
+ case "notin": return negateIfNotOp(operatorLC, { in: [fieldObject, toArray(value).map((v) => fieldOrNumberRenderer(v))] });
2505
2834
  case "between":
2506
2835
  case "notbetween": {
2507
2836
  const valueAsArray = toArray(value);
@@ -2532,20 +2861,11 @@ const defaultRuleProcessorJsonLogic = (rule, options = {}) => {
2532
2861
  return false;
2533
2862
  }
2534
2863
  case "contains":
2535
- case "doesnotcontain": {
2536
- const jsonRule = { in: [fieldOrNumberRenderer(value), fieldObject] };
2537
- return negateIfNotOp(operatorLC, jsonRule);
2538
- }
2864
+ case "doesnotcontain": return negateIfNotOp(operatorLC, { in: [fieldOrNumberRenderer(value), fieldObject] });
2539
2865
  case "beginswith":
2540
- case "doesnotbeginwith": {
2541
- const jsonRule = { startsWith: [fieldObject, fieldOrNumberRenderer(value)] };
2542
- return negateIfNotOp(operatorLC, jsonRule);
2543
- }
2866
+ case "doesnotbeginwith": return negateIfNotOp(operatorLC, { startsWith: [fieldObject, fieldOrNumberRenderer(value)] });
2544
2867
  case "endswith":
2545
- case "doesnotendwith": {
2546
- const jsonRule = { endsWith: [fieldObject, fieldOrNumberRenderer(value)] };
2547
- return negateIfNotOp(operatorLC, jsonRule);
2548
- }
2868
+ case "doesnotendwith": return negateIfNotOp(operatorLC, { endsWith: [fieldObject, fieldOrNumberRenderer(value)] });
2549
2869
  }
2550
2870
  return false;
2551
2871
  };
@@ -2580,10 +2900,7 @@ const defaultRuleProcessorLDAP = (rule, options = {}) => {
2580
2900
  case "null":
2581
2901
  case "notnull": return negateIf(`(${field}=*)`, operatorLC === "notnull");
2582
2902
  case "in":
2583
- case "notin": {
2584
- const valueAsArray = toArray(value);
2585
- return negateIf(`(|${valueAsArray.map((val) => `(${field}=${ldapEscape(val)})`).join("")})`, operatorLC === "notin");
2586
- }
2903
+ case "notin": return negateIf(`(|${toArray(value).map((val) => `(${field}=${ldapEscape(val)})`).join("")})`, operatorLC === "notin");
2587
2904
  case "between":
2588
2905
  case "notbetween": {
2589
2906
  const valueAsArray = toArray(value);
@@ -2751,10 +3068,9 @@ const defaultRuleProcessorNL = (rule, opts) => {
2751
3068
  });
2752
3069
  const operatorLC = lc(operator);
2753
3070
  if ((operatorLC === "in" || operatorLC === "notin" || operatorLC === "between" || operatorLC === "notbetween") && !value) return "";
2754
- const processedOperator = operatorProcessor(rule, opts);
2755
3071
  const wordOrderMap = {
2756
3072
  S: processedField,
2757
- V: processedOperator,
3073
+ V: operatorProcessor(rule, opts),
2758
3074
  O: value
2759
3075
  };
2760
3076
  return normalizeConstituentWordOrder(wordOrder).map((term) => `${wordOrderMap[term]}`).join(" ").trim();
@@ -3520,6 +3836,26 @@ const getValueSourcesUtil = (fieldData, operator, getValueSources) => {
3520
3836
  });
3521
3837
  };
3522
3838
 
3839
+ //#endregion
3840
+ //#region src/utils/mergeAnyTranslations.ts
3841
+ /**
3842
+ * Merges any number of partial translations into a single definition.
3843
+ */
3844
+ const mergeAnyTranslations = (base, ...otherTranslations) => (0, immer.produce)(base, (draft) => {
3845
+ for (const translations of otherTranslations)
3846
+ // istanbul ignore else
3847
+ if (translations) for (const t of objectKeys(translations)) if (draft[t]) Object.assign(draft[t], translations[t]);
3848
+ else Object.assign(draft, { [t]: translations[t] });
3849
+ });
3850
+ const mergeAnyTranslation = (el, keyPropContextMap, defaults) => {
3851
+ const finalKeys = objectEntries(keyPropContextMap).map(([key, [pT, cT]]) => [key, pT ?? cT ?? defaults?.[el]?.[key]]).filter((k) => !!k[1]);
3852
+ if (finalKeys.length > 0 || defaults) {
3853
+ const defaultProperties = defaults?.[el] ?? {};
3854
+ const finalObject = Object.assign({}, defaultProperties, Object.fromEntries(finalKeys));
3855
+ return { [el]: finalObject };
3856
+ }
3857
+ };
3858
+
3523
3859
  //#endregion
3524
3860
  //#region src/utils/mergeClassnames.ts
3525
3861
  const joinClassnamesByName = (name, args) => clsx(args.map((c) => clsx(c?.[name])));
@@ -3547,6 +3883,9 @@ const mergeClassnames = (...args) => ({
3547
3883
  dragHandle: joinClassnamesByName("dragHandle", args),
3548
3884
  lockRule: joinClassnamesByName("lockRule", args),
3549
3885
  lockGroup: joinClassnamesByName("lockGroup", args),
3886
+ muteRule: joinClassnamesByName("muteRule", args),
3887
+ muteGroup: joinClassnamesByName("muteGroup", args),
3888
+ muted: joinClassnamesByName("muted", args),
3550
3889
  valueSource: joinClassnamesByName("valueSource", args),
3551
3890
  actionElement: joinClassnamesByName("actionElement", args),
3552
3891
  valueSelector: joinClassnamesByName("valueSelector", args),
@@ -3567,19 +3906,27 @@ const mergeClassnames = (...args) => ({
3567
3906
  });
3568
3907
 
3569
3908
  //#endregion
3570
- //#region src/utils/objectUtils.ts
3909
+ //#region src/utils/preferProp.ts
3910
+ const preferPropDefaultTrue = (prop, context) => prop === false ? false : prop ? true : !(context === false);
3911
+ const preferPropDefaultFalse = (prop, context) => prop ? true : prop === false ? false : !!context;
3571
3912
  /**
3572
- * A strongly-typed version of `Object.keys()`.
3573
- *
3574
- * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
3913
+ * For given default, prop, and context values, return the first provided of prop,
3914
+ * context, and default, in that order.
3575
3915
  */
3576
- const objectKeys = Object.keys;
3916
+ const preferProp = (def, prop, context, doNotFinalize) => !doNotFinalize ? def ? preferPropDefaultTrue(prop, context) : preferPropDefaultFalse(prop, context) : prop ?? context;
3577
3917
  /**
3578
- * A strongly-typed version of `Object.entries()`.
3579
- *
3580
- * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)
3918
+ * For given default, prop, and context values, return the first provided of prop,
3919
+ * context, and default, in that order.
3581
3920
  */
3582
- const objectEntries = Object.entries;
3921
+ const preferAnyProp = (def, prop, context) => prop !== void 0 && prop != null ? prop : context !== void 0 && context != null ? context : def;
3922
+ /**
3923
+ * For a given set of defaults, props, and context values, return the first provided of prop,
3924
+ * context, and default—in that order—for each property in the defaults object.
3925
+ */
3926
+ const preferFlagProps = (props = {}, contextVals = {}, finalize) => objectEntries(queryBuilderFlagDefaults).reduce((acc, [key, def]) => {
3927
+ acc[key] = preferProp(def, props[key], contextVals[key], !finalize);
3928
+ return acc;
3929
+ }, {});
3583
3930
 
3584
3931
  //#endregion
3585
3932
  //#region src/utils/prepareQueryObjects.ts
@@ -3690,12 +4037,11 @@ const update = (query, prop, value, pathOrID, { resetOnFieldChange = true, reset
3690
4037
  resetValueSource = true;
3691
4038
  resetValue = true;
3692
4039
  }
3693
- const valueSources = getValueSourcesUtil({
4040
+ const defaultValueSource = getFirstOption(getValueSourcesUtil({
3694
4041
  name: ruleOrGroup.field,
3695
4042
  value: ruleOrGroup.field,
3696
4043
  label: ""
3697
- }, ruleOrGroup.operator, getValueSources);
3698
- const defaultValueSource = getFirstOption(valueSources);
4044
+ }, ruleOrGroup.operator, getValueSources));
3699
4045
  if (resetValueSource && ruleOrGroup.valueSource && defaultValueSource !== ruleOrGroup.valueSource || prop === "valueSource" && value !== ruleOrGroup.valueSource) {
3700
4046
  resetValue = !!ruleOrGroup.valueSource || !ruleOrGroup.valueSource && value !== defaultValueSource;
3701
4047
  ruleOrGroup.valueSource = resetValueSource ? defaultValueSource : value;
@@ -3740,8 +4086,7 @@ const getNextPath = (query, currentPath, newPathOrShiftDirection) => {
3740
4086
  return [...getParentPath(parentPath), parentPath.at(-1) + 1];
3741
4087
  } else {
3742
4088
  const evaluationPath = [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 2 : 1)];
3743
- const entityToEvaluate = findPath(evaluationPath, query);
3744
- if (isRuleGroup(entityToEvaluate)) return [...evaluationPath, 0];
4089
+ if (isRuleGroup(findPath(evaluationPath, query))) return [...evaluationPath, 0];
3745
4090
  else return [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 3 : 2)];
3746
4091
  }
3747
4092
  return currentPath;
@@ -3775,8 +4120,7 @@ const move = (query, oldPathOrID, newPath, { clone = false, combinators = defaul
3775
4120
  const newNewPath = [...nextPath];
3776
4121
  const commonAncestorPath = getCommonAncestorPath(oldPath, nextPath);
3777
4122
  if (!clone && oldPath.length === commonAncestorPath.length + 1 && nextPath[commonAncestorPath.length] > oldPath[commonAncestorPath.length]) newNewPath[commonAncestorPath.length] -= independentCombinators ? 2 : 1;
3778
- const newNewParentPath = getParentPath(newNewPath);
3779
- const parentToInsertInto = findPath(newNewParentPath, draft);
4123
+ const parentToInsertInto = findPath(getParentPath(newNewPath), draft);
3780
4124
  const newIndex = newNewPath.at(-1);
3781
4125
  /**
3782
4126
  * This function 1) glosses over the need for type assertions to splice directly
@@ -3785,15 +4129,9 @@ const move = (query, oldPathOrID, newPath, { clone = false, combinators = defaul
3785
4129
  const insertRuleOrGroup = (...args) => parentToInsertInto.rules.splice(newIndex, 0, ...args);
3786
4130
  if (parentToInsertInto.rules.length === 0 || !independentCombinators) insertRuleOrGroup(ruleOrGroup);
3787
4131
  else if (newIndex === 0) if (ruleToRemoveIndex === 0 && oldNextCombinator) insertRuleOrGroup(ruleOrGroup, oldNextCombinator);
3788
- else {
3789
- const newNextCombinator = parentToInsertInto.rules[1] ?? oldPrevCombinator ?? getFirstOption(combinators);
3790
- insertRuleOrGroup(ruleOrGroup, newNextCombinator);
3791
- }
4132
+ else insertRuleOrGroup(ruleOrGroup, parentToInsertInto.rules[1] ?? oldPrevCombinator ?? getFirstOption(combinators));
3792
4133
  else if (oldPrevCombinator) insertRuleOrGroup(oldPrevCombinator, ruleOrGroup);
3793
- else {
3794
- const newPrevCombinator = parentToInsertInto.rules[newIndex - 2] ?? oldNextCombinator ?? getFirstOption(combinators);
3795
- insertRuleOrGroup(newPrevCombinator, ruleOrGroup);
3796
- }
4134
+ else insertRuleOrGroup(parentToInsertInto.rules[newIndex - 2] ?? oldNextCombinator ?? getFirstOption(combinators), ruleOrGroup);
3797
4135
  });
3798
4136
  };
3799
4137
  /**
@@ -3816,17 +4154,11 @@ const insert = (query, ruleOrGroup, path, { combinators = defaultCombinators, co
3816
4154
  if (parentToInsertInto.rules.length === 0 || !independentCombinators) insertRuleOrGroup(newIndex, rorg);
3817
4155
  else if (replace && independentCombinators) insertRuleOrGroup(newIndex + newIndex % 2, rorg);
3818
4156
  else if (newIndex === 0) if (rorg.path?.at(-1) === 0 && combinatorSucceeding) insertRuleOrGroup(newIndex, rorg, combinatorSucceeding);
3819
- else {
3820
- const newNextCombinator = parentToInsertInto.rules[1] ?? combinatorPreceding ?? getFirstOption(combinators);
3821
- insertRuleOrGroup(newIndex, rorg, newNextCombinator);
3822
- }
4157
+ else insertRuleOrGroup(newIndex, rorg, parentToInsertInto.rules[1] ?? combinatorPreceding ?? getFirstOption(combinators));
3823
4158
  else {
3824
4159
  const normalizedNewIndex = newIndex % 2 === 0 ? newIndex - 1 : newIndex;
3825
4160
  if (combinatorPreceding) insertRuleOrGroup(normalizedNewIndex, combinatorPreceding, rorg);
3826
- else {
3827
- const newPrevCombinator = parentToInsertInto.rules[normalizedNewIndex - 2] ?? combinatorSucceeding ?? getFirstOption(combinators);
3828
- insertRuleOrGroup(normalizedNewIndex, newPrevCombinator, rorg);
3829
- }
4161
+ else insertRuleOrGroup(normalizedNewIndex, parentToInsertInto.rules[normalizedNewIndex - 2] ?? combinatorSucceeding ?? getFirstOption(combinators), rorg);
3830
4162
  }
3831
4163
  });
3832
4164
  /**
@@ -3860,8 +4192,7 @@ const group = (query, sourcePathOrID, targetPathOrID, { clone = false, combinato
3860
4192
  const newNewPath = [...nextPath];
3861
4193
  const commonAncestorPath = getCommonAncestorPath(sourcePath, nextPath);
3862
4194
  if (!clone && sourcePath.length === commonAncestorPath.length + 1 && nextPath[commonAncestorPath.length] > sourcePath[commonAncestorPath.length]) newNewPath[commonAncestorPath.length] -= independentCombinators ? 2 : 1;
3863
- const newNewParentPath = getParentPath(newNewPath);
3864
- const parentOfTargetPath = findPath(newNewParentPath, draft);
4195
+ const parentOfTargetPath = findPath(getParentPath(newNewPath), draft);
3865
4196
  const targetPathIndex = newNewPath.at(-1);
3866
4197
  parentOfTargetPath.rules.splice(targetPathIndex, 1, prepareRuleOrGroup(independentCombinators ? { rules: [
3867
4198
  targetRuleOrGroup,
@@ -3940,6 +4271,7 @@ exports.defaultRuleProcessorSQL = defaultRuleProcessorSQL;
3940
4271
  exports.defaultRuleProcessorSequelize = defaultRuleProcessorSequelize;
3941
4272
  exports.defaultRuleProcessorSpEL = defaultRuleProcessorSpEL;
3942
4273
  exports.defaultSpELValueProcessor = defaultSpELValueProcessor;
4274
+ exports.defaultTranslations = defaultTranslations;
3943
4275
  exports.defaultValidator = defaultValidator;
3944
4276
  exports.defaultValueProcessor = defaultValueProcessor;
3945
4277
  exports.defaultValueProcessorByRule = defaultValueProcessorByRule;
@@ -3993,6 +4325,8 @@ exports.joinWith = joinWith;
3993
4325
  exports.jsonLogicAdditionalOperators = jsonLogicAdditionalOperators;
3994
4326
  exports.lc = lc;
3995
4327
  exports.mapSQLOperator = mapSQLOperator;
4328
+ exports.mergeAnyTranslation = mergeAnyTranslation;
4329
+ exports.mergeAnyTranslations = mergeAnyTranslations;
3996
4330
  exports.mergeClassnames = mergeClassnames;
3997
4331
  exports.mongoDbFallback = mongoDbFallback;
3998
4332
  exports.mongoOperators = mongoOperators;
@@ -4007,12 +4341,17 @@ exports.objectKeys = objectKeys;
4007
4341
  exports.parseNumber = parseNumber;
4008
4342
  exports.pathIsDisabled = pathIsDisabled;
4009
4343
  exports.pathsAreEqual = pathsAreEqual;
4344
+ exports.preferAnyProp = preferAnyProp;
4345
+ exports.preferFlagProps = preferFlagProps;
4346
+ exports.preferProp = preferProp;
4347
+ exports.prepareOptionList = prepareOptionList;
4010
4348
  exports.prepareRule = prepareRule;
4011
4349
  exports.prepareRuleGroup = prepareRuleGroup;
4012
4350
  exports.prepareRuleOrGroup = prepareRuleOrGroup;
4013
4351
  exports.prismaFallback = prismaFallback;
4014
4352
  exports.prismaOperators = prismaOperators;
4015
4353
  exports.processMatchMode = processMatchMode;
4354
+ exports.queryBuilderFlagDefaults = queryBuilderFlagDefaults;
4016
4355
  exports.regenerateID = regenerateID;
4017
4356
  exports.regenerateIDs = regenerateIDs;
4018
4357
  exports.remove = remove;