@react-querybuilder/core 8.9.1 → 8.10.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 (106) hide show
  1. package/dist/arrayUtils-C9sO4qLO.mjs +50 -0
  2. package/dist/arrayUtils-C9sO4qLO.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-BmpEwexQ.d.mts +363 -0
  6. package/dist/basic-CDDA-KZa.d.ts +363 -0
  7. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +569 -1252
  8. package/dist/cjs/react-querybuilder_core.cjs.development.js +430 -140
  9. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  10. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +569 -1252
  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-BUgyz1GA.mjs +75 -0
  14. package/dist/convertQuery-BUgyz1GA.mjs.map +1 -0
  15. package/dist/export-Ccjfea21.d.mts +453 -0
  16. package/dist/{export-DyrnTh6K.d.ts → export-GUuxJ7zR.d.ts} +3 -2
  17. package/dist/formatQuery.d.mts +668 -0
  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 +2496 -0
  22. package/dist/formatQuery.mjs.map +1 -0
  23. package/dist/{import-Cksobmln.d.ts → import-D-hm1phN.d.ts} +2 -2
  24. package/dist/import-Dxevzw_-.d.mts +28 -0
  25. package/dist/isRuleGroup-CGe_rb2w.mjs +40 -0
  26. package/dist/isRuleGroup-CGe_rb2w.mjs.map +1 -0
  27. package/dist/isRuleGroup-DqAs2x4E.js.map +1 -1
  28. package/dist/{optGroupUtils-CXLgyg2i.js → optGroupUtils-B0hTpodo.js} +114 -1
  29. package/dist/optGroupUtils-B0hTpodo.js.map +1 -0
  30. package/dist/optGroupUtils-DrubUpx0.mjs +185 -0
  31. package/dist/optGroupUtils-DrubUpx0.mjs.map +1 -0
  32. package/dist/parseCEL.d.mts +315 -0
  33. package/dist/parseCEL.d.ts +292 -11
  34. package/dist/parseCEL.js +114 -30
  35. package/dist/parseCEL.js.map +1 -1
  36. package/dist/parseCEL.mjs +2631 -0
  37. package/dist/parseCEL.mjs.map +1 -0
  38. package/dist/parseJSONata.d.mts +37 -0
  39. package/dist/parseJSONata.d.ts +3 -2
  40. package/dist/parseJSONata.js +49 -77
  41. package/dist/parseJSONata.js.map +1 -1
  42. package/dist/parseJSONata.mjs +267 -0
  43. package/dist/parseJSONata.mjs.map +1 -0
  44. package/dist/parseJsonLogic.d.mts +37 -0
  45. package/dist/parseJsonLogic.d.ts +4 -3
  46. package/dist/parseJsonLogic.js +5 -6
  47. package/dist/parseJsonLogic.js.map +1 -1
  48. package/dist/parseJsonLogic.mjs +190 -0
  49. package/dist/parseJsonLogic.mjs.map +1 -0
  50. package/dist/parseMongoDB.d.mts +80 -0
  51. package/dist/parseMongoDB.d.ts +3 -2
  52. package/dist/parseMongoDB.js +15 -16
  53. package/dist/parseMongoDB.js.map +1 -1
  54. package/dist/parseMongoDB.mjs +266 -0
  55. package/dist/parseMongoDB.mjs.map +1 -0
  56. package/dist/parseNumber-B_-sR6d5.mjs +24 -0
  57. package/dist/parseNumber-B_-sR6d5.mjs.map +1 -0
  58. package/dist/{parseNumber-Bcys1kOH.js → parseNumber-D4iQDxK-.js} +1 -1
  59. package/dist/{parseNumber-Bcys1kOH.js.map → parseNumber-D4iQDxK-.js.map} +1 -1
  60. package/dist/parseSQL.d.mts +38 -0
  61. package/dist/parseSQL.d.ts +3 -2
  62. package/dist/parseSQL.js +11 -15
  63. package/dist/parseSQL.js.map +1 -1
  64. package/dist/parseSQL.mjs +6622 -0
  65. package/dist/parseSQL.mjs.map +1 -0
  66. package/dist/parseSpEL.d.mts +35 -0
  67. package/dist/parseSpEL.d.ts +3 -2
  68. package/dist/parseSpEL.js +7 -9
  69. package/dist/parseSpEL.js.map +1 -1
  70. package/dist/parseSpEL.mjs +272 -0
  71. package/dist/parseSpEL.mjs.map +1 -0
  72. package/dist/{prepareQueryObjects-BqFEs4eV.js → prepareQueryObjects-BOUWfel5.js} +4 -5
  73. package/dist/prepareQueryObjects-BOUWfel5.js.map +1 -0
  74. package/dist/prepareQueryObjects-CJNpnGcJ.mjs +153 -0
  75. package/dist/prepareQueryObjects-CJNpnGcJ.mjs.map +1 -0
  76. package/dist/query-builder-layout.css +1 -1
  77. package/dist/query-builder-layout.css.map +1 -1
  78. package/dist/query-builder.css +1 -1
  79. package/dist/query-builder.css.map +1 -1
  80. package/dist/react-querybuilder_core.d.mts +569 -1252
  81. package/dist/react-querybuilder_core.legacy-esm.d.ts +569 -1252
  82. package/dist/react-querybuilder_core.legacy-esm.js +430 -136
  83. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  84. package/dist/react-querybuilder_core.mjs +426 -141
  85. package/dist/react-querybuilder_core.mjs.map +1 -1
  86. package/dist/react-querybuilder_core.production.d.mts +569 -1252
  87. package/dist/react-querybuilder_core.production.mjs +1 -1
  88. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  89. package/dist/styles/_layout.scss +61 -17
  90. package/dist/styles/_main.scss +17 -4
  91. package/dist/{transformQuery-FL_nlpp5.js → transformQuery-CWDPogO5.js} +1 -1
  92. package/dist/{transformQuery-FL_nlpp5.js.map → transformQuery-CWDPogO5.js.map} +1 -1
  93. package/dist/transformQuery-DHvtgDgZ.mjs +41 -0
  94. package/dist/transformQuery-DHvtgDgZ.mjs.map +1 -0
  95. package/dist/transformQuery.d.mts +118 -0
  96. package/dist/transformQuery.d.ts +1 -1
  97. package/dist/transformQuery.js +1 -1
  98. package/dist/transformQuery.mjs +4 -0
  99. package/package.json +78 -28
  100. package/dist/arrayUtils-D5EoIsKP.js +0 -164
  101. package/dist/arrayUtils-D5EoIsKP.js.map +0 -1
  102. package/dist/basic-C8xXKHIA.d.ts +0 -1235
  103. package/dist/objectUtils-BBZSfZJz.js +0 -17
  104. package/dist/objectUtils-BBZSfZJz.js.map +0 -1
  105. package/dist/optGroupUtils-CXLgyg2i.js.map +0 -1
  106. package/dist/prepareQueryObjects-BqFEs4eV.js.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
  };
@@ -523,6 +633,11 @@ function toVal(mix) {
523
633
  }
524
634
  return str;
525
635
  }
636
+ /**
637
+ * Vendored/adapted version of the `clsx` package.
638
+ *
639
+ * **NOTE:** Prefer the official package from npm outside the context of React Query Builder.
640
+ */
526
641
  // istanbul ignore next
527
642
  function clsx(...args) {
528
643
  let i = 0;
@@ -561,6 +676,10 @@ const nullOrUndefinedOrEmpty = (value) => value === null || value === void 0 ||
561
676
  //#endregion
562
677
  //#region src/utils/isRuleGroup.ts
563
678
  /**
679
+ * Determines if an object is a {@link RuleType} (only checks for a `field` property).
680
+ */
681
+ const isRuleType = (s) => isPojo(s) && "field" in s && typeof s.field === "string";
682
+ /**
564
683
  * Determines if an object is a {@link RuleGroupType} or {@link RuleGroupTypeIC}.
565
684
  */
566
685
  const isRuleGroup = (rg) => isPojo(rg) && Array.isArray(rg.rules);
@@ -683,6 +802,21 @@ const defaultValidator = (query) => {
683
802
  return result;
684
803
  };
685
804
 
805
+ //#endregion
806
+ //#region src/utils/objectUtils.ts
807
+ /**
808
+ * A strongly-typed version of `Object.keys()`.
809
+ *
810
+ * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
811
+ */
812
+ const objectKeys = Object.keys;
813
+ /**
814
+ * A strongly-typed version of `Object.entries()`.
815
+ *
816
+ * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)
817
+ */
818
+ const objectEntries = Object.entries;
819
+
686
820
  //#endregion
687
821
  //#region src/utils/optGroupUtils.ts
688
822
  const isOptionWithName = (opt) => isPojo(opt) && "name" in opt && typeof opt.name === "string";
@@ -859,6 +993,42 @@ const uniqOptList = (originalArray) => {
859
993
  if (isFlexibleOptionGroupArray(originalArray)) return uniqOptGroups(originalArray);
860
994
  return uniqByIdentifier(originalArray.map((o) => toFullOption(o)));
861
995
  };
996
+ const prepareOptionList = (props) => {
997
+ // istanbul ignore next
998
+ const { optionList: optionListPropOriginal, baseOption = {}, labelMap = {}, placeholder: { placeholderName = defaultPlaceholderName, placeholderLabel = defaultPlaceholderLabel, placeholderGroupLabel = defaultPlaceholderLabel } = {}, autoSelectOption = true } = props;
999
+ const defaultOption = {
1000
+ id: placeholderName,
1001
+ name: placeholderName,
1002
+ value: placeholderName,
1003
+ label: placeholderLabel
1004
+ };
1005
+ const optionsProp = optionListPropOriginal ?? [defaultOption];
1006
+ let optionList = [];
1007
+ const opts = Array.isArray(optionsProp) ? toFullOptionList(optionsProp, baseOption, labelMap) : objectKeys(toFullOptionMap(optionsProp, baseOption)).map((opt) => ({
1008
+ ...optionsProp[opt],
1009
+ name: opt,
1010
+ value: opt
1011
+ })).sort((a, b) => a.label.localeCompare(b.label));
1012
+ if (isFlexibleOptionGroupArray(opts)) optionList = autoSelectOption ? uniqOptGroups(opts) : uniqOptGroups([{
1013
+ label: placeholderGroupLabel,
1014
+ options: [defaultOption]
1015
+ }, ...opts]);
1016
+ else optionList = autoSelectOption ? uniqByIdentifier(opts) : uniqByIdentifier([defaultOption, ...opts]);
1017
+ let optionsMap = {};
1018
+ if (!Array.isArray(optionsProp)) {
1019
+ const op = toFullOptionMap(optionsProp, baseOption);
1020
+ optionsMap = autoSelectOption ? op : {
1021
+ ...op,
1022
+ [placeholderName]: defaultOption
1023
+ };
1024
+ } else if (isFlexibleOptionGroupArray(optionList)) for (const og of optionList) for (const opt of og.options) optionsMap[opt.value ?? opt.name] = toFullOption(opt, baseOption);
1025
+ else for (const opt of optionList) optionsMap[opt.value ?? opt.name] = toFullOption(opt, baseOption);
1026
+ return {
1027
+ defaultOption,
1028
+ optionList,
1029
+ optionsMap
1030
+ };
1031
+ };
862
1032
 
863
1033
  //#endregion
864
1034
  //#region src/utils/filterFieldsByComparator.ts
@@ -960,9 +1130,11 @@ function transformQuery(query, options = {}) {
960
1130
  const isValidationResult = (vr) => isPojo(vr) && typeof vr.valid === "boolean";
961
1131
  /**
962
1132
  * Determines if a rule or group is valid based on a validation result (if defined)
963
- * or a validator function. Returns `true` if neither are defined.
1133
+ * or a validator function. Returns `true` if neither are defined and the `muted`
1134
+ * property is not `true`.
964
1135
  */
965
1136
  const isRuleOrGroupValid = (rg, validationResult, validator) => {
1137
+ if (rg.muted) return false;
966
1138
  if (typeof validationResult === "boolean") return validationResult;
967
1139
  if (isValidationResult(validationResult)) return validationResult.valid;
968
1140
  if (typeof validator === "function" && !isRuleGroup(rg)) {
@@ -1236,19 +1408,45 @@ const defaultRuleGroupProcessorCEL = (ruleGroup, options) => {
1236
1408
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1237
1409
  const processRuleGroup = (rg, outermost) => {
1238
1410
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermost ? fallbackExpression : "";
1239
- const expression = rg.rules.map((rule) => {
1240
- if (typeof rule === "string") return celCombinatorMap[rule];
1241
- if (isRuleGroup(rule)) return processRuleGroup(rule);
1411
+ const processedRules = [];
1412
+ let precedingCombinator = "";
1413
+ let firstRule = true;
1414
+ for (const rule of rg.rules) {
1415
+ if (typeof rule === "string") {
1416
+ precedingCombinator = celCombinatorMap[rule];
1417
+ continue;
1418
+ }
1419
+ if (isRuleGroup(rule)) {
1420
+ const processedGroup = processRuleGroup(rule);
1421
+ if (processedGroup) {
1422
+ if (!firstRule && precedingCombinator) {
1423
+ processedRules.push(precedingCombinator);
1424
+ precedingCombinator = "";
1425
+ }
1426
+ firstRule = false;
1427
+ processedRules.push(processedGroup);
1428
+ }
1429
+ continue;
1430
+ }
1242
1431
  const [validationResult, fieldValidator] = validateRule(rule);
1243
- if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return "";
1432
+ if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
1244
1433
  const fieldData = getOption(fields, rule.field);
1245
- return ruleProcessor(rule, {
1434
+ const processedRule = ruleProcessor(rule, {
1246
1435
  ...options,
1247
1436
  parseNumbers: getParseNumberBoolean(fieldData?.inputType),
1248
1437
  escapeQuotes: (rule.valueSource ?? "value") === "value",
1249
1438
  fieldData
1250
1439
  });
1251
- }).filter(Boolean).join(isRuleGroupType(rg) ? ` ${celCombinatorMap[rg.combinator]} ` : " ");
1440
+ if (processedRule) {
1441
+ if (!firstRule && precedingCombinator) {
1442
+ processedRules.push(precedingCombinator);
1443
+ precedingCombinator = "";
1444
+ }
1445
+ firstRule = false;
1446
+ processedRules.push(processedRule);
1447
+ }
1448
+ }
1449
+ const expression = processedRules.join(isRuleGroupType(rg) ? ` ${celCombinatorMap[rg.combinator]} ` : " ");
1252
1450
  const [prefix, suffix] = rg.not || !outermost ? [`${rg.not ? "!" : ""}(`, ")"] : ["", ""];
1253
1451
  return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
1254
1452
  };
@@ -1275,11 +1473,10 @@ const defaultRuleProcessorCEL = (rule, opts = {}) => {
1275
1473
  else if (matchEval) {
1276
1474
  const { mode, threshold } = matchEval;
1277
1475
  const arrayElementAlias = "elem_alias";
1278
- const celQuery = transformQuery(rule.value, { ruleProcessor: (r) => ({
1476
+ const nestedArrayFilter = defaultRuleGroupProcessorCEL(transformQuery(rule.value, { ruleProcessor: (r) => ({
1279
1477
  ...r,
1280
1478
  field: `${arrayElementAlias}${r.field ? `.${r.field}` : ""}`
1281
- }) });
1282
- const nestedArrayFilter = defaultRuleGroupProcessorCEL(celQuery, opts);
1479
+ }) }), opts);
1283
1480
  switch (mode) {
1284
1481
  case "all": return `${field}.all(${arrayElementAlias}, ${nestedArrayFilter})`;
1285
1482
  case "none":
@@ -1313,8 +1510,7 @@ const defaultRuleProcessorCEL = (rule, opts = {}) => {
1313
1510
  case "in":
1314
1511
  case "notin": {
1315
1512
  const [prefix, suffix] = shouldNegate$2(operatorTL) ? ["!(", ")"] : ["", ""];
1316
- const valueAsArray = toArray(value);
1317
- return `${prefix}${field} in [${valueAsArray.map((val) => valueIsField || shouldRenderAsNumber(val, parseNumbers) ? `${trimIfString(val)}` : `"${escapeDoubleQuotes(val, escapeQuotes)}"`).join(", ")}]${suffix}`;
1513
+ return `${prefix}${field} in [${toArray(value).map((val) => valueIsField || shouldRenderAsNumber(val, parseNumbers) ? `${trimIfString(val)}` : `"${escapeDoubleQuotes(val, escapeQuotes)}"`).join(", ")}]${suffix}`;
1318
1514
  }
1319
1515
  case "between":
1320
1516
  case "notbetween": {
@@ -1534,19 +1730,45 @@ const defaultRuleGroupProcessorSpEL = (ruleGroup, options) => {
1534
1730
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1535
1731
  const processRuleGroup = (rg, outermost) => {
1536
1732
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermost ? fallbackExpression : "";
1537
- const expression = rg.rules.map((rule) => {
1538
- if (typeof rule === "string") return rule;
1539
- if (isRuleGroup(rule)) return processRuleGroup(rule);
1733
+ const processedRules = [];
1734
+ let precedingCombinator = "";
1735
+ let firstRule = true;
1736
+ for (const rule of rg.rules) {
1737
+ if (typeof rule === "string") {
1738
+ precedingCombinator = rule;
1739
+ continue;
1740
+ }
1741
+ if (isRuleGroup(rule)) {
1742
+ const processedGroup = processRuleGroup(rule);
1743
+ if (processedGroup) {
1744
+ if (!firstRule && precedingCombinator) {
1745
+ processedRules.push(precedingCombinator);
1746
+ precedingCombinator = "";
1747
+ }
1748
+ firstRule = false;
1749
+ processedRules.push(processedGroup);
1750
+ }
1751
+ continue;
1752
+ }
1540
1753
  const [validationResult, fieldValidator] = validateRule(rule);
1541
- if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return "";
1754
+ if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
1542
1755
  const fieldData = getOption(fields, rule.field);
1543
- return ruleProcessor(rule, {
1756
+ const processedRule = ruleProcessor(rule, {
1544
1757
  ...options,
1545
1758
  parseNumbers: getParseNumberBoolean(fieldData?.inputType),
1546
1759
  escapeQuotes: (rule.valueSource ?? "value") === "value",
1547
1760
  fieldData
1548
1761
  });
1549
- }).filter(Boolean).join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ");
1762
+ if (processedRule) {
1763
+ if (!firstRule && precedingCombinator) {
1764
+ processedRules.push(precedingCombinator);
1765
+ precedingCombinator = "";
1766
+ }
1767
+ firstRule = false;
1768
+ processedRules.push(processedRule);
1769
+ }
1770
+ }
1771
+ const expression = processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ");
1550
1772
  const [prefix, suffix] = rg.not || !outermost ? [`${rg.not ? "!" : ""}(`, ")"] : ["", ""];
1551
1773
  return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
1552
1774
  };
@@ -1602,15 +1824,9 @@ const defaultRuleProcessorSpEL = (rule, opts = {}) => {
1602
1824
  case "contains":
1603
1825
  case "doesnotcontain": return wrapInNegation(`${field} matches ${valueIsField || useBareValue ? trimIfString(value) : `'${escapeSingleQuotes(value, escapeQuotes)}'`}`, shouldNegate$1(operatorTL));
1604
1826
  case "beginswith":
1605
- case "doesnotbeginwith": {
1606
- const valueTL = valueIsField ? `'^'.concat(${trimIfString(value)})` : `'${typeof value === "string" && !value.startsWith("^") || useBareValue ? "^" : ""}${escapeSingleQuotes(value, escapeQuotes)}'`;
1607
- return wrapInNegation(`${field} matches ${valueTL}`, shouldNegate$1(operatorTL));
1608
- }
1827
+ case "doesnotbeginwith": return wrapInNegation(`${field} matches ${valueIsField ? `'^'.concat(${trimIfString(value)})` : `'${typeof value === "string" && !value.startsWith("^") || useBareValue ? "^" : ""}${escapeSingleQuotes(value, escapeQuotes)}'`}`, shouldNegate$1(operatorTL));
1609
1828
  case "endswith":
1610
- case "doesnotendwith": {
1611
- const valueTL = valueIsField ? `${trimIfString(value)}.concat('$')` : `'${escapeSingleQuotes(value, escapeQuotes)}${typeof value === "string" && !value.endsWith("$") || useBareValue ? "$" : ""}'`;
1612
- return wrapInNegation(`${field} matches ${valueTL}`, shouldNegate$1(operatorTL));
1613
- }
1829
+ case "doesnotendwith": return wrapInNegation(`${field} matches ${valueIsField ? `${trimIfString(value)}.concat('$')` : `'${escapeSingleQuotes(value, escapeQuotes)}${typeof value === "string" && !value.endsWith("$") || useBareValue ? "$" : ""}'`}`, shouldNegate$1(operatorTL));
1614
1830
  case "null": return `${field} == null`;
1615
1831
  case "notnull": return `${field} != null`;
1616
1832
  case "in":
@@ -1723,11 +1939,10 @@ const defaultRuleProcessorDrizzle = (rule, _options) => {
1723
1939
  if (opts.preset !== "postgresql") return;
1724
1940
  const { mode, threshold } = matchEval;
1725
1941
  const arrayElementAlias = "elem_alias";
1726
- const sqlQuery = transformQuery(rule.value, { ruleProcessor: (r) => ({
1942
+ const nestedArrayFilter = defaultRuleGroupProcessorDrizzle(transformQuery(rule.value, { ruleProcessor: (r) => ({
1727
1943
  ...r,
1728
1944
  field: arrayElementAlias
1729
- }) });
1730
- const nestedArrayFilter = defaultRuleGroupProcessorDrizzle(sqlQuery, {
1945
+ }) }), {
1731
1946
  ...opts,
1732
1947
  context: {
1733
1948
  ...opts.context,
@@ -1813,7 +2028,6 @@ const defaultRuleGroupProcessorDrizzle = (ruleGroup, options, _meta) => (columns
1813
2028
  const { fields, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, validateRule, validationMap } = options;
1814
2029
  if (!columns || !drizzleOperators) return;
1815
2030
  const { and, not, or } = drizzleOperators;
1816
- const query = isRuleGroupType(ruleGroup) ? ruleGroup : convertFromIC(ruleGroup);
1817
2031
  const ruleProcessor = defaultRuleProcessorDrizzle;
1818
2032
  const processRuleGroup = (rg, _outermost) => {
1819
2033
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return;
@@ -1837,7 +2051,7 @@ const defaultRuleGroupProcessorDrizzle = (ruleGroup, options, _meta) => (columns
1837
2051
  const ruleGroupSQL = rg.combinator === "or" ? or(...processedRules) : and(...processedRules);
1838
2052
  return rg.not ? not(ruleGroupSQL) : ruleGroupSQL;
1839
2053
  };
1840
- return processRuleGroup(query, true);
2054
+ return processRuleGroup(convertFromIC(ruleGroup), true);
1841
2055
  };
1842
2056
 
1843
2057
  //#endregion
@@ -1849,7 +2063,6 @@ const defaultRuleGroupProcessorDrizzle = (ruleGroup, options, _meta) => (columns
1849
2063
  */
1850
2064
  const defaultRuleGroupProcessorElasticSearch = (ruleGroup, options) => {
1851
2065
  const { fields, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1852
- const query = convertFromIC(ruleGroup);
1853
2066
  const processRuleGroup = (rg) => {
1854
2067
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return false;
1855
2068
  const processedRules = rg.rules.map((rule) => {
@@ -1866,7 +2079,7 @@ const defaultRuleGroupProcessorElasticSearch = (ruleGroup, options) => {
1866
2079
  if (processedRules.length === 0) return false;
1867
2080
  return { bool: rg.not ? { must_not: /^or$/i.test(rg.combinator) ? { bool: { should: processedRules } } : processedRules } : { [/^or$/i.test(rg.combinator) ? "should" : "must"]: processedRules } };
1868
2081
  };
1869
- const processedRuleGroup = processRuleGroup(query);
2082
+ const processedRuleGroup = processRuleGroup(convertFromIC(ruleGroup));
1870
2083
  return processedRuleGroup === false ? {} : processedRuleGroup;
1871
2084
  };
1872
2085
 
@@ -1881,19 +2094,45 @@ const defaultRuleGroupProcessorJSONata = (ruleGroup, options) => {
1881
2094
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1882
2095
  const processRuleGroup = (rg, outermost) => {
1883
2096
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermost ? fallbackExpression : "";
1884
- const expression = rg.rules.map((rule) => {
1885
- if (typeof rule === "string") return rule;
1886
- if (isRuleGroup(rule)) return processRuleGroup(rule);
2097
+ const processedRules = [];
2098
+ let precedingCombinator = "";
2099
+ let firstRule = true;
2100
+ for (const rule of rg.rules) {
2101
+ if (typeof rule === "string") {
2102
+ precedingCombinator = rule;
2103
+ continue;
2104
+ }
2105
+ if (isRuleGroup(rule)) {
2106
+ const processedGroup = processRuleGroup(rule);
2107
+ if (processedGroup) {
2108
+ if (!firstRule && precedingCombinator) {
2109
+ processedRules.push(precedingCombinator);
2110
+ precedingCombinator = "";
2111
+ }
2112
+ firstRule = false;
2113
+ processedRules.push(processedGroup);
2114
+ }
2115
+ continue;
2116
+ }
1887
2117
  const [validationResult, fieldValidator] = validateRule(rule);
1888
- if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return "";
2118
+ if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
1889
2119
  const fieldData = getOption(fields, rule.field);
1890
- return ruleProcessor(rule, {
2120
+ const processedRule = ruleProcessor(rule, {
1891
2121
  ...options,
1892
2122
  parseNumbers: getParseNumberBoolean(fieldData?.inputType),
1893
2123
  escapeQuotes: (rule.valueSource ?? "value") === "value",
1894
2124
  fieldData
1895
2125
  });
1896
- }).filter(Boolean).join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ");
2126
+ if (processedRule) {
2127
+ if (!firstRule && precedingCombinator) {
2128
+ processedRules.push(precedingCombinator);
2129
+ precedingCombinator = "";
2130
+ }
2131
+ firstRule = false;
2132
+ processedRules.push(processedRule);
2133
+ }
2134
+ }
2135
+ const expression = processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ");
1897
2136
  const [prefix, suffix] = rg.not || !outermost ? [`${rg.not ? "$not" : ""}(`, ")"] : ["", ""];
1898
2137
  return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
1899
2138
  };
@@ -1939,7 +2178,6 @@ const defaultRuleGroupProcessorJsonLogic = (ruleGroup, options) => {
1939
2178
  */
1940
2179
  const defaultRuleGroupProcessorLDAP = (ruleGroup, options) => {
1941
2180
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1942
- const query = convertFromIC(ruleGroup);
1943
2181
  const processRuleGroup = (rg, outermost) => {
1944
2182
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermost ? fallbackExpression : "";
1945
2183
  const rules = rg.rules.map((rule) => {
@@ -1959,7 +2197,7 @@ const defaultRuleGroupProcessorLDAP = (ruleGroup, options) => {
1959
2197
  const [prefix, suffix] = rules.length > 1 ? [`${notPrefix}(${rg.combinator === "or" ? "|" : "&"}`, `)${notSuffix}`] : [notPrefix, notSuffix];
1960
2198
  return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
1961
2199
  };
1962
- return processRuleGroup(query, true);
2200
+ return processRuleGroup(convertFromIC(ruleGroup), true);
1963
2201
  };
1964
2202
 
1965
2203
  //#endregion
@@ -2014,20 +2252,46 @@ const defaultRuleGroupProcessorNL = (ruleGroup, options) => {
2014
2252
  const processRuleGroup = (rg, outermostOrLonelyInGroup) => {
2015
2253
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
2016
2254
  const rg2 = isRuleGroupTypeIC(rg) && rg.rules.some((r) => typeof r === "string" && lc(r) === "xor") ? convertFromIC(rg) : rg;
2017
- const processedRules = rg2.rules.map((rule) => {
2018
- if (typeof rule === "string") return `, ${translations[rule] ?? rule} `;
2019
- if (isRuleGroup(rule)) return processRuleGroup(rule, rg2.rules.length === 1 && !(rg2.not || /^xor$/i.test(rg2.combinator ?? "")));
2255
+ const processedRules = [];
2256
+ let precedingCombinator = "";
2257
+ let firstRule = true;
2258
+ for (const rule of rg2.rules) {
2259
+ if (typeof rule === "string") {
2260
+ precedingCombinator = `, ${translations[rule] ?? rule} `;
2261
+ continue;
2262
+ }
2263
+ if (isRuleGroup(rule)) {
2264
+ const processedGroup = processRuleGroup(rule, rg2.rules.length === 1 && !(rg2.not || /^xor$/i.test(rg2.combinator ?? "")));
2265
+ // istanbul ignore else
2266
+ if (processedGroup) {
2267
+ if (!firstRule && precedingCombinator) {
2268
+ processedRules.push(precedingCombinator);
2269
+ precedingCombinator = "";
2270
+ }
2271
+ firstRule = false;
2272
+ processedRules.push(processedGroup);
2273
+ }
2274
+ continue;
2275
+ }
2020
2276
  const [validationResult, fieldValidator] = validateRule(rule);
2021
- if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return "";
2277
+ if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
2022
2278
  const escapeQuotes = (rule.valueSource ?? "value") === "value";
2023
2279
  const fieldData = getOption(fields, rule.field);
2024
- return ruleProcessor(rule, {
2280
+ const processedRule = ruleProcessor(rule, {
2025
2281
  ...options,
2026
2282
  parseNumbers: getParseNumberBoolean(fieldData?.inputType),
2027
2283
  escapeQuotes,
2028
2284
  fieldData
2029
2285
  });
2030
- });
2286
+ if (processedRule) {
2287
+ if (!firstRule && precedingCombinator) {
2288
+ processedRules.push(precedingCombinator);
2289
+ precedingCombinator = "";
2290
+ }
2291
+ firstRule = false;
2292
+ processedRules.push(processedRule);
2293
+ }
2294
+ }
2031
2295
  if (processedRules.length === 0) return fallbackExpression;
2032
2296
  const isXOR = lc(rg2.combinator ?? "") === "xor";
2033
2297
  const combinator = isXOR ? rg2.combinator.slice(1) : rg2.combinator;
@@ -2035,7 +2299,7 @@ const defaultRuleGroupProcessorNL = (ruleGroup, options) => {
2035
2299
  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));
2036
2300
  const prefix = mustWrap ? `${prefixTL} (`.trim() : "";
2037
2301
  const suffix = mustWrap ? `) ${suffixTL}`.trim() : "";
2038
- return `${prefix}${processedRules.filter(Boolean).join(isRuleGroupType(rg2) ? `, ${translations[combinator] ?? combinator} ` : "")}${suffix}`;
2302
+ return `${prefix}${processedRules.join(isRuleGroupType(rg2) ? `, ${translations[combinator] ?? combinator} ` : "")}${suffix}`;
2039
2303
  };
2040
2304
  return processRuleGroup(ruleGroup, true);
2041
2305
  };
@@ -2085,11 +2349,37 @@ const defaultRuleGroupProcessorParameterized = (ruleGroup, options) => {
2085
2349
  };
2086
2350
  const processRuleGroup = (rg, outermostOrLonelyInGroup) => {
2087
2351
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
2088
- const processedRules = rg.rules.map((rule) => {
2089
- if (typeof rule === "string") return rule;
2090
- if (isRuleGroup(rule)) return processRuleGroup(rule, rg.rules.length === 1);
2091
- return processRule(rule);
2092
- }).filter(Boolean);
2352
+ const processedRules = [];
2353
+ let precedingCombinator = "";
2354
+ let firstRule = true;
2355
+ for (const rule of rg.rules) {
2356
+ if (typeof rule === "string") {
2357
+ precedingCombinator = rule;
2358
+ continue;
2359
+ }
2360
+ if (isRuleGroup(rule)) {
2361
+ const processedGroup = processRuleGroup(rule, rg.rules.length === 1);
2362
+ // istanbul ignore else
2363
+ if (processedGroup) {
2364
+ if (!firstRule && precedingCombinator) {
2365
+ processedRules.push(precedingCombinator);
2366
+ precedingCombinator = "";
2367
+ }
2368
+ firstRule = false;
2369
+ processedRules.push(processedGroup);
2370
+ }
2371
+ continue;
2372
+ }
2373
+ const processedRule = processRule(rule);
2374
+ if (processedRule) {
2375
+ if (!firstRule && precedingCombinator) {
2376
+ processedRules.push(precedingCombinator);
2377
+ precedingCombinator = "";
2378
+ }
2379
+ firstRule = false;
2380
+ processedRules.push(processedRule);
2381
+ }
2382
+ }
2093
2383
  if (processedRules.length === 0) return fallbackExpression;
2094
2384
  return `${rg.not ? "NOT " : ""}(${processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ")})`;
2095
2385
  };
@@ -2198,20 +2488,46 @@ const defaultRuleGroupProcessorSQL = (ruleGroup, options) => {
2198
2488
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
2199
2489
  const processRuleGroup = (rg, outermostOrLonelyInGroup) => {
2200
2490
  if (!isRuleOrGroupValid(rg, validationMap[rg.id ?? ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
2201
- const processedRules = rg.rules.map((rule) => {
2202
- if (typeof rule === "string") return rule;
2203
- if (isRuleGroup(rule)) return processRuleGroup(rule, rg.rules.length === 1);
2491
+ const processedRules = [];
2492
+ let precedingCombinator = "";
2493
+ let firstRule = true;
2494
+ for (const rule of rg.rules) {
2495
+ if (typeof rule === "string") {
2496
+ precedingCombinator = rule;
2497
+ continue;
2498
+ }
2499
+ if (isRuleGroup(rule)) {
2500
+ const processedGroup = processRuleGroup(rule, rg.rules.length === 1);
2501
+ // istanbul ignore else
2502
+ if (processedGroup) {
2503
+ if (!firstRule && precedingCombinator) {
2504
+ processedRules.push(precedingCombinator);
2505
+ precedingCombinator = "";
2506
+ }
2507
+ firstRule = false;
2508
+ processedRules.push(processedGroup);
2509
+ }
2510
+ continue;
2511
+ }
2204
2512
  const [validationResult, fieldValidator] = validateRule(rule);
2205
- if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return "";
2513
+ if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
2206
2514
  const escapeQuotes = (rule.valueSource ?? "value") === "value";
2207
2515
  const fieldData = getOption(fields, rule.field);
2208
- return ruleProcessor(rule, {
2516
+ const processedRule = ruleProcessor(rule, {
2209
2517
  ...options,
2210
2518
  parseNumbers: getParseNumberBoolean(fieldData?.inputType),
2211
2519
  escapeQuotes,
2212
2520
  fieldData
2213
2521
  });
2214
- }).filter(Boolean);
2522
+ if (processedRule) {
2523
+ if (!firstRule && precedingCombinator) {
2524
+ processedRules.push(precedingCombinator);
2525
+ precedingCombinator = "";
2526
+ }
2527
+ firstRule = false;
2528
+ processedRules.push(processedRule);
2529
+ }
2530
+ }
2215
2531
  if (processedRules.length === 0) return fallbackExpression;
2216
2532
  return `${rg.not ? "NOT " : ""}(${processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ")})`;
2217
2533
  };
@@ -2489,10 +2805,7 @@ const defaultRuleProcessorJsonLogic = (rule, options = {}) => {
2489
2805
  case "null":
2490
2806
  case "notnull": return { [`${operatorLC === "notnull" ? "!" : "="}=`]: [fieldObject, null] };
2491
2807
  case "in":
2492
- case "notin": {
2493
- const valueAsArray = toArray(value).map((v) => fieldOrNumberRenderer(v));
2494
- return negateIfNotOp(operatorLC, { in: [fieldObject, valueAsArray] });
2495
- }
2808
+ case "notin": return negateIfNotOp(operatorLC, { in: [fieldObject, toArray(value).map((v) => fieldOrNumberRenderer(v))] });
2496
2809
  case "between":
2497
2810
  case "notbetween": {
2498
2811
  const valueAsArray = toArray(value);
@@ -2523,20 +2836,11 @@ const defaultRuleProcessorJsonLogic = (rule, options = {}) => {
2523
2836
  return false;
2524
2837
  }
2525
2838
  case "contains":
2526
- case "doesnotcontain": {
2527
- const jsonRule = { in: [fieldOrNumberRenderer(value), fieldObject] };
2528
- return negateIfNotOp(operatorLC, jsonRule);
2529
- }
2839
+ case "doesnotcontain": return negateIfNotOp(operatorLC, { in: [fieldOrNumberRenderer(value), fieldObject] });
2530
2840
  case "beginswith":
2531
- case "doesnotbeginwith": {
2532
- const jsonRule = { startsWith: [fieldObject, fieldOrNumberRenderer(value)] };
2533
- return negateIfNotOp(operatorLC, jsonRule);
2534
- }
2841
+ case "doesnotbeginwith": return negateIfNotOp(operatorLC, { startsWith: [fieldObject, fieldOrNumberRenderer(value)] });
2535
2842
  case "endswith":
2536
- case "doesnotendwith": {
2537
- const jsonRule = { endsWith: [fieldObject, fieldOrNumberRenderer(value)] };
2538
- return negateIfNotOp(operatorLC, jsonRule);
2539
- }
2843
+ case "doesnotendwith": return negateIfNotOp(operatorLC, { endsWith: [fieldObject, fieldOrNumberRenderer(value)] });
2540
2844
  }
2541
2845
  return false;
2542
2846
  };
@@ -2571,10 +2875,7 @@ const defaultRuleProcessorLDAP = (rule, options = {}) => {
2571
2875
  case "null":
2572
2876
  case "notnull": return negateIf(`(${field}=*)`, operatorLC === "notnull");
2573
2877
  case "in":
2574
- case "notin": {
2575
- const valueAsArray = toArray(value);
2576
- return negateIf(`(|${valueAsArray.map((val) => `(${field}=${ldapEscape(val)})`).join("")})`, operatorLC === "notin");
2577
- }
2878
+ case "notin": return negateIf(`(|${toArray(value).map((val) => `(${field}=${ldapEscape(val)})`).join("")})`, operatorLC === "notin");
2578
2879
  case "between":
2579
2880
  case "notbetween": {
2580
2881
  const valueAsArray = toArray(value);
@@ -2742,10 +3043,9 @@ const defaultRuleProcessorNL = (rule, opts) => {
2742
3043
  });
2743
3044
  const operatorLC = lc(operator);
2744
3045
  if ((operatorLC === "in" || operatorLC === "notin" || operatorLC === "between" || operatorLC === "notbetween") && !value) return "";
2745
- const processedOperator = operatorProcessor(rule, opts);
2746
3046
  const wordOrderMap = {
2747
3047
  S: processedField,
2748
- V: processedOperator,
3048
+ V: operatorProcessor(rule, opts),
2749
3049
  O: value
2750
3050
  };
2751
3051
  return normalizeConstituentWordOrder(wordOrder).map((term) => `${wordOrderMap[term]}`).join(" ").trim();
@@ -3322,7 +3622,7 @@ const findPath = (path, query) => {
3322
3622
  target = typeof t === "string" ? null : t;
3323
3623
  level++;
3324
3624
  }
3325
- return target;
3625
+ return level < path.length ? null : target;
3326
3626
  };
3327
3627
  /**
3328
3628
  * Returns the {@link RuleType} or {@link RuleGroupType}/{@link RuleGroupTypeIC}
@@ -3511,6 +3811,26 @@ const getValueSourcesUtil = (fieldData, operator, getValueSources) => {
3511
3811
  });
3512
3812
  };
3513
3813
 
3814
+ //#endregion
3815
+ //#region src/utils/mergeAnyTranslations.ts
3816
+ /**
3817
+ * Merges any number of partial translations into a single definition.
3818
+ */
3819
+ const mergeAnyTranslations = (base, ...otherTranslations) => (0, immer.produce)(base, (draft) => {
3820
+ for (const translations of otherTranslations)
3821
+ // istanbul ignore else
3822
+ if (translations) for (const t of objectKeys(translations)) if (draft[t]) Object.assign(draft[t], translations[t]);
3823
+ else Object.assign(draft, { [t]: translations[t] });
3824
+ });
3825
+ const mergeAnyTranslation = (el, keyPropContextMap, defaults) => {
3826
+ const finalKeys = objectEntries(keyPropContextMap).map(([key, [pT, cT]]) => [key, pT ?? cT ?? defaults?.[el]?.[key]]).filter((k) => !!k[1]);
3827
+ if (finalKeys.length > 0 || defaults) {
3828
+ const defaultProperties = defaults?.[el] ?? {};
3829
+ const finalObject = Object.assign({}, defaultProperties, Object.fromEntries(finalKeys));
3830
+ return { [el]: finalObject };
3831
+ }
3832
+ };
3833
+
3514
3834
  //#endregion
3515
3835
  //#region src/utils/mergeClassnames.ts
3516
3836
  const joinClassnamesByName = (name, args) => clsx(args.map((c) => clsx(c?.[name])));
@@ -3538,6 +3858,9 @@ const mergeClassnames = (...args) => ({
3538
3858
  dragHandle: joinClassnamesByName("dragHandle", args),
3539
3859
  lockRule: joinClassnamesByName("lockRule", args),
3540
3860
  lockGroup: joinClassnamesByName("lockGroup", args),
3861
+ muteRule: joinClassnamesByName("muteRule", args),
3862
+ muteGroup: joinClassnamesByName("muteGroup", args),
3863
+ muted: joinClassnamesByName("muted", args),
3541
3864
  valueSource: joinClassnamesByName("valueSource", args),
3542
3865
  actionElement: joinClassnamesByName("actionElement", args),
3543
3866
  valueSelector: joinClassnamesByName("valueSelector", args),
@@ -3557,21 +3880,6 @@ const mergeClassnames = (...args) => ({
3557
3880
  hasSubQuery: joinClassnamesByName("hasSubQuery", args)
3558
3881
  });
3559
3882
 
3560
- //#endregion
3561
- //#region src/utils/objectUtils.ts
3562
- /**
3563
- * A strongly-typed version of `Object.keys()`.
3564
- *
3565
- * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
3566
- */
3567
- const objectKeys = Object.keys;
3568
- /**
3569
- * A strongly-typed version of `Object.entries()`.
3570
- *
3571
- * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)
3572
- */
3573
- const objectEntries = Object.entries;
3574
-
3575
3883
  //#endregion
3576
3884
  //#region src/utils/prepareQueryObjects.ts
3577
3885
  /**
@@ -3603,28 +3911,21 @@ const regenerateID = (rule, { idGenerator = generateID } = {}) => structuredClon
3603
3911
  id: idGenerator()
3604
3912
  });
3605
3913
  /**
3606
- * Recursively generates new `id` properties for a group and all its rules and subgroups.
3914
+ * Recursively generates new `id` properties for a rule group and all its rules and subgroups.
3607
3915
  */
3608
- const regenerateIDs = (ruleOrGroup, { idGenerator = generateID } = {}) => {
3609
- if (!isPojo(ruleOrGroup)) return ruleOrGroup;
3610
- if (!isRuleGroup(ruleOrGroup)) return structuredClone({
3611
- ...ruleOrGroup,
3916
+ const regenerateIDs = (subject, { idGenerator = generateID } = {}) => {
3917
+ if (!isPojo(subject)) return subject;
3918
+ if (!isRuleGroup(subject)) return structuredClone({
3919
+ ...subject,
3612
3920
  id: idGenerator()
3613
3921
  });
3614
- if (isRuleGroupType(ruleOrGroup)) {
3615
- const rules$1 = ruleOrGroup.rules.map((r) => isRuleGroup(r) ? regenerateIDs(r, { idGenerator }) : regenerateID(r, { idGenerator }));
3616
- return {
3617
- ...ruleOrGroup,
3618
- id: idGenerator(),
3619
- rules: rules$1
3620
- };
3621
- }
3622
- const rules = ruleOrGroup.rules.map((r) => typeof r === "string" ? r : isRuleGroup(r) ? regenerateIDs(r, { idGenerator }) : regenerateID(r, { idGenerator }));
3623
- return {
3624
- ...ruleOrGroup,
3625
- id: idGenerator(),
3626
- rules
3922
+ const newGroup = {
3923
+ ...subject,
3924
+ id: idGenerator()
3627
3925
  };
3926
+ // istanbul ignore else
3927
+ if (Array.isArray(newGroup.rules)) newGroup.rules = subject.rules.map((r) => typeof r === "string" ? r : isRuleGroup(r) ? regenerateIDs(r, { idGenerator }) : regenerateID(r, { idGenerator }));
3928
+ return newGroup;
3628
3929
  };
3629
3930
 
3630
3931
  //#endregion
@@ -3688,12 +3989,11 @@ const update = (query, prop, value, pathOrID, { resetOnFieldChange = true, reset
3688
3989
  resetValueSource = true;
3689
3990
  resetValue = true;
3690
3991
  }
3691
- const valueSources = getValueSourcesUtil({
3992
+ const defaultValueSource = getFirstOption(getValueSourcesUtil({
3692
3993
  name: ruleOrGroup.field,
3693
3994
  value: ruleOrGroup.field,
3694
3995
  label: ""
3695
- }, ruleOrGroup.operator, getValueSources);
3696
- const defaultValueSource = getFirstOption(valueSources);
3996
+ }, ruleOrGroup.operator, getValueSources));
3697
3997
  if (resetValueSource && ruleOrGroup.valueSource && defaultValueSource !== ruleOrGroup.valueSource || prop === "valueSource" && value !== ruleOrGroup.valueSource) {
3698
3998
  resetValue = !!ruleOrGroup.valueSource || !ruleOrGroup.valueSource && value !== defaultValueSource;
3699
3999
  ruleOrGroup.valueSource = resetValueSource ? defaultValueSource : value;
@@ -3738,8 +4038,7 @@ const getNextPath = (query, currentPath, newPathOrShiftDirection) => {
3738
4038
  return [...getParentPath(parentPath), parentPath.at(-1) + 1];
3739
4039
  } else {
3740
4040
  const evaluationPath = [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 2 : 1)];
3741
- const entityToEvaluate = findPath(evaluationPath, query);
3742
- if (isRuleGroup(entityToEvaluate)) return [...evaluationPath, 0];
4041
+ if (isRuleGroup(findPath(evaluationPath, query))) return [...evaluationPath, 0];
3743
4042
  else return [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 3 : 2)];
3744
4043
  }
3745
4044
  return currentPath;
@@ -3773,8 +4072,7 @@ const move = (query, oldPathOrID, newPath, { clone = false, combinators = defaul
3773
4072
  const newNewPath = [...nextPath];
3774
4073
  const commonAncestorPath = getCommonAncestorPath(oldPath, nextPath);
3775
4074
  if (!clone && oldPath.length === commonAncestorPath.length + 1 && nextPath[commonAncestorPath.length] > oldPath[commonAncestorPath.length]) newNewPath[commonAncestorPath.length] -= independentCombinators ? 2 : 1;
3776
- const newNewParentPath = getParentPath(newNewPath);
3777
- const parentToInsertInto = findPath(newNewParentPath, draft);
4075
+ const parentToInsertInto = findPath(getParentPath(newNewPath), draft);
3778
4076
  const newIndex = newNewPath.at(-1);
3779
4077
  /**
3780
4078
  * This function 1) glosses over the need for type assertions to splice directly
@@ -3783,15 +4081,9 @@ const move = (query, oldPathOrID, newPath, { clone = false, combinators = defaul
3783
4081
  const insertRuleOrGroup = (...args) => parentToInsertInto.rules.splice(newIndex, 0, ...args);
3784
4082
  if (parentToInsertInto.rules.length === 0 || !independentCombinators) insertRuleOrGroup(ruleOrGroup);
3785
4083
  else if (newIndex === 0) if (ruleToRemoveIndex === 0 && oldNextCombinator) insertRuleOrGroup(ruleOrGroup, oldNextCombinator);
3786
- else {
3787
- const newNextCombinator = parentToInsertInto.rules[1] ?? oldPrevCombinator ?? getFirstOption(combinators);
3788
- insertRuleOrGroup(ruleOrGroup, newNextCombinator);
3789
- }
4084
+ else insertRuleOrGroup(ruleOrGroup, parentToInsertInto.rules[1] ?? oldPrevCombinator ?? getFirstOption(combinators));
3790
4085
  else if (oldPrevCombinator) insertRuleOrGroup(oldPrevCombinator, ruleOrGroup);
3791
- else {
3792
- const newPrevCombinator = parentToInsertInto.rules[newIndex - 2] ?? oldNextCombinator ?? getFirstOption(combinators);
3793
- insertRuleOrGroup(newPrevCombinator, ruleOrGroup);
3794
- }
4086
+ else insertRuleOrGroup(parentToInsertInto.rules[newIndex - 2] ?? oldNextCombinator ?? getFirstOption(combinators), ruleOrGroup);
3795
4087
  });
3796
4088
  };
3797
4089
  /**
@@ -3814,17 +4106,11 @@ const insert = (query, ruleOrGroup, path, { combinators = defaultCombinators, co
3814
4106
  if (parentToInsertInto.rules.length === 0 || !independentCombinators) insertRuleOrGroup(newIndex, rorg);
3815
4107
  else if (replace && independentCombinators) insertRuleOrGroup(newIndex + newIndex % 2, rorg);
3816
4108
  else if (newIndex === 0) if (rorg.path?.at(-1) === 0 && combinatorSucceeding) insertRuleOrGroup(newIndex, rorg, combinatorSucceeding);
3817
- else {
3818
- const newNextCombinator = parentToInsertInto.rules[1] ?? combinatorPreceding ?? getFirstOption(combinators);
3819
- insertRuleOrGroup(newIndex, rorg, newNextCombinator);
3820
- }
4109
+ else insertRuleOrGroup(newIndex, rorg, parentToInsertInto.rules[1] ?? combinatorPreceding ?? getFirstOption(combinators));
3821
4110
  else {
3822
4111
  const normalizedNewIndex = newIndex % 2 === 0 ? newIndex - 1 : newIndex;
3823
4112
  if (combinatorPreceding) insertRuleOrGroup(normalizedNewIndex, combinatorPreceding, rorg);
3824
- else {
3825
- const newPrevCombinator = parentToInsertInto.rules[normalizedNewIndex - 2] ?? combinatorSucceeding ?? getFirstOption(combinators);
3826
- insertRuleOrGroup(normalizedNewIndex, newPrevCombinator, rorg);
3827
- }
4113
+ else insertRuleOrGroup(normalizedNewIndex, parentToInsertInto.rules[normalizedNewIndex - 2] ?? combinatorSucceeding ?? getFirstOption(combinators), rorg);
3828
4114
  }
3829
4115
  });
3830
4116
  /**
@@ -3858,8 +4144,7 @@ const group = (query, sourcePathOrID, targetPathOrID, { clone = false, combinato
3858
4144
  const newNewPath = [...nextPath];
3859
4145
  const commonAncestorPath = getCommonAncestorPath(sourcePath, nextPath);
3860
4146
  if (!clone && sourcePath.length === commonAncestorPath.length + 1 && nextPath[commonAncestorPath.length] > sourcePath[commonAncestorPath.length]) newNewPath[commonAncestorPath.length] -= independentCombinators ? 2 : 1;
3861
- const newNewParentPath = getParentPath(newNewPath);
3862
- const parentOfTargetPath = findPath(newNewParentPath, draft);
4147
+ const parentOfTargetPath = findPath(getParentPath(newNewPath), draft);
3863
4148
  const targetPathIndex = newNewPath.at(-1);
3864
4149
  parentOfTargetPath.rules.splice(targetPathIndex, 1, prepareRuleOrGroup(independentCombinators ? { rules: [
3865
4150
  targetRuleOrGroup,
@@ -3938,6 +4223,7 @@ exports.defaultRuleProcessorSQL = defaultRuleProcessorSQL;
3938
4223
  exports.defaultRuleProcessorSequelize = defaultRuleProcessorSequelize;
3939
4224
  exports.defaultRuleProcessorSpEL = defaultRuleProcessorSpEL;
3940
4225
  exports.defaultSpELValueProcessor = defaultSpELValueProcessor;
4226
+ exports.defaultTranslations = defaultTranslations;
3941
4227
  exports.defaultValidator = defaultValidator;
3942
4228
  exports.defaultValueProcessor = defaultValueProcessor;
3943
4229
  exports.defaultValueProcessorByRule = defaultValueProcessorByRule;
@@ -3983,6 +4269,7 @@ exports.isRuleGroup = isRuleGroup;
3983
4269
  exports.isRuleGroupType = isRuleGroupType;
3984
4270
  exports.isRuleGroupTypeIC = isRuleGroupTypeIC;
3985
4271
  exports.isRuleOrGroupValid = isRuleOrGroupValid;
4272
+ exports.isRuleType = isRuleType;
3986
4273
  exports.isValidValue = isValidValue;
3987
4274
  exports.isValidationResult = isValidationResult;
3988
4275
  exports.isValueProcessorLegacy = isValueProcessorLegacy;
@@ -3990,6 +4277,8 @@ exports.joinWith = joinWith;
3990
4277
  exports.jsonLogicAdditionalOperators = jsonLogicAdditionalOperators;
3991
4278
  exports.lc = lc;
3992
4279
  exports.mapSQLOperator = mapSQLOperator;
4280
+ exports.mergeAnyTranslation = mergeAnyTranslation;
4281
+ exports.mergeAnyTranslations = mergeAnyTranslations;
3993
4282
  exports.mergeClassnames = mergeClassnames;
3994
4283
  exports.mongoDbFallback = mongoDbFallback;
3995
4284
  exports.mongoOperators = mongoOperators;
@@ -4004,6 +4293,7 @@ exports.objectKeys = objectKeys;
4004
4293
  exports.parseNumber = parseNumber;
4005
4294
  exports.pathIsDisabled = pathIsDisabled;
4006
4295
  exports.pathsAreEqual = pathsAreEqual;
4296
+ exports.prepareOptionList = prepareOptionList;
4007
4297
  exports.prepareRule = prepareRule;
4008
4298
  exports.prepareRuleGroup = prepareRuleGroup;
4009
4299
  exports.prepareRuleOrGroup = prepareRuleOrGroup;