UNPKG

@react-querybuilder/dnd

Version:

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

1 lines 44.2 kB
{"version":3,"file":"react-querybuilder_dnd.production.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":"gbAcA,MAAM,EAA2B,IAAI,IAAiB,CAAC,QAAS,MAAO,OAAQ,MAAO,OAAO,CAAC,CAExFA,EAAqC,CACzC,IAAK,SACL,OAAQ,QACR,IAAK,SACL,IAAK,QACL,IAAK,QACL,IAAK,QACL,IAAK,YACL,IAAK,YACL,IAAK,eACL,UAAW,Q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