@react-querybuilder/dnd
Version:
Drag-and-drop-enabled version of react-querybuilder
1 lines • 44.8 kB
Source Map (JSON)
{"version":3,"file":"react-querybuilder_dnd.mjs","names":["mappedKeys: Record<string, string>","keyAliases: Record<string, string>","currentlyPressedKeys: Set<string>","key","QueryBuilderDndContext: Context<QueryBuilderDndContextProps>","dropEffect","emptyImage: HTMLImageElement","accept: [DndDropTargetType, DndDropTargetType]","rule","dropEffect","accept: [DndDropTargetType, DndDropTargetType]","ruleGroup","dropEffect","newContext: QueryBuilderContextProps","dndContextValue: QueryBuilderDndContextProps"],"sources":["../src/isHotkeyPressed.ts","../src/QueryBuilderDndContext.ts","../src/InlineCombinatorDnD.tsx","../src/isTouchDevice.ts","../src/getEmptyImage.ts","../src/useDragCommon.ts","../src/RuleDnD.tsx","../src/RuleGroupDnD.tsx","../src/QueryBuilderDnD.tsx"],"sourcesContent":["/* oxlint-disable prefer-global-this */\n\n/**\n * Adapted from\n * https://github.com/JohannesKlauss/react-hotkeys-hook/blob/bc55a281f1d212d09de786aeb5cd236c58d9531d/src/isHotkeyPressed.ts\n * and\n * https://github.com/JohannesKlauss/react-hotkeys-hook/blob/bc55a281f1d212d09de786aeb5cd236c58d9531d/src/parseHotkey.ts\n */\n\nimport { lc } from 'react-querybuilder';\n\ntype ModifierKey = 'shift' | 'alt' | 'meta' | 'mod' | 'ctrl';\n\n// #region parseHotkey.ts\nconst reservedModifierKeywords = new Set<ModifierKey>(['shift', 'alt', 'meta', 'mod', 'ctrl']);\n\nconst mappedKeys: Record<string, string> = {\n esc: 'escape',\n return: 'enter',\n '.': 'period',\n ',': 'comma',\n '-': 'slash',\n ' ': 'space',\n '`': 'backquote',\n '#': 'backslash',\n '+': 'bracketright',\n ShiftLeft: 'shift',\n ShiftRight: 'shift',\n AltLeft: 'alt',\n AltRight: 'alt',\n MetaLeft: 'meta',\n MetaRight: 'meta',\n OSLeft: 'meta',\n OSRight: 'meta',\n ControlLeft: 'ctrl',\n ControlRight: 'ctrl',\n};\n\nconst mapKey = (key?: string) =>\n lc(((key && mappedKeys[key]) || key || '').trim()).replace(/key|digit|numpad|arrow/, '');\n\nconst isHotkeyModifier = (key: string) => reservedModifierKeywords.has(key as ModifierKey);\n// #endregion parseHotkey.ts\n\nconst keyAliases: Record<string, string> = {\n '⌘': 'meta',\n cmd: 'meta',\n command: 'meta',\n '⊞': 'meta',\n win: 'meta',\n windows: 'meta',\n '⇧': 'shift',\n '⌥': 'alt',\n '⌃': 'ctrl',\n control: 'ctrl',\n};\n\n// #region isHotkeyPressed.ts\n(() => {\n if (typeof document !== 'undefined') {\n document.addEventListener('keydown', e => {\n if (e.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n\n pushToCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);\n });\n\n document.addEventListener('keyup', e => {\n if (e.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n\n removeFromCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);\n });\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('blur', () => {\n currentlyPressedKeys.clear();\n });\n }\n})();\n\nconst currentlyPressedKeys: Set<string> = new Set<string>();\n\n// https://github.com/microsoft/TypeScript/issues/17002\nconst isReadonlyArray = (value: unknown): value is readonly unknown[] => Array.isArray(value);\n\nexport const isHotkeyPressed = (key: string | readonly string[], splitKey = ','): boolean =>\n (isReadonlyArray(key) ? key : key.split(splitKey)).every(hotkey => {\n const hk = lc(hotkey.trim());\n return currentlyPressedKeys.has(keyAliases[hk] ?? hk);\n });\n\nconst pushToCurrentlyPressedKeys = (key: string | string[]) => {\n const hotkeyArray = Array.isArray(key) ? key : [key];\n\n /*\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\n */\n if (currentlyPressedKeys.has('meta')) {\n for (const key of currentlyPressedKeys) {\n if (!isHotkeyModifier(key)) {\n currentlyPressedKeys.delete(lc(key));\n }\n }\n }\n\n for (const hotkey of hotkeyArray) currentlyPressedKeys.add(lc(hotkey));\n};\n\nconst removeFromCurrentlyPressedKeys = (key: string | string[]) => {\n const hotkeyArray = Array.isArray(key) ? key : [key];\n\n /*\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\n */\n if (key === 'meta') {\n currentlyPressedKeys.clear();\n } else {\n for (const hotkey of hotkeyArray) currentlyPressedKeys.delete(lc(hotkey));\n }\n};\n// #endregion isHotkeyPressed.ts\n","import type { Context } from 'react';\nimport { createContext } from 'react';\nimport { defaultControlElements } from 'react-querybuilder';\nimport type { QueryBuilderDndContextProps } from './types';\n\nconst { rule, ruleGroup, combinatorSelector } = defaultControlElements;\n\n/**\n * @group Components\n */\nexport const QueryBuilderDndContext: Context<QueryBuilderDndContextProps> =\n createContext<QueryBuilderDndContextProps>({\n baseControls: { rule, ruleGroup, combinatorSelector },\n });\n","import type { Ref } from 'react';\nimport * as React from 'react';\nimport { useContext, useRef } from 'react';\nimport type { useDrop as useDropOriginal } from 'react-dnd';\nimport type {\n DndDropTargetType,\n DraggedItem,\n DropCollection,\n DropEffect,\n DropResult,\n InlineCombinatorProps,\n RuleGroupTypeAny,\n RuleType,\n} from 'react-querybuilder';\nimport {\n getParentPath,\n isAncestor,\n pathsAreEqual,\n standardClassnames,\n TestID,\n} from 'react-querybuilder';\nimport { isHotkeyPressed } from './isHotkeyPressed';\nimport { QueryBuilderDndContext } from './QueryBuilderDndContext';\nimport type { QueryBuilderDndContextProps } from './types';\n\n/**\n * The drag-and-drop-enabled inline combinator component.\n *\n * @group Components\n */\nexport const InlineCombinatorDnD = ({\n component: CombinatorSelectorComponent,\n ...props\n}: InlineCombinatorProps): React.JSX.Element => {\n const { canDrop, useDrop, copyModeModifierKey, groupModeModifierKey } =\n useContext(QueryBuilderDndContext);\n\n const { dropRef, dropMonitorId, isOver } = useInlineCombinatorDnD({\n ...props,\n component: CombinatorSelectorComponent,\n useDrop: useDrop!,\n canDrop,\n copyModeModifierKey,\n groupModeModifierKey,\n });\n\n const wrapperClassName = [\n props.schema.suppressStandardClassnames || standardClassnames.betweenRules,\n (isOver && !props.schema.classNames.dndOver) || false,\n (isOver && !props.schema.suppressStandardClassnames && standardClassnames.dndOver) || false,\n ]\n .filter(c => typeof c === 'string')\n .join(' ');\n\n return (\n <div\n key=\"dnd\"\n ref={dropRef}\n className={wrapperClassName}\n data-dropmonitorid={dropMonitorId}\n data-testid={TestID.inlineCombinator}>\n <CombinatorSelectorComponent {...props} testID={TestID.combinators} />\n </div>\n );\n};\n\ntype UseInlineCombinatorDndParams = InlineCombinatorProps &\n Pick<QueryBuilderDndContextProps, 'canDrop' | 'copyModeModifierKey' | 'groupModeModifierKey'> & {\n useDrop: typeof useDropOriginal;\n };\n\ninterface UseInlineCombinatorDnD {\n isOver: boolean;\n dropMonitorId: string | symbol | null;\n dropRef: Ref<HTMLDivElement>;\n dropEffect?: DropEffect;\n groupItems?: boolean;\n dropNotAllowed?: boolean;\n}\n\n/**\n * @group Hooks\n */\nexport const useInlineCombinatorDnD = (\n params: UseInlineCombinatorDndParams\n): UseInlineCombinatorDnD => {\n const dropRef = useRef<HTMLDivElement>(null);\n\n const {\n path,\n canDrop,\n schema,\n useDrop,\n rules,\n copyModeModifierKey = 'alt',\n groupModeModifierKey = 'ctrl',\n } = params;\n\n // The \"hovering\" item is the rule or group which precedes this inline combinator.\n const hoveringItem = (rules ?? /* istanbul ignore next */ [])[path.at(-1)! - 1] as\n | RuleType\n | RuleGroupTypeAny;\n\n const [{ isOver, dropMonitorId, dropEffect, dropNotAllowed }, drop] = useDrop<\n DraggedItem,\n DropResult,\n DropCollection\n >(\n () => ({\n accept: ['rule', 'ruleGroup'] as DndDropTargetType[],\n canDrop: dragging => {\n const { path: itemPath } = dragging;\n if (\n isHotkeyPressed(groupModeModifierKey) ||\n (dragging &&\n typeof canDrop === 'function' &&\n !canDrop({ dragging, hovering: { ...hoveringItem, path, qbId: schema.qbId } }))\n ) {\n return false;\n }\n const parentHoverPath = getParentPath(path);\n const parentItemPath = getParentPath(itemPath);\n const hoverIndex = path.at(-1)!;\n const itemIndex = itemPath.at(-1)!;\n\n // Disallow drop if...\n // prettier-ignore\n return !(\n // 1) the item is an ancestor of the drop target,\n isAncestor(itemPath, path) ||\n // 2) the item is hovered over itself (which should never\n // happen since combinators don't have drag handles),\n pathsAreEqual(itemPath, path) ||\n (pathsAreEqual(parentHoverPath, parentItemPath) && hoverIndex - 1 === itemIndex) ||\n // 3) independentCombinators is true and the drop target is just above the hovering item\n (schema.independentCombinators &&\n pathsAreEqual(parentHoverPath, parentItemPath) &&\n hoverIndex === itemIndex - 1)\n );\n },\n collect: monitor => ({\n dropNotAllowed: monitor.isOver() && !monitor.canDrop(),\n isOver: monitor.canDrop() && monitor.isOver(),\n dropMonitorId: monitor.getHandlerId() ?? '',\n dropEffect: isHotkeyPressed(copyModeModifierKey) ? 'copy' : 'move',\n groupItems: isHotkeyPressed(groupModeModifierKey),\n }),\n drop: () => {\n const { qbId, getQuery, dispatchQuery } = schema;\n const dropEffect = isHotkeyPressed(copyModeModifierKey) ? 'copy' : 'move';\n const groupItems = isHotkeyPressed(groupModeModifierKey);\n\n return {\n type: 'inlineCombinator',\n path,\n qbId,\n getQuery,\n dispatchQuery,\n groupItems,\n dropEffect,\n };\n },\n }),\n [canDrop, hoveringItem, path, schema]\n );\n\n drop(dropRef);\n\n return { dropRef, dropMonitorId, isOver, dropEffect, dropNotAllowed };\n};\n","/* istanbul ignore file */\n/* oxlint-disable prefer-global-this */\n\nexport const isTouchDevice = (): boolean =>\n (typeof window !== 'undefined' && 'ontouchstart' in window) ||\n (typeof navigator !== 'undefined' && navigator.maxTouchPoints > 0);\n","let emptyImage: HTMLImageElement;\n\nexport const getEmptyImage = (): HTMLImageElement => {\n if (!emptyImage) {\n emptyImage = new Image();\n emptyImage.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';\n }\n return emptyImage;\n};\n","import type { ConnectDragPreview, ConnectDragSource, useDrag as originalUseDrag } from 'react-dnd';\nimport type {\n DndDropTargetType,\n DragCollection,\n DraggedItem,\n DropResult,\n Path,\n QueryActions,\n Schema,\n} from 'react-querybuilder';\nimport { add, findPath, getParentPath, group, insert } from 'react-querybuilder';\nimport { isHotkeyPressed } from './isHotkeyPressed';\nimport type { QueryBuilderDndProps } from './types';\n\ntype UseDragCommonProps = {\n path: Path;\n type: DndDropTargetType;\n disabled?: boolean;\n independentCombinators?: boolean;\n actions: QueryActions;\n // oxlint-disable-next-line typescript/no-explicit-any\n schema: Schema<any, any>;\n useDrag: typeof originalUseDrag;\n hideDefaultDragPreview?: boolean;\n} & Required<Pick<QueryBuilderDndProps, 'copyModeModifierKey' | 'groupModeModifierKey'>>;\n\n/**\n * @group Hooks\n */\nexport const useDragCommon = ({\n type,\n path,\n disabled,\n // Unused for now\n // independentCombinators,\n actions,\n schema,\n useDrag,\n copyModeModifierKey,\n groupModeModifierKey,\n hideDefaultDragPreview,\n}: UseDragCommonProps): [DragCollection, ConnectDragSource, ConnectDragPreview] =>\n useDrag<DraggedItem, DropResult, DragCollection>(\n () => ({\n type,\n item: () => ({ ...findPath(path, schema.getQuery())!, path, qbId: schema.qbId }),\n canDrag: !disabled,\n previewOptions: { captureDraggingState: !!hideDefaultDragPreview },\n collect: monitor => ({\n isDragging: !disabled && monitor.isDragging(),\n dragMonitorId: monitor.getHandlerId() ?? '',\n }),\n end: (item, monitor) => {\n const dropResult = monitor.getDropResult();\n\n if (!dropResult) return;\n\n const dropEffect = isHotkeyPressed(copyModeModifierKey) ? 'copy' : 'move';\n const groupItems = isHotkeyPressed(groupModeModifierKey);\n\n const parentHoverPath = getParentPath(dropResult.path);\n const hoverIndex = dropResult.path.at(-1)!;\n const destinationPath = groupItems\n ? dropResult.path\n : dropResult.type === 'ruleGroup'\n ? [...dropResult.path, 0]\n : dropResult.type === 'inlineCombinator'\n ? [...parentHoverPath, hoverIndex]\n : [...parentHoverPath, hoverIndex + 1];\n\n if (schema.qbId === dropResult.qbId) {\n if (groupItems) {\n actions.groupRule(item.path, destinationPath, dropEffect === 'copy');\n } else {\n actions.moveRule(item.path, destinationPath, dropEffect === 'copy');\n }\n } else {\n const otherBuilderQuery = dropResult.getQuery();\n // istanbul ignore else\n if (otherBuilderQuery) {\n if (groupItems) {\n dropResult.dispatchQuery(\n group(\n add(otherBuilderQuery, item, []),\n [otherBuilderQuery.rules.length],\n destinationPath,\n { clone: false }\n )\n );\n } else {\n dropResult.dispatchQuery(insert(otherBuilderQuery, item, destinationPath));\n }\n // istanbul ignore else\n if (dropEffect !== 'copy') {\n actions.onRuleRemove(item.path);\n }\n }\n }\n },\n }),\n [actions.groupRule, actions.moveRule, disabled, path]\n );\n","import * as React from 'react';\nimport { useContext, useRef } from 'react';\nimport type { useDrag as useDragOriginal, useDrop as useDropOriginal } from 'react-dnd';\nimport type {\n DndDropTargetType,\n DraggedItem,\n DropCollection,\n DropResult,\n RuleProps,\n UseRuleDnD,\n} from 'react-querybuilder';\nimport { getParentPath, isAncestor, pathsAreEqual } from 'react-querybuilder';\nimport { getEmptyImage } from './getEmptyImage';\nimport { isHotkeyPressed } from './isHotkeyPressed';\nimport { QueryBuilderDndContext } from './QueryBuilderDndContext';\nimport type { QueryBuilderDndContextProps } from './types';\nimport { useDragCommon } from './useDragCommon';\n\n/**\n * Rule component for drag-and-drop. Renders the provided rule component\n * ({@link react-querybuilder!Rule Rule} by default), but forwards the\n * drag-and-drop context.\n *\n * @group Components\n */\nexport const RuleDnD = (props: RuleProps): React.JSX.Element => {\n const rqbDndContext = useContext(QueryBuilderDndContext);\n\n const {\n canDrop,\n useDrag,\n useDrop,\n copyModeModifierKey,\n groupModeModifierKey,\n hideDefaultDragPreview,\n } = rqbDndContext;\n\n const disabled = !!props.parentDisabled || !!props.disabled;\n\n const dndRefs = useRuleDnD({\n ...props,\n disabled,\n useDrag: useDrag!,\n useDrop: useDrop!,\n canDrop,\n copyModeModifierKey,\n groupModeModifierKey,\n hideDefaultDragPreview,\n });\n\n const { rule: BaseRuleComponent } = rqbDndContext.baseControls;\n\n return (\n <QueryBuilderDndContext.Provider value={rqbDndContext}>\n <BaseRuleComponent {...props} {...dndRefs} />\n </QueryBuilderDndContext.Provider>\n );\n};\n\ninterface UseRuleDndParams\n extends RuleProps, Omit<QueryBuilderDndContextProps, 'baseControls' | 'useDrag' | 'useDrop'> {\n useDrag: typeof useDragOriginal;\n useDrop: typeof useDropOriginal;\n}\n\nconst accept: [DndDropTargetType, DndDropTargetType] = ['rule', 'ruleGroup'];\n\n/**\n * @group Hooks\n */\nexport const useRuleDnD = (params: UseRuleDndParams): UseRuleDnD => {\n const dndRef = useRef<HTMLDivElement>(null);\n const dragRef = useRef<HTMLSpanElement>(null);\n\n const {\n path,\n rule,\n disabled,\n schema,\n actions,\n useDrag,\n useDrop,\n canDrop,\n copyModeModifierKey = 'alt',\n groupModeModifierKey = 'ctrl',\n hideDefaultDragPreview,\n } = params;\n\n const [{ isDragging, dragMonitorId }, drag, preview] = useDragCommon({\n type: 'rule',\n path,\n disabled,\n independentCombinators: schema.independentCombinators,\n schema,\n actions,\n useDrag,\n copyModeModifierKey,\n groupModeModifierKey,\n hideDefaultDragPreview,\n });\n\n const [{ isOver, dropMonitorId, dropEffect, groupItems, dropNotAllowed }, drop] = useDrop<\n DraggedItem,\n DropResult,\n DropCollection\n >(\n () => ({\n accept,\n canDrop: dragging => {\n if (\n (isHotkeyPressed(groupModeModifierKey) && disabled) ||\n (dragging &&\n typeof canDrop === 'function' &&\n !canDrop({ dragging, hovering: { ...rule, path, qbId: schema.qbId } }))\n ) {\n return false;\n }\n\n if (schema.qbId !== dragging.qbId) return true;\n\n const parentHoverPath = getParentPath(path);\n const parentItemPath = getParentPath(dragging.path);\n const hoverIndex = path.at(-1);\n const itemIndex = dragging.path.at(-1)!;\n\n // Disallow drop if...\n // prettier-ignore\n return !(\n // 1) item is ancestor of drop target, OR\n isAncestor(dragging.path, path) ||\n // 2) item is hovered over itself, OR\n (pathsAreEqual(path, dragging.path)) ||\n // 3) item is hovered over the previous item AND this is a move, not a group\n (!isHotkeyPressed(groupModeModifierKey) && pathsAreEqual(parentHoverPath, parentItemPath) &&\n (hoverIndex === itemIndex - 1 ||\n (schema.independentCombinators && hoverIndex === itemIndex - 2)))\n );\n },\n collect: monitor => ({\n dropNotAllowed: monitor.isOver() && !monitor.canDrop(),\n isOver: monitor.canDrop() && monitor.isOver(),\n dropMonitorId: monitor.getHandlerId() ?? '',\n dropEffect: isHotkeyPressed(copyModeModifierKey) ? 'copy' : 'move',\n groupItems: isHotkeyPressed(groupModeModifierKey),\n }),\n drop: () => {\n const { qbId, getQuery, dispatchQuery } = schema;\n const dropEffect = isHotkeyPressed(copyModeModifierKey) ? 'copy' : 'move';\n const groupItems = isHotkeyPressed(groupModeModifierKey);\n\n return { type: 'rule', path, qbId, getQuery, dispatchQuery, groupItems, dropEffect };\n },\n }),\n [disabled, actions.moveRule, path, canDrop, rule, schema]\n );\n\n React.useEffect(() => {\n drag(dragRef);\n drop(dndRef);\n preview(hideDefaultDragPreview ? getEmptyImage() : dndRef);\n }, [drag, drop, hideDefaultDragPreview, preview]);\n\n return {\n isDragging,\n dragMonitorId,\n isOver,\n dropMonitorId,\n dndRef,\n dragRef,\n dropEffect,\n groupItems,\n dropNotAllowed,\n };\n};\n","import * as React from 'react';\nimport { useContext, useRef } from 'react';\nimport type { useDrag as useDragOriginal, useDrop as useDropOriginal } from 'react-dnd';\nimport type {\n DndDropTargetType,\n DraggedItem,\n DropCollection,\n DropResult,\n RuleGroupProps,\n UseRuleGroupDnD,\n} from 'react-querybuilder';\nimport { getParentPath, isAncestor, pathsAreEqual } from 'react-querybuilder';\nimport { getEmptyImage } from './getEmptyImage';\nimport { isHotkeyPressed } from './isHotkeyPressed';\nimport { QueryBuilderDndContext } from './QueryBuilderDndContext';\nimport type { QueryBuilderDndContextProps } from './types';\nimport { useDragCommon } from './useDragCommon';\n\n/**\n * Rule group component for drag-and-drop. Renders the provided rule group component\n * ({@link react-querybuilder!RuleGroup RuleGroup} by default), but forwards the drag-and-drop\n * context so that child rules and groups will render within the appropriate drag-and-drop wrappers.\n *\n * @group Components\n */\nexport const RuleGroupDnD = (props: RuleGroupProps): React.JSX.Element => {\n const rqbDndContext = useContext(QueryBuilderDndContext);\n\n const {\n canDrop,\n baseControls: { ruleGroup: BaseRuleGroupComponent },\n useDrag,\n useDrop,\n copyModeModifierKey,\n groupModeModifierKey,\n hideDefaultDragPreview,\n } = rqbDndContext;\n\n const dndRefs = useRuleGroupDnD({\n ...props,\n disabled: !!props.parentDisabled || !!props.disabled,\n useDrag: useDrag!,\n useDrop: useDrop!,\n canDrop,\n copyModeModifierKey,\n groupModeModifierKey,\n hideDefaultDragPreview,\n });\n\n return <BaseRuleGroupComponent {...props} {...dndRefs} />;\n};\n\ninterface UseRuleGroupDndParams\n extends\n RuleGroupProps,\n Omit<QueryBuilderDndContextProps, 'baseControls' | 'useDrag' | 'useDrop'> {\n useDrag: typeof useDragOriginal;\n useDrop: typeof useDropOriginal;\n}\n\nconst accept: [DndDropTargetType, DndDropTargetType] = ['rule', 'ruleGroup'];\n\n/**\n * @group Hooks\n */\nexport const useRuleGroupDnD = (params: UseRuleGroupDndParams): UseRuleGroupDnD => {\n const previewRef = useRef<HTMLDivElement>(null);\n const dragRef = useRef<HTMLSpanElement>(null);\n const dropRef = useRef<HTMLDivElement>(null);\n\n const {\n disabled,\n path,\n ruleGroup,\n schema,\n actions,\n useDrag,\n useDrop,\n canDrop,\n copyModeModifierKey = 'alt',\n groupModeModifierKey = 'ctrl',\n hideDefaultDragPreview,\n } = params;\n\n const [{ isDragging, dragMonitorId }, drag, preview] = useDragCommon({\n type: 'ruleGroup',\n path,\n disabled,\n independentCombinators: schema.independentCombinators,\n schema,\n actions,\n useDrag,\n copyModeModifierKey,\n groupModeModifierKey,\n hideDefaultDragPreview,\n });\n\n const [{ isOver, dropMonitorId, dropEffect, groupItems, dropNotAllowed }, drop] = useDrop<\n DraggedItem,\n DropResult,\n DropCollection\n >(\n () => ({\n accept,\n canDrop: dragging => {\n if (\n disabled ||\n (dragging &&\n typeof canDrop === 'function' &&\n !canDrop({ dragging, hovering: { ...ruleGroup, path, qbId: schema.qbId } }))\n ) {\n return false;\n }\n\n if (schema.qbId !== dragging.qbId) return true;\n\n const parentItemPath = getParentPath(dragging.path);\n const itemIndex = dragging.path.at(-1);\n // Disallow drop if...\n // prettier-ignore\n return !(\n // 1) item is ancestor of drop target, OR\n isAncestor(dragging.path, path) ||\n // 2) item is first child and is dropped on its own group header, OR\n (pathsAreEqual(path, parentItemPath) && itemIndex === 0) ||\n // 3) the group is dropped on itself\n pathsAreEqual(path, dragging.path)\n );\n },\n collect: monitor => ({\n dropNotAllowed: monitor.isOver() && !monitor.canDrop(),\n isOver: monitor.canDrop() && monitor.isOver(),\n dropMonitorId: monitor.getHandlerId() ?? '',\n dropEffect: isHotkeyPressed(copyModeModifierKey) ? 'copy' : 'move',\n groupItems: isHotkeyPressed(groupModeModifierKey),\n }),\n drop: () => {\n const { qbId, getQuery, dispatchQuery } = schema;\n const dropEffect = isHotkeyPressed(copyModeModifierKey) ? 'copy' : 'move';\n const groupItems = isHotkeyPressed(groupModeModifierKey);\n\n return { type: 'ruleGroup', path, qbId, getQuery, dispatchQuery, groupItems, dropEffect };\n },\n }),\n [disabled, actions.groupRule, actions.moveRule, path, canDrop, ruleGroup, schema]\n );\n\n React.useEffect(() => {\n if (path.length > 0) {\n drag(dragRef);\n preview(hideDefaultDragPreview ? getEmptyImage() : previewRef);\n }\n drop(dropRef);\n }, [drag, drop, hideDefaultDragPreview, path.length, preview]);\n\n return {\n isDragging,\n dragMonitorId,\n isOver,\n dropMonitorId,\n previewRef,\n dragRef,\n dropRef,\n dropEffect,\n groupItems,\n dropNotAllowed,\n };\n};\n","import * as React from 'react';\nimport { useContext, useEffect, useMemo, useState } from 'react';\nimport type { QueryBuilderContextProps } from 'react-querybuilder';\nimport {\n messages,\n preferAnyProp,\n preferProp,\n QueryBuilderContext,\n useMergedContext,\n} from 'react-querybuilder';\nimport { InlineCombinatorDnD } from './InlineCombinatorDnD';\nimport { isTouchDevice } from './isTouchDevice';\nimport { QueryBuilderDndContext } from './QueryBuilderDndContext';\nimport { RuleDnD } from './RuleDnD';\nimport { RuleGroupDnD } from './RuleGroupDnD';\nimport type {\n DndProp,\n QueryBuilderDndContextProps,\n QueryBuilderDndProps,\n UseReactDnD,\n} from './types';\n\nconst emptyObject = {} as UseReactDnD;\n\n/**\n * Context provider to enable drag-and-drop. If the application already implements\n * `react-dnd`, use {@link QueryBuilderDndWithoutProvider} instead.\n *\n * @group Components\n */\nexport const QueryBuilderDnD = (props: QueryBuilderDndProps): React.JSX.Element => {\n const {\n controlClassnames,\n controlElements,\n debugMode,\n enableDragAndDrop: enableDragAndDropProp,\n enableMountQueryChange,\n translations,\n } = props;\n\n const rqbContext = useMergedContext({\n controlClassnames,\n controlElements,\n debugMode,\n enableDragAndDrop: enableDragAndDropProp ?? true,\n enableMountQueryChange,\n translations: translations ?? {},\n });\n const { enableDragAndDrop } = rqbContext;\n\n const dnd = useReactDnD(props.dnd);\n const key = enableDragAndDrop && dnd ? 'dnd' : 'no-dnd';\n\n const { DndProvider, ReactDndBackend } = dnd ?? emptyObject;\n\n const contextWithoutDnD = useMemo(\n () => ({ ...rqbContext, enableDragAndDrop: false, debugMode }),\n [rqbContext, debugMode]\n );\n const contextWithDnD = useMemo(\n () => ({ ...rqbContext, enableDragAndDrop, debugMode }),\n [rqbContext, debugMode, enableDragAndDrop]\n );\n\n if (!enableDragAndDrop || !dnd || !DndProvider || !ReactDndBackend) {\n return (\n <QueryBuilderContext.Provider key={key} value={contextWithoutDnD}>\n {props.children}\n </QueryBuilderContext.Provider>\n );\n }\n\n return (\n <DndProvider key={key} backend={ReactDndBackend} debugMode={debugMode}>\n <QueryBuilderContext.Provider key={key} value={contextWithDnD}>\n <QueryBuilderDndWithoutProvider\n dnd={dnd}\n canDrop={props.canDrop}\n copyModeModifierKey={props.copyModeModifierKey}\n groupModeModifierKey={props.groupModeModifierKey}\n hideDefaultDragPreview={props.hideDefaultDragPreview}>\n {props.children}\n </QueryBuilderDndWithoutProvider>\n </QueryBuilderContext.Provider>\n </DndProvider>\n );\n};\n\n/**\n * Context provider to enable drag-and-drop. Only use this provider if the application\n * already implements `react-dnd`, otherwise use {@link QueryBuilderDnD}.\n *\n * @group Components\n */\nexport const QueryBuilderDndWithoutProvider = (props: QueryBuilderDndProps): React.JSX.Element => {\n const rqbContext = useContext(QueryBuilderContext);\n const rqbDndContext = useContext(QueryBuilderDndContext);\n const dnd = useReactDnD(props.dnd);\n const copyModeModifierKey = preferAnyProp(\n undefined,\n props.copyModeModifierKey,\n rqbDndContext.copyModeModifierKey\n );\n const groupModeModifierKey = preferAnyProp(\n undefined,\n props.groupModeModifierKey,\n rqbDndContext.groupModeModifierKey\n );\n const enableDragAndDrop = preferProp(true, props.enableDragAndDrop, rqbContext.enableDragAndDrop);\n const debugMode = preferProp(false, props.debugMode, rqbContext.debugMode);\n const hideDefaultDragPreview = preferProp(\n false,\n props.hideDefaultDragPreview,\n rqbDndContext.hideDefaultDragPreview\n );\n const canDrop = preferAnyProp(undefined, props.canDrop, rqbDndContext.canDrop);\n const key = enableDragAndDrop && dnd ? 'dnd' : 'no-dnd';\n\n const baseControls = useMemo(\n () => ({\n rule:\n props.controlElements?.rule ??\n rqbContext.controlElements?.rule ??\n rqbDndContext.baseControls.rule,\n ruleGroup:\n props.controlElements?.ruleGroup ??\n rqbContext.controlElements?.ruleGroup ??\n rqbDndContext.baseControls.ruleGroup,\n combinatorSelector:\n props.controlElements?.combinatorSelector ??\n rqbContext.controlElements?.combinatorSelector ??\n rqbDndContext.baseControls.combinatorSelector,\n }),\n [\n props.controlElements?.combinatorSelector,\n props.controlElements?.rule,\n props.controlElements?.ruleGroup,\n rqbContext.controlElements?.combinatorSelector,\n rqbContext.controlElements?.rule,\n rqbContext.controlElements?.ruleGroup,\n rqbDndContext.baseControls.combinatorSelector,\n rqbDndContext.baseControls.rule,\n rqbDndContext.baseControls.ruleGroup,\n ]\n );\n\n const newContext: QueryBuilderContextProps = useMemo(\n () => ({\n ...rqbContext,\n enableDragAndDrop,\n debugMode,\n controlElements: {\n ...rqbContext.controlElements,\n ruleGroup: RuleGroupDnD,\n rule: RuleDnD,\n inlineCombinator: InlineCombinatorDnD,\n },\n }),\n [debugMode, enableDragAndDrop, rqbContext]\n );\n\n const { DndContext, useDrag, useDrop } = dnd ?? {};\n\n const dndContextValue: QueryBuilderDndContextProps = useMemo(\n () => ({\n baseControls,\n canDrop,\n copyModeModifierKey,\n groupModeModifierKey,\n hideDefaultDragPreview,\n useDrag,\n useDrop,\n }),\n [\n baseControls,\n canDrop,\n copyModeModifierKey,\n groupModeModifierKey,\n hideDefaultDragPreview,\n useDrag,\n useDrop,\n ]\n );\n\n const contextWithoutDnD = useMemo(\n () => ({ ...rqbContext, enableDragAndDrop: false, debugMode }),\n [rqbContext, debugMode]\n );\n\n if (!enableDragAndDrop || !DndContext) {\n return (\n <QueryBuilderContext.Provider key={key} value={contextWithoutDnD}>\n {props.children}\n </QueryBuilderContext.Provider>\n );\n }\n\n return (\n <DndContext.Consumer key={key}>\n {() => (\n <QueryBuilderContext.Provider key={key} value={newContext}>\n <QueryBuilderDndContext.Provider value={dndContextValue}>\n {props.children}\n </QueryBuilderDndContext.Provider>\n </QueryBuilderContext.Provider>\n )}\n </DndContext.Consumer>\n );\n};\n\nlet didWarnEnabledDndWithoutReactDnD = false;\n\n/**\n * @group Hooks\n */\nexport const useReactDnD = (dndParam?: DndProp): UseReactDnD | null => {\n const [dnd, setDnd] = useState<DndProp | null>(dndParam ?? null);\n\n useEffect(() => {\n let didCancel = false;\n\n const getDnD = async () => {\n const [reactDnD, reactDndHTML5Be, reactDndTouchBe] = await Promise.all(\n ['', '-html5-backend', '-touch-backend'].map(pn =>\n import(/* @vite-ignore */ `react-dnd${pn}`).catch(() => null)\n )\n );\n\n // istanbul ignore else\n if (!didCancel) {\n if (reactDnD) {\n // istanbul ignore next\n // Only prefer HTML5 backend if not touch device or we don't have the touch backend\n // (Can't test this since jsdom unconditionally defines `window.ontouchstart`.)\n if (reactDndHTML5Be && (!reactDndTouchBe || (reactDndTouchBe && !isTouchDevice()))) {\n setDnd(() => ({\n ...reactDnD,\n ...reactDndHTML5Be,\n ...reactDndTouchBe,\n ReactDndBackend: reactDndHTML5Be.HTML5Backend,\n }));\n } else if (reactDndTouchBe) {\n setDnd(() => ({\n ...reactDnD,\n ...reactDndTouchBe,\n ...reactDndHTML5Be,\n ReactDndBackend: reactDndTouchBe.TouchBackend,\n }));\n }\n } else {\n // istanbul ignore else\n if (process.env.NODE_ENV !== 'production' && !didWarnEnabledDndWithoutReactDnD) {\n console.error(messages.errorEnabledDndWithoutReactDnD);\n didWarnEnabledDndWithoutReactDnD = true;\n }\n }\n }\n };\n\n if (!dnd) {\n getDnD();\n }\n\n return () => {\n didCancel = true;\n };\n }, [dnd]);\n\n // istanbul ignore next\n if (dnd && !dnd.ReactDndBackend) {\n // Prefer touch backend if this is a touch device\n dnd.ReactDndBackend = isTouchDevice()\n ? (dnd.TouchBackend ?? dnd.HTML5Backend)\n : (dnd.HTML5Backend ?? dnd.TouchBackend);\n }\n\n return dnd as UseReactDnD;\n};\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,2BAA2B,IAAI,IAAiB;CAAC;CAAS;CAAO;CAAQ;CAAO;CAAO,CAAC;AAE9F,MAAMA,aAAqC;CACzC,KAAK;CACL,QAAQ;CACR,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;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