@react-querybuilder/core 8.9.1 → 8.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/arrayUtils-C9sO4qLO.mjs +50 -0
  2. package/dist/arrayUtils-C9sO4qLO.mjs.map +1 -0
  3. package/dist/arrayUtils-QxZOZTf6.js +73 -0
  4. package/dist/arrayUtils-QxZOZTf6.js.map +1 -0
  5. package/dist/basic-BmpEwexQ.d.mts +363 -0
  6. package/dist/basic-CDDA-KZa.d.ts +363 -0
  7. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +569 -1252
  8. package/dist/cjs/react-querybuilder_core.cjs.development.js +430 -140
  9. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  10. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +569 -1252
  11. package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
  12. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
  13. package/dist/convertQuery-BUgyz1GA.mjs +75 -0
  14. package/dist/convertQuery-BUgyz1GA.mjs.map +1 -0
  15. package/dist/export-Ccjfea21.d.mts +453 -0
  16. package/dist/{export-DyrnTh6K.d.ts → export-GUuxJ7zR.d.ts} +3 -2
  17. package/dist/formatQuery.d.mts +668 -0
  18. package/dist/formatQuery.d.ts +3 -2
  19. package/dist/formatQuery.js +217 -87
  20. package/dist/formatQuery.js.map +1 -1
  21. package/dist/formatQuery.mjs +2496 -0
  22. package/dist/formatQuery.mjs.map +1 -0
  23. package/dist/{import-Cksobmln.d.ts → import-D-hm1phN.d.ts} +2 -2
  24. package/dist/import-Dxevzw_-.d.mts +28 -0
  25. package/dist/isRuleGroup-CGe_rb2w.mjs +40 -0
  26. package/dist/isRuleGroup-CGe_rb2w.mjs.map +1 -0
  27. package/dist/isRuleGroup-DqAs2x4E.js.map +1 -1
  28. package/dist/{optGroupUtils-CXLgyg2i.js → optGroupUtils-B0hTpodo.js} +114 -1
  29. package/dist/optGroupUtils-B0hTpodo.js.map +1 -0
  30. package/dist/optGroupUtils-DrubUpx0.mjs +185 -0
  31. package/dist/optGroupUtils-DrubUpx0.mjs.map +1 -0
  32. package/dist/parseCEL.d.mts +315 -0
  33. package/dist/parseCEL.d.ts +292 -11
  34. package/dist/parseCEL.js +114 -30
  35. package/dist/parseCEL.js.map +1 -1
  36. package/dist/parseCEL.mjs +2631 -0
  37. package/dist/parseCEL.mjs.map +1 -0
  38. package/dist/parseJSONata.d.mts +37 -0
  39. package/dist/parseJSONata.d.ts +3 -2
  40. package/dist/parseJSONata.js +49 -77
  41. package/dist/parseJSONata.js.map +1 -1
  42. package/dist/parseJSONata.mjs +267 -0
  43. package/dist/parseJSONata.mjs.map +1 -0
  44. package/dist/parseJsonLogic.d.mts +37 -0
  45. package/dist/parseJsonLogic.d.ts +4 -3
  46. package/dist/parseJsonLogic.js +5 -6
  47. package/dist/parseJsonLogic.js.map +1 -1
  48. package/dist/parseJsonLogic.mjs +190 -0
  49. package/dist/parseJsonLogic.mjs.map +1 -0
  50. package/dist/parseMongoDB.d.mts +80 -0
  51. package/dist/parseMongoDB.d.ts +3 -2
  52. package/dist/parseMongoDB.js +15 -16
  53. package/dist/parseMongoDB.js.map +1 -1
  54. package/dist/parseMongoDB.mjs +266 -0
  55. package/dist/parseMongoDB.mjs.map +1 -0
  56. package/dist/parseNumber-B_-sR6d5.mjs +24 -0
  57. package/dist/parseNumber-B_-sR6d5.mjs.map +1 -0
  58. package/dist/{parseNumber-Bcys1kOH.js → parseNumber-D4iQDxK-.js} +1 -1
  59. package/dist/{parseNumber-Bcys1kOH.js.map → parseNumber-D4iQDxK-.js.map} +1 -1
  60. package/dist/parseSQL.d.mts +38 -0
  61. package/dist/parseSQL.d.ts +3 -2
  62. package/dist/parseSQL.js +11 -15
  63. package/dist/parseSQL.js.map +1 -1
  64. package/dist/parseSQL.mjs +6622 -0
  65. package/dist/parseSQL.mjs.map +1 -0
  66. package/dist/parseSpEL.d.mts +35 -0
  67. package/dist/parseSpEL.d.ts +3 -2
  68. package/dist/parseSpEL.js +7 -9
  69. package/dist/parseSpEL.js.map +1 -1
  70. package/dist/parseSpEL.mjs +272 -0
  71. package/dist/parseSpEL.mjs.map +1 -0
  72. package/dist/{prepareQueryObjects-BqFEs4eV.js → prepareQueryObjects-BOUWfel5.js} +4 -5
  73. package/dist/prepareQueryObjects-BOUWfel5.js.map +1 -0
  74. package/dist/prepareQueryObjects-CJNpnGcJ.mjs +153 -0
  75. package/dist/prepareQueryObjects-CJNpnGcJ.mjs.map +1 -0
  76. package/dist/query-builder-layout.css +1 -1
  77. package/dist/query-builder-layout.css.map +1 -1
  78. package/dist/query-builder.css +1 -1
  79. package/dist/query-builder.css.map +1 -1
  80. package/dist/react-querybuilder_core.d.mts +569 -1252
  81. package/dist/react-querybuilder_core.legacy-esm.d.ts +569 -1252
  82. package/dist/react-querybuilder_core.legacy-esm.js +430 -136
  83. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  84. package/dist/react-querybuilder_core.mjs +426 -141
  85. package/dist/react-querybuilder_core.mjs.map +1 -1
  86. package/dist/react-querybuilder_core.production.d.mts +569 -1252
  87. package/dist/react-querybuilder_core.production.mjs +1 -1
  88. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  89. package/dist/styles/_layout.scss +61 -17
  90. package/dist/styles/_main.scss +17 -4
  91. package/dist/{transformQuery-FL_nlpp5.js → transformQuery-CWDPogO5.js} +1 -1
  92. package/dist/{transformQuery-FL_nlpp5.js.map → transformQuery-CWDPogO5.js.map} +1 -1
  93. package/dist/transformQuery-DHvtgDgZ.mjs +41 -0
  94. package/dist/transformQuery-DHvtgDgZ.mjs.map +1 -0
  95. package/dist/transformQuery.d.mts +118 -0
  96. package/dist/transformQuery.d.ts +1 -1
  97. package/dist/transformQuery.js +1 -1
  98. package/dist/transformQuery.mjs +4 -0
  99. package/package.json +78 -28
  100. package/dist/arrayUtils-D5EoIsKP.js +0 -164
  101. package/dist/arrayUtils-D5EoIsKP.js.map +0 -1
  102. package/dist/basic-C8xXKHIA.d.ts +0 -1235
  103. package/dist/objectUtils-BBZSfZJz.js +0 -17
  104. package/dist/objectUtils-BBZSfZJz.js.map +0 -1
  105. package/dist/optGroupUtils-CXLgyg2i.js.map +0 -1
  106. package/dist/prepareQueryObjects-BqFEs4eV.js.map +0 -1
@@ -0,0 +1,50 @@
1
+ import { defaultJoinChar } from "./optGroupUtils-DrubUpx0.mjs";
2
+
3
+ //#region src/utils/arrayUtils.ts
4
+ /**
5
+ * Splits a string by a given character (see {@link defaultJoinChar}). Escaped characters
6
+ * (characters preceded by a backslash) will not apply to the split, and the backslash will
7
+ * be removed in the array element. Inverse of {@link joinWith}.
8
+ *
9
+ * @example
10
+ * splitBy('this\\,\\,that,,the other,,,\\,')
11
+ * // or
12
+ * splitBy('this\\,\\,that,,the other,,,\\,', ',')
13
+ * // would return
14
+ * ['this,,that', '', 'the other', '', '', ',']
15
+ */
16
+ const splitBy = (str, splitChar = defaultJoinChar) => typeof str === "string" ? str.split(`\\${splitChar}`).map((c) => c.split(splitChar)).reduce((prev, curr, idx) => {
17
+ if (idx === 0) return curr;
18
+ return [
19
+ ...prev.slice(0, -1),
20
+ `${prev.at(-1)}${splitChar}${curr[0]}`,
21
+ ...curr.slice(1)
22
+ ];
23
+ }, []) : [];
24
+ /**
25
+ * Joins an array of strings using the given character (see {@link defaultJoinChar}). When
26
+ * the given character appears in an array element, a backslash will be added just before it
27
+ * to distinguish it from the join character. Effectively the inverse of {@link splitBy}.
28
+ *
29
+ * TIP: The join character can actually be a string of any length. Only the first character
30
+ * will be searched for in the array elements and preceded by a backslash.
31
+ *
32
+ * @example
33
+ * joinWith(['this,,that', '', 'the other', '', '', ','], ', ')
34
+ * // would return
35
+ * 'this\\,\\,that, , the other, , , \\,'
36
+ */
37
+ const joinWith = (strArr, joinChar = defaultJoinChar) => strArr.map((str) => `${str ?? ""}`.replaceAll(joinChar[0], `\\${joinChar[0]}`)).join(joinChar);
38
+ /**
39
+ * Trims the value if it is a string. Otherwise returns the value as is.
40
+ */
41
+ const trimIfString = (val) => typeof val === "string" ? val.trim() : val;
42
+ /**
43
+ * Splits a string by comma then trims each element. Arrays are returned as is except
44
+ * any string elements are trimmed.
45
+ */
46
+ 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] : [];
47
+
48
+ //#endregion
49
+ export { joinWith, splitBy, toArray, trimIfString };
50
+ //# sourceMappingURL=arrayUtils-C9sO4qLO.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrayUtils-C9sO4qLO.mjs","names":["v"],"sources":["../src/utils/arrayUtils.ts"],"sourcesContent":["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":";;;;;;;;;;;;;;;AAcA,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,aAAaA,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"}
@@ -0,0 +1,73 @@
1
+ const require_optGroupUtils = require('./optGroupUtils-B0hTpodo.js');
2
+
3
+ //#region src/utils/arrayUtils.ts
4
+ /**
5
+ * Splits a string by a given character (see {@link defaultJoinChar}). Escaped characters
6
+ * (characters preceded by a backslash) will not apply to the split, and the backslash will
7
+ * be removed in the array element. Inverse of {@link joinWith}.
8
+ *
9
+ * @example
10
+ * splitBy('this\\,\\,that,,the other,,,\\,')
11
+ * // or
12
+ * splitBy('this\\,\\,that,,the other,,,\\,', ',')
13
+ * // would return
14
+ * ['this,,that', '', 'the other', '', '', ',']
15
+ */
16
+ const splitBy = (str, splitChar = require_optGroupUtils.defaultJoinChar) => typeof str === "string" ? str.split(`\\${splitChar}`).map((c) => c.split(splitChar)).reduce((prev, curr, idx) => {
17
+ if (idx === 0) return curr;
18
+ return [
19
+ ...prev.slice(0, -1),
20
+ `${prev.at(-1)}${splitChar}${curr[0]}`,
21
+ ...curr.slice(1)
22
+ ];
23
+ }, []) : [];
24
+ /**
25
+ * Joins an array of strings using the given character (see {@link defaultJoinChar}). When
26
+ * the given character appears in an array element, a backslash will be added just before it
27
+ * to distinguish it from the join character. Effectively the inverse of {@link splitBy}.
28
+ *
29
+ * TIP: The join character can actually be a string of any length. Only the first character
30
+ * will be searched for in the array elements and preceded by a backslash.
31
+ *
32
+ * @example
33
+ * joinWith(['this,,that', '', 'the other', '', '', ','], ', ')
34
+ * // would return
35
+ * 'this\\,\\,that, , the other, , , \\,'
36
+ */
37
+ const joinWith = (strArr, joinChar = require_optGroupUtils.defaultJoinChar) => strArr.map((str) => `${str ?? ""}`.replaceAll(joinChar[0], `\\${joinChar[0]}`)).join(joinChar);
38
+ /**
39
+ * Trims the value if it is a string. Otherwise returns the value as is.
40
+ */
41
+ const trimIfString = (val) => typeof val === "string" ? val.trim() : val;
42
+ /**
43
+ * Splits a string by comma then trims each element. Arrays are returned as is except
44
+ * any string elements are trimmed.
45
+ */
46
+ const toArray = (v, { retainEmptyStrings } = {}) => Array.isArray(v) ? v.map((v$1) => trimIfString(v$1)) : typeof v === "string" ? splitBy(v, require_optGroupUtils.defaultJoinChar).filter(retainEmptyStrings ? () => true : (s) => !/^\s*$/.test(s)).map((s) => s.trim()) : typeof v === "number" ? [v] : [];
47
+
48
+ //#endregion
49
+ Object.defineProperty(exports, 'joinWith', {
50
+ enumerable: true,
51
+ get: function () {
52
+ return joinWith;
53
+ }
54
+ });
55
+ Object.defineProperty(exports, 'splitBy', {
56
+ enumerable: true,
57
+ get: function () {
58
+ return splitBy;
59
+ }
60
+ });
61
+ Object.defineProperty(exports, 'toArray', {
62
+ enumerable: true,
63
+ get: function () {
64
+ return toArray;
65
+ }
66
+ });
67
+ Object.defineProperty(exports, 'trimIfString', {
68
+ enumerable: true,
69
+ get: function () {
70
+ return trimIfString;
71
+ }
72
+ });
73
+ //# sourceMappingURL=arrayUtils-QxZOZTf6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrayUtils-QxZOZTf6.js","names":["defaultJoinChar","v"],"sources":["../src/utils/arrayUtils.ts"],"sourcesContent":["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":";;;;;;;;;;;;;;;AAcA,MAAa,WAAW,KAAc,YAAoBA,0CACxD,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,WAAmBA,0CACzD,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,GAAGD,sCAAgB,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"}
@@ -0,0 +1,363 @@
1
+ import { Except, RequireAtLeastOne, SetRequired, Simplify } from "type-fest";
2
+
3
+ //#region src/types/options.d.ts
4
+
5
+ /**
6
+ * Adds an `unknown` index property to an interface.
7
+ */
8
+ type WithUnknownIndex<T> = T & {
9
+ [key: string]: unknown;
10
+ };
11
+ /**
12
+ * Do not use this type directly; use {@link Option}, {@link ValueOption},
13
+ * or {@link FullOption} instead. For specific option types, you can use
14
+ * {@link FullField}, {@link FullOperator}, or {@link FullCombinator},
15
+ * all of which extend {@link FullOption}.
16
+ *
17
+ * @group Option Lists
18
+ */
19
+ interface BaseOption<N extends string = string> {
20
+ name?: N;
21
+ value?: N;
22
+ label: string;
23
+ disabled?: boolean;
24
+ }
25
+ /**
26
+ * A generic option. Used directly in {@link OptionList} or
27
+ * as the child element of an {@link OptionGroup}.
28
+ *
29
+ * @group Option Lists
30
+ */
31
+ type Option<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "name">>>;
32
+ /**
33
+ * A generic {@link Option} with either a `name` or `value` as its primary identifier.
34
+ * {@link OptionList}-type props on the {@link QueryBuilder} component accept this type,
35
+ * but corresponding props passed down to subcomponents will always be translated
36
+ * to {@link FullOption} first.
37
+ *
38
+ * @group Option Lists
39
+ */
40
+ type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne<BaseOption<N>, "name" | "value">>>;
41
+ /**
42
+ * Utility type to turn an {@link Option}, {@link ValueOption}, or {@link BaseOption}
43
+ * into a {@link FlexibleOption}.
44
+ *
45
+ * @group Option Lists
46
+ */
47
+ type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
48
+ /**
49
+ * A generic {@link Option} requiring both `name` _and_ `value` properties.
50
+ * Props that extend {@link OptionList} accept {@link BaseOption}, but
51
+ * corresponding props sent to subcomponents will always be translated to this
52
+ * type first to ensure both `name` and `value` are available.
53
+ *
54
+ * NOTE: Do not extend from this type directly. Use {@link BaseFullOption}
55
+ * (optionally wrapped in {@link WithUnknownIndex}) instead, otherwise
56
+ * the `unknown` index property will cause issues. See {@link Option} and
57
+ * {@link ValueOption} for examples.
58
+ *
59
+ * @group Option Lists
60
+ */
61
+ type FullOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "name" | "value">>>;
62
+ /**
63
+ * This type is identical to {@link FullOption} but without the `unknown` index
64
+ * property. Extend from this type instead of {@link FullOption} directly.
65
+ *
66
+ * @group Option Lists
67
+ */
68
+ type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption<N>, "name" | "value">>;
69
+ /**
70
+ * Utility type to turn an {@link Option}, {@link ValueOption} or
71
+ * {@link BaseOption} into a {@link FullOption}.
72
+ *
73
+ * @group Option Lists
74
+ */
75
+ type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
76
+ /**
77
+ * A group of {@link Option}s, usually within an {@link OptionList}.
78
+ *
79
+ * @group Option Lists
80
+ */
81
+ interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
82
+ label: string;
83
+ options: WithUnknownIndex<Opt>[];
84
+ }
85
+ /**
86
+ * A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
87
+ *
88
+ * @group Option Lists
89
+ */
90
+ type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
91
+ label: string;
92
+ options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
93
+ };
94
+ /**
95
+ * Either an array of {@link Option}s or an array of {@link OptionGroup}s.
96
+ *
97
+ * @group Option Lists
98
+ */
99
+ type OptionList<Opt extends Option = Option> = Opt[] | OptionGroup<Opt>[];
100
+ /**
101
+ * An array of options or option groups, like {@link OptionList} but the option type
102
+ * may use either `name` or `value` as the primary identifier.
103
+ *
104
+ * @group Option Lists
105
+ */
106
+ type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
107
+ /**
108
+ * An array of options or option groups, like {@link OptionList}, but using
109
+ * {@link FullOption} instead of {@link Option}. This means that every member is
110
+ * guaranteed to have both `name` and `value`.
111
+ *
112
+ * @group Option Lists
113
+ */
114
+ type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
115
+ //#endregion
116
+ //#region src/types/ruleGroups.d.ts
117
+ /**
118
+ * Properties common to both rules and groups.
119
+ */
120
+ interface CommonRuleAndGroupProperties {
121
+ path?: Path;
122
+ id?: string;
123
+ disabled?: boolean;
124
+ /**
125
+ * Whether this rule or group is muted. When muted, the rule or group
126
+ * is excluded from query export formats (SQL, JSON, MongoDB, etc.).
127
+ * For groups, muting recursively mutes all children.
128
+ */
129
+ muted?: boolean;
130
+ }
131
+ /**
132
+ * The main rule type. The `field`, `operator`, and `value` properties
133
+ * can be narrowed with generics.
134
+ */
135
+ interface RuleType<F extends string = string, O extends string = string, V = any, C extends string = string> extends CommonRuleAndGroupProperties {
136
+ field: F;
137
+ operator: O;
138
+ value: V;
139
+ valueSource?: ValueSource;
140
+ match?: MatchConfig;
141
+ /**
142
+ * Only used when adding a rule to a query that uses independent combinators.
143
+ */
144
+ combinatorPreceding?: C;
145
+ }
146
+ /**
147
+ * The main rule group type. This type is used for query definitions as well as
148
+ * all sub-groups of queries.
149
+ */
150
+ interface RuleGroupType<R extends RuleType = RuleType, C extends string = string> extends CommonRuleAndGroupProperties {
151
+ combinator: C;
152
+ rules: RuleGroupArray<RuleGroupType<R, C>, R>;
153
+ not?: boolean;
154
+ }
155
+ /**
156
+ * The type of the `rules` array in a {@link RuleGroupType}.
157
+ */
158
+ type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R extends RuleType = RuleType> = (R | RG)[];
159
+ /**
160
+ * The type of the `rules` array in a {@link DefaultRuleGroupType}.
161
+ */
162
+ type DefaultRuleGroupArray<F extends string = string> = RuleGroupArray<DefaultRuleGroupType, DefaultRuleType<F>>;
163
+ /**
164
+ * {@link RuleGroupType} with the `combinator` property limited to
165
+ * {@link DefaultCombinatorNameExtended} and `rules` limited to {@link DefaultRuleType}.
166
+ */
167
+ type DefaultRuleGroupType<F extends string = string> = RuleGroupType<DefaultRuleType<F>, DefaultCombinatorNameExtended> & {
168
+ rules: DefaultRuleGroupArray<F>;
169
+ };
170
+ /**
171
+ * {@link RuleType} with the `operator` property limited to {@link DefaultOperatorName}.
172
+ */
173
+ type DefaultRuleType<F extends string = string> = RuleType<F, DefaultOperatorName>;
174
+ /**
175
+ * Default allowed values for the `combinator` property.
176
+ *
177
+ * @group Option Lists
178
+ */
179
+ type DefaultCombinatorName = "and" | "or";
180
+ /**
181
+ * Default allowed values for the `combinator` property, plus `"xor"`.
182
+ *
183
+ * @group Option Lists
184
+ */
185
+ type DefaultCombinatorNameExtended = DefaultCombinatorName | "xor";
186
+ /**
187
+ * Default values for the `operator` property.
188
+ *
189
+ * @group Option Lists
190
+ */
191
+ type DefaultOperatorName = "=" | "!=" | "<" | ">" | "<=" | ">=" | "contains" | "beginsWith" | "endsWith" | "doesNotContain" | "doesNotBeginWith" | "doesNotEndWith" | "null" | "notNull" | "in" | "notIn" | "between" | "notBetween";
192
+ //#endregion
193
+ //#region src/types/ruleGroupsIC.utils.d.ts
194
+ type MAXIMUM_ALLOWED_BOUNDARY = 80;
195
+ type MappedTuple<Tuple extends Array<unknown>, Result extends Array<unknown> = [], Count extends ReadonlyArray<number> = []> = Count["length"] extends MAXIMUM_ALLOWED_BOUNDARY ? Result : Tuple extends [] ? [] : Result extends [] ? MappedTuple<Tuple, Tuple, [...Count, 1]> : MappedTuple<Tuple, Result | [...Result, ...Tuple], [...Count, 1]>;
196
+ //#endregion
197
+ //#region src/types/ruleGroupsIC.d.ts
198
+ /**
199
+ * The main rule group interface when using independent combinators. This type is used
200
+ * for query definitions as well as all sub-groups of queries.
201
+ */
202
+ interface RuleGroupTypeIC<R extends RuleType = RuleType, C extends string = string> extends Except<RuleGroupType<R, C>, "combinator" | "rules"> {
203
+ combinator?: undefined;
204
+ rules: RuleGroupICArray<RuleGroupTypeIC<R, C>, R, C>;
205
+ /**
206
+ * Only used when adding a rule to a query that uses independent combinators
207
+ */
208
+ combinatorPreceding?: C;
209
+ }
210
+ /**
211
+ * Shorthand for "either {@link RuleGroupType} or {@link RuleGroupTypeIC}".
212
+ */
213
+ type RuleGroupTypeAny<R extends RuleType = RuleType, C extends string = string> = RuleGroupType<R, C> | RuleGroupTypeIC<R, C>;
214
+ /**
215
+ * The type of the `rules` array in a {@link RuleGroupTypeIC}.
216
+ */
217
+ type RuleGroupICArray<RG extends RuleGroupTypeIC = RuleGroupTypeIC, R extends RuleType = RuleType, C extends string = string> = [R | RG] | [R | RG, ...MappedTuple<[C, R | RG]>] | ((R | RG)[] & {
218
+ length: 0;
219
+ });
220
+ /**
221
+ * The type of the `rules` array in a {@link DefaultRuleGroupTypeIC}.
222
+ */
223
+ type DefaultRuleGroupICArray<F extends string = string> = RuleGroupICArray<DefaultRuleGroupTypeIC<F>, DefaultRuleType<F>, DefaultCombinatorName>;
224
+ /**
225
+ * {@link RuleGroupTypeIC} with combinators limited to
226
+ * {@link DefaultCombinatorName} and rules limited to {@link DefaultRuleType}.
227
+ */
228
+ interface DefaultRuleGroupTypeIC<F extends string = string> extends RuleGroupTypeIC<DefaultRuleType<F>> {
229
+ rules: DefaultRuleGroupICArray<F>;
230
+ }
231
+ //#endregion
232
+ //#region src/types/validation.d.ts
233
+ /**
234
+ * Object with a `valid` boolean value and optional `reasons`.
235
+ */
236
+ interface ValidationResult {
237
+ valid: boolean;
238
+ reasons?: any[];
239
+ }
240
+ /**
241
+ * Map of rule/group `id` to its respective {@link ValidationResult}.
242
+ */
243
+ type ValidationMap = Record<string, boolean | ValidationResult>;
244
+ /**
245
+ * Function that validates a query.
246
+ */
247
+ type QueryValidator = (query: RuleGroupTypeAny) => boolean | ValidationMap;
248
+ /**
249
+ * Function that validates a rule.
250
+ */
251
+ type RuleValidator = (rule: RuleType) => boolean | ValidationResult;
252
+ //#endregion
253
+ //#region src/types/basic.d.ts
254
+ /**
255
+ * @see https://react-querybuilder.js.org/docs/tips/path
256
+ */
257
+ type Path = number[];
258
+ /**
259
+ * String of classnames, array of classname strings, or object where the
260
+ * keys are classnames and those with truthy values will be included.
261
+ * Suitable for passing to the `clsx` package.
262
+ */
263
+ type Classname = string | string[] | Record<string, any>;
264
+ /**
265
+ * A source for the `value` property of a rule.
266
+ */
267
+ type ValueSource = "value" | "field";
268
+ /**
269
+ * Type of {@link ValueEditor} that will be displayed.
270
+ */
271
+ type ValueEditorType = "text" | "select" | "checkbox" | "radio" | "textarea" | "switch" | "multiselect" | null;
272
+ /**
273
+ * A valid array of potential value sources.
274
+ *
275
+ * @see {@link ValueSource}
276
+ */
277
+ type ValueSources = ["value"] | ["value", "field"] | ["field", "value"] | ["field"];
278
+ type ValueSourceFlexibleOptions = ToFlexibleOptionArrays<ValueSources>;
279
+ type ToFlexibleOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: FlexibleOption<Sources[K]> } : never;
280
+ type WithOptionalClassName<T> = T & {
281
+ className?: Classname;
282
+ };
283
+ /**
284
+ * HTML5 input types
285
+ */
286
+ type InputType = "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week" | "bigint" | (string & {});
287
+ /**
288
+ * Quantification mode describing how many elements of the value array must pass
289
+ * the filter for the rule itself to pass.
290
+ *
291
+ * For "atLeast", "atMost", and "exactly", the threshold value will be converted to
292
+ * a percentage if the number is less than 1. Non-numeric values and numbers less
293
+ * than 0 will be ignored.
294
+ */
295
+ interface MatchConfig {
296
+ mode: MatchMode;
297
+ threshold?: number | null | undefined;
298
+ }
299
+ type MatchMode = "all" | "some" | "none" | "atLeast" | "atMost" | "exactly";
300
+ /**
301
+ * Base for all Field types/interfaces.
302
+ */
303
+ interface BaseFullField<FieldName extends string = string, OperatorName extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName>, ValueObj extends FullOption = FullOption<ValueName>> extends WithOptionalClassName<BaseFullOption<FieldName>> {
304
+ id?: string;
305
+ operators?: FlexibleOptionList<OperatorObj> | OperatorName[] | FlexibleOption<OperatorName>[] | (OperatorName | FlexibleOption<OperatorName>)[];
306
+ valueEditorType?: ValueEditorType | ((operator: OperatorName) => ValueEditorType);
307
+ valueSources?: ValueSources | ValueSourceFlexibleOptions | ((operator: OperatorName) => ValueSources | ValueSourceFlexibleOptions);
308
+ inputType?: InputType | null;
309
+ values?: FlexibleOptionList<ValueObj>;
310
+ matchModes?: boolean | MatchMode[] | FlexibleOption<MatchMode>[];
311
+ /** Properties of items in the value. */
312
+ subproperties?: FlexibleOptionList<FullField>;
313
+ defaultOperator?: OperatorName;
314
+ defaultValue?: any;
315
+ placeholder?: string;
316
+ validator?: RuleValidator;
317
+ comparator?: string | ((f: FullField, operator: string) => boolean);
318
+ }
319
+ /**
320
+ * Full field definition used in the `fields` prop of {@link QueryBuilder}.
321
+ * This type requires both `name` and `value`, but the `fields` prop itself
322
+ * can use a {@link FlexibleOption} where only one of `name` or `value` is
323
+ * required (along with `label`), or {@link Field} where only `name` and
324
+ * `label` are required.
325
+ *
326
+ * The `name`/`value`, `operators`, and `values` properties of this interface
327
+ * can be narrowed with generics.
328
+ *
329
+ * @group Option Lists
330
+ */
331
+ type FullField<FieldName extends string = string, OperatorName extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName>, ValueObj extends FullOption = FullOption<ValueName>> = Simplify<FullOption<FieldName> & BaseFullField<FieldName, OperatorName, ValueName, OperatorObj, ValueObj>>;
332
+ /**
333
+ * Allowed values of the {@link FullOperator} property `arity`. A value of `"unary"` or
334
+ * a number less than two will cause the default {@link ValueEditor} to render `null`.
335
+ */
336
+ type Arity = number | "unary" | "binary" | "ternary";
337
+ /**
338
+ * Full operator definition used in the `operators`/`getOperators` props of
339
+ * {@link QueryBuilder}. This type requires both `name` and `value`, but the
340
+ * `operators`/`getOperators` props themselves can use a {@link FlexibleOption}
341
+ * where only one of `name` or `value` is required, or {@link FullOperator} where
342
+ * only `name` is required.
343
+ *
344
+ * The `name`/`value` properties of this interface can be narrowed with generics.
345
+ *
346
+ * @group Option Lists
347
+ */
348
+ interface FullOperator<N extends string = string> extends WithOptionalClassName<FullOption<N>> {
349
+ arity?: Arity;
350
+ }
351
+ type ParseNumberMethodName = "enhanced" | "native" | "strict";
352
+ /**
353
+ * Parsing algorithms used by {@link parseNumber}.
354
+ */
355
+
356
+ type ParseNumbersModerationLevel = "-limited" | "";
357
+ /**
358
+ * Options for the `parseNumbers` prop of {@link QueryBuilder}.
359
+ */
360
+ type ParseNumbersPropConfig = boolean | `${ParseNumberMethodName}${ParseNumbersModerationLevel}`;
361
+ //#endregion
362
+ export { DefaultCombinatorName, DefaultOperatorName, DefaultRuleGroupType, DefaultRuleGroupTypeIC, FlexibleOptionList, FullField, FullOperator, FullOptionList, InputType, OptionList, ParseNumbersPropConfig, QueryValidator, RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleType, RuleValidator, ValidationMap, ValidationResult, ValueSource, ValueSources };
363
+ //# sourceMappingURL=basic-BmpEwexQ.d.mts.map