@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.
- package/dist/arrayUtils-C9sO4qLO.mjs +50 -0
- package/dist/arrayUtils-C9sO4qLO.mjs.map +1 -0
- package/dist/arrayUtils-QxZOZTf6.js +73 -0
- package/dist/arrayUtils-QxZOZTf6.js.map +1 -0
- package/dist/basic-BmpEwexQ.d.mts +363 -0
- package/dist/basic-CDDA-KZa.d.ts +363 -0
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +569 -1252
- package/dist/cjs/react-querybuilder_core.cjs.development.js +430 -140
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +569 -1252
- package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
- package/dist/convertQuery-BUgyz1GA.mjs +75 -0
- package/dist/convertQuery-BUgyz1GA.mjs.map +1 -0
- package/dist/export-Ccjfea21.d.mts +453 -0
- package/dist/{export-DyrnTh6K.d.ts → export-GUuxJ7zR.d.ts} +3 -2
- package/dist/formatQuery.d.mts +668 -0
- package/dist/formatQuery.d.ts +3 -2
- package/dist/formatQuery.js +217 -87
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +2496 -0
- package/dist/formatQuery.mjs.map +1 -0
- package/dist/{import-Cksobmln.d.ts → import-D-hm1phN.d.ts} +2 -2
- package/dist/import-Dxevzw_-.d.mts +28 -0
- package/dist/isRuleGroup-CGe_rb2w.mjs +40 -0
- package/dist/isRuleGroup-CGe_rb2w.mjs.map +1 -0
- package/dist/isRuleGroup-DqAs2x4E.js.map +1 -1
- package/dist/{optGroupUtils-CXLgyg2i.js → optGroupUtils-B0hTpodo.js} +114 -1
- package/dist/optGroupUtils-B0hTpodo.js.map +1 -0
- package/dist/optGroupUtils-DrubUpx0.mjs +185 -0
- package/dist/optGroupUtils-DrubUpx0.mjs.map +1 -0
- package/dist/parseCEL.d.mts +315 -0
- package/dist/parseCEL.d.ts +292 -11
- package/dist/parseCEL.js +114 -30
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +2631 -0
- package/dist/parseCEL.mjs.map +1 -0
- package/dist/parseJSONata.d.mts +37 -0
- package/dist/parseJSONata.d.ts +3 -2
- package/dist/parseJSONata.js +49 -77
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +267 -0
- package/dist/parseJSONata.mjs.map +1 -0
- package/dist/parseJsonLogic.d.mts +37 -0
- package/dist/parseJsonLogic.d.ts +4 -3
- package/dist/parseJsonLogic.js +5 -6
- package/dist/parseJsonLogic.js.map +1 -1
- package/dist/parseJsonLogic.mjs +190 -0
- package/dist/parseJsonLogic.mjs.map +1 -0
- package/dist/parseMongoDB.d.mts +80 -0
- package/dist/parseMongoDB.d.ts +3 -2
- package/dist/parseMongoDB.js +15 -16
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +266 -0
- package/dist/parseMongoDB.mjs.map +1 -0
- package/dist/parseNumber-B_-sR6d5.mjs +24 -0
- package/dist/parseNumber-B_-sR6d5.mjs.map +1 -0
- package/dist/{parseNumber-Bcys1kOH.js → parseNumber-D4iQDxK-.js} +1 -1
- package/dist/{parseNumber-Bcys1kOH.js.map → parseNumber-D4iQDxK-.js.map} +1 -1
- package/dist/parseSQL.d.mts +38 -0
- package/dist/parseSQL.d.ts +3 -2
- package/dist/parseSQL.js +11 -15
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +6622 -0
- package/dist/parseSQL.mjs.map +1 -0
- package/dist/parseSpEL.d.mts +35 -0
- package/dist/parseSpEL.d.ts +3 -2
- package/dist/parseSpEL.js +7 -9
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +272 -0
- package/dist/parseSpEL.mjs.map +1 -0
- package/dist/{prepareQueryObjects-BqFEs4eV.js → prepareQueryObjects-BOUWfel5.js} +4 -5
- package/dist/prepareQueryObjects-BOUWfel5.js.map +1 -0
- package/dist/prepareQueryObjects-CJNpnGcJ.mjs +153 -0
- package/dist/prepareQueryObjects-CJNpnGcJ.mjs.map +1 -0
- package/dist/query-builder-layout.css +1 -1
- package/dist/query-builder-layout.css.map +1 -1
- package/dist/query-builder.css +1 -1
- package/dist/query-builder.css.map +1 -1
- package/dist/react-querybuilder_core.d.mts +569 -1252
- package/dist/react-querybuilder_core.legacy-esm.d.ts +569 -1252
- package/dist/react-querybuilder_core.legacy-esm.js +430 -136
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +426 -141
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +569 -1252
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/styles/_layout.scss +61 -17
- package/dist/styles/_main.scss +17 -4
- package/dist/{transformQuery-FL_nlpp5.js → transformQuery-CWDPogO5.js} +1 -1
- package/dist/{transformQuery-FL_nlpp5.js.map → transformQuery-CWDPogO5.js.map} +1 -1
- package/dist/transformQuery-DHvtgDgZ.mjs +41 -0
- package/dist/transformQuery-DHvtgDgZ.mjs.map +1 -0
- package/dist/transformQuery.d.mts +118 -0
- package/dist/transformQuery.d.ts +1 -1
- package/dist/transformQuery.js +1 -1
- package/dist/transformQuery.mjs +4 -0
- package/package.json +78 -28
- package/dist/arrayUtils-D5EoIsKP.js +0 -164
- package/dist/arrayUtils-D5EoIsKP.js.map +0 -1
- package/dist/basic-C8xXKHIA.d.ts +0 -1235
- package/dist/objectUtils-BBZSfZJz.js +0 -17
- package/dist/objectUtils-BBZSfZJz.js.map +0 -1
- package/dist/optGroupUtils-CXLgyg2i.js.map +0 -1
- package/dist/prepareQueryObjects-BqFEs4eV.js.map +0 -1
|
@@ -65,6 +65,108 @@ const defaultPlaceholderValueLabel = defaultPlaceholderLabel;
|
|
|
65
65
|
*/
|
|
66
66
|
const defaultPlaceholderValueGroupLabel = defaultPlaceholderLabel;
|
|
67
67
|
/**
|
|
68
|
+
* Default configuration of translatable strings.
|
|
69
|
+
*
|
|
70
|
+
* @group Defaults
|
|
71
|
+
*/
|
|
72
|
+
const defaultTranslations = {
|
|
73
|
+
fields: {
|
|
74
|
+
title: "Field",
|
|
75
|
+
placeholderName: defaultPlaceholderFieldName,
|
|
76
|
+
placeholderLabel: defaultPlaceholderFieldLabel,
|
|
77
|
+
placeholderGroupLabel: defaultPlaceholderFieldGroupLabel
|
|
78
|
+
},
|
|
79
|
+
operators: {
|
|
80
|
+
title: "Operator",
|
|
81
|
+
placeholderName: defaultPlaceholderOperatorName,
|
|
82
|
+
placeholderLabel: defaultPlaceholderOperatorLabel,
|
|
83
|
+
placeholderGroupLabel: defaultPlaceholderOperatorGroupLabel
|
|
84
|
+
},
|
|
85
|
+
values: {
|
|
86
|
+
title: "Values",
|
|
87
|
+
placeholderName: defaultPlaceholderValueName,
|
|
88
|
+
placeholderLabel: defaultPlaceholderValueLabel,
|
|
89
|
+
placeholderGroupLabel: defaultPlaceholderValueGroupLabel
|
|
90
|
+
},
|
|
91
|
+
matchMode: { title: "Match mode" },
|
|
92
|
+
matchThreshold: { title: "Match threshold" },
|
|
93
|
+
value: { title: "Value" },
|
|
94
|
+
removeRule: {
|
|
95
|
+
label: "⨯",
|
|
96
|
+
title: "Remove rule"
|
|
97
|
+
},
|
|
98
|
+
removeGroup: {
|
|
99
|
+
label: "⨯",
|
|
100
|
+
title: "Remove group"
|
|
101
|
+
},
|
|
102
|
+
addRule: {
|
|
103
|
+
label: "+ Rule",
|
|
104
|
+
title: "Add rule"
|
|
105
|
+
},
|
|
106
|
+
addGroup: {
|
|
107
|
+
label: "+ Group",
|
|
108
|
+
title: "Add group"
|
|
109
|
+
},
|
|
110
|
+
combinators: { title: "Combinator" },
|
|
111
|
+
notToggle: {
|
|
112
|
+
label: "Not",
|
|
113
|
+
title: "Invert this group"
|
|
114
|
+
},
|
|
115
|
+
cloneRule: {
|
|
116
|
+
label: "⧉",
|
|
117
|
+
title: "Clone rule"
|
|
118
|
+
},
|
|
119
|
+
cloneRuleGroup: {
|
|
120
|
+
label: "⧉",
|
|
121
|
+
title: "Clone group"
|
|
122
|
+
},
|
|
123
|
+
shiftActionUp: {
|
|
124
|
+
label: "˄",
|
|
125
|
+
title: "Shift up"
|
|
126
|
+
},
|
|
127
|
+
shiftActionDown: {
|
|
128
|
+
label: "˅",
|
|
129
|
+
title: "Shift down"
|
|
130
|
+
},
|
|
131
|
+
dragHandle: {
|
|
132
|
+
label: "⁞⁞",
|
|
133
|
+
title: "Drag handle"
|
|
134
|
+
},
|
|
135
|
+
lockRule: {
|
|
136
|
+
label: "🔓",
|
|
137
|
+
title: "Lock rule"
|
|
138
|
+
},
|
|
139
|
+
lockGroup: {
|
|
140
|
+
label: "🔓",
|
|
141
|
+
title: "Lock group"
|
|
142
|
+
},
|
|
143
|
+
lockRuleDisabled: {
|
|
144
|
+
label: "🔒",
|
|
145
|
+
title: "Unlock rule"
|
|
146
|
+
},
|
|
147
|
+
lockGroupDisabled: {
|
|
148
|
+
label: "🔒",
|
|
149
|
+
title: "Unlock group"
|
|
150
|
+
},
|
|
151
|
+
muteRule: {
|
|
152
|
+
label: "🔊",
|
|
153
|
+
title: "Mute rule"
|
|
154
|
+
},
|
|
155
|
+
muteGroup: {
|
|
156
|
+
label: "🔊",
|
|
157
|
+
title: "Mute group"
|
|
158
|
+
},
|
|
159
|
+
unmuteRule: {
|
|
160
|
+
label: "🔇",
|
|
161
|
+
title: "Unmute rule"
|
|
162
|
+
},
|
|
163
|
+
unmuteGroup: {
|
|
164
|
+
label: "🔇",
|
|
165
|
+
title: "Unmute group"
|
|
166
|
+
},
|
|
167
|
+
valueSourceSelector: { title: "Value source" }
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
68
170
|
* Default character used to `.join` and `.split` arrays.
|
|
69
171
|
*
|
|
70
172
|
* @group Defaults
|
|
@@ -313,8 +415,11 @@ const standardClassnames = {
|
|
|
313
415
|
dndDropNotAllowed: "dndDropNotAllowed",
|
|
314
416
|
dragHandle: "queryBuilder-dragHandle",
|
|
315
417
|
disabled: "queryBuilder-disabled",
|
|
418
|
+
muted: "queryBuilder-muted",
|
|
316
419
|
lockRule: "rule-lock",
|
|
317
420
|
lockGroup: "ruleGroup-lock",
|
|
421
|
+
muteRule: "rule-mute",
|
|
422
|
+
muteGroup: "ruleGroup-mute",
|
|
318
423
|
valueSource: "rule-valueSource",
|
|
319
424
|
valueListItem: "rule-value-list-item",
|
|
320
425
|
branches: "queryBuilder-branches",
|
|
@@ -349,6 +454,9 @@ const defaultControlClassnames = {
|
|
|
349
454
|
dragHandle: "",
|
|
350
455
|
lockRule: "",
|
|
351
456
|
lockGroup: "",
|
|
457
|
+
muteRule: "",
|
|
458
|
+
muteGroup: "",
|
|
459
|
+
muted: "",
|
|
352
460
|
valueSource: "",
|
|
353
461
|
actionElement: "",
|
|
354
462
|
valueSelector: "",
|
|
@@ -399,6 +507,8 @@ const TestID = {
|
|
|
399
507
|
dragHandle: "drag-handle",
|
|
400
508
|
lockRule: "lock-rule",
|
|
401
509
|
lockGroup: "lock-group",
|
|
510
|
+
muteRule: "mute-rule",
|
|
511
|
+
muteGroup: "mute-group",
|
|
402
512
|
valueSourceSelector: "value-source-selector",
|
|
403
513
|
matchModeEditor: "match-mode-editor"
|
|
404
514
|
};
|
|
@@ -498,6 +608,11 @@ function toVal(mix) {
|
|
|
498
608
|
}
|
|
499
609
|
return str;
|
|
500
610
|
}
|
|
611
|
+
/**
|
|
612
|
+
* Vendored/adapted version of the `clsx` package.
|
|
613
|
+
*
|
|
614
|
+
* **NOTE:** Prefer the official package from npm outside the context of React Query Builder.
|
|
615
|
+
*/
|
|
501
616
|
// istanbul ignore next
|
|
502
617
|
function clsx(...args) {
|
|
503
618
|
let i = 0;
|
|
@@ -536,6 +651,10 @@ const nullOrUndefinedOrEmpty = (value) => value === null || value === void 0 ||
|
|
|
536
651
|
//#endregion
|
|
537
652
|
//#region src/utils/isRuleGroup.ts
|
|
538
653
|
/**
|
|
654
|
+
* Determines if an object is a {@link RuleType} (only checks for a `field` property).
|
|
655
|
+
*/
|
|
656
|
+
const isRuleType = (s) => isPojo(s) && "field" in s && typeof s.field === "string";
|
|
657
|
+
/**
|
|
539
658
|
* Determines if an object is a {@link RuleGroupType} or {@link RuleGroupTypeIC}.
|
|
540
659
|
*/
|
|
541
660
|
const isRuleGroup = (rg) => isPojo(rg) && Array.isArray(rg.rules);
|
|
@@ -549,7 +668,7 @@ const isRuleGroupType = (rg) => isRuleGroup(rg) && typeof rg.combinator === "str
|
|
|
549
668
|
const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0;
|
|
550
669
|
|
|
551
670
|
//#endregion
|
|
552
|
-
//#region \0@oxc-project+runtime@0.
|
|
671
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/typeof.js
|
|
553
672
|
function _typeof(o) {
|
|
554
673
|
"@babel/helpers - typeof";
|
|
555
674
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
@@ -560,7 +679,7 @@ function _typeof(o) {
|
|
|
560
679
|
}
|
|
561
680
|
|
|
562
681
|
//#endregion
|
|
563
|
-
//#region \0@oxc-project+runtime@0.
|
|
682
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/toPrimitive.js
|
|
564
683
|
function toPrimitive(t, r) {
|
|
565
684
|
if ("object" != _typeof(t) || !t) return t;
|
|
566
685
|
var e = t[Symbol.toPrimitive];
|
|
@@ -573,14 +692,14 @@ function toPrimitive(t, r) {
|
|
|
573
692
|
}
|
|
574
693
|
|
|
575
694
|
//#endregion
|
|
576
|
-
//#region \0@oxc-project+runtime@0.
|
|
695
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/toPropertyKey.js
|
|
577
696
|
function toPropertyKey(t) {
|
|
578
697
|
var i = toPrimitive(t, "string");
|
|
579
698
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
580
699
|
}
|
|
581
700
|
|
|
582
701
|
//#endregion
|
|
583
|
-
//#region \0@oxc-project+runtime@0.
|
|
702
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/defineProperty.js
|
|
584
703
|
function _defineProperty(e, r, t) {
|
|
585
704
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
586
705
|
value: t,
|
|
@@ -591,7 +710,7 @@ function _defineProperty(e, r, t) {
|
|
|
591
710
|
}
|
|
592
711
|
|
|
593
712
|
//#endregion
|
|
594
|
-
//#region \0@oxc-project+runtime@0.
|
|
713
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/objectSpread2.js
|
|
595
714
|
function ownKeys(e, r) {
|
|
596
715
|
var t = Object.keys(e);
|
|
597
716
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -615,7 +734,7 @@ function _objectSpread2(e) {
|
|
|
615
734
|
}
|
|
616
735
|
|
|
617
736
|
//#endregion
|
|
618
|
-
//#region \0@oxc-project+runtime@0.
|
|
737
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/objectWithoutPropertiesLoose.js
|
|
619
738
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
620
739
|
if (null == r) return {};
|
|
621
740
|
var t = {};
|
|
@@ -627,7 +746,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
627
746
|
}
|
|
628
747
|
|
|
629
748
|
//#endregion
|
|
630
|
-
//#region \0@oxc-project+runtime@0.
|
|
749
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/objectWithoutProperties.js
|
|
631
750
|
function _objectWithoutProperties(e, t) {
|
|
632
751
|
if (null == e) return {};
|
|
633
752
|
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
@@ -745,6 +864,21 @@ const defaultValidator = (query) => {
|
|
|
745
864
|
return result;
|
|
746
865
|
};
|
|
747
866
|
|
|
867
|
+
//#endregion
|
|
868
|
+
//#region src/utils/objectUtils.ts
|
|
869
|
+
/**
|
|
870
|
+
* A strongly-typed version of `Object.keys()`.
|
|
871
|
+
*
|
|
872
|
+
* [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
|
|
873
|
+
*/
|
|
874
|
+
const objectKeys = Object.keys;
|
|
875
|
+
/**
|
|
876
|
+
* A strongly-typed version of `Object.entries()`.
|
|
877
|
+
*
|
|
878
|
+
* [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)
|
|
879
|
+
*/
|
|
880
|
+
const objectEntries = Object.entries;
|
|
881
|
+
|
|
748
882
|
//#endregion
|
|
749
883
|
//#region src/utils/optGroupUtils.ts
|
|
750
884
|
const isOptionWithName = (opt) => isPojo(opt) && "name" in opt && typeof opt.name === "string";
|
|
@@ -932,6 +1066,44 @@ const uniqOptList = (originalArray) => {
|
|
|
932
1066
|
if (isFlexibleOptionGroupArray(originalArray)) return uniqOptGroups(originalArray);
|
|
933
1067
|
return uniqByIdentifier(originalArray.map((o) => toFullOption(o)));
|
|
934
1068
|
};
|
|
1069
|
+
const prepareOptionList = (props) => {
|
|
1070
|
+
// istanbul ignore next
|
|
1071
|
+
const { optionList: optionListPropOriginal, baseOption = {}, labelMap = {}, placeholder: { placeholderName = defaultPlaceholderName, placeholderLabel = defaultPlaceholderLabel, placeholderGroupLabel = defaultPlaceholderLabel } = {}, autoSelectOption = true } = props;
|
|
1072
|
+
const defaultOption = {
|
|
1073
|
+
id: placeholderName,
|
|
1074
|
+
name: placeholderName,
|
|
1075
|
+
value: placeholderName,
|
|
1076
|
+
label: placeholderLabel
|
|
1077
|
+
};
|
|
1078
|
+
const optionsProp = optionListPropOriginal !== null && optionListPropOriginal !== void 0 ? optionListPropOriginal : [defaultOption];
|
|
1079
|
+
let optionList = [];
|
|
1080
|
+
const opts = Array.isArray(optionsProp) ? toFullOptionList(optionsProp, baseOption, labelMap) : objectKeys(toFullOptionMap(optionsProp, baseOption)).map((opt) => _objectSpread2(_objectSpread2({}, optionsProp[opt]), {}, {
|
|
1081
|
+
name: opt,
|
|
1082
|
+
value: opt
|
|
1083
|
+
})).sort((a, b) => a.label.localeCompare(b.label));
|
|
1084
|
+
if (isFlexibleOptionGroupArray(opts)) optionList = autoSelectOption ? uniqOptGroups(opts) : uniqOptGroups([{
|
|
1085
|
+
label: placeholderGroupLabel,
|
|
1086
|
+
options: [defaultOption]
|
|
1087
|
+
}, ...opts]);
|
|
1088
|
+
else optionList = autoSelectOption ? uniqByIdentifier(opts) : uniqByIdentifier([defaultOption, ...opts]);
|
|
1089
|
+
let optionsMap = {};
|
|
1090
|
+
if (!Array.isArray(optionsProp)) {
|
|
1091
|
+
const op = toFullOptionMap(optionsProp, baseOption);
|
|
1092
|
+
optionsMap = autoSelectOption ? op : _objectSpread2(_objectSpread2({}, op), {}, { [placeholderName]: defaultOption });
|
|
1093
|
+
} else if (isFlexibleOptionGroupArray(optionList)) for (const og of optionList) for (const opt of og.options) {
|
|
1094
|
+
var _opt$value3;
|
|
1095
|
+
optionsMap[(_opt$value3 = opt.value) !== null && _opt$value3 !== void 0 ? _opt$value3 : opt.name] = toFullOption(opt, baseOption);
|
|
1096
|
+
}
|
|
1097
|
+
else for (const opt of optionList) {
|
|
1098
|
+
var _opt$value4;
|
|
1099
|
+
optionsMap[(_opt$value4 = opt.value) !== null && _opt$value4 !== void 0 ? _opt$value4 : opt.name] = toFullOption(opt, baseOption);
|
|
1100
|
+
}
|
|
1101
|
+
return {
|
|
1102
|
+
defaultOption,
|
|
1103
|
+
optionList,
|
|
1104
|
+
optionsMap
|
|
1105
|
+
};
|
|
1106
|
+
};
|
|
935
1107
|
|
|
936
1108
|
//#endregion
|
|
937
1109
|
//#region src/utils/filterFieldsByComparator.ts
|
|
@@ -1021,9 +1193,11 @@ function transformQuery(query, options = {}) {
|
|
|
1021
1193
|
const isValidationResult = (vr) => isPojo(vr) && typeof vr.valid === "boolean";
|
|
1022
1194
|
/**
|
|
1023
1195
|
* Determines if a rule or group is valid based on a validation result (if defined)
|
|
1024
|
-
* or a validator function. Returns `true` if neither are defined
|
|
1196
|
+
* or a validator function. Returns `true` if neither are defined and the `muted`
|
|
1197
|
+
* property is not `true`.
|
|
1025
1198
|
*/
|
|
1026
1199
|
const isRuleOrGroupValid = (rg, validationResult, validator) => {
|
|
1200
|
+
if (rg.muted) return false;
|
|
1027
1201
|
if (typeof validationResult === "boolean") return validationResult;
|
|
1028
1202
|
if (isValidationResult(validationResult)) return validationResult.valid;
|
|
1029
1203
|
if (typeof validator === "function" && !isRuleGroup(rg)) {
|
|
@@ -1293,19 +1467,45 @@ const defaultRuleGroupProcessorCEL = (ruleGroup, options) => {
|
|
|
1293
1467
|
const processRuleGroup = (rg, outermost) => {
|
|
1294
1468
|
var _rg$id;
|
|
1295
1469
|
if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : ""])) return outermost ? fallbackExpression : "";
|
|
1296
|
-
const
|
|
1470
|
+
const processedRules = [];
|
|
1471
|
+
let precedingCombinator = "";
|
|
1472
|
+
let firstRule = true;
|
|
1473
|
+
for (const rule of rg.rules) {
|
|
1297
1474
|
var _rule$valueSource;
|
|
1298
|
-
if (typeof rule === "string")
|
|
1299
|
-
|
|
1475
|
+
if (typeof rule === "string") {
|
|
1476
|
+
precedingCombinator = celCombinatorMap[rule];
|
|
1477
|
+
continue;
|
|
1478
|
+
}
|
|
1479
|
+
if (isRuleGroup(rule)) {
|
|
1480
|
+
const processedGroup = processRuleGroup(rule);
|
|
1481
|
+
if (processedGroup) {
|
|
1482
|
+
if (!firstRule && precedingCombinator) {
|
|
1483
|
+
processedRules.push(precedingCombinator);
|
|
1484
|
+
precedingCombinator = "";
|
|
1485
|
+
}
|
|
1486
|
+
firstRule = false;
|
|
1487
|
+
processedRules.push(processedGroup);
|
|
1488
|
+
}
|
|
1489
|
+
continue;
|
|
1490
|
+
}
|
|
1300
1491
|
const [validationResult, fieldValidator] = validateRule(rule);
|
|
1301
|
-
if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName)
|
|
1492
|
+
if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
|
|
1302
1493
|
const fieldData = getOption(fields, rule.field);
|
|
1303
|
-
|
|
1494
|
+
const processedRule = ruleProcessor(rule, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1304
1495
|
parseNumbers: getParseNumberBoolean(fieldData === null || fieldData === void 0 ? void 0 : fieldData.inputType),
|
|
1305
1496
|
escapeQuotes: ((_rule$valueSource = rule.valueSource) !== null && _rule$valueSource !== void 0 ? _rule$valueSource : "value") === "value",
|
|
1306
1497
|
fieldData
|
|
1307
1498
|
}));
|
|
1308
|
-
|
|
1499
|
+
if (processedRule) {
|
|
1500
|
+
if (!firstRule && precedingCombinator) {
|
|
1501
|
+
processedRules.push(precedingCombinator);
|
|
1502
|
+
precedingCombinator = "";
|
|
1503
|
+
}
|
|
1504
|
+
firstRule = false;
|
|
1505
|
+
processedRules.push(processedRule);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
const expression = processedRules.join(isRuleGroupType(rg) ? ` ${celCombinatorMap[rg.combinator]} ` : " ");
|
|
1309
1509
|
const [prefix, suffix] = rg.not || !outermost ? [`${rg.not ? "!" : ""}(`, ")"] : ["", ""];
|
|
1310
1510
|
return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
|
|
1311
1511
|
};
|
|
@@ -1332,8 +1532,7 @@ const defaultRuleProcessorCEL = (rule, opts = {}) => {
|
|
|
1332
1532
|
else if (matchEval) {
|
|
1333
1533
|
const { mode, threshold } = matchEval;
|
|
1334
1534
|
const arrayElementAlias = "elem_alias";
|
|
1335
|
-
const
|
|
1336
|
-
const nestedArrayFilter = defaultRuleGroupProcessorCEL(celQuery, opts);
|
|
1535
|
+
const nestedArrayFilter = defaultRuleGroupProcessorCEL(transformQuery(rule.value, { ruleProcessor: (r) => _objectSpread2(_objectSpread2({}, r), {}, { field: `${arrayElementAlias}${r.field ? `.${r.field}` : ""}` }) }), opts);
|
|
1337
1536
|
switch (mode) {
|
|
1338
1537
|
case "all": return `${field}.all(${arrayElementAlias}, ${nestedArrayFilter})`;
|
|
1339
1538
|
case "none":
|
|
@@ -1367,8 +1566,7 @@ const defaultRuleProcessorCEL = (rule, opts = {}) => {
|
|
|
1367
1566
|
case "in":
|
|
1368
1567
|
case "notin": {
|
|
1369
1568
|
const [prefix, suffix] = shouldNegate$2(operatorTL) ? ["!(", ")"] : ["", ""];
|
|
1370
|
-
|
|
1371
|
-
return `${prefix}${field} in [${valueAsArray.map((val) => valueIsField || shouldRenderAsNumber(val, parseNumbers) ? `${trimIfString(val)}` : `"${escapeDoubleQuotes(val, escapeQuotes)}"`).join(", ")}]${suffix}`;
|
|
1569
|
+
return `${prefix}${field} in [${toArray(value).map((val) => valueIsField || shouldRenderAsNumber(val, parseNumbers) ? `${trimIfString(val)}` : `"${escapeDoubleQuotes(val, escapeQuotes)}"`).join(", ")}]${suffix}`;
|
|
1372
1570
|
}
|
|
1373
1571
|
case "between":
|
|
1374
1572
|
case "notbetween": {
|
|
@@ -1575,19 +1773,45 @@ const defaultRuleGroupProcessorSpEL = (ruleGroup, options) => {
|
|
|
1575
1773
|
const processRuleGroup = (rg, outermost) => {
|
|
1576
1774
|
var _rg$id;
|
|
1577
1775
|
if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : ""])) return outermost ? fallbackExpression : "";
|
|
1578
|
-
const
|
|
1776
|
+
const processedRules = [];
|
|
1777
|
+
let precedingCombinator = "";
|
|
1778
|
+
let firstRule = true;
|
|
1779
|
+
for (const rule of rg.rules) {
|
|
1579
1780
|
var _rule$valueSource;
|
|
1580
|
-
if (typeof rule === "string")
|
|
1581
|
-
|
|
1781
|
+
if (typeof rule === "string") {
|
|
1782
|
+
precedingCombinator = rule;
|
|
1783
|
+
continue;
|
|
1784
|
+
}
|
|
1785
|
+
if (isRuleGroup(rule)) {
|
|
1786
|
+
const processedGroup = processRuleGroup(rule);
|
|
1787
|
+
if (processedGroup) {
|
|
1788
|
+
if (!firstRule && precedingCombinator) {
|
|
1789
|
+
processedRules.push(precedingCombinator);
|
|
1790
|
+
precedingCombinator = "";
|
|
1791
|
+
}
|
|
1792
|
+
firstRule = false;
|
|
1793
|
+
processedRules.push(processedGroup);
|
|
1794
|
+
}
|
|
1795
|
+
continue;
|
|
1796
|
+
}
|
|
1582
1797
|
const [validationResult, fieldValidator] = validateRule(rule);
|
|
1583
|
-
if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName)
|
|
1798
|
+
if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
|
|
1584
1799
|
const fieldData = getOption(fields, rule.field);
|
|
1585
|
-
|
|
1800
|
+
const processedRule = ruleProcessor(rule, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1586
1801
|
parseNumbers: getParseNumberBoolean(fieldData === null || fieldData === void 0 ? void 0 : fieldData.inputType),
|
|
1587
1802
|
escapeQuotes: ((_rule$valueSource = rule.valueSource) !== null && _rule$valueSource !== void 0 ? _rule$valueSource : "value") === "value",
|
|
1588
1803
|
fieldData
|
|
1589
1804
|
}));
|
|
1590
|
-
|
|
1805
|
+
if (processedRule) {
|
|
1806
|
+
if (!firstRule && precedingCombinator) {
|
|
1807
|
+
processedRules.push(precedingCombinator);
|
|
1808
|
+
precedingCombinator = "";
|
|
1809
|
+
}
|
|
1810
|
+
firstRule = false;
|
|
1811
|
+
processedRules.push(processedRule);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
const expression = processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ");
|
|
1591
1815
|
const [prefix, suffix] = rg.not || !outermost ? [`${rg.not ? "!" : ""}(`, ")"] : ["", ""];
|
|
1592
1816
|
return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
|
|
1593
1817
|
};
|
|
@@ -1640,15 +1864,9 @@ const defaultRuleProcessorSpEL = (rule, opts = {}) => {
|
|
|
1640
1864
|
case "contains":
|
|
1641
1865
|
case "doesnotcontain": return wrapInNegation(`${field} matches ${valueIsField || useBareValue ? trimIfString(value) : `'${escapeSingleQuotes(value, escapeQuotes)}'`}`, shouldNegate$1(operatorTL));
|
|
1642
1866
|
case "beginswith":
|
|
1643
|
-
case "doesnotbeginwith": {
|
|
1644
|
-
const valueTL = valueIsField ? `'^'.concat(${trimIfString(value)})` : `'${typeof value === "string" && !value.startsWith("^") || useBareValue ? "^" : ""}${escapeSingleQuotes(value, escapeQuotes)}'`;
|
|
1645
|
-
return wrapInNegation(`${field} matches ${valueTL}`, shouldNegate$1(operatorTL));
|
|
1646
|
-
}
|
|
1867
|
+
case "doesnotbeginwith": return wrapInNegation(`${field} matches ${valueIsField ? `'^'.concat(${trimIfString(value)})` : `'${typeof value === "string" && !value.startsWith("^") || useBareValue ? "^" : ""}${escapeSingleQuotes(value, escapeQuotes)}'`}`, shouldNegate$1(operatorTL));
|
|
1647
1868
|
case "endswith":
|
|
1648
|
-
case "doesnotendwith": {
|
|
1649
|
-
const valueTL = valueIsField ? `${trimIfString(value)}.concat('$')` : `'${escapeSingleQuotes(value, escapeQuotes)}${typeof value === "string" && !value.endsWith("$") || useBareValue ? "$" : ""}'`;
|
|
1650
|
-
return wrapInNegation(`${field} matches ${valueTL}`, shouldNegate$1(operatorTL));
|
|
1651
|
-
}
|
|
1869
|
+
case "doesnotendwith": return wrapInNegation(`${field} matches ${valueIsField ? `${trimIfString(value)}.concat('$')` : `'${escapeSingleQuotes(value, escapeQuotes)}${typeof value === "string" && !value.endsWith("$") || useBareValue ? "$" : ""}'`}`, shouldNegate$1(operatorTL));
|
|
1652
1870
|
case "null": return `${field} == null`;
|
|
1653
1871
|
case "notnull": return `${field} != null`;
|
|
1654
1872
|
case "in":
|
|
@@ -1762,8 +1980,7 @@ const defaultRuleProcessorDrizzle = (rule, _options) => {
|
|
|
1762
1980
|
if (opts.preset !== "postgresql") return;
|
|
1763
1981
|
const { mode, threshold } = matchEval;
|
|
1764
1982
|
const arrayElementAlias = "elem_alias";
|
|
1765
|
-
const
|
|
1766
|
-
const nestedArrayFilter = defaultRuleGroupProcessorDrizzle(sqlQuery, _objectSpread2(_objectSpread2({}, opts), {}, { context: _objectSpread2(_objectSpread2({}, opts.context), {}, { useRawFields: true }) }));
|
|
1983
|
+
const nestedArrayFilter = defaultRuleGroupProcessorDrizzle(transformQuery(rule.value, { ruleProcessor: (r) => _objectSpread2(_objectSpread2({}, r), {}, { field: arrayElementAlias }) }), _objectSpread2(_objectSpread2({}, opts), {}, { context: _objectSpread2(_objectSpread2({}, opts.context), {}, { useRawFields: true }) }));
|
|
1767
1984
|
switch (mode) {
|
|
1768
1985
|
case "all": return sql`(select count(*) from unnest(${column}) as ${sql.raw(arrayElementAlias)} where ${nestedArrayFilter({}, drizzleOperators)}) = array_length(${column}, 1)`;
|
|
1769
1986
|
case "none": return sql`not exists (select 1 from unnest(${column}) as ${sql.raw(arrayElementAlias)} where ${nestedArrayFilter({}, drizzleOperators)})`;
|
|
@@ -1843,7 +2060,6 @@ const defaultRuleGroupProcessorDrizzle = (ruleGroup, options, _meta) => (columns
|
|
|
1843
2060
|
const { fields, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, validateRule, validationMap } = options;
|
|
1844
2061
|
if (!columns || !drizzleOperators) return;
|
|
1845
2062
|
const { and, not, or } = drizzleOperators;
|
|
1846
|
-
const query = isRuleGroupType(ruleGroup) ? ruleGroup : convertFromIC(ruleGroup);
|
|
1847
2063
|
const ruleProcessor = defaultRuleProcessorDrizzle;
|
|
1848
2064
|
const processRuleGroup = (rg, _outermost) => {
|
|
1849
2065
|
var _rg$id;
|
|
@@ -1866,7 +2082,7 @@ const defaultRuleGroupProcessorDrizzle = (ruleGroup, options, _meta) => (columns
|
|
|
1866
2082
|
const ruleGroupSQL = rg.combinator === "or" ? or(...processedRules) : and(...processedRules);
|
|
1867
2083
|
return rg.not ? not(ruleGroupSQL) : ruleGroupSQL;
|
|
1868
2084
|
};
|
|
1869
|
-
return processRuleGroup(
|
|
2085
|
+
return processRuleGroup(convertFromIC(ruleGroup), true);
|
|
1870
2086
|
};
|
|
1871
2087
|
|
|
1872
2088
|
//#endregion
|
|
@@ -1878,7 +2094,6 @@ const defaultRuleGroupProcessorDrizzle = (ruleGroup, options, _meta) => (columns
|
|
|
1878
2094
|
*/
|
|
1879
2095
|
const defaultRuleGroupProcessorElasticSearch = (ruleGroup, options) => {
|
|
1880
2096
|
const { fields, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
|
|
1881
|
-
const query = convertFromIC(ruleGroup);
|
|
1882
2097
|
const processRuleGroup = (rg) => {
|
|
1883
2098
|
var _rg$id;
|
|
1884
2099
|
if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : ""])) return false;
|
|
@@ -1895,7 +2110,7 @@ const defaultRuleGroupProcessorElasticSearch = (ruleGroup, options) => {
|
|
|
1895
2110
|
if (processedRules.length === 0) return false;
|
|
1896
2111
|
return { bool: rg.not ? { must_not: /^or$/i.test(rg.combinator) ? { bool: { should: processedRules } } : processedRules } : { [/^or$/i.test(rg.combinator) ? "should" : "must"]: processedRules } };
|
|
1897
2112
|
};
|
|
1898
|
-
const processedRuleGroup = processRuleGroup(
|
|
2113
|
+
const processedRuleGroup = processRuleGroup(convertFromIC(ruleGroup));
|
|
1899
2114
|
return processedRuleGroup === false ? {} : processedRuleGroup;
|
|
1900
2115
|
};
|
|
1901
2116
|
|
|
@@ -1911,19 +2126,45 @@ const defaultRuleGroupProcessorJSONata = (ruleGroup, options) => {
|
|
|
1911
2126
|
const processRuleGroup = (rg, outermost) => {
|
|
1912
2127
|
var _rg$id;
|
|
1913
2128
|
if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : ""])) return outermost ? fallbackExpression : "";
|
|
1914
|
-
const
|
|
2129
|
+
const processedRules = [];
|
|
2130
|
+
let precedingCombinator = "";
|
|
2131
|
+
let firstRule = true;
|
|
2132
|
+
for (const rule of rg.rules) {
|
|
1915
2133
|
var _rule$valueSource;
|
|
1916
|
-
if (typeof rule === "string")
|
|
1917
|
-
|
|
2134
|
+
if (typeof rule === "string") {
|
|
2135
|
+
precedingCombinator = rule;
|
|
2136
|
+
continue;
|
|
2137
|
+
}
|
|
2138
|
+
if (isRuleGroup(rule)) {
|
|
2139
|
+
const processedGroup = processRuleGroup(rule);
|
|
2140
|
+
if (processedGroup) {
|
|
2141
|
+
if (!firstRule && precedingCombinator) {
|
|
2142
|
+
processedRules.push(precedingCombinator);
|
|
2143
|
+
precedingCombinator = "";
|
|
2144
|
+
}
|
|
2145
|
+
firstRule = false;
|
|
2146
|
+
processedRules.push(processedGroup);
|
|
2147
|
+
}
|
|
2148
|
+
continue;
|
|
2149
|
+
}
|
|
1918
2150
|
const [validationResult, fieldValidator] = validateRule(rule);
|
|
1919
|
-
if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName)
|
|
2151
|
+
if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
|
|
1920
2152
|
const fieldData = getOption(fields, rule.field);
|
|
1921
|
-
|
|
2153
|
+
const processedRule = ruleProcessor(rule, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1922
2154
|
parseNumbers: getParseNumberBoolean(fieldData === null || fieldData === void 0 ? void 0 : fieldData.inputType),
|
|
1923
2155
|
escapeQuotes: ((_rule$valueSource = rule.valueSource) !== null && _rule$valueSource !== void 0 ? _rule$valueSource : "value") === "value",
|
|
1924
2156
|
fieldData
|
|
1925
2157
|
}));
|
|
1926
|
-
|
|
2158
|
+
if (processedRule) {
|
|
2159
|
+
if (!firstRule && precedingCombinator) {
|
|
2160
|
+
processedRules.push(precedingCombinator);
|
|
2161
|
+
precedingCombinator = "";
|
|
2162
|
+
}
|
|
2163
|
+
firstRule = false;
|
|
2164
|
+
processedRules.push(processedRule);
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
const expression = processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ");
|
|
1927
2168
|
const [prefix, suffix] = rg.not || !outermost ? [`${rg.not ? "$not" : ""}(`, ")"] : ["", ""];
|
|
1928
2169
|
return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
|
|
1929
2170
|
};
|
|
@@ -1969,7 +2210,6 @@ const defaultRuleGroupProcessorJsonLogic = (ruleGroup, options) => {
|
|
|
1969
2210
|
*/
|
|
1970
2211
|
const defaultRuleGroupProcessorLDAP = (ruleGroup, options) => {
|
|
1971
2212
|
const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
|
|
1972
|
-
const query = convertFromIC(ruleGroup);
|
|
1973
2213
|
const processRuleGroup = (rg, outermost) => {
|
|
1974
2214
|
var _rg$id;
|
|
1975
2215
|
if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : ""])) return outermost ? fallbackExpression : "";
|
|
@@ -1990,7 +2230,7 @@ const defaultRuleGroupProcessorLDAP = (ruleGroup, options) => {
|
|
|
1990
2230
|
const [prefix, suffix] = rules.length > 1 ? [`${notPrefix}(${rg.combinator === "or" ? "|" : "&"}`, `)${notSuffix}`] : [notPrefix, notSuffix];
|
|
1991
2231
|
return expression ? `${prefix}${expression}${suffix}` : fallbackExpression;
|
|
1992
2232
|
};
|
|
1993
|
-
return processRuleGroup(
|
|
2233
|
+
return processRuleGroup(convertFromIC(ruleGroup), true);
|
|
1994
2234
|
};
|
|
1995
2235
|
|
|
1996
2236
|
//#endregion
|
|
@@ -2046,26 +2286,48 @@ const defaultRuleGroupProcessorNL = (ruleGroup, options) => {
|
|
|
2046
2286
|
var _rg$id, _rg2$combinator2, _translations2;
|
|
2047
2287
|
if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
|
|
2048
2288
|
const rg2 = isRuleGroupTypeIC(rg) && rg.rules.some((r) => typeof r === "string" && lc(r) === "xor") ? convertFromIC(rg) : rg;
|
|
2049
|
-
const processedRules =
|
|
2289
|
+
const processedRules = [];
|
|
2290
|
+
let precedingCombinator = "";
|
|
2291
|
+
let firstRule = true;
|
|
2292
|
+
for (const rule of rg2.rules) {
|
|
2050
2293
|
var _rule$valueSource;
|
|
2051
2294
|
if (typeof rule === "string") {
|
|
2052
2295
|
var _translations;
|
|
2053
|
-
|
|
2296
|
+
precedingCombinator = `, ${(_translations = translations[rule]) !== null && _translations !== void 0 ? _translations : rule} `;
|
|
2297
|
+
continue;
|
|
2054
2298
|
}
|
|
2055
2299
|
if (isRuleGroup(rule)) {
|
|
2056
2300
|
var _rg2$combinator;
|
|
2057
|
-
|
|
2301
|
+
const processedGroup = processRuleGroup(rule, rg2.rules.length === 1 && !(rg2.not || /^xor$/i.test((_rg2$combinator = rg2.combinator) !== null && _rg2$combinator !== void 0 ? _rg2$combinator : "")));
|
|
2302
|
+
// istanbul ignore else
|
|
2303
|
+
if (processedGroup) {
|
|
2304
|
+
if (!firstRule && precedingCombinator) {
|
|
2305
|
+
processedRules.push(precedingCombinator);
|
|
2306
|
+
precedingCombinator = "";
|
|
2307
|
+
}
|
|
2308
|
+
firstRule = false;
|
|
2309
|
+
processedRules.push(processedGroup);
|
|
2310
|
+
}
|
|
2311
|
+
continue;
|
|
2058
2312
|
}
|
|
2059
2313
|
const [validationResult, fieldValidator] = validateRule(rule);
|
|
2060
|
-
if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName)
|
|
2314
|
+
if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
|
|
2061
2315
|
const escapeQuotes = ((_rule$valueSource = rule.valueSource) !== null && _rule$valueSource !== void 0 ? _rule$valueSource : "value") === "value";
|
|
2062
2316
|
const fieldData = getOption(fields, rule.field);
|
|
2063
|
-
|
|
2317
|
+
const processedRule = ruleProcessor(rule, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
2064
2318
|
parseNumbers: getParseNumberBoolean(fieldData === null || fieldData === void 0 ? void 0 : fieldData.inputType),
|
|
2065
2319
|
escapeQuotes,
|
|
2066
2320
|
fieldData
|
|
2067
2321
|
}));
|
|
2068
|
-
|
|
2322
|
+
if (processedRule) {
|
|
2323
|
+
if (!firstRule && precedingCombinator) {
|
|
2324
|
+
processedRules.push(precedingCombinator);
|
|
2325
|
+
precedingCombinator = "";
|
|
2326
|
+
}
|
|
2327
|
+
firstRule = false;
|
|
2328
|
+
processedRules.push(processedRule);
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2069
2331
|
if (processedRules.length === 0) return fallbackExpression;
|
|
2070
2332
|
const isXOR = lc((_rg2$combinator2 = rg2.combinator) !== null && _rg2$combinator2 !== void 0 ? _rg2$combinator2 : "") === "xor";
|
|
2071
2333
|
const combinator = isXOR ? rg2.combinator.slice(1) : rg2.combinator;
|
|
@@ -2073,7 +2335,7 @@ const defaultRuleGroupProcessorNL = (ruleGroup, options) => {
|
|
|
2073
2335
|
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));
|
|
2074
2336
|
const prefix = mustWrap ? `${prefixTL} (`.trim() : "";
|
|
2075
2337
|
const suffix = mustWrap ? `) ${suffixTL}`.trim() : "";
|
|
2076
|
-
return `${prefix}${processedRules.
|
|
2338
|
+
return `${prefix}${processedRules.join(isRuleGroupType(rg2) ? `, ${(_translations2 = translations[combinator]) !== null && _translations2 !== void 0 ? _translations2 : combinator} ` : "")}${suffix}`;
|
|
2077
2339
|
};
|
|
2078
2340
|
return processRuleGroup(ruleGroup, true);
|
|
2079
2341
|
};
|
|
@@ -2124,11 +2386,37 @@ const defaultRuleGroupProcessorParameterized = (ruleGroup, options) => {
|
|
|
2124
2386
|
const processRuleGroup = (rg, outermostOrLonelyInGroup) => {
|
|
2125
2387
|
var _rg$id;
|
|
2126
2388
|
if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
|
|
2127
|
-
const processedRules =
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2389
|
+
const processedRules = [];
|
|
2390
|
+
let precedingCombinator = "";
|
|
2391
|
+
let firstRule = true;
|
|
2392
|
+
for (const rule of rg.rules) {
|
|
2393
|
+
if (typeof rule === "string") {
|
|
2394
|
+
precedingCombinator = rule;
|
|
2395
|
+
continue;
|
|
2396
|
+
}
|
|
2397
|
+
if (isRuleGroup(rule)) {
|
|
2398
|
+
const processedGroup = processRuleGroup(rule, rg.rules.length === 1);
|
|
2399
|
+
// istanbul ignore else
|
|
2400
|
+
if (processedGroup) {
|
|
2401
|
+
if (!firstRule && precedingCombinator) {
|
|
2402
|
+
processedRules.push(precedingCombinator);
|
|
2403
|
+
precedingCombinator = "";
|
|
2404
|
+
}
|
|
2405
|
+
firstRule = false;
|
|
2406
|
+
processedRules.push(processedGroup);
|
|
2407
|
+
}
|
|
2408
|
+
continue;
|
|
2409
|
+
}
|
|
2410
|
+
const processedRule = processRule(rule);
|
|
2411
|
+
if (processedRule) {
|
|
2412
|
+
if (!firstRule && precedingCombinator) {
|
|
2413
|
+
processedRules.push(precedingCombinator);
|
|
2414
|
+
precedingCombinator = "";
|
|
2415
|
+
}
|
|
2416
|
+
firstRule = false;
|
|
2417
|
+
processedRules.push(processedRule);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2132
2420
|
if (processedRules.length === 0) return fallbackExpression;
|
|
2133
2421
|
return `${rg.not ? "NOT " : ""}(${processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ")})`;
|
|
2134
2422
|
};
|
|
@@ -2238,20 +2526,46 @@ const defaultRuleGroupProcessorSQL = (ruleGroup, options) => {
|
|
|
2238
2526
|
const processRuleGroup = (rg, outermostOrLonelyInGroup) => {
|
|
2239
2527
|
var _rg$id;
|
|
2240
2528
|
if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
|
|
2241
|
-
const processedRules =
|
|
2529
|
+
const processedRules = [];
|
|
2530
|
+
let precedingCombinator = "";
|
|
2531
|
+
let firstRule = true;
|
|
2532
|
+
for (const rule of rg.rules) {
|
|
2242
2533
|
var _rule$valueSource;
|
|
2243
|
-
if (typeof rule === "string")
|
|
2244
|
-
|
|
2534
|
+
if (typeof rule === "string") {
|
|
2535
|
+
precedingCombinator = rule;
|
|
2536
|
+
continue;
|
|
2537
|
+
}
|
|
2538
|
+
if (isRuleGroup(rule)) {
|
|
2539
|
+
const processedGroup = processRuleGroup(rule, rg.rules.length === 1);
|
|
2540
|
+
// istanbul ignore else
|
|
2541
|
+
if (processedGroup) {
|
|
2542
|
+
if (!firstRule && precedingCombinator) {
|
|
2543
|
+
processedRules.push(precedingCombinator);
|
|
2544
|
+
precedingCombinator = "";
|
|
2545
|
+
}
|
|
2546
|
+
firstRule = false;
|
|
2547
|
+
processedRules.push(processedGroup);
|
|
2548
|
+
}
|
|
2549
|
+
continue;
|
|
2550
|
+
}
|
|
2245
2551
|
const [validationResult, fieldValidator] = validateRule(rule);
|
|
2246
|
-
if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName)
|
|
2552
|
+
if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) continue;
|
|
2247
2553
|
const escapeQuotes = ((_rule$valueSource = rule.valueSource) !== null && _rule$valueSource !== void 0 ? _rule$valueSource : "value") === "value";
|
|
2248
2554
|
const fieldData = getOption(fields, rule.field);
|
|
2249
|
-
|
|
2555
|
+
const processedRule = ruleProcessor(rule, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
2250
2556
|
parseNumbers: getParseNumberBoolean(fieldData === null || fieldData === void 0 ? void 0 : fieldData.inputType),
|
|
2251
2557
|
escapeQuotes,
|
|
2252
2558
|
fieldData
|
|
2253
2559
|
}));
|
|
2254
|
-
|
|
2560
|
+
if (processedRule) {
|
|
2561
|
+
if (!firstRule && precedingCombinator) {
|
|
2562
|
+
processedRules.push(precedingCombinator);
|
|
2563
|
+
precedingCombinator = "";
|
|
2564
|
+
}
|
|
2565
|
+
firstRule = false;
|
|
2566
|
+
processedRules.push(processedRule);
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2255
2569
|
if (processedRules.length === 0) return fallbackExpression;
|
|
2256
2570
|
return `${rg.not ? "NOT " : ""}(${processedRules.join(isRuleGroupType(rg) ? ` ${rg.combinator} ` : " ")})`;
|
|
2257
2571
|
};
|
|
@@ -2527,10 +2841,7 @@ const defaultRuleProcessorJsonLogic = (rule, options = {}) => {
|
|
|
2527
2841
|
case "null":
|
|
2528
2842
|
case "notnull": return { [`${operatorLC === "notnull" ? "!" : "="}=`]: [fieldObject, null] };
|
|
2529
2843
|
case "in":
|
|
2530
|
-
case "notin": {
|
|
2531
|
-
const valueAsArray = toArray(value).map((v) => fieldOrNumberRenderer(v));
|
|
2532
|
-
return negateIfNotOp(operatorLC, { in: [fieldObject, valueAsArray] });
|
|
2533
|
-
}
|
|
2844
|
+
case "notin": return negateIfNotOp(operatorLC, { in: [fieldObject, toArray(value).map((v) => fieldOrNumberRenderer(v))] });
|
|
2534
2845
|
case "between":
|
|
2535
2846
|
case "notbetween": {
|
|
2536
2847
|
const valueAsArray = toArray(value);
|
|
@@ -2561,20 +2872,11 @@ const defaultRuleProcessorJsonLogic = (rule, options = {}) => {
|
|
|
2561
2872
|
return false;
|
|
2562
2873
|
}
|
|
2563
2874
|
case "contains":
|
|
2564
|
-
case "doesnotcontain": {
|
|
2565
|
-
const jsonRule = { in: [fieldOrNumberRenderer(value), fieldObject] };
|
|
2566
|
-
return negateIfNotOp(operatorLC, jsonRule);
|
|
2567
|
-
}
|
|
2875
|
+
case "doesnotcontain": return negateIfNotOp(operatorLC, { in: [fieldOrNumberRenderer(value), fieldObject] });
|
|
2568
2876
|
case "beginswith":
|
|
2569
|
-
case "doesnotbeginwith": {
|
|
2570
|
-
const jsonRule = { startsWith: [fieldObject, fieldOrNumberRenderer(value)] };
|
|
2571
|
-
return negateIfNotOp(operatorLC, jsonRule);
|
|
2572
|
-
}
|
|
2877
|
+
case "doesnotbeginwith": return negateIfNotOp(operatorLC, { startsWith: [fieldObject, fieldOrNumberRenderer(value)] });
|
|
2573
2878
|
case "endswith":
|
|
2574
|
-
case "doesnotendwith": {
|
|
2575
|
-
const jsonRule = { endsWith: [fieldObject, fieldOrNumberRenderer(value)] };
|
|
2576
|
-
return negateIfNotOp(operatorLC, jsonRule);
|
|
2577
|
-
}
|
|
2879
|
+
case "doesnotendwith": return negateIfNotOp(operatorLC, { endsWith: [fieldObject, fieldOrNumberRenderer(value)] });
|
|
2578
2880
|
}
|
|
2579
2881
|
return false;
|
|
2580
2882
|
};
|
|
@@ -2609,10 +2911,7 @@ const defaultRuleProcessorLDAP = (rule, options = {}) => {
|
|
|
2609
2911
|
case "null":
|
|
2610
2912
|
case "notnull": return negateIf(`(${field}=*)`, operatorLC === "notnull");
|
|
2611
2913
|
case "in":
|
|
2612
|
-
case "notin": {
|
|
2613
|
-
const valueAsArray = toArray(value);
|
|
2614
|
-
return negateIf(`(|${valueAsArray.map((val) => `(${field}=${ldapEscape(val)})`).join("")})`, operatorLC === "notin");
|
|
2615
|
-
}
|
|
2914
|
+
case "notin": return negateIf(`(|${toArray(value).map((val) => `(${field}=${ldapEscape(val)})`).join("")})`, operatorLC === "notin");
|
|
2616
2915
|
case "between":
|
|
2617
2916
|
case "notbetween": {
|
|
2618
2917
|
const valueAsArray = toArray(value);
|
|
@@ -2783,10 +3082,9 @@ const defaultRuleProcessorNL = (rule, opts) => {
|
|
|
2783
3082
|
}));
|
|
2784
3083
|
const operatorLC = lc(operator);
|
|
2785
3084
|
if ((operatorLC === "in" || operatorLC === "notin" || operatorLC === "between" || operatorLC === "notbetween") && !value) return "";
|
|
2786
|
-
const processedOperator = operatorProcessor(rule, opts);
|
|
2787
3085
|
const wordOrderMap = {
|
|
2788
3086
|
S: processedField,
|
|
2789
|
-
V:
|
|
3087
|
+
V: operatorProcessor(rule, opts),
|
|
2790
3088
|
O: value
|
|
2791
3089
|
};
|
|
2792
3090
|
return normalizeConstituentWordOrder(wordOrder).map((term) => `${wordOrderMap[term]}`).join(" ").trim();
|
|
@@ -3354,7 +3652,7 @@ const findPath = (path, query) => {
|
|
|
3354
3652
|
target = typeof t === "string" ? null : t;
|
|
3355
3653
|
level++;
|
|
3356
3654
|
}
|
|
3357
|
-
return target;
|
|
3655
|
+
return level < path.length ? null : target;
|
|
3358
3656
|
};
|
|
3359
3657
|
/**
|
|
3360
3658
|
* Returns the {@link RuleType} or {@link RuleGroupType}/{@link RuleGroupTypeIC}
|
|
@@ -3551,6 +3849,30 @@ const getValueSourcesUtil = (fieldData, operator, getValueSources) => {
|
|
|
3551
3849
|
});
|
|
3552
3850
|
};
|
|
3553
3851
|
|
|
3852
|
+
//#endregion
|
|
3853
|
+
//#region src/utils/mergeAnyTranslations.ts
|
|
3854
|
+
/**
|
|
3855
|
+
* Merges any number of partial translations into a single definition.
|
|
3856
|
+
*/
|
|
3857
|
+
const mergeAnyTranslations = (base, ...otherTranslations) => produce(base, (draft) => {
|
|
3858
|
+
for (const translations of otherTranslations)
|
|
3859
|
+
// istanbul ignore else
|
|
3860
|
+
if (translations) for (const t of objectKeys(translations)) if (draft[t]) Object.assign(draft[t], translations[t]);
|
|
3861
|
+
else Object.assign(draft, { [t]: translations[t] });
|
|
3862
|
+
});
|
|
3863
|
+
const mergeAnyTranslation = (el, keyPropContextMap, defaults) => {
|
|
3864
|
+
const finalKeys = objectEntries(keyPropContextMap).map(([key, [pT, cT]]) => {
|
|
3865
|
+
var _ref, _defaults$el;
|
|
3866
|
+
return [key, (_ref = pT !== null && pT !== void 0 ? pT : cT) !== null && _ref !== void 0 ? _ref : defaults === null || defaults === void 0 || (_defaults$el = defaults[el]) === null || _defaults$el === void 0 ? void 0 : _defaults$el[key]];
|
|
3867
|
+
}).filter((k) => !!k[1]);
|
|
3868
|
+
if (finalKeys.length > 0 || defaults) {
|
|
3869
|
+
var _defaults$el2;
|
|
3870
|
+
const defaultProperties = (_defaults$el2 = defaults === null || defaults === void 0 ? void 0 : defaults[el]) !== null && _defaults$el2 !== void 0 ? _defaults$el2 : {};
|
|
3871
|
+
const finalObject = Object.assign({}, defaultProperties, Object.fromEntries(finalKeys));
|
|
3872
|
+
return { [el]: finalObject };
|
|
3873
|
+
}
|
|
3874
|
+
};
|
|
3875
|
+
|
|
3554
3876
|
//#endregion
|
|
3555
3877
|
//#region src/utils/mergeClassnames.ts
|
|
3556
3878
|
const joinClassnamesByName = (name, args) => clsx(args.map((c) => clsx(c === null || c === void 0 ? void 0 : c[name])));
|
|
@@ -3578,6 +3900,9 @@ const mergeClassnames = (...args) => ({
|
|
|
3578
3900
|
dragHandle: joinClassnamesByName("dragHandle", args),
|
|
3579
3901
|
lockRule: joinClassnamesByName("lockRule", args),
|
|
3580
3902
|
lockGroup: joinClassnamesByName("lockGroup", args),
|
|
3903
|
+
muteRule: joinClassnamesByName("muteRule", args),
|
|
3904
|
+
muteGroup: joinClassnamesByName("muteGroup", args),
|
|
3905
|
+
muted: joinClassnamesByName("muted", args),
|
|
3581
3906
|
valueSource: joinClassnamesByName("valueSource", args),
|
|
3582
3907
|
actionElement: joinClassnamesByName("actionElement", args),
|
|
3583
3908
|
valueSelector: joinClassnamesByName("valueSelector", args),
|
|
@@ -3597,21 +3922,6 @@ const mergeClassnames = (...args) => ({
|
|
|
3597
3922
|
hasSubQuery: joinClassnamesByName("hasSubQuery", args)
|
|
3598
3923
|
});
|
|
3599
3924
|
|
|
3600
|
-
//#endregion
|
|
3601
|
-
//#region src/utils/objectUtils.ts
|
|
3602
|
-
/**
|
|
3603
|
-
* A strongly-typed version of `Object.keys()`.
|
|
3604
|
-
*
|
|
3605
|
-
* [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
|
|
3606
|
-
*/
|
|
3607
|
-
const objectKeys = Object.keys;
|
|
3608
|
-
/**
|
|
3609
|
-
* A strongly-typed version of `Object.entries()`.
|
|
3610
|
-
*
|
|
3611
|
-
* [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)
|
|
3612
|
-
*/
|
|
3613
|
-
const objectEntries = Object.entries;
|
|
3614
|
-
|
|
3615
3925
|
//#endregion
|
|
3616
3926
|
//#region src/utils/prepareQueryObjects.ts
|
|
3617
3927
|
/**
|
|
@@ -3640,23 +3950,15 @@ const prepareRuleOrGroup = (rg, { idGenerator = generateID } = {}) => isRuleGrou
|
|
|
3640
3950
|
*/
|
|
3641
3951
|
const regenerateID = (rule, { idGenerator = generateID } = {}) => structuredClone(_objectSpread2(_objectSpread2({}, rule), {}, { id: idGenerator() }));
|
|
3642
3952
|
/**
|
|
3643
|
-
* Recursively generates new `id` properties for a group and all its rules and subgroups.
|
|
3953
|
+
* Recursively generates new `id` properties for a rule group and all its rules and subgroups.
|
|
3644
3954
|
*/
|
|
3645
|
-
const regenerateIDs = (
|
|
3646
|
-
if (!isPojo(
|
|
3647
|
-
if (!isRuleGroup(
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
rules: rules$1
|
|
3653
|
-
});
|
|
3654
|
-
}
|
|
3655
|
-
const rules = ruleOrGroup.rules.map((r) => typeof r === "string" ? r : isRuleGroup(r) ? regenerateIDs(r, { idGenerator }) : regenerateID(r, { idGenerator }));
|
|
3656
|
-
return _objectSpread2(_objectSpread2({}, ruleOrGroup), {}, {
|
|
3657
|
-
id: idGenerator(),
|
|
3658
|
-
rules
|
|
3659
|
-
});
|
|
3955
|
+
const regenerateIDs = (subject, { idGenerator = generateID } = {}) => {
|
|
3956
|
+
if (!isPojo(subject)) return subject;
|
|
3957
|
+
if (!isRuleGroup(subject)) return structuredClone(_objectSpread2(_objectSpread2({}, subject), {}, { id: idGenerator() }));
|
|
3958
|
+
const newGroup = _objectSpread2(_objectSpread2({}, subject), {}, { id: idGenerator() });
|
|
3959
|
+
// istanbul ignore else
|
|
3960
|
+
if (Array.isArray(newGroup.rules)) newGroup.rules = subject.rules.map((r) => typeof r === "string" ? r : isRuleGroup(r) ? regenerateIDs(r, { idGenerator }) : regenerateID(r, { idGenerator }));
|
|
3961
|
+
return newGroup;
|
|
3660
3962
|
};
|
|
3661
3963
|
|
|
3662
3964
|
//#endregion
|
|
@@ -3721,12 +4023,11 @@ const update = (query, prop, value, pathOrID, { resetOnFieldChange = true, reset
|
|
|
3721
4023
|
resetValueSource = true;
|
|
3722
4024
|
resetValue = true;
|
|
3723
4025
|
}
|
|
3724
|
-
const
|
|
4026
|
+
const defaultValueSource = getFirstOption(getValueSourcesUtil({
|
|
3725
4027
|
name: ruleOrGroup.field,
|
|
3726
4028
|
value: ruleOrGroup.field,
|
|
3727
4029
|
label: ""
|
|
3728
|
-
}, ruleOrGroup.operator, getValueSources);
|
|
3729
|
-
const defaultValueSource = getFirstOption(valueSources);
|
|
4030
|
+
}, ruleOrGroup.operator, getValueSources));
|
|
3730
4031
|
if (resetValueSource && ruleOrGroup.valueSource && defaultValueSource !== ruleOrGroup.valueSource || prop === "valueSource" && value !== ruleOrGroup.valueSource) {
|
|
3731
4032
|
resetValue = !!ruleOrGroup.valueSource || !ruleOrGroup.valueSource && value !== defaultValueSource;
|
|
3732
4033
|
ruleOrGroup.valueSource = resetValueSource ? defaultValueSource : value;
|
|
@@ -3771,8 +4072,7 @@ const getNextPath = (query, currentPath, newPathOrShiftDirection) => {
|
|
|
3771
4072
|
return [...getParentPath(parentPath), parentPath.at(-1) + 1];
|
|
3772
4073
|
} else {
|
|
3773
4074
|
const evaluationPath = [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 2 : 1)];
|
|
3774
|
-
|
|
3775
|
-
if (isRuleGroup(entityToEvaluate)) return [...evaluationPath, 0];
|
|
4075
|
+
if (isRuleGroup(findPath(evaluationPath, query))) return [...evaluationPath, 0];
|
|
3776
4076
|
else return [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 3 : 2)];
|
|
3777
4077
|
}
|
|
3778
4078
|
return currentPath;
|
|
@@ -3806,8 +4106,7 @@ const move = (query, oldPathOrID, newPath, { clone = false, combinators = defaul
|
|
|
3806
4106
|
const newNewPath = [...nextPath];
|
|
3807
4107
|
const commonAncestorPath = getCommonAncestorPath(oldPath, nextPath);
|
|
3808
4108
|
if (!clone && oldPath.length === commonAncestorPath.length + 1 && nextPath[commonAncestorPath.length] > oldPath[commonAncestorPath.length]) newNewPath[commonAncestorPath.length] -= independentCombinators ? 2 : 1;
|
|
3809
|
-
const
|
|
3810
|
-
const parentToInsertInto = findPath(newNewParentPath, draft);
|
|
4109
|
+
const parentToInsertInto = findPath(getParentPath(newNewPath), draft);
|
|
3811
4110
|
const newIndex = newNewPath.at(-1);
|
|
3812
4111
|
/**
|
|
3813
4112
|
* This function 1) glosses over the need for type assertions to splice directly
|
|
@@ -3818,14 +4117,12 @@ const move = (query, oldPathOrID, newPath, { clone = false, combinators = defaul
|
|
|
3818
4117
|
else if (newIndex === 0) if (ruleToRemoveIndex === 0 && oldNextCombinator) insertRuleOrGroup(ruleOrGroup, oldNextCombinator);
|
|
3819
4118
|
else {
|
|
3820
4119
|
var _ref, _parentToInsertInto$r;
|
|
3821
|
-
|
|
3822
|
-
insertRuleOrGroup(ruleOrGroup, newNextCombinator);
|
|
4120
|
+
insertRuleOrGroup(ruleOrGroup, (_ref = (_parentToInsertInto$r = parentToInsertInto.rules[1]) !== null && _parentToInsertInto$r !== void 0 ? _parentToInsertInto$r : oldPrevCombinator) !== null && _ref !== void 0 ? _ref : getFirstOption(combinators));
|
|
3823
4121
|
}
|
|
3824
4122
|
else if (oldPrevCombinator) insertRuleOrGroup(oldPrevCombinator, ruleOrGroup);
|
|
3825
4123
|
else {
|
|
3826
4124
|
var _ref2, _parentToInsertInto$r2;
|
|
3827
|
-
|
|
3828
|
-
insertRuleOrGroup(newPrevCombinator, ruleOrGroup);
|
|
4125
|
+
insertRuleOrGroup((_ref2 = (_parentToInsertInto$r2 = parentToInsertInto.rules[newIndex - 2]) !== null && _parentToInsertInto$r2 !== void 0 ? _parentToInsertInto$r2 : oldNextCombinator) !== null && _ref2 !== void 0 ? _ref2 : getFirstOption(combinators), ruleOrGroup);
|
|
3829
4126
|
}
|
|
3830
4127
|
});
|
|
3831
4128
|
};
|
|
@@ -3853,16 +4150,14 @@ const insert = (query, ruleOrGroup, path, { combinators = defaultCombinators, co
|
|
|
3853
4150
|
if (((_rorg$path = rorg.path) === null || _rorg$path === void 0 ? void 0 : _rorg$path.at(-1)) === 0 && combinatorSucceeding) insertRuleOrGroup(newIndex, rorg, combinatorSucceeding);
|
|
3854
4151
|
else {
|
|
3855
4152
|
var _ref3, _parentToInsertInto$r3;
|
|
3856
|
-
|
|
3857
|
-
insertRuleOrGroup(newIndex, rorg, newNextCombinator);
|
|
4153
|
+
insertRuleOrGroup(newIndex, rorg, (_ref3 = (_parentToInsertInto$r3 = parentToInsertInto.rules[1]) !== null && _parentToInsertInto$r3 !== void 0 ? _parentToInsertInto$r3 : combinatorPreceding) !== null && _ref3 !== void 0 ? _ref3 : getFirstOption(combinators));
|
|
3858
4154
|
}
|
|
3859
4155
|
} else {
|
|
3860
4156
|
const normalizedNewIndex = newIndex % 2 === 0 ? newIndex - 1 : newIndex;
|
|
3861
4157
|
if (combinatorPreceding) insertRuleOrGroup(normalizedNewIndex, combinatorPreceding, rorg);
|
|
3862
4158
|
else {
|
|
3863
4159
|
var _ref4, _parentToInsertInto$r4;
|
|
3864
|
-
|
|
3865
|
-
insertRuleOrGroup(normalizedNewIndex, newPrevCombinator, rorg);
|
|
4160
|
+
insertRuleOrGroup(normalizedNewIndex, (_ref4 = (_parentToInsertInto$r4 = parentToInsertInto.rules[normalizedNewIndex - 2]) !== null && _parentToInsertInto$r4 !== void 0 ? _parentToInsertInto$r4 : combinatorSucceeding) !== null && _ref4 !== void 0 ? _ref4 : getFirstOption(combinators), rorg);
|
|
3866
4161
|
}
|
|
3867
4162
|
}
|
|
3868
4163
|
});
|
|
@@ -3897,8 +4192,7 @@ const group = (query, sourcePathOrID, targetPathOrID, { clone = false, combinato
|
|
|
3897
4192
|
const newNewPath = [...nextPath];
|
|
3898
4193
|
const commonAncestorPath = getCommonAncestorPath(sourcePath, nextPath);
|
|
3899
4194
|
if (!clone && sourcePath.length === commonAncestorPath.length + 1 && nextPath[commonAncestorPath.length] > sourcePath[commonAncestorPath.length]) newNewPath[commonAncestorPath.length] -= independentCombinators ? 2 : 1;
|
|
3900
|
-
const
|
|
3901
|
-
const parentOfTargetPath = findPath(newNewParentPath, draft);
|
|
4195
|
+
const parentOfTargetPath = findPath(getParentPath(newNewPath), draft);
|
|
3902
4196
|
const targetPathIndex = newNewPath.at(-1);
|
|
3903
4197
|
parentOfTargetPath.rules.splice(targetPathIndex, 1, prepareRuleOrGroup(independentCombinators ? { rules: [
|
|
3904
4198
|
targetRuleOrGroup,
|
|
@@ -3912,5 +4206,5 @@ const group = (query, sourcePathOrID, targetPathOrID, { clone = false, combinato
|
|
|
3912
4206
|
};
|
|
3913
4207
|
|
|
3914
4208
|
//#endregion
|
|
3915
|
-
export { LogType, TestID, add, bigIntJsonParseReviver, bigIntJsonStringifyReplacer, celCombinatorMap, clsx, convertFromIC, convertQuery, convertToIC, defaultCELValueProcessor, defaultCombinatorLabelMap, defaultCombinators, defaultCombinatorsExtended, defaultControlClassnames, defaultExportOperatorMap, defaultJoinChar, defaultMatchModes, defaultMongoDBValueProcessor, defaultNLTranslations, defaultOperatorLabelMap, defaultOperatorNegationMap, defaultOperatorProcessorNL, defaultOperatorProcessorSQL, defaultOperators, defaultPlaceholderFieldGroupLabel, defaultPlaceholderFieldLabel, defaultPlaceholderFieldName, defaultPlaceholderLabel, defaultPlaceholderName, defaultPlaceholderOperatorGroupLabel, defaultPlaceholderOperatorLabel, defaultPlaceholderOperatorName, defaultPlaceholderValueGroupLabel, defaultPlaceholderValueLabel, defaultPlaceholderValueName, defaultRuleGroupProcessorCEL, defaultRuleGroupProcessorDrizzle, defaultRuleGroupProcessorElasticSearch, defaultRuleGroupProcessorJSONata, defaultRuleGroupProcessorJsonLogic, defaultRuleGroupProcessorLDAP, defaultRuleGroupProcessorMongoDB, defaultRuleGroupProcessorMongoDBQuery, defaultRuleGroupProcessorNL, defaultRuleGroupProcessorParameterized, defaultRuleGroupProcessorPrisma, defaultRuleGroupProcessorSQL, defaultRuleGroupProcessorSequelize, defaultRuleGroupProcessorSpEL, defaultRuleProcessorCEL, defaultRuleProcessorDrizzle, defaultRuleProcessorElasticSearch, defaultRuleProcessorJSONata, defaultRuleProcessorJsonLogic, defaultRuleProcessorLDAP, defaultRuleProcessorMongoDB, defaultRuleProcessorMongoDBQuery, defaultRuleProcessorNL, defaultRuleProcessorParameterized, defaultRuleProcessorPrisma, defaultRuleProcessorSQL, defaultRuleProcessorSequelize, defaultRuleProcessorSpEL, defaultSpELValueProcessor, defaultValidator, defaultValueProcessor, defaultValueProcessorByRule, defaultValueProcessorCELByRule, defaultValueProcessorMongoDBByRule, defaultValueProcessorNL, defaultValueProcessorSpELByRule, filterFieldsByComparator, findID, findPath, formatQuery, formatQueryOptionPresets, generateAccessibleDescription, generateID, getCommonAncestorPath, getFirstOption, getMatchModesUtil, getNLTranslataion, getOption, getParentPath, getParseNumberMethod, getPathOfID, getQuoteFieldNamesWithArray, getQuotedFieldName, getValidationClassNames, getValueSourcesUtil, group, groupInvalidReasons, insert, isAncestor, isFlexibleOptionArray, isFlexibleOptionGroupArray, isFullOptionArray, isFullOptionGroupArray, isOptionGroupArray, isPojo, isRuleGroup, isRuleGroupType, isRuleGroupTypeIC, isRuleOrGroupValid, isValidValue, isValidationResult, isValueProcessorLegacy, joinWith, jsonLogicAdditionalOperators, lc, mapSQLOperator, mergeClassnames, mongoDbFallback, mongoOperators, move, normalizeConstituentWordOrder, nullFreeArray, nullOrUndefinedOrEmpty, numericRegex, numerifyValues, objectEntries, objectKeys, parseNumber, pathIsDisabled, pathsAreEqual, prepareRule, prepareRuleGroup, prepareRuleOrGroup, prismaFallback, prismaOperators, processMatchMode, regenerateID, regenerateIDs, remove, rootPath, shouldRenderAsNumber, splitBy, sqlDialectPresets, standardClassnames, toArray, toFlatOptionArray, toFullOption, toFullOptionList, toFullOptionMap, transformQuery, trimIfString, uniqByIdentifier, uniqByName, uniqOptGroups, uniqOptList, update };
|
|
4209
|
+
export { LogType, TestID, add, bigIntJsonParseReviver, bigIntJsonStringifyReplacer, celCombinatorMap, clsx, convertFromIC, convertQuery, convertToIC, defaultCELValueProcessor, defaultCombinatorLabelMap, defaultCombinators, defaultCombinatorsExtended, defaultControlClassnames, defaultExportOperatorMap, defaultJoinChar, defaultMatchModes, defaultMongoDBValueProcessor, defaultNLTranslations, defaultOperatorLabelMap, defaultOperatorNegationMap, defaultOperatorProcessorNL, defaultOperatorProcessorSQL, defaultOperators, defaultPlaceholderFieldGroupLabel, defaultPlaceholderFieldLabel, defaultPlaceholderFieldName, defaultPlaceholderLabel, defaultPlaceholderName, defaultPlaceholderOperatorGroupLabel, defaultPlaceholderOperatorLabel, defaultPlaceholderOperatorName, defaultPlaceholderValueGroupLabel, defaultPlaceholderValueLabel, defaultPlaceholderValueName, defaultRuleGroupProcessorCEL, defaultRuleGroupProcessorDrizzle, defaultRuleGroupProcessorElasticSearch, defaultRuleGroupProcessorJSONata, defaultRuleGroupProcessorJsonLogic, defaultRuleGroupProcessorLDAP, defaultRuleGroupProcessorMongoDB, defaultRuleGroupProcessorMongoDBQuery, defaultRuleGroupProcessorNL, defaultRuleGroupProcessorParameterized, defaultRuleGroupProcessorPrisma, defaultRuleGroupProcessorSQL, defaultRuleGroupProcessorSequelize, defaultRuleGroupProcessorSpEL, defaultRuleProcessorCEL, defaultRuleProcessorDrizzle, defaultRuleProcessorElasticSearch, defaultRuleProcessorJSONata, defaultRuleProcessorJsonLogic, defaultRuleProcessorLDAP, defaultRuleProcessorMongoDB, defaultRuleProcessorMongoDBQuery, defaultRuleProcessorNL, defaultRuleProcessorParameterized, defaultRuleProcessorPrisma, defaultRuleProcessorSQL, defaultRuleProcessorSequelize, defaultRuleProcessorSpEL, defaultSpELValueProcessor, defaultTranslations, defaultValidator, defaultValueProcessor, defaultValueProcessorByRule, defaultValueProcessorCELByRule, defaultValueProcessorMongoDBByRule, defaultValueProcessorNL, defaultValueProcessorSpELByRule, filterFieldsByComparator, findID, findPath, formatQuery, formatQueryOptionPresets, generateAccessibleDescription, generateID, getCommonAncestorPath, getFirstOption, getMatchModesUtil, getNLTranslataion, getOption, getParentPath, getParseNumberMethod, getPathOfID, getQuoteFieldNamesWithArray, getQuotedFieldName, getValidationClassNames, getValueSourcesUtil, group, groupInvalidReasons, insert, isAncestor, isFlexibleOptionArray, isFlexibleOptionGroupArray, isFullOptionArray, isFullOptionGroupArray, isOptionGroupArray, isPojo, isRuleGroup, isRuleGroupType, isRuleGroupTypeIC, isRuleOrGroupValid, isRuleType, isValidValue, isValidationResult, isValueProcessorLegacy, joinWith, jsonLogicAdditionalOperators, lc, mapSQLOperator, mergeAnyTranslation, mergeAnyTranslations, mergeClassnames, mongoDbFallback, mongoOperators, move, normalizeConstituentWordOrder, nullFreeArray, nullOrUndefinedOrEmpty, numericRegex, numerifyValues, objectEntries, objectKeys, parseNumber, pathIsDisabled, pathsAreEqual, prepareOptionList, prepareRule, prepareRuleGroup, prepareRuleOrGroup, prismaFallback, prismaOperators, processMatchMode, regenerateID, regenerateIDs, remove, rootPath, shouldRenderAsNumber, splitBy, sqlDialectPresets, standardClassnames, toArray, toFlatOptionArray, toFullOption, toFullOptionList, toFullOptionMap, transformQuery, trimIfString, uniqByIdentifier, uniqByName, uniqOptGroups, uniqOptList, update };
|
|
3916
4210
|
//# sourceMappingURL=react-querybuilder_core.legacy-esm.js.map
|