UNPKG

@react-querybuilder/dnd

Version:

Drag-and-drop-enabled version of react-querybuilder

1,058 lines (1,047 loc) 55.1 kB
// src/InlineCombinatorDnD.tsx import { jsx } from "react/jsx-runtime"; import { useContext, useRef } from "react"; import { getParentPath, isAncestor, pathsAreEqual, standardClassnames, TestID } from "react-querybuilder"; // src/isHotkeyPressed.ts import { lc } from "react-querybuilder"; function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F2() { }; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e2(r2) { throw r2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r2 = t.next(); return a = r2.done, r2; }, e: function e2(r2) { u = true, o = r2; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } var reservedModifierKeywords = /* @__PURE__ */ new Set(["shift", "alt", "meta", "mod", "ctrl"]); var mappedKeys = { esc: "escape", "return": "enter", ".": "period", ",": "comma", "-": "slash", " ": "space", "`": "backquote", "#": "backslash", "+": "bracketright", ShiftLeft: "shift", ShiftRight: "shift", AltLeft: "alt", AltRight: "alt", MetaLeft: "meta", MetaRight: "meta", OSLeft: "meta", OSRight: "meta", ControlLeft: "ctrl", ControlRight: "ctrl" }; var mapKey = function mapKey2(key) { return lc((key && mappedKeys[key] || key || "").trim()).replace(/key|digit|numpad|arrow/, ""); }; var isHotkeyModifier = function isHotkeyModifier2(key) { return reservedModifierKeywords.has(key); }; var keyAliases = { "\u2318": "meta", cmd: "meta", command: "meta", "\u229E": "meta", win: "meta", windows: "meta", "\u21E7": "shift", "\u2325": "alt", "\u2303": "ctrl", control: "ctrl" }; (function() { if (typeof document !== "undefined") { document.addEventListener("keydown", function(e) { if (e.key === void 0) { return; } pushToCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]); }); document.addEventListener("keyup", function(e) { if (e.key === void 0) { return; } removeFromCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]); }); } if (typeof window !== "undefined") { window.addEventListener("blur", function() { currentlyPressedKeys.clear(); }); } })(); var currentlyPressedKeys = /* @__PURE__ */ new Set(); var isReadonlyArray = function isReadonlyArray2(value) { return Array.isArray(value); }; var isHotkeyPressed = function isHotkeyPressed2(key) { var splitKey = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ","; return (isReadonlyArray(key) ? key : key.split(splitKey)).every(function(hotkey) { var _a; var hk = lc(hotkey.trim()); return currentlyPressedKeys.has((_a = keyAliases[hk]) != null ? _a : hk); }); }; var pushToCurrentlyPressedKeys = function pushToCurrentlyPressedKeys2(key) { var hotkeyArray = Array.isArray(key) ? key : [key]; if (currentlyPressedKeys.has("meta")) { var _iterator = _createForOfIteratorHelper(currentlyPressedKeys), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done; ) { var key2 = _step.value; if (!isHotkeyModifier(key2)) { currentlyPressedKeys["delete"](lc(key2)); } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } var _iterator2 = _createForOfIteratorHelper(hotkeyArray), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) { var hotkey = _step2.value; currentlyPressedKeys.add(lc(hotkey)); } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } }; var removeFromCurrentlyPressedKeys = function removeFromCurrentlyPressedKeys2(key) { var hotkeyArray = Array.isArray(key) ? key : [key]; if (key === "meta") { currentlyPressedKeys.clear(); } else { var _iterator3 = _createForOfIteratorHelper(hotkeyArray), _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) { var hotkey = _step3.value; currentlyPressedKeys["delete"](lc(hotkey)); } } catch (err) { _iterator3.e(err); } finally { _iterator3.f(); } } }; // src/QueryBuilderDndContext.ts import { createContext } from "react"; import { defaultControlElements } from "react-querybuilder"; var rule = defaultControlElements.rule; var ruleGroup = defaultControlElements.ruleGroup; var combinatorSelector = defaultControlElements.combinatorSelector; var QueryBuilderDndContext = /* @__PURE__ */ createContext({ baseControls: { rule, ruleGroup, combinatorSelector } }); // src/InlineCombinatorDnD.tsx function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray2(r, e) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = true, o = false; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = false; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ; } catch (r2) { o = true, n = r2; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } function _createForOfIteratorHelper2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray2(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F2() { }; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e2(r2) { throw r2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r2 = t.next(); return a = r2.done, r2; }, e: function e2(r2) { u = true, o = r2; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } function _unsupportedIterableToArray2(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray2(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray2(r, a) : void 0; } } function _arrayLikeToArray2(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = function __defNormalProp2(obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; }; var __spreadValues = function __spreadValues2(a, b) { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) { var _iterator = _createForOfIteratorHelper2(__getOwnPropSymbols(b)), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done; ) { var prop = _step.value; if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } return a; }; var __spreadProps = function __spreadProps2(a, b) { return __defProps(a, __getOwnPropDescs(b)); }; var __objRest = function __objRest2(source, exclude) { var target = {}; for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop]; if (source != null && __getOwnPropSymbols) { var _iterator2 = _createForOfIteratorHelper2(__getOwnPropSymbols(source)), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) { var prop = _step2.value; if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop]; } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } } return target; }; var InlineCombinatorDnD = function InlineCombinatorDnD2(_a) { var _b = _a, CombinatorSelectorComponent = _b.component, props = __objRest(_b, ["component"]); var _useContext = useContext(QueryBuilderDndContext), canDrop = _useContext.canDrop, useDrop = _useContext.useDrop, copyModeModifierKey = _useContext.copyModeModifierKey, groupModeModifierKey = _useContext.groupModeModifierKey; var _useInlineCombinatorD = useInlineCombinatorDnD(__spreadProps(__spreadValues({}, props), { component: CombinatorSelectorComponent, useDrop, canDrop, copyModeModifierKey, groupModeModifierKey })), dropRef = _useInlineCombinatorD.dropRef, dropMonitorId = _useInlineCombinatorD.dropMonitorId, isOver = _useInlineCombinatorD.isOver; var wrapperClassName = [props.schema.suppressStandardClassnames || standardClassnames.betweenRules, isOver && !props.schema.classNames.dndOver || false, isOver && !props.schema.suppressStandardClassnames && standardClassnames.dndOver || false].filter(function(c2) { return typeof c2 === "string"; }).join(" "); return /* @__PURE__ */ jsx("div", { ref: dropRef, className: wrapperClassName, "data-dropmonitorid": dropMonitorId, "data-testid": TestID.inlineCombinator, children: /* @__PURE__ */ jsx(CombinatorSelectorComponent, __spreadProps(__spreadValues({}, props), { testID: TestID.combinators })) }, "dnd"); }; var useInlineCombinatorDnD = function useInlineCombinatorDnD2(params) { var dropRef = useRef(null); var path = params.path, _canDrop = params.canDrop, schema = params.schema, useDrop = params.useDrop, rules = params.rules, _params$copyModeModif = params.copyModeModifierKey, copyModeModifierKey = _params$copyModeModif === void 0 ? "alt" : _params$copyModeModif, _params$groupModeModi = params.groupModeModifierKey, groupModeModifierKey = _params$groupModeModi === void 0 ? "ctrl" : _params$groupModeModi; var hoveringItem = (rules != null ? rules : ( /* istanbul ignore next */ [] ))[path.at(-1) - 1]; var _useDrop = useDrop(function() { return { accept: ["rule", "ruleGroup"], canDrop: function canDrop(dragging) { var itemPath = dragging.path; if (isHotkeyPressed(groupModeModifierKey) || dragging && typeof _canDrop === "function" && !_canDrop({ dragging, hovering: __spreadProps(__spreadValues({}, hoveringItem), { path, qbId: schema.qbId }) })) { return false; } var parentHoverPath = getParentPath(path); var parentItemPath = getParentPath(itemPath); var hoverIndex = path.at(-1); var itemIndex = itemPath.at(-1); return !// 1) the item is an ancestor of the drop target, (isAncestor(itemPath, path) || // 2) the item is hovered over itself (which should never // happen since combinators don't have drag handles), pathsAreEqual(itemPath, path) || pathsAreEqual(parentHoverPath, parentItemPath) && hoverIndex - 1 === itemIndex || // 3) independentCombinators is true and the drop target is just above the hovering item schema.independentCombinators && pathsAreEqual(parentHoverPath, parentItemPath) && hoverIndex === itemIndex - 1); }, collect: function collect(monitor) { var _a; return { isOver: monitor.canDrop() && monitor.isOver(), dropMonitorId: (_a = monitor.getHandlerId()) != null ? _a : "", dropEffect: isHotkeyPressed(copyModeModifierKey) ? "copy" : "move", groupItems: isHotkeyPressed(groupModeModifierKey) }; }, drop: function drop2() { var qbId = schema.qbId, getQuery = schema.getQuery, dispatchQuery = schema.dispatchQuery; var dropEffect2 = isHotkeyPressed(copyModeModifierKey) ? "copy" : "move"; var groupItems = isHotkeyPressed(groupModeModifierKey); return { type: "inlineCombinator", path, qbId, getQuery, dispatchQuery, groupItems, dropEffect: dropEffect2 }; } }; }, [_canDrop, hoveringItem, path, schema]), _useDrop2 = _slicedToArray(_useDrop, 2), _useDrop2$ = _useDrop2[0], isOver = _useDrop2$.isOver, dropMonitorId = _useDrop2$.dropMonitorId, dropEffect = _useDrop2$.dropEffect, drop = _useDrop2[1]; drop(dropRef); return { dropRef, dropMonitorId, isOver, dropEffect }; }; // src/QueryBuilderDnD.tsx import { jsx as jsx4 } from "react/jsx-runtime"; import { useContext as useContext4, useEffect, useMemo as useMemo2, useState } from "react"; import { messages, QueryBuilderContext, useMergedContext, usePreferAnyProp, usePreferProp } from "react-querybuilder"; // src/isTouchDevice.ts var isTouchDevice = function isTouchDevice2() { return typeof window !== "undefined" && "ontouchstart" in window || typeof navigator !== "undefined" && navigator.maxTouchPoints > 0; }; // ../../utils/react-compiler/react-compiler-runtime.ts import * as React from "react"; var $empty = Symbol["for"]("react.memo_cache_sentinel"); function c(size) { return React.useMemo( function() { var $ = new Array(size); for (var ii = 0; ii < size; ii++) { $[ii] = $empty; } $[$empty] = true; return $; }, // oxlint-disable-next-line exhaustive-deps [] ); } // src/RuleDnD.tsx import { jsx as jsx2 } from "react/jsx-runtime"; import { useContext as useContext2, useRef as useRef2 } from "react"; import { getParentPath as getParentPath3, isAncestor as isAncestor2, pathsAreEqual as pathsAreEqual2 } from "react-querybuilder"; // src/useDragCommon.ts import { add, findPath, getParentPath as getParentPath2, group, insert } from "react-querybuilder"; function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray3(r) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray3(r); } function _createForOfIteratorHelper3(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray3(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F2() { }; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e2(r2) { throw r2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r2 = t.next(); return a = r2.done, r2; }, e: function e2(r2) { u = true, o = r2; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } function _unsupportedIterableToArray3(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray3(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray3(r, a) : void 0; } } function _arrayLikeToArray3(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } var __defProp2 = Object.defineProperty; var __defProps2 = Object.defineProperties; var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols2 = Object.getOwnPropertySymbols; var __hasOwnProp2 = Object.prototype.hasOwnProperty; var __propIsEnum2 = Object.prototype.propertyIsEnumerable; var __defNormalProp3 = function __defNormalProp4(obj, key, value) { return key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; }; var __spreadValues3 = function __spreadValues4(a, b) { for (var prop in b || (b = {})) if (__hasOwnProp2.call(b, prop)) __defNormalProp3(a, prop, b[prop]); if (__getOwnPropSymbols2) { var _iterator = _createForOfIteratorHelper3(__getOwnPropSymbols2(b)), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done; ) { var prop = _step.value; if (__propIsEnum2.call(b, prop)) __defNormalProp3(a, prop, b[prop]); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } return a; }; var __spreadProps3 = function __spreadProps4(a, b) { return __defProps2(a, __getOwnPropDescs2(b)); }; var useDragCommon = function useDragCommon2(_ref) { var type = _ref.type, path = _ref.path, disabled = _ref.disabled, actions = _ref.actions, schema = _ref.schema, useDrag = _ref.useDrag, copyModeModifierKey = _ref.copyModeModifierKey, groupModeModifierKey = _ref.groupModeModifierKey; return useDrag(function() { return { type, item: function item() { return __spreadProps3(__spreadValues3({}, findPath(path, schema.getQuery())), { path, qbId: schema.qbId }); }, canDrag: !disabled, collect: function collect(monitor) { var _a; return { isDragging: !disabled && monitor.isDragging(), dragMonitorId: (_a = monitor.getHandlerId()) != null ? _a : "" }; }, end: function end(item, monitor_0) { var dropResult = monitor_0.getDropResult(); if (!dropResult) return; var dropEffect = isHotkeyPressed(copyModeModifierKey) ? "copy" : "move"; var groupItems = isHotkeyPressed(groupModeModifierKey); var parentHoverPath = getParentPath2(dropResult.path); var hoverIndex = dropResult.path.at(-1); var destinationPath = groupItems ? dropResult.path : dropResult.type === "ruleGroup" ? [].concat(_toConsumableArray(dropResult.path), [0]) : dropResult.type === "inlineCombinator" ? [].concat(_toConsumableArray(parentHoverPath), [hoverIndex]) : [].concat(_toConsumableArray(parentHoverPath), [hoverIndex + 1]); if (schema.qbId === dropResult.qbId) { if (groupItems) { actions.groupRule(item.path, destinationPath, dropEffect === "copy"); } else { actions.moveRule(item.path, destinationPath, dropEffect === "copy"); } } else { var otherBuilderQuery = dropResult.getQuery(); if (otherBuilderQuery) { if (groupItems) { dropResult.dispatchQuery(group(add(otherBuilderQuery, item, []), [otherBuilderQuery.rules.length], destinationPath, { clone: false })); } else { dropResult.dispatchQuery(insert(otherBuilderQuery, item, destinationPath)); } if (dropEffect !== "copy") { actions.onRuleRemove(item.path); } } } } }; }, [actions.groupRule, actions.moveRule, disabled, path]); }; // src/RuleDnD.tsx function _slicedToArray2(r, e) { return _arrayWithHoles2(r) || _iterableToArrayLimit2(r, e) || _unsupportedIterableToArray4(r, e) || _nonIterableRest2(); } function _nonIterableRest2() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArrayLimit2(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = true, o = false; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = false; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ; } catch (r2) { o = true, n = r2; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles2(r) { if (Array.isArray(r)) return r; } function _createForOfIteratorHelper4(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray4(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F2() { }; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e2(r2) { throw r2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r2 = t.next(); return a = r2.done, r2; }, e: function e2(r2) { u = true, o = r2; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } function _unsupportedIterableToArray4(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray4(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray4(r, a) : void 0; } } function _arrayLikeToArray4(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } var __defProp3 = Object.defineProperty; var __defProps3 = Object.defineProperties; var __getOwnPropDescs3 = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols3 = Object.getOwnPropertySymbols; var __hasOwnProp3 = Object.prototype.hasOwnProperty; var __propIsEnum3 = Object.prototype.propertyIsEnumerable; var __defNormalProp5 = function __defNormalProp6(obj, key, value) { return key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; }; var __spreadValues5 = function __spreadValues6(a, b) { for (var prop in b || (b = {})) if (__hasOwnProp3.call(b, prop)) __defNormalProp5(a, prop, b[prop]); if (__getOwnPropSymbols3) { var _iterator = _createForOfIteratorHelper4(__getOwnPropSymbols3(b)), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done; ) { var prop = _step.value; if (__propIsEnum3.call(b, prop)) __defNormalProp5(a, prop, b[prop]); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } return a; }; var __spreadProps5 = function __spreadProps6(a, b) { return __defProps3(a, __getOwnPropDescs3(b)); }; var RuleDnD = function RuleDnD2(props) { var $ = c(13); var rqbDndContext = useContext2(QueryBuilderDndContext); var canDrop = rqbDndContext.canDrop, useDrag = rqbDndContext.useDrag, useDrop = rqbDndContext.useDrop, copyModeModifierKey = rqbDndContext.copyModeModifierKey, groupModeModifierKey = rqbDndContext.groupModeModifierKey; var disabled = !!props.parentDisabled || !!props.disabled; var t0; if ($[0] !== canDrop || $[1] !== copyModeModifierKey || $[2] !== disabled || $[3] !== groupModeModifierKey || $[4] !== props || $[5] !== useDrag || $[6] !== useDrop) { t0 = __spreadProps5(__spreadValues5({}, props), { disabled, useDrag, useDrop, canDrop, copyModeModifierKey, groupModeModifierKey }); $[0] = canDrop; $[1] = copyModeModifierKey; $[2] = disabled; $[3] = groupModeModifierKey; $[4] = props; $[5] = useDrag; $[6] = useDrop; $[7] = t0; } else { t0 = $[7]; } var dndRefs = useRuleDnD(t0); var BaseRuleComponent = rqbDndContext.baseControls.rule; var t1; if ($[8] !== BaseRuleComponent || $[9] !== dndRefs || $[10] !== props || $[11] !== rqbDndContext) { t1 = jsx2(QueryBuilderDndContext.Provider, { value: rqbDndContext, children: jsx2(BaseRuleComponent, __spreadValues5(__spreadValues5({}, props), dndRefs)) }); $[8] = BaseRuleComponent; $[9] = dndRefs; $[10] = props; $[11] = rqbDndContext; $[12] = t1; } else { t1 = $[12]; } return t1; }; var accept = ["rule", "ruleGroup"]; var useRuleDnD = function useRuleDnD2(params) { var dndRef = useRef2(null); var dragRef = useRef2(null); var path = params.path, rule2 = params.rule, disabled = params.disabled, schema = params.schema, actions = params.actions, useDrag = params.useDrag, useDrop = params.useDrop, _canDrop = params.canDrop, _params$copyModeModif = params.copyModeModifierKey, copyModeModifierKey = _params$copyModeModif === void 0 ? "alt" : _params$copyModeModif, _params$groupModeModi = params.groupModeModifierKey, groupModeModifierKey = _params$groupModeModi === void 0 ? "ctrl" : _params$groupModeModi; var _useDragCommon = useDragCommon({ type: "rule", path, disabled, independentCombinators: schema.independentCombinators, schema, actions, useDrag, copyModeModifierKey, groupModeModifierKey }), _useDragCommon2 = _slicedToArray2(_useDragCommon, 3), _useDragCommon2$ = _useDragCommon2[0], isDragging = _useDragCommon2$.isDragging, dragMonitorId = _useDragCommon2$.dragMonitorId, drag = _useDragCommon2[1], preview = _useDragCommon2[2]; var _useDrop = useDrop(function() { return { accept, canDrop: function canDrop(dragging) { if (isHotkeyPressed(groupModeModifierKey) && disabled || dragging && typeof _canDrop === "function" && !_canDrop({ dragging, hovering: __spreadProps5(__spreadValues5({}, rule2), { path, qbId: schema.qbId }) })) { return false; } if (schema.qbId !== dragging.qbId) return true; var parentHoverPath = getParentPath3(path); var parentItemPath = getParentPath3(dragging.path); var hoverIndex = path.at(-1); var itemIndex = dragging.path.at(-1); return !// 1) item is ancestor of drop target, OR (isAncestor2(dragging.path, path) || // 2) item is hovered over itself, OR pathsAreEqual2(path, dragging.path) || // 3) item is hovered over the previous item AND this is a move, not a group !isHotkeyPressed(groupModeModifierKey) && pathsAreEqual2(parentHoverPath, parentItemPath) && (hoverIndex === itemIndex - 1 || schema.independentCombinators && hoverIndex === itemIndex - 2)); }, collect: function collect(monitor) { var _a; return { isOver: monitor.canDrop() && monitor.isOver(), dropMonitorId: (_a = monitor.getHandlerId()) != null ? _a : "", dropEffect: isHotkeyPressed(copyModeModifierKey) ? "copy" : "move", groupItems: isHotkeyPressed(groupModeModifierKey) }; }, drop: function drop2() { var qbId = schema.qbId, getQuery = schema.getQuery, dispatchQuery = schema.dispatchQuery; var dropEffect2 = isHotkeyPressed(copyModeModifierKey) ? "copy" : "move"; var groupItems2 = isHotkeyPressed(groupModeModifierKey); return { type: "rule", path, qbId, getQuery, dispatchQuery, groupItems: groupItems2, dropEffect: dropEffect2 }; } }; }, [disabled, actions.moveRule, path, _canDrop, rule2, schema]), _useDrop2 = _slicedToArray2(_useDrop, 2), _useDrop2$ = _useDrop2[0], isOver = _useDrop2$.isOver, dropMonitorId = _useDrop2$.dropMonitorId, dropEffect = _useDrop2$.dropEffect, groupItems = _useDrop2$.groupItems, drop = _useDrop2[1]; drag(dragRef); preview(drop(dndRef)); return { isDragging, dragMonitorId, isOver, dropMonitorId, dndRef, dragRef, dropEffect, groupItems }; }; // src/RuleGroupDnD.tsx import { jsx as jsx3 } from "react/jsx-runtime"; import { useContext as useContext3, useRef as useRef3 } from "react"; import { getParentPath as getParentPath4, isAncestor as isAncestor3, pathsAreEqual as pathsAreEqual3 } from "react-querybuilder"; function _slicedToArray3(r, e) { return _arrayWithHoles3(r) || _iterableToArrayLimit3(r, e) || _unsupportedIterableToArray5(r, e) || _nonIterableRest3(); } function _nonIterableRest3() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArrayLimit3(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = true, o = false; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = false; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ; } catch (r2) { o = true, n = r2; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles3(r) { if (Array.isArray(r)) return r; } function _createForOfIteratorHelper5(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray5(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F2() { }; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e2(r2) { throw r2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r2 = t.next(); return a = r2.done, r2; }, e: function e2(r2) { u = true, o = r2; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } function _unsupportedIterableToArray5(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray5(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray5(r, a) : void 0; } } function _arrayLikeToArray5(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } var __defProp4 = Object.defineProperty; var __defProps4 = Object.defineProperties; var __getOwnPropDescs4 = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols4 = Object.getOwnPropertySymbols; var __hasOwnProp4 = Object.prototype.hasOwnProperty; var __propIsEnum4 = Object.prototype.propertyIsEnumerable; var __defNormalProp7 = function __defNormalProp8(obj, key, value) { return key in obj ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; }; var __spreadValues7 = function __spreadValues8(a, b) { for (var prop in b || (b = {})) if (__hasOwnProp4.call(b, prop)) __defNormalProp7(a, prop, b[prop]); if (__getOwnPropSymbols4) { var _iterator = _createForOfIteratorHelper5(__getOwnPropSymbols4(b)), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done; ) { var prop = _step.value; if (__propIsEnum4.call(b, prop)) __defNormalProp7(a, prop, b[prop]); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } return a; }; var __spreadProps7 = function __spreadProps8(a, b) { return __defProps4(a, __getOwnPropDescs4(b)); }; var RuleGroupDnD = function RuleGroupDnD2(props) { var $ = c(11); var rqbDndContext = useContext3(QueryBuilderDndContext); var canDrop = rqbDndContext.canDrop, t0 = rqbDndContext.baseControls, useDrag = rqbDndContext.useDrag, useDrop = rqbDndContext.useDrop, copyModeModifierKey = rqbDndContext.copyModeModifierKey, groupModeModifierKey = rqbDndContext.groupModeModifierKey; var BaseRuleGroupComponent = t0.ruleGroup; var t1; if ($[0] !== canDrop || $[1] !== copyModeModifierKey || $[2] !== groupModeModifierKey || $[3] !== props || $[4] !== useDrag || $[5] !== useDrop) { t1 = __spreadProps7(__spreadValues7({}, props), { disabled: !!props.parentDisabled || !!props.disabled, useDrag, useDrop, canDrop, copyModeModifierKey, groupModeModifierKey }); $[0] = canDrop; $[1] = copyModeModifierKey; $[2] = groupModeModifierKey; $[3] = props; $[4] = useDrag; $[5] = useDrop; $[6] = t1; } else { t1 = $[6]; } var dndRefs = useRuleGroupDnD(t1); var t2; if ($[7] !== BaseRuleGroupComponent || $[8] !== dndRefs || $[9] !== props) { t2 = jsx3(BaseRuleGroupComponent, __spreadValues7(__spreadValues7({}, props), dndRefs)); $[7] = BaseRuleGroupComponent; $[8] = dndRefs; $[9] = props; $[10] = t2; } else { t2 = $[10]; } return t2; }; var accept2 = ["rule", "ruleGroup"]; var useRuleGroupDnD = function useRuleGroupDnD2(params) { var previewRef = useRef3(null); var dragRef = useRef3(null); var dropRef = useRef3(null); var disabled = params.disabled, path = params.path, ruleGroup2 = params.ruleGroup, schema = params.schema, actions = params.actions, useDrag = params.useDrag, useDrop = params.useDrop, _canDrop = params.canDrop, _params$copyModeModif = params.copyModeModifierKey, copyModeModifierKey = _params$copyModeModif === void 0 ? "alt" : _params$copyModeModif, _params$groupModeModi = params.groupModeModifierKey, groupModeModifierKey = _params$groupModeModi === void 0 ? "ctrl" : _params$groupModeModi; var _useDragCommon = useDragCommon({ type: "ruleGroup", path, disabled, independentCombinators: schema.independentCombinators, schema, actions, useDrag, copyModeModifierKey, groupModeModifierKey }), _useDragCommon2 = _slicedToArray3(_useDragCommon, 3), _useDragCommon2$ = _useDragCommon2[0], isDragging = _useDragCommon2$.isDragging, dragMonitorId = _useDragCommon2$.dragMonitorId, drag = _useDragCommon2[1], preview = _useDragCommon2[2]; var _useDrop = useDrop(function() { return { accept: accept2, canDrop: function canDrop(dragging) { if (disabled || dragging && typeof _canDrop === "function" && !_canDrop({ dragging, hovering: __spreadProps7(__spreadValues7({}, ruleGroup2), { path, qbId: schema.qbId }) })) { return false; } if (schema.qbId !== dragging.qbId) return true; var parentItemPath = getParentPath4(dragging.path); var itemIndex = dragging.path.at(-1); return !// 1) item is ancestor of drop target, OR (isAncestor3(dragging.path, path) || // 2) item is first child and is dropped on its own group header, OR pathsAreEqual3(path, parentItemPath) && itemIndex === 0 || // 3) the group is dropped on itself pathsAreEqual3(path, dragging.path)); }, collect: function collect(monitor) { var _a; return { isOver: monitor.canDrop() && monitor.isOver(), dropMonitorId: (_a = monitor.getHandlerId()) != null ? _a : "", dropEffect: isHotkeyPressed(copyModeModifierKey) ? "copy" : "move", groupItems: isHotkeyPressed(groupModeModifierKey) }; }, drop: function drop2() { var qbId = schema.qbId, getQuery = schema.getQuery, dispatchQuery = schema.dispatchQuery; var dropEffect2 = isHotkeyPressed(copyModeModifierKey) ? "copy" : "move"; var groupItems2 = isHotkeyPressed(groupModeModifierKey); return { type: "ruleGroup", path, qbId, getQuery, dispatchQuery, groupItems: groupItems2, dropEffect: dropEffect2 }; } }; }, [disabled, actions.groupRule, actions.moveRule, path, _canDrop, ruleGroup2, schema]), _useDrop2 = _slicedToArray3(_useDrop, 2), _useDrop2$ = _useDrop2[0], isOver = _useDrop2$.isOver, dropMonitorId = _useDrop2$.dropMonitorId, dropEffect = _useDrop2$.dropEffect, groupItems = _useDrop2$.groupItems, drop = _useDrop2[1]; if (path.length > 0) { drag(dragRef); preview(previewRef); } drop(dropRef); return { isDragging, dragMonitorId, isOver, dropMonitorId, previewRef, dragRef, dropRef, dropEffect, groupItems }; }; // src/QueryBuilderDnD.tsx function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r2, n2, o2, i2) { var c3 = n2 && n2.prototype instanceof Generator ? n2 : Generator, u2 = Object.create(c3.prototype); return _regeneratorDefine2(u2, "_invoke", function(r3, n3, o3) { var i3, c4, u3, f2 = 0, p = o3 || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d2(t2, r4) { return i3 = t2, c4 = 0, u3 = e, G.n = r4, a; } }; function d(r4, n4) { for (c4 = r4, u3 = n4, t = 0; !y && f2 && !o4 && t < p.length; t++) { var o4, i4 = p[t], d2 = G.p, l = i4[2]; r4 > 3 ? (o4 = l === n4) && (u3 = i4[(c4 = i4[4]) ? 5 : (c4 = 3, 3)], i4[4] = i4[5] = e) : i4[0] <= d2 && ((o4 = r4 < 2 && d2 < i4[1]) ? (c4 = 0, G.v = n4, G.n = i4[1]) : d2 < l && (o4 = r4 < 3 || i4[0] > n4 || n4 > l) && (i4[4] = r4, i4[5] = n4, G.n = l, c4 = 0)); } if (o4 || r4 > 1) return a; throw y = true, n4; } return function(o4, p2, l) { if (f2 > 1) throw TypeError("Generator is already running"); for (y && 1 === p2 && d(p2, l), c4 = p2, u3 = l; (t = c4 < 2 ? e : u3) || !y; ) { i3 || (c4 ? c4 < 3 ? (c4 > 1 && (G.n = -1), d(c4, u3)) : G.n = u3 : G.v = u3); try { if (f2 = 2, i3) { if (c4 || (o4 = "next"), t = i3[o4]) { if (!(t = t.call(i3, u3))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u3 = t.value, c4 < 2 && (c4 = 0); } else 1 === c4 && (t = i3["return"]) && t.call(i3), c4 < 2 && (u3 = TypeError("The iterator does not provide a '" + o4 + "' method"), c4 = 1); i3 = e; } else if ((t = (y = G.n < 0) ? u3 : r3.call(n3, G)) !== a) break; } catch (t2) { i3 = e, c4 = 1, u3 = t2; } finally { f2 = 1; } } return { value: t, done: y }; }; }(r2, o2, i2), true), u2; } var a = {}; function Generator() { } function GeneratorFunction() { } function GeneratorFunctionPrototype() { } t = Object.getPrototypeOf; var c2 = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function() { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c2); function f(e2) { return Object.setPrototypeOf ? Object.setPrototypeOf(e2, GeneratorFunctionPrototype) : (e2.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e2, o, "GeneratorFunction")), e2.prototype = Object.create(u), e2; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function() { return this; }), _regeneratorDefine2(u, "toString", function() { return "[object Generator]"; }), (_regenerator = function _regenerator2() { return { w: i, m: f }; })(); } function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e2) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e2, r2, n2, t2) { if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2; else { var o = function o2(r3, n3) { _regeneratorDefine2(e2, r3, function(e3) { return this._invoke(r3, n3, e3); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); } function asyncGeneratorStep(n, t, e, r, o, a, c2) { try { var i = n[a](c2), u = i.value; } catch (n2) { return void e(n2); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function() { var t = this, e = arguments; return new Promise(function(r, o) { var a = n.apply(t, e); function _next(n2) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n2); } function _throw(n2) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n2); } _next(void 0); }); }; } function _slicedToArray4(r, e) { return _arrayWithHoles4(r) || _iterableToArrayLimit4(r, e) || _unsupportedIterableToArray6(r, e) || _nonIterableRest4(); } function _nonIterableRest4() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArrayLimit4(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = true, o = false; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = false; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ; } catch (r2) { o = true, n = r2; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles4(r) { if (Array.isArray(r)) return r; } function _createForOfIteratorHelper6(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray6(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F2() { }; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e2(r2) { throw r2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r2 = t.next(); return a = r2.done, r2; }, e: function e2(r2) { u = true, o = r2; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } function _unsupportedIterableToArray6(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray6(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray6(r, a) : void 0; } } function _arrayLikeToArray6(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } var __defProp5 = Object.defineProperty; var __defProps5 = Object.defineProperties; var __getOwnPropDescs5 = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols5 = Object.getOwnPropertySymbols; var __hasOwnProp5 = Object.prototype.hasOwnProperty; var __propIsEnum5 = Object.prototype.propertyIsEnumerable; var __defNormalProp9 = function __defNormalProp10(obj, key, value) { return key in obj ? __defProp5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; }; var __spreadValues9 = function __spreadValues10(a, b) { for (var prop in b || (b = {})) if (__hasOwnProp5.call(b, prop)) __defNormalProp9(a, prop, b[prop]); if (__getOwnPropSymbols5) { var _iterator = _createForOfIteratorHelper6(__getOwnPropSymbols5(b)), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done; ) { var prop = _step.value; if (__propIsEnum5.call(b, prop)) __defNormalProp9(a, prop, b[prop]); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } return a; }; var __spreadProps9 = function __spreadProps10(a, b) { return __defProps5(a, __getOwnPropDescs5(b)); }; var emptyObject = {}; var QueryBuilderDnD = function QueryBuilderDnD2(props) { var controlClassnames = props.controlClassnames, controlElements = props.controlElements, debugMode = props.debugMode, enableDragAndDropProp = props.enableDragAndDrop, enableMountQueryChange = props.enableMountQueryChange, translations = props.translations, canDrop = props.canDrop, copyModeModifierKey = props.copyModeModifierKey, groupModeModifierKey = props.groupModeModifierKey; var rqbContext = useMergedContext({ controlClassnames, controlElements, debugMode, enableDragAndDrop: enableDragAndDropProp != null ? enableDragAndDropProp : true, enableMountQueryChange, translations: translations != null ? translations : {} }); var enableDragAndDrop = rqbContext.enableDragAndDrop; var dnd = useReactDnD(props.dnd); var key = enableDragAndDrop && dnd ? "dnd" : "no-dnd"; var _ref = dnd != null ? dnd : emptyObject, DndProvider = _ref.DndProvider, ReactDndBackend = _ref.ReactDndBackend; var contextWithoutDnD = useMemo2(function() { return __spreadProps9(__spreadValues9({}, rqbContext), { enableDragAndDrop: false, debugMode }); }, [rqbContext, debugMode]); var contextWithDnD = useMemo2(function() { return __spreadProps9(__spreadValues9({}, rqbContext), { enableDragAndDrop, debugMode }); }, [rqbContext, debugMode, enableDragAndDrop]); if (!enableDragAndDrop || !dnd || !DndProvider || !ReactDndBackend) { return /* @__PURE__ */ jsx4(QueryBuilderContext.Provider, { value: contextWithoutDnD, children: props.children }, key); } return /* @__PURE__ */ jsx4(DndProvider, { backend: ReactDndBackend, debugMode, children: /* @__PURE__ */ jsx4(QueryBuilderContext.Provider, { value: contextWithDnD, children: /* @__PURE__ */ jsx4(QueryBuilderDndWithoutProvider, { dnd, canDrop, copyModeModifierKey, groupModeModifierKey, children: props.children }) }, key) }, key); }; var QueryBuilderDndWithoutProvider = function QueryBuilderDndWithoutProvider2(props) { var _a, _b, _c, _d, _e, _f; var rqbContext = useContext4(QueryBuilderContext); var rqbDndContext = useContext4(QueryBuilderDndContext); var dnd = useReactDnD(props.dnd); var debugMode = usePreferProp(false, props.debugMode, rqbContext.debugMode); var canDrop = usePreferAnyProp(void 0, props.canDrop, rqbDndContext.canDrop); var copyModeModifierKey = usePreferAnyProp(void 0, props.copyModeModifierKey, rqbDndContext.copyModeModifierKey); var groupModeModifierKey = usePreferAnyProp(void 0, props.groupModeModifierKey, rqbDndContext.groupModeModifierKey); var enableDragAndDrop = usePreferProp(true, props.enableDragAndDrop, rqbContext.enableDragAndDrop); var key = enableDragAndDrop && dnd ? "dnd" : "no-dnd"; var baseControls = useMemo2(function() { var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l; return { rule: (_d2 = (_c2 = (_a2 = props.controlElements) == null ? void 0 : _a2.rule) != null ? _c2 : (_b2 = rqbContext.controlElements) == null ? void 0 : _b2.rule) != null ? _d2 : rqbDndContext.baseControls.rule, ruleGroup: (_h = (_g = (_e2 = props.controlElements) == null ? void 0 : _e2.ruleGroup) != null ? _g : (_f2 = rqbContext.controlElements) == null ? void 0 : _f2.ruleGroup) != null ? _h : rqbDndContext.baseControls.ruleGroup, combinatorSelector: (_l = (_k = (_i = props.controlElements) == null ? void 0 : _i.combinatorSelector) != null ? _k : (_j = rqbContext.controlElements) == null ? void 0 : _j.combinatorSelector) != null ? _l : rqbDndContext.baseControls.combinatorSelector }; }, [(_a =