@react-querybuilder/core 8.11.1 → 8.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/{basic-BeKPP0_1.d.ts → basic-DbvrfPNz.d.mts} +39 -4
  2. package/dist/{basic-B4vXboTG.d.mts → basic-o1-sYjK6.d.ts} +39 -4
  3. package/dist/chunk-BxBTb9qk.js +39 -0
  4. package/dist/chunk-DrjzjjTJ.mjs +23 -0
  5. package/dist/chunk-Dv2ph0Ay.js +23 -0
  6. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +131 -53
  7. package/dist/cjs/react-querybuilder_core.cjs.development.js +36 -39
  8. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  9. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +131 -53
  10. package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
  11. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
  12. package/dist/{convertQuery-CqX3rPvj.mjs → convertQuery-Cj4t-LT4.mjs} +2 -2
  13. package/dist/{convertQuery-CqX3rPvj.mjs.map → convertQuery-Cj4t-LT4.mjs.map} +1 -1
  14. package/dist/{convertQuery-DAqoID3O.js → convertQuery-DuY_BJHy.js} +3 -3
  15. package/dist/{convertQuery-DAqoID3O.js.map → convertQuery-DuY_BJHy.js.map} +1 -1
  16. package/dist/{export-BjRt-qrK.d.mts → export-CCULKoP4.d.mts} +2 -2
  17. package/dist/{export-CQB0nuvW.d.ts → export-WDHFbiPz.d.ts} +2 -2
  18. package/dist/formatQuery.d.mts +15 -3
  19. package/dist/formatQuery.d.ts +15 -3
  20. package/dist/formatQuery.js +172 -425
  21. package/dist/formatQuery.js.map +1 -1
  22. package/dist/formatQuery.mjs +4 -257
  23. package/dist/formatQuery.mjs.map +1 -1
  24. package/dist/{import-Dvayhrgj.d.ts → import-BSWb9Vgd.d.ts} +2 -2
  25. package/dist/{import-Bc_p8ls9.d.mts → import-CLyHpgk8.d.mts} +2 -2
  26. package/dist/{isRuleGroup-CYcfPgbg.mjs → isRuleGroup-BcfwGaIN.mjs} +1 -1
  27. package/dist/{isRuleGroup-CYcfPgbg.mjs.map → isRuleGroup-BcfwGaIN.mjs.map} +1 -1
  28. package/dist/{isRuleGroup-DqAs2x4E.js → isRuleGroup-Do9KKsmt.js} +2 -40
  29. package/dist/{isRuleGroup-DqAs2x4E.js.map → isRuleGroup-Do9KKsmt.js.map} +1 -1
  30. package/dist/parseCEL.d.mts +32 -7
  31. package/dist/parseCEL.d.ts +32 -7
  32. package/dist/parseCEL.js +181 -12
  33. package/dist/parseCEL.js.map +1 -1
  34. package/dist/parseCEL.mjs +174 -8
  35. package/dist/parseCEL.mjs.map +1 -1
  36. package/dist/parseJSONata.d.mts +2 -2
  37. package/dist/parseJSONata.d.ts +2 -2
  38. package/dist/parseJSONata.js +6 -5
  39. package/dist/parseJSONata.js.map +1 -1
  40. package/dist/parseJSONata.mjs +3 -3
  41. package/dist/parseJsonLogic.d.mts +3 -3
  42. package/dist/parseJsonLogic.d.ts +3 -3
  43. package/dist/parseJsonLogic.js +10 -11
  44. package/dist/parseJsonLogic.js.map +1 -1
  45. package/dist/parseJsonLogic.mjs +4 -5
  46. package/dist/parseJsonLogic.mjs.map +1 -1
  47. package/dist/parseMongoDB.d.mts +2 -2
  48. package/dist/parseMongoDB.d.ts +2 -2
  49. package/dist/parseMongoDB.js +20 -21
  50. package/dist/parseMongoDB.js.map +1 -1
  51. package/dist/parseMongoDB.mjs +4 -5
  52. package/dist/parseMongoDB.mjs.map +1 -1
  53. package/dist/parseSQL.d.mts +2 -2
  54. package/dist/parseSQL.d.ts +2 -2
  55. package/dist/parseSQL.js +10 -13
  56. package/dist/parseSQL.js.map +1 -1
  57. package/dist/parseSQL.mjs +3 -5
  58. package/dist/parseSQL.mjs.map +1 -1
  59. package/dist/parseSpEL.d.mts +2 -2
  60. package/dist/parseSpEL.d.ts +2 -2
  61. package/dist/parseSpEL.js +7 -7
  62. package/dist/parseSpEL.js.map +1 -1
  63. package/dist/parseSpEL.mjs +3 -4
  64. package/dist/parseSpEL.mjs.map +1 -1
  65. package/dist/{prepareQueryObjects-DPCC-iHp.mjs → prepareQueryObjects-BfnyRV5t.mjs} +4 -3
  66. package/dist/{prepareQueryObjects-DPCC-iHp.mjs.map → prepareQueryObjects-BfnyRV5t.mjs.map} +1 -1
  67. package/dist/{prepareQueryObjects-BOUWfel5.js → prepareQueryObjects-DCtJJrF5.js} +14 -13
  68. package/dist/prepareQueryObjects-DCtJJrF5.js.map +1 -0
  69. package/dist/react-querybuilder_core.d.mts +131 -53
  70. package/dist/react-querybuilder_core.legacy-esm.d.ts +131 -53
  71. package/dist/react-querybuilder_core.legacy-esm.js +43 -21
  72. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  73. package/dist/react-querybuilder_core.mjs +36 -14
  74. package/dist/react-querybuilder_core.mjs.map +1 -1
  75. package/dist/react-querybuilder_core.production.d.mts +131 -53
  76. package/dist/react-querybuilder_core.production.mjs +1 -1
  77. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  78. package/dist/{transformQuery-DCCpjtyq.mjs → transformQuery-Bq4iyYsE.mjs} +9 -2
  79. package/dist/{transformQuery-DCCpjtyq.mjs.map → transformQuery-Bq4iyYsE.mjs.map} +1 -1
  80. package/dist/{transformQuery-CWDPogO5.js → transformQuery-DvJTAvkh.js} +10 -3
  81. package/dist/{transformQuery-CWDPogO5.js.map → transformQuery-DvJTAvkh.js.map} +1 -1
  82. package/dist/transformQuery.d.mts +1 -1
  83. package/dist/transformQuery.d.ts +1 -1
  84. package/dist/transformQuery.js +2 -2
  85. package/dist/transformQuery.mjs +2 -2
  86. package/dist/utils-CoYbYnVo.js +706 -0
  87. package/dist/utils-CoYbYnVo.js.map +1 -0
  88. package/dist/utils-DxH23QtE.mjs +514 -0
  89. package/dist/utils-DxH23QtE.mjs.map +1 -0
  90. package/package.json +15 -15
  91. package/dist/arrayUtils-A_OXU9W1.mjs +0 -50
  92. package/dist/arrayUtils-A_OXU9W1.mjs.map +0 -1
  93. package/dist/arrayUtils-QxZOZTf6.js +0 -73
  94. package/dist/arrayUtils-QxZOZTf6.js.map +0 -1
  95. package/dist/optGroupUtils-B0hTpodo.js +0 -251
  96. package/dist/optGroupUtils-B0hTpodo.js.map +0 -1
  97. package/dist/optGroupUtils-VeZ3k7-1.mjs +0 -185
  98. package/dist/optGroupUtils-VeZ3k7-1.mjs.map +0 -1
  99. package/dist/parseNumber-CXdMVNFx.mjs +0 -24
  100. package/dist/parseNumber-CXdMVNFx.mjs.map +0 -1
  101. package/dist/parseNumber-D4iQDxK-.js +0 -31
  102. package/dist/parseNumber-D4iQDxK-.js.map +0 -1
  103. package/dist/prepareQueryObjects-BOUWfel5.js.map +0 -1
@@ -1,9 +1,7 @@
1
- import { d as defaultPlaceholderOperatorName, i as toFlatOptionArray, o as toFullOptionList, t as getOption, u as defaultPlaceholderFieldName } from "./optGroupUtils-VeZ3k7-1.mjs";
2
- import { i as trimIfString, n as splitBy, r as toArray, t as joinWith } from "./arrayUtils-A_OXU9W1.mjs";
3
- import { a as lc, i as isPojo, n as isRuleGroupType, o as nullOrUndefinedOrEmpty, r as isRuleGroupTypeIC, s as numericRegex, t as isRuleGroup } from "./isRuleGroup-CYcfPgbg.mjs";
4
- import { t as parseNumber } from "./parseNumber-CXdMVNFx.mjs";
5
- import { t as transformQuery } from "./transformQuery-DCCpjtyq.mjs";
6
- import { t as convertFromIC } from "./convertQuery-CqX3rPvj.mjs";
1
+ import { E as parseNumber, M as defaultPlaceholderOperatorName, O as toArray, S as toFlatOptionArray, _ as shouldRenderAsNumber, a as getNLTranslataion, c as isValidValue, d as mapSQLOperator, f as mongoOperators, g as processMatchMode, h as prismaOperators, i as defaultNLTranslations, j as defaultPlaceholderFieldName, k as trimIfString, l as isValueProcessorLegacy, m as numerifyValues, n as bigIntJsonStringifyReplacer, o as getQuoteFieldNamesWithArray, p as normalizeConstituentWordOrder, r as celCombinatorMap, s as getQuotedFieldName, t as bigIntJsonParseReviver, u as jsonLogicAdditionalOperators, v as getParseNumberMethod, w as toFullOptionList, y as getOption } from "./utils-DxH23QtE.mjs";
2
+ import { a as lc, i as isPojo, n as isRuleGroupType, o as nullOrUndefinedOrEmpty, r as isRuleGroupTypeIC, t as isRuleGroup } from "./isRuleGroup-BcfwGaIN.mjs";
3
+ import { t as transformQuery } from "./transformQuery-Bq4iyYsE.mjs";
4
+ import { t as convertFromIC } from "./convertQuery-Cj4t-LT4.mjs";
7
5
  import { produce } from "immer";
8
6
 
9
7
  //#region src/utils/isRuleOrGroupValid.ts
@@ -29,257 +27,6 @@ const isRuleOrGroupValid = (rg, validationResult, validator) => {
29
27
  return true;
30
28
  };
31
29
 
32
- //#endregion
33
- //#region src/utils/getParseNumberMethod.ts
34
- const getParseNumberMethod = ({ parseNumbers, inputType }) => {
35
- if (typeof parseNumbers === "string") {
36
- const [method, level] = parseNumbers.split("-");
37
- if (level === "limited") return inputType === "number" ? method : false;
38
- return method;
39
- }
40
- return parseNumbers ? "strict" : false;
41
- };
42
-
43
- //#endregion
44
- //#region src/utils/formatQuery/utils.ts
45
- /**
46
- * Maps a {@link DefaultOperatorName} to a SQL operator.
47
- *
48
- * @group Export
49
- */
50
- const mapSQLOperator = (rqbOperator) => {
51
- switch (lc(rqbOperator)) {
52
- case "null": return "is null";
53
- case "notnull": return "is not null";
54
- case "notin": return "not in";
55
- case "notbetween": return "not between";
56
- case "contains":
57
- case "beginswith":
58
- case "endswith": return "like";
59
- case "doesnotcontain":
60
- case "doesnotbeginwith":
61
- case "doesnotendwith": return "not like";
62
- default: return rqbOperator;
63
- }
64
- };
65
- /**
66
- * Maps a (lowercase) {@link DefaultOperatorName} to a MongoDB operator.
67
- *
68
- * @group Export
69
- */
70
- const mongoOperators = {
71
- "=": "$eq",
72
- "!=": "$ne",
73
- "<": "$lt",
74
- "<=": "$lte",
75
- ">": "$gt",
76
- ">=": "$gte",
77
- in: "$in",
78
- notin: "$nin",
79
- notIn: "$nin"
80
- };
81
- /**
82
- * Maps a (lowercase) {@link DefaultOperatorName} to a Prisma ORM operator.
83
- *
84
- * @group Export
85
- */
86
- const prismaOperators = {
87
- "=": "equals",
88
- "!=": "not",
89
- "<": "lt",
90
- "<=": "lte",
91
- ">": "gt",
92
- ">=": "gte",
93
- in: "in",
94
- notin: "notIn"
95
- };
96
- /**
97
- * Maps a {@link DefaultCombinatorName} to a CEL combinator.
98
- *
99
- * @group Export
100
- */
101
- const celCombinatorMap = {
102
- and: "&&",
103
- or: "||"
104
- };
105
- /**
106
- * Register these operators with `jsonLogic` before applying the result
107
- * of `formatQuery(query, 'jsonlogic')`.
108
- *
109
- * @example
110
- * ```
111
- * for (const [op, func] of Object.entries(jsonLogicAdditionalOperators)) {
112
- * jsonLogic.add_operation(op, func);
113
- * }
114
- * jsonLogic.apply({ "startsWith": [{ "var": "firstName" }, "Stev"] }, data);
115
- * ```
116
- *
117
- * @group Export
118
- */
119
- const jsonLogicAdditionalOperators = {
120
- startsWith: (a, b) => typeof a === "string" && a.startsWith(b),
121
- endsWith: (a, b) => typeof a === "string" && a.endsWith(b)
122
- };
123
- /**
124
- * Converts all `string`-type `value` properties of a query object into `number` where appropriate.
125
- *
126
- * Used by {@link formatQuery} for the `json*` formats when `parseNumbers` is `true`.
127
- *
128
- * @group Export
129
- */
130
- const numerifyValues = (rg, options) => ({
131
- ...rg,
132
- rules: rg.rules.map((r) => {
133
- if (typeof r === "string") return r;
134
- if (isRuleGroup(r)) return numerifyValues(r, options);
135
- const fieldData = getOption(options.fields, r.field);
136
- const parseNumbers = getParseNumberMethod({
137
- parseNumbers: options.parseNumbers,
138
- inputType: fieldData?.inputType
139
- });
140
- if (Array.isArray(r.value)) return {
141
- ...r,
142
- value: r.value.map((v) => parseNumber(v, { parseNumbers }))
143
- };
144
- const valAsArray = toArray(r.value, { retainEmptyStrings: true }).map((v) => parseNumber(v, { parseNumbers }));
145
- if (valAsArray.every((v) => typeof v === "number")) {
146
- // istanbul ignore else
147
- if (valAsArray.length > 1) return {
148
- ...r,
149
- value: valAsArray
150
- };
151
- else if (valAsArray.length === 1) return {
152
- ...r,
153
- value: valAsArray[0]
154
- };
155
- }
156
- return r;
157
- })
158
- });
159
- /**
160
- * Determines whether a value is _anything_ except an empty `string` or `NaN`.
161
- *
162
- * @group Export
163
- */
164
- const isValidValue = (value) => typeof value === "string" && value.length > 0 || typeof value === "number" && !Number.isNaN(value) || typeof value !== "string" && typeof value !== "number";
165
- /**
166
- * Determines whether {@link formatQuery} should render the given value as a number.
167
- * As long as `parseNumbers` is `true`, `number` and `bigint` values will return `true` and
168
- * `string` values will return `true` if they test positive against {@link numericRegex}.
169
- *
170
- * @group Export
171
- */
172
- const shouldRenderAsNumber = (value, parseNumbers) => !!parseNumbers && (typeof value === "number" || typeof value === "bigint" || typeof value === "string" && numericRegex.test(value));
173
- /**
174
- * Used by {@link formatQuery} to determine whether the given value processor is a
175
- * "legacy" value processor by counting the number of arguments. Legacy value
176
- * processors take 3 arguments (not counting any arguments with default values), while
177
- * rule-based value processors take no more than 2 arguments.
178
- *
179
- * @group Export
180
- */
181
- const isValueProcessorLegacy = (valueProcessor) => valueProcessor.length >= 3;
182
- /**
183
- * Converts the `quoteFieldNamesWith` option into an array of two strings.
184
- * If the option is a string, the array elements are both that string.
185
- *
186
- * @default
187
- * ['', '']
188
- *
189
- * @group Export
190
- */
191
- const getQuoteFieldNamesWithArray = (quoteFieldNamesWith = ["", ""]) => Array.isArray(quoteFieldNamesWith) ? quoteFieldNamesWith : typeof quoteFieldNamesWith === "string" ? [quoteFieldNamesWith, quoteFieldNamesWith] : quoteFieldNamesWith ?? ["", ""];
192
- /**
193
- * Given a field name and relevant {@link ValueProcessorOptions}, returns the field name
194
- * wrapped in the configured quote character(s).
195
- *
196
- * @group Export
197
- */
198
- const getQuotedFieldName = (fieldName, { quoteFieldNamesWith, fieldIdentifierSeparator }) => {
199
- const [qPre, qPost] = getQuoteFieldNamesWithArray(quoteFieldNamesWith);
200
- return typeof fieldIdentifierSeparator === "string" && fieldIdentifierSeparator.length > 0 ? joinWith(splitBy(fieldName, fieldIdentifierSeparator).map((part) => `${qPre}${part}${qPost}`), fieldIdentifierSeparator) : `${qPre}${fieldName}${qPost}`;
201
- };
202
- const defaultWordOrder = [
203
- "S",
204
- "V",
205
- "O"
206
- ];
207
- /**
208
- * Given a [Constituent word order](https://en.wikipedia.org/wiki/Word_order#Constituent_word_orders)
209
- * like "svo" or "sov", returns a permutation of `["S", "V", "O"]` based on the first occurrence of
210
- * each letter in the input string (case insensitive). This widens the valid input from abbreviations
211
- * like "svo" to more expressive strings like "subject-verb-object" or "sub ver obj". Any missing
212
- * letters are appended in the default order "SVO" (e.g., "object" would yield `["O", "S", "V"]`).
213
- *
214
- * @group Export
215
- */
216
- const normalizeConstituentWordOrder = (input) => {
217
- const result = [];
218
- const letterSet = new Set(defaultWordOrder);
219
- for (const char of input.toUpperCase()) if (letterSet.has(char)) {
220
- result.push(char);
221
- letterSet.delete(char);
222
- if (letterSet.size === 0) break;
223
- }
224
- for (const letter of defaultWordOrder) if (letterSet.has(letter)) result.push(letter);
225
- return result;
226
- };
227
- /**
228
- * Default translations used by {@link formatQuery} for "natural_language" format.
229
- *
230
- * @group Export
231
- */
232
- const defaultNLTranslations = {
233
- groupPrefix: "",
234
- groupPrefix_not_xor: "either zero or more than one of",
235
- groupPrefix_xor: "exactly one of",
236
- groupSuffix: "is true",
237
- groupSuffix_not: "is not true"
238
- };
239
- /**
240
- * Note: This function assumes `conditions.length > 0`
241
- */
242
- const translationMatchFilter = (key, keyToTest, conditions) => keyToTest.startsWith(key) && conditions.every((c) => keyToTest.includes(`_${c}`) && keyToTest.match(/_/g)?.length === conditions.length);
243
- /**
244
- * Used by {@link formatQuery} to get a translation based on certain conditions
245
- * for the "natural_language" format.
246
- *
247
- * @group Export
248
- */
249
- const getNLTranslataion = (key, translations, conditions = []) => conditions.length === 0 ? translations[key] ?? defaultNLTranslations[key] ?? "" : Object.entries(translations).find(([keyToTest]) => translationMatchFilter(key, keyToTest, conditions))?.[1] ?? Object.entries(defaultNLTranslations).find(([keyToTest]) => translationMatchFilter(key, keyToTest, conditions))?.[1] ?? defaultNLTranslations[key] ?? "";
250
- const processMatchMode = (rule) => {
251
- const { mode, threshold } = rule.match ?? {};
252
- if (mode) {
253
- if (!isRuleGroup(rule.value)) return false;
254
- const matchModeLC = lc(mode);
255
- const matchModeCoerced = matchModeLC === "atleast" && threshold === 1 ? "some" : matchModeLC === "atmost" && threshold === 0 ? "none" : matchModeLC;
256
- if ((matchModeCoerced === "atleast" || matchModeCoerced === "atmost" || matchModeCoerced === "exactly") && (typeof threshold !== "number" || threshold < 0)) return false;
257
- return {
258
- mode: matchModeCoerced,
259
- threshold
260
- };
261
- }
262
- };
263
- /**
264
- * "Replacer" method for JSON.stringify's second argument. Converts `bigint` values to
265
- * objects with a `$bigint` property having a value of a string representation of
266
- * the actual `bigint`-type value.
267
- *
268
- * Inverse of {@link bigIntJsonParseReviver}.
269
- *
270
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json
271
- */
272
- const bigIntJsonStringifyReplacer = (_key, value) => typeof value === "bigint" ? { $bigint: value.toString() } : value;
273
- /**
274
- * "Reviver" method for JSON.parse's second argument. Converts objects having a single
275
- * `$bigint: string` property to an actual `bigint` value.
276
- *
277
- * Inverse of {@link bigIntJsonStringifyReplacer}.
278
- *
279
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json
280
- */
281
- const bigIntJsonParseReviver = (_key, value) => isPojo(value) && Object.keys(value).length === 1 && typeof value.$bigint === "string" ? BigInt(value.$bigint) : value;
282
-
283
30
  //#endregion
284
31
  //#region src/utils/formatQuery/defaultRuleGroupProcessorCEL.ts
285
32
  /**