@react-querybuilder/core 8.23.1 → 8.24.1
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/cjs/react-querybuilder_core.cjs.development.d.ts +516 -455
- package/dist/cjs/react-querybuilder_core.cjs.development.js +169 -6
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +516 -455
- package/dist/cjs/react-querybuilder_core.cjs.production.js +74 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
- package/dist/derivations.d.mts +290 -239
- package/dist/derivations.d.ts +290 -239
- package/dist/derivations.js +137 -4
- package/dist/derivations.js.map +1 -1
- package/dist/derivations.mjs +136 -5
- package/dist/derivations.mjs.map +1 -1
- package/dist/formatQuery.d.mts +1 -1
- package/dist/formatQuery.d.ts +1 -1
- package/dist/formatQuery.js +7 -4
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +7 -4
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-BfZTwhp2.d.ts → import-BCkipOTY.d.ts} +2 -2
- package/dist/{import-BdKPtLzo.d.mts → import-C9el4B_K.d.mts} +2 -2
- package/dist/{index-DOIE2pwx.d.ts → index-BExDPYEG.d.mts} +10 -8
- package/dist/{index-DOIE2pwx.d.mts → index-BExDPYEG.d.ts} +10 -8
- package/dist/{index-XueTy_XQ.d.ts → index-icv8DBhg.d.mts} +5 -3
- package/dist/{index-OF2Q1gTp.d.mts → index-yXGVO31H.d.ts} +5 -3
- package/dist/parseCEL.d.mts +112 -112
- package/dist/parseCEL.d.ts +112 -112
- package/dist/parseCEL.js +4 -4
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +4 -4
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseCypher.d.mts +8 -8
- package/dist/parseCypher.d.ts +8 -8
- package/dist/parseGremlin.d.mts +5 -5
- package/dist/parseGremlin.d.ts +5 -5
- package/dist/parseJSONata.d.mts +39 -39
- package/dist/parseJSONata.d.ts +39 -39
- package/dist/parseJSONata.js +2 -2
- package/dist/parseJSONata.mjs +2 -2
- package/dist/parseJsonLogic.d.mts +10 -10
- package/dist/parseJsonLogic.d.ts +10 -10
- package/dist/parseJsonLogic.js +3 -3
- package/dist/parseJsonLogic.mjs +3 -3
- package/dist/parseMongoDB.d.mts +9 -9
- package/dist/parseMongoDB.d.ts +9 -9
- package/dist/parseMongoDB.js +3 -3
- package/dist/parseMongoDB.mjs +3 -3
- package/dist/parseSPARQL.d.mts +5 -5
- package/dist/parseSPARQL.d.ts +5 -5
- package/dist/parseSQL.d.mts +63 -63
- package/dist/parseSQL.d.ts +63 -63
- package/dist/parseSQL.js +4 -4
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +4 -4
- package/dist/parseSQL.mjs.map +1 -1
- package/dist/parseSpEL.d.mts +57 -57
- package/dist/parseSpEL.d.ts +57 -57
- package/dist/parseSpEL.js +3 -3
- package/dist/parseSpEL.mjs +3 -3
- package/dist/{parserUtils-DbBXyAht.js → parserUtils-2VtG7m8L.js} +3 -3
- package/dist/{parserUtils-DbBXyAht.js.map → parserUtils-2VtG7m8L.js.map} +1 -1
- package/dist/{parserUtils-BKPstAaO.mjs → parserUtils-BlafvoFb.mjs} +3 -3
- package/dist/{parserUtils-BKPstAaO.mjs.map → parserUtils-BlafvoFb.mjs.map} +1 -1
- package/dist/{prepareQueryObjects-Dj9cTl9D.js → prepareQueryObjects-DJ_VjOLb.js} +2 -2
- package/dist/{prepareQueryObjects-Dj9cTl9D.js.map → prepareQueryObjects-DJ_VjOLb.js.map} +1 -1
- package/dist/{prepareQueryObjects-Dmyf3Wi_.mjs → prepareQueryObjects-DawsH4e3.mjs} +2 -2
- package/dist/{prepareQueryObjects-Dmyf3Wi_.mjs.map → prepareQueryObjects-DawsH4e3.mjs.map} +1 -1
- package/dist/react-querybuilder_core.d.mts +516 -455
- package/dist/react-querybuilder_core.legacy-esm.d.ts +516 -455
- package/dist/react-querybuilder_core.legacy-esm.js +172 -14
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +168 -7
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +516 -455
- package/dist/react-querybuilder_core.production.mjs +74 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/{transformQuery-B7d9AWUf.d.mts → transformQuery-B6PRLRkS.d.mts} +2 -2
- package/dist/{transformQuery-BXDiUBGB.d.ts → transformQuery-DVjJZXnB.d.ts} +2 -2
- package/dist/transformQuery.d.mts +1 -1
- package/dist/transformQuery.d.ts +1 -1
- package/dist/{utils-e-7KHkjV.js → utils-B4E1-ZvU.js} +12 -2
- package/dist/utils-B4E1-ZvU.js.map +1 -0
- package/dist/{utils-CP5Jqy1P.mjs → utils-DLZCoyAh.mjs} +12 -2
- package/dist/utils-DLZCoyAh.mjs.map +1 -0
- package/package.json +20 -19
- package/dist/utils-CP5Jqy1P.mjs.map +0 -1
- package/dist/utils-e-7KHkjV.js.map +0 -1
package/dist/derivations.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils = require("./utils-
|
|
2
|
+
const require_utils = require("./utils-B4E1-ZvU.js");
|
|
3
3
|
const require_objectUtils = require("./objectUtils-DfnEmDSV.js");
|
|
4
4
|
const require_convertQuery = require("./convertQuery-BLT0GIhM.js");
|
|
5
|
-
const require_prepareQueryObjects = require("./prepareQueryObjects-
|
|
5
|
+
const require_prepareQueryObjects = require("./prepareQueryObjects-DJ_VjOLb.js");
|
|
6
6
|
const require_isRuleOrGroupValid = require("./isRuleOrGroupValid-CtUf4_4x.js");
|
|
7
7
|
const require_transformQuery = require("./transformQuery.js");
|
|
8
8
|
let immer = require("immer");
|
|
@@ -49,6 +49,7 @@ const controlKeys = [
|
|
|
49
49
|
"ruleGroupHeaderElements",
|
|
50
50
|
"shiftActions",
|
|
51
51
|
"undoRedoActions",
|
|
52
|
+
"ungroupAction",
|
|
52
53
|
"valueEditor",
|
|
53
54
|
"valueSelector",
|
|
54
55
|
"valueSourceSelector"
|
|
@@ -459,6 +460,7 @@ const controlPropKeys = {
|
|
|
459
460
|
"toggleLockGroup",
|
|
460
461
|
"toggleMuteGroup",
|
|
461
462
|
"translations",
|
|
463
|
+
"ungroup",
|
|
462
464
|
"validationClassName",
|
|
463
465
|
"validationResult"
|
|
464
466
|
],
|
|
@@ -506,6 +508,7 @@ const controlPropKeys = {
|
|
|
506
508
|
"toggleLockGroup",
|
|
507
509
|
"toggleMuteGroup",
|
|
508
510
|
"translations",
|
|
511
|
+
"ungroup",
|
|
509
512
|
"validationClassName",
|
|
510
513
|
"validationResult"
|
|
511
514
|
],
|
|
@@ -542,6 +545,22 @@ const controlPropKeys = {
|
|
|
542
545
|
"titles",
|
|
543
546
|
"validation"
|
|
544
547
|
],
|
|
548
|
+
ungroupAction: [
|
|
549
|
+
"className",
|
|
550
|
+
"context",
|
|
551
|
+
"disabled",
|
|
552
|
+
"disabledTranslation",
|
|
553
|
+
"handleOnClick",
|
|
554
|
+
"label",
|
|
555
|
+
"level",
|
|
556
|
+
"path",
|
|
557
|
+
"ruleOrGroup",
|
|
558
|
+
"rules",
|
|
559
|
+
"schema",
|
|
560
|
+
"testID",
|
|
561
|
+
"title",
|
|
562
|
+
"validation"
|
|
563
|
+
],
|
|
545
564
|
valueEditor: [
|
|
546
565
|
"className",
|
|
547
566
|
"context",
|
|
@@ -642,6 +661,7 @@ const controlKind = {
|
|
|
642
661
|
ruleGroupHeaderElements: null,
|
|
643
662
|
shiftActions: null,
|
|
644
663
|
undoRedoActions: null,
|
|
664
|
+
ungroupAction: "action",
|
|
645
665
|
valueEditor: null,
|
|
646
666
|
valueSelector: null,
|
|
647
667
|
valueSourceSelector: "selector"
|
|
@@ -662,6 +682,7 @@ const strictAbortReasons = [
|
|
|
662
682
|
"target-not-found",
|
|
663
683
|
"parent-not-found",
|
|
664
684
|
"parent-not-a-group",
|
|
685
|
+
"target-not-a-group",
|
|
665
686
|
"destination-not-found",
|
|
666
687
|
"root-not-allowed",
|
|
667
688
|
"not-a-combinator-slot",
|
|
@@ -856,6 +877,7 @@ const ruleGroupClassnameSources = {
|
|
|
856
877
|
addRule: ["actionElement", "addRule"],
|
|
857
878
|
addGroup: ["actionElement", "addGroup"],
|
|
858
879
|
cloneGroup: ["actionElement", "cloneGroup"],
|
|
880
|
+
ungroup: ["actionElement", "ungroup"],
|
|
859
881
|
lockGroup: ["actionElement", "lockGroup"],
|
|
860
882
|
muteGroup: ["actionElement", "muteGroup"],
|
|
861
883
|
removeGroup: ["actionElement", "removeGroup"],
|
|
@@ -1515,6 +1537,7 @@ const mergeClassnames = (...args) => ({
|
|
|
1515
1537
|
addGroup: joinClassnamesByName("addGroup", args),
|
|
1516
1538
|
cloneRule: joinClassnamesByName("cloneRule", args),
|
|
1517
1539
|
cloneGroup: joinClassnamesByName("cloneGroup", args),
|
|
1540
|
+
ungroup: joinClassnamesByName("ungroup", args),
|
|
1518
1541
|
removeGroup: joinClassnamesByName("removeGroup", args),
|
|
1519
1542
|
rule: joinClassnamesByName("rule", args),
|
|
1520
1543
|
fields: joinClassnamesByName("fields", args),
|
|
@@ -2020,6 +2043,81 @@ const removeInPlace = (query, pathOrID, options = {}) => {
|
|
|
2020
2043
|
} else parent.rules.splice(index, 1);
|
|
2021
2044
|
return query;
|
|
2022
2045
|
};
|
|
2046
|
+
/**
|
|
2047
|
+
* Replaces a group with its own rules in its parent group, without mutating the original query.
|
|
2048
|
+
*
|
|
2049
|
+
* The group's `combinator`, `not`, `id`, `muted`, and `disabled` properties are discarded; its
|
|
2050
|
+
* rules keep their `id`s since they remain in the same query. An empty group is simply removed.
|
|
2051
|
+
*
|
|
2052
|
+
* @returns A new query with the group's rules promoted into its parent group.
|
|
2053
|
+
*
|
|
2054
|
+
* @group Query Tools
|
|
2055
|
+
*/
|
|
2056
|
+
const ungroup = (query, pathOrID, options = {}) => producerFor(options.freeze)(query, (q) => ungroupInPlace(q, pathOrID, options));
|
|
2057
|
+
/**
|
|
2058
|
+
* Replaces a group with its own rules in its parent group, in place.
|
|
2059
|
+
*
|
|
2060
|
+
* @returns The query (mutated in place) with the group's rules promoted into its parent group.
|
|
2061
|
+
*
|
|
2062
|
+
* @group Query Tools
|
|
2063
|
+
*/
|
|
2064
|
+
const ungroupInPlace = (query, pathOrID, options = {}) => {
|
|
2065
|
+
const { onAbort } = options;
|
|
2066
|
+
const path = Array.isArray(pathOrID) ? pathOrID : getPathOfID(pathOrID, query);
|
|
2067
|
+
if (!path) {
|
|
2068
|
+
onAbort?.({
|
|
2069
|
+
reason: "target-not-found",
|
|
2070
|
+
operation: "ungroup",
|
|
2071
|
+
pathOrID
|
|
2072
|
+
});
|
|
2073
|
+
return query;
|
|
2074
|
+
}
|
|
2075
|
+
if (path.length === 0) {
|
|
2076
|
+
onAbort?.({
|
|
2077
|
+
reason: "root-not-allowed",
|
|
2078
|
+
operation: "ungroup",
|
|
2079
|
+
pathOrID
|
|
2080
|
+
});
|
|
2081
|
+
return query;
|
|
2082
|
+
}
|
|
2083
|
+
const ungroupGuardReason = getGuardAbortReason(query, path, options);
|
|
2084
|
+
if (ungroupGuardReason) {
|
|
2085
|
+
onAbort?.({
|
|
2086
|
+
reason: ungroupGuardReason,
|
|
2087
|
+
operation: "ungroup",
|
|
2088
|
+
pathOrID
|
|
2089
|
+
});
|
|
2090
|
+
return query;
|
|
2091
|
+
}
|
|
2092
|
+
const target = findPath(path, query);
|
|
2093
|
+
if (!target) {
|
|
2094
|
+
onAbort?.({
|
|
2095
|
+
reason: "target-not-found",
|
|
2096
|
+
operation: "ungroup",
|
|
2097
|
+
pathOrID
|
|
2098
|
+
});
|
|
2099
|
+
return query;
|
|
2100
|
+
}
|
|
2101
|
+
if (!require_objectUtils.isRuleGroup(target)) {
|
|
2102
|
+
onAbort?.({
|
|
2103
|
+
reason: "target-not-a-group",
|
|
2104
|
+
operation: "ungroup",
|
|
2105
|
+
pathOrID
|
|
2106
|
+
});
|
|
2107
|
+
return query;
|
|
2108
|
+
}
|
|
2109
|
+
const index = path.at(-1);
|
|
2110
|
+
const parent = findPath(getParentPath(path), query);
|
|
2111
|
+
if (target.rules.length === 0) {
|
|
2112
|
+
if (!require_objectUtils.isRuleGroupType(parent) && parent.rules.length > 1) {
|
|
2113
|
+
const idxStartDelete = index === 0 ? 0 : index - 1;
|
|
2114
|
+
parent.rules.splice(idxStartDelete, 2);
|
|
2115
|
+
} else parent.rules.splice(index, 1);
|
|
2116
|
+
return query;
|
|
2117
|
+
}
|
|
2118
|
+
parent.rules.splice(index, 1, ...target.rules);
|
|
2119
|
+
return query;
|
|
2120
|
+
};
|
|
2023
2121
|
const getNextPath = (query, currentPath, newPathOrShiftDirection) => {
|
|
2024
2122
|
if (Array.isArray(newPathOrShiftDirection)) return newPathOrShiftDirection;
|
|
2025
2123
|
const ic = require_objectUtils.isRuleGroupTypeIC(query);
|
|
@@ -2358,7 +2456,7 @@ const groupInPlace = (query, sourcePathOrID, targetPathOrID, options = {}) => {
|
|
|
2358
2456
|
//#endregion
|
|
2359
2457
|
//#region src/utils/queryActions.ts
|
|
2360
2458
|
/**
|
|
2361
|
-
* Builds the query builder's
|
|
2459
|
+
* Builds the query builder's seven mutation handlers as pure functions of the current query.
|
|
2362
2460
|
*
|
|
2363
2461
|
* This is the framework-agnostic core of the action handlers in `useQueryBuilderSchema`. It owns
|
|
2364
2462
|
* the policy that surrounds the query tools—disabled gating, the confirmation callback protocol,
|
|
@@ -2368,7 +2466,7 @@ const groupInPlace = (query, sourcePathOrID, targetPathOrID, options = {}) => {
|
|
|
2368
2466
|
* @group Query Tools
|
|
2369
2467
|
*/
|
|
2370
2468
|
const createQueryActions = (config = {}) => {
|
|
2371
|
-
const { qbId, combinators, idGenerator, maxLevels = Infinity, queryDisabled, respectDisabled = true, disabledPaths, resetOnFieldChange, resetOnOperatorChange, getRuleDefaultOperator, getValueSources, getRuleDefaultValue, getMatchModes, freeze, onAddRule, onAddGroup, onRemove, onMoveRule, onMoveGroup, onGroupRule, onGroupGroup, onLog } = config;
|
|
2469
|
+
const { qbId, combinators, idGenerator, maxLevels = Infinity, queryDisabled, respectDisabled = true, disabledPaths, resetOnFieldChange, resetOnOperatorChange, getRuleDefaultOperator, getValueSources, getRuleDefaultValue, getMatchModes, freeze, onAddRule, onAddGroup, onRemove, onMoveRule, onMoveGroup, onGroupRule, onGroupGroup, onUngroup, onLog } = config;
|
|
2372
2470
|
const log = (payload) => onLog?.({
|
|
2373
2471
|
qbId,
|
|
2374
2472
|
...payload
|
|
@@ -2608,6 +2706,39 @@ const createQueryActions = (config = {}) => {
|
|
|
2608
2706
|
clone
|
|
2609
2707
|
});
|
|
2610
2708
|
return newQuery;
|
|
2709
|
+
},
|
|
2710
|
+
ungroupRuleGroup: (query, path, context) => {
|
|
2711
|
+
if (blocked(query, path)) {
|
|
2712
|
+
log({
|
|
2713
|
+
type: require_utils.LogType.pathDisabled,
|
|
2714
|
+
path,
|
|
2715
|
+
query
|
|
2716
|
+
});
|
|
2717
|
+
return;
|
|
2718
|
+
}
|
|
2719
|
+
const ruleGroup = findPath(path, query);
|
|
2720
|
+
if (path.length === 0 || !require_objectUtils.isRuleGroup(ruleGroup)) return void 0;
|
|
2721
|
+
const nextQuery = ungroup(query, path, { freeze });
|
|
2722
|
+
const callbackResult = onUngroup ? onUngroup(ruleGroup, path, query, nextQuery, context) : true;
|
|
2723
|
+
if (!callbackResult) {
|
|
2724
|
+
log({
|
|
2725
|
+
type: require_utils.LogType.onUngroupFalse,
|
|
2726
|
+
ruleGroup,
|
|
2727
|
+
path,
|
|
2728
|
+
query,
|
|
2729
|
+
nextQuery
|
|
2730
|
+
});
|
|
2731
|
+
return;
|
|
2732
|
+
}
|
|
2733
|
+
const newQuery = require_objectUtils.isRuleGroup(callbackResult) ? callbackResult : nextQuery;
|
|
2734
|
+
log({
|
|
2735
|
+
type: require_utils.LogType.ungroup,
|
|
2736
|
+
query,
|
|
2737
|
+
newQuery,
|
|
2738
|
+
path,
|
|
2739
|
+
ruleGroup
|
|
2740
|
+
});
|
|
2741
|
+
return newQuery;
|
|
2611
2742
|
}
|
|
2612
2743
|
};
|
|
2613
2744
|
};
|
|
@@ -2833,6 +2964,8 @@ exports.toFullOptionMap = require_utils.toFullOptionMap;
|
|
|
2833
2964
|
exports.transformQuery = require_transformQuery.transformQuery;
|
|
2834
2965
|
exports.trimIfString = require_utils.trimIfString;
|
|
2835
2966
|
exports.unchangedSignature = unchangedSignature;
|
|
2967
|
+
exports.ungroup = ungroup;
|
|
2968
|
+
exports.ungroupInPlace = ungroupInPlace;
|
|
2836
2969
|
exports.uniqByIdentifier = require_utils.uniqByIdentifier;
|
|
2837
2970
|
exports.uniqByName = require_utils.uniqByName;
|
|
2838
2971
|
exports.uniqOptGroups = require_utils.uniqOptGroups;
|