@react-querybuilder/core 8.9.2 → 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-BF1P8iHS.mjs → arrayUtils-C9sO4qLO.mjs} +3 -75
- 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 +553 -1247
- package/dist/cjs/react-querybuilder_core.cjs.development.js +408 -121
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +553 -1247
- 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-H7RhQiIc.mjs → convertQuery-BUgyz1GA.mjs} +2 -2
- package/dist/{convertQuery-H7RhQiIc.mjs.map → convertQuery-BUgyz1GA.mjs.map} +1 -1
- package/dist/{export-r-V7bU31.d.mts → export-Ccjfea21.d.mts} +3 -2
- package/dist/{export-DyrnTh6K.d.ts → export-GUuxJ7zR.d.ts} +3 -2
- package/dist/formatQuery.d.mts +3 -2
- package/dist/formatQuery.d.ts +3 -2
- package/dist/formatQuery.js +217 -87
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +217 -87
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-Cksobmln.d.ts → import-D-hm1phN.d.ts} +2 -2
- package/dist/{import-BwbbP4oU.d.mts → import-Dxevzw_-.d.mts} +2 -2
- package/dist/{isRuleGroup-CnhYpLOM.mjs → isRuleGroup-CGe_rb2w.mjs} +1 -1
- package/dist/{isRuleGroup-CnhYpLOM.mjs.map → isRuleGroup-CGe_rb2w.mjs.map} +1 -1
- package/dist/{optGroupUtils-CXLgyg2i.js → optGroupUtils-B0hTpodo.js} +114 -1
- package/dist/optGroupUtils-B0hTpodo.js.map +1 -0
- package/dist/{optGroupUtils-Duv-M8rf.mjs → optGroupUtils-DrubUpx0.mjs} +86 -3
- package/dist/optGroupUtils-DrubUpx0.mjs.map +1 -0
- package/dist/parseCEL.d.mts +292 -11
- package/dist/parseCEL.d.ts +292 -11
- package/dist/parseCEL.js +114 -30
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +69 -31
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseJSONata.d.mts +3 -2
- package/dist/parseJSONata.d.ts +3 -2
- package/dist/parseJSONata.js +49 -77
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +4 -5
- package/dist/parseJSONata.mjs.map +1 -1
- package/dist/parseJsonLogic.d.mts +4 -3
- package/dist/parseJsonLogic.d.ts +4 -3
- package/dist/parseJsonLogic.js +5 -6
- package/dist/parseJsonLogic.js.map +1 -1
- package/dist/parseJsonLogic.mjs +5 -6
- package/dist/parseJsonLogic.mjs.map +1 -1
- package/dist/parseMongoDB.d.mts +3 -2
- package/dist/parseMongoDB.d.ts +3 -2
- package/dist/parseMongoDB.js +15 -16
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +5 -6
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/{parseNumber-BtGKa58z.mjs → parseNumber-B_-sR6d5.mjs} +1 -1
- package/dist/{parseNumber-BtGKa58z.mjs.map → parseNumber-B_-sR6d5.mjs.map} +1 -1
- 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 +3 -2
- package/dist/parseSQL.d.ts +3 -2
- package/dist/parseSQL.js +11 -15
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +12 -16
- package/dist/parseSQL.mjs.map +1 -1
- package/dist/parseSpEL.d.mts +3 -2
- package/dist/parseSpEL.d.ts +3 -2
- package/dist/parseSpEL.js +7 -9
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +5 -6
- package/dist/parseSpEL.mjs.map +1 -1
- package/dist/{prepareQueryObjects-BqFEs4eV.js → prepareQueryObjects-BOUWfel5.js} +4 -5
- package/dist/prepareQueryObjects-BOUWfel5.js.map +1 -0
- package/dist/{prepareQueryObjects-CS6Wmhmf.mjs → prepareQueryObjects-CJNpnGcJ.mjs} +5 -6
- 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 +553 -1247
- package/dist/react-querybuilder_core.legacy-esm.d.ts +553 -1247
- package/dist/react-querybuilder_core.legacy-esm.js +412 -119
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +405 -122
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +553 -1247
- 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-DdMvmrCh.mjs → transformQuery-DHvtgDgZ.mjs} +2 -2
- package/dist/{transformQuery-DdMvmrCh.mjs.map → transformQuery-DHvtgDgZ.mjs.map} +1 -1
- package/dist/transformQuery.d.mts +1 -1
- package/dist/transformQuery.d.ts +1 -1
- package/dist/transformQuery.js +1 -1
- package/dist/transformQuery.mjs +2 -2
- package/package.json +14 -12
- package/dist/arrayUtils-BF1P8iHS.mjs.map +0 -1
- package/dist/arrayUtils-D5EoIsKP.js +0 -164
- package/dist/arrayUtils-D5EoIsKP.js.map +0 -1
- package/dist/basic-BfD-7CN3.d.mts +0 -1235
- 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/objectUtils-BtWdcZVG.mjs +0 -11
- package/dist/objectUtils-BtWdcZVG.mjs.map +0 -1
- package/dist/optGroupUtils-CXLgyg2i.js.map +0 -1
- package/dist/optGroupUtils-Duv-M8rf.mjs.map +0 -1
- package/dist/prepareQueryObjects-BqFEs4eV.js.map +0 -1
- package/dist/prepareQueryObjects-CS6Wmhmf.mjs.map +0 -1
package/dist/styles/_layout.scss
CHANGED
|
@@ -84,9 +84,13 @@
|
|
|
84
84
|
/* #endregion */
|
|
85
85
|
|
|
86
86
|
/* #region Branches */
|
|
87
|
-
|
|
87
|
+
@mixin branch-layout-styles($direction) {
|
|
88
|
+
$ltr-after: if($direction == rtl, before, after);
|
|
89
|
+
$ltr-before: if($direction == rtl, after, before);
|
|
90
|
+
$margin-side: if($direction == rtl, right, left);
|
|
91
|
+
|
|
88
92
|
.ruleGroup-body {
|
|
89
|
-
margin-
|
|
93
|
+
margin-#{$margin-side}: calc(2 * var(--#{$rqb-var-prefix}branch-indent));
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
.rule,
|
|
@@ -97,26 +101,40 @@
|
|
|
97
101
|
&::after {
|
|
98
102
|
content: '';
|
|
99
103
|
width: var(--#{$rqb-var-prefix}branch-indent);
|
|
100
|
-
|
|
104
|
+
#{$margin-side}: calc(
|
|
101
105
|
-1 * (var(--#{$rqb-var-prefix}branch-indent) + var(--#{$rqb-var-prefix}branch-width))
|
|
102
106
|
);
|
|
103
107
|
border-radius: 0;
|
|
104
108
|
position: absolute;
|
|
105
109
|
}
|
|
106
110
|
|
|
107
|
-
|
|
111
|
+
&::#{$ltr-before} {
|
|
108
112
|
top: calc(-1 * var(--#{$rqb-var-prefix}spacing));
|
|
109
113
|
height: calc(50% + var(--#{$rqb-var-prefix}spacing));
|
|
110
|
-
|
|
114
|
+
@if $direction == rtl {
|
|
115
|
+
border-width: 0
|
|
116
|
+
var(--#{$rqb-var-prefix}branch-width)
|
|
117
|
+
var(--#{$rqb-var-prefix}branch-width)
|
|
118
|
+
0;
|
|
119
|
+
} @else {
|
|
120
|
+
border-width: 0
|
|
121
|
+
0
|
|
122
|
+
var(--#{$rqb-var-prefix}branch-width)
|
|
123
|
+
var(--#{$rqb-var-prefix}branch-width);
|
|
124
|
+
}
|
|
111
125
|
}
|
|
112
126
|
|
|
113
|
-
|
|
127
|
+
&::#{$ltr-after} {
|
|
114
128
|
top: 50%;
|
|
115
129
|
height: 50%;
|
|
116
|
-
|
|
130
|
+
@if $direction == rtl {
|
|
131
|
+
border-width: 0 var(--#{$rqb-var-prefix}branch-width) 0 0;
|
|
132
|
+
} @else {
|
|
133
|
+
border-width: 0 0 0 var(--#{$rqb-var-prefix}branch-width);
|
|
134
|
+
}
|
|
117
135
|
}
|
|
118
136
|
|
|
119
|
-
&:last-child
|
|
137
|
+
&:last-child::#{$ltr-after} {
|
|
120
138
|
display: none;
|
|
121
139
|
}
|
|
122
140
|
}
|
|
@@ -125,7 +143,7 @@
|
|
|
125
143
|
.ruleGroup .ruleGroup {
|
|
126
144
|
&::before,
|
|
127
145
|
&::after {
|
|
128
|
-
|
|
146
|
+
#{$margin-side}: calc(
|
|
129
147
|
-1 *
|
|
130
148
|
(
|
|
131
149
|
var(--#{$rqb-var-prefix}branch-indent) + var(--#{$rqb-var-prefix}branch-width) +
|
|
@@ -134,12 +152,12 @@
|
|
|
134
152
|
);
|
|
135
153
|
}
|
|
136
154
|
|
|
137
|
-
|
|
155
|
+
&::#{$ltr-before} {
|
|
138
156
|
top: calc(-1 * (var(--#{$rqb-var-prefix}spacing) + var(--#{$rqb-var-prefix}border-width)));
|
|
139
157
|
height: calc(50% + var(--#{$rqb-var-prefix}spacing) + var(--#{$rqb-var-prefix}border-width));
|
|
140
158
|
}
|
|
141
159
|
|
|
142
|
-
|
|
160
|
+
&::#{$ltr-after} {
|
|
143
161
|
height: calc(50% + var(--#{$rqb-var-prefix}border-width));
|
|
144
162
|
}
|
|
145
163
|
}
|
|
@@ -147,24 +165,40 @@
|
|
|
147
165
|
.betweenRules {
|
|
148
166
|
position: relative;
|
|
149
167
|
|
|
150
|
-
|
|
168
|
+
&::#{$ltr-before} {
|
|
151
169
|
content: '';
|
|
152
170
|
width: var(--#{$rqb-var-prefix}branch-indent);
|
|
153
|
-
|
|
171
|
+
#{$margin-side}: calc(
|
|
154
172
|
-1 * (var(--#{$rqb-var-prefix}branch-indent) + var(--#{$rqb-var-prefix}branch-width))
|
|
155
173
|
);
|
|
156
174
|
border-radius: 0;
|
|
157
175
|
position: absolute;
|
|
158
176
|
top: calc(-1 * var(--#{$rqb-var-prefix}spacing));
|
|
159
177
|
height: calc(100% + var(--#{$rqb-var-prefix}spacing));
|
|
160
|
-
|
|
178
|
+
@if $direction == rtl {
|
|
179
|
+
border-width: 0 var(--#{$rqb-var-prefix}branch-width) 0 0;
|
|
180
|
+
} @else {
|
|
181
|
+
border-width: 0 0 0 var(--#{$rqb-var-prefix}branch-width);
|
|
182
|
+
}
|
|
161
183
|
}
|
|
162
184
|
}
|
|
163
185
|
}
|
|
186
|
+
|
|
187
|
+
/* LTR */
|
|
188
|
+
.queryBuilder-branches:dir(ltr) {
|
|
189
|
+
@include branch-layout-styles(ltr);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/* RTL */
|
|
193
|
+
.queryBuilder-branches:dir(rtl) {
|
|
194
|
+
@include branch-layout-styles(rtl);
|
|
195
|
+
}
|
|
164
196
|
/* #endregion */
|
|
165
197
|
|
|
166
198
|
/* #region Justified */
|
|
167
|
-
|
|
199
|
+
@mixin justified-auto-margin($direction) {
|
|
200
|
+
$margin-side: if($direction == rtl, right, left);
|
|
201
|
+
|
|
168
202
|
.ruleGroup-combinators,
|
|
169
203
|
.ruleGroup-notToggle,
|
|
170
204
|
.shiftActions,
|
|
@@ -187,15 +221,25 @@
|
|
|
187
221
|
& + .rule-cloneRule,
|
|
188
222
|
& + .rule-lock,
|
|
189
223
|
& + .rule-remove {
|
|
190
|
-
margin-
|
|
224
|
+
margin-#{$margin-side}: auto !important;
|
|
191
225
|
}
|
|
192
226
|
}
|
|
193
227
|
|
|
194
228
|
.ruleGroup-addRule,
|
|
195
229
|
.ruleGroup-addGroup {
|
|
196
230
|
&:first-child {
|
|
197
|
-
margin-
|
|
231
|
+
margin-#{$margin-side}: auto !important;
|
|
198
232
|
}
|
|
199
233
|
}
|
|
200
234
|
}
|
|
235
|
+
|
|
236
|
+
/* LTR */
|
|
237
|
+
.queryBuilder-justified:dir(ltr) {
|
|
238
|
+
@include justified-auto-margin(ltr);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* RTL */
|
|
242
|
+
.queryBuilder-justified:dir(rtl) {
|
|
243
|
+
@include justified-auto-margin(rtl);
|
|
244
|
+
}
|
|
201
245
|
/* #endregion */
|
package/dist/styles/_main.scss
CHANGED
|
@@ -88,7 +88,10 @@
|
|
|
88
88
|
/* #endregion */
|
|
89
89
|
|
|
90
90
|
/* #region Branch styles */
|
|
91
|
-
|
|
91
|
+
@mixin branch-styles($direction) {
|
|
92
|
+
$before-after: if($direction == rtl, after, before);
|
|
93
|
+
$border-side: if($direction == rtl, right, left);
|
|
94
|
+
|
|
92
95
|
.rule,
|
|
93
96
|
.ruleGroup .ruleGroup {
|
|
94
97
|
&::before,
|
|
@@ -97,18 +100,28 @@
|
|
|
97
100
|
border-style: var(--#{$rqb-var-prefix}branch-style);
|
|
98
101
|
}
|
|
99
102
|
|
|
100
|
-
&:last-child
|
|
101
|
-
border-bottom-
|
|
103
|
+
&:last-child::#{$before-after} {
|
|
104
|
+
border-bottom-#{$border-side}-radius: var(--#{$rqb-var-prefix}branch-radius);
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
.betweenRules {
|
|
106
109
|
position: relative;
|
|
107
110
|
|
|
108
|
-
|
|
111
|
+
&::#{$before-after} {
|
|
109
112
|
border-color: var(--#{$rqb-var-prefix}branch-color);
|
|
110
113
|
border-style: var(--#{$rqb-var-prefix}branch-style);
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
}
|
|
117
|
+
|
|
118
|
+
/* LTR */
|
|
119
|
+
.queryBuilder-branches:dir(ltr) {
|
|
120
|
+
@include branch-styles(ltr);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* RTL */
|
|
124
|
+
.queryBuilder-branches:dir(rtl) {
|
|
125
|
+
@include branch-styles(rtl);
|
|
126
|
+
}
|
|
114
127
|
/* #endregion */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformQuery-
|
|
1
|
+
{"version":3,"file":"transformQuery-CWDPogO5.js","names":["isRuleGroupType","isRuleGroup"],"sources":["../src/utils/transformQuery.ts"],"sourcesContent":["/**\n * Recursively steps through a query object ({@link index!RuleGroupType RuleGroupType} or {@link index!RuleGroupTypeIC RuleGroupTypeIC}),\n * passing each {@link index!RuleType RuleType} object to a provided `ruleProcessor` function and returning a\n * new query object if there were any referential changes.\n *\n * @module transformQuery\n */\n\nimport { produce } from 'immer';\nimport type { RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleType } from '../types';\nimport { isRuleGroup, isRuleGroupType } from './isRuleGroup';\n\nconst remapProperties = (\n // oxlint-disable-next-line typescript/no-explicit-any\n obj: Record<string, any>,\n propertyMap: Record<string, string | false>,\n deleteRemappedProperties: boolean\n) =>\n produce(obj, draft => {\n for (const [k, v] of Object.entries(propertyMap)) {\n if (v === false) {\n delete draft[k];\n } else if (!!v && k !== v && k in draft) {\n draft[v] = draft[k];\n if (deleteRemappedProperties) {\n delete draft[k];\n }\n }\n }\n });\n\n/**\n * Options object for {@link index!transformQuery transformQuery}.\n */\nexport interface TransformQueryOptions<RG extends RuleGroupTypeAny = RuleGroupType> {\n /**\n * When a rule is encountered in the hierarchy, it will be replaced\n * with the result of this function.\n *\n * @defaultValue `r => r`\n */\n // oxlint-disable-next-line typescript/no-explicit-any\n ruleProcessor?: (rule: RuleType) => any;\n /**\n * When a group is encountered in the hierarchy (including the root group, the\n * query itself), it will be replaced with the result of this function.\n *\n * @defaultValue `rg => rg`\n */\n // oxlint-disable-next-line typescript/no-explicit-any\n ruleGroupProcessor?: (ruleGroup: RG) => Record<string, any>;\n /**\n * For each rule and group in the query, any properties matching a key\n * in this object will be renamed to the corresponding value. To retain both\n * the new _and_ the original properties, set `deleteRemappedProperties`\n * to `false`.\n *\n * If a key has a value of `false`, the corresponding property will be removed\n * without being copied to a new property name. (Warning: `{ rules: false }`\n * will prevent recursion and only return the processed root group.)\n *\n * @defaultValue `{}`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', not: true, rules: [] },\n * { propertyMap: { combinator: 'AndOr', not: false } }\n * )\n * // Returns: { AndOr: 'and', rules: [] }\n * ```\n */\n propertyMap?: Record<string, string | false>;\n /**\n * Any combinator values (including independent combinators) will be translated\n * from the key in this object to the value.\n *\n * @defaultValue `{}`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', rules: [] },\n * { combinatorMap: { and: '&&', or: '||' } }\n * )\n * // Returns: { combinator: '&&', rules: [] }\n * ```\n */\n combinatorMap?: Record<string, string>;\n /**\n * Any operator values will be translated from the key in this object to the value.\n *\n * @defaultValue `{}`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', rules: [{ field: 'name', operator: '=', value: 'Steve Vai' }] },\n * { operatorMap: { '=': 'is' } }\n * )\n * // Returns:\n * // {\n * // combinator: 'and',\n * // rules: [{ field: 'name', operator: 'is', value: 'Steve Vai' }]\n * // }\n * ```\n */\n operatorMap?: Record<string, string>;\n /**\n * Prevents the `path` property (see {@link index!Path Path}) from being added to each\n * rule and group in the hierarchy.\n *\n * @defaultValue `false`\n */\n omitPath?: boolean;\n /**\n * Original properties remapped according to the `propertyMap` option will be removed.\n *\n * @defaultValue `true`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', rules: [] },\n * { propertyMap: { combinator: 'AndOr' }, deleteRemappedProperties: false }\n * )\n * // Returns: { combinator: 'and', AndOr: 'and', rules: [] }\n * ```\n */\n deleteRemappedProperties?: boolean;\n}\n\n/**\n * Recursively process a query heirarchy using this versatile utility function.\n *\n * [Documentation](https://react-querybuilder.js.org/docs/utils/misc#transformquery)\n */\nexport function transformQuery(\n query: RuleGroupType,\n options?: TransformQueryOptions\n // oxlint-disable-next-line typescript/no-explicit-any\n): any;\n/**\n * Recursively process a query heirarchy with independent combinators using this\n * versatile utility function.\n *\n * [Documentation](https://react-querybuilder.js.org/docs/utils/misc#transformquery)\n */\nexport function transformQuery(\n query: RuleGroupTypeIC,\n options?: TransformQueryOptions<RuleGroupTypeIC>\n // oxlint-disable-next-line typescript/no-explicit-any\n): any;\nexport function transformQuery<RG extends RuleGroupTypeAny>(\n query: RG,\n options: TransformQueryOptions<RG> = {}\n) {\n const {\n ruleProcessor = r => r,\n ruleGroupProcessor = rg => rg,\n propertyMap = {},\n combinatorMap = {},\n operatorMap = {},\n omitPath = false,\n deleteRemappedProperties = true,\n } = options;\n\n // oxlint-disable-next-line typescript/no-explicit-any\n const processGroup = (rg: RuleGroupTypeAny): any => ({\n ...ruleGroupProcessor(\n remapProperties(\n {\n ...rg,\n ...(isRuleGroupType(rg)\n ? { combinator: combinatorMap[rg.combinator] ?? rg.combinator }\n : {}),\n },\n propertyMap,\n deleteRemappedProperties\n ) as RG\n ),\n ...(propertyMap['rules'] === false\n ? null\n : {\n // oxlint-disable-next-line typescript/no-explicit-any\n [propertyMap['rules'] ?? 'rules']: rg.rules.map((r: any, idx) => {\n const pathObject = omitPath ? null : { path: [...rg.path!, idx] };\n if (typeof r === 'string') {\n // independent combinators\n return combinatorMap[r] ?? r;\n } else if (isRuleGroup(r)) {\n // sub-groups\n return processGroup({ ...r, ...pathObject });\n }\n // rules\n return ruleProcessor(\n remapProperties(\n {\n ...r,\n ...pathObject,\n ...('operator' in r ? { operator: operatorMap[r.operator] ?? r.operator } : {}),\n },\n propertyMap,\n deleteRemappedProperties\n ) as RuleType\n );\n }),\n }),\n });\n\n return processGroup({ ...query, ...(omitPath ? null : { path: [] }) });\n}\n"],"mappings":";;;;;AAYA,MAAM,mBAEJ,KACA,aACA,gDAEQ,MAAK,UAAS;AACpB,MAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,YAAY,CAC9C,KAAI,MAAM,MACR,QAAO,MAAM;UACJ,CAAC,CAAC,KAAK,MAAM,KAAK,KAAK,OAAO;AACvC,QAAM,KAAK,MAAM;AACjB,MAAI,yBACF,QAAO,MAAM;;EAInB;AA4HJ,SAAgB,eACd,OACA,UAAqC,EAAE,EACvC;CACA,MAAM,EACJ,iBAAgB,MAAK,GACrB,sBAAqB,OAAM,IAC3B,cAAc,EAAE,EAChB,gBAAgB,EAAE,EAClB,cAAc,EAAE,EAChB,WAAW,OACX,2BAA2B,SACzB;CAGJ,MAAM,gBAAgB,QAA+B;EACnD,GAAG,mBACD,gBACE;GACE,GAAG;GACH,GAAIA,oCAAgB,GAAG,GACnB,EAAE,YAAY,cAAc,GAAG,eAAe,GAAG,YAAY,GAC7D,EAAE;GACP,EACD,aACA,yBACD,CACF;EACD,GAAI,YAAY,aAAa,QACzB,OACA,GAEG,YAAY,YAAY,UAAU,GAAG,MAAM,KAAK,GAAQ,QAAQ;GAC/D,MAAM,aAAa,WAAW,OAAO,EAAE,MAAM,CAAC,GAAG,GAAG,MAAO,IAAI,EAAE;AACjE,OAAI,OAAO,MAAM,SAEf,QAAO,cAAc,MAAM;YAClBC,gCAAY,EAAE,CAEvB,QAAO,aAAa;IAAE,GAAG;IAAG,GAAG;IAAY,CAAC;AAG9C,UAAO,cACL,gBACE;IACE,GAAG;IACH,GAAG;IACH,GAAI,cAAc,IAAI,EAAE,UAAU,YAAY,EAAE,aAAa,EAAE,UAAU,GAAG,EAAE;IAC/E,EACD,aACA,yBACD,CACF;IACD,EACH;EACN;AAED,QAAO,aAAa;EAAE,GAAG;EAAO,GAAI,WAAW,OAAO,EAAE,MAAM,EAAE,EAAE;EAAG,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRuleGroup, isRuleGroupType } from "./isRuleGroup-
|
|
1
|
+
import { isRuleGroup, isRuleGroupType } from "./isRuleGroup-CGe_rb2w.mjs";
|
|
2
2
|
import { produce } from "immer";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/transformQuery.ts
|
|
@@ -38,4 +38,4 @@ function transformQuery(query, options = {}) {
|
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
40
|
export { transformQuery };
|
|
41
|
-
//# sourceMappingURL=transformQuery-
|
|
41
|
+
//# sourceMappingURL=transformQuery-DHvtgDgZ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformQuery-
|
|
1
|
+
{"version":3,"file":"transformQuery-DHvtgDgZ.mjs","names":[],"sources":["../src/utils/transformQuery.ts"],"sourcesContent":["/**\n * Recursively steps through a query object ({@link index!RuleGroupType RuleGroupType} or {@link index!RuleGroupTypeIC RuleGroupTypeIC}),\n * passing each {@link index!RuleType RuleType} object to a provided `ruleProcessor` function and returning a\n * new query object if there were any referential changes.\n *\n * @module transformQuery\n */\n\nimport { produce } from 'immer';\nimport type { RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleType } from '../types';\nimport { isRuleGroup, isRuleGroupType } from './isRuleGroup';\n\nconst remapProperties = (\n // oxlint-disable-next-line typescript/no-explicit-any\n obj: Record<string, any>,\n propertyMap: Record<string, string | false>,\n deleteRemappedProperties: boolean\n) =>\n produce(obj, draft => {\n for (const [k, v] of Object.entries(propertyMap)) {\n if (v === false) {\n delete draft[k];\n } else if (!!v && k !== v && k in draft) {\n draft[v] = draft[k];\n if (deleteRemappedProperties) {\n delete draft[k];\n }\n }\n }\n });\n\n/**\n * Options object for {@link index!transformQuery transformQuery}.\n */\nexport interface TransformQueryOptions<RG extends RuleGroupTypeAny = RuleGroupType> {\n /**\n * When a rule is encountered in the hierarchy, it will be replaced\n * with the result of this function.\n *\n * @defaultValue `r => r`\n */\n // oxlint-disable-next-line typescript/no-explicit-any\n ruleProcessor?: (rule: RuleType) => any;\n /**\n * When a group is encountered in the hierarchy (including the root group, the\n * query itself), it will be replaced with the result of this function.\n *\n * @defaultValue `rg => rg`\n */\n // oxlint-disable-next-line typescript/no-explicit-any\n ruleGroupProcessor?: (ruleGroup: RG) => Record<string, any>;\n /**\n * For each rule and group in the query, any properties matching a key\n * in this object will be renamed to the corresponding value. To retain both\n * the new _and_ the original properties, set `deleteRemappedProperties`\n * to `false`.\n *\n * If a key has a value of `false`, the corresponding property will be removed\n * without being copied to a new property name. (Warning: `{ rules: false }`\n * will prevent recursion and only return the processed root group.)\n *\n * @defaultValue `{}`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', not: true, rules: [] },\n * { propertyMap: { combinator: 'AndOr', not: false } }\n * )\n * // Returns: { AndOr: 'and', rules: [] }\n * ```\n */\n propertyMap?: Record<string, string | false>;\n /**\n * Any combinator values (including independent combinators) will be translated\n * from the key in this object to the value.\n *\n * @defaultValue `{}`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', rules: [] },\n * { combinatorMap: { and: '&&', or: '||' } }\n * )\n * // Returns: { combinator: '&&', rules: [] }\n * ```\n */\n combinatorMap?: Record<string, string>;\n /**\n * Any operator values will be translated from the key in this object to the value.\n *\n * @defaultValue `{}`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', rules: [{ field: 'name', operator: '=', value: 'Steve Vai' }] },\n * { operatorMap: { '=': 'is' } }\n * )\n * // Returns:\n * // {\n * // combinator: 'and',\n * // rules: [{ field: 'name', operator: 'is', value: 'Steve Vai' }]\n * // }\n * ```\n */\n operatorMap?: Record<string, string>;\n /**\n * Prevents the `path` property (see {@link index!Path Path}) from being added to each\n * rule and group in the hierarchy.\n *\n * @defaultValue `false`\n */\n omitPath?: boolean;\n /**\n * Original properties remapped according to the `propertyMap` option will be removed.\n *\n * @defaultValue `true`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', rules: [] },\n * { propertyMap: { combinator: 'AndOr' }, deleteRemappedProperties: false }\n * )\n * // Returns: { combinator: 'and', AndOr: 'and', rules: [] }\n * ```\n */\n deleteRemappedProperties?: boolean;\n}\n\n/**\n * Recursively process a query heirarchy using this versatile utility function.\n *\n * [Documentation](https://react-querybuilder.js.org/docs/utils/misc#transformquery)\n */\nexport function transformQuery(\n query: RuleGroupType,\n options?: TransformQueryOptions\n // oxlint-disable-next-line typescript/no-explicit-any\n): any;\n/**\n * Recursively process a query heirarchy with independent combinators using this\n * versatile utility function.\n *\n * [Documentation](https://react-querybuilder.js.org/docs/utils/misc#transformquery)\n */\nexport function transformQuery(\n query: RuleGroupTypeIC,\n options?: TransformQueryOptions<RuleGroupTypeIC>\n // oxlint-disable-next-line typescript/no-explicit-any\n): any;\nexport function transformQuery<RG extends RuleGroupTypeAny>(\n query: RG,\n options: TransformQueryOptions<RG> = {}\n) {\n const {\n ruleProcessor = r => r,\n ruleGroupProcessor = rg => rg,\n propertyMap = {},\n combinatorMap = {},\n operatorMap = {},\n omitPath = false,\n deleteRemappedProperties = true,\n } = options;\n\n // oxlint-disable-next-line typescript/no-explicit-any\n const processGroup = (rg: RuleGroupTypeAny): any => ({\n ...ruleGroupProcessor(\n remapProperties(\n {\n ...rg,\n ...(isRuleGroupType(rg)\n ? { combinator: combinatorMap[rg.combinator] ?? rg.combinator }\n : {}),\n },\n propertyMap,\n deleteRemappedProperties\n ) as RG\n ),\n ...(propertyMap['rules'] === false\n ? null\n : {\n // oxlint-disable-next-line typescript/no-explicit-any\n [propertyMap['rules'] ?? 'rules']: rg.rules.map((r: any, idx) => {\n const pathObject = omitPath ? null : { path: [...rg.path!, idx] };\n if (typeof r === 'string') {\n // independent combinators\n return combinatorMap[r] ?? r;\n } else if (isRuleGroup(r)) {\n // sub-groups\n return processGroup({ ...r, ...pathObject });\n }\n // rules\n return ruleProcessor(\n remapProperties(\n {\n ...r,\n ...pathObject,\n ...('operator' in r ? { operator: operatorMap[r.operator] ?? r.operator } : {}),\n },\n propertyMap,\n deleteRemappedProperties\n ) as RuleType\n );\n }),\n }),\n });\n\n return processGroup({ ...query, ...(omitPath ? null : { path: [] }) });\n}\n"],"mappings":";;;;AAYA,MAAM,mBAEJ,KACA,aACA,6BAEA,QAAQ,MAAK,UAAS;AACpB,MAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,YAAY,CAC9C,KAAI,MAAM,MACR,QAAO,MAAM;UACJ,CAAC,CAAC,KAAK,MAAM,KAAK,KAAK,OAAO;AACvC,QAAM,KAAK,MAAM;AACjB,MAAI,yBACF,QAAO,MAAM;;EAInB;AA4HJ,SAAgB,eACd,OACA,UAAqC,EAAE,EACvC;CACA,MAAM,EACJ,iBAAgB,MAAK,GACrB,sBAAqB,OAAM,IAC3B,cAAc,EAAE,EAChB,gBAAgB,EAAE,EAClB,cAAc,EAAE,EAChB,WAAW,OACX,2BAA2B,SACzB;CAGJ,MAAM,gBAAgB,QAA+B;EACnD,GAAG,mBACD,gBACE;GACE,GAAG;GACH,GAAI,gBAAgB,GAAG,GACnB,EAAE,YAAY,cAAc,GAAG,eAAe,GAAG,YAAY,GAC7D,EAAE;GACP,EACD,aACA,yBACD,CACF;EACD,GAAI,YAAY,aAAa,QACzB,OACA,GAEG,YAAY,YAAY,UAAU,GAAG,MAAM,KAAK,GAAQ,QAAQ;GAC/D,MAAM,aAAa,WAAW,OAAO,EAAE,MAAM,CAAC,GAAG,GAAG,MAAO,IAAI,EAAE;AACjE,OAAI,OAAO,MAAM,SAEf,QAAO,cAAc,MAAM;YAClB,YAAY,EAAE,CAEvB,QAAO,aAAa;IAAE,GAAG;IAAG,GAAG;IAAY,CAAC;AAG9C,UAAO,cACL,gBACE;IACE,GAAG;IACH,GAAG;IACH,GAAI,cAAc,IAAI,EAAE,UAAU,YAAY,EAAE,aAAa,EAAE,UAAU,GAAG,EAAE;IAC/E,EACD,aACA,yBACD,CACF;IACD,EACH;EACN;AAED,QAAO,aAAa;EAAE,GAAG;EAAO,GAAI,WAAW,OAAO,EAAE,MAAM,EAAE,EAAE;EAAG,CAAC"}
|
package/dist/transformQuery.d.ts
CHANGED
package/dist/transformQuery.js
CHANGED
package/dist/transformQuery.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-querybuilder/core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.10.0",
|
|
4
4
|
"description": "React Query Builder component for constructing queries and filters, with utilities for executing them in various database and evaluation contexts",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -144,24 +144,26 @@
|
|
|
144
144
|
"@babel/core": "^7.28.4",
|
|
145
145
|
"@babel/preset-env": "^7.28.3",
|
|
146
146
|
"@babel/preset-typescript": "^7.27.1",
|
|
147
|
-
"@electric-sql/pglite": "^0.3.
|
|
147
|
+
"@electric-sql/pglite": "^0.3.10",
|
|
148
148
|
"@types/json-logic-js": "^2.0.8",
|
|
149
|
-
"@types/node": "^24.
|
|
149
|
+
"@types/node": "^24.7.1",
|
|
150
150
|
"babel-plugin-istanbul": "^7.0.1",
|
|
151
|
-
"drizzle-orm": "^0.44.
|
|
151
|
+
"drizzle-orm": "^0.44.6",
|
|
152
152
|
"json-logic-js": "^2.0.5",
|
|
153
153
|
"jsonata": "^2.1.0",
|
|
154
|
-
"mongodb-memory-server-core": "^10.2.
|
|
155
|
-
"mongoose": "^8.
|
|
154
|
+
"mongodb-memory-server-core": "^10.2.3",
|
|
155
|
+
"mongoose": "^8.19.1",
|
|
156
156
|
"pglite-prisma-adapter": "^0.6.1",
|
|
157
|
-
"prisma": "~6.
|
|
157
|
+
"prisma": "~6.17.0",
|
|
158
158
|
"query-string": "^9.3.1",
|
|
159
159
|
"regenerator-runtime": "^0.14.1",
|
|
160
|
-
"rollup-plugin-visualizer": "^6.0.
|
|
161
|
-
"sass": "^1.
|
|
160
|
+
"rollup-plugin-visualizer": "^6.0.4",
|
|
161
|
+
"sass": "^1.93.2",
|
|
162
162
|
"sequelize": "^6.37.7",
|
|
163
|
-
"spel2js": "^0.2.
|
|
164
|
-
"
|
|
163
|
+
"spel2js": "^0.2.9",
|
|
164
|
+
"type-fest": "^4.41.0",
|
|
165
|
+
"typescript": "^5.9.3",
|
|
166
|
+
"vite": "^7.1.9"
|
|
165
167
|
},
|
|
166
168
|
"dependencies": {
|
|
167
169
|
"immer": "^10.1.3",
|
|
@@ -191,5 +193,5 @@
|
|
|
191
193
|
"typecheck": "tsc --noEmit",
|
|
192
194
|
"typecheck:watch": "tsc --noEmit --watch"
|
|
193
195
|
},
|
|
194
|
-
"gitHead": "
|
|
196
|
+
"gitHead": "fc383fac6b7deefae34f004c6fe60b924ddd3b20"
|
|
195
197
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrayUtils-BF1P8iHS.mjs","names":["defaultPlaceholderFieldName: typeof defaultPlaceholderName","defaultPlaceholderOperatorName: typeof defaultPlaceholderName","defaultOperatorNegationMap: Record<DefaultOperatorName, DefaultOperatorName>","defaultCombinators: DefaultCombinators","defaultCombinatorsExtended: DefaultCombinatorsExtended","v"],"sources":["../src/defaults.ts","../src/utils/arrayUtils.ts"],"sourcesContent":["import type {\n Classnames,\n DefaultCombinatorName,\n DefaultCombinatorNameExtended,\n DefaultOperatorName,\n MatchMode,\n Path,\n StringUnionToFullOptionArray,\n} from './types';\n\n// DO NOT ALTER OR REMOVE REGION NAMES. Some of them are used\n// to generate code snippets in the documentation.\n\n/**\n * @group Defaults\n */\nexport const defaultPlaceholderName = '~';\n/**\n * @group Defaults\n */\nexport const defaultPlaceholderLabel = '------';\n/**\n * Default `name` for placeholder option in the `fields` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderFieldName: typeof defaultPlaceholderName = defaultPlaceholderName;\n/**\n * Default `label` for placeholder option in the `fields` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderFieldLabel: typeof defaultPlaceholderLabel = defaultPlaceholderLabel;\n/**\n * Default `label` for placeholder option group in the `fields` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderFieldGroupLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n/**\n * Default `name` for placeholder option in the `operators` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderOperatorName: typeof defaultPlaceholderName = defaultPlaceholderName;\n/**\n * Default `label` for placeholder option in the `operators` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderOperatorLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n/**\n * Default `label` for placeholder option group in the `operators` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderOperatorGroupLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n/**\n * Default `name` for placeholder option in the `values` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderValueName: typeof defaultPlaceholderName = defaultPlaceholderName;\n/**\n * Default `label` for placeholder option in the `values` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderValueLabel: typeof defaultPlaceholderLabel = defaultPlaceholderLabel;\n/**\n * Default `label` for placeholder option group in the `values` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderValueGroupLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n\n/**\n * Default character used to `.join` and `.split` arrays.\n *\n * @group Defaults\n */\nexport const defaultJoinChar = ',';\n\nexport type DefaultOperators = StringUnionToFullOptionArray<DefaultOperatorName>;\n\nexport const defaultOperatorLabelMap: Record<DefaultOperatorName, string> = {\n '=': '=',\n '!=': '!=',\n '<': '<',\n '>': '>',\n '<=': '<=',\n '>=': '>=',\n contains: 'contains',\n beginsWith: 'begins with',\n endsWith: 'ends with',\n doesNotContain: 'does not contain',\n doesNotBeginWith: 'does not begin with',\n doesNotEndWith: 'does not end with',\n null: 'is null',\n notNull: 'is not null',\n in: 'in',\n notIn: 'not in',\n between: 'between',\n notBetween: 'not between',\n};\n\nexport const defaultCombinatorLabelMap: Record<DefaultCombinatorNameExtended, string> = {\n and: 'AND',\n or: 'OR',\n xor: 'XOR',\n};\n\n/**\n * Default operator list.\n *\n * @group Defaults\n */\n// #region docs-operators\nexport const defaultOperators: DefaultOperators = [\n { name: '=', value: '=', label: '=' },\n { name: '!=', value: '!=', label: '!=' },\n { name: '<', value: '<', label: '<' },\n { name: '>', value: '>', label: '>' },\n { name: '<=', value: '<=', label: '<=' },\n { name: '>=', value: '>=', label: '>=' },\n { name: 'contains', value: 'contains', label: 'contains' },\n { name: 'beginsWith', value: 'beginsWith', label: 'begins with' },\n { name: 'endsWith', value: 'endsWith', label: 'ends with' },\n { name: 'doesNotContain', value: 'doesNotContain', label: 'does not contain' },\n { name: 'doesNotBeginWith', value: 'doesNotBeginWith', label: 'does not begin with' },\n { name: 'doesNotEndWith', value: 'doesNotEndWith', label: 'does not end with' },\n { name: 'null', value: 'null', label: 'is null' },\n { name: 'notNull', value: 'notNull', label: 'is not null' },\n { name: 'in', value: 'in', label: 'in' },\n { name: 'notIn', value: 'notIn', label: 'not in' },\n { name: 'between', value: 'between', label: 'between' },\n { name: 'notBetween', value: 'notBetween', label: 'not between' },\n];\n// #endregion\n\n/**\n * Map of default operators to their respective opposite/negating operators.\n *\n * @group Defaults\n */\nexport const defaultOperatorNegationMap: Record<DefaultOperatorName, DefaultOperatorName> = {\n '=': '!=',\n '!=': '=',\n '<': '>=',\n '<=': '>',\n '>': '<=',\n '>=': '<',\n beginsWith: 'doesNotBeginWith',\n doesNotBeginWith: 'beginsWith',\n endsWith: 'doesNotEndWith',\n doesNotEndWith: 'endsWith',\n contains: 'doesNotContain',\n doesNotContain: 'contains',\n between: 'notBetween',\n notBetween: 'between',\n in: 'notIn',\n notIn: 'in',\n notNull: 'null',\n null: 'notNull',\n} satisfies Record<DefaultOperatorName, DefaultOperatorName>;\n\nexport type DefaultCombinators = StringUnionToFullOptionArray<DefaultCombinatorName>;\n\n/**\n * Default combinator list.\n *\n * @group Defaults\n */\n// #region docs-combinators\nexport const defaultCombinators: DefaultCombinators = [\n { name: 'and', value: 'and', label: 'AND' } as const,\n { name: 'or', value: 'or', label: 'OR' } as const,\n];\n// #endregion\n\nexport type DefaultCombinatorsExtended =\n StringUnionToFullOptionArray<DefaultCombinatorNameExtended>;\n\n/**\n * Default combinator list, with `XOR` added.\n *\n * @group Defaults\n */\nexport const defaultCombinatorsExtended: DefaultCombinatorsExtended = [\n ...defaultCombinators,\n { name: 'xor', value: 'xor', label: 'XOR' } as const,\n];\n\nexport type DefaultMatchModes = StringUnionToFullOptionArray<MatchMode>;\n\n/**\n * Default match modes.\n *\n * @group Defaults\n */\n// #region docs-matchmodes\nexport const defaultMatchModes: DefaultMatchModes = [\n { name: 'all', value: 'all', label: 'all' },\n { name: 'some', value: 'some', label: 'some' },\n { name: 'none', value: 'none', label: 'none' },\n { name: 'atLeast', value: 'atLeast', label: 'at least' },\n { name: 'atMost', value: 'atMost', label: 'at most' },\n { name: 'exactly', value: 'exactly', label: 'exactly' },\n];\n// #endregion\n\n/**\n * Standard classnames applied to each component.\n *\n * @group Defaults\n */\n// #region docs-standardclassnames\nexport const standardClassnames = {\n queryBuilder: 'queryBuilder',\n ruleGroup: 'ruleGroup',\n header: 'ruleGroup-header',\n body: 'ruleGroup-body',\n combinators: 'ruleGroup-combinators',\n addRule: 'ruleGroup-addRule',\n addGroup: 'ruleGroup-addGroup',\n cloneRule: 'rule-cloneRule',\n cloneGroup: 'ruleGroup-cloneGroup',\n removeGroup: 'ruleGroup-remove',\n notToggle: 'ruleGroup-notToggle',\n rule: 'rule',\n fields: 'rule-fields',\n matchMode: 'rule-matchMode',\n matchThreshold: 'rule-matchThreshold',\n operators: 'rule-operators',\n value: 'rule-value',\n removeRule: 'rule-remove',\n betweenRules: 'betweenRules',\n valid: 'queryBuilder-valid',\n invalid: 'queryBuilder-invalid',\n shiftActions: 'shiftActions',\n dndDragging: 'dndDragging',\n dndOver: 'dndOver',\n dndCopy: 'dndCopy',\n dndGroup: 'dndGroup',\n dndDropNotAllowed: 'dndDropNotAllowed',\n dragHandle: 'queryBuilder-dragHandle',\n disabled: 'queryBuilder-disabled',\n lockRule: 'rule-lock',\n lockGroup: 'ruleGroup-lock',\n valueSource: 'rule-valueSource',\n valueListItem: 'rule-value-list-item',\n branches: 'queryBuilder-branches',\n justified: 'queryBuilder-justified',\n hasSubQuery: 'rule-hasSubQuery',\n} as const;\n// #endregion\n\n/**\n * Default classnames for each component.\n *\n * @group Defaults\n */\nexport const defaultControlClassnames: Classnames = {\n queryBuilder: '',\n ruleGroup: '',\n header: '',\n body: '',\n combinators: '',\n addRule: '',\n addGroup: '',\n cloneRule: '',\n cloneGroup: '',\n removeGroup: '',\n notToggle: '',\n rule: '',\n fields: '',\n matchMode: '',\n matchThreshold: '',\n operators: '',\n value: '',\n removeRule: '',\n shiftActions: '',\n dragHandle: '',\n lockRule: '',\n lockGroup: '',\n valueSource: '',\n actionElement: '',\n valueSelector: '',\n betweenRules: '',\n valid: '',\n invalid: '',\n dndDragging: '',\n dndOver: '',\n dndGroup: '',\n dndCopy: '',\n dndDropNotAllowed: '',\n disabled: '',\n valueListItem: '',\n branches: '',\n hasSubQuery: '',\n} satisfies Classnames;\n\n/**\n * Default reason codes for a group being invalid.\n *\n * @group Defaults\n */\nexport const groupInvalidReasons = {\n empty: 'empty',\n invalidCombinator: 'invalid combinator',\n invalidIndependentCombinators: 'invalid independent combinators',\n} as const;\n\n/**\n * Component identifiers for testing.\n *\n * @group Defaults\n */\nexport const TestID = {\n rule: 'rule',\n ruleGroup: 'rule-group',\n inlineCombinator: 'inline-combinator',\n addGroup: 'add-group',\n removeGroup: 'remove-group',\n cloneGroup: 'clone-group',\n cloneRule: 'clone-rule',\n addRule: 'add-rule',\n removeRule: 'remove-rule',\n combinators: 'combinators',\n fields: 'fields',\n operators: 'operators',\n valueEditor: 'value-editor',\n notToggle: 'not-toggle',\n shiftActions: 'shift-actions',\n dragHandle: 'drag-handle',\n lockRule: 'lock-rule',\n lockGroup: 'lock-group',\n valueSourceSelector: 'value-source-selector',\n matchModeEditor: 'match-mode-editor',\n} as const;\n\nexport const LogType = {\n parentPathDisabled: 'action aborted: parent path disabled',\n pathDisabled: 'action aborted: path is disabled',\n queryUpdate: 'query updated',\n onAddRuleFalse: 'onAddRule callback returned false',\n onAddGroupFalse: 'onAddGroup callback returned false',\n onGroupRuleFalse: 'onGroupRule callback returned false',\n onGroupGroupFalse: 'onGroupGroup callback returned false',\n onMoveRuleFalse: 'onMoveRule callback returned false',\n onMoveGroupFalse: 'onMoveGroup callback returned false',\n onRemoveFalse: 'onRemove callback returned false',\n add: 'rule or group added',\n remove: 'rule or group removed',\n update: 'rule or group updated',\n move: 'rule or group moved',\n group: 'rule or group grouped with another',\n} as const;\n\n/**\n * The {@link Path} of the root group.\n *\n * @group Defaults\n */\nexport const rootPath: Path = [] satisfies Path;\n","import { defaultJoinChar } from '../defaults';\n\n/**\n * Splits a string by a given character (see {@link defaultJoinChar}). Escaped characters\n * (characters preceded by a backslash) will not apply to the split, and the backslash will\n * be removed in the array element. Inverse of {@link joinWith}.\n *\n * @example\n * splitBy('this\\\\,\\\\,that,,the other,,,\\\\,')\n * // or\n * splitBy('this\\\\,\\\\,that,,the other,,,\\\\,', ',')\n * // would return\n * ['this,,that', '', 'the other', '', '', ',']\n */\nexport const splitBy = (str?: string, splitChar: string = defaultJoinChar): string[] =>\n typeof str === 'string'\n ? str\n .split(`\\\\${splitChar}`)\n .map(c => c.split(splitChar))\n .reduce((prev, curr, idx) => {\n if (idx === 0) {\n return curr;\n }\n return [...prev.slice(0, -1), `${prev.at(-1)}${splitChar}${curr[0]}`, ...curr.slice(1)];\n }, [])\n : [];\n\n/**\n * Joins an array of strings using the given character (see {@link defaultJoinChar}). When\n * the given character appears in an array element, a backslash will be added just before it\n * to distinguish it from the join character. Effectively the inverse of {@link splitBy}.\n *\n * TIP: The join character can actually be a string of any length. Only the first character\n * will be searched for in the array elements and preceded by a backslash.\n *\n * @example\n * joinWith(['this,,that', '', 'the other', '', '', ','], ', ')\n * // would return\n * 'this\\\\,\\\\,that, , the other, , , \\\\,'\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const joinWith = (strArr: any[], joinChar: string = defaultJoinChar): string =>\n strArr.map(str => `${str ?? ''}`.replaceAll(joinChar[0], `\\\\${joinChar[0]}`)).join(joinChar);\n\n/**\n * Trims the value if it is a string. Otherwise returns the value as is.\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const trimIfString = (val: any): any => (typeof val === 'string' ? val.trim() : val);\n\n/**\n * Splits a string by comma then trims each element. Arrays are returned as is except\n * any string elements are trimmed.\n */\nexport const toArray = (\n // oxlint-disable-next-line typescript/no-explicit-any\n v: any,\n { retainEmptyStrings }: { retainEmptyStrings?: boolean } = {}\n // oxlint-disable-next-line typescript/no-explicit-any\n): any[] =>\n Array.isArray(v)\n ? v.map(v => trimIfString(v))\n : typeof v === 'string'\n ? splitBy(v, defaultJoinChar)\n .filter(retainEmptyStrings ? () => true : s => !/^\\s*$/.test(s))\n .map(s => s.trim())\n : typeof v === 'number'\n ? [v]\n : [];\n\n/**\n * Determines if an array is free of `null`/`undefined`.\n */\nexport const nullFreeArray = <T>(arr: T[]): arr is Exclude<T, null>[] =>\n arr.every(el => el === false || (el ?? false) !== false);\n"],"mappings":";;;;AAgBA,MAAa,yBAAyB;;;;;;AAUtC,MAAaA,8BAA6D;;;;;;AAmB1E,MAAaC,iCAAgE;;;;;;AAwC7E,MAAa,kBAAkB;;;;;;AAgE/B,MAAaC,6BAA+E;CAC1F,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,YAAY;CACZ,kBAAkB;CAClB,UAAU;CACV,gBAAgB;CAChB,UAAU;CACV,gBAAgB;CAChB,SAAS;CACT,YAAY;CACZ,IAAI;CACJ,OAAO;CACP,SAAS;CACT,MAAM;CACP;;;;;;AAUD,MAAaC,qBAAyC,CACpD;CAAE,MAAM;CAAO,OAAO;CAAO,OAAO;CAAO,EAC3C;CAAE,MAAM;CAAM,OAAO;CAAM,OAAO;CAAM,CACzC;;;;;;AAWD,MAAaC,6BAAyD,CACpE,GAAG,oBACH;CAAE,MAAM;CAAO,OAAO;CAAO,OAAO;CAAO,CAC5C;;;;;;;;;;;;;;;;ACrLD,MAAa,WAAW,KAAc,YAAoB,oBACxD,OAAO,QAAQ,WACX,IACG,MAAM,KAAK,YAAY,CACvB,KAAI,MAAK,EAAE,MAAM,UAAU,CAAC,CAC5B,QAAQ,MAAM,MAAM,QAAQ;AAC3B,KAAI,QAAQ,EACV,QAAO;AAET,QAAO;EAAC,GAAG,KAAK,MAAM,GAAG,GAAG;EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,YAAY,KAAK;EAAM,GAAG,KAAK,MAAM,EAAE;EAAC;GACtF,EAAE,CAAC,GACR,EAAE;;;;;;;;;;;;;;AAgBR,MAAa,YAAY,QAAe,WAAmB,oBACzD,OAAO,KAAI,QAAO,GAAG,OAAO,KAAK,WAAW,SAAS,IAAI,KAAK,SAAS,KAAK,CAAC,CAAC,KAAK,SAAS;;;;AAM9F,MAAa,gBAAgB,QAAmB,OAAO,QAAQ,WAAW,IAAI,MAAM,GAAG;;;;;AAMvF,MAAa,WAEX,GACA,EAAE,uBAAyD,EAAE,KAG7D,MAAM,QAAQ,EAAE,GACZ,EAAE,KAAI,QAAK,aAAaC,IAAE,CAAC,GAC3B,OAAO,MAAM,WACX,QAAQ,GAAG,gBAAgB,CACxB,OAAO,2BAA2B,QAAO,MAAK,CAAC,QAAQ,KAAK,EAAE,CAAC,CAC/D,KAAI,MAAK,EAAE,MAAM,CAAC,GACrB,OAAO,MAAM,WACX,CAAC,EAAE,GACH,EAAE"}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/defaults.ts
|
|
3
|
-
/**
|
|
4
|
-
* @group Defaults
|
|
5
|
-
*/
|
|
6
|
-
const defaultPlaceholderName = "~";
|
|
7
|
-
/**
|
|
8
|
-
* Default `name` for placeholder option in the `fields` array.
|
|
9
|
-
*
|
|
10
|
-
* @group Defaults
|
|
11
|
-
*/
|
|
12
|
-
const defaultPlaceholderFieldName = defaultPlaceholderName;
|
|
13
|
-
/**
|
|
14
|
-
* Default `name` for placeholder option in the `operators` array.
|
|
15
|
-
*
|
|
16
|
-
* @group Defaults
|
|
17
|
-
*/
|
|
18
|
-
const defaultPlaceholderOperatorName = defaultPlaceholderName;
|
|
19
|
-
/**
|
|
20
|
-
* Default character used to `.join` and `.split` arrays.
|
|
21
|
-
*
|
|
22
|
-
* @group Defaults
|
|
23
|
-
*/
|
|
24
|
-
const defaultJoinChar = ",";
|
|
25
|
-
/**
|
|
26
|
-
* Map of default operators to their respective opposite/negating operators.
|
|
27
|
-
*
|
|
28
|
-
* @group Defaults
|
|
29
|
-
*/
|
|
30
|
-
const defaultOperatorNegationMap = {
|
|
31
|
-
"=": "!=",
|
|
32
|
-
"!=": "=",
|
|
33
|
-
"<": ">=",
|
|
34
|
-
"<=": ">",
|
|
35
|
-
">": "<=",
|
|
36
|
-
">=": "<",
|
|
37
|
-
beginsWith: "doesNotBeginWith",
|
|
38
|
-
doesNotBeginWith: "beginsWith",
|
|
39
|
-
endsWith: "doesNotEndWith",
|
|
40
|
-
doesNotEndWith: "endsWith",
|
|
41
|
-
contains: "doesNotContain",
|
|
42
|
-
doesNotContain: "contains",
|
|
43
|
-
between: "notBetween",
|
|
44
|
-
notBetween: "between",
|
|
45
|
-
in: "notIn",
|
|
46
|
-
notIn: "in",
|
|
47
|
-
notNull: "null",
|
|
48
|
-
null: "notNull"
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Default combinator list.
|
|
52
|
-
*
|
|
53
|
-
* @group Defaults
|
|
54
|
-
*/
|
|
55
|
-
const defaultCombinators = [{
|
|
56
|
-
name: "and",
|
|
57
|
-
value: "and",
|
|
58
|
-
label: "AND"
|
|
59
|
-
}, {
|
|
60
|
-
name: "or",
|
|
61
|
-
value: "or",
|
|
62
|
-
label: "OR"
|
|
63
|
-
}];
|
|
64
|
-
/**
|
|
65
|
-
* Default combinator list, with `XOR` added.
|
|
66
|
-
*
|
|
67
|
-
* @group Defaults
|
|
68
|
-
*/
|
|
69
|
-
const defaultCombinatorsExtended = [...defaultCombinators, {
|
|
70
|
-
name: "xor",
|
|
71
|
-
value: "xor",
|
|
72
|
-
label: "XOR"
|
|
73
|
-
}];
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region src/utils/arrayUtils.ts
|
|
77
|
-
/**
|
|
78
|
-
* Splits a string by a given character (see {@link defaultJoinChar}). Escaped characters
|
|
79
|
-
* (characters preceded by a backslash) will not apply to the split, and the backslash will
|
|
80
|
-
* be removed in the array element. Inverse of {@link joinWith}.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* splitBy('this\\,\\,that,,the other,,,\\,')
|
|
84
|
-
* // or
|
|
85
|
-
* splitBy('this\\,\\,that,,the other,,,\\,', ',')
|
|
86
|
-
* // would return
|
|
87
|
-
* ['this,,that', '', 'the other', '', '', ',']
|
|
88
|
-
*/
|
|
89
|
-
const splitBy = (str, splitChar = defaultJoinChar) => typeof str === "string" ? str.split(`\\${splitChar}`).map((c) => c.split(splitChar)).reduce((prev, curr, idx) => {
|
|
90
|
-
if (idx === 0) return curr;
|
|
91
|
-
return [
|
|
92
|
-
...prev.slice(0, -1),
|
|
93
|
-
`${prev.at(-1)}${splitChar}${curr[0]}`,
|
|
94
|
-
...curr.slice(1)
|
|
95
|
-
];
|
|
96
|
-
}, []) : [];
|
|
97
|
-
/**
|
|
98
|
-
* Joins an array of strings using the given character (see {@link defaultJoinChar}). When
|
|
99
|
-
* the given character appears in an array element, a backslash will be added just before it
|
|
100
|
-
* to distinguish it from the join character. Effectively the inverse of {@link splitBy}.
|
|
101
|
-
*
|
|
102
|
-
* TIP: The join character can actually be a string of any length. Only the first character
|
|
103
|
-
* will be searched for in the array elements and preceded by a backslash.
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* joinWith(['this,,that', '', 'the other', '', '', ','], ', ')
|
|
107
|
-
* // would return
|
|
108
|
-
* 'this\\,\\,that, , the other, , , \\,'
|
|
109
|
-
*/
|
|
110
|
-
const joinWith = (strArr, joinChar = defaultJoinChar) => strArr.map((str) => `${str ?? ""}`.replaceAll(joinChar[0], `\\${joinChar[0]}`)).join(joinChar);
|
|
111
|
-
/**
|
|
112
|
-
* Trims the value if it is a string. Otherwise returns the value as is.
|
|
113
|
-
*/
|
|
114
|
-
const trimIfString = (val) => typeof val === "string" ? val.trim() : val;
|
|
115
|
-
/**
|
|
116
|
-
* Splits a string by comma then trims each element. Arrays are returned as is except
|
|
117
|
-
* any string elements are trimmed.
|
|
118
|
-
*/
|
|
119
|
-
const toArray = (v, { retainEmptyStrings } = {}) => Array.isArray(v) ? v.map((v$1) => trimIfString(v$1)) : typeof v === "string" ? splitBy(v, defaultJoinChar).filter(retainEmptyStrings ? () => true : (s) => !/^\s*$/.test(s)).map((s) => s.trim()) : typeof v === "number" ? [v] : [];
|
|
120
|
-
|
|
121
|
-
//#endregion
|
|
122
|
-
Object.defineProperty(exports, 'defaultOperatorNegationMap', {
|
|
123
|
-
enumerable: true,
|
|
124
|
-
get: function () {
|
|
125
|
-
return defaultOperatorNegationMap;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
Object.defineProperty(exports, 'defaultPlaceholderFieldName', {
|
|
129
|
-
enumerable: true,
|
|
130
|
-
get: function () {
|
|
131
|
-
return defaultPlaceholderFieldName;
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
Object.defineProperty(exports, 'defaultPlaceholderOperatorName', {
|
|
135
|
-
enumerable: true,
|
|
136
|
-
get: function () {
|
|
137
|
-
return defaultPlaceholderOperatorName;
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
Object.defineProperty(exports, 'joinWith', {
|
|
141
|
-
enumerable: true,
|
|
142
|
-
get: function () {
|
|
143
|
-
return joinWith;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
Object.defineProperty(exports, 'splitBy', {
|
|
147
|
-
enumerable: true,
|
|
148
|
-
get: function () {
|
|
149
|
-
return splitBy;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
Object.defineProperty(exports, 'toArray', {
|
|
153
|
-
enumerable: true,
|
|
154
|
-
get: function () {
|
|
155
|
-
return toArray;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
Object.defineProperty(exports, 'trimIfString', {
|
|
159
|
-
enumerable: true,
|
|
160
|
-
get: function () {
|
|
161
|
-
return trimIfString;
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
//# sourceMappingURL=arrayUtils-D5EoIsKP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrayUtils-D5EoIsKP.js","names":["defaultPlaceholderFieldName: typeof defaultPlaceholderName","defaultPlaceholderOperatorName: typeof defaultPlaceholderName","defaultOperatorNegationMap: Record<DefaultOperatorName, DefaultOperatorName>","defaultCombinators: DefaultCombinators","defaultCombinatorsExtended: DefaultCombinatorsExtended","v"],"sources":["../src/defaults.ts","../src/utils/arrayUtils.ts"],"sourcesContent":["import type {\n Classnames,\n DefaultCombinatorName,\n DefaultCombinatorNameExtended,\n DefaultOperatorName,\n MatchMode,\n Path,\n StringUnionToFullOptionArray,\n} from './types';\n\n// DO NOT ALTER OR REMOVE REGION NAMES. Some of them are used\n// to generate code snippets in the documentation.\n\n/**\n * @group Defaults\n */\nexport const defaultPlaceholderName = '~';\n/**\n * @group Defaults\n */\nexport const defaultPlaceholderLabel = '------';\n/**\n * Default `name` for placeholder option in the `fields` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderFieldName: typeof defaultPlaceholderName = defaultPlaceholderName;\n/**\n * Default `label` for placeholder option in the `fields` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderFieldLabel: typeof defaultPlaceholderLabel = defaultPlaceholderLabel;\n/**\n * Default `label` for placeholder option group in the `fields` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderFieldGroupLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n/**\n * Default `name` for placeholder option in the `operators` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderOperatorName: typeof defaultPlaceholderName = defaultPlaceholderName;\n/**\n * Default `label` for placeholder option in the `operators` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderOperatorLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n/**\n * Default `label` for placeholder option group in the `operators` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderOperatorGroupLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n/**\n * Default `name` for placeholder option in the `values` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderValueName: typeof defaultPlaceholderName = defaultPlaceholderName;\n/**\n * Default `label` for placeholder option in the `values` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderValueLabel: typeof defaultPlaceholderLabel = defaultPlaceholderLabel;\n/**\n * Default `label` for placeholder option group in the `values` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderValueGroupLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n\n/**\n * Default character used to `.join` and `.split` arrays.\n *\n * @group Defaults\n */\nexport const defaultJoinChar = ',';\n\nexport type DefaultOperators = StringUnionToFullOptionArray<DefaultOperatorName>;\n\nexport const defaultOperatorLabelMap: Record<DefaultOperatorName, string> = {\n '=': '=',\n '!=': '!=',\n '<': '<',\n '>': '>',\n '<=': '<=',\n '>=': '>=',\n contains: 'contains',\n beginsWith: 'begins with',\n endsWith: 'ends with',\n doesNotContain: 'does not contain',\n doesNotBeginWith: 'does not begin with',\n doesNotEndWith: 'does not end with',\n null: 'is null',\n notNull: 'is not null',\n in: 'in',\n notIn: 'not in',\n between: 'between',\n notBetween: 'not between',\n};\n\nexport const defaultCombinatorLabelMap: Record<DefaultCombinatorNameExtended, string> = {\n and: 'AND',\n or: 'OR',\n xor: 'XOR',\n};\n\n/**\n * Default operator list.\n *\n * @group Defaults\n */\n// #region docs-operators\nexport const defaultOperators: DefaultOperators = [\n { name: '=', value: '=', label: '=' },\n { name: '!=', value: '!=', label: '!=' },\n { name: '<', value: '<', label: '<' },\n { name: '>', value: '>', label: '>' },\n { name: '<=', value: '<=', label: '<=' },\n { name: '>=', value: '>=', label: '>=' },\n { name: 'contains', value: 'contains', label: 'contains' },\n { name: 'beginsWith', value: 'beginsWith', label: 'begins with' },\n { name: 'endsWith', value: 'endsWith', label: 'ends with' },\n { name: 'doesNotContain', value: 'doesNotContain', label: 'does not contain' },\n { name: 'doesNotBeginWith', value: 'doesNotBeginWith', label: 'does not begin with' },\n { name: 'doesNotEndWith', value: 'doesNotEndWith', label: 'does not end with' },\n { name: 'null', value: 'null', label: 'is null' },\n { name: 'notNull', value: 'notNull', label: 'is not null' },\n { name: 'in', value: 'in', label: 'in' },\n { name: 'notIn', value: 'notIn', label: 'not in' },\n { name: 'between', value: 'between', label: 'between' },\n { name: 'notBetween', value: 'notBetween', label: 'not between' },\n];\n// #endregion\n\n/**\n * Map of default operators to their respective opposite/negating operators.\n *\n * @group Defaults\n */\nexport const defaultOperatorNegationMap: Record<DefaultOperatorName, DefaultOperatorName> = {\n '=': '!=',\n '!=': '=',\n '<': '>=',\n '<=': '>',\n '>': '<=',\n '>=': '<',\n beginsWith: 'doesNotBeginWith',\n doesNotBeginWith: 'beginsWith',\n endsWith: 'doesNotEndWith',\n doesNotEndWith: 'endsWith',\n contains: 'doesNotContain',\n doesNotContain: 'contains',\n between: 'notBetween',\n notBetween: 'between',\n in: 'notIn',\n notIn: 'in',\n notNull: 'null',\n null: 'notNull',\n} satisfies Record<DefaultOperatorName, DefaultOperatorName>;\n\nexport type DefaultCombinators = StringUnionToFullOptionArray<DefaultCombinatorName>;\n\n/**\n * Default combinator list.\n *\n * @group Defaults\n */\n// #region docs-combinators\nexport const defaultCombinators: DefaultCombinators = [\n { name: 'and', value: 'and', label: 'AND' } as const,\n { name: 'or', value: 'or', label: 'OR' } as const,\n];\n// #endregion\n\nexport type DefaultCombinatorsExtended =\n StringUnionToFullOptionArray<DefaultCombinatorNameExtended>;\n\n/**\n * Default combinator list, with `XOR` added.\n *\n * @group Defaults\n */\nexport const defaultCombinatorsExtended: DefaultCombinatorsExtended = [\n ...defaultCombinators,\n { name: 'xor', value: 'xor', label: 'XOR' } as const,\n];\n\nexport type DefaultMatchModes = StringUnionToFullOptionArray<MatchMode>;\n\n/**\n * Default match modes.\n *\n * @group Defaults\n */\n// #region docs-matchmodes\nexport const defaultMatchModes: DefaultMatchModes = [\n { name: 'all', value: 'all', label: 'all' },\n { name: 'some', value: 'some', label: 'some' },\n { name: 'none', value: 'none', label: 'none' },\n { name: 'atLeast', value: 'atLeast', label: 'at least' },\n { name: 'atMost', value: 'atMost', label: 'at most' },\n { name: 'exactly', value: 'exactly', label: 'exactly' },\n];\n// #endregion\n\n/**\n * Standard classnames applied to each component.\n *\n * @group Defaults\n */\n// #region docs-standardclassnames\nexport const standardClassnames = {\n queryBuilder: 'queryBuilder',\n ruleGroup: 'ruleGroup',\n header: 'ruleGroup-header',\n body: 'ruleGroup-body',\n combinators: 'ruleGroup-combinators',\n addRule: 'ruleGroup-addRule',\n addGroup: 'ruleGroup-addGroup',\n cloneRule: 'rule-cloneRule',\n cloneGroup: 'ruleGroup-cloneGroup',\n removeGroup: 'ruleGroup-remove',\n notToggle: 'ruleGroup-notToggle',\n rule: 'rule',\n fields: 'rule-fields',\n matchMode: 'rule-matchMode',\n matchThreshold: 'rule-matchThreshold',\n operators: 'rule-operators',\n value: 'rule-value',\n removeRule: 'rule-remove',\n betweenRules: 'betweenRules',\n valid: 'queryBuilder-valid',\n invalid: 'queryBuilder-invalid',\n shiftActions: 'shiftActions',\n dndDragging: 'dndDragging',\n dndOver: 'dndOver',\n dndCopy: 'dndCopy',\n dndGroup: 'dndGroup',\n dndDropNotAllowed: 'dndDropNotAllowed',\n dragHandle: 'queryBuilder-dragHandle',\n disabled: 'queryBuilder-disabled',\n lockRule: 'rule-lock',\n lockGroup: 'ruleGroup-lock',\n valueSource: 'rule-valueSource',\n valueListItem: 'rule-value-list-item',\n branches: 'queryBuilder-branches',\n justified: 'queryBuilder-justified',\n hasSubQuery: 'rule-hasSubQuery',\n} as const;\n// #endregion\n\n/**\n * Default classnames for each component.\n *\n * @group Defaults\n */\nexport const defaultControlClassnames: Classnames = {\n queryBuilder: '',\n ruleGroup: '',\n header: '',\n body: '',\n combinators: '',\n addRule: '',\n addGroup: '',\n cloneRule: '',\n cloneGroup: '',\n removeGroup: '',\n notToggle: '',\n rule: '',\n fields: '',\n matchMode: '',\n matchThreshold: '',\n operators: '',\n value: '',\n removeRule: '',\n shiftActions: '',\n dragHandle: '',\n lockRule: '',\n lockGroup: '',\n valueSource: '',\n actionElement: '',\n valueSelector: '',\n betweenRules: '',\n valid: '',\n invalid: '',\n dndDragging: '',\n dndOver: '',\n dndGroup: '',\n dndCopy: '',\n dndDropNotAllowed: '',\n disabled: '',\n valueListItem: '',\n branches: '',\n hasSubQuery: '',\n} satisfies Classnames;\n\n/**\n * Default reason codes for a group being invalid.\n *\n * @group Defaults\n */\nexport const groupInvalidReasons = {\n empty: 'empty',\n invalidCombinator: 'invalid combinator',\n invalidIndependentCombinators: 'invalid independent combinators',\n} as const;\n\n/**\n * Component identifiers for testing.\n *\n * @group Defaults\n */\nexport const TestID = {\n rule: 'rule',\n ruleGroup: 'rule-group',\n inlineCombinator: 'inline-combinator',\n addGroup: 'add-group',\n removeGroup: 'remove-group',\n cloneGroup: 'clone-group',\n cloneRule: 'clone-rule',\n addRule: 'add-rule',\n removeRule: 'remove-rule',\n combinators: 'combinators',\n fields: 'fields',\n operators: 'operators',\n valueEditor: 'value-editor',\n notToggle: 'not-toggle',\n shiftActions: 'shift-actions',\n dragHandle: 'drag-handle',\n lockRule: 'lock-rule',\n lockGroup: 'lock-group',\n valueSourceSelector: 'value-source-selector',\n matchModeEditor: 'match-mode-editor',\n} as const;\n\nexport const LogType = {\n parentPathDisabled: 'action aborted: parent path disabled',\n pathDisabled: 'action aborted: path is disabled',\n queryUpdate: 'query updated',\n onAddRuleFalse: 'onAddRule callback returned false',\n onAddGroupFalse: 'onAddGroup callback returned false',\n onGroupRuleFalse: 'onGroupRule callback returned false',\n onGroupGroupFalse: 'onGroupGroup callback returned false',\n onMoveRuleFalse: 'onMoveRule callback returned false',\n onMoveGroupFalse: 'onMoveGroup callback returned false',\n onRemoveFalse: 'onRemove callback returned false',\n add: 'rule or group added',\n remove: 'rule or group removed',\n update: 'rule or group updated',\n move: 'rule or group moved',\n group: 'rule or group grouped with another',\n} as const;\n\n/**\n * The {@link Path} of the root group.\n *\n * @group Defaults\n */\nexport const rootPath: Path = [] satisfies Path;\n","import { defaultJoinChar } from '../defaults';\n\n/**\n * Splits a string by a given character (see {@link defaultJoinChar}). Escaped characters\n * (characters preceded by a backslash) will not apply to the split, and the backslash will\n * be removed in the array element. Inverse of {@link joinWith}.\n *\n * @example\n * splitBy('this\\\\,\\\\,that,,the other,,,\\\\,')\n * // or\n * splitBy('this\\\\,\\\\,that,,the other,,,\\\\,', ',')\n * // would return\n * ['this,,that', '', 'the other', '', '', ',']\n */\nexport const splitBy = (str?: string, splitChar: string = defaultJoinChar): string[] =>\n typeof str === 'string'\n ? str\n .split(`\\\\${splitChar}`)\n .map(c => c.split(splitChar))\n .reduce((prev, curr, idx) => {\n if (idx === 0) {\n return curr;\n }\n return [...prev.slice(0, -1), `${prev.at(-1)}${splitChar}${curr[0]}`, ...curr.slice(1)];\n }, [])\n : [];\n\n/**\n * Joins an array of strings using the given character (see {@link defaultJoinChar}). When\n * the given character appears in an array element, a backslash will be added just before it\n * to distinguish it from the join character. Effectively the inverse of {@link splitBy}.\n *\n * TIP: The join character can actually be a string of any length. Only the first character\n * will be searched for in the array elements and preceded by a backslash.\n *\n * @example\n * joinWith(['this,,that', '', 'the other', '', '', ','], ', ')\n * // would return\n * 'this\\\\,\\\\,that, , the other, , , \\\\,'\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const joinWith = (strArr: any[], joinChar: string = defaultJoinChar): string =>\n strArr.map(str => `${str ?? ''}`.replaceAll(joinChar[0], `\\\\${joinChar[0]}`)).join(joinChar);\n\n/**\n * Trims the value if it is a string. Otherwise returns the value as is.\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const trimIfString = (val: any): any => (typeof val === 'string' ? val.trim() : val);\n\n/**\n * Splits a string by comma then trims each element. Arrays are returned as is except\n * any string elements are trimmed.\n */\nexport const toArray = (\n // oxlint-disable-next-line typescript/no-explicit-any\n v: any,\n { retainEmptyStrings }: { retainEmptyStrings?: boolean } = {}\n // oxlint-disable-next-line typescript/no-explicit-any\n): any[] =>\n Array.isArray(v)\n ? v.map(v => trimIfString(v))\n : typeof v === 'string'\n ? splitBy(v, defaultJoinChar)\n .filter(retainEmptyStrings ? () => true : s => !/^\\s*$/.test(s))\n .map(s => s.trim())\n : typeof v === 'number'\n ? [v]\n : [];\n\n/**\n * Determines if an array is free of `null`/`undefined`.\n */\nexport const nullFreeArray = <T>(arr: T[]): arr is Exclude<T, null>[] =>\n arr.every(el => el === false || (el ?? false) !== false);\n"],"mappings":";;;;;AAgBA,MAAa,yBAAyB;;;;;;AAUtC,MAAaA,8BAA6D;;;;;;AAmB1E,MAAaC,iCAAgE;;;;;;AAwC7E,MAAa,kBAAkB;;;;;;AAgE/B,MAAaC,6BAA+E;CAC1F,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,YAAY;CACZ,kBAAkB;CAClB,UAAU;CACV,gBAAgB;CAChB,UAAU;CACV,gBAAgB;CAChB,SAAS;CACT,YAAY;CACZ,IAAI;CACJ,OAAO;CACP,SAAS;CACT,MAAM;CACP;;;;;;AAUD,MAAaC,qBAAyC,CACpD;CAAE,MAAM;CAAO,OAAO;CAAO,OAAO;CAAO,EAC3C;CAAE,MAAM;CAAM,OAAO;CAAM,OAAO;CAAM,CACzC;;;;;;AAWD,MAAaC,6BAAyD,CACpE,GAAG,oBACH;CAAE,MAAM;CAAO,OAAO;CAAO,OAAO;CAAO,CAC5C;;;;;;;;;;;;;;;;ACrLD,MAAa,WAAW,KAAc,YAAoB,oBACxD,OAAO,QAAQ,WACX,IACG,MAAM,KAAK,YAAY,CACvB,KAAI,MAAK,EAAE,MAAM,UAAU,CAAC,CAC5B,QAAQ,MAAM,MAAM,QAAQ;AAC3B,KAAI,QAAQ,EACV,QAAO;AAET,QAAO;EAAC,GAAG,KAAK,MAAM,GAAG,GAAG;EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,YAAY,KAAK;EAAM,GAAG,KAAK,MAAM,EAAE;EAAC;GACtF,EAAE,CAAC,GACR,EAAE;;;;;;;;;;;;;;AAgBR,MAAa,YAAY,QAAe,WAAmB,oBACzD,OAAO,KAAI,QAAO,GAAG,OAAO,KAAK,WAAW,SAAS,IAAI,KAAK,SAAS,KAAK,CAAC,CAAC,KAAK,SAAS;;;;AAM9F,MAAa,gBAAgB,QAAmB,OAAO,QAAQ,WAAW,IAAI,MAAM,GAAG;;;;;AAMvF,MAAa,WAEX,GACA,EAAE,uBAAyD,EAAE,KAG7D,MAAM,QAAQ,EAAE,GACZ,EAAE,KAAI,QAAK,aAAaC,IAAE,CAAC,GAC3B,OAAO,MAAM,WACX,QAAQ,GAAG,gBAAgB,CACxB,OAAO,2BAA2B,QAAO,MAAK,CAAC,QAAQ,KAAK,EAAE,CAAC,CAC/D,KAAI,MAAK,EAAE,MAAM,CAAC,GACrB,OAAO,MAAM,WACX,CAAC,EAAE,GACH,EAAE"}
|