@vue-dnd-kit/core 2.4.7 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -48
  3. package/dist/devtools.cjs +2 -0
  4. package/dist/devtools.cjs.map +1 -0
  5. package/dist/devtools.d.cts +610 -0
  6. package/dist/devtools.d.ts +610 -0
  7. package/dist/devtools.js +569 -0
  8. package/dist/devtools.js.map +1 -0
  9. package/dist/index.cjs +12 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.cts +2425 -0
  12. package/dist/index.d.ts +2425 -2
  13. package/dist/index.js +5865 -0
  14. package/dist/index.js.map +1 -0
  15. package/package.json +59 -29
  16. package/dist/external/components/DnDProvider.vue.d.ts +0 -25
  17. package/dist/external/components/DragPreview.vue.d.ts +0 -89
  18. package/dist/external/composables/makeAutoScroll.d.ts +0 -14
  19. package/dist/external/composables/makeConstraintArea.d.ts +0 -7
  20. package/dist/external/composables/makeDraggable.d.ts +0 -24
  21. package/dist/external/composables/makeDroppable.d.ts +0 -21
  22. package/dist/external/composables/makeSelectionArea.d.ts +0 -15
  23. package/dist/external/composables/useDnDProvider.d.ts +0 -2
  24. package/dist/external/env.d.ts +0 -7
  25. package/dist/external/index.d.ts +0 -11
  26. package/dist/external/types/entities.d.ts +0 -208
  27. package/dist/external/types/index.d.ts +0 -5
  28. package/dist/external/types/operations.d.ts +0 -187
  29. package/dist/external/types/placement.d.ts +0 -34
  30. package/dist/external/types/pointer.d.ts +0 -10
  31. package/dist/external/types/provider.d.ts +0 -89
  32. package/dist/internal/composables/useDnDProviderEvents.d.ts +0 -2
  33. package/dist/internal/composables/useDnDProviderInternal.d.ts +0 -2
  34. package/dist/internal/composables/useDnDProviderState.d.ts +0 -4
  35. package/dist/internal/composables/useViewportAutoScroll.d.ts +0 -9
  36. package/dist/internal/logic/hover.d.ts +0 -6
  37. package/dist/internal/logic/keyboard.d.ts +0 -6
  38. package/dist/internal/logic/operations.d.ts +0 -35
  39. package/dist/internal/logic/payload.d.ts +0 -5
  40. package/dist/internal/logic/pointer.d.ts +0 -11
  41. package/dist/internal/logic/scroll.d.ts +0 -2
  42. package/dist/internal/sensors/default-collision.d.ts +0 -18
  43. package/dist/internal/sensors/index.d.ts +0 -2
  44. package/dist/internal/sensors/sensor.d.ts +0 -68
  45. package/dist/internal/sensors/steps.d.ts +0 -58
  46. package/dist/internal/types/auto-scroll.d.ts +0 -20
  47. package/dist/internal/types/observer.d.ts +0 -11
  48. package/dist/internal/types/provider.d.ts +0 -31
  49. package/dist/internal/utils/auto-scroll.d.ts +0 -13
  50. package/dist/internal/utils/constraints.d.ts +0 -43
  51. package/dist/internal/utils/disabled.d.ts +0 -9
  52. package/dist/internal/utils/dom.d.ts +0 -44
  53. package/dist/internal/utils/drag-activation.d.ts +0 -29
  54. package/dist/internal/utils/events.d.ts +0 -22
  55. package/dist/internal/utils/geometry.d.ts +0 -23
  56. package/dist/internal/utils/groups.d.ts +0 -23
  57. package/dist/internal/utils/hover.d.ts +0 -15
  58. package/dist/internal/utils/keyboard.d.ts +0 -5
  59. package/dist/internal/utils/namespaces.d.ts +0 -18
  60. package/dist/internal/utils/observer.d.ts +0 -15
  61. package/dist/internal/utils/placement.d.ts +0 -22
  62. package/dist/internal/utils/pointer.d.ts +0 -33
  63. package/dist/internal/utils/provider.d.ts +0 -12
  64. package/dist/internal/utils/selection.d.ts +0 -36
  65. package/dist/internal/utils/session.d.ts +0 -5
  66. package/dist/vite.svg +0 -1
  67. package/dist/vue-dnd-kit-core.cjs.js +0 -2
  68. package/dist/vue-dnd-kit-core.es.js +0 -1524
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/utils/dom.ts","../src/animation/layout.ts","../src/core/measure.ts","../src/core/manager/state.ts","../src/core/manager/registry.ts","../src/core/a11y.ts","../src/core/manager/events.ts","../src/core/snapshot.ts","../src/core/clone.ts","../src/core/manager/overlay.ts","../src/core/collision.ts","../src/core/manager/detection.ts","../src/core/haptics.ts","../src/core/manager/frame.ts","../src/animation/drop.ts","../src/core/styles.ts","../src/core/verdict.ts","../src/core/manager/follow.ts","../src/core/manager/session.ts","../src/core/manager/index.ts","../src/core/deciding.ts","../src/core/context.ts","../src/core/devtoolsHook.ts","../src/core/sensors/activation.ts","../src/core/sensors/leave.ts","../src/core/autoscroll/math.ts","../src/core/autoscroll/dom.ts","../src/core/autoscroll/loop.ts","../src/core/sensors/steps.ts","../src/core/sensors/drag.ts","../src/core/sensors/host.ts","../src/core/native/data.ts","../src/core/native/bridge.ts","../src/core/sensors/pointer.ts","../src/core/sensors/keyboard.ts","../src/core/modifiers.ts","../src/core/overlayScope.ts","../src/core/DragPreview.ts","../src/core/DragOverlay.ts","../src/core/DnDProvider.ts","../src/core/accept.ts","../src/utils/read.ts","../src/core/makeDraggable.ts","../src/core/makeDroppable.ts","../src/sortable/draft.ts","../src/sortable/context.ts","../src/sortable/accept.ts","../src/sortable/multiple.ts","../src/sortable/block.ts","../src/sortable/column.ts","../src/sortable/projection.ts","../src/sortable/tree/projection.ts","../src/sortable/combine.ts","../src/sortable/announcements.ts","../src/sortable/stability.ts","../src/sortable/landing.ts","../src/sortable/resize.ts","../src/sortable/flip.ts","../src/sortable/slot.ts","../src/sortable/indicator.ts","../src/animation/presence.ts","../src/sortable/autoAnimate.ts","../src/sortable/modifier.ts","../src/sortable/modes/mode.ts","../src/sortable/modes/swap.ts","../src/sortable/modes/sort.ts","../src/sortable/keyboard.ts","../src/sortable/modes/copy.ts","../src/sortable/modes/insert.ts","../src/sortable/session.ts","../src/sortable/drop.ts","../src/sortable/place.ts","../src/sortable/group.ts","../src/sortable/layout.ts","../src/sortable/makeSortableList.ts","../src/sortable/makeSortableItem.ts","../src/sortable/tree/flatten.ts","../src/sortable/tree/depth.ts","../src/sortable/tree/context.ts","../src/sortable/tree/move.ts","../src/sortable/tree/drop.ts","../src/sortable/tree/layout.ts","../src/sortable/tree/keyboard.ts","../src/sortable/makeSortableTree.ts","../src/core/makeSelectionArea.ts","../src/core/makeDragArea.ts"],"sourcesContent":["import { getCurrentInstance, toValue, useId, type ComponentPublicInstance, type VNode } from 'vue';\r\nimport { unrefElement } from '@vueuse/core';\r\nimport type { MaybeElementRef } from '../types';\r\n\r\nlet uid = 0;\r\n\r\n/**\r\n * Default id of a composable. In a component: `useId()`, the same on the server and\r\n * the client, unique per app (`app.config.idPrefix` tells apps sharing a provider\r\n * apart). Without a component instance (a detached `effectScope`): a module counter.\r\n */\r\nexport const createId = (prefix: string): string =>\r\n `${prefix}-${getCurrentInstance() ? useId() : ++uid}`;\r\n\r\nexport const isClient = typeof window !== 'undefined';\r\n\r\nconst ELEMENT_NODE = 1;\r\n\r\n/**\r\n * End anchor of a component's fragment (or teleport) root, through components that\r\n * render another component (`<UTooltip>` → `<TooltipRoot>` → fragment). `null` for a\r\n * root without a range (a comment or a text); `undefined` when `value` isn't a component.\r\n */\r\nconst fragmentEnd = (value: unknown): Node | null | undefined => {\r\n const instance = (value as Partial<ComponentPublicInstance> | null)?.$;\r\n if (!instance) return undefined;\r\n let tree: VNode | undefined = instance.subTree;\r\n while (tree?.component) tree = tree.component.subTree;\r\n return (tree?.anchor as Node | null | undefined) ?? null;\r\n};\r\n\r\n/**\r\n * Resolves an element, component ref or getter to a DOM element. A component with\r\n * several root nodes (a fragment, common in UI kits: tooltips and menus render their\r\n * activator next to a teleport) exposes the fragment's start anchor, a text node, as\r\n * `$el`: its first element is used instead. Nothing past the fragment's end counts:\r\n * a fragment with no element in place (only teleported content) resolves to `null`,\r\n * never to the element that follows the component.\r\n */\r\nexport const toElement = (target: MaybeElementRef): HTMLElement | null => {\r\n const node = unrefElement(target as Parameters<typeof unrefElement>[0]) as Node | null | undefined;\r\n if (!node) return null;\r\n if (node.nodeType === ELEMENT_NODE) return node as HTMLElement;\r\n const end = fragmentEnd(toValue(target));\r\n // A component that rendered a comment (`v-if`) or a text has no element.\r\n if (end === null) return null;\r\n for (let next = node.nextSibling; next && next !== end; next = next.nextSibling) {\r\n if (next.nodeType === ELEMENT_NODE) return next as HTMLElement;\r\n }\r\n return null;\r\n};\r\n\r\n/**\r\n * Parent in the flat tree: slotted elements go to their slot, shadow roots to their\r\n * host. This is the tree that lays out, clips and scrolls an element, and the one\r\n * hit-testing walks.\r\n */\r\nexport const parentOf = (element: Element): Element | null =>\r\n element.assignedSlot ??\r\n element.parentElement ??\r\n ((element.getRootNode() as ShadowRoot).host as Element | undefined) ??\r\n null;\r\n\r\n/** `ancestor.contains(node)` across shadow roots and slots. */\r\nexport const containsComposed = (ancestor: Element, node: Element): boolean => {\r\n if (ancestor.contains(node)) return true;\r\n // In the same tree, a flat-tree ancestor is always a DOM ancestor too.\r\n if (ancestor.getRootNode() === node.getRootNode()) return false;\r\n for (let element = parentOf(node); element; element = parentOf(element)) {\r\n if (element === ancestor) return true;\r\n }\r\n return false;\r\n};\r\n\r\n/** Real event target, not retargeted to a shadow host (open shadow roots). */\r\nexport const getEventTarget = (event: Event): EventTarget | null =>\r\n event.composedPath?.()[0] ?? event.target;\r\n\r\n/** Topmost element at a point, descending into open shadow roots. */\r\nexport const elementFromPoint = (x: number, y: number): Element | null => {\r\n let element = document.elementFromPoint(x, y);\r\n while (element?.shadowRoot) {\r\n const inner = element.shadowRoot.elementFromPoint(x, y);\r\n if (!inner || inner === element) break;\r\n element = inner;\r\n }\r\n return element;\r\n};\r\n\r\n/**\r\n * Topmost element at a point outside `skip`: what is under an element that sits on the\r\n * point itself (a draggable moved without an overlay). Its parent when nothing else is.\r\n */\r\nexport const elementBelow = (x: number, y: number, skip: Element): Element | null => {\r\n const stack = document.elementsFromPoint?.(x, y) ?? [];\r\n const below = stack.find((element) => !containsComposed(skip, element)) ?? parentOf(skip);\r\n if (!below?.shadowRoot) return below;\r\n const inner = elementFromPoint(x, y);\r\n return inner && !containsComposed(skip, inner) ? inner : below;\r\n};\r\n\r\nconst EDITABLE = 'input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])';\r\nconst INTERACTIVE = `${EDITABLE}, option, button`;\r\nconst FOCUSABLE = `${EDITABLE}, a[href], button`;\r\n\r\n/** True when `target` sits inside an interactive element nested in `container`. */\r\nexport const isInsideInteractive = (\r\n target: Element,\r\n container: Element,\r\n): boolean => {\r\n const interactive = target.closest(INTERACTIVE);\r\n return (\r\n !!interactive && interactive !== container && container.contains(interactive)\r\n );\r\n};\r\n\r\nexport const isEditable = (element: Element): boolean => element.matches(EDITABLE);\r\n\r\nexport const isNativelyFocusable = (element: Element): boolean =>\r\n element.matches(FOCUSABLE);\r\n\r\n/**\r\n * True when nothing has the focus any more: the focused element left the document\r\n * (re-rendered or unmounted), and the browser moved the focus back to <body>.\r\n */\r\nexport const isFocusLost = (): boolean => {\r\n const focused = document.activeElement;\r\n return (\r\n !focused ||\r\n focused === document.body ||\r\n focused === document.documentElement ||\r\n !focused.isConnected\r\n );\r\n};\r\n\r\n/** Frames stop in hidden tabs and can stall on a busy compositor: wait at most this long. */\r\nconst FRAME_TIMEOUT = 100;\r\n\r\n/** Resolves on the next animation frame, or after `FRAME_TIMEOUT` ms when frames stall. */\r\nexport const nextFrame = (): Promise<void> =>\r\n new Promise((resolve) => {\r\n const done = () => {\r\n cancelAnimationFrame(frame);\r\n clearTimeout(timer);\r\n resolve();\r\n };\r\n const frame = requestAnimationFrame(done);\r\n const timer = setTimeout(done, FRAME_TIMEOUT);\r\n });\r\n","/**\r\n * Geometry and the FLIP engine shared by every layer.\r\n * Layout animations run on the CSS `translate` property, so they compose with\r\n * `transform` set by the user or by virtualizers.\r\n */\r\n\r\nimport type {\r\n AnimationOptions,\r\n Coordinates,\r\n Key,\r\n LayoutAnimation,\r\n LayoutAnimationContext,\r\n Rect,\r\n Size,\r\n} from '../types';\r\nimport { parentOf } from '../utils/dom';\r\n\r\ninterface LayoutAnimationState {\r\n /** Ends it early: cancels the animation, aborts a custom function's signal. */\r\n stop(): void;\r\n running(): boolean;\r\n /** Layout rect the animation ends at. */\r\n to: Rect;\r\n /** From a user function: it may animate more than `translate`. */\r\n custom: boolean;\r\n /** Slides in from another list: it ignores the pointer meanwhile (see `FlipEntry.crossing`). */\r\n crossing?: boolean;\r\n}\r\n\r\nconst layoutAnimations = new WeakMap<Element, LayoutAnimationState>();\r\n\r\nconst isRunning = (animation: Animation) =>\r\n animation.playState !== 'finished' && animation.playState !== 'idle';\r\n\r\n/** What a custom animation function returned is a WAAPI `Animation` (or acts like one). */\r\nconst isAnimation = (value: unknown): value is Animation =>\r\n !!value &&\r\n typeof (value as Animation).cancel === 'function' &&\r\n typeof (value as Animation).addEventListener === 'function';\r\n\r\nconst noop = () => {};\r\n\r\n/**\r\n * Settles when what an animation function returned has ended: an `Animation` finished\r\n * or cancelled, a promise (or a thenable, e.g. a GSAP tween) settled, anything with a\r\n * `finished` promise (motion's controls) done; at once for anything else. Never rejects.\r\n */\r\nconst ended = (result: unknown): Promise<void> => {\r\n const finished = (result as { finished?: unknown } | null | undefined)?.finished;\r\n const done = finished && typeof (finished as PromiseLike<unknown>).then === 'function' ? finished : result;\r\n return Promise.resolve(done).then(noop, noop);\r\n};\r\n\r\n/** Margin over an animation's duration after which it counts as ended anyway. */\r\nexport const STALL_MARGIN = 1000;\r\n\r\n/**\r\n * Waits for an animation (see `ended`), but never longer than `timeout`: one that never\r\n * settles (a stalled compositor, a custom function that never resolves) must not hold\r\n * up what waits for it, such as a drop (rfcs/0001-v3.md §13).\r\n */\r\nexport const settle = async (result: unknown, timeout: number): Promise<void> => {\r\n let timer: ReturnType<typeof setTimeout> | undefined;\r\n try {\r\n await Promise.race([ended(result), new Promise((resolve) => (timer = setTimeout(resolve, timeout)))]);\r\n } finally {\r\n clearTimeout(timer);\r\n }\r\n};\r\n\r\nexport const DEFAULT_LAYOUT_ANIMATION: Required<AnimationOptions> = {\r\n duration: 200,\r\n easing: 'cubic-bezier(0.25, 1, 0.5, 1)',\r\n};\r\n\r\nexport const createRect = (\r\n left: number,\r\n top: number,\r\n width: number,\r\n height: number,\r\n): Rect => ({ left, top, width, height, right: left + width, bottom: top + height });\r\n\r\nexport const toRect = (rect: DOMRectReadOnly | Rect): Rect =>\r\n createRect(rect.left, rect.top, rect.width, rect.height);\r\n\r\nexport const getRect = (element: Element): Rect =>\r\n toRect(element.getBoundingClientRect());\r\n\r\nexport const offsetRect = (rect: Rect, x: number, y: number): Rect =>\r\n createRect(rect.left + x, rect.top + y, rect.width, rect.height);\r\n\r\n/** Overlap of two rects; `null` when they don't overlap. */\r\nexport const intersectRect = (a: Rect, b: Rect): Rect | null => {\r\n const left = Math.max(a.left, b.left);\r\n const top = Math.max(a.top, b.top);\r\n const right = Math.min(a.right, b.right);\r\n const bottom = Math.min(a.bottom, b.bottom);\r\n return right > left && bottom > top ? createRect(left, top, right - left, bottom - top) : null;\r\n};\r\n\r\n/** Overlap test: touching edges don't count, a zero-width rect crossing the other does. */\r\nexport const intersects = (a: Rect, b: Rect): boolean =>\r\n a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;\r\n\r\n/** Smallest rect containing both. */\r\nexport const unionRect = (a: Rect, b: Rect): Rect => {\r\n const left = Math.min(a.left, b.left);\r\n const top = Math.min(a.top, b.top);\r\n return createRect(left, top, Math.max(a.right, b.right) - left, Math.max(a.bottom, b.bottom) - top);\r\n};\r\n\r\n/** `rect` grown by `x` and `y` on each side. */\r\nexport const expandRect = (rect: Rect, x: number, y: number): Rect =>\r\n createRect(rect.left - x, rect.top - y, rect.width + 2 * x, rect.height + 2 * y);\r\n\r\nexport const containsPoint = (rect: Rect, point: Coordinates): boolean =>\r\n point.x >= rect.left &&\r\n point.x <= rect.right &&\r\n point.y >= rect.top &&\r\n point.y <= rect.bottom;\r\n\r\nexport const getCenter = (rect: Rect): Coordinates => ({\r\n x: rect.left + rect.width / 2,\r\n y: rect.top + rect.height / 2,\r\n});\r\n\r\nexport const distance = (a: Coordinates, b: Coordinates): number => Math.hypot(a.x - b.x, a.y - b.y);\r\n\r\nexport const getWindowRect = (): Rect =>\r\n createRect(0, 0, window.innerWidth, window.innerHeight);\r\n\r\n/** Where `point` lies in `rect`, as fractions of its size: 0 at the left/top edge, 1 at the right/bottom. */\r\nexport const getFraction = (rect: Rect, point: Coordinates): Coordinates => ({\r\n x: rect.width ? (point.x - rect.left) / rect.width : 0,\r\n y: rect.height ? (point.y - rect.top) / rect.height : 0,\r\n});\r\n\r\n/** `rect` resized to `size` around the point at `fraction` of it: that point keeps its fraction. */\r\nexport const resizeAround = (rect: Rect, size: Size, fraction: Coordinates): Rect =>\r\n createRect(\r\n rect.left + (rect.width - size.width) * fraction.x,\r\n rect.top + (rect.height - size.height) * fraction.y,\r\n size.width,\r\n size.height,\r\n );\r\n\r\nconst parseTranslate = (value: string): Coordinates => {\r\n if (!value || value === 'none') return { x: 0, y: 0 };\r\n const [x = '0', y = '0'] = value.split(' ');\r\n return { x: parseFloat(x) || 0, y: parseFloat(y) || 0 };\r\n};\r\n\r\n/** Rect of the element without its in-flight layout animation. */\r\nexport const getLayoutRect = (element: Element): Rect => {\r\n const rect = getRect(element);\r\n const state = layoutAnimations.get(element);\r\n if (!state?.running()) return rect;\r\n const { x, y } = parseTranslate(getComputedStyle(element).translate);\r\n return offsetRect(rect, -x, -y);\r\n};\r\n\r\n/** A layout animation moving an element now (`layoutShifts`), and how far it has it moved. */\r\nexport interface LayoutShift {\r\n /** Which animation: a new one is a new object. */\r\n animation: object;\r\n offset: Coordinates;\r\n}\r\n\r\n/**\r\n * The layout animations in flight that move the element: its own and its ancestors' (flat\r\n * tree), each with its current `translate`. Walks every ancestor.\r\n */\r\nexport const layoutShifts = (element: Element): LayoutShift[] => {\r\n const shifts: LayoutShift[] = [];\r\n for (let node: Element | null = element; node; node = parentOf(node)) {\r\n const animation = layoutAnimations.get(node);\r\n if (animation?.running()) shifts.push({ animation, offset: parseTranslate(getComputedStyle(node).translate) });\r\n }\r\n return shifts;\r\n};\r\n\r\n/**\r\n * Where the element will be once the layout animations in flight have ended: its own and\r\n * its ancestors' (flat tree). An item of a list nested in another list's item (a field in\r\n * a form section, a card in a kanban column) slides along with that item after a drop.\r\n * Walks every ancestor: for landings, not for per-frame measuring.\r\n */\r\nexport const getSettledRect = (element: Element): Rect => {\r\n let x = 0;\r\n let y = 0;\r\n for (const { offset } of layoutShifts(element)) {\r\n x += offset.x;\r\n y += offset.y;\r\n }\r\n return offsetRect(getRect(element), -x, -y);\r\n};\r\n\r\nexport const prefersReducedMotion = (): boolean =>\r\n typeof matchMedia !== 'undefined' &&\r\n matchMedia('(prefers-reduced-motion: reduce)').matches;\r\n\r\nexport const canAnimate = (element: Element): boolean =>\r\n typeof (element as HTMLElement).animate === 'function';\r\n\r\n/** Resolves `true | false | options | fn` into options + optional custom function. */\r\nexport const resolveAnimation = <TFn extends (...args: never[]) => unknown>(\r\n option: boolean | AnimationOptions | TFn | undefined,\r\n defaults: Required<AnimationOptions>,\r\n): { options: Required<AnimationOptions>; custom: TFn | null } | null => {\r\n if (option === false) return null;\r\n if (typeof option === 'function') return { options: defaults, custom: option };\r\n const options = { ...defaults, ...(option === true ? {} : option) };\r\n if (options.duration <= 0 || prefersReducedMotion()) return null;\r\n return { options, custom: null };\r\n};\r\n\r\n/**\r\n * Cancels CSS transitions on `transform`/`translate` of `elements`: they would\r\n * distort the measurement. `Element.getAnimations()` scans every animation of the\r\n * document, so one call per element is quadratic while many FLIP animations run;\r\n * one `getAnimations()` per document or shadow root is linear.\r\n */\r\nconst cancelTransformTransitions = (elements: Element[]) => {\r\n if (typeof CSSTransition === 'undefined' || !elements.length) return;\r\n const targets = new Set<Element | null>(elements);\r\n const roots = new Set<Document | ShadowRoot>();\r\n for (const element of elements) {\r\n const root = element.getRootNode() as Partial<Document | ShadowRoot>;\r\n if (typeof root.getAnimations === 'function') roots.add(root as Document | ShadowRoot);\r\n }\r\n for (const root of roots) {\r\n for (const animation of root.getAnimations()) {\r\n if (\r\n animation instanceof CSSTransition &&\r\n (animation.transitionProperty === 'transform' ||\r\n animation.transitionProperty === 'translate') &&\r\n targets.has((animation.effect as KeyframeEffect | null)?.target ?? null)\r\n ) {\r\n animation.cancel();\r\n }\r\n }\r\n }\r\n};\r\n\r\nconst release = (element: HTMLElement, state: LayoutAnimationState) => {\r\n if (layoutAnimations.get(element) !== state) return;\r\n layoutAnimations.delete(element);\r\n if (state.crossing) element.style.pointerEvents = '';\r\n};\r\n\r\nexport const stopLayoutAnimation = (element: Element): void => {\r\n const state = layoutAnimations.get(element);\r\n if (!state) return;\r\n release(element as HTMLElement, state);\r\n state.stop();\r\n};\r\n\r\nconst track = (element: HTMLElement, state: LayoutAnimationState) => {\r\n layoutAnimations.set(element, state);\r\n if (state.crossing) element.style.pointerEvents = 'none';\r\n};\r\n\r\n/** Keeps a WAAPI animation of `element` (ours, or a custom function's) until it ends. */\r\nconst trackAnimation = (\r\n element: HTMLElement,\r\n animation: Animation,\r\n state: Omit<LayoutAnimationState, 'stop' | 'running'>,\r\n abort?: AbortController,\r\n) => {\r\n const tracked: LayoutAnimationState = {\r\n ...state,\r\n stop: () => {\r\n animation.cancel();\r\n abort?.abort();\r\n },\r\n running: () => isRunning(animation),\r\n };\r\n track(element, tracked);\r\n animation.addEventListener('finish', () => release(element, tracked));\r\n animation.addEventListener('cancel', () => release(element, tracked));\r\n};\r\n\r\n/**\r\n * Keeps what a custom function returned until it ends (see `ended`): an `Animation`, or\r\n * a promise whose animation only the function's `signal` can stop.\r\n */\r\nconst trackCustom = (\r\n element: HTMLElement,\r\n result: unknown,\r\n abort: AbortController,\r\n state: Omit<LayoutAnimationState, 'stop' | 'running' | 'custom'>,\r\n) => {\r\n if (isAnimation(result)) return trackAnimation(element, result, { ...state, custom: true }, abort);\r\n if (!result || typeof result !== 'object') return;\r\n let settled = false;\r\n const tracked: LayoutAnimationState = {\r\n ...state,\r\n custom: true,\r\n stop: () => abort.abort(),\r\n running: () => !settled,\r\n };\r\n track(element, tracked);\r\n void ended(result).then(() => {\r\n settled = true;\r\n release(element, tracked);\r\n });\r\n};\r\n\r\nconst sameRect = (a: Rect, b: Rect) =>\r\n Math.abs(a.left - b.left) < 0.5 && Math.abs(a.top - b.top) < 0.5;\r\n\r\nexport interface FlipEntry {\r\n key: Key;\r\n element: HTMLElement;\r\n /** Visual rect captured before the change (including any running animation). */\r\n first: Rect;\r\n /**\r\n * Slides in from another list (a swap partner, an item a list didn't take): it ignores\r\n * the pointer until it lands, or hit tests over the lists it crosses would find it.\r\n */\r\n crossing?: boolean;\r\n}\r\n\r\n/** Entries animated with one option: the items of one list. */\r\nexport interface FlipBatch {\r\n entries: FlipEntry[];\r\n option: LayoutAnimation | undefined;\r\n /** Timing for `true` and for custom functions. Default `DEFAULT_LAYOUT_ANIMATION`. */\r\n defaults?: Required<AnimationOptions>;\r\n}\r\n\r\n/**\r\n * Animates elements from their captured rects to their current layout, a batch per list.\r\n * Every layout read happens in one pass before any animation starts. An animation still\r\n * heading to the same layout rect keeps running; one whose target moved restarts from\r\n * where the element visually was. A custom function's animation restarts every time:\r\n * its offset in flight can't be told apart from the layout.\r\n */\r\nexport const flip = (batches: FlipBatch[], reason: LayoutAnimationContext['reason'] = 'drag'): void => {\r\n // Writes first: whatever the measurement can't see through.\r\n cancelTransformTransitions(batches.flatMap(({ entries }) => entries.map((entry) => entry.element)));\r\n const runs = batches.map(({ entries, option, defaults }) => {\r\n const resolved = resolveAnimation(option, defaults ?? DEFAULT_LAYOUT_ANIMATION);\r\n for (const { element } of entries) {\r\n if (!resolved || layoutAnimations.get(element)?.custom) stopLayoutAnimation(element);\r\n }\r\n return resolved && { resolved, entries };\r\n });\r\n const measured = runs.map((run) => run?.entries.map((entry) => getLayoutRect(entry.element)));\r\n const reducedMotion = prefersReducedMotion();\r\n\r\n runs.forEach((run, index) => {\r\n if (!run) return;\r\n const { resolved, entries } = run;\r\n entries.forEach(({ key, element, first, crossing }, at) => {\r\n const last = measured[index]![at]!;\r\n const running = layoutAnimations.get(element);\r\n if (running?.running() && sameRect(running.to, last)) return;\r\n // Interrupted on its way in from another list, it keeps ignoring the pointer.\r\n const passing = !!crossing || (!!running?.crossing && running.running());\r\n stopLayoutAnimation(element);\r\n const dx = first.left - last.left;\r\n const dy = first.top - last.top;\r\n if (Math.abs(dx) < 0.5 && Math.abs(dy) < 0.5) return;\r\n if (resolved.custom) {\r\n const abort = new AbortController();\r\n const { options } = resolved;\r\n const result = resolved.custom({\r\n key,\r\n element,\r\n from: first,\r\n to: last,\r\n options,\r\n reason,\r\n signal: abort.signal,\r\n reducedMotion,\r\n });\r\n trackCustom(element, result, abort, { to: last, crossing: passing });\r\n return;\r\n }\r\n if (!canAnimate(element)) return;\r\n const animation = element.animate([{ translate: `${dx}px ${dy}px` }, { translate: '0px 0px' }], resolved.options);\r\n trackAnimation(element, animation, { to: last, custom: false, crossing: passing });\r\n });\r\n });\r\n};\r\n\r\n/** Fade for elements that appear because of a drag change (returned multi-drag items, copies). */\r\nexport const fadeIn = (element: HTMLElement, option: LayoutAnimation | undefined): void => {\r\n const resolved = resolveAnimation(option, DEFAULT_LAYOUT_ANIMATION);\r\n if (!resolved || resolved.custom || !canAnimate(element)) return;\r\n element.animate([{ opacity: 0 }, { opacity: 1 }], resolved.options);\r\n};\r\n","/**\r\n * Measuring service (rfcs/0001-v3.md §3, §6, §12; research: dnd-kit.md §9,\r\n * virtualization.md §4–§5).\r\n *\r\n * - Rects are layout rects: an in-flight FLIP `translate` is excluded.\r\n * - During a drag session a rect is cached per element together with the scroll\r\n * offsets of its scroll containers. Reads add the scroll delta lazily, so\r\n * scrolling never re-measures (dnd-kit classic `Rect`).\r\n * - Visible rects are clipped by every clipping ancestor and the viewport. A fully\r\n * clipped element (a virtualizer's overscan row) has none and can't be hit.\r\n * - Scroll offsets and clip rects are read once per frame (`nextFrame()`), and\r\n * nothing here writes to the DOM, so a frame reads layout in one pass.\r\n */\r\n\r\nimport type { Coordinates, Rect } from '../types';\r\nimport {\r\n createRect,\r\n expandRect,\r\n getLayoutRect,\r\n intersectRect,\r\n offsetRect,\r\n} from '../animation/layout';\r\nimport { parentOf } from '../utils/dom';\r\n\r\n/** FLIP runs within this many sizes of a scroll container's visible area around it. */\r\nexport const NEAR_VIEWPORT = 1;\r\n\r\ninterface Flags {\r\n clipX: boolean;\r\n clipY: boolean;\r\n fixed: boolean;\r\n sticky: boolean;\r\n}\r\n\r\n/** What moves and clips an element. */\r\ninterface Chain {\r\n /** Clipping (and possibly scrolling) ancestors, nearest first. */\r\n scrollers: readonly Element[];\r\n /** The window scroll moves the element (no fixed ancestor). */\r\n window: boolean;\r\n /** Sticky positioning in the chain: a scroll delta can't predict the rect. */\r\n volatile: boolean;\r\n}\r\n\r\ninterface Entry {\r\n rect: Rect;\r\n chain: Chain;\r\n /** Scroll offsets at measure time: x and y of each scroller, then of the window. */\r\n offsets: number[];\r\n frame: number;\r\n /** Invalidation generation at measure time: older entries are stale. */\r\n generation: number;\r\n /** Padding box relative to the border box, read when the element clips others. */\r\n client?: Rect;\r\n}\r\n\r\nconst ROOT: Chain = { scrollers: [], window: true, volatile: false };\r\nconst FIXED: Chain = { scrollers: [], window: false, volatile: false };\r\n\r\n// DOM emulations (happy-dom, jsdom) report unset longhands as ''.\r\nconst clipsOverflow = (value: string) => value !== 'visible' && value !== '';\r\n\r\nexport interface Measurer {\r\n /** Starts caching for a drag session. */\r\n begin(): void;\r\n /** Drops the cache and the session listeners. */\r\n end(): void;\r\n /** Scroll offsets and clip rects are re-read at most once per frame. */\r\n nextFrame(): void;\r\n /** Layout rect in viewport coordinates, without in-flight FLIP translates. */\r\n measure(element: Element): Rect;\r\n /** `measure()` clipped by scroll containers and the viewport; `null` when fully clipped. */\r\n measureVisible(element: Element): Rect | null;\r\n /**\r\n * Whether the element is within `margin` sizes of its scroll container's visible\r\n * area. An estimate: it may use a rect made stale by `invalidate()`.\r\n */\r\n isNearViewport(element: Element, margin?: number): boolean;\r\n /**\r\n * After layout changes (draft changes): cached rects of `elements`, or all of\r\n * them, go stale. Exact reads re-measure them; `isNearViewport()` may still use\r\n * them, because a draft change moves items by a few item sizes at most, well\r\n * within its margin, and re-measuring thousands of far items for FLIP would cost\r\n * more than the animation saves.\r\n */\r\n invalidate(elements?: Iterable<Element>): void;\r\n /** Invalidates the cache when `element` resizes during the session. */\r\n observe(element: Element): void;\r\n}\r\n\r\nexport interface MeasurerOptions {\r\n /**\r\n * A scroll container inside a shadow root scrolled during the session. Its `scroll`\r\n * event isn't composed, so document listeners never see it.\r\n */\r\n onShadowScroll?: () => void;\r\n}\r\n\r\nexport function createMeasurer(options: MeasurerOptions = {}): Measurer {\r\n let active = false;\r\n let frame = 0;\r\n let generation = 0;\r\n // Computed styles barely change during a drag: read them once per session.\r\n let flags = new WeakMap<Element, Flags>();\r\n const entries = new Map<Element, Entry>();\r\n /** Chain applying to the descendants of a container. */\r\n const chains = new Map<Element, Chain>();\r\n\r\n // Per frame.\r\n const scroll = new Map<Element, Coordinates>();\r\n const clips = new Map<Element, Rect | null>();\r\n const nearRegions = new Map<Element, Rect | null>();\r\n let windowScroll: Coordinates | null = null;\r\n let viewport: Rect | null = null;\r\n\r\n let observer: ResizeObserver | null = null;\r\n const sizes = new Map<Element, string>();\r\n const shadowRoots = new Set<ShadowRoot>();\r\n\r\n const onShadowScroll = () => options.onShadowScroll?.();\r\n\r\n const watchShadowRoot = (element: Element) => {\r\n const root = element.getRootNode();\r\n if (!active || !(root instanceof ShadowRoot) || shadowRoots.has(root)) return;\r\n shadowRoots.add(root);\r\n root.addEventListener('scroll', onShadowScroll, { capture: true, passive: true });\r\n };\r\n\r\n const clearFrame = () => {\r\n scroll.clear();\r\n clips.clear();\r\n nearRegions.clear();\r\n windowScroll = null;\r\n viewport = null;\r\n };\r\n\r\n /** Outside a session nothing is cached: every read is fresh. */\r\n const prepare = () => {\r\n if (active) return;\r\n flags = new WeakMap();\r\n entries.clear();\r\n chains.clear();\r\n clearFrame();\r\n };\r\n\r\n const flagsOf = (element: Element): Flags => {\r\n let result = flags.get(element);\r\n if (!result) {\r\n const style = getComputedStyle(element);\r\n // Overflow and containment don't apply without a box of their own.\r\n const boxed = style.display !== 'contents' && style.display !== 'inline';\r\n const paint = boxed && /paint|strict|content/.test(style.contain ?? '');\r\n result = {\r\n clipX: paint || (boxed && clipsOverflow(style.overflowX)),\r\n clipY: paint || (boxed && clipsOverflow(style.overflowY)),\r\n fixed: style.position === 'fixed',\r\n sticky: style.position === 'sticky',\r\n };\r\n flags.set(element, result);\r\n }\r\n return result;\r\n };\r\n\r\n const clipsContent = (element: Element) => {\r\n const own = flagsOf(element);\r\n if (!own.clipX && !own.clipY) return false;\r\n // `overflow` on <body> applies to the viewport unless <html> sets its own.\r\n if (element === document.body) {\r\n const root = flagsOf(document.documentElement);\r\n return root.clipX || root.clipY;\r\n }\r\n return true;\r\n };\r\n\r\n const withSticky = (chain: Chain, sticky: boolean): Chain =>\r\n sticky && !chain.volatile ? { ...chain, volatile: true } : chain;\r\n\r\n const chainBelow = (container: Element | null): Chain => {\r\n if (!container || container === document.documentElement) return ROOT;\r\n let chain = chains.get(container);\r\n if (chain) return chain;\r\n const own = flagsOf(container);\r\n const outer = own.fixed ? FIXED : chainBelow(parentOf(container));\r\n const clipping = clipsContent(container);\r\n if (clipping) watchShadowRoot(container);\r\n chain = clipping\r\n ? {\r\n scrollers: [container, ...outer.scrollers],\r\n window: outer.window,\r\n volatile: outer.volatile || own.sticky,\r\n }\r\n : withSticky(outer, own.sticky);\r\n chains.set(container, chain);\r\n return chain;\r\n };\r\n\r\n const chainOf = (element: Element): Chain => {\r\n const own = flagsOf(element);\r\n if (own.fixed) return FIXED;\r\n return withSticky(chainBelow(parentOf(element)), own.sticky);\r\n };\r\n\r\n const scrollOf = (scroller: Element): Coordinates => {\r\n let value = scroll.get(scroller);\r\n if (!value) {\r\n value = { x: scroller.scrollLeft, y: scroller.scrollTop };\r\n scroll.set(scroller, value);\r\n }\r\n return value;\r\n };\r\n\r\n const windowOffset = (): Coordinates =>\r\n (windowScroll ??= { x: window.scrollX, y: window.scrollY });\r\n\r\n const record = (element: Element): Entry => {\r\n const chain = chainOf(element);\r\n const offsets: number[] = [];\r\n for (const scroller of chain.scrollers) {\r\n const { x, y } = scrollOf(scroller);\r\n offsets.push(x, y);\r\n }\r\n if (chain.window) {\r\n const { x, y } = windowOffset();\r\n offsets.push(x, y);\r\n }\r\n const entry: Entry = { rect: getLayoutRect(element), chain, offsets, frame, generation };\r\n entries.set(element, entry);\r\n return entry;\r\n };\r\n\r\n /** `exact: false` accepts a stale rect (estimates). */\r\n const entryOf = (element: Element, exact = true): Entry => {\r\n const entry = entries.get(element);\r\n if (\r\n entry &&\r\n (!exact || entry.generation === generation) &&\r\n !(entry.chain.volatile && entry.frame !== frame)\r\n ) {\r\n return entry;\r\n }\r\n return record(element);\r\n };\r\n\r\n // Scroll delta of the last `measureDelta()`; plain variables keep hot loops allocation-free.\r\n let dx = 0;\r\n let dy = 0;\r\n\r\n /** Scroll since the entry was measured, into `dx`/`dy`. */\r\n const measureDelta = (entry: Entry) => {\r\n const { chain, offsets } = entry;\r\n dx = 0;\r\n dy = 0;\r\n let index = 0;\r\n for (const scroller of chain.scrollers) {\r\n const now = scrollOf(scroller);\r\n dx += offsets[index++]! - now.x;\r\n dy += offsets[index++]! - now.y;\r\n }\r\n if (chain.window) {\r\n const now = windowOffset();\r\n dx += offsets[index++]! - now.x;\r\n dy += offsets[index]! - now.y;\r\n }\r\n };\r\n\r\n /** Cached rect moved by the scroll that happened since it was measured. */\r\n const rectOf = (entry: Entry): Rect => {\r\n measureDelta(entry);\r\n return dx || dy ? offsetRect(entry.rect, dx, dy) : entry.rect;\r\n };\r\n\r\n const viewportRect = (): Rect =>\r\n (viewport ??= createRect(0, 0, window.innerWidth, window.innerHeight));\r\n\r\n /** Visible area for the content of the chain's nearest scroller. */\r\n const clipOf = (chain: Chain): Rect | null => {\r\n const scroller = chain.scrollers[0];\r\n if (!scroller) return viewportRect();\r\n const cached = clips.get(scroller);\r\n if (cached !== undefined) return cached;\r\n const entry = entryOf(scroller);\r\n const outer = clipOf(entry.chain);\r\n let result: Rect | null = null;\r\n if (outer) {\r\n const border = rectOf(entry);\r\n // Content is clipped at the padding box, scrollbars excluded.\r\n const client = (entry.client ??= createRect(\r\n scroller.clientLeft,\r\n scroller.clientTop,\r\n scroller.clientWidth,\r\n scroller.clientHeight,\r\n ));\r\n const box = offsetRect(client, border.left, border.top);\r\n const { clipX, clipY } = flagsOf(scroller);\r\n // `overflow-x: clip` alone leaves the other axis unclipped.\r\n result = intersectRect(\r\n outer,\r\n createRect(\r\n clipX ? box.left : outer.left,\r\n clipY ? box.top : outer.top,\r\n clipX ? box.width : outer.width,\r\n clipY ? box.height : outer.height,\r\n ),\r\n );\r\n }\r\n clips.set(scroller, result);\r\n return result;\r\n };\r\n\r\n const measure = (element: Element): Rect => {\r\n prepare();\r\n return rectOf(entryOf(element));\r\n };\r\n\r\n const measureVisible = (element: Element): Rect | null => {\r\n prepare();\r\n const entry = entryOf(element);\r\n const clip = clipOf(entry.chain);\r\n return clip && intersectRect(rectOf(entry), clip);\r\n };\r\n\r\n /** Visible area of the chain's nearest scroller grown by `margin` of its size; per frame. */\r\n const nearRegionOf = (chain: Chain, margin: number): Rect | null => {\r\n const key = chain.scrollers[0] ?? document.documentElement;\r\n if (margin === NEAR_VIEWPORT) {\r\n const cached = nearRegions.get(key);\r\n if (cached !== undefined) return cached;\r\n }\r\n const clip = clipOf(chain);\r\n const region = clip && expandRect(clip, clip.width * margin, clip.height * margin);\r\n if (margin === NEAR_VIEWPORT) nearRegions.set(key, region);\r\n return region;\r\n };\r\n\r\n // Called for every item of a group on each draft change: no allocations.\r\n const isNearViewport = (element: Element, margin = NEAR_VIEWPORT): boolean => {\r\n prepare();\r\n const entry = entryOf(element, false);\r\n const region = nearRegionOf(entry.chain, margin);\r\n if (!region) return false;\r\n measureDelta(entry);\r\n const { left, top, right, bottom } = entry.rect;\r\n return (\r\n right + dx > region.left &&\r\n left + dx < region.right &&\r\n bottom + dy > region.top &&\r\n top + dy < region.bottom\r\n );\r\n };\r\n\r\n const invalidate = (elements?: Iterable<Element>) => {\r\n if (elements) {\r\n for (const element of elements) entries.delete(element);\r\n } else {\r\n generation++;\r\n chains.clear();\r\n }\r\n // Clip rects derive from the containers' entries.\r\n clips.clear();\r\n nearRegions.clear();\r\n };\r\n\r\n /** Resizes reflow anything: not even estimates survive. */\r\n const reset = () => {\r\n entries.clear();\r\n chains.clear();\r\n clips.clear();\r\n nearRegions.clear();\r\n };\r\n\r\n const onResize = () => reset();\r\n\r\n const observe = (element: Element) => {\r\n if (!active || sizes.has(element) || typeof ResizeObserver === 'undefined') return;\r\n observer ??= new ResizeObserver((records) => {\r\n let changed = false;\r\n for (const { target, contentRect } of records) {\r\n const size = `${contentRect.width}x${contentRect.height}`;\r\n // The first notification only reports the initial size.\r\n if (sizes.get(target) && sizes.get(target) !== size) changed = true;\r\n sizes.set(target, size);\r\n }\r\n // No new frame: the target follows the pointer, never a layout shift alone.\r\n if (changed) reset();\r\n });\r\n sizes.set(element, '');\r\n observer.observe(element);\r\n };\r\n\r\n const end = () => {\r\n if (active) window.removeEventListener('resize', onResize);\r\n active = false;\r\n observer?.disconnect();\r\n observer = null;\r\n sizes.clear();\r\n for (const root of shadowRoots) {\r\n root.removeEventListener('scroll', onShadowScroll, { capture: true });\r\n }\r\n shadowRoots.clear();\r\n flags = new WeakMap();\r\n entries.clear();\r\n chains.clear();\r\n clearFrame();\r\n };\r\n\r\n const begin = () => {\r\n end();\r\n active = true;\r\n window.addEventListener('resize', onResize, { passive: true });\r\n };\r\n\r\n const nextFrame = () => {\r\n frame++;\r\n clearFrame();\r\n };\r\n\r\n return { begin, end, nextFrame, measure, measureVisible, isNearViewport, invalidate, observe };\r\n}\r\n","/**\r\n * The state of one provider's manager. `createDnDManager` builds a `ManagerContext` and\r\n * hands it to each of its modules; what a module alone needs stays in its closure.\r\n * No provider's state lives at module level, so providers on one page stay independent\r\n * (`owners` in `registry.ts` is shared on purpose: it tells their elements apart).\r\n */\r\n\r\nimport { shallowReactive, shallowRef, type Component } from 'vue';\r\nimport type {\r\n Active,\r\n Coordinates,\r\n DnDEvent,\r\n DnDProviderProps,\r\n DnDStatus,\r\n DragMode,\r\n DropAnimation,\r\n DropDestination,\r\n Key,\r\n LayoutAnimation,\r\n Over,\r\n Rect,\r\n Size,\r\n} from '../../types';\r\nimport type { landOverlayItems } from '../../animation/drop';\r\nimport type { Measurer } from '../measure';\r\nimport type { Detection } from './detection';\r\nimport type { Events } from './events';\r\nimport type { Follow } from './follow';\r\nimport type { FrameLoop } from './frame';\r\nimport type { Overlay, PreviewSource } from './overlay';\r\nimport type { RegistryLookups, RegistryMembers } from './registry';\r\n\r\n/**\r\n * Multi-drag layout of the default overlay, set by the sortable layer: every dragged id\r\n * in drop order, along `axis`, `gap` apart.\r\n */\r\nexport interface OverlayColumn {\r\n ids: Key[];\r\n axis: 'x' | 'y';\r\n gap: number;\r\n /** `'column'` (default): the items in a row along `axis`. `'pile'` (grids): stacked behind the active one. */\r\n layout?: 'column' | 'pile';\r\n /** The list's layout animation: the clones gather into the column with it. */\r\n animation?: LayoutAnimation;\r\n /** Renders the column in the default overlay. The sortable layer brings it: plain drags don't bundle it. */\r\n preview: Component;\r\n /** Lands the overlay's clones (`overlayItems`: the column's, custom layouts' `DragPreview`s) with the drop. */\r\n land: typeof landOverlayItems;\r\n}\r\n\r\nexport const NO_LANDINGS: ReadonlyMap<Key, Key> = new Map();\r\n\r\n/**\r\n * An ended drag whose overlay is landing (`session.ts`): what the box shows and where it\r\n * goes, as the drag left them. The provider is free for the next drag meanwhile; the\r\n * overlay renders a box per flight.\r\n */\r\nexport interface Flight {\r\n /** The drag's session: the overlay keys a drag's box by it, so the box carries on as the flight's. */\r\n id: number;\r\n reason: 'drop' | 'cancel';\r\n /** What `onDragEnd` (a `DnDEndEvent`) or `onDragCancel` got; `onDragSettle` gets it too. */\r\n event: DnDEvent;\r\n active: Active;\r\n mode: DragMode;\r\n /** The target it was dropped on: what it lands on; `null` on a cancel. */\r\n over: Over | null;\r\n /** Where the drop went, as the overlay's `to` said at the release. */\r\n to: DropDestination | null;\r\n /** The row the overlay lands on when it isn't the active item's (a copy, a created item). */\r\n landingKey: Key | null;\r\n /** The slot hidden until the overlay is there: the active item's, its copy's; `null` for none. */\r\n slot: Key | null;\r\n /** Multi-drag: slot → dragged id of the other items landing (see `landings`). */\r\n landings: ReadonlyMap<Key, Key>;\r\n column: OverlayColumn | null;\r\n /** The clones taken at pickup (`DragPreview`), and the ids that have one, in drop order. */\r\n previews: ReadonlyMap<Key, PreviewSource>;\r\n previewIds: readonly Key[];\r\n /** The drag's own overlay component (`null`: the provider's slot or the clone). */\r\n component: Component | null;\r\n /** The drop target's overlay around it, if it has one. */\r\n target: Component | undefined;\r\n /** The drag's own `dropAnimation` (the item's, its list's). */\r\n dropAnimation: DropAnimation | undefined;\r\n fitSize: Size | null;\r\n /** Where the box was left (viewport). */\r\n rect: Rect;\r\n /** Clones of the other items in the box, which land on their own slots. */\r\n items: Map<Key, HTMLElement>;\r\n /** The box. */\r\n element: HTMLElement | null;\r\n /** Keeps the box on what it lands on while the page scrolls. */\r\n follow: Follow;\r\n /**\r\n * The other dragged items nothing in the box lands on (no clone of theirs flies): they\r\n * show at once, fading in, rather than wait as placeholders for the box to land.\r\n */\r\n released: ReadonlySet<Key>;\r\n /** Fades of items without a clone, kept until their placeholder marks are gone. */\r\n fades: Animation[];\r\n /** Landed, or the provider went away: its awaited steps do nothing. */\r\n done: boolean;\r\n}\r\n\r\n/** The reactive drag state: what the overlay, the composables and `useDnD()` render. */\r\nexport const createDragState = () => ({\r\n status: shallowRef<DnDStatus>('idle'),\r\n active: shallowRef<Active | null>(null),\r\n over: shallowRef<Over | null>(null),\r\n pointer: shallowRef<Coordinates | null>(null),\r\n /**\r\n * Ended drags whose overlay is landing, oldest first. A decided drop hands its overlay\r\n * to a flight and clears the drag state (`active`, `over` read `null`), so the next drag\r\n * can start while it lands.\r\n */\r\n flights: shallowRef<readonly Flight[]>([]),\r\n transform: shallowRef<Coordinates>({ x: 0, y: 0 }),\r\n /**\r\n * How far the content the drag started in has moved on screen since the start (see\r\n * `ModifierArgs.containerShift`): axis locks hold the other axis there, and an element\r\n * dragged without an overlay subtracts it, as it moves with that content.\r\n */\r\n containerShift: shallowRef<Coordinates>({ x: 0, y: 0 }),\r\n activationProgress: shallowRef(0),\r\n /** The browser's own drag (`native`) went out of the window: nothing here follows it then. */\r\n outside: shallowRef(false),\r\n isAutoScrolling: shallowRef(false),\r\n /** The containers auto-scroll moved in its last frame (the window aside): a new array when they change. */\r\n autoScrollers: shallowRef<readonly Element[]>([]),\r\n overlayElement: shallowRef<HTMLElement | null>(null),\r\n /** Size the overlay box has while dragging (see `updateFitSize`). */\r\n fitSize: shallowRef<Size | null>(null),\r\n announcement: shallowRef(''),\r\n selection: shallowReactive(new Set<Key>()),\r\n /** What a drop would do, set by the sortable layer (overlay slot `mode`). */\r\n mode: shallowRef<DragMode>('move'),\r\n /** Key whose element the overlay lands on, when it isn't the active id (copies, external items). */\r\n landingKey: shallowRef<Key | null>(null),\r\n /**\r\n * Multi-drag, set by the sortable layer: slot key → id of the dragged item (other than\r\n * the active one) that lands there. While dragging: the placeholders of a `'group'`\r\n * block; after the commit: where each accepted item went (copies included).\r\n */\r\n landings: shallowRef<ReadonlyMap<Key, Key>>(NO_LANDINGS),\r\n /** Multi-drag layout of the default overlay; `null`: the active item with a count (a pile of plain draggables). */\r\n overlayColumn: shallowRef<OverlayColumn | null>(null),\r\n /** Clones of the other items in the default overlay's column, by id: each lands on its own slot. */\r\n overlayItems: new Map<Key, HTMLElement>(),\r\n});\r\n\r\nexport type DragState = ReturnType<typeof createDragState>;\r\n\r\n/**\r\n * Everything the manager's modules share. They reach each other through it when they\r\n * run, never while they are created: `createDnDManager` puts every module in place\r\n * before anything can call one.\r\n */\r\nexport interface ManagerContext extends DragState, RegistryLookups, RegistryMembers {\r\n props: DnDProviderProps;\r\n measurer: Measurer;\r\n /** Pointer position at drag start. */\r\n origin: Coordinates;\r\n /** The drag was started by touch: it vibrates (`haptics`). */\r\n touch: boolean;\r\n /** Pointer position as the sensor reported it, before modifiers. */\r\n raw: Coordinates;\r\n /**\r\n * Topmost element under the pointer at the last target detection, for auto-scroll;\r\n * `null` while a modifier moves the point away from the pointer.\r\n */\r\n pointerElement: Element | null;\r\n /** Takes the page out of drag mode (cursor, text selection); set while it is in it. */\r\n restoreDocument: (() => void) | null;\r\n /** A drag out of the page dropped somewhere else (`endOutside`): what that place did with it. */\r\n droppedOutside?: 'move' | 'copy' | 'link';\r\n\r\n events: Events;\r\n overlay: Overlay;\r\n detection: Detection;\r\n loop: FrameLoop;\r\n}\r\n","/**\r\n * What a provider knows about: its draggables and drop targets (by id: elements may be\r\n * recreated mid-drag), its monitors, and the hooks library layers plug in (drag sources,\r\n * target rules, announcers, auto-scroll overrides).\r\n */\r\n\r\nimport { nextTick, shallowRef, type Component } from 'vue';\r\nimport type {\r\n ActivationOptions,\r\n Active,\r\n Announcer,\r\n AutoScrollOptions,\r\n BeforeDropResult,\r\n Coordinates,\r\n DnDEvent,\r\n DnDMonitor,\r\n DragSource,\r\n DropAnimation,\r\n DropDestination,\r\n DroppableOptions,\r\n ExternalAccept,\r\n Key,\r\n NativeDragOptions,\r\n Modifier,\r\n SortablePosition,\r\n} from '../../types';\r\nimport { parentOf } from '../../utils/dom';\r\n\r\nexport interface DraggableEntry {\r\n id: Key;\r\n getElement(): HTMLElement | null;\r\n /** Handle element or selector; `null` when the whole element is the handle. */\r\n getHandle(): HTMLElement | string | null;\r\n /** Element that receives focus and keyboard activation. */\r\n getFocusTarget(): HTMLElement | null;\r\n getData(): unknown;\r\n /** What people call it (`label`). */\r\n getLabel?(): string | undefined;\r\n getTypes(): string[];\r\n isDisabled(): boolean;\r\n getActivation?(): ActivationOptions | undefined;\r\n canDrag?: (event: PointerEvent | KeyboardEvent) => boolean;\r\n /** `false`: no overlay; `true`: the provider's slot or the clone; a component (`markRaw`): rendered instead. */\r\n getOverlay(): boolean | Component;\r\n /** Its own (or its list's) drop animation; `undefined` leaves the provider's. */\r\n getDropAnimation?(): DropAnimation | undefined;\r\n /** Modifiers of this draggable (or its list), applied after the provider's. */\r\n getModifiers?(): Modifier[] | undefined;\r\n /** Arrow keys in free keyboard drags: move by pixels (default) or jump between accepting drop targets. */\r\n getKeyboard?(): 'pixels' | 'droppables' | undefined;\r\n /** Sortable integration: the item object behind this draggable. */\r\n getItem?(): unknown;\r\n /** Sortable integration: container used by `restrictToParent`. */\r\n getContainer?(): HTMLElement | null;\r\n /** A mouse drag of it is the browser's own drag (`native`): its options, else `undefined`. */\r\n getNative?(): NativeDragOptions | undefined;\r\n /** Sortable integration: the item's group, which another window's lists take it by. */\r\n getGroup?(): string;\r\n}\r\n\r\nexport interface DroppableEntry {\r\n id: Key;\r\n getElement(): HTMLElement | null;\r\n getData(): unknown;\r\n /** What people call it (`label`). */\r\n getLabel?(): string | undefined;\r\n isDisabled(): boolean;\r\n accepts(active: Active): boolean;\r\n /** What it takes from drags that come from outside the page (`external`); without it, it ignores them. */\r\n getExternal?(): ExternalAccept | undefined;\r\n /** A sortable list or tree: its group, whose items it takes from another window of the app. */\r\n getGroup?(): string;\r\n getPriority(): number;\r\n /** A sortable list or tree: what drops on it is shown in it, as a slot. */\r\n sortable?: boolean;\r\n /** The options it was made with, for the devtools (its `accept` rule). */\r\n options?: DroppableOptions;\r\n /** What the overlay shows while a drag it accepts is over it (`markRaw`); `undefined`: the drag's own. */\r\n getOverlay?(): Component | undefined;\r\n /** How the overlay lands when dropped here; `undefined` leaves the dragged item's and the provider's. */\r\n getDropAnimation?(): DropAnimation | undefined;\r\n onDragEnter?(event: DnDEvent): void;\r\n onDragLeave?(event: DnDEvent): void;\r\n onBeforeDrop?(event: DnDEvent): BeforeDropResult | Promise<BeforeDropResult>;\r\n onDrop?(event: DnDEvent): void;\r\n}\r\n\r\n/** A monitor of a library layer (`addMonitor(monitor, true)`): hooks users' monitors don't have. */\r\nexport interface IntegrationMonitor extends DnDMonitor {\r\n /**\r\n * Programmatic moves (`SensorDrag.place`): puts the slot of the running drag at a list\r\n * position; returns where the drag goes then, `undefined` when this layer can't.\r\n */\r\n placeAt?(active: Active, position: SortablePosition): Promise<Coordinates | undefined>;\r\n}\r\n\r\n/**\r\n * Integration rule for a drop target, asked on every target detection: `false` leaves it\r\n * out of this one (sortable: a target inside an item counts only in the item's middle).\r\n */\r\nexport type TargetRule = (entry: DroppableEntry, element: HTMLElement, point: Coordinates, active: Active) => boolean;\r\n\r\n/** Per-container auto-scroll override (e.g. `SortableListOptions.autoScroll`). */\r\nexport interface AutoScrollEntry {\r\n getElement(): Element | null;\r\n /** Read when the drag starts; `undefined`: no override. */\r\n getOptions(): boolean | AutoScrollOptions | undefined;\r\n}\r\n\r\n/** A drag area (`makeDragArea`): rules for the drags that start in its element. */\r\nexport interface AreaEntry {\r\n getElement(): HTMLElement | null;\r\n isDisabled(): boolean;\r\n getActivation(): ActivationOptions | undefined;\r\n getModifiers(): Modifier[] | undefined;\r\n getAxis(): 'x' | 'y' | undefined;\r\n /** `restrictToArea`: the drag stays inside the area's element. */\r\n restricts(): boolean;\r\n}\r\n\r\n/** Elements owned by any provider, so nested providers ignore each other's items. */\r\nconst owners = new WeakMap<Element, object>();\r\n\r\n/** Bundlers replace it: development builds keep the warnings, production drops them. */\r\ndeclare const process: { env: { NODE_ENV?: string } };\r\n\r\ninterface Registered {\r\n id: Key;\r\n getElement(): Element | null;\r\n}\r\n\r\n/** Development: entries registered and not unregistered since. */\r\nconst live = new WeakSet<Registered>();\r\n\r\n/**\r\n * Development: `entry` took the id of `previous`. That is fine when `previous` goes in the\r\n * same render (an item re-created in another list registers before the old one is gone, a\r\n * virtual list gives a recycled row another id); if both are still there once it has\r\n * settled, only `entry` counts, and the user is told.\r\n */\r\nconst checkShared = (kind: 'draggable' | 'drop target', map: Map<Key, Registered>, previous: Registered, entry: Registered) => {\r\n void nextTick(() => {\r\n if (!live.has(previous) || previous.id !== entry.id || map.get(entry.id) !== entry) return;\r\n const before = previous.getElement();\r\n const after = entry.getElement();\r\n if (!before?.isConnected || !after?.isConnected || before === after) return;\r\n const effect = kind === 'draggable' ? 'only the last one registered is dragged, also from the other one' : 'only the last one registered takes drops';\r\n console.warn(`[vue-dnd-kit] Two ${kind}s share the id \"${String(entry.id)}\": ${effect}. Give each its own id.`);\r\n });\r\n};\r\n\r\nexport type Registry = ReturnType<typeof createRegistry>;\r\nexport type RegistryLookups = Registry['lookups'];\r\nexport type RegistryMembers = Registry['members'];\r\n\r\nexport function createRegistry() {\r\n const draggables = new Map<Key, DraggableEntry>();\r\n const droppables = new Map<Key, DroppableEntry>();\r\n const draggableIds = new WeakMap<Element, Key>();\r\n const monitors = new Set<IntegrationMonitor>();\r\n /** Monitors of library layers (see `addMonitor`). */\r\n const integrations = new Set<DnDMonitor>();\r\n const sourceResolvers = new Set<(active: Active) => DragSource | undefined>();\r\n const targetRules = new Set<TargetRule>();\r\n /** Integration announcers (sortable positions): after the user's `announcements`, before the defaults. */\r\n const announcers = new Set<Announcer>();\r\n /** Where a drop would put the dragged items, by integrations (sortable groups); reactive. */\r\n const destinationResolvers = new Set<() => DropDestination | null>();\r\n const activationAborts = new Set<() => void>();\r\n const autoScrollEntries = new Set<AutoScrollEntry>();\r\n /** Cancels the running rubber-band selection (`status === 'selecting'`). */\r\n const selectionAborts = new Set<() => void>();\r\n /** This provider, as `owners` records it. */\r\n const owner = {};\r\n const areas = new WeakMap<Element, AreaEntry>();\r\n let areaCount = 0;\r\n /** Bumped when an area binds or unbinds an element: whatever reads `findArea` follows. */\r\n const areasVersion = shallowRef(0);\r\n\r\n const registerDraggable = (entry: DraggableEntry): (() => void) => {\r\n const previous = draggables.get(entry.id);\r\n draggables.set(entry.id, entry);\r\n if (process.env.NODE_ENV !== 'production') {\r\n live.add(entry);\r\n if (previous && previous !== entry) checkShared('draggable', draggables, previous, entry);\r\n }\r\n return () => {\r\n if (process.env.NODE_ENV !== 'production') live.delete(entry);\r\n // A recreated element may already have registered the same id.\r\n if (draggables.get(entry.id) === entry) draggables.delete(entry.id);\r\n };\r\n };\r\n\r\n const registerDroppable = (entry: DroppableEntry): (() => void) => {\r\n const previous = droppables.get(entry.id);\r\n droppables.set(entry.id, entry);\r\n if (process.env.NODE_ENV !== 'production') {\r\n live.add(entry);\r\n if (previous && previous !== entry) checkShared('drop target', droppables, previous, entry);\r\n }\r\n return () => {\r\n if (process.env.NODE_ENV !== 'production') live.delete(entry);\r\n if (droppables.get(entry.id) === entry) droppables.delete(entry.id);\r\n };\r\n };\r\n\r\n const bindDraggableElement = (element: Element, id: Key) => {\r\n draggableIds.set(element, id);\r\n owners.set(element, owner);\r\n };\r\n\r\n const unbindDraggableElement = (element: Element, id: Key) => {\r\n if (draggableIds.get(element) !== id) return;\r\n draggableIds.delete(element);\r\n owners.delete(element);\r\n };\r\n\r\n /** Closest draggable owned by this provider, walking up from the event target. */\r\n const findDraggable = (\r\n target: Element,\r\n ): { entry: DraggableEntry; element: HTMLElement } | null => {\r\n for (let element: Element | null = target; element; element = parentOf(element)) {\r\n const elementOwner = owners.get(element);\r\n if (!elementOwner) continue;\r\n if (elementOwner !== owner) return null;\r\n const id = draggableIds.get(element);\r\n const entry = id == null ? undefined : draggables.get(id);\r\n return entry ? { entry, element: element as HTMLElement } : null;\r\n }\r\n return null;\r\n };\r\n\r\n const bindArea = (element: Element, entry: AreaEntry) => {\r\n if (!areas.has(element)) areaCount++;\r\n areas.set(element, entry);\r\n areasVersion.value++;\r\n };\r\n\r\n const unbindArea = (element: Element, entry: AreaEntry) => {\r\n if (areas.get(element) !== entry) return;\r\n areas.delete(element);\r\n areaCount--;\r\n areasVersion.value++;\r\n };\r\n\r\n /** The areas of this provider around `element` (or on it), the closest first, while `visit` returns `false`. */\r\n const walkAreas = (element: Element | null, visit: (area: AreaEntry) => boolean): AreaEntry | null => {\r\n // Read even without areas: an effect asking now hears about the first one.\r\n void areasVersion.value;\r\n if (!areaCount) return null;\r\n for (let node = element; node; node = parentOf(node)) {\r\n const area = areas.get(node);\r\n if (area && visit(area)) return area;\r\n }\r\n return null;\r\n };\r\n\r\n /** The closest area around `element`: the one whose rules its drags follow. */\r\n const findArea = (element: Element | null): AreaEntry | null => walkAreas(element, () => true);\r\n\r\n /** Some area around `element` is disabled: a disabled area turns off the areas inside it too. */\r\n const inDisabledArea = (element: Element | null): boolean => !!walkAreas(element, (area) => area.isDisabled());\r\n\r\n /**\r\n * `integration`: a library layer (sortable groups). Its notifications run before the\r\n * others', so the user's `onDragEnd` sees the drop it wrote; its `onBeforeDrop` runs\r\n * after theirs (see `drop`).\r\n */\r\n const addMonitor = (monitor: IntegrationMonitor, integration = false): (() => void) => {\r\n monitors.add(monitor);\r\n if (integration) integrations.add(monitor);\r\n return () => {\r\n monitors.delete(monitor);\r\n integrations.delete(monitor);\r\n };\r\n };\r\n\r\n const addSourceResolver = (resolver: (active: Active) => DragSource | undefined) => {\r\n sourceResolvers.add(resolver);\r\n return () => sourceResolvers.delete(resolver);\r\n };\r\n\r\n const addTargetRule = (rule: TargetRule) => {\r\n targetRules.add(rule);\r\n return () => targetRules.delete(rule);\r\n };\r\n\r\n /** Overrides auto-scroll for the scroll container of `getElement()` (the element or its closest scrollable ancestor). */\r\n const registerAutoScroll = (\r\n getElement: () => Element | null,\r\n getOptions: () => boolean | AutoScrollOptions | undefined,\r\n ): (() => void) => {\r\n const entry: AutoScrollEntry = { getElement, getOptions };\r\n autoScrollEntries.add(entry);\r\n return () => autoScrollEntries.delete(entry);\r\n };\r\n\r\n /** Extra announcers (sortable positions): after the provider's own texts, before the defaults. */\r\n const addAnnouncer = (announcer: Announcer): (() => void) => {\r\n announcers.add(announcer);\r\n return () => announcers.delete(announcer);\r\n };\r\n\r\n /**\r\n * Where a drop would put the dragged items (the overlay's `to`), from an integration: a\r\n * reactive getter (a computed's value), `null` when the drag isn't its own.\r\n */\r\n const addDestinationResolver = (resolver: () => DropDestination | null): (() => void) => {\r\n destinationResolvers.add(resolver);\r\n return () => destinationResolvers.delete(resolver);\r\n };\r\n\r\n /** The first integration's answer: a sortable group knows where its slot is. */\r\n const getDestination = (): DropDestination | null => {\r\n for (const resolver of destinationResolvers) {\r\n const destination = resolver();\r\n if (destination) return destination;\r\n }\r\n return null;\r\n };\r\n\r\n return {\r\n /** What the manager's modules look up. */\r\n lookups: { draggables, droppables, draggableIds, integrations, sourceResolvers, targetRules, announcers },\r\n /** Members of the manager (`DnDManager`), as they are. */\r\n members: {\r\n monitors,\r\n activationAborts,\r\n selectionAborts,\r\n getDraggable: (id: Key) => draggables.get(id),\r\n /** Every registered draggable, e.g. for selection hit-testing. */\r\n getDraggables: (): IterableIterator<DraggableEntry> => draggables.values(),\r\n getDroppable: (id: Key) => droppables.get(id),\r\n getDroppables: () => droppables.values(),\r\n autoScrollEntries,\r\n registerAutoScroll,\r\n registerDraggable,\r\n registerDroppable,\r\n bindDraggableElement,\r\n unbindDraggableElement,\r\n findDraggable,\r\n bindArea,\r\n unbindArea,\r\n findArea,\r\n inDisabledArea,\r\n addMonitor,\r\n addSourceResolver,\r\n addTargetRule,\r\n addAnnouncer,\r\n addDestinationResolver,\r\n getDestination,\r\n },\r\n };\r\n}\r\n","import type { Active, Announcements, Over } from '../types';\r\n\r\nexport const DEFAULT_INSTRUCTIONS =\r\n 'To pick up a draggable item, press space or enter. While dragging, use the arrow keys to move the item. Press space or enter again to drop the item in its new position, or press escape to cancel.';\r\n\r\n// What the texts call things: their `label` as written, else a phrase with the id.\r\nconst item = (active: Active) => active.label ?? `draggable item ${active.id}`;\r\nconst Item = (active: Active) => active.label ?? `Draggable item ${active.id}`;\r\nconst area = (over: Over) => over.label ?? `droppable area ${over.id}`;\r\n\r\nexport const defaultAnnouncements: Announcements = {\r\n onDragStart: ({ active }) => `Picked up ${item(active)}.`,\r\n onDragOver: ({ active, over }) =>\r\n over ? `${Item(active)} was moved over ${area(over)}.` : `${Item(active)} is no longer over a droppable area.`,\r\n onDragEnd: ({ active, over }) => (over ? `${Item(active)} was dropped over ${area(over)}.` : `${Item(active)} was dropped.`),\r\n onDragCancel: ({ active }) => `Dragging was cancelled. ${Item(active)} was dropped.`,\r\n onDragResume: ({ active }) => `${Item(active)} was not dropped. It is still being moved.`,\r\n};\r\n\r\nexport const VISUALLY_HIDDEN = {\r\n position: 'fixed',\r\n width: '1px',\r\n height: '1px',\r\n margin: '-1px',\r\n padding: '0',\r\n border: '0',\r\n overflow: 'hidden',\r\n clip: 'rect(0 0 0 0)',\r\n clipPath: 'inset(100%)',\r\n whiteSpace: 'nowrap',\r\n} as const;\r\n","/**\r\n * What a drag tells: events to the monitors, texts to screen readers.\r\n *\r\n * Integrations (library layers, see `addMonitor`) hear events first, so the user's\r\n * `onDragEnd` sees the drop they wrote, and decide `onBeforeDrop` last, after the user's\r\n * monitors. Texts are spoken by the provider's live region (`announcement`): the\r\n * provider's own `announcements` win, then integrations' (sortable positions), then the\r\n * defaults; moves are debounced, only the target the drag rests on is spoken.\r\n */\r\n\r\nimport type { Active, AnnouncementContext, Announcements, Coordinates, DnDEndEvent, DnDEvent, DnDMonitor, DragSource, Over, Rect } from '../../types';\r\nimport { defaultAnnouncements } from '../a11y';\r\nimport type { ManagerContext } from './state';\r\n\r\ntype MonitorHandler = Exclude<keyof DnDMonitor, 'onBeforeDrop' | 'getKeyboardCoordinates'>;\r\n\r\nconst OVER_ANNOUNCE_DELAY = 500;\r\n\r\nexport type Events = ReturnType<typeof createEvents>;\r\n\r\n/**\r\n * Where `box`'s top-left corner is in `over`: from its padding edge, with its scroll. What\r\n * `left`/`top` inside it take to put the item where it was dropped.\r\n */\r\nexport const positionInTarget = (box: Rect, { element, rect }: Over): Coordinates => ({\r\n x: box.left - rect.left - element.clientLeft + element.scrollLeft,\r\n y: box.top - rect.top - element.clientTop + element.scrollTop,\r\n});\r\n\r\nexport function createEvents(ctx: ManagerContext) {\r\n let announceTimer: ReturnType<typeof setTimeout> | undefined;\r\n let lastAnnouncement = '';\r\n\r\n // ─── Events ──────────────────────────────────────────────────────────────────\r\n\r\n /** Where the dragged box is in `over` (`DnDEvent.position`). */\r\n const positionIn = (current: Active, over: Over | null, offset: Coordinates): Coordinates | null =>\r\n over ? positionInTarget(ctx.overlay.getOverlayRect(current, offset), over) : null;\r\n\r\n const createEvent = (): DnDEvent => {\r\n const current = ctx.active.value!;\r\n const { origin } = ctx;\r\n const p = ctx.pointer.value ?? origin;\r\n let source: DragSource | undefined;\r\n for (const resolve of ctx.sourceResolvers) {\r\n source = resolve(current);\r\n if (source) break;\r\n }\r\n const over = ctx.over.value;\r\n const offset = ctx.transform.value;\r\n let position: Coordinates | null | undefined;\r\n return {\r\n active: current,\r\n over,\r\n pointer: p,\r\n delta: { x: p.x - origin.x, y: p.y - origin.y },\r\n mode: ctx.mode.value,\r\n source,\r\n ...(current.external && { external: current.external }),\r\n // Measured when read (it reads the target's layout), once.\r\n get position() {\r\n if (position === undefined) position = positionIn(current, over, offset);\r\n return position;\r\n },\r\n };\r\n };\r\n\r\n /** The monitors with integrations first (or last), each side in registration order. */\r\n const orderMonitors = (integrationsFirst: boolean): DnDMonitor[] => {\r\n const rank = (monitor: DnDMonitor) => Number(ctx.integrations.has(monitor) === integrationsFirst);\r\n return [...ctx.monitors].sort((a, b) => rank(b) - rank(a));\r\n };\r\n\r\n const emit = (name: MonitorHandler, event: DnDEvent | DnDEndEvent) => {\r\n // Integrations first (see `addMonitor`), each side in registration order.\r\n for (const monitor of orderMonitors(true)) {\r\n try {\r\n (monitor[name] as ((event: DnDEvent) => void) | undefined)?.(event);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n };\r\n\r\n // ─── Announcements ───────────────────────────────────────────────────────────\r\n\r\n const setAnnouncement = (text: string) => {\r\n const { announcement } = ctx;\r\n // Screen readers only speak changes: repeating the same text needs a different string.\r\n announcement.value =\r\n text === lastAnnouncement && announcement.value === text ? `${text} ` : text;\r\n lastAnnouncement = text;\r\n };\r\n\r\n const announce = (name: keyof Announcements, event: DnDEvent = createEvent()) => {\r\n const custom = ctx.props.announcements;\r\n if (custom === false) return clearTimeout(announceTimer);\r\n type Announce = (this: unknown, event: DnDEvent, context: AnnouncementContext) => string | undefined;\r\n let text: string | undefined;\r\n try {\r\n // What the text is about, as the integrations know it (sortable positions).\r\n let described: Partial<AnnouncementContext> | undefined;\r\n for (const announcer of ctx.announcers) {\r\n described = announcer.describe?.(name, event);\r\n if (described) break;\r\n }\r\n const context: AnnouncementContext = {\r\n count: event.active.ids.length,\r\n copy: ctx.mode.value === 'copy',\r\n ...described,\r\n };\r\n // The provider's own text wins, then announcers (sortable positions), then defaults.\r\n // `undefined`: not this source's business, the next one speaks; '': nothing to say.\r\n text = (custom?.[name] as Announce | undefined)?.call(custom, event, context);\r\n for (const announcer of ctx.announcers) {\r\n if (text !== undefined) break;\r\n text = (announcer[name] as Announce | undefined)?.call(announcer, event, context);\r\n }\r\n text ??= (defaultAnnouncements[name] as Announce).call(defaultAnnouncements, event, context);\r\n } catch (error) {\r\n // A throwing announcement must not break the session (§13).\r\n clearTimeout(announceTimer);\r\n console.error(error);\r\n return;\r\n }\r\n // Nothing new (e.g. the first target of a drag is where it started): neither speak\r\n // nor cancel what is pending. Once the drag has ended, though, a pending move text is\r\n // stale: a silent end drops it too.\r\n if (text === '') {\r\n if (name === 'onDragEnd' || name === 'onDragCancel') clearTimeout(announceTimer);\r\n return;\r\n }\r\n clearTimeout(announceTimer);\r\n if (!text) return;\r\n if (name === 'onDragOver') {\r\n // Debounced: only the target the pointer settles on is spoken, and only if it changed.\r\n announceTimer = setTimeout(() => {\r\n if (text !== lastAnnouncement) setAnnouncement(text);\r\n }, OVER_ANNOUNCE_DELAY);\r\n } else {\r\n setAnnouncement(text);\r\n }\r\n };\r\n\r\n return {\r\n createEvent,\r\n orderMonitors,\r\n emit,\r\n announce,\r\n /** Drops the pending move announcement (the provider unmounts). */\r\n stopAnnouncing: () => clearTimeout(announceTimer),\r\n };\r\n}\r\n","/**\r\n * Style snapshot of an overlay clone. The overlay is rendered outside the list (in <body>\r\n * by default), where rules that match through ancestors no longer reach the clone:\r\n * `.grid li { display: flex }`, `table td { padding }`, a shadow root's styles, a UI kit's\r\n * styles keyed on its list. At pickup the clone is laid out in a host where the overlay\r\n * goes, at the overlay's size; its computed styles are compared with the source's, element\r\n * by element, and only what differs is inlined. What already matches keeps flowing:\r\n * inherited values, defaults, sizes that follow the overlay box.\r\n *\r\n * Passes, each reading every element before writing any: what an element looks like and\r\n * its box; what the layout resolves (margins, offsets, grid tracks, transforms); sizes the\r\n * source sets; then sizes that still differ. The host leaves before anything paints.\r\n */\r\n\r\ntype Styled = Element & ElementCSSInlineStyle;\r\n\r\ninterface Entry {\r\n source: Element;\r\n clone: Styled;\r\n parent?: Entry;\r\n /**\r\n * Properties compared in each pass, with the source's values: look, resolved, the sizes\r\n * the source sets, then any size (the same map twice). Last (`SHOWN`), the clone's values\r\n * as compared: a child that inherits compares with its parent's.\r\n */\r\n passes: Array<Map<string, string>>;\r\n /** The source's Typed OM computed values, made when first read (`computedValue`). */\r\n styleMap?: StylePropertyMapReadOnly | null;\r\n}\r\n\r\n/**\r\n * Elements snapshotted at most, the root and the levels below it first: reading styles\r\n * is most of a pickup's cost. Deeper elements keep what the overlay's cascade gives them.\r\n */\r\nconst LIMIT = 200;\r\nconst SHOWN = 4;\r\n\r\n// Shorthands where they cover several longhands: every engine serializes them in\r\n// computed styles, and one read (and write) takes all of them.\r\nconst names = (list: string) => list.split(' ');\r\n\r\n/** Inherited: a child that inherits one in the clone will get its parent's snapshot value. */\r\nconst INHERITED = new Set(\r\n names(\r\n 'color font-family font-size font-weight font-style font-variant font-feature-settings line-height ' +\r\n 'letter-spacing text-align text-transform text-shadow white-space word-break overflow-wrap direction ' +\r\n 'visibility list-style-type',\r\n ),\r\n);\r\n\r\n/**\r\n * Compared on every element. Size constraints (`min-*`, `max-*`, `aspect-ratio`) show in\r\n * the sizes the last passes compare.\r\n */\r\nconst LOOK = [\r\n ...INHERITED,\r\n ...names(\r\n 'display opacity filter box-shadow outline background overflow text-overflow text-decoration-line ' +\r\n 'border-radius padding border-width border-style border-color flex-flow place-content place-items gap ' +\r\n 'position z-index vertical-align flex object-fit',\r\n ),\r\n];\r\n\r\n/**\r\n * Resolved by the layout, compared below the root only: the root fills the overlay box.\r\n * Grid tracks are a box's own, compared on the root too.\r\n */\r\nconst RESOLVED = names('grid-template-columns grid-template-rows margin inset transform translate rotate scale');\r\nconst SIZES = names('width height');\r\n\r\nconst read = (style: CSSStyleDeclaration, list: string[], into = new Map<string, string>()) => {\r\n for (const name of list) into.set(name, style.getPropertyValue(name));\r\n return into;\r\n};\r\n\r\n/** Source and clone elements side by side, breadth first. SVG contents follow their <svg>. */\r\nconst collect = (source: Element, clone: Styled): Entry[] => {\r\n const entries: Entry[] = [{ source, clone, passes: [] }];\r\n for (const parent of entries) {\r\n if (parent.source.localName === 'svg') continue;\r\n [...parent.source.children].forEach((child, index) => {\r\n const copy = parent.clone.children[index] as Styled | undefined;\r\n if (copy && entries.length < LIMIT) entries.push({ source: child, clone: copy, parent, passes: [] });\r\n });\r\n }\r\n return entries;\r\n};\r\n\r\n/**\r\n * The root's custom properties: the box around the clone passes on those that inherit; the\r\n * others (`@property` with `inherits: false`) are compared as the look is.\r\n */\r\nconst readCustom = (style: CSSStyleDeclaration, into: Map<string, string>) => {\r\n for (let index = 0; index < style.length; index++) {\r\n const name = style.item(index);\r\n if (name.startsWith('--')) into.set(name, style.getPropertyValue(name));\r\n }\r\n return into;\r\n};\r\n\r\nconst readSource = (entry: Entry) => {\r\n const style = getComputedStyle(entry.source);\r\n const { parent } = entry;\r\n const sizes = read(style, parent ? SIZES : []);\r\n const look = read(style, LOOK);\r\n entry.passes = [\r\n parent ? look : readCustom(style, look),\r\n read(style, parent ? RESOLVED : RESOLVED.slice(0, 2)),\r\n sizes,\r\n sizes,\r\n new Map(),\r\n ];\r\n};\r\n\r\n/**\r\n * The source's computed value (Typed OM, Chromium and WebKit): unlike the used value the\r\n * layout resolves, `auto` margins, `50%` and `calc()` keep following the overlay box.\r\n */\r\nconst computedValue = (entry: Entry, name: string): string | undefined => {\r\n try {\r\n // One map per element and snapshot: a map is live, and making one costs as much as reading it.\r\n entry.styleMap ??= entry.source.computedStyleMap?.() ?? null;\r\n return entry.styleMap?.get(name)?.toString();\r\n } catch {\r\n // A property this browser's Typed OM doesn't know.\r\n }\r\n};\r\n\r\n/**\r\n * What to write on `entry`'s clone in `pass`. The first pass writes the source's values;\r\n * the layout's passes its computed ones where they can. Sizes run twice: those the source\r\n * sets first, then what still differs, as used: a size the source leaves to the layout\r\n * (`auto`) may only have followed content fixed by the first.\r\n */\r\nconst compare = (entry: Entry, pass: number): Array<() => void> => {\r\n const { clone, parent, passes } = entry;\r\n const style = getComputedStyle(clone);\r\n const writes: Array<() => void> = [];\r\n for (const [name, from] of passes[pass]!) {\r\n let value = style.getPropertyValue(name);\r\n // Inherited properties are compared in the first pass only.\r\n const inherited = INHERITED.has(name);\r\n passes[SHOWN]!.set(name, value);\r\n // A child that inherits in the clone will inherit its parent's snapshot value.\r\n if (inherited && parent && value === parent.passes[SHOWN]!.get(name)) value = parent.passes[0]!.get(name)!;\r\n // Sizes within half a pixel are the same size.\r\n if (value === from || (pass > 1 && Math.abs(parseFloat(value) - parseFloat(from)) < 0.5)) continue;\r\n // Passes 1 and 2 take the computed value, and so do inherited values: a unitless\r\n // `line-height` is inherited as a ratio, not as the root's pixels. Otherwise the\r\n // source's (used) value.\r\n const computed = pass % 3 || inherited ? computedValue(entry, name) : undefined;\r\n // No computed value, or a keyword (`auto`): left to the next pass.\r\n if (pass === 2 && /^[a-z-]*$/.test(computed + '')) continue;\r\n writes.push(() => clone.style.setProperty(name, computed ?? from));\r\n }\r\n return writes;\r\n};\r\n\r\n/**\r\n * Inlines on `clone` (a deep copy of `source`, shown as `mount`: itself or its table\r\n * wrapper) the computed styles it would lose in `container`, the overlay's parent.\r\n * `source` is in the document.\r\n */\r\nexport const snapshotStyles = (source: HTMLElement, clone: HTMLElement, mount: HTMLElement, container: Element) =>\r\n snapshotMany([{ source, clone, mount }], container);\r\n\r\nexport interface SnapshotJob {\r\n source: HTMLElement;\r\n clone: HTMLElement;\r\n mount: HTMLElement;\r\n}\r\n\r\n/**\r\n * `snapshotStyles` for several clones at once: every source is read, then the clones are\r\n * laid out side by side, each in a host of its source's size, and every pass runs over all\r\n * of them. The page lays out once per pass, not once per pass and clone.\r\n */\r\nexport const snapshotMany = (jobs: readonly SnapshotJob[], container: Element) => {\r\n const all = jobs.map((job) => ({ ...job, entries: collect(job.source, job.clone) }));\r\n for (const job of all) job.entries.forEach(readSource);\r\n const sizes = all.map((job) => job.source.getBoundingClientRect());\r\n // Overlay boxes, out of the page's layout: `contain` keeps the page from re-laying out.\r\n const hosts = all.map((job, index) => {\r\n const host = document.createElement('div');\r\n host.style.cssText = `position:fixed;contain:strict;width:${sizes[index]!.width}px;height:${sizes[index]!.height}px`;\r\n host.appendChild(job.mount);\r\n return host;\r\n });\r\n container.append(...hosts);\r\n try {\r\n for (let pass = 0; pass < 4; pass++) {\r\n // Values written start transitions: the reads want where they end. Animations of the\r\n // clone's own start again in the overlay.\r\n for (const job of all) job.mount.getAnimations?.({ subtree: true }).forEach((animation) => animation.cancel());\r\n all.flatMap((job) => job.entries.flatMap((entry) => compare(entry, pass))).forEach((write) => write());\r\n }\r\n } finally {\r\n for (const job of all) job.mount.remove();\r\n for (const host of hosts) host.remove();\r\n }\r\n};\r\n","/**\r\n * Overlay clone of the dragged element. Taken synchronously at drag start,\r\n * before the placeholder re-renders, and detached from page-level side effects.\r\n */\r\n\r\nimport { snapshotMany } from './snapshot';\r\n\r\nlet radioGroup = 0;\r\n\r\nconst copyFormState = (source: Element, clone: Element) => {\r\n const sourceFields = source.querySelectorAll('input, textarea, select');\r\n const cloneFields = clone.querySelectorAll('input, textarea, select');\r\n const suffix = `-dnd-clone-${++radioGroup}`;\r\n sourceFields.forEach((field, index) => {\r\n const target = cloneFields[index];\r\n if (!target) return;\r\n if (field instanceof HTMLInputElement && target instanceof HTMLInputElement) {\r\n target.value = field.value;\r\n target.checked = field.checked;\r\n // A cloned radio would join (and steal from) the original group.\r\n if (field.type === 'radio' && field.name) target.name = field.name + suffix;\r\n } else if (field instanceof HTMLTextAreaElement && target instanceof HTMLTextAreaElement) {\r\n target.value = field.value;\r\n } else if (field instanceof HTMLSelectElement && target instanceof HTMLSelectElement) {\r\n target.selectedIndex = field.selectedIndex;\r\n }\r\n });\r\n};\r\n\r\nconst copyCanvases = (source: Element, clone: Element) => {\r\n const sourceCanvases = source.querySelectorAll('canvas');\r\n const cloneCanvases = clone.querySelectorAll('canvas');\r\n sourceCanvases.forEach((canvas, index) => {\r\n const target = cloneCanvases[index];\r\n try {\r\n target?.getContext('2d')?.drawImage(canvas, 0, 0);\r\n } catch {\r\n // Tainted or WebGL canvases can't be copied; the clone stays blank.\r\n }\r\n });\r\n};\r\n\r\nconst wrapTableRow = (row: HTMLElement, source: HTMLElement): HTMLElement => {\r\n const table = document.createElement('table');\r\n const body = document.createElement('tbody');\r\n table.style.borderCollapse = 'collapse';\r\n table.style.width = '100%';\r\n table.style.height = '100%';\r\n const sourceCells = source.children;\r\n Array.from(row.children).forEach((cell, index) => {\r\n const width = sourceCells[index]?.getBoundingClientRect().width;\r\n if (width) (cell as HTMLElement).style.width = `${width}px`;\r\n });\r\n body.appendChild(row);\r\n table.appendChild(body);\r\n return table;\r\n};\r\n\r\n/**\r\n * Where the clone will be shown (the overlay's parent): the styles it loses there are\r\n * inlined. Backgrounds aren't guessed: a source without one of its own (a list row the\r\n * list paints) gives a transparent clone, styled with `[data-dnd-overlay]` in CSS.\r\n */\r\nexport interface CloneOptions {\r\n container?: Element | null;\r\n}\r\n\r\n/**\r\n * Effects UI kits add inside an element while it's pressed: Vuetify's ripple, Quasar's,\r\n * PrimeVue's ink, Naive UI's wave. A copy would freeze them mid-animation.\r\n */\r\nconst PRESS_EFFECTS = '.v-ripple__container, .q-ripple, .p-ink, .n-base-wave';\r\n\r\n/** Nodes of copies marked `data-dnd-no-clone` in their source (the mark itself is stripped). */\r\nconst leftOut = new WeakSet<Element>();\r\n\r\n/**\r\n * Takes out of a copy what shouldn't travel with it: press effects of UI kits and elements\r\n * marked `data-dnd-no-clone`. After the style snapshot, which pairs the copy's elements\r\n * with the source's by position.\r\n */\r\nexport const removeTransient = (copy: Element): void => {\r\n for (const element of copy.querySelectorAll('*')) {\r\n if (leftOut.has(element) || element.matches(PRESS_EFFECTS)) element.remove();\r\n }\r\n};\r\n\r\n/**\r\n * A deep copy of `source` that stays out of the page's way: no ids, no `data-dnd-*` marks,\r\n * hidden from assistive tech, with what `cloneNode` leaves out (form state, canvas pixels).\r\n * `source` may be detached (an item Vue just removed).\r\n */\r\nexport const copyElement = (source: HTMLElement): HTMLElement => {\r\n const clone = source.cloneNode(true) as HTMLElement;\r\n for (const element of [clone, ...clone.querySelectorAll('*')]) {\r\n element.removeAttribute('id');\r\n if (element.hasAttribute('data-dnd-no-clone')) leftOut.add(element);\r\n for (const name of element.getAttributeNames()) {\r\n if (name.startsWith('data-dnd-')) element.removeAttribute(name);\r\n }\r\n }\r\n copyFormState(source, clone);\r\n copyCanvases(source, clone);\r\n clone.setAttribute('aria-hidden', 'true');\r\n clone.removeAttribute('tabindex');\r\n return clone;\r\n};\r\n\r\n/**\r\n * The overlay's clone of `source`: a copy that fills the overlay box, with the computed\r\n * styles it would lose outside its list inlined (`snapshot.ts`), in a box that carries the\r\n * custom properties it inherits. A table row comes in a table of its own.\r\n */\r\nexport const clonePreview = (source: HTMLElement, options: CloneOptions = {}): HTMLElement =>\r\n clonePreviews([source], options)[0]!;\r\n\r\n/** The copy of `source` before its style snapshot: what it carries, filling the overlay box. */\r\nconst prepare = (source: HTMLElement) => {\r\n const clone = copyElement(source);\r\n const computed = getComputedStyle(source);\r\n // The custom properties the source inherits go on a box around the copy: inline on the\r\n // copy they would beat its own rules in the overlay (Tailwind's `--tw-ring-shadow` from\r\n // `in-data-[dnd-overlay]:ring-2`). The snapshot inlines those that don't reach it.\r\n const box = document.createElement('div');\r\n box.style.cssText = 'width:100%;height:100%';\r\n for (let index = 0; index < computed.length; index++) {\r\n const property = computed.item(index);\r\n if (property.startsWith('--')) {\r\n box.style.setProperty(property, computed.getPropertyValue(property));\r\n }\r\n }\r\n // The clone fills the overlay box: when the box takes the size of another list's\r\n // items, the content re-lays out at that size instead of being scaled.\r\n Object.assign(clone.style, {\r\n width: '100%',\r\n height: '100%',\r\n margin: '0',\r\n boxSizing: 'border-box',\r\n transform: 'none',\r\n translate: 'none',\r\n transition: 'none',\r\n pointerEvents: 'none',\r\n });\r\n box.appendChild(source.tagName === 'TR' ? wrapTableRow(clone, source) : clone);\r\n return { source, clone, mount: box, positioned: computed.position !== 'static' };\r\n};\r\n\r\n/**\r\n * `clonePreview` for several sources: their style snapshots run together, one layout per\r\n * pass for all of them (`snapshotMany`), not one per clone.\r\n */\r\nexport const clonePreviews = (sources: readonly HTMLElement[], { container }: CloneOptions = {}): HTMLElement[] => {\r\n const jobs = sources.map(prepare);\r\n // Laid out as the overlay will show them: the roots' styles above are in place.\r\n snapshotMany(jobs, container ?? document.body);\r\n return jobs.map(({ clone, mount, positioned }) => {\r\n removeTransient(clone);\r\n // No transitions while the snapshot inlined its styles; the page's own run on the\r\n // overlay again (its `dragging` / `dropping` looks).\r\n clone.style.removeProperty('transition');\r\n // A positioned source (a piece on a board) would keep its offsets inside the overlay.\r\n // `relative` keeps it a containing block for its own positioned children.\r\n if (positioned) Object.assign(clone.style, { position: 'relative', inset: 'auto' });\r\n return mount;\r\n });\r\n};\r\n","/**\r\n * The overlay of a drag: what it shows (whether there is one, its component, the clones\r\n * of the dragged items taken at pickup) and its box (where it is for a drag offset, at\r\n * which size, and the modifiers that move it). `overlayFit: 'slot'` glides the box to\r\n * the size of the slot the item will land in, around the point where the pointer holds it.\r\n */\r\n\r\nimport type { Component } from 'vue';\r\nimport type { Active, Coordinates, DropAnimation, Key, Modifier, Rect, Size } from '../../types';\r\nimport {\r\n getFraction,\r\n getLayoutRect,\r\n getRect,\r\n getWindowRect,\r\n offsetRect,\r\n prefersReducedMotion,\r\n resizeAround,\r\n} from '../../animation/layout';\r\nimport { clonePreview, clonePreviews } from '../clone';\r\nimport type { ManagerContext } from './state';\r\nimport type { DraggableEntry } from './registry';\r\n\r\n/** A clone taken at pickup and the rect of its source then (`DragPreview`). */\r\nexport interface PreviewSource {\r\n element: HTMLElement;\r\n rect: Rect;\r\n}\r\n\r\n/**\r\n * Items cloned at pickup by default (`overlayPreviews`): the grabbed one and the others\r\n * next to it in drop order. Cloning lays out the clones and reads their computed styles\r\n * (`snapshot.ts`), the most expensive part of a pickup, and a column of more clones covers\r\n * most of the screen; the overlay counts the rest instead.\r\n */\r\nconst DEFAULT_PREVIEWS = 5;\r\n/** A placeholder styled smaller than this share of the source (a drop line) keeps the source size on that axis. */\r\nconst FIT_MIN_RATIO = 0.25;\r\n/** Overlay box resizes (a target list with other item sizes) glide instead of jumping. */\r\nconst RESIZE_DURATION = 150;\r\n\r\nexport type Overlay = ReturnType<typeof createOverlay>;\r\n\r\nexport function createOverlay(ctx: ManagerContext) {\r\n /** Clones taken at pickup by id (`DragPreview`), and the ids that have one, in drop order. */\r\n let previews = new Map<Key, PreviewSource>();\r\n let previewIds: Key[] = [];\r\n let previewEnabled = false;\r\n /**\r\n * The draggable the drag started from. Its `overlay` and `dropAnimation` are read live\r\n * (a ref switched mid-drag applies at once); its options outlive an unmounted element.\r\n */\r\n let source: DraggableEntry | null = null;\r\n /** Where the pointer holds the overlay box, as fractions of its size: it resizes around this point. */\r\n let grab: Coordinates = { x: 0, y: 0 };\r\n /** The container the drag started in (`restrictToParent`, `snapToGrid`), measured on every move. */\r\n let container: Element | null = null;\r\n /** Where the container was at the start, and how far its content was scrolled (`containerShift`). */\r\n let containerStart: { rect: Rect; scroll: Coordinates } | null = null;\r\n /** Modifiers of the draggable the drag started from, taken at start like the overlay. */\r\n let sourceModifiers: readonly Modifier[] = [];\r\n /**\r\n * Glide of `fitSize` to a new slot size. It runs in the frame loop rather than as a\r\n * CSS transition: the box resizes around the grab point, so its position depends\r\n * on its size, and collision and modifiers must see the box as it is shown.\r\n */\r\n let resize: { from: Size; to: Size; start: number } | null = null;\r\n\r\n // ─── Content ─────────────────────────────────────────────────────────────────\r\n\r\n /** Where the overlay renders: the clones are laid out there, with its styles. */\r\n const overlayContainer = () => {\r\n const to = ctx.props.overlayTo;\r\n return typeof to === 'string' ? document.querySelector(to) : to;\r\n };\r\n\r\n /** The rendered element of a dragged item, if it can be cloned. */\r\n const sourceOf = (id: Key) => {\r\n const element = ctx.draggables.get(id)?.getElement();\r\n return element?.isConnected ? element : null;\r\n };\r\n\r\n const takePreview = (id: Key): PreviewSource | null => {\r\n const element = sourceOf(id);\r\n if (!element) return null;\r\n return { element: clonePreview(element, { container: overlayContainer() }), rect: getRect(element) };\r\n };\r\n\r\n /**\r\n * Clones of the other dragged items, next to the active one in drop order (the overlay\r\n * column's order, else `ids`), as many as `overlayPreviews` asks for. Runs right after\r\n * `onDragStart`: the sortable layer has set the order, and the DOM hasn't re-rendered\r\n * yet. They are cloned together: the page lays out once per snapshot pass for all.\r\n */\r\n const takePreviews = (current: Active) => {\r\n const order = ctx.overlayColumn.value?.ids ?? current.ids;\r\n const wanted = ctx.props.overlayPreviews ?? DEFAULT_PREVIEWS;\r\n const limit = wanted === 'all' ? order.length : Math.max(1, Math.floor(wanted));\r\n const at = Math.max(order.indexOf(current.id), 0);\r\n const from = Math.max(0, Math.min(at - ((limit - 1) >> 1), order.length - limit));\r\n const ids = order.slice(from, from + limit);\r\n const missing = ids.flatMap((id) => {\r\n const element = previews.has(id) ? null : sourceOf(id);\r\n return element ? [{ id, element, rect: getRect(element) }] : [];\r\n });\r\n const clones = clonePreviews(\r\n missing.map(({ element }) => element),\r\n { container: overlayContainer() },\r\n );\r\n missing.forEach(({ id, rect }, index) => previews.set(id, { element: clones[index]!, rect }));\r\n previewIds = ids.filter((id) => previews.has(id));\r\n };\r\n\r\n // ─── Box ─────────────────────────────────────────────────────────────────────\r\n\r\n /**\r\n * The overlay box for a drag offset: the dragged element's rect moved by `offset`,\r\n * at the box's current size, resized around the grab point. The overlay, collision\r\n * and modifiers all place the box with this, so they never disagree.\r\n */\r\n const getOverlayRect = (current: Active, offset: Coordinates): Rect =>\r\n resizeAround(offsetRect(current.rect, offset.x, offset.y), ctx.fitSize.value ?? current.rect, grab);\r\n\r\n /** The provider's modifiers, then those of the draggable (or list) the drag started from. */\r\n const getModifiers = (): readonly Modifier[] => {\r\n const { modifiers } = ctx.props;\r\n return sourceModifiers.length ? [...(modifiers ?? []), ...sourceModifiers] : (modifiers ?? []);\r\n };\r\n\r\n /**\r\n * How far the content the drag started in has moved on screen: the container itself,\r\n * less what its content scrolled inside it. Kept as it was once the container is gone.\r\n */\r\n const shiftOf = (containerRect: Rect | null): Coordinates => {\r\n const previous = ctx.containerShift.value;\r\n if (!containerRect || !containerStart) return previous;\r\n const { rect, scroll } = containerStart;\r\n const x = containerRect.left - rect.left - (container!.scrollLeft - scroll.x);\r\n const y = containerRect.top - rect.top - (container!.scrollTop - scroll.y);\r\n return x === previous.x && y === previous.y ? previous : (ctx.containerShift.value = { x, y });\r\n };\r\n\r\n const applyModifiers = (current: Active, offset: Coordinates): Coordinates => {\r\n let result = offset;\r\n // Where it is now: the page may have scrolled since the drag started.\r\n const containerRect = container?.isConnected ? getRect(container) : null;\r\n const containerShift = shiftOf(containerRect);\r\n for (const modifier of getModifiers()) {\r\n result = modifier({\r\n transform: result,\r\n active: current,\r\n activeRect: current.rect,\r\n overlayRect: getOverlayRect(current, result),\r\n origin: ctx.origin,\r\n containerRect,\r\n containerShift,\r\n windowRect: getWindowRect(),\r\n over: ctx.over.value,\r\n });\r\n }\r\n return result;\r\n };\r\n\r\n /**\r\n * `overlayFit: 'slot'`: the overlay takes the size of the slot the item will land in,\r\n * so it matches the items of the list it hovers. Layout sizes (`offset*`) ignore\r\n * FLIP translates; each axis is taken on its own, so a thin custom placeholder\r\n * still passes its width.\r\n */\r\n const updateFitSize = (current: Active) => {\r\n const { fitSize } = ctx;\r\n // Without an overlay the element itself moves: it keeps its size.\r\n if (ctx.props.overlayFit === 'source' || !previewEnabled) return;\r\n const slot = ctx.draggables.get(ctx.landingKey.value ?? current.id)?.getElement();\r\n if (!slot?.isConnected) return;\r\n const size =\r\n slot instanceof HTMLElement\r\n ? { width: slot.offsetWidth, height: slot.offsetHeight }\r\n : getLayoutRect(slot);\r\n const { width: sourceWidth, height: sourceHeight } = current.rect;\r\n const width = size.width >= sourceWidth * FIT_MIN_RATIO ? size.width : sourceWidth;\r\n const height = size.height >= sourceHeight * FIT_MIN_RATIO ? size.height : sourceHeight;\r\n const previous = resize?.to ?? fitSize.value;\r\n if (previous && Math.abs(previous.width - width) < 0.5 && Math.abs(previous.height - height) < 0.5) {\r\n return;\r\n }\r\n const shown = fitSize.value;\r\n if (!shown || prefersReducedMotion()) {\r\n resize = null;\r\n fitSize.value = { width, height };\r\n return;\r\n }\r\n resize = { from: shown, to: { width, height }, start: performance.now() };\r\n ctx.loop.requestFrame();\r\n };\r\n\r\n /** Moves `fitSize` along the running glide; asks for frames until it ends. */\r\n const stepResize = () => {\r\n if (!resize) return;\r\n const { from, to, start } = resize;\r\n const progress = (performance.now() - start) / RESIZE_DURATION;\r\n if (progress >= 1) {\r\n resize = null;\r\n ctx.fitSize.value = to;\r\n return;\r\n }\r\n // Ease-out: quick at first, settling on the slot size.\r\n const eased = 1 - (1 - progress) ** 3;\r\n ctx.fitSize.value = {\r\n width: from.width + (to.width - from.width) * eased,\r\n height: from.height + (to.height - from.height) * eased,\r\n };\r\n ctx.loop.requestFrame();\r\n };\r\n\r\n return {\r\n /** Whether the drag has an overlay; without one the element itself moves. */\r\n get enabled() {\r\n return previewEnabled;\r\n },\r\n /** The drag's own component (the item's, else its list's); `null`: the provider's slot or the clone. Reactive. */\r\n get component(): Component | null {\r\n if (!previewEnabled || !source) return null;\r\n const overlay = source.getOverlay();\r\n return typeof overlay === 'boolean' ? null : overlay;\r\n },\r\n /** The drag's own drop animation (the item's, else its list's); `undefined`: the provider's. */\r\n get dropAnimation(): DropAnimation | undefined {\r\n return source?.getDropAnimation?.();\r\n },\r\n get previewIds(): readonly Key[] {\r\n return previewIds;\r\n },\r\n getPreview: (id: Key): PreviewSource | undefined => previews.get(id),\r\n takePreviews,\r\n getOverlayRect,\r\n getModifiers,\r\n applyModifiers,\r\n updateFitSize,\r\n stepResize,\r\n\r\n /**\r\n * Takes a drag's overlay from the draggable's `overlay` option: whether there is one\r\n * is decided here, its component is read live. The grabbed item's clone is taken\r\n * synchronously, before the placeholder re-renders. Overlay components get it too:\r\n * they may show it (`DragPreview`).\r\n */\r\n pickUp(id: Key, entry: DraggableEntry, caught?: ReadonlyMap<Key, PreviewSource>, browser = false) {\r\n source = entry;\r\n // The browser's own drag draws its image: no overlay.\r\n previewEnabled = !browser && entry.getOverlay() !== false;\r\n // A drag that catches a landing overlay takes its clones: the slots are still hidden.\r\n previews = new Map(previewEnabled ? caught : undefined);\r\n const preview = previewEnabled && !previews.has(id) ? takePreview(id) : null;\r\n if (preview) previews.set(id, preview);\r\n previewIds = [];\r\n },\r\n\r\n /**\r\n * The box of a new drag, at the source size; `parent` is the container of\r\n * `restrictToParent`. The modifiers run: `origin` and `over` must be set. `caught`:\r\n * the box of a landing overlay the drag catches in flight, where the box starts.\r\n */\r\n place(current: Active, coordinates: Coordinates, modifiers: readonly Modifier[], parent: Element | null, caught?: Rect | null) {\r\n sourceModifiers = modifiers;\r\n container = parent;\r\n containerStart = parent?.isConnected\r\n ? { rect: getRect(parent), scroll: { x: parent.scrollLeft, y: parent.scrollTop } }\r\n : null;\r\n ctx.containerShift.value = { x: 0, y: 0 };\r\n resize = null;\r\n if (caught) {\r\n // The box goes on from where it was caught, at its size there, held where it was\r\n // pressed: the item's rect moved so that point is under the pointer. It glides to\r\n // the slot's size as any box does. Pointer, box and drop offset stay consistent:\r\n // the origin moves back by the offset the drag starts with.\r\n ctx.fitSize.value = { width: caught.width, height: caught.height };\r\n grab = getFraction(caught, coordinates);\r\n const offset = {\r\n x: coordinates.x - grab.x * current.rect.width - current.rect.left,\r\n y: coordinates.y - grab.y * current.rect.height - current.rect.top,\r\n };\r\n ctx.origin = { x: coordinates.x - offset.x, y: coordinates.y - offset.y };\r\n ctx.transform.value = offset;\r\n return;\r\n }\r\n ctx.fitSize.value = { width: current.rect.width, height: current.rect.height };\r\n // Where the pointer holds the box on the first frame, after modifiers (the center\r\n // with snapCenterToCursor). The box has the source size here: no grab applies yet.\r\n const first = applyModifiers(current, { x: 0, y: 0 });\r\n grab = getFraction(offsetRect(current.rect, first.x, first.y), coordinates);\r\n },\r\n\r\n /**\r\n * The drop is decided: what the overlay shows goes to the flight that lands it (its\r\n * clones, its component and own drop animation, its size), read as they are now.\r\n */\r\n release() {\r\n return {\r\n previews: previews as ReadonlyMap<Key, PreviewSource>,\r\n previewIds: previewIds as readonly Key[],\r\n component: this.component,\r\n dropAnimation: this.dropAnimation,\r\n fitSize: ctx.fitSize.value,\r\n };\r\n },\r\n\r\n end() {\r\n ctx.fitSize.value = null;\r\n resize = null;\r\n previews = new Map();\r\n previewIds = [];\r\n previewEnabled = false;\r\n source = null;\r\n sourceModifiers = [];\r\n container = null;\r\n containerStart = null;\r\n ctx.containerShift.value = { x: 0, y: 0 };\r\n },\r\n };\r\n}\r\n","import type { CollisionDetection, Coordinates, Key, Rect } from '../types';\r\nimport { distance, getCenter } from '../animation/layout';\r\n\r\nconst area = (rect: Rect) => rect.width * rect.height;\r\n\r\nconst intersectionRatio = (a: Rect, b: Rect): number => {\r\n const width = Math.min(a.right, b.right) - Math.max(a.left, b.left);\r\n const height = Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top);\r\n if (width <= 0 || height <= 0) return 0;\r\n const intersection = width * height;\r\n return intersection / (area(a) + area(b) - intersection);\r\n};\r\n\r\n/** Targets under the pointer, from hit-testing: respects z-order, overlays and shadow roots. */\r\nexport const pointerWithin: CollisionDetection = ({ hits }) => hits;\r\n\r\n/** Targets overlapping the overlay: higher priority, then deeper nesting, then intersection over union. */\r\nexport const rectIntersection: CollisionDetection = ({ overlayRect, candidates }) => {\r\n if (!overlayRect) return [];\r\n return candidates\r\n .map((candidate) => ({ candidate, ratio: intersectionRatio(overlayRect, candidate.rect) }))\r\n .filter((entry) => entry.ratio > 0)\r\n .sort(\r\n (a, b) =>\r\n b.candidate.priority - a.candidate.priority ||\r\n (b.candidate.depth ?? 0) - (a.candidate.depth ?? 0) ||\r\n b.ratio - a.ratio,\r\n )\r\n .map((entry) => entry.candidate.id);\r\n};\r\n\r\n/** Every target, by distance between centers. */\r\nexport const closestCenter: CollisionDetection = ({ overlayRect, pointer, candidates }) => {\r\n const center = overlayRect ? getCenter(overlayRect) : pointer;\r\n return [...candidates]\r\n .sort((a, b) => distance(center, getCenter(a.rect)) - distance(center, getCenter(b.rect)))\r\n .map((candidate) => candidate.id);\r\n};\r\n\r\nconst corners = (rect: Rect): Coordinates[] => [\r\n { x: rect.left, y: rect.top },\r\n { x: rect.right, y: rect.top },\r\n { x: rect.left, y: rect.bottom },\r\n { x: rect.right, y: rect.bottom },\r\n];\r\n\r\n/** Every target, by summed distance between corners (good for stacked targets such as kanban columns). */\r\nexport const closestCorners: CollisionDetection = ({ overlayRect, pointer, candidates }) => {\r\n const source = overlayRect\r\n ? corners(overlayRect)\r\n : [pointer, pointer, pointer, pointer];\r\n const score = (rect: Rect) =>\r\n corners(rect).reduce((sum, corner, index) => sum + distance(corner, source[index]!), 0);\r\n return [...candidates]\r\n .sort((a, b) => score(a.rect) - score(b.rect))\r\n .map((candidate) => candidate.id);\r\n};\r\n\r\n/** Default: what is under the pointer, else what the overlay overlaps. */\r\nexport const pointerFirst: CollisionDetection = (args) => {\r\n const within = pointerWithin(args);\r\n return within.length ? within : rectIntersection(args);\r\n};\r\n\r\n// ─── Stability (rfcs/0001-v3.md §6) ────────────────────────────────────────────\r\n\r\n/** Pointer travel (px) before a target that was just left can win again. */\r\nexport const HYSTERESIS = 10;\r\n\r\nexport interface StabilizeContext {\r\n pointer: Coordinates;\r\n /** Current target. */\r\n previous: Key | null;\r\n /** Best target of this frame by the collision detection. */\r\n next: Key | null;\r\n /** The target can still be kept (mounted, enabled, visible). */\r\n isValid(id: Key): boolean;\r\n /** The pointer is over `parent`, between the drop targets nested in it, one of which is `child`. */\r\n isGap(parent: Key, child: Key): boolean;\r\n /** Input without jitter (keyboard): no hysteresis. */\r\n exact?: boolean;\r\n}\r\n\r\n/**\r\n * Damps target switches:\r\n * - a target that was just left can't win again until the pointer has moved\r\n * `HYSTERESIS` px from where it was left: boundaries don't flicker, and a layout\r\n * shift after a cross-list move can't bounce the item back;\r\n * - between nested targets the last one is kept: the gaps of a parent zone don't\r\n * flash the parent.\r\n */\r\nexport function createTargetStabilizer() {\r\n let recent: { id: Key; point: Coordinates } | null = null;\r\n\r\n return {\r\n /** Forgets the hysteresis, e.g. after a scroll moved the content under the pointer. */\r\n reset() {\r\n recent = null;\r\n },\r\n resolve(context: StabilizeContext): Key | null {\r\n const { pointer, previous, next } = context;\r\n if (recent && distance(pointer, recent.point) >= HYSTERESIS) recent = null;\r\n if (next === previous) return next;\r\n if (previous != null && context.isValid(previous)) {\r\n if (next != null && context.isGap(next, previous)) return previous;\r\n if (!context.exact && recent?.id === next) return previous;\r\n } else if (previous == null && !context.exact && recent?.id === next) {\r\n return null;\r\n }\r\n if (previous != null) recent = { id: previous, point: pointer };\r\n return next;\r\n },\r\n };\r\n}\r\n\r\nexport type TargetStabilizer = ReturnType<typeof createTargetStabilizer>;\r\n","/**\r\n * Target detection: the drop target a point of the drag is over. Candidates are the\r\n * enabled, connected targets the integration rules let in, never one in a dragged item;\r\n * hit-testing and the provider's `collision` rank them, and the stabilizer damps the\r\n * switches between them (rfcs/0001-v3.md §6).\r\n */\r\n\r\nimport type { Active, CollisionCandidate, Coordinates, Key, Over, Rect } from '../../types';\r\nimport { containsPoint, unionRect } from '../../animation/layout';\r\nimport { createTargetStabilizer, pointerFirst } from '../collision';\r\nimport { containsComposed, elementBelow, elementFromPoint, parentOf } from '../../utils/dom';\r\nimport type { DroppableEntry } from './registry';\r\nimport type { ManagerContext } from './state';\r\n\r\nexport type Detection = ReturnType<typeof createDetection>;\r\n\r\nexport function createDetection(ctx: ManagerContext) {\r\n const stabilizer = createTargetStabilizer();\r\n /** Nesting depth of drop target elements among drop targets, per session. */\r\n let nesting = new WeakMap<Element, number>();\r\n /** Drop target elements in a dragged item or in a slot one lands in, per session. */\r\n let owned = new WeakMap<Element, boolean>();\r\n\r\n /**\r\n * Drop targets under the point: the topmost element (shadow roots included) and its\r\n * flat-tree ancestors. Higher priority first, then the deepest.\r\n */\r\n const hitTest = (point: Coordinates, byElement: Map<Element, DroppableEntry>, current: Active): Key[] => {\r\n const hits: DroppableEntry[] = [];\r\n let top = elementFromPoint(point.x, point.y);\r\n // A drag without an overlay moves the element itself under the pointer: look through it.\r\n if (top && current.element.isConnected && containsComposed(current.element, top)) {\r\n top = elementBelow(point.x, point.y, current.element);\r\n }\r\n ctx.pointerElement = point.x === ctx.raw.x && point.y === ctx.raw.y ? top : null;\r\n for (let element = top; element; element = parentOf(element)) {\r\n const entry = byElement.get(element);\r\n if (entry) hits.push(entry);\r\n }\r\n return hits\r\n .map((entry, depth) => ({ id: entry.id, priority: entry.getPriority(), depth }))\r\n .sort((a, b) => b.priority - a.priority || a.depth - b.depth)\r\n .map(({ id }) => id);\r\n };\r\n\r\n const depthOf = (element: Element, byElement: Map<Element, DroppableEntry>): number => {\r\n let depth = nesting.get(element);\r\n if (depth === undefined) {\r\n depth = 0;\r\n for (let parent = parentOf(element); parent; parent = parentOf(parent)) {\r\n if (byElement.has(parent)) {\r\n depth = depthOf(parent, byElement) + 1;\r\n break;\r\n }\r\n }\r\n nesting.set(element, depth);\r\n }\r\n return depth;\r\n };\r\n\r\n /**\r\n * Never drop items into themselves: a target in (or on) any dragged item, or in a slot\r\n * one lands in (a copy, a created item), is out for the whole drag.\r\n */\r\n const isOwned = (element: Element, current: Active): boolean => {\r\n let own = owned.get(element);\r\n if (own === undefined) {\r\n own = false;\r\n for (let node: Element | null = element; node && !own; node = parentOf(node)) {\r\n const id = ctx.draggableIds.get(node);\r\n own =\r\n id != null &&\r\n (current.ids.includes(id) ||\r\n id === ctx.landingKey.value ||\r\n ctx.landings.value.has(id) ||\r\n // A slot an earlier drop is still landing on: hidden until it has.\r\n ctx.flights.value.some((flight) => flight.slot === id || flight.landings.has(id)));\r\n }\r\n owned.set(element, own);\r\n }\r\n return own;\r\n };\r\n\r\n const detectOver = (current: Active, point: Coordinates): Over | null => {\r\n const { droppables, measurer } = ctx;\r\n const candidates: CollisionCandidate[] = [];\r\n // Every target that could be one (nesting depth), and the ones the rules let in now.\r\n const all = new Map<Element, DroppableEntry>();\r\n const byElement = new Map<Element, DroppableEntry>();\r\n const elements = new Map<Key, HTMLElement>();\r\n // A drag from outside the page is for the targets that take such drags only (`external`).\r\n const external = !!current.external && !current.external.group;\r\n for (const entry of droppables.values()) {\r\n if (entry.isDisabled() || (external && !entry.getExternal?.())) continue;\r\n const element = entry.getElement();\r\n if (!element?.isConnected || isOwned(element, current)) continue;\r\n all.set(element, entry);\r\n let hidden = false;\r\n for (const rule of ctx.targetRules) hidden ||= !rule(entry, element, point, current);\r\n if (hidden) continue;\r\n byElement.set(element, entry);\r\n elements.set(entry.id, element);\r\n measurer.observe(element);\r\n }\r\n for (const [element, entry] of byElement) {\r\n // Fully clipped by a scroll container or the viewport: not hittable.\r\n const rect = measurer.measureVisible(element);\r\n if (rect) {\r\n candidates.push({ id: entry.id, rect, priority: entry.getPriority(), depth: depthOf(element, all) });\r\n }\r\n }\r\n const hits = hitTest(point, byElement, current);\r\n const detect = ctx.props.collision ?? pointerFirst;\r\n const ranked = detect({\r\n pointer: point,\r\n overlayRect: ctx.overlay.getOverlayRect(current, ctx.transform.value),\r\n candidates,\r\n hits,\r\n });\r\n\r\n const visible = new Set<Key>(hits);\r\n for (const candidate of candidates) visible.add(candidate.id);\r\n const id = stabilizer.resolve({\r\n pointer: point,\r\n previous: ctx.over.value?.id ?? null,\r\n next: ranked.find((key) => elements.has(key)) ?? null,\r\n exact: current.sensor === 'keyboard',\r\n isValid: (key) => visible.has(key),\r\n isGap: (parent, child) => {\r\n const parentElement = elements.get(parent)!;\r\n const childElement = elements.get(child);\r\n if (!childElement || parentElement === childElement) return false;\r\n if (!containsComposed(parentElement, childElement)) return false;\r\n // The pointer is within the bounds of the targets nested in `parent`, but over none.\r\n let bounds: Rect | null = null;\r\n for (const candidate of candidates) {\r\n const element = elements.get(candidate.id)!;\r\n if (element === parentElement || !containsComposed(parentElement, element)) continue;\r\n if (containsPoint(candidate.rect, point)) return false;\r\n bounds = bounds ? unionRect(bounds, candidate.rect) : candidate.rect;\r\n }\r\n return !!bounds && containsPoint(bounds, point);\r\n },\r\n });\r\n if (id == null) return null;\r\n const entry = droppables.get(id)!;\r\n const element = elements.get(id)!;\r\n return {\r\n id,\r\n data: entry.getData(),\r\n label: entry.getLabel?.(),\r\n element,\r\n rect: measurer.measure(element),\r\n accepted: entry.accepts(current),\r\n };\r\n };\r\n\r\n return {\r\n detectOver,\r\n isOwned,\r\n /** Damps target switches; `reset()` forgets the hysteresis (scrolling moved the content). */\r\n stabilizer,\r\n /** A new session: nesting and ownership are cached per drag. */\r\n begin() {\r\n stabilizer.reset();\r\n nesting = new WeakMap();\r\n owned = new WeakMap();\r\n },\r\n };\r\n}\r\n","/**\r\n * Haptic feedback for touch drags (`haptics` option): a short vibration when the long\r\n * press turns into a drag, and on request when the drag enters an accepting target, drops\r\n * or is refused. Only drags started by touch vibrate. Browsers without\r\n * `navigator.vibrate` (iOS Safari) do nothing, and nothing is tried before the user has\r\n * interacted with the page: the browser would block it and log a warning.\r\n */\r\n\r\nimport type { HapticPattern, HapticsOptions } from '../types';\r\n\r\nexport type HapticEvent = keyof HapticsOptions;\r\n\r\n/** What `true` stands for. */\r\nconst DEFAULT_PATTERNS: Record<HapticEvent, number | number[]> = {\r\n start: 10,\r\n enter: 10,\r\n drop: 10,\r\n refuse: [20, 40, 20],\r\n};\r\n\r\n/** The vibration for `event` under the provider's `haptics` option; `null`: none. */\r\nexport const resolveHaptic = (\r\n option: boolean | HapticsOptions | undefined,\r\n event: HapticEvent,\r\n): number | number[] | null => {\r\n if (option === false) return null;\r\n const byDefault = event === 'start';\r\n const value: HapticPattern = typeof option === 'object' ? (option[event] ?? byDefault) : byDefault;\r\n if (value === true) return DEFAULT_PATTERNS[event];\r\n if (value === false || value === 0 || (Array.isArray(value) && !value.length)) return null;\r\n return value;\r\n};\r\n\r\n/** Vibrates for `event` of a drag (see the module comment); `touch`: the drag was started by touch. */\r\nexport const vibrate = (option: boolean | HapticsOptions | undefined, event: HapticEvent, touch: boolean): void => {\r\n if (!touch || typeof navigator === 'undefined' || typeof navigator.vibrate !== 'function') return;\r\n // Blocked without a tap on the page so far (Chromium logs an intervention).\r\n if (navigator.userActivation && !navigator.userActivation.hasBeenActive) return;\r\n const pattern = resolveHaptic(option, event);\r\n if (pattern === null) return;\r\n try {\r\n navigator.vibrate(pattern);\r\n } catch {\r\n // Some embedders throw instead of ignoring it.\r\n }\r\n};\r\n","/**\r\n * The frame loop of a drag: at most once per animation frame it applies the modifiers\r\n * to the pointer, moves the overlay box, detects the target and tells the target, the\r\n * monitors and the live region.\r\n */\r\n\r\nimport { nextTick } from 'vue';\r\nimport type { Coordinates } from '../../types';\r\nimport type { ManagerContext } from './state';\r\nimport { vibrate } from '../haptics';\r\n\r\nexport type FrameLoop = ReturnType<typeof createFrameLoop>;\r\n\r\nconst samePoint = (a: Coordinates, b: Coordinates | null) => !!b && a.x === b.x && a.y === b.y;\r\n\r\nexport function createFrameLoop(ctx: ManagerContext) {\r\n let frame = 0;\r\n /** Pointer of the last target detection (after modifiers), and the pointer as reported then. */\r\n let detectedAt: Coordinates | null = null;\r\n let detectedRaw: Coordinates | null = null;\r\n /** Scroll, resize or an external request since the last frame: detect even if the pointer stood still. */\r\n let refreshRequested = false;\r\n\r\n const runFrame = () => {\r\n frame = 0;\r\n const current = ctx.active.value;\r\n if (ctx.status.value !== 'dragging' || !current) return;\r\n const { overlay, origin, raw } = ctx;\r\n // Reorders render between frames: the slot may have moved into another list.\r\n overlay.updateFitSize(current);\r\n overlay.stepResize();\r\n const refresh = refreshRequested;\r\n refreshRequested = false;\r\n const offset = overlay.applyModifiers(current, { x: raw.x - origin.x, y: raw.y - origin.y });\r\n const point = { x: origin.x + offset.x, y: origin.y + offset.y };\r\n // A modifier moved the point off the pointer (it may hold it while the pointer moves on).\r\n if (point.x !== raw.x || point.y !== raw.y) ctx.pointerElement = null;\r\n\r\n // The target follows the pointer, scrolling and resizing, never a layout shift\r\n // alone: a frame where none of them changed (a repeated pointermove) does nothing.\r\n // A point a modifier holds still (at the edge of a box) runs on while the pointer\r\n // moves: lists project from the pointer there (`sortable/modes/sort.ts`).\r\n if (!refresh && detectedAt && samePoint(point, detectedAt) && samePoint(raw, detectedRaw)) return;\r\n // The first detection of the drag: the target found under the item at pickup isn't news.\r\n const pickup = !detectedAt;\r\n detectedAt = point;\r\n detectedRaw = { x: raw.x, y: raw.y };\r\n ctx.transform.value = offset;\r\n ctx.pointer.value = point;\r\n ctx.measurer.nextFrame();\r\n // Scrolling moves the content under the pointer: the hysteresis, which measures\r\n // pointer travel, no longer applies.\r\n if (refresh) ctx.detection.stabilizer.reset();\r\n\r\n const previous = ctx.over.value;\r\n const next = ctx.detection.detectOver(current, point);\r\n const changed = previous?.id !== next?.id || previous?.accepted !== next?.accepted;\r\n if (changed) ctx.over.value = next;\r\n else if (previous && next) previous.rect = next.rect;\r\n\r\n const { events } = ctx;\r\n const event = events.createEvent();\r\n if (changed) {\r\n if (previous) ctx.droppables.get(previous.id)?.onDragLeave?.(event);\r\n if (next) ctx.droppables.get(next.id)?.onDragEnter?.(event);\r\n events.emit('onDragOver', event);\r\n if (!pickup) {\r\n events.announce('onDragOver', event);\r\n if (next?.accepted) vibrate(ctx.props.haptics, 'enter', ctx.touch);\r\n }\r\n }\r\n events.emit('onDragMove', event);\r\n // The move may have reordered (sortable): fit the slot once that rendered, even if\r\n // the pointer stops here and no further frame runs.\r\n void nextTick(() => {\r\n if (ctx.status.value === 'dragging' && ctx.active.value === current) overlay.updateFitSize(current);\r\n });\r\n };\r\n\r\n const requestFrame = () => {\r\n if (!frame && ctx.status.value === 'dragging') frame = requestAnimationFrame(runFrame);\r\n };\r\n\r\n return {\r\n runFrame,\r\n requestFrame,\r\n /** Re-detects the target on the next frame even if the pointer stands still (scroll, resize). */\r\n scheduleFrame() {\r\n if (ctx.status.value !== 'dragging') return;\r\n refreshRequested = true;\r\n requestFrame();\r\n },\r\n /** Runs a pending frame now. Without one, the target is already up to date. */\r\n flushFrame() {\r\n if (!frame) return;\r\n cancelAnimationFrame(frame);\r\n runFrame();\r\n },\r\n /** Drops the pending frame. */\r\n cancel() {\r\n if (frame) cancelAnimationFrame(frame);\r\n frame = 0;\r\n },\r\n /** A new session (or none): its first detection is the pickup's. */\r\n reset() {\r\n detectedAt = null;\r\n detectedRaw = null;\r\n refreshRequested = false;\r\n },\r\n };\r\n}\r\n","import type { AnimationOptions, DropAnimation, DropAnimationContext, Rect } from '../types';\r\nimport { STALL_MARGIN, canAnimate, getCenter, prefersReducedMotion, resolveAnimation, settle } from './layout';\r\n\r\nexport const DEFAULT_DROP_ANIMATION: Required<AnimationOptions> = {\r\n duration: 250,\r\n easing: 'ease',\r\n};\r\n\r\n/** Scale at which an overlay going `into` a zone vanishes, centered on it. */\r\nconst INTO_SCALE = 0.25;\r\n\r\n/** Time between the clones of a multi-drag going into a zone, one after another; the box goes last. */\r\nconst INTO_STAGGER = 60;\r\n/** However many go in, the last one starts within this. */\r\nconst INTO_SPREAD = 360;\r\n\r\n/** The delay between `count` clones going into a zone (and the box after them). */\r\nexport const intoStagger = (count: number): number => Math.min(INTO_STAGGER, INTO_SPREAD / (count + 1));\r\n\r\n/** The longest a drop waits for the overlay's content to finish animating. */\r\nconst CONTENT_WAIT = 2000;\r\n\r\n/**\r\n * Finite animations running inside the overlay box as it lands: CSS animations and\r\n * transitions an overlay component starts on `dropping` (a splash, a settle), the\r\n * crossfade of `overlayTransition`. The drop ends when they do, at most `CONTENT_WAIT`\r\n * later. The box's own landing, finished animations and endless loops don't count.\r\n */\r\nexport const contentAnimations = (overlay: HTMLElement): Promise<void> => {\r\n const running = (overlay.getAnimations?.({ subtree: true }) ?? []).filter((animation) => {\r\n if (animation.playState === 'finished' || animation.playState === 'idle') return false;\r\n const effect = animation.effect as KeyframeEffect | null;\r\n if (!effect || effect.target === overlay) return false;\r\n return Number.isFinite(effect.getComputedTiming().endTime);\r\n });\r\n if (!running.length) return Promise.resolve();\r\n let timer: ReturnType<typeof setTimeout> | undefined;\r\n return Promise.race([\r\n // A cancelled animation rejects `finished`: it ended all the same.\r\n Promise.allSettled(running.map((animation) => animation.finished)),\r\n new Promise<void>((resolve) => (timer = setTimeout(resolve, CONTENT_WAIT))),\r\n ]).then(() => clearTimeout(timer));\r\n};\r\n\r\n/**\r\n * Flies the overlay to the final rect of the dropped item, or fades it out when the\r\n * item isn't rendered: shrinking into the zone it was dropped `into`, else in place.\r\n * A landing animates the size as width/height, not `scale()`: the content re-lays out\r\n * at the target size instead of being stretched.\r\n */\r\nexport const runDropAnimation = async (\r\n option: DropAnimation | undefined,\r\n context: Omit<DropAnimationContext, 'options' | 'reducedMotion'>,\r\n /** The default animation starts this late: after the clones going in before it. */\r\n delay = 0,\r\n): Promise<void> => {\r\n const resolved = resolveAnimation(option, DEFAULT_DROP_ANIMATION);\r\n if (!resolved) return;\r\n const full: DropAnimationContext = { ...context, options: resolved.options, reducedMotion: prefersReducedMotion() };\r\n if (resolved.custom) return settle(resolved.custom(full), resolved.options.duration + STALL_MARGIN);\r\n const { overlay, from, to, into } = context;\r\n if (!canAnimate(overlay)) return;\r\n\r\n // Into a zone: scaled around its center (the overlay's transform origin is its corner).\r\n const end = into && getCenter(into);\r\n const keyframes: Keyframe[] = to\r\n ? [\r\n {\r\n transform: `translate3d(${from.left}px, ${from.top}px, 0)`,\r\n width: `${from.width}px`,\r\n height: `${from.height}px`,\r\n },\r\n {\r\n transform: `translate3d(${to.left}px, ${to.top}px, 0)`,\r\n width: `${to.width}px`,\r\n height: `${to.height}px`,\r\n },\r\n ]\r\n : [\r\n { opacity: 1, transform: `translate3d(${from.left}px, ${from.top}px, 0)` },\r\n {\r\n opacity: 0,\r\n transform: end\r\n ? `translate3d(${end.x - (from.width * INTO_SCALE) / 2}px, ${end.y - (from.height * INTO_SCALE) / 2}px, 0) scale(${INTO_SCALE})`\r\n : `translate3d(${from.left}px, ${from.top}px, 0) scale(0.96)`,\r\n },\r\n ];\r\n await settle(\r\n overlay.animate(keyframes, { ...resolved.options, delay, fill: 'both' }),\r\n delay + resolved.options.duration + STALL_MARGIN,\r\n );\r\n};\r\n\r\n/**\r\n * Timing for what the library animates along with the drop. A custom `dropAnimation`\r\n * moves the overlay box itself; the rest then uses the default timing, and nothing\r\n * moves when reduced motion is preferred (custom hooks skip that check).\r\n */\r\nconst companionTiming = (option: DropAnimation | undefined): Required<AnimationOptions> | null => {\r\n const resolved = resolveAnimation(option, DEFAULT_DROP_ANIMATION);\r\n if (!resolved || (resolved.custom && prefersReducedMotion())) return null;\r\n return resolved.options;\r\n};\r\n\r\nexport interface OverlayItemLanding {\r\n /**\r\n * A clone riding in the overlay box: a cell of the default column, or a `DragPreview`\r\n * of a custom layout, which may be turned or scaled by its wrappers' `transform`.\r\n */\r\n element: HTMLElement;\r\n /** Where it is now (viewport): its bounding box. */\r\n from: Rect;\r\n /** Final rect of its item; `null` when it isn't visible (the clone fades out). */\r\n to: Rect | null;\r\n}\r\n\r\n/**\r\n * A keyframe placing the clone by `matrix` around its top left corner: the translation\r\n * in pixels, then the turn (and any scale its wrappers give it).\r\n */\r\nconst frame = ({ a, b, c, d, e, f }: DOMMatrix, width: string, height: string, opacity = 1): Keyframe => ({\r\n transformOrigin: '0 0',\r\n transform: `translate(${e}px, ${f}px) matrix(${a}, ${b}, ${c}, ${d}, 0, 0)`,\r\n width,\r\n height,\r\n opacity,\r\n});\r\n\r\n/**\r\n * Where a clone with the bounding box `rect` is: the turn and scale of its wrappers inside\r\n * the overlay (`linear`), its own transform around its top left corner, and that corner\r\n * (viewport) without it.\r\n */\r\nconst placeOf = (element: HTMLElement, overlay: Element | null, rect: Rect = element.getBoundingClientRect()) => {\r\n let linear = new DOMMatrix();\r\n for (let node = element.parentElement; node && node !== overlay; node = node.parentElement) {\r\n linear = new DOMMatrix(getComputedStyle(node).transform).multiply(linear);\r\n }\r\n linear.e = linear.f = 0;\r\n const style = getComputedStyle(element);\r\n const [x = 0, y = 0] = style.transformOrigin.split(' ').map(parseFloat);\r\n const own = new DOMMatrix().translate(x, y).multiply(new DOMMatrix(style.transform)).translate(-x, -y);\r\n // The bounding box starts at the leftmost and topmost corner of the turned box.\r\n const { a, b, c, d, e, f } = linear.multiply(own);\r\n const { offsetWidth: w, offsetHeight: h } = element;\r\n return {\r\n linear,\r\n own,\r\n x: rect.left - e - Math.min(0, a * w) - Math.min(0, c * h),\r\n y: rect.top - f - Math.min(0, b * w) - Math.min(0, d * h),\r\n width: style.width,\r\n height: style.height,\r\n };\r\n};\r\n\r\n/**\r\n * Multi-drag: the clones of the other items ride inside the overlay box, which flies\r\n * from `box.from` to `box.to`. Each one animates relative to the box with the box's\r\n * timing, so position and box add up to a straight flight that ends exactly on its\r\n * slot, its wrappers' turn undone on the way. Width and height animate, never\r\n * `scale()` (see `runDropAnimation`).\r\n */\r\nexport const landOverlayItems = async (\r\n option: DropAnimation | undefined,\r\n items: OverlayItemLanding[],\r\n box: { from: Rect; to: Rect | null },\r\n): Promise<void> => {\r\n const timing = items.length ? companionTiming(option) : null;\r\n if (!timing) return;\r\n const { from } = box;\r\n // A box that fades out stays where it is.\r\n const end = box.to ?? from;\r\n const overlay = items[0]!.element.closest<HTMLElement>('[data-dnd-overlay]');\r\n const places = items.map(({ element, from: rect }) => placeOf(element, overlay, rect));\r\n // A layout that follows the box's size (a custom one) is measured at the size the box lands\r\n // with: `!important` wins over the box's animation, which holds the size it starts from.\r\n let landed = places;\r\n if (overlay && (end.width !== from.width || end.height !== from.height)) {\r\n const { style } = overlay;\r\n const { width, height } = style;\r\n style.setProperty('width', `${end.width}px`, 'important');\r\n style.setProperty('height', `${end.height}px`, 'important');\r\n landed = items.map(({ element }) => placeOf(element, overlay));\r\n style.width = width;\r\n style.height = height;\r\n }\r\n await Promise.all(\r\n items.map(({ element, to }, index) => {\r\n if (!canAnimate(element)) return undefined;\r\n const { linear, own, width, height } = places[index]!;\r\n // The box carries the corner to where it is at the landing size, moved by the box's\r\n // flight; from there the clone goes to the slot, its wrappers' turn undone.\r\n const corner = landed[index]!;\r\n const finish = to\r\n ? frame(\r\n linear.inverse().translate(to.left - corner.x - end.left + from.left, to.top - corner.y - end.top + from.top),\r\n `${to.width}px`,\r\n `${to.height}px`,\r\n )\r\n : frame(own, width, height, 0);\r\n return settle(\r\n element.animate([frame(own, width, height), finish], { ...timing, fill: 'forwards' }),\r\n timing.duration + STALL_MARGIN,\r\n );\r\n }),\r\n );\r\n};\r\n\r\n/**\r\n * A multi-drag dropped into a zone (a folder, a trash can): the clones of the other items\r\n * in the overlay fly into the zone's middle one after another, shrinking as they fade, as\r\n * if each went in on its own. The box goes after them (`intoStagger`, see `runDropAnimation`).\r\n */\r\nexport const intoOverlayItems = async (option: DropAnimation | undefined, clones: HTMLElement[], into: Rect): Promise<void> => {\r\n const timing = clones.length ? companionTiming(option) : null;\r\n if (!timing) return;\r\n const overlay = clones[0]!.closest('[data-dnd-overlay]');\r\n const center = getCenter(into);\r\n const step = intoStagger(clones.length);\r\n await Promise.all(\r\n clones.map((element, index) => {\r\n if (!canAnimate(element)) return undefined;\r\n const rect = element.getBoundingClientRect();\r\n // The way to the zone's middle, in the clone's own terms: its wrappers may turn it.\r\n const { linear } = placeOf(element, overlay, rect);\r\n const way = linear.inverse().transformPoint({\r\n x: center.x - (rect.left + rect.width / 2),\r\n y: center.y - (rect.top + rect.height / 2),\r\n });\r\n const own = getComputedStyle(element).transform;\r\n const base = own === 'none' ? '' : own;\r\n const delay = index * step;\r\n return settle(\r\n element.animate(\r\n [\r\n { transform: base || 'none', opacity: 1 },\r\n { transform: `translate(${way.x}px, ${way.y}px) ${base} scale(${INTO_SCALE})`, opacity: 0 },\r\n ],\r\n { ...timing, delay, fill: 'both' },\r\n ),\r\n delay + timing.duration + STALL_MARGIN,\r\n );\r\n }),\r\n );\r\n};\r\n\r\n/**\r\n * Dragged items without a clone in the overlay (past `overlayPreviews`, custom overlays) fade in\r\n * where they are during the drop: from their placeholder opacity, or from nothing when the\r\n * page styles placeholders another way (hidden content at full opacity). Read while they\r\n * are still marked. The animations hold full opacity until the caller cancels them.\r\n */\r\nexport const fadeInPlace = (option: DropAnimation | undefined, elements: HTMLElement[]): Animation[] => {\r\n const timing = elements.length ? companionTiming(option) : null;\r\n if (!timing) return [];\r\n // Reads first, then writes.\r\n const opacities = elements.map((element) => {\r\n const { opacity } = getComputedStyle(element);\r\n return opacity === '1' && element.hasAttribute('data-dnd-placeholder') ? '0' : opacity;\r\n });\r\n return elements.flatMap((element, index) => {\r\n const opacity = opacities[index]!;\r\n if (!canAnimate(element) || opacity === '1' || opacity === '') return [];\r\n return [element.animate([{ opacity }, { opacity: 1 }], { ...timing, fill: 'forwards' })];\r\n });\r\n};\r\n","/**\r\n * The styles a provider injects, once per document, when it mounts: those drags rely on\r\n * always, and the looks unless `defaultStyles` is `false`.\r\n * `:where()` keeps specificity at zero, so any user CSS overrides them. The looks\r\n * (opacity) sit in the cascade layer `vue-dnd-kit`, first in the document, so layered\r\n * CSS (Tailwind v4 utilities, UI kits) overrides them too.\r\n * While dragging, `<html>` gets `data-dnd-dragging` instead of inline body styles,\r\n * so nothing the page set inline is ever overwritten.\r\n */\r\n\r\nconst BEHAVIOR_ID = 'vue-dnd-kit-behavior';\r\nconst LOOKS_ID = 'vue-dnd-kit-styles';\r\n\r\n// No text selection while dragging, and no scroll anchoring: a virtual list's rows\r\n// re-measured mid-drag would shift the page under the pointer.\r\n// A touch drag starts (200ms) before iOS shows its link callout and magnifier (~500ms),\r\n// and WebKit reads `-webkit-touch-callout` when it recognises that long press.\r\n// The `!important` rules stay out of any layer: in one, they would beat the page's own.\r\n// `--dnd-cursor`: the grabbed element's own cursor (`dragCursor`), else the page's, else `grabbing`.\r\nconst BEHAVIOR = `\r\n:where(html[data-dnd-dragging]),\r\n:where(html[data-dnd-dragging] *) { user-select: none !important; -webkit-user-select: none !important; overflow-anchor: none !important; }\r\n:where(html[data-dnd-dragging=\"pointer\"]),\r\n:where(html[data-dnd-dragging=\"pointer\"] *) { cursor: var(--dnd-cursor, grabbing) !important; -webkit-touch-callout: none !important; }\r\n`;\r\n\r\n// `[data-dnd-dragging]` on an item: dragged along but left in place (multi-drag 'gaps').\r\n// <html> carries the same attribute for the whole drag, hence `:not(html)`.\r\nconst LOOKS = `\r\n@layer vue-dnd-kit {\r\n :where([data-dnd-placeholder]) { opacity: 0.4; }\r\n :where([data-dnd-dragging]:not(html)) { opacity: 0.4; }\r\n}\r\n`;\r\n\r\nconst inject = (id: string, css: string) => {\r\n if (document.getElementById(id)) return;\r\n const style = document.createElement('style');\r\n style.id = id;\r\n style.textContent = css;\r\n // First: the layer is declared before the page's, which makes it the weakest.\r\n document.head.prepend(style);\r\n};\r\n\r\n/** The behaviour drags need, always; the looks (`looks`: the provider's `defaultStyles`) too. */\r\nexport const injectDefaultStyles = (looks: boolean): void => {\r\n if (typeof document === 'undefined') return;\r\n inject(BEHAVIOR_ID, BEHAVIOR);\r\n if (looks) inject(LOOKS_ID, LOOKS);\r\n};\r\n\r\n/**\r\n * Cursors that only say \"press here\": a drag shows `grabbing` instead. Any other (a resize\r\n * handle's `ns-resize`, `move`, an image) is the grabbed element's own and stays.\r\n */\r\nconst PRESS_CURSORS = new Set(['auto', 'default', 'pointer', 'text', 'vertical-text', 'grab', '-webkit-grab', 'help', 'context-menu', 'cell']);\r\n\r\n/** The cursor a pointer drag of `grabbed` keeps: its own, or `null` when it only said \"press here\". */\r\nexport const dragCursor = (grabbed: Element): string | null => {\r\n const { cursor } = getComputedStyle(grabbed);\r\n return !cursor || PRESS_CURSORS.has(cursor) ? null : cursor;\r\n};\r\n\r\n/** Marks the document as dragging (with `cursor`, a pointer drag's: see `dragCursor`); returns the restore function. */\r\nexport const markDocumentDragging = (sensor: 'pointer' | 'keyboard', cursor: string | null = null): (() => void) => {\r\n const root = document.documentElement;\r\n root.setAttribute('data-dnd-dragging', sensor);\r\n if (cursor) root.style.setProperty('--dnd-cursor', cursor);\r\n document.getSelection()?.removeAllRanges();\r\n const preventSelection = (event: Event) => event.preventDefault();\r\n document.addEventListener('selectstart', preventSelection);\r\n return () => {\r\n root.removeAttribute('data-dnd-dragging');\r\n if (cursor && root.style.getPropertyValue('--dnd-cursor') === cursor) root.style.removeProperty('--dnd-cursor');\r\n document.removeEventListener('selectstart', preventSelection);\r\n };\r\n};\r\n","import type { BeforeDropResult, Key } from '../types';\r\n\r\n/** An `onBeforeDrop` answer as the drop reads it: nothing is no say, the words are booleans. */\r\nexport type Verdict = boolean | Key[] | 'continue' | undefined;\r\n\r\n/** `'accept'` is `true`, `'reject'` is `false`; ids and `'continue'` stay as they are. */\r\nexport const toVerdict = (value: BeforeDropResult): Verdict =>\r\n value === 'accept' ? true : value === 'reject' ? false : (value ?? undefined);\r\n\r\n/** The answer ends the asking: no drop at all, or a drag that goes on. */\r\nexport const isFinal = (verdict: Verdict): verdict is false | 'continue' => verdict === false || verdict === 'continue';\r\n","/**\r\n * Keeps a dropped overlay box on what it lands on. The box is `position: fixed`: when\r\n * that moves while the drop is decided or lands (the page or a container scrolls, the\r\n * layout shifts), the box moves with it, by its `translate`, on top of the `transform` the\r\n * drop animation moves. The flight then ends on the slot where it is now.\r\n *\r\n * A layout change (another drag reorders the list) moves the anchor where it settles at\r\n * once, and its layout animation (FLIP) slides it there from where it was: the box slides\r\n * along with it, rather than jump. The layout animations that moved the anchor when the box\r\n * began to follow are the drop animation's: it already lands where they end.\r\n */\r\n\r\nimport type { Coordinates, Rect } from '../../types';\r\nimport { getRect, layoutShifts, offsetRect } from '../../animation/layout';\r\n\r\nexport type Follow = ReturnType<typeof createFollow>;\r\n\r\n/** Hundredths of a pixel: a layout animation's last frames leave dust that moves nothing. */\r\nconst round = (value: number) => Math.round(value * 100) / 100;\r\n\r\n/** `getBox`: the box to move, read when it moves. */\r\nexport function createFollow(getBox: () => HTMLElement | null) {\r\n let anchor: Element | null = null;\r\n /** Where the anchor settled when the box began to follow it. */\r\n let start: Rect | null = null;\r\n /**\r\n * The part of each layout animation of the anchor the box slides along with, per axis:\r\n * none of the first ones; of a later one, what the layout change it animates moved.\r\n */\r\n let shares = new WeakMap<object, Coordinates>();\r\n /** The anchor's layout animations last frame: how far each had it moved. */\r\n let last = new Map<object, Coordinates>();\r\n /** Frames a new layout animation was seen that hadn't moved the anchor yet. */\r\n let unstarted = new WeakMap<object, number>();\r\n /** How far the box has moved with the anchor: its `translate`. */\r\n let shift: Coordinates | null = null;\r\n let frame = 0;\r\n\r\n const place = (next: Coordinates | null) => {\r\n shift = next;\r\n // On the element, not through its rendered style: re-rendering that would write back\r\n // the `transform` and size an animation library (GSAP, motion) moves inline.\r\n const box = getBox();\r\n if (box) box.style.translate = next ? `${next.x}px ${next.y}px` : '';\r\n };\r\n\r\n /**\r\n * Where the anchor settles, and how far its layout animations still have to slide the\r\n * box; `null` for a frame a new one hasn't moved the anchor yet (an animation library may\r\n * start a frame late): what it carries is only known once it has.\r\n */\r\n const measure = () => {\r\n const shifts = layoutShifts(anchor!);\r\n // Where the animations that ended or were replaced since last frame left the anchor. A\r\n // new one that still shows just that hasn't moved it yet: a library may stop the old\r\n // animation a frame before the new one writes its first frame (motion).\r\n let left = { x: 0, y: 0 };\r\n for (const [animation, offset] of last) {\r\n if (!shifts.some((entry) => entry.animation === animation)) left = { x: left.x + offset.x, y: left.y + offset.y };\r\n }\r\n const leftover = (offset: Coordinates) =>\r\n (left.x || left.y) && Math.abs(offset.x - left.x) <= 1 && Math.abs(offset.y - left.y) <= 1;\r\n for (const { animation, offset } of shifts) {\r\n if (shares.has(animation) || ((offset.x || offset.y) && !leftover(offset))) continue;\r\n const frames = (unstarted.get(animation) ?? 0) + 1;\r\n unstarted.set(animation, frames);\r\n // A library under load may take a few frames. One that never moves it (a hook\r\n // animating something else) counts after four.\r\n if (frames <= 4) return null;\r\n }\r\n // What the animations that ended or were replaced since last frame still had to go and\r\n // wasn't the box's: a new animation starts from where they left the anchor.\r\n let carried = { x: 0, y: 0 };\r\n for (const [animation, offset] of last) {\r\n if (shifts.some((entry) => entry.animation === animation)) continue;\r\n const share = shares.get(animation) ?? { x: 0, y: 0 };\r\n carried = { x: carried.x + offset.x * (1 - share.x), y: carried.y + offset.y * (1 - share.y) };\r\n }\r\n last = new Map();\r\n let all = { x: 0, y: 0 };\r\n let pending = { x: 0, y: 0 };\r\n for (const { animation, offset } of shifts) {\r\n last.set(animation, offset);\r\n all = { x: all.x + offset.x, y: all.y + offset.y };\r\n let share = shares.get(animation);\r\n if (!share) {\r\n const part = (value: number, from: number) => (value ? (value - from) / value : 0);\r\n share = { x: part(offset.x, carried.x), y: part(offset.y, carried.y) };\r\n carried = { x: 0, y: 0 };\r\n shares.set(animation, share);\r\n }\r\n pending = { x: pending.x + offset.x * share.x, y: pending.y + offset.y * share.y };\r\n }\r\n return { settled: offsetRect(getRect(anchor!), -all.x, -all.y), pending };\r\n };\r\n\r\n // Every frame rather than on scroll events: a layout shift moves the anchor too.\r\n const step = () => {\r\n frame = 0;\r\n // An anchor that went away (a virtual row scrolled off) leaves the box where it got to.\r\n if (!anchor?.isConnected || !start) return;\r\n const measured = measure();\r\n // The box waits where it is: the anchor's slide starts next frame.\r\n if (!measured) {\r\n if (shift) place(shift);\r\n frame = requestAnimationFrame(step);\r\n return;\r\n }\r\n const { settled, pending } = measured;\r\n const x = round(settled.left - start.left + pending.x);\r\n const y = round(settled.top - start.top + pending.y);\r\n // Written every frame it is moved: a re-render of the box's style clears it.\r\n const moved = x !== 0 || y !== 0;\r\n if (moved || shift) place(moved ? { x, y } : null);\r\n frame = requestAnimationFrame(step);\r\n };\r\n\r\n const halt = () => {\r\n if (frame) cancelAnimationFrame(frame);\r\n frame = 0;\r\n anchor = start = null;\r\n shares = new WeakMap();\r\n last = new Map();\r\n unstarted = new WeakMap();\r\n };\r\n\r\n return {\r\n /** The box follows `element` from now on, from where it is; `null`: it stays there. */\r\n follow(element: Element | null) {\r\n halt();\r\n place(null);\r\n anchor = element?.isConnected ? element : null;\r\n if (!anchor) return;\r\n // The layout animations moving it now: the drop animation lands where they end.\r\n for (const { animation } of layoutShifts(anchor)) shares.set(animation, { x: 0, y: 0 });\r\n start = measure()!.settled;\r\n frame = requestAnimationFrame(step);\r\n },\r\n /** Stops following and takes the shift off the box: what it was, for its new place. */\r\n take(): Coordinates | null {\r\n const taken = shift;\r\n halt();\r\n place(null);\r\n return taken;\r\n },\r\n /** Stops following, the shift with it. */\r\n stop() {\r\n halt();\r\n place(null);\r\n },\r\n };\r\n}\r\n","/**\r\n * A drag session from start to end. `start` takes the active item and its overlay, puts\r\n * the page into drag mode and runs the first frame; `move` feeds the pointer to the frame\r\n * loop. At the end the drop is decided (`onBeforeDrop`) and committed, or the drag is\r\n * cancelled. The drag then hands its overlay to a flight (`Flight`), which lands it while\r\n * the next drag may already start, and settles once it has landed (`onDragSettle`).\r\n */\r\n\r\nimport { nextTick, type Component } from 'vue';\r\nimport type {\r\n Active,\r\n Coordinates,\r\n DnDEndEvent,\r\n DnDEvent,\r\n DnDStatus,\r\n DragItem,\r\n DropAnimation,\r\n DropDestination,\r\n ExternalData,\r\n Key,\r\n Rect,\r\n SensorType,\r\n} from '../../types';\r\nimport { containsPoint, getLayoutRect, getRect, getSettledRect, offsetRect } from '../../animation/layout';\r\nimport {\r\n contentAnimations,\r\n fadeInPlace,\r\n intoOverlayItems,\r\n intoStagger,\r\n landOverlayItems,\r\n runDropAnimation,\r\n type OverlayItemLanding,\r\n} from '../../animation/drop';\r\nimport { isFocusLost, nextFrame } from '../../utils/dom';\r\nimport { dragCursor, markDocumentDragging } from '../styles';\r\nimport { vibrate } from '../haptics';\r\nimport { isFinal, toVerdict, type Verdict } from '../verdict';\r\nimport { NO_LANDINGS, type Flight, type ManagerContext } from './state';\r\nimport { createFollow } from './follow';\r\n\r\n/** Frames a keyboard drag's item has to take the focus back after the drop. */\r\nconst FOCUS_FRAMES = 10;\r\n\r\nexport function createSession(ctx: ManagerContext) {\r\n /** Counts drags: the overlay keys a drag's box by it, and an awaited step of an older one does nothing. */\r\n let session = 0;\r\n /** Keeps the overlay on the target it was dropped on while `onBeforeDrop` decides. */\r\n const waiting = createFollow(() => ctx.overlayElement.value);\r\n /** Where the drop would go as the drag was released (the overlay's `to`). */\r\n let releasedTo: DropDestination | null = null;\r\n /** The target's overlay as the drag was released: the drop lands showing it, whatever `onDrop` changes. */\r\n let releasedTarget: Component | undefined;\r\n /** The cursor of the running pointer drag (`dragCursor`), kept through a resume. */\r\n let cursor: string | null = null;\r\n const targetOverlay = (): Component | undefined => {\r\n const over = ctx.over.value;\r\n return over?.accepted ? ctx.droppables.get(over.id)?.getOverlay?.() : undefined;\r\n };\r\n\r\n const restoreDocument = () => {\r\n ctx.restoreDocument?.();\r\n ctx.restoreDocument = null;\r\n };\r\n\r\n /** What the status rests at without a drag: `'dropping'` while an overlay still lands. */\r\n const restStatus = (): DnDStatus => (ctx.flights.value.length ? 'dropping' : 'idle');\r\n\r\n /** No drag runs, none is deciding its drop: a new one may start (landings don't count). */\r\n const isAtRest = (): boolean => {\r\n const status = ctx.status.value;\r\n return status === 'idle' || (status === 'dropping' && !ctx.active.value);\r\n };\r\n\r\n // ─── Start ───────────────────────────────────────────────────────────────────\r\n\r\n const buildItems = (ids: Key[]): DragItem[] =>\r\n ids.map((id) => {\r\n const entry = ctx.draggables.get(id);\r\n return {\r\n id,\r\n item: entry?.getItem?.(),\r\n data: entry?.getData(),\r\n label: entry?.getLabel?.(),\r\n type: entry?.getTypes() ?? [],\r\n };\r\n });\r\n\r\n /** Lets integrations (sortable) fix up the active item, e.g. multi-drag ids from unmounted rows. */\r\n const updateActive = (patch: Partial<Pick<Active, 'ids' | 'items'>>) => {\r\n if (ctx.active.value) ctx.active.value = { ...ctx.active.value, ...patch };\r\n };\r\n\r\n /**\r\n * Starts a drag of `id` from `coordinates` (sensors: `SensorContext.activate`); `touch`:\r\n * started by touch. `browser`: the browser's own drag (`native/bridge.ts`), with no\r\n * overlay; a drag from outside the page brings its items and what it carries.\r\n */\r\n const start = (\r\n id: Key,\r\n coordinates: Coordinates,\r\n sensor: SensorType,\r\n touch = false,\r\n browser?: { items?: DragItem[]; external?: ExternalData },\r\n ): boolean => {\r\n // One drag at a time, and none while a drop is still being decided. Landings don't\r\n // hold the next drag back.\r\n if (ctx.active.value || ctx.status.value === 'selecting') return false;\r\n const entry = ctx.draggables.get(id);\r\n const element = entry?.getElement();\r\n if (!entry || !element || entry.isDisabled()) return false;\r\n\r\n session++;\r\n // Caught in flight: an item whose overlay still lands. Its landing ends where the box\r\n // is, and the drag goes on from there with its clones (its slots are still hidden).\r\n const caught = ctx.flights.value.find((flight) => flight.active.ids.includes(id));\r\n let caughtAt = caught?.element?.isConnected ? getRect(caught.element) : null;\r\n // A keyboard drag is held at its item, not under a pointer: it goes on from the box\r\n // only where the box is over the item, else from the item as any pickup.\r\n if (caughtAt && sensor !== 'pointer' && !containsPoint(caughtAt, coordinates)) caughtAt = null;\r\n if (caught) land(caught);\r\n const ids = browser?.items\r\n ? browser.items.map((item) => item.id)\r\n : ctx.selection.has(id) && ctx.selection.size > 1\r\n ? [id, ...[...ctx.selection].filter((key) => key !== id)]\r\n : [id];\r\n const items = browser?.items ?? buildItems(ids);\r\n const modifiers = entry.getModifiers?.() ?? [];\r\n ctx.droppedOutside = undefined;\r\n ctx.overlay.pickUp(id, entry, caught?.previews, !!browser);\r\n ctx.overlayColumn.value = null;\r\n ctx.landings.value = NO_LANDINGS;\r\n ctx.overlayItems.clear();\r\n ctx.active.value = {\r\n id,\r\n ids,\r\n items,\r\n data: items[0]!.data,\r\n label: items[0]!.label,\r\n type: items[0]!.type,\r\n element,\r\n rect: getLayoutRect(element),\r\n sensor,\r\n ...(browser && { native: true, external: browser.external }),\r\n };\r\n const container = entry.getContainer?.() ?? element.parentElement;\r\n ctx.origin = coordinates;\r\n ctx.touch = touch;\r\n ctx.raw = coordinates;\r\n ctx.pointer.value = coordinates;\r\n ctx.transform.value = { x: 0, y: 0 };\r\n ctx.over.value = null;\r\n ctx.overlay.place(ctx.active.value, coordinates, modifiers, container, caughtAt);\r\n ctx.mode.value = 'move';\r\n ctx.landingKey.value = null;\r\n ctx.activationProgress.value = 1;\r\n ctx.measurer.begin();\r\n ctx.detection.begin();\r\n ctx.loop.reset();\r\n ctx.status.value = 'dragging';\r\n if (sensor === 'pointer' && !browser) {\r\n // What the pointer grabbed: the element under it (a handle, a part of it) shows its cursor.\r\n const hit = document.elementFromPoint(coordinates.x, coordinates.y);\r\n cursor = dragCursor(hit && element.contains(hit) ? hit : element);\r\n } else {\r\n cursor = null;\r\n }\r\n ctx.restoreDocument = markDocumentDragging(sensor, cursor);\r\n\r\n const event = ctx.events.createEvent();\r\n ctx.events.emit('onDragStart', event);\r\n if (ctx.overlay.enabled && ctx.active.value) ctx.overlay.takePreviews(ctx.active.value);\r\n ctx.events.announce('onDragStart', event);\r\n vibrate(ctx.props.haptics, 'start', touch);\r\n ctx.loop.runFrame();\r\n return true;\r\n };\r\n\r\n const move = (coordinates: Coordinates) => {\r\n ctx.raw = coordinates;\r\n ctx.loop.requestFrame();\r\n };\r\n\r\n // ─── End ─────────────────────────────────────────────────────────────────────\r\n\r\n /**\r\n * Gives focus back to the dragged item after a keyboard drag. Looked up by id once\r\n * the result has rendered: moving between lists recreates the element, and the old\r\n * one took the focus with it. Focus the user moved elsewhere is left alone.\r\n */\r\n const restoreFocus = (id: Key) => {\r\n const attempt = () => {\r\n const target = ctx.draggables.get(id)?.getFocusTarget();\r\n if (!target?.isConnected) return false;\r\n if (!isFocusLost()) return true;\r\n target.focus({ preventScroll: true });\r\n // A target that can't take the focus yet (still hidden as the slot) is tried again.\r\n return document.activeElement === target;\r\n };\r\n void nextTick(() => {\r\n // Virtualizers may mount the row a frame later; a slot may stay hidden a few frames.\r\n let frames = 0;\r\n const retry = () => {\r\n if (!attempt() && ++frames < FOCUS_FRAMES) requestAnimationFrame(retry);\r\n };\r\n retry();\r\n });\r\n };\r\n\r\n /** The drag is over: its state goes, the page leaves drag mode. Its flight, if any, lands on. */\r\n const clear = () => {\r\n restoreDocument();\r\n waiting.stop();\r\n ctx.loop.cancel();\r\n ctx.measurer.end();\r\n ctx.loop.reset();\r\n ctx.pointerElement = null;\r\n ctx.active.value = null;\r\n ctx.over.value = null;\r\n ctx.pointer.value = null;\r\n ctx.transform.value = { x: 0, y: 0 };\r\n ctx.overlay.end();\r\n // The box, if it lands, is its flight's now.\r\n ctx.overlayElement.value = null;\r\n ctx.mode.value = 'move';\r\n ctx.landingKey.value = null;\r\n ctx.landings.value = NO_LANDINGS;\r\n ctx.overlayColumn.value = null;\r\n ctx.overlayItems.clear();\r\n ctx.activationProgress.value = 0;\r\n ctx.outside.value = false;\r\n ctx.status.value = restStatus();\r\n };\r\n\r\n /**\r\n * The drop is decided (or the drag cancelled): the drag hands its overlay to a flight,\r\n * which lands it, and clears its state, so the next drag can start at once. The box\r\n * stays where it was left, moved by what it followed while the drop was decided.\r\n */\r\n const handOff = (reason: 'drop' | 'cancel', event: DnDEvent): Flight => {\r\n const current = event.active;\r\n const shift = waiting.take();\r\n const box = ctx.overlay.getOverlayRect(current, ctx.transform.value);\r\n const over = reason === 'drop' ? event.over : null;\r\n const mode = ctx.mode.value;\r\n const landingKey = ctx.landingKey.value;\r\n const flight: Flight = {\r\n id: session,\r\n reason,\r\n event,\r\n active: current,\r\n mode,\r\n over,\r\n to: releasedTo,\r\n landingKey,\r\n // A copy that found no slot leaves the original as it is.\r\n slot: landingKey ?? (mode === 'copy' ? null : current.id),\r\n landings: ctx.landings.value,\r\n column: ctx.overlayColumn.value,\r\n ...ctx.overlay.release(),\r\n target: over?.accepted ? releasedTarget : undefined,\r\n rect: shift ? offsetRect(box, shift.x, shift.y) : box,\r\n items: new Map(ctx.overlayItems),\r\n element: ctx.overlay.enabled ? ctx.overlayElement.value : null,\r\n follow: createFollow(() => flight.element),\r\n released: new Set(),\r\n fades: [],\r\n done: false,\r\n };\r\n releasedTo = null;\r\n releasedTarget = undefined;\r\n ctx.flights.value = [...ctx.flights.value, flight];\r\n clear();\r\n return flight;\r\n };\r\n\r\n /** A flight has landed: its slots show, the focus comes back after a keyboard drag. */\r\n const land = (flight: Flight) => {\r\n if (flight.done) return;\r\n flight.done = true;\r\n flight.follow.stop();\r\n if (flight.active.sensor === 'keyboard') restoreFocus(flight.active.id);\r\n ctx.flights.value = ctx.flights.value.filter((entry) => entry !== flight);\r\n // A drag that started meanwhile has its own status.\r\n if (ctx.status.value === 'dropping' && !ctx.active.value) ctx.status.value = restStatus();\r\n // Faded-in items keep full opacity until their placeholder marks are gone (post-flush).\r\n const faded = flight.fades;\r\n flight.fades = [];\r\n if (faded.length) void nextTick(() => faded.forEach((animation) => animation.cancel()));\r\n ctx.events.emit('onDragSettle', flight.event);\r\n };\r\n\r\n /**\r\n * Where a dragged item lands, if its slot is rendered and can be seen: virtualizers\r\n * keep overscan rows mounted outside the scroller, and the slot may be scrolled away.\r\n * Measured where the slot will settle: in a nested list it may still be sliding with\r\n * an ancestor (the item of the outer list that holds it).\r\n */\r\n const landingRect = (target: Element | null | undefined): Rect | null => {\r\n const to = target?.isConnected ? getSettledRect(target) : null;\r\n return to && to.width > 0 && ctx.measurer.measureVisible(target!) ? to : null;\r\n };\r\n\r\n /** The clones of the other dragged items riding in a flight's box, in drop order. */\r\n const clonesOf = (flight: Flight): HTMLElement[] => {\r\n const current = flight.active;\r\n return current.ids.flatMap((id) => {\r\n const clone = id === current.id ? null : flight.items.get(id);\r\n return clone?.isConnected ? [clone] : [];\r\n });\r\n };\r\n\r\n /**\r\n * Multi-drag: the overlay's clones of the other items (the column's cells, a pile's, a\r\n * custom layout's `DragPreview`s) land on their own slots with the box; items without a\r\n * clone (past `overlayPreviews`, custom overlays) show at once and fade in where they\r\n * are, instead of waiting as placeholders and popping when the drop ends. Into a zone,\r\n * the clones go in one after another, the box after them; the items still shown fade\r\n * in where they are.\r\n */\r\n const landItems = (\r\n flight: Flight,\r\n animation: DropAnimation | undefined,\r\n box: { from: Rect; to: Rect | null },\r\n into: Rect | null,\r\n ): Promise<void> => {\r\n const current = flight.active;\r\n if (current.ids.length < 2) return Promise.resolve();\r\n const slotOf = new Map<Key, Key>();\r\n for (const [slot, id] of flight.landings) slotOf.set(id, slot);\r\n const elementOf = (id: Key) => {\r\n const element = ctx.draggables.get(slotOf.get(id) ?? id)?.getElement();\r\n return element?.isConnected ? element : null;\r\n };\r\n const items: OverlayItemLanding[] = [];\r\n const resting: HTMLElement[] = [];\r\n const released = new Set<Key>();\r\n for (const id of current.ids) {\r\n if (id === current.id) continue;\r\n const clone = flight.items.get(id);\r\n const target = elementOf(id);\r\n if (into || !clone?.isConnected) {\r\n if (target) resting.push(target);\r\n released.add(id);\r\n continue;\r\n }\r\n const to = landingRect(target);\r\n items.push({ element: clone, from: getRect(clone), to });\r\n }\r\n // Read while they are still placeholders: a placeholder styled by the page (its content\r\n // hidden, a tint) fades in from nothing.\r\n flight.fades = fadeInPlace(animation, resting);\r\n if (released.size) {\r\n flight.released = released;\r\n flight.landings = new Map([...flight.landings].filter(([, id]) => !released.has(id)));\r\n ctx.flights.value = [...ctx.flights.value];\r\n }\r\n if (into) return intoOverlayItems(animation, clonesOf(flight), into);\r\n return (flight.column?.land ?? landOverlayItems)(animation, items, box);\r\n };\r\n\r\n /**\r\n * How a flight lands: the drop target's own `dropAnimation` (a zone's, a list's\r\n * `overDropAnimation`), else the dragged item's (its list's), else the provider's.\r\n * `false` counts: it is someone's choice of no animation.\r\n */\r\n const dropAnimationOf = (flight: Flight): DropAnimation | undefined => {\r\n const { over } = flight;\r\n const target = over ? ctx.droppables.get(over.id)?.getDropAnimation?.() : undefined;\r\n return target ?? flight.dropAnimation ?? ctx.props.dropAnimation;\r\n };\r\n\r\n /** Hands the overlay to a flight, plays its drop or return animation, then settles it. */\r\n const finish = async (reason: 'drop' | 'cancel', event: DnDEvent) => {\r\n const flight = handOff(reason, event);\r\n const overlay = flight.element;\r\n if (overlay) {\r\n // Measure the target after the commit has rendered, then once more a frame\r\n // later: virtualizers may re-measure rows with a ResizeObserver in between.\r\n await nextTick();\r\n await nextFrame();\r\n if (flight.done) return;\r\n const current = flight.active;\r\n // Copies and created items land on their own row, not on the dragged one.\r\n const target = ctx.draggables.get(flight.landingKey ?? current.id)?.getElement();\r\n // The commit changed the layout since the last frame: read afresh.\r\n ctx.measurer.invalidate();\r\n ctx.measurer.nextFrame();\r\n // Fly only to a slot that can be seen, otherwise fade out.\r\n const landing = landingRect(target);\r\n const from = getRect(overlay);\r\n // Shown nowhere after a drop on a zone (not a list: an item dropped into a folder,\r\n // a trash zone): the overlay goes into the zone. Otherwise it fades where it is.\r\n const zone = landing || reason !== 'drop' ? null : event.over;\r\n const into =\r\n (zone?.element.isConnected && !ctx.droppables.get(zone.id)?.sortable && ctx.measurer.measureVisible(zone.element)) ||\r\n null;\r\n const { over } = flight;\r\n // While it lands, the box stays on where it goes (the slot, the zone), else on what\r\n // it was dropped on: scrolling the page mid-flight doesn't send it astray.\r\n const anchor = landing ? target! : into ? zone!.element : over?.element;\r\n flight.follow.follow(anchor ?? null);\r\n const animation = dropAnimationOf(flight);\r\n // Into a zone, the box goes in after the clones it carries, one after another.\r\n const going = into ? clonesOf(flight).length : 0;\r\n // The overlay's content may animate its own landing (a splash on `dropping`): the\r\n // drop ends when that does too.\r\n await Promise.all([\r\n runDropAnimation(animation, { overlay, from, to: landing, into, reason, active: current, over }, going * intoStagger(going)),\r\n landItems(flight, animation, { from, to: landing }, into),\r\n contentAnimations(overlay),\r\n ]);\r\n if (flight.done) return;\r\n }\r\n land(flight);\r\n };\r\n\r\n /** Tells the monitors and the live region how the drag ended, then lands the overlay. */\r\n const conclude = (name: 'onDragEnd' | 'onDragCancel', event: DnDEvent) => {\r\n ctx.events.emit(name, event);\r\n ctx.events.announce(name, event);\r\n return finish(name === 'onDragEnd' ? 'drop' : 'cancel', event);\r\n };\r\n\r\n /** Aborts a press that is still activating, or a running rubber band: `true` if there was one. */\r\n const abortPending = (): boolean => {\r\n const { value } = ctx.status;\r\n const aborts = value === 'activating' ? ctx.activationAborts : value === 'selecting' ? ctx.selectionAborts : null;\r\n aborts?.forEach((abort) => abort());\r\n return !!aborts;\r\n };\r\n\r\n const cancel = () => {\r\n if (abortPending() || ctx.status.value !== 'dragging' || !ctx.active.value) return;\r\n releasedTo = ctx.getDestination();\r\n void conclude('onDragCancel', ctx.events.createEvent());\r\n };\r\n\r\n /**\r\n * `onBeforeDrop` answered `'continue'`: nothing dropped, and the drag goes on from where\r\n * it stood, the page back in drag mode. The sensor takes it up again (`onResume`): a\r\n * pointer moves it without a button, and its next release drops.\r\n */\r\n const resume = (event: DnDEvent) => {\r\n // The overlay follows the pointer again.\r\n waiting.stop();\r\n ctx.status.value = 'dragging';\r\n ctx.restoreDocument = markDocumentDragging(event.active.sensor, cursor);\r\n ctx.events.emit('onDragResume', event);\r\n ctx.events.announce('onDragResume', event);\r\n // Where the pointer is now: the user may have moved it during the wait.\r\n ctx.loop.scheduleFrame();\r\n };\r\n\r\n const drop = async () => {\r\n if (ctx.status.value !== 'dragging' || !ctx.active.value) return;\r\n ctx.loop.flushFrame();\r\n releasedTo = ctx.getDestination();\r\n releasedTarget = targetOverlay();\r\n const id = session;\r\n ctx.status.value = 'dropping';\r\n // `onBeforeDrop` may wait for the user (a confirmation dialog): the page stops being\r\n // in drag mode now, with its own cursor and text selection. The drag state and the\r\n // overlay stay as they are until the drop is decided.\r\n restoreDocument();\r\n const event = ctx.events.createEvent();\r\n // Measured now: the handlers below may change the page before anyone reads it.\r\n void event.position;\r\n const target = event.over;\r\n // While `onBeforeDrop` decides (a confirmation may take a while), the overlay stays on\r\n // the target it was dropped on, wherever the page scrolls.\r\n if (ctx.overlay.enabled) waiting.follow(target?.element ?? null);\r\n\r\n let verdict: Verdict = true;\r\n try {\r\n // The user's monitors decide first: a list may apply a controlled drop's result in\r\n // its own `onBeforeDrop`, and a veto after that would strand the applied result.\r\n for (const monitor of ctx.events.orderMonitors(false)) {\r\n const result = toVerdict(await monitor.onBeforeDrop?.(event));\r\n if (isFinal(result)) {\r\n verdict = result;\r\n break;\r\n }\r\n if (Array.isArray(result)) verdict = result;\r\n }\r\n if (!isFinal(verdict) && target?.accepted) {\r\n const result = toVerdict(await ctx.droppables.get(target.id)?.onBeforeDrop?.(event));\r\n if (isFinal(result) || Array.isArray(result)) verdict = result;\r\n }\r\n } catch (error) {\r\n console.error(error);\r\n verdict = false;\r\n }\r\n if (id !== session) return;\r\n\r\n if (verdict === 'continue') return resume(event);\r\n if (verdict === false || (target && !target.accepted)) {\r\n vibrate(ctx.props.haptics, 'refuse', ctx.touch);\r\n return conclude('onDragCancel', event);\r\n }\r\n\r\n const accepted = Array.isArray(verdict) ? verdict : event.active.ids;\r\n const endEvent: DnDEndEvent = {\r\n ...event,\r\n dropped: !!target,\r\n accepted,\r\n rejected: event.active.ids.filter((id) => !accepted.includes(id)),\r\n ...(ctx.droppedOutside && { droppedOutside: ctx.droppedOutside }),\r\n };\r\n // The target is told what it takes: a partial accept leaves the others out.\r\n if (target) {\r\n try {\r\n ctx.droppables.get(target.id)?.onDrop?.(endEvent);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n vibrate(ctx.props.haptics, 'drop', ctx.touch);\r\n return conclude('onDragEnd', endEvent);\r\n };\r\n\r\n /**\r\n * A drag out of the page (`native`) was dropped somewhere else (`effect`): the drop is\r\n * over no target here. A move takes the items out of their sortable list (as a trash\r\n * zone's `e.source.remove()`); a copy or a link leaves them. `'none'`: it was cancelled.\r\n */\r\n const endOutside = (effect: 'move' | 'copy' | 'link' | 'none') => {\r\n const current = ctx.active.value;\r\n if (ctx.status.value !== 'dragging' || !current) return;\r\n if (effect === 'none') return cancel();\r\n ctx.loop.flushFrame();\r\n ctx.droppedOutside = effect;\r\n ctx.over.value = null;\r\n if (effect === 'move') {\r\n for (const resolve of ctx.sourceResolvers) {\r\n const source = resolve(current);\r\n if (source) {\r\n source.remove();\r\n break;\r\n }\r\n }\r\n }\r\n return drop();\r\n };\r\n\r\n const destroy = () => {\r\n abortPending();\r\n const current = ctx.active.value;\r\n // A running drag ends, also one whose drop `onBeforeDrop` was still deciding: its answer\r\n // comes to nothing (`session` moves on below), so this is its one terminal event.\r\n if (current) ctx.events.emit('onDragCancel', ctx.events.createEvent());\r\n // An awaited drop of it, and the landings, do nothing more.\r\n session++;\r\n for (const flight of ctx.flights.value) {\r\n flight.done = true;\r\n flight.follow.stop();\r\n }\r\n ctx.flights.value = [];\r\n if (current) clear();\r\n ctx.events.stopAnnouncing();\r\n };\r\n\r\n return {\r\n updateActive,\r\n start,\r\n move,\r\n drop,\r\n cancel,\r\n endOutside,\r\n destroy,\r\n restStatus,\r\n isAtRest,\r\n /** The current (or last) drag's number: the overlay keys its box by it. */\r\n sessionId: () => session,\r\n };\r\n}\r\n","/**\r\n * The drag session state machine: idle → activating → dragging → dropping → idle,\r\n * plus idle → selecting → idle while a selection area draws its rubber band.\r\n *\r\n * Invariants (rfcs/0001-v3.md §13):\r\n * - one session per provider; input during `dropping` is ignored;\r\n * - every exit path (drop, reject, cancel, callback error, provider unmount)\r\n * restores the document and emits exactly one terminal event;\r\n * - items are identified by id, never by element: elements may be recreated mid-drag.\r\n *\r\n * `createDnDManager` composes the modules of this folder around one `ManagerContext`\r\n * (`state.ts`): the registry, events and announcements, the overlay, target detection,\r\n * the frame loop and the session itself.\r\n */\r\n\r\nimport type { Coordinates, DnDProviderProps, Key } from '../../types';\r\nimport { getRect } from '../../animation/layout';\r\nimport { createMeasurer } from '../measure';\r\n// In the order the modules build on each other.\r\nimport { createDragState, type ManagerContext } from './state';\r\nimport { createRegistry } from './registry';\r\nimport { createEvents } from './events';\r\nimport { createOverlay } from './overlay';\r\nimport { createDetection } from './detection';\r\nimport { createFrameLoop } from './frame';\r\nimport { createSession } from './session';\r\n\r\nexport type { AreaEntry, AutoScrollEntry, DraggableEntry, DroppableEntry, IntegrationMonitor, TargetRule } from './registry';\r\nexport type { Flight, OverlayColumn } from './state';\r\nexport type { PreviewSource } from './overlay';\r\n\r\nexport type DnDManager = ReturnType<typeof createDnDManager>;\r\n\r\nexport function createDnDManager(props: DnDProviderProps) {\r\n const state = createDragState();\r\n const { lookups, members } = createRegistry();\r\n // The modules are put in right below, before anything can call one (see `ManagerContext`).\r\n const ctx = {\r\n props,\r\n ...state,\r\n ...lookups,\r\n ...members,\r\n measurer: createMeasurer({ onShadowScroll: () => ctx.loop.scheduleFrame() }),\r\n origin: { x: 0, y: 0 },\r\n touch: false,\r\n raw: { x: 0, y: 0 },\r\n pointerElement: null,\r\n restoreDocument: null,\r\n } as ManagerContext;\r\n const events = (ctx.events = createEvents(ctx));\r\n const overlay = (ctx.overlay = createOverlay(ctx));\r\n const detection = (ctx.detection = createDetection(ctx));\r\n const loop = (ctx.loop = createFrameLoop(ctx));\r\n const { measurer } = ctx;\r\n\r\n // The getters below are read-only, though the spreads leave them writable in `DnDManager`.\r\n const manager = {\r\n props,\r\n ...state,\r\n instructionsId: '',\r\n // monitors, activationAborts, selectionAborts, getDraggable(s), getDroppable(s), registration\r\n ...members,\r\n /** Clone of a dragged item taken at pickup (`DragPreview`); none past `overlayPreviews` or for unrendered items. */\r\n getPreview: overlay.getPreview,\r\n /** Ids that have a clone, in drop order: what the default overlay's column shows. */\r\n get previewIds(): readonly Key[] {\r\n return overlay.previewIds;\r\n },\r\n get hasOverlay() {\r\n return overlay.enabled;\r\n },\r\n getModifiers: overlay.getModifiers,\r\n /** The dragged item's overlay component (its own, else its list's); `null`: slot or clone. */\r\n get overlayComponent() {\r\n return overlay.component;\r\n },\r\n /** Pointer position as the sensor reported it, before modifiers. */\r\n getRawPointer: (): Coordinates => ctx.raw,\r\n /**\r\n * Topmost element under the pointer at the last target detection (at most a frame\r\n * old); `null` when unknown, e.g. while a modifier moves the point off the pointer.\r\n */\r\n getPointerElement: (): Element | null => ctx.pointerElement,\r\n /** The overlay box for a drag offset, as the overlay, collision and modifiers see it. */\r\n getOverlayRect: overlay.getOverlayRect,\r\n /** The element is (in) a dragged item or a slot one lands in: never a drop target. */\r\n isOwned: detection.isOwned,\r\n /** A slot a landing overlay flies to: hidden (`data-dnd-placeholder`) until it is there. */\r\n isLanding: (key: Key): boolean => ctx.flights.value.some((flight) => flight.slot === key || flight.landings.has(key)),\r\n /** The flight landing this dragged item, if one is (and lands something on it). */\r\n flightOf: (id: Key) => ctx.flights.value.find((flight) => flight.active.ids.includes(id) && !flight.released.has(id)),\r\n /** The item of a landing box under `point`, the newest on top: a press there catches it in flight. */\r\n catchAt: (point: Coordinates): Key | null => {\r\n for (const flight of [...ctx.flights.value].reverse()) {\r\n const { element } = flight;\r\n if (!element?.isConnected || !ctx.draggables.has(flight.active.id)) continue;\r\n const rect = getRect(element);\r\n if (point.x >= rect.left && point.x <= rect.right && point.y >= rect.top && point.y <= rect.bottom) {\r\n return flight.active.id;\r\n }\r\n }\r\n return null;\r\n },\r\n /** A landing overlay carries this slot's item: its box, or a clone in it, flies there (FLIP leaves it alone). */\r\n isCarried: (key: Key): boolean =>\r\n ctx.flights.value.some(\r\n (flight) => key === (flight.landingKey ?? flight.active.id) || flight.items.has(flight.landings.get(key) ?? key),\r\n ),\r\n announce: events.announce,\r\n // updateActive, start, move, drop, cancel, endOutside, destroy\r\n ...createSession(ctx),\r\n /** The running drop is of a drag out of the page that something else took (`endOutside`). */\r\n getDroppedOutside: () => ctx.droppedOutside,\r\n scheduleFrame: loop.scheduleFrame,\r\n /** Runs the pending frame now (discrete keyboard moves need `pointer`/`over` updated at once). */\r\n flushFrame: loop.flushFrame,\r\n /** Layout rect without in-flight FLIP translates; cached during a drag, scroll-aware. */\r\n measure: measurer.measure,\r\n /** `measure()` clipped by scroll containers and the viewport; `null` when fully clipped. */\r\n measureVisible: measurer.measureVisible,\r\n /** Whether FLIP should animate the element (near its scroll container's visible area). */\r\n isNearViewport: measurer.isNearViewport,\r\n /** Call after layout changes the library caused (draft changes): cached rects go stale. */\r\n invalidateMeasurements: measurer.invalidate,\r\n };\r\n return manager;\r\n}\r\n","/**\r\n * Development only. While `onBeforeDrop` decides a drop, the provider takes no input\r\n * (rfcs/0001-v3.md §13): a new drag or a cancel asked for meanwhile does nothing. The\r\n * first one of each such drop says why: an `onBeforeDrop` whose promise never settles\r\n * would otherwise look like a provider that stopped working.\r\n */\r\n\r\nimport type { DnDManager } from './manager';\r\n\r\n/** Per provider, the drag (`sessionId`) whose decision has been told about. */\r\nconst told = new WeakMap<DnDManager, number>();\r\n\r\n/** `asked` did nothing: says why if a drop is being decided, once per drop. */\r\nexport const warnIfDeciding = (manager: DnDManager, asked: 'A new drag' | 'cancel()'): void => {\r\n const active = manager.active.value;\r\n if (manager.status.value !== 'dropping' || !active) return;\r\n const session = manager.sessionId();\r\n if (told.get(manager) === session) return;\r\n told.set(manager, session);\r\n console.warn(\r\n `[vue-dnd-kit] ${asked} does nothing while onBeforeDrop decides the drop of \"${String(active.id)}\": the provider takes no input until it answers. Make sure the promise it returns settles.`,\r\n );\r\n};\r\n","import {\r\n computed,\r\n inject,\r\n onScopeDispose,\r\n readonly,\r\n type App,\r\n type InjectionKey,\r\n} from 'vue';\r\nimport type { DnDContext, DnDMonitor, DnDSelection, DnDState, Key } from '../types';\r\nimport type { DnDManager } from './manager';\r\nimport { positionInTarget } from './manager/events';\r\nimport { warnIfDeciding } from './deciding';\r\n\r\n/** Bundlers replace it: development builds keep the warnings, production drops them. */\r\ndeclare const process: { env: { NODE_ENV?: string } };\r\n\r\nexport const DND_CONTEXT: InjectionKey<DnDManager> = Symbol('vue-dnd-kit');\r\n\r\n/** The provider's manager: what the library itself works with. */\r\nexport const useManager = (): DnDManager => {\r\n const manager = inject(DND_CONTEXT, null);\r\n if (!manager) {\r\n throw new Error('[vue-dnd-kit] No <DnDProvider> found above this component.');\r\n }\r\n return manager;\r\n};\r\n\r\n/**\r\n * The provider above this component, as an opaque handle for `provideDnDContext`: it\r\n * bridges the provider into shadow roots and separate Vue apps.\r\n */\r\nexport const useDnDContext = (): DnDContext => useManager() as unknown as DnDContext;\r\n\r\n/** Shares a provider (from `useDnDContext()`) with another Vue app, e.g. one mounted inside a shadow root. */\r\nexport const provideDnDContext = (app: App, context: DnDContext): void => {\r\n app.provide(DND_CONTEXT, context as unknown as DnDManager);\r\n};\r\n\r\n/** Id-based selection over the provider's reactive set: per-id updates, survives unmounts. */\r\nexport const createSelection = (set: Set<Key>): DnDSelection => ({\r\n get ids() {\r\n return set;\r\n },\r\n has: (id) => set.has(id),\r\n add: (...ids) => ids.forEach((id) => set.add(id)),\r\n delete: (...ids) => ids.forEach((id) => set.delete(id)),\r\n toggle: (id, force) => {\r\n if (force ?? !set.has(id)) set.add(id);\r\n else set.delete(id);\r\n },\r\n set: (ids) => {\r\n // Copy first: `ids` may be this very set (or a view of it).\r\n const next = new Set(ids);\r\n for (const id of [...set]) if (!next.has(id)) set.delete(id);\r\n for (const id of next) set.add(id);\r\n },\r\n clear: () => set.clear(),\r\n});\r\n\r\n/** Read-only drag state for custom UI (valid-target highlighting, spinners, progress). */\r\nexport const useDnD = (): DnDState => {\r\n const manager = useManager();\r\n return {\r\n status: readonly(manager.status),\r\n // A decided drop hands its overlay to a flight: the drag state is gone at once.\r\n active: readonly(manager.active) as DnDState['active'],\r\n over: readonly(manager.over) as DnDState['over'],\r\n pointer: readonly(manager.pointer),\r\n // Measured only for those who read it: an overlay component showing where it would land.\r\n position: computed(() => {\r\n const current = manager.active.value;\r\n const over = manager.over.value;\r\n if (!current || !over) return null;\r\n return positionInTarget(manager.getOverlayRect(current, manager.transform.value), over);\r\n }),\r\n activation: { progress: readonly(manager.activationProgress) },\r\n isAutoScrolling: readonly(manager.isAutoScrolling),\r\n selection: createSelection(manager.selection),\r\n cancel:\r\n process.env.NODE_ENV !== 'production'\r\n ? () => {\r\n warnIfDeciding(manager, 'cancel()');\r\n manager.cancel();\r\n }\r\n : manager.cancel,\r\n };\r\n};\r\n\r\n/** Subscribes to the events of every drag under the provider, for as long as the calling component (or effect scope) lives. */\r\nexport const useDnDMonitor = (monitor: DnDMonitor): void => {\r\n const manager = useManager();\r\n onScopeDispose(manager.addMonitor(monitor));\r\n};\r\n","/**\r\n * The devtools hook. The devtools bridge (`@vue-dnd-kit/core/devtools`, which the\r\n * `@vue-dnd-kit/devtools` plugin connects) puts it on `globalThis` before the app mounts,\r\n * and providers and sortable groups report to it as they are created, sensors as they\r\n * start a drag. Without it\r\n * nothing else runs; production builds drop the lookup.\r\n */\r\n\r\nimport type { Key, Sensor } from '../types';\r\nimport type { GroupContext } from '../sortable/context';\r\nimport type { DnDManager } from './manager';\r\n\r\n/** Bundlers replace it: development builds keep the hook, production drops it. */\r\ndeclare const process: { env: { NODE_ENV?: string } };\r\n\r\n/** What providers and sortable groups report (implemented by `devtools/index.ts`). */\r\nexport interface DevtoolsHook {\r\n /** A provider was set up; called in its `setup`, so the bridge can tell its app and unmount. */\r\n provider(manager: DnDManager): void;\r\n /** A sortable group was created on the provider `g.manager`. */\r\n group(g: GroupContext): void;\r\n /** A sensor's drag of `id` is about to start (`sensor` is missing for a drag it took over). */\r\n sensor(manager: DnDManager, id: Key, sensor: Sensor | undefined, touch: boolean): void;\r\n}\r\n\r\n/** The hook, while the devtools bridge is connected. */\r\nexport const devtoolsHook = (): DevtoolsHook | undefined =>\r\n process.env.NODE_ENV === 'production'\r\n ? undefined\r\n : (globalThis as { __VUE_DND_KIT_DEVTOOLS_HOOK__?: DevtoolsHook }).__VUE_DND_KIT_DEVTOOLS_HOOK__;\r\n","/**\r\n * The rules a press must pass before it becomes a drag (rfcs/0001-v3.md §10): where it\r\n * may start from, and the activation constraint it waits for. Every sensor gets them\r\n * from `SensorContext.activate()`.\r\n */\r\n\r\nimport type { ActivationConstraint, ActivationOptions, PointerKind, SensorActivation, SensorType } from '../../types';\r\nimport type { DraggableEntry } from '../manager';\r\nimport { isEditable, isInsideInteractive } from '../../utils/dom';\r\n\r\nconst DEFAULT_ACTIVATION: Record<PointerKind, ActivationConstraint> = {\r\n mouse: { distance: 4 },\r\n pen: { distance: 4 },\r\n touch: { delay: 200, tolerance: 5 },\r\n};\r\n\r\n/** Default `tolerance` of a delay without a distance. */\r\nconst DEFAULT_TOLERANCE = 5;\r\n\r\n/**\r\n * Activation constraint for a press: the item's option, then the provider's, then the\r\n * defaults (mouse/pen 4px, touch 200ms with 5px tolerance). A mouse press on an\r\n * explicit handle starts at once unless something was configured.\r\n */\r\nexport const resolveActivation = (\r\n kind: PointerKind,\r\n item: ActivationOptions | undefined,\r\n provider: ActivationOptions | undefined,\r\n onHandle: boolean,\r\n): ActivationConstraint =>\r\n item?.[kind] ?? provider?.[kind] ?? (onHandle && kind === 'mouse' ? {} : DEFAULT_ACTIVATION[kind]);\r\n\r\n/** The constraint a sensor asked for (`SensorActivation.activation`): none by default. */\r\nexport const resolveConstraint = (\r\n activation: SensorActivation['activation'],\r\n entry: DraggableEntry,\r\n provider: ActivationOptions | undefined,\r\n): ActivationConstraint =>\r\n typeof activation === 'string'\r\n ? resolveActivation(activation, entry.getActivation?.(), provider, entry.getHandle() != null)\r\n : (activation ?? {});\r\n\r\n/**\r\n * State of a pending activation after the pointer moved `distance` px in `elapsed` ms:\r\n * `'start'`, `'abort'` or the progress (0–1). Distance and delay have OR semantics,\r\n * whichever is met first; moving past `tolerance` while a delay runs aborts, so the\r\n * page can scroll. No constraint at all starts immediately.\r\n */\r\nexport const checkActivation = (\r\n constraint: ActivationConstraint,\r\n distance: number,\r\n elapsed: number,\r\n): 'start' | 'abort' | number => {\r\n const required = constraint.distance ?? 0;\r\n const delay = constraint.delay ?? 0;\r\n if (required <= 0 && delay <= 0) return 'start';\r\n if (required > 0 && distance >= required) return 'start';\r\n if (delay > 0) {\r\n if (elapsed >= delay) return 'start';\r\n const tolerance = constraint.tolerance ?? (required > 0 ? Infinity : DEFAULT_TOLERANCE);\r\n if (distance > tolerance) return 'abort';\r\n }\r\n return Math.min(\r\n Math.max(required > 0 ? distance / required : 0, delay > 0 ? elapsed / delay : 0),\r\n 1,\r\n );\r\n};\r\n\r\n/**\r\n * True when a drag of `type` may start from `target` inside the draggable `element`.\r\n * Pointer: on the handle, or anywhere but interactive children. Keyboard: only from the\r\n * draggable itself (or its handle), never from a button inside it or an editable field.\r\n */\r\nexport const canStartFrom = (entry: DraggableEntry, element: HTMLElement, target: Element, type: SensorType) => {\r\n if (type === 'keyboard') return !isEditable(target) && target === entry.getFocusTarget();\r\n const handle = entry.getHandle();\r\n if (handle) {\r\n const handleElement = typeof handle === 'string' ? target.closest(handle) : handle;\r\n return !!handleElement && handleElement.contains(target) && element.contains(handleElement);\r\n }\r\n return !isInsideInteractive(target, element);\r\n};\r\n","import { parentOf } from '../../utils/dom';\r\n\r\n/**\r\n * A pointer-like drag captures the pointer on <body> (the item may be recreated mid-drag):\r\n * from then on `mouseup` and `mouseleave` go to the capture target, and the pressed element\r\n * and its ancestors never see the pointer leave them. UI kits end their press and hover\r\n * effects on those events (Vuetify's ripple stays frozen in the item otherwise). The item\r\n * now travels in the overlay, away from the pointer: they are told so, as the browser would\r\n * have, from the pressed element up to the dragged item. Not beyond it: the pointer is\r\n * still over the list and the rest of the page (a menu opened by hovering must stay open).\r\n */\r\nexport const leavePressed = (pressed: Element, item: Element): void => {\r\n const chain: Element[] = [];\r\n for (let node: Element | null = pressed; node; node = parentOf(node)) {\r\n chain.push(node);\r\n if (node === item) break;\r\n }\r\n if (chain.at(-1) !== item) return;\r\n const init = { bubbles: true, composed: true, relatedTarget: document.body };\r\n const dispatch = (node: Element, type: string, bubbles: boolean) => {\r\n const Event = type.startsWith('pointer') && typeof PointerEvent === 'function' ? PointerEvent : MouseEvent;\r\n node.dispatchEvent(new Event(type, { ...init, bubbles }));\r\n };\r\n dispatch(pressed, 'pointerout', true);\r\n dispatch(pressed, 'mouseout', true);\r\n for (const node of chain) {\r\n dispatch(node, 'pointerleave', false);\r\n dispatch(node, 'mouseleave', false);\r\n }\r\n};\r\n","/**\r\n * Auto-scroll math (rfcs/0001-v3.md §11): edge zones, speeds, scroll intent and options.\r\n * Pure functions of numbers and rects; `dom.ts` measures, `loop.ts` runs them per frame.\r\n */\r\n\r\nimport type { AutoScrollOptions, Coordinates, Rect } from '../../types';\r\n\r\nexport interface Directions {\r\n up: boolean;\r\n down: boolean;\r\n left: boolean;\r\n right: boolean;\r\n}\r\n\r\nexport const DEFAULT_AUTO_SCROLL: Required<AutoScrollOptions> = {\r\n threshold: 0.2,\r\n maxSpeed: 25,\r\n acceleration: 10,\r\n};\r\n\r\nconst MIN_EDGE = 24;\r\nconst MAX_EDGE = 96;\r\n/** A pointer this far beside a container (across the scroll axis) still scrolls it. */\r\nconst CROSS_AXIS_TOLERANCE = 10;\r\n/** Pointer travel in px that unlocks a scroll direction. */\r\nconst INTENT_DISTANCE = 5;\r\n\r\n/** Edge zone for a container `size` px long: `threshold × size`, clamped to 24–96px and to half the size. */\r\nexport const getEdgeSize = (size: number, threshold: number): number =>\r\n threshold > 0 && size > 0\r\n ? Math.min(Math.max(threshold * size, MIN_EDGE), MAX_EDGE, size / 2)\r\n : 0;\r\n\r\n/**\r\n * Speed in px per frame for a pointer `depth` zones into the edge zone: 0 at its\r\n * inner border, 1 at the container edge, more beyond it. Quadratic inside the zone\r\n * for fine control, linear past the edge (same slope at 1), capped by `maxSpeed`.\r\n */\r\nexport const getEdgeSpeed = (\r\n depth: number,\r\n { acceleration, maxSpeed }: Required<AutoScrollOptions>,\r\n): number => {\r\n if (depth <= 0) return 0;\r\n const curve = depth <= 1 ? depth * depth : 2 * depth - 1;\r\n return Math.min(acceleration * curve, maxSpeed);\r\n};\r\n\r\nconst axisVelocity = (\r\n position: number,\r\n start: number,\r\n end: number,\r\n backward: boolean,\r\n forward: boolean,\r\n options: Required<AutoScrollOptions>,\r\n): number => {\r\n const edge = getEdgeSize(end - start, options.threshold);\r\n if (!edge) return 0;\r\n if (backward && position < start + edge) {\r\n return -getEdgeSpeed((start + edge - position) / edge, options);\r\n }\r\n if (forward && position > end - edge) {\r\n return getEdgeSpeed((position - end + edge) / edge, options);\r\n }\r\n return 0;\r\n};\r\n\r\n/**\r\n * Velocity in px per 60fps frame (negative: up/left) for a container whose visible\r\n * client area is `rect`. A direction needs room to scroll and the user's intent;\r\n * a pointer beside the container (past the cross-axis tolerance) doesn't scroll it.\r\n */\r\nexport const getScrollVelocity = (\r\n pointer: Coordinates,\r\n rect: Rect,\r\n canScroll: Directions,\r\n intent: Directions,\r\n options: Required<AutoScrollOptions>,\r\n): Coordinates => {\r\n const t = CROSS_AXIS_TOLERANCE;\r\n const besideX = pointer.x < rect.left - t || pointer.x > rect.right + t;\r\n const besideY = pointer.y < rect.top - t || pointer.y > rect.bottom + t;\r\n return {\r\n x: besideY\r\n ? 0\r\n : axisVelocity(\r\n pointer.x,\r\n rect.left,\r\n rect.right,\r\n canScroll.left && intent.left,\r\n canScroll.right && intent.right,\r\n options,\r\n ),\r\n y: besideX\r\n ? 0\r\n : axisVelocity(\r\n pointer.y,\r\n rect.top,\r\n rect.bottom,\r\n canScroll.up && intent.up,\r\n canScroll.down && intent.down,\r\n options,\r\n ),\r\n };\r\n};\r\n\r\nexport interface ScrollIntent {\r\n /** Extremes of the pointer since the drag started. */\r\n min: Coordinates;\r\n max: Coordinates;\r\n directions: Directions;\r\n}\r\n\r\nexport const createScrollIntent = (pointer: Coordinates): ScrollIntent => ({\r\n min: { ...pointer },\r\n max: { ...pointer },\r\n directions: { up: false, down: false, left: false, right: false },\r\n});\r\n\r\n/**\r\n * Unlocks a direction once the pointer has moved that way since the drag started,\r\n * so an item picked up near an edge doesn't scroll by itself. Directions stay unlocked.\r\n */\r\nexport const updateScrollIntent = (intent: ScrollIntent, pointer: Coordinates): Directions => {\r\n const { min, max, directions } = intent;\r\n if (pointer.y - min.y > INTENT_DISTANCE) directions.down = true;\r\n if (max.y - pointer.y > INTENT_DISTANCE) directions.up = true;\r\n if (pointer.x - min.x > INTENT_DISTANCE) directions.right = true;\r\n if (max.x - pointer.x > INTENT_DISTANCE) directions.left = true;\r\n min.x = Math.min(min.x, pointer.x);\r\n min.y = Math.min(min.y, pointer.y);\r\n max.x = Math.max(max.x, pointer.x);\r\n max.y = Math.max(max.y, pointer.y);\r\n return directions;\r\n};\r\n\r\nconst mergeOptions = (\r\n base: Required<AutoScrollOptions>,\r\n patch: boolean | AutoScrollOptions | undefined,\r\n): Required<AutoScrollOptions> => {\r\n if (typeof patch !== 'object' || !patch) return base;\r\n const result = { ...base };\r\n for (const key of Object.keys(patch) as Array<keyof AutoScrollOptions>) {\r\n const value = patch[key];\r\n if (typeof value === 'number' && Number.isFinite(value)) result[key] = value;\r\n }\r\n return result;\r\n};\r\n\r\n/** Options for one container: a per-container override wins over the provider; `null` means off. */\r\nexport const resolveAutoScrollOptions = (\r\n provider: boolean | AutoScrollOptions | undefined,\r\n override?: boolean | AutoScrollOptions,\r\n): Required<AutoScrollOptions> | null => {\r\n if ((override ?? provider ?? true) === false) return null;\r\n return mergeOptions(mergeOptions(DEFAULT_AUTO_SCROLL, provider), override);\r\n};\r\n\r\n/** How far to scroll so `rect` fits into `view` (its start edge wins when it is larger). */\r\nexport const getRevealDelta = (rect: Rect, view: Rect, margin = 0): Coordinates => {\r\n const axis = (start: number, end: number, viewStart: number, viewEnd: number) => {\r\n if (start < viewStart + margin) return start - viewStart - margin;\r\n if (end > viewEnd - margin) return Math.min(end - viewEnd + margin, start - viewStart - margin);\r\n return 0;\r\n };\r\n return {\r\n x: axis(rect.left, rect.right, view.left, view.right),\r\n y: axis(rect.top, rect.bottom, view.top, view.bottom),\r\n };\r\n};\r\n","/**\r\n * Scroll containers in the DOM: what scrolls and how far it can, read from computed\r\n * styles and scroll offsets, and relative scroll steps.\r\n */\r\n\r\nimport type { Rect } from '../../types';\r\nimport { createRect, getLayoutRect } from '../../animation/layout';\r\nimport { parentOf } from '../../utils/dom';\r\nimport { getRevealDelta, type Directions } from './math';\r\n\r\nexport interface ScrollStyle {\r\n x: boolean;\r\n y: boolean;\r\n /** Scroll offsets run from -max to 0 (RTL, `*-reverse` flex containers). */\r\n reverseX: boolean;\r\n reverseY: boolean;\r\n /** Has `scroll-snap-type`. */\r\n snap: boolean;\r\n}\r\n\r\nexport interface Measured {\r\n /** Visible client area in viewport coordinates. */\r\n rect: Rect;\r\n canScroll: Directions;\r\n}\r\n\r\nconst OVERFLOW = /^(auto|scroll|overlay)$/;\r\n\r\nexport const readScrollStyle = (element: Element): ScrollStyle => {\r\n const style = getComputedStyle(element);\r\n const flex = style.display.endsWith('flex');\r\n return {\r\n x: OVERFLOW.test(style.overflowX),\r\n y: OVERFLOW.test(style.overflowY),\r\n reverseX: (style.direction === 'rtl') !== (flex && style.flexDirection === 'row-reverse'),\r\n reverseY: flex && style.flexDirection === 'column-reverse',\r\n snap: hasSnapping(style),\r\n };\r\n};\r\n\r\nconst hasSnapping = (style: CSSStyleDeclaration): boolean =>\r\n !!style.scrollSnapType && style.scrollSnapType !== 'none';\r\n\r\n/** The page itself scrolls through the window, which is always the last candidate. */\r\nexport const isPageRoot = (element: Element): boolean =>\r\n element === document.body || element === document.documentElement;\r\n\r\n/** Room to scroll backward/forward; 1px slack absorbs fractional offsets. */\r\nconst room = (position: number, max: number, reversed: boolean): [boolean, boolean] => {\r\n if (max < 1) return [false, false];\r\n const low = reversed ? -max : 0;\r\n const high = reversed ? 0 : max;\r\n return [position > low + 1, position < high - 1];\r\n};\r\n\r\nconst clientRect = (element: Element): Rect => {\r\n const box = element.getBoundingClientRect();\r\n return createRect(\r\n box.left + element.clientLeft,\r\n box.top + element.clientTop,\r\n element.clientWidth,\r\n element.clientHeight,\r\n );\r\n};\r\n\r\nexport const measureElement = (element: Element, style: ScrollStyle): Measured | null => {\r\n const maxX = style.x ? element.scrollWidth - element.clientWidth : 0;\r\n const maxY = style.y ? element.scrollHeight - element.clientHeight : 0;\r\n if (maxX < 1 && maxY < 1) return null;\r\n const [left, right] = room(element.scrollLeft, maxX, style.reverseX);\r\n const [up, down] = room(element.scrollTop, maxY, style.reverseY);\r\n return { rect: clientRect(element), canScroll: { up, down, left, right } };\r\n};\r\n\r\n/** How the page scrolls, read once per drag. */\r\nexport interface PageScroll {\r\n x: boolean;\r\n y: boolean;\r\n reverseX: boolean;\r\n /** `scroll-snap-type` on the root, which snaps the viewport. */\r\n snap: boolean;\r\n}\r\n\r\nexport const readPageScroll = (): PageScroll => {\r\n const root = getComputedStyle(document.documentElement);\r\n const body = getComputedStyle(document.body);\r\n // `overflow` on <body> applies to the viewport when <html> leaves it visible.\r\n // A page locked with `hidden` (an open modal) can still be scrolled by script: don't.\r\n const allowed = (axis: 'overflowX' | 'overflowY') => {\r\n const value = root[axis] === 'visible' ? body[axis] : root[axis];\r\n return value !== 'hidden' && value !== 'clip';\r\n };\r\n return {\r\n x: allowed('overflowX'),\r\n y: allowed('overflowY'),\r\n reverseX: root.direction === 'rtl',\r\n snap: hasSnapping(root),\r\n };\r\n};\r\n\r\nexport const measureWindow = (page: PageScroll): Measured => {\r\n const root = document.scrollingElement ?? document.documentElement;\r\n // The root's client size is the viewport without scrollbars.\r\n const { clientWidth: width, clientHeight: height } = document.documentElement;\r\n const [left, right] = page.x ? room(window.scrollX, root.scrollWidth - width, page.reverseX) : [false, false];\r\n const [up, down] = page.y ? room(window.scrollY, root.scrollHeight - height, false) : [false, false];\r\n return { rect: createRect(0, 0, width, height), canScroll: { up, down, left, right } };\r\n};\r\n\r\nexport type Scroller = Element | Window;\r\n\r\nexport const scrollBy = (scroller: Scroller, left: number, top: number) => {\r\n // 'instant' overrides a page-level `scroll-behavior: smooth`, which would lag behind the loop.\r\n const options: ScrollToOptions = { left, top, behavior: 'instant' };\r\n if (scroller === window) window.scrollBy(options);\r\n else (scroller as Element).scrollBy(options);\r\n};\r\n\r\n/**\r\n * Scrolls the scrollers around `element` by relative steps until it is visible.\r\n * Not `scrollIntoView`: it jumps virtual lists and scrolls unrelated ancestors.\r\n * Runs once per key press, so reading after each write is fine. Uses the layout\r\n * rect: a keyboard-sorted slot is revealed right after its FLIP starts, and the\r\n * running `translate` would aim at where it came from.\r\n */\r\nexport const revealElement = (element: Element, margin = 8): void => {\r\n for (let node = parentOf(element); node && !isPageRoot(node); node = parentOf(node)) {\r\n const measured = measureElement(node, readScrollStyle(node));\r\n if (!measured) continue;\r\n const delta = getRevealDelta(getLayoutRect(element), measured.rect, margin);\r\n if (delta.x || delta.y) scrollBy(node, delta.x, delta.y);\r\n }\r\n const page = readPageScroll();\r\n const delta = getRevealDelta(getLayoutRect(element), measureWindow(page).rect, margin);\r\n const dx = page.x ? delta.x : 0;\r\n const dy = page.y ? delta.y : 0;\r\n if (dx || dy) scrollBy(window, dx, dy);\r\n};\r\n","/**\r\n * Auto-scroll during pointer drags (rfcs/0001-v3.md §11).\r\n *\r\n * One rAF loop per drag. Each frame first reads every candidate scroller (the\r\n * element under the pointer and its scrollable ancestors, the ancestors of the\r\n * current drop target, the window last), picks per axis the first one that wants\r\n * to and can scroll, and only then writes. Steps are always relative (`scrollBy`):\r\n * virtualizers correct `scrollTop` themselves when rows get measured, and an\r\n * absolute target would fight those corrections.\r\n */\r\n\r\nimport { onScopeDispose, watch } from 'vue';\r\nimport type { AutoScrollOptions, Coordinates } from '../../types';\r\nimport type { DnDManager } from '../manager';\r\nimport { elementFromPoint, parentOf } from '../../utils/dom';\r\nimport {\r\n createScrollIntent,\r\n getScrollVelocity,\r\n resolveAutoScrollOptions,\r\n updateScrollIntent,\r\n type ScrollIntent,\r\n} from './math';\r\nimport {\r\n isPageRoot,\r\n measureElement,\r\n measureWindow,\r\n readPageScroll,\r\n readScrollStyle,\r\n scrollBy,\r\n type Measured,\r\n type PageScroll,\r\n type Scroller,\r\n type ScrollStyle,\r\n} from './dom';\r\n\r\n/** Speeds are px per 60fps frame; steps scale with the real frame time. */\r\nconst FRAME_MS = 1000 / 60;\r\n/** Caps the step after a stalled frame (tab switch, long task). */\r\nconst MAX_FRAME_MS = 50;\r\n\r\ninterface Target {\r\n scroller: Scroller;\r\n speed: number;\r\n}\r\n\r\ninterface Session {\r\n last: number;\r\n /** Where the pointer has been since the drag started: the directions it may scroll. */\r\n intent: ScrollIntent;\r\n styles: WeakMap<Element, ScrollStyle>;\r\n /** Per-list options, keyed by the list's scroll container. */\r\n overrides: Map<Element, boolean | AutoScrollOptions>;\r\n /** Sub-pixel steps carried over to the next frame, so slow speeds still move. */\r\n remainders: Map<Scroller, Coordinates>;\r\n /** Elements that scrolled last frame: they keep scrolling while the pointer is past their edge. */\r\n previous: Element[];\r\n page: PageScroll;\r\n /** Inline `scroll-snap-type` of the scrollers whose snapping is suspended, restored when the drag ends. */\r\n snaps: Map<HTMLElement, { value: string; priority: string }>;\r\n}\r\n\r\n/** Runs auto-scroll for the provider's pointer drags. Keyboard drags never auto-scroll. */\r\nexport function useAutoScroll(manager: DnDManager): void {\r\n let frame = 0;\r\n let session: Session | null = null;\r\n\r\n const styleOf = (current: Session, element: Element): ScrollStyle => {\r\n let style = current.styles.get(element);\r\n if (!style) {\r\n style = readScrollStyle(element);\r\n current.styles.set(element, style);\r\n }\r\n return style;\r\n };\r\n\r\n const isScrollContainer = (current: Session, element: Element) => {\r\n const style = styleOf(current, element);\r\n return style.x || style.y;\r\n };\r\n\r\n const addScrollers = (current: Session, from: Element | null | undefined, into: Element[]) => {\r\n for (let node = from ?? null; node && !isPageRoot(node); node = parentOf(node)) {\r\n if (isScrollContainer(current, node) && !into.includes(node)) into.push(node);\r\n }\r\n };\r\n\r\n /**\r\n * Scroll snapping and small relative steps don't mix: Chromium snaps every\r\n * programmatic `scrollBy` in its direction (a whole column per frame with\r\n * `mandatory`), and a step shorter than the `proximity` range snaps back. Snapping\r\n * is suspended on a scroller from its first step until the drag ends; restoring it\r\n * re-snaps to the nearest snap position.\r\n */\r\n const suspendSnapping = (current: Session, scroller: Scroller) => {\r\n const snaps = scroller === window ? current.page.snap : styleOf(current, scroller as Element).snap;\r\n const element = scroller === window ? document.documentElement : scroller;\r\n if (!snaps || !(element instanceof HTMLElement) || current.snaps.has(element)) return;\r\n const { style } = element;\r\n current.snaps.set(element, {\r\n value: style.getPropertyValue('scroll-snap-type'),\r\n priority: style.getPropertyPriority('scroll-snap-type'),\r\n });\r\n style.setProperty('scroll-snap-type', 'none', 'important');\r\n };\r\n\r\n const restoreSnapping = (current: Session) => {\r\n for (const [element, { value, priority }] of current.snaps) {\r\n if (value) element.style.setProperty('scroll-snap-type', value, priority);\r\n else element.style.removeProperty('scroll-snap-type');\r\n }\r\n current.snaps.clear();\r\n };\r\n\r\n const step = (current: Session, scroller: Scroller, dx: number, dy: number) => {\r\n let remainder = current.remainders.get(scroller);\r\n if (!remainder) current.remainders.set(scroller, (remainder = { x: 0, y: 0 }));\r\n const x = remainder.x + dx;\r\n const y = remainder.y + dy;\r\n const left = Math.trunc(x);\r\n const top = Math.trunc(y);\r\n remainder.x = x - left;\r\n remainder.y = y - top;\r\n if (!left && !top) return;\r\n suspendSnapping(current, scroller);\r\n scrollBy(scroller, left, top);\r\n };\r\n\r\n // Not while the browser's own drag is out of the window: its last point stays at an edge.\r\n const isPointerDrag = () =>\r\n manager.status.value === 'dragging' && manager.active.value?.sensor === 'pointer' && !manager.outside.value;\r\n\r\n const tick = (now: number) => {\r\n frame = 0;\r\n const current = session;\r\n if (!current || !isPointerDrag()) return;\r\n const elapsed = current.last ? Math.min(now - current.last, MAX_FRAME_MS) : FRAME_MS;\r\n current.last = now;\r\n\r\n const pointer = manager.getRawPointer();\r\n const intent = updateScrollIntent(current.intent, pointer);\r\n const provider = manager.props.autoScroll;\r\n\r\n // Read pass: innermost first, the window last. What is under the pointer comes from\r\n // the manager's hit test of the last frame: a hit test brings the page's rendering\r\n // up to date, which with thousands of items costs more than the rest of the frame.\r\n const candidates: Element[] = [];\r\n addScrollers(current, manager.getPointerElement() ?? elementFromPoint(pointer.x, pointer.y), candidates);\r\n const over = manager.over.value?.element;\r\n if (over?.isConnected) addScrollers(current, over, candidates);\r\n for (const element of current.previous) {\r\n if (element.isConnected && !candidates.includes(element)) candidates.push(element);\r\n }\r\n\r\n // Per axis, only the first container that wants to and can scroll does.\r\n const picked: { x: Target | null; y: Target | null } = { x: null, y: null };\r\n const consider = (scroller: Scroller, measured: Measured, options: Required<AutoScrollOptions>) => {\r\n const velocity = getScrollVelocity(pointer, measured.rect, measured.canScroll, intent, options);\r\n if (!picked.x && velocity.x) picked.x = { scroller, speed: velocity.x };\r\n if (!picked.y && velocity.y) picked.y = { scroller, speed: velocity.y };\r\n };\r\n for (const element of candidates) {\r\n if (picked.x && picked.y) break;\r\n const options = resolveAutoScrollOptions(provider, current.overrides.get(element));\r\n const measured = options && measureElement(element, styleOf(current, element));\r\n if (options && measured) consider(element, measured, options);\r\n }\r\n if (!picked.x || !picked.y) {\r\n const options = resolveAutoScrollOptions(provider);\r\n if (options) consider(window, measureWindow(current.page), options);\r\n }\r\n\r\n // Write pass.\r\n const scale = elapsed / FRAME_MS;\r\n const { x, y } = picked;\r\n if (x && y && x.scroller === y.scroller) {\r\n step(current, x.scroller, x.speed * scale, y.speed * scale);\r\n } else {\r\n if (x) step(current, x.scroller, x.speed * scale, 0);\r\n if (y) step(current, y.scroller, 0, y.speed * scale);\r\n }\r\n const scrolled = [x?.scroller, y?.scroller].filter(\r\n (scroller, index, all): scroller is Element => !!scroller && scroller !== window && all.indexOf(scroller) === index,\r\n );\r\n const { autoScrollers } = manager;\r\n if (scrolled.length !== autoScrollers.value.length || scrolled.some((element, i) => element !== autoScrollers.value[i])) {\r\n autoScrollers.value = scrolled;\r\n }\r\n current.previous = scrolled;\r\n manager.isAutoScrolling.value = !!(x || y);\r\n frame = requestAnimationFrame(tick);\r\n };\r\n\r\n const start = () => {\r\n const provider = manager.props.autoScroll;\r\n // Lists' options are read once per drag; `undefined` leaves the provider's.\r\n const entries: Array<{ element: Element | null; options: boolean | AutoScrollOptions }> = [];\r\n for (const entry of manager.autoScrollEntries) {\r\n const options = entry.getOptions();\r\n if (options !== undefined) entries.push({ element: entry.getElement(), options });\r\n }\r\n if (provider === false && !entries.some((entry) => entry.options !== false)) return;\r\n const current: Session = {\r\n last: 0,\r\n // From where the drag starts, not from the first frame: a pointer that is already at\r\n // the edge by then (a late frame, coalesced input) has moved toward it all the same.\r\n intent: createScrollIntent(manager.getRawPointer()),\r\n styles: new WeakMap(),\r\n overrides: new Map(),\r\n remainders: new Map(),\r\n previous: [],\r\n page: readPageScroll(),\r\n snaps: new Map(),\r\n };\r\n // A list's option applies to its scroll container: the list itself or its closest scrollable ancestor.\r\n for (const entry of entries) {\r\n let node = entry.element;\r\n while (node && !isPageRoot(node) && !isScrollContainer(current, node)) node = parentOf(node);\r\n if (node && !isPageRoot(node) && !current.overrides.has(node)) {\r\n current.overrides.set(node, entry.options);\r\n }\r\n }\r\n session = current;\r\n frame = requestAnimationFrame(tick);\r\n };\r\n\r\n const stop = () => {\r\n if (frame) cancelAnimationFrame(frame);\r\n frame = 0;\r\n if (session) restoreSnapping(session);\r\n session = null;\r\n manager.isAutoScrolling.value = false;\r\n if (manager.autoScrollers.value.length) manager.autoScrollers.value = [];\r\n };\r\n\r\n watch(isPointerDrag, (dragging) => (dragging ? start() : stop()), { flush: 'sync' });\r\n onScopeDispose(stop);\r\n}\r\n","/**\r\n * How keyboard drags move (rfcs/0001-v3.md §10), whichever sensor drives them: by items.\r\n * An arrow asks the monitors for the next position (sortable lists answer with the next\r\n * slot); without an answer a free drag jumps to the next accepting target\r\n * (`keyboard: 'droppables'`) or moves by pixels. `place` puts the item at a position of\r\n * a list directly.\r\n */\r\n\r\nimport type { Active, Coordinates, Key, Rect, SensorDirection, SortablePosition } from '../../types';\r\nimport type { DnDManager } from '../manager';\r\nimport { getCenter, getRect, getWindowRect, intersectRect } from '../../animation/layout';\r\nimport { revealElement } from '../autoscroll';\r\n\r\nconst DEFAULT_STEP = 25;\r\nconst FAST_STEP_FACTOR = 4;\r\n/** In `'droppables'` mode a target's center must lie at least this far in the arrow's direction. */\r\nconst MIN_JUMP = 10;\r\n\r\n/** Unit vector of each arrow. */\r\nexport const DIRECTIONS: Record<SensorDirection, Coordinates> = {\r\n up: { x: 0, y: -1 },\r\n down: { x: 0, y: 1 },\r\n left: { x: -1, y: 0 },\r\n right: { x: 1, y: 0 },\r\n};\r\n\r\nconst ARROW_KEYS: Record<SensorDirection, string> = {\r\n up: 'ArrowUp',\r\n down: 'ArrowDown',\r\n left: 'ArrowLeft',\r\n right: 'ArrowRight',\r\n};\r\n\r\n/** The key press a step stands for, when the sensor has none (monitors get a `KeyboardEvent`). */\r\nexport const arrowEvent = (direction: SensorDirection, fast: boolean): KeyboardEvent => {\r\n const key = ARROW_KEYS[direction];\r\n return new KeyboardEvent('keydown', { key, code: key, shiftKey: fast });\r\n};\r\n\r\n/**\r\n * `'droppables'` mode: the closest target whose center lies in the arrow's direction,\r\n * scored by the distance along the arrow plus twice the sideways offset, so targets\r\n * in line with the pointer win over closer ones off to the side.\r\n */\r\nexport const pickInDirection = (\r\n pointer: Coordinates,\r\n direction: Coordinates,\r\n candidates: ReadonlyArray<{ id: Key; rect: Rect }>,\r\n): Key | null => {\r\n let best: Key | null = null;\r\n let bestScore = Infinity;\r\n for (const { id, rect } of candidates) {\r\n const center = getCenter(rect);\r\n const dx = center.x - pointer.x;\r\n const dy = center.y - pointer.y;\r\n const along = dx * direction.x + dy * direction.y;\r\n if (along < MIN_JUMP) continue;\r\n const score = along + 2 * Math.abs(dx * direction.y + dy * direction.x);\r\n if (score < bestScore) {\r\n bestScore = score;\r\n best = id;\r\n }\r\n }\r\n return best;\r\n};\r\n\r\n/** Center of the part of `rect` inside the viewport, so the hit test lands on it. */\r\nconst visibleCenter = (rect: Rect): Coordinates => getCenter(intersectRect(rect, getWindowRect()) ?? rect);\r\n\r\n/**\r\n * Next accepting drop target in `direction` from `pointer` (but the one under the drag and\r\n * those `skip` leaves out), scrolled into view, and the point that lands on it.\r\n */\r\nexport const findDroppable = (\r\n manager: DnDManager,\r\n current: Active,\r\n pointer: Coordinates,\r\n direction: Coordinates,\r\n skip?: (id: Key) => boolean,\r\n): { id: Key; point: Coordinates } | undefined => {\r\n const overId = manager.over.value?.id;\r\n const candidates: Array<{ id: Key; rect: Rect }> = [];\r\n const elements = new Map<Key, HTMLElement>();\r\n for (const entry of manager.getDroppables()) {\r\n if (entry.id === overId || entry.isDisabled() || skip?.(entry.id)) continue;\r\n const element = entry.getElement();\r\n if (!element?.isConnected || manager.isOwned(element, current)) continue;\r\n if (!entry.accepts(current)) continue;\r\n candidates.push({ id: entry.id, rect: getRect(element) });\r\n elements.set(entry.id, element);\r\n }\r\n const id = pickInDirection(pointer, direction, candidates);\r\n const element = id == null ? undefined : elements.get(id);\r\n if (id == null || !element) return undefined;\r\n revealElement(element);\r\n return { id, point: visibleCenter(getRect(element)) };\r\n};\r\n\r\n/** The drag `current` is still the provider's running drag (a step may have awaited a render). */\r\nconst isRunning = (manager: DnDManager, current: Active) =>\r\n manager.status.value === 'dragging' && manager.active.value?.id === current.id;\r\n\r\n/** Moves a keyboard drag to `next` at once: the next step reads `pointer` and `over`. */\r\nconst moveNow = (manager: DnDManager, next: Coordinates) => {\r\n manager.move(next);\r\n // The next key press reads `pointer` and `over`: don't leave them a frame behind.\r\n manager.flushFrame();\r\n};\r\n\r\n/** One arrow step of the running keyboard drag `current`. */\r\nexport const step = async (\r\n manager: DnDManager,\r\n current: Active,\r\n direction: Coordinates,\r\n event: KeyboardEvent,\r\n fast: boolean,\r\n): Promise<void> => {\r\n const pointer = manager.pointer.value ?? getCenter(current.rect);\r\n let next: Coordinates | undefined;\r\n for (const monitor of [...manager.monitors]) {\r\n next = await monitor.getKeyboardCoordinates?.(event, { active: current, pointer, direction });\r\n if (next) break;\r\n }\r\n if (!isRunning(manager, current)) return;\r\n if (!next) {\r\n if (manager.getDraggable(current.id)?.getKeyboard?.() === 'droppables') {\r\n next = findDroppable(manager, current, pointer, direction)?.point;\r\n } else {\r\n const keyboard = manager.props.keyboard || undefined;\r\n const size = (keyboard?.step ?? DEFAULT_STEP) * (fast ? FAST_STEP_FACTOR : 1);\r\n next = { x: pointer.x + direction.x * size, y: pointer.y + direction.y * size };\r\n }\r\n }\r\n if (next) moveNow(manager, next);\r\n};\r\n\r\n/** Puts the item of the running drag `current` at `position` (see `SensorDrag.place`). */\r\nexport const place = async (manager: DnDManager, current: Active, position: SortablePosition): Promise<boolean> => {\r\n let next: Coordinates | undefined;\r\n for (const monitor of [...manager.monitors]) {\r\n next = await monitor.placeAt?.(current, position);\r\n if (next) break;\r\n }\r\n if (!next || !isRunning(manager, current)) return false;\r\n moveNow(manager, next);\r\n return true;\r\n};\r\n","/**\r\n * One drag of a sensor (`SensorDrag`), from `activate()` to its end: first the pending\r\n * activation (its constraint, progress for the UI, the abort), then the running drag.\r\n *\r\n * Keyboard drags queue their moves: a step may await monitors (sortable resolves the\r\n * next slot after a render), so a quick \"arrow, arrow, Space\" moves twice and then drops.\r\n */\r\n\r\nimport type {\r\n ActivationConstraint,\r\n Coordinates,\r\n Key,\r\n Sensor,\r\n SensorActivation,\r\n SensorDirection,\r\n SensorDrag,\r\n SensorDragState,\r\n SensorStepOptions,\r\n SensorType,\r\n SortablePosition,\r\n} from '../../types';\r\nimport type { DnDManager } from '../manager';\r\nimport { devtoolsHook } from '../devtoolsHook';\r\nimport { checkActivation } from './activation';\r\nimport { leavePressed } from './leave';\r\nimport { DIRECTIONS, arrowEvent, place, step } from './steps';\r\n\r\nexport interface DragSetup {\r\n manager: DnDManager;\r\n id: Key;\r\n type: SensorType;\r\n /** Where the drag starts. */\r\n origin: Coordinates;\r\n constraint: ActivationConstraint;\r\n /** Started by touch: it vibrates (`haptics`). */\r\n touch: boolean;\r\n /** The sensor that activated it (the devtools tell it); none for a drag started without one. */\r\n sensor?: Sensor;\r\n /** The element the input pressed, inside the dragged `item` (a sensor that gave an element). */\r\n pressed?: { target: Element; item: Element };\r\n callbacks: Pick<SensorActivation, 'onStart' | 'onEnd' | 'onResume'>;\r\n /** The drag ended: whoever tracks it lets it go. */\r\n onEnded(): void;\r\n}\r\n\r\nexport interface DragControl {\r\n drag: SensorDrag;\r\n /** Starts waiting for the constraint (or the drag, without one): `false` when it ended at once. */\r\n begin(): boolean;\r\n /** Stands for a drag that has just started without a sensor (`manager.start`). */\r\n adopt(): void;\r\n /** The provider's drag ended: dropped (`onDragEnd`) or not (`onDragCancel`). */\r\n conclude(dropped: boolean): void;\r\n /** The drop didn't happen and the drag goes on (`'continue'`): the sensor drives it again. */\r\n resume(): void;\r\n /** Aborts a pending activation (Escape, a hidden tab). */\r\n abort(): void;\r\n}\r\n\r\nconst report = (error: unknown) => console.error(error);\r\n\r\nexport function createSensorDrag(setup: DragSetup): DragControl {\r\n const { manager, id, type, origin, constraint, callbacks } = setup;\r\n let state: SensorDragState = 'pending';\r\n let started = false;\r\n /** `drop()` or `cancel()` was called: the sensor is done with the drag. */\r\n let released = false;\r\n let dropped = false;\r\n let point = origin;\r\n const startedAt = performance.now();\r\n let timer: ReturnType<typeof setTimeout> | undefined;\r\n let frame = 0;\r\n\r\n let queue: Promise<void> = Promise.resolve();\r\n let queued = 0;\r\n /** Runs `task` after the keyboard moves before it; resolves `fallback` if it throws. */\r\n const enqueue = <T>(task: () => Promise<T>, fallback: T): Promise<T> => {\r\n queued++;\r\n const run = queue.then(task);\r\n queue = run.then(() => undefined, report).finally(() => queued--);\r\n return run.catch(() => fallback);\r\n };\r\n\r\n /** The provider's drag is still this one. */\r\n const isRunning = () => manager.status.value === 'dragging' && manager.active.value?.id === id;\r\n /** Calls that move or end the drag apply. */\r\n const isLive = () => state === 'dragging' && !released && isRunning();\r\n\r\n const stopTracking = () => {\r\n clearTimeout(timer);\r\n if (frame) cancelAnimationFrame(frame);\r\n frame = 0;\r\n };\r\n\r\n const end = () => {\r\n if (state === 'ended') return;\r\n state = 'ended';\r\n stopTracking();\r\n setup.onEnded();\r\n try {\r\n callbacks.onEnd?.(drag);\r\n } catch (error) {\r\n report(error);\r\n }\r\n };\r\n\r\n const abort = () => {\r\n if (state !== 'pending') return;\r\n if (manager.status.value === 'activating') {\r\n manager.status.value = manager.restStatus();\r\n manager.activationProgress.value = 0;\r\n }\r\n end();\r\n };\r\n\r\n const startNow = (): boolean => {\r\n stopTracking();\r\n // The manager starts from rest (`idle`, or `dropping` while overlays land).\r\n if (manager.status.value === 'activating') manager.status.value = manager.restStatus();\r\n // Before the start: a monitor of `onDragStart` may already end it.\r\n state = 'dragging';\r\n devtoolsHook()?.sensor(manager, id, setup.sensor, setup.touch);\r\n if (!manager.start(id, origin, type, setup.touch)) {\r\n manager.activationProgress.value = 0;\r\n end();\r\n return false;\r\n }\r\n started = true;\r\n if (state !== 'dragging') return true;\r\n try {\r\n callbacks.onStart?.(drag);\r\n } catch (error) {\r\n report(error);\r\n }\r\n if (type === 'pointer') {\r\n if (setup.pressed) leavePressed(setup.pressed.target, setup.pressed.item);\r\n // Where the input went while the activation waited.\r\n manager.move(point);\r\n }\r\n return true;\r\n };\r\n\r\n /** Re-checks the pending activation: `true` while it still waits. */\r\n const evaluate = (): boolean => {\r\n if (state !== 'pending' || manager.status.value !== 'activating') return false;\r\n const distance = Math.hypot(point.x - origin.x, point.y - origin.y);\r\n const verdict = checkActivation(constraint, distance, performance.now() - startedAt);\r\n if (verdict === 'start') startNow();\r\n else if (verdict === 'abort') abort();\r\n else {\r\n manager.activationProgress.value = verdict;\r\n return true;\r\n }\r\n return false;\r\n };\r\n\r\n const trackDelay = () => {\r\n const { delay } = constraint;\r\n if (!delay) return;\r\n timer = setTimeout(evaluate, delay);\r\n // Progress for the UI (e.g. a long-press ring), once per frame.\r\n const tick = () => {\r\n frame = evaluate() ? requestAnimationFrame(tick) : 0;\r\n };\r\n frame = requestAnimationFrame(tick);\r\n };\r\n\r\n const begin = (): boolean => {\r\n if (checkActivation(constraint, 0, 0) === 'start') return startNow();\r\n manager.status.value = 'activating';\r\n manager.activationProgress.value = 0;\r\n if (evaluate()) trackDelay();\r\n return state !== 'ended';\r\n };\r\n\r\n const move = (next: Coordinates) => {\r\n if (state === 'pending') {\r\n point = next;\r\n evaluate();\r\n return;\r\n }\r\n if (!isLive()) return;\r\n point = next;\r\n if (type === 'pointer') return manager.move(next);\r\n void enqueue(async () => {\r\n if (!isRunning()) return;\r\n manager.move(next);\r\n manager.flushFrame();\r\n }, undefined);\r\n };\r\n\r\n const stepBy = (direction: SensorDirection, options: SensorStepOptions = {}): Promise<void> => {\r\n const current = manager.active.value;\r\n if (type !== 'keyboard' || !isLive() || !current) return Promise.resolve();\r\n const { event } = options;\r\n // A held arrow repeats (pixel moves glide), but repeats don't pile up behind a move\r\n // that is still resolving. Separate presses are never dropped.\r\n if (event?.repeat && queued > 0) return Promise.resolve();\r\n const fast = options.fast ?? event?.shiftKey ?? false;\r\n const key = event ?? arrowEvent(direction, fast);\r\n return enqueue(() => step(manager, current, DIRECTIONS[direction], key, fast), undefined);\r\n };\r\n\r\n const placeAt = (position: SortablePosition): Promise<boolean> => {\r\n const current = manager.active.value;\r\n if (!isLive() || !current) return Promise.resolve(false);\r\n const task = () => place(manager, current, position);\r\n return type === 'keyboard' ? enqueue(task, false) : task();\r\n };\r\n\r\n const drop = (): Promise<boolean> => {\r\n if (state === 'pending') abort();\r\n if (state !== 'dragging' || released) return Promise.resolve(false);\r\n released = true;\r\n const task = async () => {\r\n await manager.drop();\r\n return dropped;\r\n };\r\n return type === 'keyboard' ? enqueue(task, false) : task();\r\n };\r\n\r\n const cancel = () => {\r\n if (state === 'pending') return abort();\r\n if (state !== 'dragging' || released) return;\r\n released = true;\r\n if (isRunning()) manager.cancel();\r\n };\r\n\r\n const drag: SensorDrag = {\r\n id,\r\n type,\r\n get state() {\r\n return state;\r\n },\r\n get started() {\r\n return started;\r\n },\r\n move,\r\n step: stepBy,\r\n place: placeAt,\r\n drop,\r\n cancel,\r\n };\r\n\r\n return {\r\n drag,\r\n begin,\r\n adopt() {\r\n state = 'dragging';\r\n started = true;\r\n },\r\n conclude(value) {\r\n if (state !== 'dragging') return;\r\n dropped = value;\r\n end();\r\n },\r\n resume() {\r\n if (state !== 'dragging') return;\r\n released = false;\r\n try {\r\n callbacks.onResume?.(drag);\r\n } catch (error) {\r\n report(error);\r\n }\r\n },\r\n abort,\r\n };\r\n}\r\n","/**\r\n * Sensors of a provider (rfcs/0001-v3.md В§10). A sensor only says \"drag this item from\r\n * here\" (`SensorContext.activate`), then where it moved and that it dropped or\r\n * cancelled. The rules every drag follows are kept here and in `drag.ts`, the same for\r\n * the built-in sensors and custom ones:\r\n * - one drag per provider, none while a drop is decided (an async `onBeforeDrop`); the\r\n * overlays of decided drops land on while the next drag runs;\r\n * - only draggables of this provider that aren't disabled, from where a drag of that type\r\n * may start (the handle, no interactive child; the focus target for keyboard drags),\r\n * and only if `canDrag` lets the input event through;\r\n * - activation constraints (distance, delay, tolerance) with their progress;\r\n * - the drag itself (document drag mode, auto-scroll, keyboard moves by items, focus and\r\n * announcements) is the manager's (`manager/session.ts`);\r\n * - a hidden tab cancels the drag; a sensor that stops cancels its own.\r\n */\r\n\r\nimport { effectScope, onScopeDispose, watch } from 'vue';\r\nimport { defaultDocument, useEventListener } from '@vueuse/core';\r\nimport type { Key, Sensor, SensorActivation, SensorContext, SensorDrag, SensorType } from '../../types';\r\nimport type { DnDManager } from '../manager';\r\nimport { useManager } from '../context';\r\nimport { getCenter, getRect } from '../../animation/layout';\r\nimport { isClient } from '../../utils/dom';\r\nimport { warnIfDeciding } from '../deciding';\r\nimport { canStartFrom, resolveConstraint } from './activation';\r\nimport { createSensorDrag, type DragControl } from './drag';\r\n\r\n/** Bundlers replace it: development builds keep the warnings, production drops them. */\r\ndeclare const process: { env: { NODE_ENV?: string } };\r\n\r\n/** A running sensor. */\r\ninterface Owner {\r\n active: boolean;\r\n /** Its drag, until it ends. */\r\n current: DragControl | null;\r\n sensor: Sensor;\r\n}\r\n\r\ninterface Host {\r\n /** Runs a sensor; the returned function stops it (`cancel`: and its drag). */\r\n run(sensor: Sensor): (cancel?: boolean) => void;\r\n}\r\n\r\n/** Per provider, like sortable groups (`useSortableGroup`): providers stay independent. */\r\nconst hosts = new WeakMap<DnDManager, Host>();\r\n\r\n/** The draggable a sensor's `target` points at, if a drag of `type` may start there. */\r\nconst findTarget = (manager: DnDManager, target: Element | Key, type: SensorType) => {\r\n if (typeof target === 'object') {\r\n const found = target && manager.findDraggable(target);\r\n return found && canStartFrom(found.entry, found.element, target, type) ? found : null;\r\n }\r\n const entry = manager.getDraggable(target);\r\n const element = entry?.getElement();\r\n return entry && element ? { entry, element } : null;\r\n};\r\n\r\nfunction createHost(manager: DnDManager): Host {\r\n /** The provider's drag, from `activate()` (or its start elsewhere) until it ends. */\r\n let current: DragControl | null = null;\r\n\r\n const track = (control: DragControl) => {\r\n current = control;\r\n return control;\r\n };\r\n const forget = (control: DragControl) => {\r\n if (current === control) current = null;\r\n };\r\n\r\n // A library layer: it hears events first and is asked about drops last, so users'\r\n // monitors run as they would without it.\r\n manager.addMonitor(\r\n {\r\n // A drag started without a sensor (`manager.start`) still gets a handle, so that\r\n // sensors can drive it (the keyboard moves keyboard drags, whoever started them).\r\n onDragStart: () => {\r\n const active = manager.active.value;\r\n // A sensor's drag starting.\r\n if (current?.drag.state === 'dragging' || !active) return;\r\n // Started elsewhere while a press still waited: that press is over.\r\n current?.abort();\r\n const control: DragControl = track(\r\n createSensorDrag({\r\n manager,\r\n id: active.id,\r\n type: active.sensor,\r\n origin: manager.getRawPointer(),\r\n constraint: {},\r\n touch: false,\r\n callbacks: {},\r\n onEnded: () => forget(control),\r\n }),\r\n );\r\n control.adopt();\r\n },\r\n // A running drag hears how it ended, whoever ended it, or that it goes on.\r\n onDragEnd: () => current?.conclude(true),\r\n onDragCancel: () => current?.conclude(false),\r\n onDragResume: () => current?.resume(),\r\n },\r\n true,\r\n );\r\n // Escape and `useDnD().cancel()` abort a pending activation.\r\n manager.activationAborts.add(() => current?.abort());\r\n\r\n const activate = (owner: Owner, options: SensorActivation): SensorDrag | null => {\r\n const type = options.type ?? 'pointer';\r\n if (!owner.active) return null;\r\n // Overlays still landing don't hold a new press back.\r\n if (current || !manager.isAtRest()) {\r\n // A press on a draggable while a drop is decided: development builds say why nothing happens.\r\n if (process.env.NODE_ENV !== 'production' && manager.status.value === 'dropping' && findTarget(manager, options.target, type)) {\r\n warnIfDeciding(manager, 'A new drag');\r\n }\r\n return null;\r\n }\r\n // A press on an overlay still landing catches its item in flight, whatever is under it\r\n // (the box lets the pointer through).\r\n const caught = type === 'pointer' && options.point ? manager.catchAt(options.point) : null;\r\n const found = findTarget(manager, caught ?? options.target, type);\r\n if (!found || found.entry.isDisabled()) return null;\r\n const { entry, element } = found;\r\n const { event } = options;\r\n // A mouse drag of a `native` draggable is the browser's own (`native/bridge.ts`).\r\n if ((event as Partial<PointerEvent> | undefined)?.pointerType === 'mouse' && entry.getNative?.()) return null;\r\n if (event && entry.canDrag && !entry.canDrag(event)) return null;\r\n\r\n const control: DragControl = track(\r\n createSensorDrag({\r\n manager,\r\n id: entry.id,\r\n type,\r\n origin: options.point ?? getCenter(getRect(element)),\r\n constraint: resolveConstraint(options.activation, entry, manager.props.activation),\r\n touch: (event as Partial<PointerEvent> | undefined)?.pointerType === 'touch',\r\n sensor: owner.sensor,\r\n pressed: caught == null && typeof options.target === 'object' ? { target: options.target, item: element } : undefined,\r\n callbacks: options,\r\n onEnded: () => {\r\n forget(control);\r\n if (owner.current === control) owner.current = null;\r\n },\r\n }),\r\n );\r\n owner.current = control;\r\n return control.begin() ? control.drag : null;\r\n };\r\n\r\n const run = (sensor: Sensor) => {\r\n const owner: Owner = { active: true, current: null, sensor };\r\n const context: SensorContext = {\r\n get props() {\r\n return manager.props;\r\n },\r\n get status() {\r\n return manager.status.value;\r\n },\r\n get drag() {\r\n return current?.drag ?? null;\r\n },\r\n activate: (options) => activate(owner, options),\r\n cancel: () => {\r\n if (process.env.NODE_ENV !== 'production') warnIfDeciding(manager, 'cancel()');\r\n manager.cancel();\r\n },\r\n };\r\n const scope = effectScope(true);\r\n scope.run(() => {\r\n try {\r\n const cleanup = sensor.setup(context);\r\n if (typeof cleanup === 'function') onScopeDispose(cleanup);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n });\r\n return (cancel = true) => {\r\n owner.active = false;\r\n scope.stop();\r\n if (cancel) owner.current?.drag.cancel();\r\n };\r\n };\r\n\r\n return { run };\r\n}\r\n\r\nconst hostOf = (manager: DnDManager): Host => {\r\n let host = hosts.get(manager);\r\n if (!host) hosts.set(manager, (host = createHost(manager)));\r\n return host;\r\n};\r\n\r\n/**\r\n * Runs the provider's `sensors` (`defaults` without the prop), in the browser only, and\r\n * follows changes of the list: sensors that leave it stop, cancelling their drag.\r\n */\r\nexport function useSensors(manager: DnDManager, defaults: readonly Sensor[]): void {\r\n if (!isClient) return;\r\n const host = hostOf(manager);\r\n // The pointerup of a hidden tab may never come.\r\n useEventListener(defaultDocument, 'visibilitychange', () => {\r\n if (document.visibilityState === 'hidden') manager.cancel();\r\n });\r\n const running = new Map<Sensor, (cancel?: boolean) => void>();\r\n watch(\r\n () => manager.props.sensors ?? defaults,\r\n (sensors) => {\r\n const next = new Set(sensors);\r\n for (const [sensor, stop] of running) {\r\n if (next.has(sensor)) continue;\r\n running.delete(sensor);\r\n stop();\r\n }\r\n for (const sensor of next) if (!running.has(sensor)) running.set(sensor, host.run(sensor));\r\n },\r\n { immediate: true },\r\n );\r\n // The provider unmounts: the manager ends the drag itself (`destroy`).\r\n onScopeDispose(() => {\r\n for (const stop of running.values()) stop(false);\r\n running.clear();\r\n });\r\n}\r\n\r\n/**\r\n * Runs a sensor in the provider above for as long as the calling component (or effect\r\n * scope) lives, next to the provider's `sensors`. Its drag is cancelled when it unmounts.\r\n */\r\nexport function useSensor(sensor: Sensor): void {\r\n const manager = useManager();\r\n if (!isClient) return;\r\n const stop = hostOf(manager).run(sensor);\r\n onScopeDispose(() => stop());\r\n}\r\n\r\n/** Defines a sensor (see `Sensor`): it only helps with the types and returns its argument. */\r\nexport const defineSensor = (sensor: Sensor): Sensor => sensor;\r\n","/**\r\n * What the browser's drags carry (`DataTransfer`), as the library reads it: while a drag\r\n * is held over the page only the types are known (and the files' MIME types), the data\r\n * comes with the drop. Also how a window of the app hands its items to another one.\r\n */\r\n\r\nimport type { DragItem, ExternalAccept, ExternalData, ExternalFile } from '../../types';\r\n\r\n/** The items of a drag out of a window of the app, as JSON (readable at the drop). */\r\nexport const ITEMS_TYPE = 'application/x-vue-dnd-kit';\r\n\r\n/**\r\n * The same, readable while the drag is held: browsers show the types of a drag before the\r\n * drop, never its data, so the items ride in a type's name, hex-encoded (types are\r\n * lowercased). Up to `HINT_LIMIT` characters; past that, only the group name.\r\n */\r\nconst HINT_PREFIX = 'application/x-vue-dnd-kit.';\r\nconst HINT_LIMIT = 32_000;\r\n\r\n/** The items of a window's drag, as another window reads them. */\r\nexport interface RemotePayload {\r\n group: string;\r\n items: Array<Pick<DragItem, 'id' | 'item' | 'data' | 'label' | 'type'>>;\r\n}\r\n\r\nconst toHex = (text: string) => [...new TextEncoder().encode(text)].map((byte) => byte.toString(16).padStart(2, '0')).join('');\r\n\r\nconst fromHex = (hex: string) => {\r\n const bytes = new Uint8Array(hex.length / 2);\r\n for (let index = 0; index < bytes.length; index++) bytes[index] = parseInt(hex.slice(index * 2, index * 2 + 2), 16);\r\n return new TextDecoder().decode(bytes);\r\n};\r\n\r\n/** Puts a window's items on its drag (`dragstart`); `false` when they can't be written as JSON. */\r\nexport const writeRemote = (transfer: DataTransfer, payload: RemotePayload): boolean => {\r\n let json: string;\r\n try {\r\n json = JSON.stringify(payload);\r\n } catch {\r\n return false;\r\n }\r\n transfer.setData(ITEMS_TYPE, json);\r\n const hint = toHex(json);\r\n transfer.setData(HINT_PREFIX + (hint.length <= HINT_LIMIT ? hint : toHex(JSON.stringify({ group: payload.group, items: [] }))), '1');\r\n return true;\r\n};\r\n\r\n/** The items another window's drag carries, from the names of its types (while it is held). */\r\nexport const readRemoteHint = (types: readonly string[]): RemotePayload | null => {\r\n const hint = types.find((type) => type.startsWith(HINT_PREFIX));\r\n if (!hint) return null;\r\n try {\r\n const payload = JSON.parse(fromHex(hint.slice(HINT_PREFIX.length))) as RemotePayload;\r\n return typeof payload.group === 'string' && Array.isArray(payload.items) ? payload : null;\r\n } catch {\r\n return null;\r\n }\r\n};\r\n\r\n/** The same, from its data (at the drop). */\r\nexport const readRemote = (transfer: DataTransfer): RemotePayload | null => {\r\n try {\r\n const payload = JSON.parse(transfer.getData(ITEMS_TYPE)) as RemotePayload;\r\n return typeof payload.group === 'string' && Array.isArray(payload.items) ? payload : null;\r\n } catch {\r\n return null;\r\n }\r\n};\r\n\r\n/** A drag the browser carries: files, links, text, an app's own types, or a window's items. */\r\nexport const carries = (transfer: DataTransfer | null): transfer is DataTransfer => !!transfer?.types.length;\r\n\r\n/** What a drag held over the page carries, before its data comes (`ExternalData`). */\r\nexport const readHeld = (transfer: DataTransfer, group?: string): ExternalData => {\r\n const types = [...transfer.types];\r\n const fileTypes = [...transfer.items].filter((item) => item.kind === 'file').map((item) => item.type);\r\n return {\r\n types,\r\n // Some browsers list no items while the drag is held: one file for the `Files` type then.\r\n fileTypes: fileTypes.length || !types.includes('Files') ? fileTypes : [''],\r\n files: [],\r\n urls: [],\r\n text: '',\r\n html: '',\r\n getData: () => '',\r\n ready: false,\r\n group,\r\n };\r\n};\r\n\r\nconst tokensOf = (accept: string | readonly string[]) =>\r\n (typeof accept === 'string' ? accept.split(',') : accept).map((token) => token.trim().toLowerCase()).filter(Boolean);\r\n\r\n/** Whether `files` of `ExternalAccept` takes `file`. A name not known yet passes the extensions. */\r\nexport const takesFile = (rule: ExternalAccept['files'], file: ExternalFile): boolean => {\r\n if (!rule) return false;\r\n if (rule === true) return true;\r\n if (typeof rule === 'function') return rule(file);\r\n const tokens = tokensOf(rule);\r\n const type = file.type.toLowerCase();\r\n return (\r\n !tokens.length ||\r\n tokens.some((token) => {\r\n if (token.startsWith('.')) return file.name === undefined || file.name.toLowerCase().endsWith(token);\r\n return token.endsWith('/*') ? type.startsWith(token.slice(0, -1)) : type === token;\r\n })\r\n );\r\n};\r\n\r\n/**\r\n * Whether a target with `rule` takes the drag `external` from outside the page: files it\r\n * takes (all of them, and one only without `multiple`), links, text or a type it lists.\r\n */\r\nexport const takesExternal = (rule: ExternalAccept | undefined, external: ExternalData): boolean => {\r\n if (!rule || external.group) return false;\r\n const { types } = external;\r\n if (rule.types?.some((type) => types.includes(type.toLowerCase()))) return true;\r\n const files = external.ready ? external.files.map((file) => ({ type: file.type, name: file.name, size: file.size })) : external.fileTypes.map((type) => ({ type }));\r\n if (types.includes('Files') && rule.files) {\r\n if (rule.multiple === false && files.length > 1) return false;\r\n if (files.length && files.every((file) => takesFile(rule.files, file))) return true;\r\n }\r\n if (rule.links && types.includes('text/uri-list')) return true;\r\n return !!rule.text && types.includes('text/plain') && !types.includes('Files');\r\n};\r\n\r\n/**\r\n * Reads the data of a dropped drag into `external`: the files `rule` takes (folders left\r\n * out), the links, the text and the HTML. Only in the `drop` event: the browser empties\r\n * the `DataTransfer` after it.\r\n */\r\nexport const readDropped = (external: ExternalData, transfer: DataTransfer, rule: ExternalAccept | undefined): void => {\r\n const files = [...transfer.items]\r\n .filter((item) => item.kind === 'file' && !item.webkitGetAsEntry?.()?.isDirectory)\r\n .map((item) => item.getAsFile())\r\n .filter((file): file is File => !!file);\r\n const data = new Map<string, string>();\r\n for (const type of transfer.types) if (type !== 'Files') data.set(type, transfer.getData(type));\r\n const uriList = data.get('text/uri-list') ?? '';\r\n Object.assign(external, {\r\n files: rule?.files ? files.filter((file) => takesFile(rule.files, { type: file.type, name: file.name, size: file.size })) : [],\r\n urls: uriList\r\n .split(/\\r?\\n/)\r\n .map((line) => line.trim())\r\n .filter((line) => line && !line.startsWith('#')),\r\n text: data.get('text/plain') ?? '',\r\n html: data.get('text/html') ?? '',\r\n getData: (type: string) => data.get(type.toLowerCase()) ?? '',\r\n ready: true,\r\n } satisfies Partial<ExternalData>);\r\n};\r\n\r\n/**\r\n * The items of a drag from outside: one per file (`type: ['file']`, its MIME type as\r\n * `data`), else one for what it carries (`'link'`, `'text'`, `'data'`).\r\n */\r\nexport const externalItems = (id: string, external: ExternalData): DragItem[] => {\r\n if (external.fileTypes.length) {\r\n return external.fileTypes.map((type, index) => ({ id: `${id}:${index}`, data: { type }, type: ['file'] }));\r\n }\r\n const { types } = external;\r\n const kind = types.includes('text/uri-list') ? 'link' : types.includes('text/plain') ? 'text' : 'data';\r\n return [{ id, data: { types }, type: [kind] }];\r\n};\r\n\r\n/** What people call a drag from outside: \"2 files\", \"a link\". */\r\nexport const externalLabel = (external: ExternalData): string => {\r\n const count = external.fileTypes.length;\r\n if (count) return count === 1 ? 'a file' : `${count} files`;\r\n const { types } = external;\r\n return types.includes('text/uri-list') ? 'a link' : types.includes('text/plain') ? 'text' : 'data';\r\n};\r\n","/**\r\n * The browser's own drag and drop (HTML5) as drags of a provider:\r\n * - drags from outside the page (files, links, text) run as drags of the provider for the\r\n * targets that take them (`external`): they get a stand-in element, no overlay (the\r\n * browser draws its image), and their data at the drop;\r\n * - a mouse drag of a `native` draggable is the browser's drag, so it can leave the page;\r\n * on the page it is a drag of the provider like any other, minus the overlay;\r\n * - such a drag carries a sortable item for its group's lists in another window of the app\r\n * (`data.ts`), where it comes in as a drag from outside. Dropped there as a move, it\r\n * leaves its list here (`endOutside`).\r\n *\r\n * The browser's events drive it: `dragover` moves it, `drop` drops it, leaving the window\r\n * cancels a drag from outside (one of the page's own waits outside), `dragend` ends one of\r\n * the page's own that was dropped elsewhere.\r\n */\r\n\r\nimport { defaultDocument, defaultWindow, useEventListener } from '@vueuse/core';\r\nimport type { Active, DragItem, ExternalData } from '../../types';\r\nimport { createRect } from '../../animation/layout';\r\nimport type { DnDManager, DraggableEntry } from '../manager';\r\nimport { canStartFrom } from '../sensors/activation';\r\nimport { isClient } from '../../utils/dom';\r\nimport {\r\n carries,\r\n externalItems,\r\n externalLabel,\r\n readDropped,\r\n readHeld,\r\n readRemote,\r\n readRemoteHint,\r\n writeRemote,\r\n type RemotePayload,\r\n} from './data';\r\n\r\ntype Effect = 'none' | 'copy' | 'move' | 'link';\r\n\r\ninterface BrowserDrag {\r\n manager: DnDManager;\r\n /** A drag of the page's own (`native`), not one from outside. */\r\n own: boolean;\r\n /** A drag from outside: what it carries. */\r\n external?: ExternalData;\r\n /** `dragenter` less `dragleave` over the document: 0 once the drag left the window. */\r\n depth: number;\r\n /** Dropped on this page: its `dragend` is no news. */\r\n dropped: boolean;\r\n /** When the last `dragover` came: mouse events after it mean the drag ended unseen. */\r\n lastOver: number;\r\n /** A drag from outside: takes its stand-in away. */\r\n cleanup?: () => void;\r\n /** A drag from outside: the ids of its items (another window's items too: theirs may be ours). */\r\n idOf?: (index: number) => string;\r\n}\r\n\r\n/** The browser runs one drag at a time: the provider that took it (one per page). */\r\nlet current: BrowserDrag | null = null;\r\nlet made = 0;\r\n\r\n/** Whether `allowed` (`effectAllowed`) lets the drop be `effect`. */\r\nconst allows = (allowed: string, effect: Effect) =>\r\n allowed === 'all' || allowed === 'uninitialized' || allowed.toLowerCase().includes(effect);\r\n\r\nconst pointOf = (event: DragEvent) => ({ x: event.clientX, y: event.clientY });\r\n\r\n/** Another window's items, with ids of this drag: their own keys may be items here too. */\r\nconst remoteItems = (items: RemotePayload['items'], idOf: (index: number) => string): DragItem[] =>\r\n items.map((item, index) => ({ ...item, id: idOf(index), type: item.type ?? [] }));\r\n\r\n/** Runs the provider's browser drags (see above), in the browser only. */\r\nexport function useNativeDrags(manager: DnDManager): void {\r\n if (!isClient) return;\r\n\r\n /** Elements a mouse press made `draggable`, so the browser can start its drag there. */\r\n const madeDraggable = new Set<HTMLElement>();\r\n const undoDraggable = () => {\r\n for (const element of madeDraggable) element.removeAttribute('draggable');\r\n madeDraggable.clear();\r\n };\r\n\r\n const ours = () => (current?.manager === manager ? current : null);\r\n\r\n const end = (drag: BrowserDrag) => {\r\n drag.cleanup?.();\r\n if (current === drag) current = null;\r\n };\r\n\r\n /**\r\n * What the drop would be over the current target: nothing for a target that refuses. Another\r\n * window's items move, or copy with the browser's copy key (Ctrl, Option on a Mac).\r\n */\r\n const effectOf = (drag: BrowserDrag, allowed: string, copyKey = false): Effect => {\r\n const over = manager.over.value;\r\n if (over && !over.accepted) return 'none';\r\n // From outside, only a target makes a drop: elsewhere the browser would open the file.\r\n if (drag.external && !over) return 'none';\r\n const copying = drag.external ? !drag.external.group || copyKey : manager.mode.value === 'copy';\r\n const wanted: Effect = copying ? 'copy' : 'move';\r\n for (const effect of [wanted, 'move', 'copy', 'link'] as const) if (allows(allowed, effect)) return effect;\r\n return 'none';\r\n };\r\n\r\n // ─── The page's own drags (`native`) ──────────────────────────────────────────\r\n\r\n /** A mouse press on a `native` draggable, where its drags start: the browser may drag it. */\r\n const onPointerDown = (event: PointerEvent) => {\r\n undoDraggable();\r\n if (event.pointerType !== 'mouse' || event.button !== 0 || !(event.target instanceof Element)) return;\r\n const found = manager.findDraggable(event.target);\r\n if (!found?.entry.getNative?.() || found.entry.isDisabled() || !canStartFrom(found.entry, found.element, event.target, 'pointer')) return;\r\n // `canDrag` is asked at the press, as the pointer sensor does.\r\n if (found.entry.canDrag && !found.entry.canDrag(event)) return;\r\n // The user's own attribute stays as it is.\r\n if (found.element.hasAttribute('draggable')) return;\r\n found.element.setAttribute('draggable', 'true');\r\n madeDraggable.add(found.element);\r\n };\r\n\r\n const startOwn = (event: DragEvent, entry: DraggableEntry) => {\r\n const transfer = event.dataTransfer!;\r\n if (current || !manager.isAtRest() || !manager.start(entry.id, pointOf(event), 'pointer', false, {})) {\r\n event.preventDefault();\r\n return;\r\n }\r\n const active = manager.active.value!;\r\n const native = entry.getNative!()!;\r\n transfer.effectAllowed = native.effect ?? 'copyMove';\r\n const data = native.data?.(active) ?? (active.label ? { 'text/plain': active.label } : {});\r\n for (const [type, value] of Object.entries(data)) transfer.setData(type, value);\r\n const group = entry.getGroup?.();\r\n if (group) writeRemote(transfer, { group, items: active.items.map(({ id, item, data, label, type }) => ({ id, item, data, label, type })) });\r\n const drag: BrowserDrag = { manager, own: true, depth: 0, dropped: false, lastOver: performance.now() };\r\n current = drag;\r\n // The element may leave the document mid-drag (moved to another list): its `dragend`\r\n // still comes to it, and doesn't bubble up here then.\r\n event.target!.addEventListener('dragend', (end) => onDragEnd(end as DragEvent), { once: true });\r\n };\r\n\r\n const onDragStart = (event: DragEvent) => {\r\n if (!(event.target instanceof Element) || !event.dataTransfer) return;\r\n const found = manager.findDraggable(event.target);\r\n if (!found?.entry.getNative?.() || (!madeDraggable.has(found.element) && found.element.getAttribute('draggable') !== 'true')) return;\r\n startOwn(event, found.entry);\r\n };\r\n\r\n /** A drag of the page's own ended: dropped here (done), elsewhere, or cancelled. */\r\n const onDragEnd = (event: DragEvent) => {\r\n const drag = ours();\r\n undoDraggable();\r\n if (!drag?.own) return;\r\n end(drag);\r\n if (!drag.dropped) manager.endOutside((event.dataTransfer?.dropEffect ?? 'none') as Effect);\r\n };\r\n\r\n // ─── Drags from outside ────────────────────────────────────────────────────────\r\n\r\n /**\r\n * Whether the provider has a target for the drag: one that takes drags from outside\r\n * (`external`), whose rule then says yes or no as the drag goes over it; for another\r\n * window's items, a list of their group or a target that takes them.\r\n */\r\n const wanted = (probe: Active) =>\r\n [...manager.getDroppables()].some((entry) => {\r\n if (entry.isDisabled()) return false;\r\n const { external } = probe;\r\n if (!external?.group) return !!entry.getExternal?.();\r\n return entry.sortable ? entry.getGroup?.() === external.group : entry.accepts(probe);\r\n });\r\n\r\n /** A drag from outside comes in: it starts, for the targets that take it, at a stand-in element. */\r\n const startExternal = (event: DragEvent) => {\r\n const transfer = event.dataTransfer!;\r\n const remote = readRemoteHint(transfer.types);\r\n const external = readHeld(transfer, remote?.group);\r\n const id = `external-${++made}`;\r\n const idOf = (index: number) => `${id}:${index}`;\r\n const items: DragItem[] = remote ? remoteItems(remote.items, idOf) : externalItems(id, external);\r\n if (!items.length) return;\r\n if (!remote) items[0]!.label = externalLabel(external);\r\n const point = pointOf(event);\r\n const standIn = document.createElement('div');\r\n standIn.setAttribute('aria-hidden', 'true');\r\n standIn.setAttribute('data-dnd-external', '');\r\n standIn.style.cssText = `position:fixed;left:${point.x}px;top:${point.y}px;width:0;height:0;pointer-events:none`;\r\n document.body.appendChild(standIn);\r\n const first = items[0]!;\r\n const probe: Active = {\r\n id: first.id,\r\n ids: items.map((item) => item.id),\r\n items,\r\n data: first.data,\r\n label: first.label,\r\n type: first.type,\r\n element: standIn,\r\n rect: createRect(point.x, point.y, 0, 0),\r\n sensor: 'pointer',\r\n external,\r\n native: true,\r\n };\r\n if (!wanted(probe)) {\r\n standIn.remove();\r\n return;\r\n }\r\n const entry: DraggableEntry = {\r\n id: first.id,\r\n getElement: () => standIn,\r\n getHandle: () => null,\r\n getFocusTarget: () => null,\r\n getData: () => first.data,\r\n getLabel: () => first.label,\r\n getTypes: () => first.type,\r\n isDisabled: () => false,\r\n getOverlay: () => false,\r\n };\r\n const unregister = manager.registerDraggable(entry);\r\n const cleanup = () => {\r\n unregister();\r\n standIn.remove();\r\n };\r\n if (!manager.start(first.id, point, 'pointer', false, { items, external })) return cleanup();\r\n current = { manager, own: false, external, depth: 1, dropped: false, lastOver: performance.now(), cleanup, idOf };\r\n event.preventDefault();\r\n transfer.dropEffect = effectOf(current, transfer.effectAllowed);\r\n };\r\n\r\n // ─── Both ──────────────────────────────────────────────────────────────────────\r\n\r\n const onDragEnter = (event: DragEvent) => {\r\n const drag = ours();\r\n if (drag) {\r\n drag.depth++;\r\n event.preventDefault();\r\n return;\r\n }\r\n if (!current && carries(event.dataTransfer) && manager.isAtRest()) startExternal(event);\r\n };\r\n\r\n const onDragOver = (event: DragEvent) => {\r\n const drag = ours();\r\n if (!drag || !event.dataTransfer) return;\r\n // Cancelled, the event lets a drop come; the effect says whether it is welcome.\r\n event.preventDefault();\r\n drag.lastOver = performance.now();\r\n if (manager.outside.value) manager.outside.value = false;\r\n manager.move(pointOf(event));\r\n event.dataTransfer.dropEffect = effectOf(drag, event.dataTransfer.effectAllowed, event.ctrlKey || event.altKey);\r\n };\r\n\r\n const onDragLeave = () => {\r\n const drag = ours();\r\n if (!drag || --drag.depth > 0) return;\r\n drag.depth = 0;\r\n if (drag.own) {\r\n // Out of the window: it may come back, or be dropped elsewhere (`dragend`).\r\n manager.outside.value = true;\r\n return;\r\n }\r\n end(drag);\r\n manager.cancel();\r\n };\r\n\r\n const onDrop = (event: DragEvent) => {\r\n const drag = ours();\r\n if (!drag || !event.dataTransfer) return;\r\n event.preventDefault();\r\n drag.dropped = true;\r\n manager.move(pointOf(event));\r\n manager.flushFrame();\r\n const { external } = drag;\r\n if (external) {\r\n const over = manager.over.value;\r\n readDropped(external, event.dataTransfer, over ? manager.getDroppable(over.id)?.getExternal?.() : undefined);\r\n // Another window's items, in full (the names of the types may have carried only their group).\r\n const remote = external.group ? readRemote(event.dataTransfer) : null;\r\n if (remote?.items.length && drag.idOf) manager.updateActive({ items: remoteItems(remote.items, drag.idOf) });\r\n }\r\n void manager.drop().finally(() => {\r\n if (!drag.own) end(drag);\r\n });\r\n };\r\n\r\n /** Mouse events don't come while the browser drags: one now means its drag ended unseen. */\r\n const onPointerMove = () => {\r\n const drag = ours();\r\n if (!drag || performance.now() - drag.lastOver < 300) return;\r\n end(drag);\r\n manager.cancel();\r\n };\r\n\r\n // Another hand ended the drag (`useDnD().cancel()`, the provider unmounting): the browser's\r\n // drag goes on as the browser's alone.\r\n manager.addMonitor(\r\n {\r\n onDragCancel: (event) => {\r\n const drag = ours();\r\n if (drag && !drag.own && !drag.dropped && event.active.external === drag.external) end(drag);\r\n },\r\n },\r\n true,\r\n );\r\n\r\n useEventListener(defaultDocument, 'pointerdown', onPointerDown, { capture: true });\r\n useEventListener(defaultDocument, 'pointerup', undoDraggable, { capture: true });\r\n useEventListener(defaultDocument, 'dragstart', onDragStart, { capture: true });\r\n useEventListener(defaultDocument, 'dragend', onDragEnd, { capture: true });\r\n useEventListener(defaultDocument, 'dragenter', onDragEnter, { capture: true });\r\n useEventListener(defaultDocument, 'dragover', onDragOver, { capture: true });\r\n useEventListener(defaultDocument, 'dragleave', onDragLeave, { capture: true });\r\n useEventListener(defaultDocument, 'drop', onDrop, { capture: true });\r\n useEventListener(defaultWindow, 'pointermove', onPointerMove, { capture: true, passive: true });\r\n}\r\n\r\n","/**\r\n * Mouse, touch and pen via Pointer Events (rfcs/0001-v3.md §10), built on the public\r\n * sensor API like any custom sensor: the provider checks where a press may start and\r\n * waits for its activation constraint (`SensorContext.activate`). What is left here is\r\n * what pointers need from the page: capture, no text selection, no native drag or\r\n * context menu, no scrolling under a touch drag, no click after the drop.\r\n */\r\n\r\nimport { defaultDocument, defaultWindow, useEventListener } from '@vueuse/core';\r\nimport type { Coordinates, PointerKind, SensorDrag } from '../../types';\r\nimport { defineSensor } from './host';\r\n\r\n/** How long the click suppressor waits for the click that follows a drop. */\r\nconst CLICK_SUPPRESS_MS = 100;\r\n\r\n/**\r\n * Movement (px) a press may make and stay a click: a drag that starts at once (a mouse\r\n * on a handle) and is let go where it started clicks what was pressed.\r\n */\r\nconst CLICK_TOLERANCE = 3;\r\n\r\nconst pointerKind = (event: PointerEvent): PointerKind =>\r\n event.pointerType === 'touch' || event.pointerType === 'pen' ? event.pointerType : 'mouse';\r\n\r\n/**\r\n * Swallows the click that follows a drag (with capture on <body> it lands on a\r\n * common ancestor). Removed by that click, by the next press, or after a moment.\r\n */\r\nconst suppressNextClick = () => {\r\n const stop = (event: Event) => {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n cleanup();\r\n };\r\n const cleanup = () => {\r\n clearTimeout(timer);\r\n window.removeEventListener('click', stop, true);\r\n window.removeEventListener('pointerdown', cleanup, true);\r\n };\r\n window.addEventListener('click', stop, true);\r\n window.addEventListener('pointerdown', cleanup, true);\r\n const timer = setTimeout(cleanup, CLICK_SUPPRESS_MS);\r\n};\r\n\r\nconst USER_SELECT = ['-webkit-user-select', 'user-select'] as const;\r\n\r\nconst isUnselectable = (element: Element): boolean => {\r\n const style = getComputedStyle(element);\r\n return USER_SELECT.some((name) => style.getPropertyValue(name) === 'none');\r\n};\r\n\r\n/**\r\n * Makes the pressed node selectable until the returned function runs, so that the\r\n * press dispatches a `selectstart` the sensor can cancel (see the pointerdown handler).\r\n * Only an inline value the sensor set is ever restored (rfcs/0001-v3.md §13).\r\n */\r\nexport const makeSelectableForPress = (element: Element): (() => void) => {\r\n if (!(element instanceof HTMLElement || element instanceof SVGElement) || !isUnselectable(element)) {\r\n return () => {};\r\n }\r\n const { style } = element;\r\n const saved = USER_SELECT.map(\r\n (name) => [name, style.getPropertyValue(name), style.getPropertyPriority(name)] as const,\r\n );\r\n for (const name of USER_SELECT) style.setProperty(name, 'text', 'important');\r\n let restored = false;\r\n return () => {\r\n if (restored) return;\r\n restored = true;\r\n for (const [name, value, priority] of saved) {\r\n if (value) style.setProperty(name, value, priority);\r\n else style.removeProperty(name);\r\n }\r\n };\r\n};\r\n\r\n/** A press on a draggable, from pointerdown to pointerup (or cancel). */\r\ninterface Press {\r\n /** `null` while a resumed drag is carried with no button held: any primary pointer moves it. */\r\n pointerId: number | null;\r\n drag: SensorDrag;\r\n kind: PointerKind;\r\n /** Where it was pressed; `null` for a carried drag. */\r\n point: Coordinates | null;\r\n /** It went past `CLICK_TOLERANCE`: a drag, not a click. */\r\n moved: boolean;\r\n /** Undoes `makeSelectableForPress` once the press has been handled. */\r\n restoreSelectable: () => void;\r\n stops: Array<() => void>;\r\n}\r\n\r\n/** Mouse, touch and pen via Pointer Events. In `sensors` by default. */\r\nexport const pointerSensor = /* @__PURE__ */ defineSensor({\r\n name: 'pointer',\r\n setup(context) {\r\n let press: Press | null = null;\r\n\r\n const release = () => {\r\n if (!press) return;\r\n press.stops.forEach((stop) => stop());\r\n press.restoreSelectable();\r\n if (press.pointerId !== null && document.body.hasPointerCapture?.(press.pointerId)) {\r\n document.body.releasePointerCapture(press.pointerId);\r\n }\r\n press = null;\r\n };\r\n\r\n /**\r\n * Capture on <body>, not on the item: the item may be recreated mid-drag. Captured,\r\n * the click of the press would go to <body>: a press waits until it has moved.\r\n */\r\n const capture = (pointerId: number | null) => {\r\n if (pointerId === null) return;\r\n try {\r\n document.body.setPointerCapture(pointerId);\r\n } catch {\r\n // The pointer may already be gone; document listeners still work.\r\n }\r\n };\r\n\r\n /** The pointer of the press; a carried drag (no button held) follows the primary one. */\r\n const isOurs = (event: PointerEvent) =>\r\n !!press && (press.pointerId === null ? event.isPrimary : event.pointerId === press.pointerId);\r\n\r\n const onPointerMove = (event: PointerEvent) => {\r\n if (!press || !isOurs(event)) return;\r\n // The mousedown that came with the press has been handled by now.\r\n press.restoreSelectable();\r\n const { point } = press;\r\n if (!press.moved && point && Math.hypot(event.clientX - point.x, event.clientY - point.y) > CLICK_TOLERANCE) {\r\n press.moved = true;\r\n if (press.drag.started) capture(press.pointerId);\r\n }\r\n press.drag.move({ x: event.clientX, y: event.clientY });\r\n };\r\n\r\n const onPointerUp = (event: PointerEvent) => {\r\n if (!press || event.pointerId !== press.pointerId) return;\r\n const { drag, kind, moved } = press;\r\n release();\r\n // Even when the drag was cancelled meanwhile (Escape): the press was a drag. A mouse\r\n // press that started at once and didn't move is a click (a touch held still is not).\r\n if (drag.started && (moved || kind === 'touch')) suppressNextClick();\r\n void drag.drop();\r\n };\r\n\r\n const onPointerCancel = (event: PointerEvent) => {\r\n if (!press || event.pointerId !== press.pointerId) return;\r\n const { drag } = press;\r\n release();\r\n drag.cancel();\r\n };\r\n\r\n const preventWhileActive = (event: Event) => {\r\n if (press) event.preventDefault();\r\n };\r\n\r\n /**\r\n * A press on a draggable never starts a text selection (rfcs/0001-v3.md §10). Beyond\r\n * the selection itself, WebKit uses it to auto-scroll the scroll container the press\r\n * started in whenever the pointer is outside it, even with the library's auto-scroll\r\n * off: that fights the library's own auto-scroll and moves targets under the pointer.\r\n * WebKit settles this on mousedown, by dispatching `selectstart`: once that is\r\n * cancelled, it neither selects nor auto-scrolls. (Cancelling `mousemove` or\r\n * `-webkit-user-drag: none` don't stop it.)\r\n */\r\n const cancelSelection = (event: Event) => {\r\n if (!press) return;\r\n event.preventDefault();\r\n press.restoreSelectable();\r\n // What the press would have done otherwise: a click drops the selection elsewhere.\r\n if (!press.drag.started) document.getSelection()?.removeAllRanges();\r\n };\r\n\r\n /** A touch drag owns the gesture: the page must not scroll or zoom under it. */\r\n const preventTouchScroll = (event: TouchEvent) => {\r\n if (event.cancelable && press?.drag.state === 'dragging') event.preventDefault();\r\n };\r\n\r\n /**\r\n * A carried drag's press: it takes the item in hand where it lands (a touch has no\r\n * hover, the item comes to the finger) and its release drops. The page under the item\r\n * never sees it.\r\n */\r\n const onCarriedDown = (event: PointerEvent) => {\r\n if (!press || press.pointerId !== null || !event.isPrimary) return;\r\n event.preventDefault();\r\n event.stopPropagation();\r\n press.pointerId = event.pointerId;\r\n capture(event.pointerId);\r\n press.drag.move({ x: event.clientX, y: event.clientY });\r\n };\r\n\r\n /**\r\n * The drop the pointer asked for didn't happen and the drag goes on (`'continue'`),\r\n * with no button held any more: the item follows the pointer, and the next release\r\n * drops it, so a click does.\r\n */\r\n const carry = (drag: SensorDrag) => {\r\n release();\r\n press = {\r\n pointerId: null,\r\n drag,\r\n kind: 'mouse',\r\n point: null,\r\n moved: true,\r\n restoreSelectable: () => {},\r\n stops: [\r\n useEventListener(window, 'pointerdown', onCarriedDown, { capture: true }),\r\n useEventListener(document, 'pointermove', onPointerMove),\r\n useEventListener(document, 'pointerup', onPointerUp),\r\n useEventListener(document, 'pointercancel', onPointerCancel),\r\n useEventListener(window, 'contextmenu', preventWhileActive),\r\n useEventListener(window, 'dragstart', preventWhileActive),\r\n useEventListener(document, 'selectstart', cancelSelection, { capture: true }),\r\n ],\r\n };\r\n };\r\n\r\n useEventListener(defaultDocument, 'pointerdown', (event: PointerEvent) => {\r\n if (press || !event.isPrimary || event.button !== 0) return;\r\n const target = event.composedPath()[0];\r\n if (!(target instanceof Element)) return;\r\n const kind = pointerKind(event);\r\n const { pointerId } = event;\r\n const point = { x: event.clientX, y: event.clientY };\r\n const drag = context.activate({\r\n target,\r\n point,\r\n event,\r\n activation: kind,\r\n onStart() {\r\n // A drag that starts at once (`press` isn't set yet) waits for the pointer to move.\r\n if (kind === 'touch' || press?.moved) capture(pointerId);\r\n },\r\n // An aborted activation (moved past the tolerance, Escape) ends the press. A drag\r\n // that ended keeps it until the pointerup, whose click it swallows.\r\n onEnd(ended) {\r\n if (!ended.started && press?.drag === ended) release();\r\n // A carried drag ended otherwise (Escape): nothing to release with a click.\r\n else if (press?.drag === ended && press.pointerId === null) release();\r\n },\r\n onResume: carry,\r\n });\r\n if (!drag) return;\r\n\r\n const stops = [\r\n useEventListener(document, 'pointermove', onPointerMove),\r\n useEventListener(document, 'pointerup', onPointerUp),\r\n useEventListener(document, 'pointercancel', onPointerCancel),\r\n useEventListener(window, 'contextmenu', preventWhileActive),\r\n useEventListener(window, 'dragstart', preventWhileActive),\r\n // From the press on: the mousedown that follows decides about selecting.\r\n useEventListener(document, 'selectstart', cancelSelection, { capture: true }),\r\n ];\r\n if (kind === 'touch') {\r\n // Touch events keep targeting the element the finger landed on. When a drag into\r\n // another list re-creates the item, that element leaves the document and its\r\n // touchmoves no longer bubble to the window listener below: the browser would\r\n // pan the page and fire `pointercancel`. A listener on the target itself still\r\n // sees them.\r\n stops.push(useEventListener(target, 'touchmove', preventTouchScroll, { passive: false }));\r\n }\r\n press = {\r\n pointerId,\r\n drag,\r\n kind,\r\n point,\r\n moved: false,\r\n // WebKit dispatches no `selectstart` for a `user-select: none` node, yet still\r\n // auto-scrolls: such a node is selectable for the press, so it can be cancelled.\r\n restoreSelectable: kind === 'touch' ? () => {} : makeSelectableForPress(target),\r\n stops,\r\n };\r\n });\r\n\r\n // iOS Safari honours preventDefault() on touchmove only when a non-passive\r\n // listener exists before the gesture starts. While activating, the page must\r\n // still scroll (a quick swipe is a scroll, not a drag).\r\n useEventListener(defaultWindow, 'touchmove', preventTouchScroll, { passive: false });\r\n\r\n // The provider cancels the drag of a hidden tab; its pointerup may never come.\r\n useEventListener(defaultDocument, 'visibilitychange', () => {\r\n if (document.visibilityState === 'hidden') release();\r\n });\r\n\r\n return release;\r\n },\r\n});\r\n","/**\r\n * Keyboard drags (rfcs/0001-v3.md §10), built on the public sensor API like any custom\r\n * sensor: Space/Enter picks up the focused draggable and drops it, arrows move it by\r\n * items (`SensorDrag.step`), Escape cancels any drag. The keys are rebound with the\r\n * provider's `keyboard` option.\r\n */\r\n\r\nimport { defaultDocument, useEventListener } from '@vueuse/core';\r\nimport type { SensorDirection } from '../../types';\r\nimport { getEventTarget } from '../../utils/dom';\r\nimport { defineSensor } from './host';\r\n\r\nconst DEFAULT_KEYS = {\r\n start: ['Space', 'Enter'],\r\n drop: ['Space', 'Enter'],\r\n cancel: ['Escape'],\r\n};\r\n\r\nconst ARROWS = new Map<string, SensorDirection>([\r\n ['ArrowUp', 'up'],\r\n ['ArrowDown', 'down'],\r\n ['ArrowLeft', 'left'],\r\n ['ArrowRight', 'right'],\r\n]);\r\n\r\n/** Bindings match `event.code` ('Space', 'KeyW') or `event.key` ('Enter', 'w'). */\r\nexport const matches = (bindings: readonly string[], event: KeyboardEvent): boolean =>\r\n bindings.includes(event.code) || bindings.includes(event.key);\r\n\r\n/**\r\n * A key the drag acts on is consumed: nothing below the document sees it. UI kits\r\n * handle the same keys on their own elements (a list moving focus on arrows, an item\r\n * clicking itself on Enter/Space and stopping propagation, an overlay closing on\r\n * Escape); left to them, the press would act twice or never reach the drag.\r\n */\r\nconst consume = (event: KeyboardEvent) => {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n};\r\n\r\n/**\r\n * Space/Enter, arrows and Escape (rebound with the provider's `keyboard` option). In\r\n * `sensors` by default; it also cancels pointer and custom drags with Escape, even with\r\n * `keyboard: false`.\r\n */\r\nexport const keyboardSensor = /* @__PURE__ */ defineSensor({\r\n name: 'keyboard',\r\n setup(context) {\r\n const options = () => (context.props.keyboard === false ? null : (context.props.keyboard ?? {}));\r\n const keys = () => ({ ...DEFAULT_KEYS, ...options()?.keys });\r\n\r\n // Capture phase: runs before any handler on the focused element or its ancestors.\r\n useEventListener(defaultDocument, 'keydown', (event: KeyboardEvent) => {\r\n const { status } = context;\r\n const bindings = keys();\r\n\r\n // Escape cancels any drag, including pointer drags and pending activations.\r\n if ((status === 'dragging' || status === 'activating') && matches(bindings.cancel, event)) {\r\n consume(event);\r\n context.cancel();\r\n return;\r\n }\r\n\r\n if (status === 'dragging') {\r\n // Every keyboard drag, whoever picked it up; pointer drags leave the keys to the page.\r\n const { drag } = context;\r\n if (drag?.type !== 'keyboard' || drag.state !== 'dragging') return;\r\n if (matches(bindings.drop, event)) {\r\n consume(event);\r\n if (!event.repeat) void drag.drop();\r\n return;\r\n }\r\n const direction = ARROWS.get(event.key) ?? ARROWS.get(event.code);\r\n if (!direction) return;\r\n consume(event);\r\n void drag.step(direction, { event });\r\n return;\r\n }\r\n\r\n // Overlays still landing don't hold a pickup back, as they don't hold a press back; a\r\n // drop still being decided does (it is a drag: `drag` is set).\r\n const atRest = status === 'idle' || (status === 'dropping' && !context.drag);\r\n if (!atRest || !options() || event.repeat) return;\r\n if (!matches(bindings.start, event)) return;\r\n const target = getEventTarget(event);\r\n if (!(target instanceof Element)) return;\r\n if (context.activate({ target, type: 'keyboard', event })) consume(event);\r\n }, { capture: true });\r\n },\r\n});\r\n","import type { AnimationOptions, Coordinates, MaybeElementRef, Modifier, Rect, SnapToGridOptions } from '../types';\r\nimport type { AreaEntry } from './manager';\r\nimport { getCenter, getRect } from '../animation/layout';\r\nimport { toElement } from '../utils/dom';\r\n\r\n/** Keeps `rect` moved by `transform` inside `bounds`. */\r\nconst restrictToRect = (transform: Coordinates, rect: Rect, bounds: Rect): Coordinates => {\r\n let { x, y } = transform;\r\n if (rect.left + x < bounds.left) x = bounds.left - rect.left;\r\n else if (rect.right + x > bounds.right) x = bounds.right - rect.right;\r\n if (rect.top + y < bounds.top) y = bounds.top - rect.top;\r\n else if (rect.bottom + y > bounds.bottom) y = bounds.bottom - rect.bottom;\r\n return { x, y };\r\n};\r\n\r\n/** `overlayRect` is the rect after `transform`; this gives the rect before it. */\r\nconst baseRect = (overlayRect: Rect, transform: Coordinates): Rect => ({\r\n ...overlayRect,\r\n left: overlayRect.left - transform.x,\r\n right: overlayRect.right - transform.x,\r\n top: overlayRect.top - transform.y,\r\n bottom: overlayRect.bottom - transform.y,\r\n});\r\n\r\n/**\r\n * Moves only vertically: horizontally it stays with the content it started in\r\n * (`containerShift`), however the page scrolls. The `axis: 'y'` option does the same, last.\r\n */\r\nexport const restrictToVerticalAxis: Modifier = ({ transform, containerShift }) => ({ x: containerShift.x, y: transform.y });\r\n\r\n/**\r\n * Moves only horizontally: vertically it stays with the content it started in\r\n * (`containerShift`), however the page scrolls. The `axis: 'x'` option does the same, last.\r\n */\r\nexport const restrictToHorizontalAxis: Modifier = ({ transform, containerShift }) => ({ x: transform.x, y: containerShift.y });\r\n\r\n/** `modifiers` with the lock of the `axis` option last, so it holds whatever they do. */\r\nexport const withAxis = (modifiers: Modifier[] | undefined, axis: 'x' | 'y' | null | undefined): Modifier[] | undefined =>\r\n axis ? [...(modifiers ?? []), axis === 'x' ? restrictToHorizontalAxis : restrictToVerticalAxis] : modifiers;\r\n\r\n/**\r\n * The modifiers of a drag after the provider's: those of its area (`makeDragArea`), the\r\n * draggable's own (or its list's), the area's bounds (`restrictToArea`), and the axis\r\n * lock last. The draggable's `axis` (or its list's) wins over the area's.\r\n */\r\nexport const dragModifiers = (\r\n own: Modifier[] | undefined,\r\n axis: 'x' | 'y' | undefined,\r\n area: AreaEntry | null,\r\n): Modifier[] | undefined => {\r\n if (!area) return withAxis(own, axis);\r\n const modifiers = [...(area.getModifiers() ?? []), ...(own ?? [])];\r\n if (area.restricts()) modifiers.push(restrictToElement(area.getElement));\r\n return withAxis(modifiers, axis ?? area.getAxis());\r\n};\r\n\r\n/** Keeps the overlay inside the window. */\r\nexport const restrictToWindowEdges: Modifier = ({ transform, overlayRect, windowRect }) =>\r\n restrictToRect(transform, baseRect(overlayRect, transform), windowRect);\r\n\r\n/**\r\n * Keeps the overlay inside the container the drag started in: the sortable list\r\n * (not its DOM parent) or, for plain draggables, the parent element.\r\n */\r\nexport const restrictToParent: Modifier = ({ transform, overlayRect, containerRect }) =>\r\n containerRect ? restrictToRect(transform, baseRect(overlayRect, transform), containerRect) : transform;\r\n\r\n/** Keeps the overlay inside an element: the element, a ref or a getter. */\r\nexport const restrictToElement =\r\n (target: MaybeElementRef): Modifier =>\r\n ({ transform, overlayRect }) => {\r\n const element = toElement(target);\r\n return element\r\n ? restrictToRect(transform, baseRect(overlayRect, transform), getRect(element))\r\n : transform;\r\n };\r\n\r\nconst isScrollable = (element: Element) => {\r\n const style = getComputedStyle(element);\r\n return /(auto|scroll|overlay)/.test(style.overflow + style.overflowX + style.overflowY);\r\n};\r\n\r\n// Modifiers run every frame: resolve the ancestor once per dragged element.\r\nconst scrollableAncestors = new WeakMap<Element, Element | null>();\r\n\r\n/** Keeps the overlay inside the first scrollable ancestor of the dragged element. */\r\nexport const restrictToFirstScrollableAncestor: Modifier = ({ transform, overlayRect, active }) => {\r\n let element = scrollableAncestors.get(active.element);\r\n if (element === undefined) {\r\n element = active.element.parentElement;\r\n while (element && !isScrollable(element)) element = element.parentElement;\r\n scrollableAncestors.set(active.element, element);\r\n }\r\n return element?.isConnected\r\n ? restrictToRect(transform, baseRect(overlayRect, transform), getRect(element))\r\n : transform;\r\n};\r\n\r\n/** Marker read by the overlay: glide between the positions this modifier produces. */\r\nexport type SmoothModifier = Modifier & { smooth?: Required<AnimationOptions> };\r\n\r\nconst DEFAULT_SMOOTH: Required<AnimationOptions> = { duration: 80, easing: 'ease-out' };\r\n\r\nconst snap = (value: number, size = 0) => (size > 0 ? Math.round(value / size) * size : value);\r\n\r\n/**\r\n * Snaps the overlay to a grid, to the nearest cell: a number is the size of square cells;\r\n * options set each axis, where the grid starts and a glide between cells (`SnapToGridOptions`).\r\n */\r\nexport const snapToGrid = (size: number | SnapToGridOptions): Modifier => {\r\n const options: SnapToGridOptions = typeof size === 'number' ? { x: size, y: size } : size;\r\n const { x: sx, y: sy, origin = 'container' } = options;\r\n const modifier: Modifier = ({ transform, overlayRect, containerRect }) => {\r\n if (origin === 'delta' || !containerRect) {\r\n return { x: snap(transform.x, sx), y: snap(transform.y, sy) };\r\n }\r\n const left = overlayRect.left - containerRect.left;\r\n const top = overlayRect.top - containerRect.top;\r\n return { x: transform.x + snap(left, sx) - left, y: transform.y + snap(top, sy) - top };\r\n };\r\n const smooth = options.smooth;\r\n if (!smooth) return modifier;\r\n const resolved = { ...DEFAULT_SMOOTH, ...(smooth === true ? {} : smooth) };\r\n return resolved.duration > 0 ? Object.assign(modifier, { smooth: resolved }) : modifier;\r\n};\r\n\r\n/** The glide the overlay should apply between modifier outputs, if any modifier asks for one. */\r\nexport const getOverlaySmoothing = (\r\n modifiers: readonly Modifier[] | undefined,\r\n): Required<AnimationOptions> | null => {\r\n for (const modifier of modifiers ?? []) {\r\n const smooth = (modifier as SmoothModifier).smooth;\r\n if (smooth) return smooth;\r\n }\r\n return null;\r\n};\r\n\r\n/** Centers the overlay under the pointer instead of keeping the grab offset. */\r\nexport const snapCenterToCursor: Modifier = ({ transform, overlayRect, origin }) => {\r\n // Moves the box by the distance from its center to the pointer (`origin + transform`).\r\n const center = getCenter(overlayRect);\r\n return {\r\n x: transform.x + origin.x + transform.x - center.x,\r\n y: transform.y + origin.y + transform.y - center.y,\r\n };\r\n};\r\n","/**\r\n * What a box of the overlay shows, for the content the library renders in it (the\r\n * default clone, the multi-drag column, `DragPreview`). The overlay has a box for the\r\n * drag and one per landing flight: each provides its own, so a landing box keeps showing\r\n * its drag while the next drag shows another.\r\n */\r\n\r\nimport { inject, type InjectionKey } from 'vue';\r\nimport type { Active, Key, Size } from '../types';\r\nimport type { DnDManager, Flight, OverlayColumn, PreviewSource } from './manager';\r\nimport { useManager } from './context';\r\n\r\nexport interface OverlayScope {\r\n readonly active: Active | null;\r\n readonly column: OverlayColumn | null;\r\n /** Ids with a clone, in drop order. */\r\n readonly previewIds: readonly Key[];\r\n /** The box's size while dragging (`overlayFit: 'slot'`). */\r\n readonly fitSize: Size | null;\r\n getPreview(id: Key): PreviewSource | undefined;\r\n /** Clones of the other dragged items in the box: each lands on its own slot. */\r\n readonly items: Map<Key, HTMLElement>;\r\n}\r\n\r\nexport const OVERLAY_SCOPE: InjectionKey<() => OverlayScope> = Symbol('vue-dnd-kit overlay scope');\r\n\r\n/** The running drag's box: read live from the manager. */\r\nexport const dragScope = (manager: DnDManager): OverlayScope => ({\r\n get active() {\r\n return manager.active.value;\r\n },\r\n get column() {\r\n return manager.overlayColumn.value;\r\n },\r\n get previewIds() {\r\n return manager.previewIds;\r\n },\r\n get fitSize() {\r\n return manager.fitSize.value;\r\n },\r\n getPreview: (id) => manager.getPreview(id),\r\n get items() {\r\n return manager.overlayItems;\r\n },\r\n});\r\n\r\n/** A landing box: what its drag left. */\r\nexport const flightScope = (flight: Flight): OverlayScope => ({\r\n active: flight.active,\r\n column: flight.column,\r\n previewIds: flight.previewIds,\r\n fitSize: flight.fitSize,\r\n getPreview: (id) => flight.previews.get(id),\r\n items: flight.items,\r\n});\r\n\r\n/** The scope of the box this component renders in; the drag's outside the overlay. */\r\nexport const useOverlayScope = (): (() => OverlayScope) => {\r\n const provided = inject(OVERLAY_SCOPE, null);\r\n if (provided) return provided;\r\n const scope = dragScope(useManager());\r\n return () => scope;\r\n};\r\n","import { defineComponent, h, onBeforeUnmount, onMounted, shallowRef, watch, type PropType } from 'vue';\r\nimport type { DragPreviewProps, Key } from '../types';\r\nimport { useOverlayScope } from './overlayScope';\r\n\r\n/**\r\n * The default clone of one dragged item (see `DragPreviewProps`). Custom overlays use\r\n * it to lay out several items themselves; the default overlay shows a multi-drag with it.\r\n */\r\nexport const DragPreview = /* @__PURE__ */ defineComponent({\r\n name: 'DragPreview',\r\n props: {\r\n id: { type: [String, Number] as PropType<DragPreviewProps['id']>, required: true },\r\n },\r\n setup(props, { slots }) {\r\n // The box it renders in: the drag's, or a landing one's.\r\n const scope = useOverlayScope();\r\n const host = shallowRef<HTMLElement | null>(null);\r\n let shown: HTMLElement | null = null;\r\n /** This preview as the overlay clone of its item, which lands on the item's slot. */\r\n let landing: { id: Key; element: HTMLElement; items: Map<Key, HTMLElement> } | null = null;\r\n\r\n const release = () => {\r\n if (landing && landing.items.get(landing.id) === landing.element) landing.items.delete(landing.id);\r\n landing = null;\r\n };\r\n\r\n const attach = () => {\r\n shown?.remove();\r\n shown = null;\r\n release();\r\n const { active, column, getPreview, items } = scope();\r\n const preview = getPreview(props.id);\r\n const element = host.value;\r\n if (!preview || !element) return;\r\n // One clone, one place: a second preview of the same item shows a copy of it.\r\n shown = preview.element.isConnected ? (preview.element.cloneNode(true) as HTMLElement) : preview.element;\r\n element.appendChild(shown);\r\n // In a custom overlay layout of a sortable multi-drag (the column brings the landing),\r\n // another dragged item's preview lands on that item's slot with the drop, as the\r\n // default column's cells do (those register themselves).\r\n const parent = element.parentElement;\r\n const lands =\r\n !!column &&\r\n props.id !== active?.id &&\r\n !!parent?.closest('[data-dnd-overlay]') &&\r\n !parent.closest('[data-dnd-overlay-item]');\r\n element.toggleAttribute('data-dnd-overlay-item', lands);\r\n if (!lands) return;\r\n items.set(props.id, element);\r\n landing = { id: props.id, element, items };\r\n };\r\n onMounted(attach);\r\n watch(() => props.id, attach, { flush: 'post' });\r\n onBeforeUnmount(release);\r\n\r\n return () => {\r\n const preview = scope().getPreview(props.id as Key);\r\n if (!preview) {\r\n // In an element of its own, so `class` and `style` apply to the fallback as to a clone.\r\n const fallback = slots.default?.();\r\n return fallback?.length ? h('div', null, fallback) : null;\r\n }\r\n const { width, height } = preview.rect;\r\n return h('div', { ref: host, 'aria-hidden': 'true', style: { width: `${width}px`, height: `${height}px` } });\r\n };\r\n },\r\n});\r\n","import {\r\n cloneVNode,\r\n Comment,\r\n computed,\r\n defineComponent,\r\n Fragment,\r\n h,\r\n isVNode,\r\n provide,\r\n shallowRef,\r\n Transition,\r\n watch,\r\n type Component,\r\n type PropType,\r\n type SlotsType,\r\n type TransitionProps,\r\n type VNode,\r\n type VNodeArrayChildren,\r\n} from 'vue';\r\nimport type { DropDestination, Key, OverlaySlotProps, Rect } from '../types';\r\nimport type { Flight } from './manager';\r\nimport { useManager } from './context';\r\nimport { getOverlaySmoothing } from './modifiers';\r\nimport { DragPreview } from './DragPreview';\r\nimport { OVERLAY_SCOPE, dragScope, flightScope, useOverlayScope, type OverlayScope } from './overlayScope';\r\nimport { prefersReducedMotion, settle } from '../animation/layout';\r\n\r\nexport const BADGE_STYLE = {\r\n position: 'absolute',\r\n top: '-8px',\r\n right: '-8px',\r\n minWidth: '20px',\r\n height: '20px',\r\n padding: '0 6px',\r\n borderRadius: '10px',\r\n background: '#2563eb',\r\n color: '#fff',\r\n font: '600 12px/20px system-ui, sans-serif',\r\n textAlign: 'center',\r\n boxSizing: 'border-box',\r\n} as const;\r\n\r\nexport const FILL = { width: '100%', height: '100%' } as const;\r\n\r\n/** Where the items behind the active one lie in a pile, fanned out a little. */\r\nexport const PILE = [\r\n { x: 8, y: 7, rotate: 4 },\r\n { x: -7, y: 10, rotate: -5 },\r\n { x: 14, y: 14, rotate: 8 },\r\n];\r\n\r\n/**\r\n * Default overlay content: the clone taken at drag start. A multi-drag shows every item\r\n * (the sortable layer's column); of plain draggables, a pile: the grabbed one on top of up\r\n * to three others, and the count. The pile's clones fly back to their items when the drag\r\n * is cancelled, and into the zone a drop goes into, one after another. With `'stack'` the\r\n * sortable layer brings the others back itself: the grabbed one and the count. The clone\r\n * fills the overlay box, so a resize re-lays it out instead of stretching it.\r\n */\r\nconst DefaultPreview = /* @__PURE__ */ defineComponent({\r\n name: 'DnDDefaultPreview',\r\n setup() {\r\n const scope = useOverlayScope();\r\n const cells = new Map<Key, HTMLElement>();\r\n /** A pile's clone lands with the drop: it goes in the box's landing items. */\r\n const register = (id: Key, element: Element | null) => {\r\n const { items } = scope();\r\n const previous = cells.get(id);\r\n if (previous && items.get(id) === previous) items.delete(id);\r\n cells.delete(id);\r\n if (!(element instanceof HTMLElement)) return;\r\n cells.set(id, element);\r\n items.set(id, element);\r\n };\r\n return () => {\r\n const { active: current, column, previewIds } = scope();\r\n if (!current) return null;\r\n const count = current.ids.length;\r\n if (count > 1 && column) return h(column.preview);\r\n // Sortable items carry their list's item: theirs come back on their own ('stack').\r\n const plain = current.items[0]?.item === undefined;\r\n // Every clone is in the pile, the ones past the third under it: into a zone, they\r\n // all go in one after another.\r\n const behind = count > 1 && plain ? previewIds.filter((id) => id !== current.id) : [];\r\n return h('div', { 'aria-hidden': 'true', style: { ...FILL, position: 'relative' } }, [\r\n // Deepest first: the grabbed one lies on top.\r\n ...behind\r\n .map((id, index) => {\r\n const { x, y, rotate } = PILE[Math.min(index, PILE.length - 1)]!;\r\n return h(\r\n 'div',\r\n {\r\n key: id,\r\n ref: (element) => register(id, element as Element | null),\r\n 'data-dnd-overlay-item': '',\r\n style: { position: 'absolute', top: '0', left: '0', ...FILL, transform: `translate(${x}px, ${y}px) rotate(${rotate}deg)` },\r\n },\r\n h(DragPreview, { id, style: FILL }),\r\n );\r\n })\r\n .reverse(),\r\n h(DragPreview, { key: current.id, id: current.id, style: { ...FILL, position: 'relative' } }),\r\n count > 1 ? h('span', { style: { ...BADGE_STYLE, zIndex: 1 } }, String(count)) : null,\r\n ]);\r\n };\r\n },\r\n});\r\n\r\n/** Slot output that renders nothing: comments (`v-if`) and empty fragments only. */\r\nconst isEmpty = (nodes: VNodeArrayChildren): boolean =>\r\n nodes.every((node) =>\r\n isVNode(node)\r\n ? node.type === Comment || (node.type === Fragment && isEmpty(node.children as VNodeArrayChildren))\r\n : node == null || typeof node === 'boolean' || (Array.isArray(node) && isEmpty(node)),\r\n );\r\n\r\n/**\r\n * The overlay's props an overlay component declares: the others would fall through to its\r\n * root as attributes (`active=\"[object Object]\"`). A component that declares none (a\r\n * function) gets them all, as its props.\r\n */\r\nexport const overlayProps = (component: Component, props: OverlaySlotProps): Record<string, unknown> => {\r\n const all = props as unknown as Record<string, unknown>;\r\n const declared = (component as { props?: readonly string[] | Record<string, unknown> }).props;\r\n if (!declared) return all;\r\n const names = Array.isArray(declared) ? declared : Object.keys(declared);\r\n return Object.fromEntries(names.filter((name) => name in all).map((name) => [name, all[name]]));\r\n};\r\n\r\n/**\r\n * The drag's own overlay content by precedence: its component (the item's `overlay`,\r\n * else its list's), the provider's `#overlay` slot, the clone. A slot that renders\r\n * nothing for this drag (`v-if` on the item type) falls back to the clone.\r\n */\r\nexport const renderOverlay = (\r\n component: Component | null,\r\n slot: ((props: OverlaySlotProps) => VNode[]) | undefined,\r\n props: OverlaySlotProps,\r\n fallback: Component,\r\n): VNode | VNode[] => {\r\n if (component) return h(component, overlayProps(component, props));\r\n const content = slot?.(props);\r\n return content && !isEmpty(content) ? content : h(fallback);\r\n};\r\n\r\n/** The default `overlayTransition`: the two contents crossfade, the leaving one on top of the other. */\r\nconst CROSSFADE = 150;\r\n\r\nconst crossfade = (element: Element, keyframes: Keyframe[], done: () => void) => {\r\n if (prefersReducedMotion() || typeof (element as HTMLElement).animate !== 'function') return done();\r\n // A fade that never ends (a stalled timeline) must not keep the old content around.\r\n void settle((element as HTMLElement).animate(keyframes, { duration: CROSSFADE, easing: 'ease' }), CROSSFADE * 2).then(done);\r\n};\r\n\r\nconst DEFAULT_TRANSITION: TransitionProps = {\r\n css: false,\r\n onEnter: (element, done) => crossfade(element, [{ opacity: 0 }, { opacity: 1 }], done),\r\n onLeave: (element, done) => {\r\n // Out of the flow, over the entering content: the box shows both while they fade.\r\n Object.assign((element as HTMLElement).style, { position: 'absolute', top: '0', left: '0' });\r\n crossfade(element, [{ opacity: 1 }, { opacity: 0 }], done);\r\n },\r\n};\r\n\r\n/** Keys of overlay components: a new component under the transition is new content. */\r\nconst componentKeys = new WeakMap<object, number>();\r\nlet lastComponentKey = 0;\r\nconst keyOf = (component: Component | null): string => {\r\n if (!component) return 'default';\r\n let key = componentKeys.get(component);\r\n if (key == null) componentKeys.set(component, (key = ++lastComponentKey));\r\n return `component-${key}`;\r\n};\r\n\r\n/** A single element or component: what a `<Transition>` can animate. */\r\nconst transitionable = (content: VNode | VNode[]): VNode | null => {\r\n const node = Array.isArray(content) ? (content.length === 1 ? content[0] : null) : content;\r\n return node && isVNode(node) && node.type !== Comment && node.type !== Fragment ? node : null;\r\n};\r\n\r\n/** The content's box: the whole overlay box, which positioned content (a crossfade) is placed in. */\r\nconst CONTENT_STYLE = { width: '100%', height: '100%', position: 'relative' } as const;\r\n\r\n/** The box's style where it doesn't move with the pointer: a landing box, at `rect`. */\r\nconst boxStyle = (rect: Rect) =>\r\n ({\r\n position: 'fixed',\r\n top: '0',\r\n left: '0',\r\n zIndex: '9999',\r\n pointerEvents: 'none',\r\n transformOrigin: '0 0',\r\n willChange: 'transform',\r\n boxSizing: 'border-box',\r\n width: `${rect.width}px`,\r\n height: `${rect.height}px`,\r\n transform: `translate3d(${rect.left}px, ${rect.top}px, 0)`,\r\n }) as const;\r\n\r\n/**\r\n * One box of the overlay: the drag's, or a landing flight's. It gives its content the\r\n * scope it shows (`OverlayScope`). A drag's box carries on as its flight's (same key), so\r\n * what is in it (a running transition, a component's state) lands as it was.\r\n */\r\nconst OverlayBox = /* @__PURE__ */ defineComponent({\r\n name: 'DnDOverlayBox',\r\n // The attributes (`inert`, `aria-hidden`) go on the box below. Fallthrough would merge\r\n // them into a new style object every render, and a re-render (another box landing, a new\r\n // drag) would write the box's `transform` and size back over a landing an animation\r\n // library (GSAP, motion) moves inline.\r\n inheritAttrs: false,\r\n props: {\r\n scope: { type: Object as PropType<OverlayScope>, required: true },\r\n boxStyle: { type: Object as PropType<Record<string, string | undefined>>, required: true },\r\n status: { type: String, required: true },\r\n /** Told the box element (or `null` once it is gone). */\r\n onElement: { type: Function as PropType<(element: HTMLElement | null) => void>, required: true },\r\n },\r\n setup(props, { slots, attrs }) {\r\n provide(OVERLAY_SCOPE, () => props.scope);\r\n const manager = useManager();\r\n const element = shallowRef<HTMLElement | null>(null);\r\n watch(element, (value) => props.onElement(value));\r\n // `data-dnd-overlay` says what the box is doing, for CSS: `dragging`, then `dropping`\r\n // while it lands (or waits for an async `onBeforeDrop`). A landing box's style is one\r\n // object for its whole flight: it is written once. The library moves and sizes the box;\r\n // `data-dnd-overlay-content` fills it and is the page's to animate (a lift, a tilt).\r\n return () =>\r\n h('div', { ...attrs, ref: element, style: props.boxStyle, 'data-dnd-overlay': props.status }, [\r\n h('div', { 'data-dnd-overlay-content': '', class: manager.props.overlayClass, style: CONTENT_STYLE }, slots.default?.()),\r\n ]);\r\n },\r\n});\r\n\r\n/** What a landing box renders, made once per flight: its props never change. */\r\ninterface FlightView {\r\n scope: OverlayScope;\r\n props: OverlaySlotProps;\r\n style: ReturnType<typeof boxStyle>;\r\n onElement: (element: HTMLElement | null) => void;\r\n}\r\n\r\n/**\r\n * The overlay: a box that follows the pointer while dragging, and a box per landing\r\n * flight; rendered by DnDProvider.\r\n */\r\nexport const DragOverlay = /* @__PURE__ */ defineComponent({\r\n name: 'DnDDragOverlay',\r\n // Several boxes: each takes the attributes (`inert`, `aria-hidden` from the provider).\r\n inheritAttrs: false,\r\n slots: Object as SlotsType<{ default?: (props: OverlaySlotProps) => VNode[] }>,\r\n setup(_, { slots, attrs }) {\r\n const manager = useManager();\r\n const scope = dragScope(manager);\r\n const setElement = (value: HTMLElement | null) => {\r\n // A box that went on as a flight's is no longer the drag's.\r\n if (value || manager.active.value) manager.overlayElement.value = value;\r\n };\r\n\r\n const views = new WeakMap<Flight, FlightView>();\r\n const viewOf = (flight: Flight): FlightView => {\r\n let view = views.get(flight);\r\n if (!view) {\r\n const { active, over } = flight;\r\n view = {\r\n scope: flightScope(flight),\r\n props: { active, items: active.items, over, accepted: over?.accepted ?? false, status: 'dropping', mode: flight.mode, to: flight.to },\r\n style: boxStyle(flight.rect),\r\n onElement: (element) => (flight.element = element),\r\n };\r\n views.set(flight, view);\r\n }\r\n return view;\r\n };\r\n\r\n const visible = computed(() => {\r\n const status = manager.status.value;\r\n return !!manager.active.value && manager.hasOverlay && (status === 'dragging' || status === 'dropping');\r\n });\r\n\r\n // Smooth snapping glides between snapped positions while dragging. The transition\r\n // goes away with `dragging`: a running CSS transition would override the WAAPI\r\n // drop animation (transitions sit above animations in the cascade).\r\n const transition = computed(() => {\r\n if (manager.status.value !== 'dragging' || prefersReducedMotion()) return undefined;\r\n const smooth = getOverlaySmoothing(manager.getModifiers());\r\n return smooth ? `transform ${smooth.duration}ms ${smooth.easing}` : undefined;\r\n });\r\n\r\n const style = computed(() => {\r\n const current = manager.active.value!;\r\n const offset = manager.transform.value;\r\n // Sized and placed as collision sees it: resized around the grab point.\r\n const box = manager.getOverlayRect(current, offset);\r\n // While `transform` glides (smooth snapping), the shift of a resize goes to\r\n // `translate`, so it keeps pace with the size. Otherwise, and on drop (the drop\r\n // animation moves `transform` from this rect), it all sits in `transform`: then\r\n // `translate` keeps the dropped box on what it lands on while that scrolls (`follow.ts`).\r\n const glide = !!transition.value;\r\n const x = glide ? current.rect.left + offset.x : box.left;\r\n const y = glide ? current.rect.top + offset.y : box.top;\r\n return {\r\n position: 'fixed',\r\n top: '0',\r\n left: '0',\r\n zIndex: '9999',\r\n pointerEvents: 'none',\r\n transformOrigin: '0 0',\r\n willChange: 'transform',\r\n boxSizing: 'border-box',\r\n width: `${box.width}px`,\r\n height: `${box.height}px`,\r\n transform: `translate3d(${x}px, ${y}px, 0)`,\r\n translate: glide ? `${box.left - x}px ${box.top - y}px` : undefined,\r\n transition: transition.value,\r\n } as const;\r\n });\r\n\r\n /** Where the drop would go, kept as it was at the release while the drop is decided. */\r\n let landingTo: DropDestination | null = null;\r\n\r\n /**\r\n * A box's content: the drop target's overlay around the drag's own (its component, the\r\n * provider's slot, the clone). A change of component animates (`overlayTransition`).\r\n */\r\n const content = (props: OverlaySlotProps, target: Component | undefined, own: Component | null) => {\r\n const renderOwn = () => renderOverlay(own, slots.default, props, DefaultPreview);\r\n const shown = target ? h(target, overlayProps(target, props), { default: renderOwn }) : renderOwn();\r\n // The content's root is keyed by its component: a new one is new content.\r\n const option = manager.props.overlayTransition;\r\n const change = option === false ? null : option === true || option == null ? DEFAULT_TRANSITION : option;\r\n const root = change && transitionable(shown);\r\n return root ? h(Transition, change, () => cloneVNode(root, { key: keyOf(target ?? own) })) : shown;\r\n };\r\n\r\n const dragBox = () => {\r\n const current = manager.active.value!;\r\n const over = manager.over.value;\r\n if (manager.status.value === 'dragging') landingTo = manager.getDestination();\r\n const props: OverlaySlotProps = {\r\n active: current,\r\n items: current.items,\r\n over,\r\n accepted: over?.accepted ?? false,\r\n status: manager.status.value,\r\n mode: manager.mode.value,\r\n to: landingTo,\r\n };\r\n // A target that takes the drag may show its own overlay: the drag's own is its slot.\r\n const target = over?.accepted ? manager.getDroppable(over.id)?.getOverlay?.() : undefined;\r\n return h(\r\n OverlayBox,\r\n { ...attrs, key: manager.sessionId(), scope, boxStyle: style.value, status: props.status, onElement: setElement },\r\n () => content(props, target, manager.overlayComponent),\r\n );\r\n };\r\n\r\n return () => {\r\n // The landing boxes first, the drag's last: a drag's box goes on as its flight's in place.\r\n const boxes = manager.flights.value.map((flight) => {\r\n const view = viewOf(flight);\r\n return h(\r\n OverlayBox,\r\n { ...attrs, key: flight.id, scope: view.scope, boxStyle: view.style, status: 'dropping', onElement: view.onElement },\r\n () => content(view.props, flight.target, flight.component),\r\n );\r\n });\r\n if (visible.value) boxes.push(dragBox());\r\n return boxes;\r\n };\r\n },\r\n});\r\n","import {\r\n defineComponent,\r\n h,\r\n onMounted,\r\n onScopeDispose,\r\n provide,\r\n shallowRef,\r\n Teleport,\r\n useId,\r\n type PropType,\r\n type SlotsType,\r\n type TransitionProps,\r\n type VNode,\r\n} from 'vue';\r\nimport { defaultDocument, defaultWindow, useEventListener } from '@vueuse/core';\r\nimport type {\r\n ActivationOptions,\r\n Announcements,\r\n AutoAnimation,\r\n AutoScrollOptions,\r\n CollisionDetection,\r\n DnDEndEvent,\r\n DnDEvent,\r\n DnDProviderProps,\r\n DropAnimation,\r\n HapticsOptions,\r\n KeyboardOptions,\r\n LayoutAnimation,\r\n Modifier,\r\n OverlaySlotProps,\r\n Sensor,\r\n} from '../types';\r\nimport { createDnDManager } from './manager';\r\nimport { DND_CONTEXT, useManager } from './context';\r\nimport { devtoolsHook } from './devtoolsHook';\r\nimport { useSensors } from './sensors/host';\r\nimport { useNativeDrags } from './native/bridge';\r\nimport { pointerSensor } from './sensors/pointer';\r\nimport { keyboardSensor } from './sensors/keyboard';\r\nimport { useAutoScroll } from './autoscroll';\r\nimport { DragOverlay } from './DragOverlay';\r\nimport { DEFAULT_INSTRUCTIONS, VISUALLY_HIDDEN } from './a11y';\r\nimport { injectDefaultStyles } from './styles';\r\n\r\n/** `sensors` by default. */\r\nconst DEFAULT_SENSORS: readonly Sensor[] = [pointerSensor, keyboardSensor];\r\n\r\nconst LiveRegion = /* @__PURE__ */ defineComponent({\r\n name: 'DnDLiveRegion',\r\n setup() {\r\n const manager = useManager();\r\n return () =>\r\n h(\r\n 'div',\r\n { role: 'status', 'aria-live': 'assertive', 'aria-atomic': 'true', style: VISUALLY_HIDDEN },\r\n manager.announcement.value,\r\n );\r\n },\r\n});\r\n\r\n/**\r\n * Owns the drags of everything rendered inside it: input, the overlay, the selection,\r\n * auto-scroll and the screen reader announcements (see `DnDProviderProps`).\r\n */\r\nexport const DnDProvider = /* @__PURE__ */ defineComponent({\r\n name: 'DnDProvider',\r\n props: {\r\n collision: Function as PropType<CollisionDetection>,\r\n modifiers: Array as PropType<Modifier[]>,\r\n animation: { type: [Boolean, Object, Function] as PropType<LayoutAnimation>, default: undefined },\r\n dropAnimation: { type: [Boolean, Object, Function] as PropType<DropAnimation>, default: undefined },\r\n animateChanges: { type: [Boolean, Object] as PropType<AutoAnimation>, default: undefined },\r\n autoScroll: { type: [Boolean, Object] as PropType<boolean | AutoScrollOptions>, default: true },\r\n activation: Object as PropType<ActivationOptions>,\r\n keyboard: { type: [Boolean, Object] as PropType<KeyboardOptions | false>, default: undefined },\r\n sensors: Array as PropType<Sensor[]>,\r\n haptics: { type: [Boolean, Object] as PropType<boolean | HapticsOptions>, default: undefined },\r\n copyModifier: { type: String as PropType<string | null>, default: 'Alt' },\r\n overlayTo: { type: [String, Object] as PropType<string | HTMLElement>, default: 'body' },\r\n overlayFit: { type: String as PropType<'slot' | 'source'>, default: 'slot' },\r\n overlayPreviews: { type: [Number, String] as PropType<number | 'all'>, default: 5 },\r\n overlayTransition: { type: [Boolean, Object] as PropType<boolean | TransitionProps>, default: true },\r\n overlayClass: { type: [String, Object, Array] as PropType<DnDProviderProps['overlayClass']>, default: undefined },\r\n announcements: { type: [Boolean, Object] as PropType<Partial<Announcements> | false>, default: undefined },\r\n screenReaderInstructions: String,\r\n defaultStyles: { type: Boolean, default: true },\r\n },\r\n emits: {\r\n dragStart: (_event: DnDEvent) => true,\r\n dragMove: (_event: DnDEvent) => true,\r\n dragOver: (_event: DnDEvent) => true,\r\n dragEnd: (_event: DnDEndEvent) => true,\r\n dragCancel: (_event: DnDEvent) => true,\r\n dragResume: (_event: DnDEvent) => true,\r\n dragSettle: (_event: DnDEvent | DnDEndEvent) => true,\r\n },\r\n slots: Object as SlotsType<{\r\n default?: () => VNode[];\r\n /**\r\n * Overlay for drags without an `overlay` component of their own (item, list or\r\n * tree option). Rendering nothing (`v-if`) falls back to the clone.\r\n */\r\n overlay?: (props: OverlaySlotProps) => VNode[];\r\n }>,\r\n setup(props, { slots, emit }) {\r\n const manager = createDnDManager(props as DnDProviderProps);\r\n manager.instructionsId = `dnd-kit-instructions-${useId()}`;\r\n provide(DND_CONTEXT, manager);\r\n // Reports to the devtools only when the plugin is installed (`devtoolsHook.ts`).\r\n devtoolsHook()?.provider(manager);\r\n\r\n manager.addMonitor({\r\n onDragStart: (event) => emit('dragStart', event),\r\n onDragMove: (event) => emit('dragMove', event),\r\n onDragOver: (event) => emit('dragOver', event),\r\n onDragEnd: (event) => emit('dragEnd', event),\r\n onDragCancel: (event) => emit('dragCancel', event),\r\n onDragResume: (event) => emit('dragResume', event),\r\n onDragSettle: (event) => emit('dragSettle', event),\r\n });\r\n\r\n useSensors(manager, DEFAULT_SENSORS);\r\n useNativeDrags(manager);\r\n useAutoScroll(manager);\r\n\r\n const refresh = () => manager.scheduleFrame();\r\n useEventListener(defaultDocument, 'scroll', refresh, { capture: true, passive: true });\r\n useEventListener(defaultWindow, 'resize', refresh, { passive: true });\r\n\r\n // The teleported part renders on the client only: SSR can't place it into <body>\r\n // (hydration mismatch in Nuxt), and nothing in it is needed before a drag.\r\n const mounted = shallowRef(false);\r\n onMounted(() => {\r\n mounted.value = true;\r\n injectDefaultStyles(props.defaultStyles);\r\n });\r\n onScopeDispose(manager.destroy);\r\n\r\n return () => [\r\n slots.default?.(),\r\n mounted.value\r\n ? h(Teleport, { to: props.overlayTo }, [\r\n // A visual copy of the dragged item: hidden from assistive tech and focus.\r\n h(\r\n DragOverlay,\r\n { inert: true, 'aria-hidden': 'true' },\r\n slots.overlay ? { default: slots.overlay } : undefined,\r\n ),\r\n h(\r\n 'div',\r\n { id: manager.instructionsId, style: { display: 'none' } },\r\n props.screenReaderInstructions ?? DEFAULT_INSTRUCTIONS,\r\n ),\r\n h(LiveRegion),\r\n ])\r\n : null,\r\n ];\r\n },\r\n});\r\n","import type { AcceptContext, AcceptMode, AcceptRule, DragItem, Key } from '../types';\r\n\r\nexport const normalizeTypes = (type: string | string[] | null | undefined): string[] =>\r\n type == null ? [] : Array.isArray(type) ? type : [type];\r\n\r\nconst itemMatches = (item: DragItem, allowed: string[]) =>\r\n item.type.length === 0 || item.type.some((type) => allowed.includes(type));\r\n\r\n/** Splits dragged items into accepted and rejected by a rule. */\r\nexport const partitionByRule = (\r\n rule: AcceptRule | undefined,\r\n context: AcceptContext,\r\n): { accepted: Key[]; rejected: Key[] } => {\r\n if (rule == null || rule === '*') {\r\n return { accepted: context.items.map((item) => item.id), rejected: [] };\r\n }\r\n if (typeof rule === 'function') {\r\n return rule(context)\r\n ? { accepted: context.items.map((item) => item.id), rejected: [] }\r\n : { accepted: [], rejected: context.items.map((item) => item.id) };\r\n }\r\n const allowed = Array.isArray(rule) ? rule : [rule];\r\n const accepted: Key[] = [];\r\n const rejected: Key[] = [];\r\n for (const item of context.items) {\r\n (itemMatches(item, allowed) ? accepted : rejected).push(item.id);\r\n }\r\n return { accepted, rejected };\r\n};\r\n\r\nexport const matchesRule = (\r\n rule: AcceptRule | undefined,\r\n context: AcceptContext,\r\n mode: AcceptMode = 'all',\r\n): boolean => {\r\n const { accepted, rejected } = partitionByRule(rule, context);\r\n return mode === 'some' ? accepted.length > 0 : rejected.length === 0;\r\n};\r\n","import { toValue, type MaybeRefOrGetter } from 'vue';\r\nimport type { MaybeReadonlyRefOrGetter } from '../types';\r\n\r\n/** `toValue` for read-only option values (see `MaybeReadonlyRefOrGetter`). */\r\nexport const read = <T>(source: MaybeReadonlyRefOrGetter<T>): T =>\r\n toValue(source as MaybeRefOrGetter<T>);\r\n","import { computed, markRaw, onScopeDispose, unref, watch, watchEffect, type Component } from 'vue';\r\nimport type { DraggableOptions, DraggableReturn, DropAnimation, Key, MaybeElementRef } from '../types';\r\nimport type { DraggableEntry } from './manager';\r\nimport { useManager } from './context';\r\nimport { normalizeTypes } from './accept';\r\nimport { dragModifiers } from './modifiers';\r\nimport { createId, isNativelyFocusable, toElement } from '../utils/dom';\r\nimport { read } from '../utils/read';\r\n\r\n/** Hooks used by the sortable layer on top of a plain draggable. */\r\nexport interface DraggableInternals {\r\n getItem?: () => unknown;\r\n getContainer?: () => HTMLElement | null;\r\n /** Overlay when the option has none (a sortable item: its list's). */\r\n getOverlay?: () => Component | undefined;\r\n /** Drop animation when the option has none (a sortable item: its list's). */\r\n getDropAnimation?: () => DropAnimation | undefined;\r\n /** A sortable item's group: another window's lists of it take the item. */\r\n getGroup?: () => string;\r\n}\r\n\r\n/**\r\n * The `overlay` option as the manager keeps it: on/off, or a component. Components\r\n * are never made reactive (rfcs/0001-v3.md §13), wherever the options came from.\r\n */\r\nexport const toOverlay = (overlay: boolean | Component | undefined): boolean | Component =>\r\n overlay == null || overlay === true ? true : overlay && markRaw(overlay);\r\n\r\n// ─── Attributes ────────────────────────────────────────────────────────────────\r\n// The library only ever touches attributes it added itself: anything already on the\r\n// element belongs to the user and is never overwritten (rfcs/0001-v3.md §10). The\r\n// exception is `aria-describedby`, a list the instructions id joins (below).\r\n\r\n/** Attribute name → the value the library set, per element. */\r\nconst ownedAttributes = new WeakMap<Element, Map<string, string>>();\r\n\r\n/** True when the attribute is (still) the library's: absent, or exactly what it set. */\r\nconst ownsAttribute = (element: Element, name: string): boolean => {\r\n const current = element.getAttribute(name);\r\n if (current === null) return true;\r\n const ours = ownedAttributes.get(element)?.get(name);\r\n if (ours === current) return true;\r\n // Set by the user from the start, or changed by them (e.g. a binding) since.\r\n ownedAttributes.get(element)?.delete(name);\r\n return false;\r\n};\r\n\r\nconst setOwnAttribute = (element: Element, name: string, value: string) => {\r\n if (!ownsAttribute(element, name)) return;\r\n let owned = ownedAttributes.get(element);\r\n if (!owned) ownedAttributes.set(element, (owned = new Map()));\r\n owned.set(name, value);\r\n if (element.getAttribute(name) !== value) element.setAttribute(name, value);\r\n};\r\n\r\nconst removeOwnAttribute = (element: Element, name: string) => {\r\n const owned = ownedAttributes.get(element);\r\n if (!owned?.has(name)) return;\r\n if (ownsAttribute(element, name)) element.removeAttribute(name);\r\n owned.delete(name);\r\n};\r\n\r\n// `aria-describedby` is a list of ids, and UI kits put their own there (a tooltip on its\r\n// activator). The instructions id joins it as one more token, after the ids already\r\n// there: the library adds, restores and removes that token only. The id is generated by\r\n// the provider, so any occurrence of it is the library's.\r\n\r\nconst DESCRIBED_BY = 'aria-describedby';\r\n\r\n/** Element → the instructions id the library keeps in its `aria-describedby`. */\r\nconst describedBy = new WeakMap<Element, string>();\r\n\r\nconst idsOf = (element: Element): string[] => element.getAttribute(DESCRIBED_BY)?.split(/\\s+/).filter(Boolean) ?? [];\r\n\r\nconst appendId = (element: Element, id: string) => {\r\n const ids = idsOf(element);\r\n if (!ids.includes(id)) element.setAttribute(DESCRIBED_BY, [...ids, id].join(' '));\r\n};\r\n\r\n/** Puts the id back when a binding rewrites the attribute (a kit tooltip while it is open). */\r\nlet describedByObserver: MutationObserver | null = null;\r\n\r\nconst addDescription = (element: Element, id: string) => {\r\n if (describedBy.get(element) !== id) {\r\n describedBy.set(element, id);\r\n describedByObserver ??= new MutationObserver((records) => {\r\n for (const { target } of records) {\r\n const own = describedBy.get(target as Element);\r\n if (own) appendId(target as Element, own);\r\n }\r\n });\r\n describedByObserver.observe(element, { attributeFilter: [DESCRIBED_BY] });\r\n }\r\n appendId(element, id);\r\n};\r\n\r\nconst removeDescription = (element: Element) => {\r\n const id = describedBy.get(element);\r\n if (id === undefined) return;\r\n describedBy.delete(element);\r\n const ids = idsOf(element);\r\n if (!ids.includes(id)) return;\r\n const rest = ids.filter((token) => token !== id);\r\n if (rest.length) element.setAttribute(DESCRIBED_BY, rest.join(' '));\r\n else element.removeAttribute(DESCRIBED_BY);\r\n};\r\n\r\nconst releaseAttributes = (element: Element) => {\r\n removeDescription(element);\r\n const owned = ownedAttributes.get(element);\r\n if (!owned) return;\r\n for (const name of [...owned.keys()]) removeOwnAttribute(element, name);\r\n ownedAttributes.delete(element);\r\n};\r\n\r\nconst hasButtonRole = (element: Element) =>\r\n (element.getAttribute('role') ?? (element.tagName === 'BUTTON' ? 'button' : null)) === 'button';\r\n\r\nconst applyStaticAttributes = (element: HTMLElement, instructionsId: string, roleDescription: string) => {\r\n if (!isNativelyFocusable(element)) setOwnAttribute(element, 'tabindex', '0');\r\n // A native <button> already has the role.\r\n if (element.tagName !== 'BUTTON') setOwnAttribute(element, 'role', 'button');\r\n setOwnAttribute(element, 'aria-roledescription', roleDescription);\r\n if (instructionsId) addDescription(element, instructionsId);\r\n};\r\n\r\nexport function createDraggable<TData>(\r\n target: MaybeElementRef,\r\n options: DraggableOptions<TData>,\r\n internals: DraggableInternals & { roleDescription?: string } = {},\r\n): DraggableReturn {\r\n const manager = useManager();\r\n const fallbackId = createId('draggable');\r\n const id = computed<Key>(() => read(options.id) ?? fallbackId);\r\n\r\n const getElement = () => toElement(target);\r\n /** Handle element; a selector resolves to the first match inside the draggable. */\r\n const getHandleElement = (): HTMLElement | null => {\r\n const handle = read(options.handle);\r\n if (handle == null) return null;\r\n if (typeof handle === 'string') return getElement()?.querySelector<HTMLElement>(handle) ?? null;\r\n return toElement(handle);\r\n };\r\n\r\n /** The drag area (`makeDragArea`) the draggable is in, whose rules its drags follow. */\r\n const area = () => manager.findArea(getElement());\r\n\r\n const entry: DraggableEntry = {\r\n id: id.value,\r\n getOverlay: () => toOverlay(unref(options.overlay) ?? internals.getOverlay?.()),\r\n getDropAnimation: () => unref(options.dropAnimation) ?? internals.getDropAnimation?.(),\r\n getModifiers: () => dragModifiers(read(options.modifiers), read(options.axis), area()),\r\n // Per pointer kind: the draggable's own constraint, else its area's.\r\n getActivation: () => {\r\n const own = read(options.activation);\r\n const inherited = area()?.getActivation();\r\n return own && inherited ? { ...inherited, ...own } : (own ?? inherited);\r\n },\r\n canDrag: options.canDrag,\r\n getKeyboard: () => read(options.keyboardMode),\r\n getElement,\r\n getHandle: () => {\r\n const handle = read(options.handle);\r\n return typeof handle === 'string' ? handle : getHandleElement();\r\n },\r\n getFocusTarget: () => getHandleElement() ?? getElement(),\r\n getData: () => read(options.data),\r\n getLabel: () => read(options.label),\r\n getTypes: () => normalizeTypes(read(options.type)),\r\n isDisabled: () => !!read(options.disabled) || manager.inDisabledArea(getElement()),\r\n getItem: internals.getItem,\r\n getContainer: internals.getContainer,\r\n getNative: () => {\r\n const native = read(options.native);\r\n return native ? (native === true ? {} : native) : undefined;\r\n },\r\n getGroup: internals.getGroup,\r\n };\r\n\r\n // The browser's own drag of the element (an image, a link, a selection in it) would fight\r\n // the library's; with `native`, a mouse drag is that drag (`native/bridge.ts`).\r\n const preventNativeDrag = (event: Event) => {\r\n if (!entry.getNative!()) event.preventDefault();\r\n };\r\n\r\n let unregister = manager.registerDraggable(entry);\r\n watch(id, (next) => {\r\n unregister();\r\n entry.id = next;\r\n unregister = manager.registerDraggable(entry);\r\n });\r\n\r\n let bound: { element: HTMLElement; id: Key } | null = null;\r\n const unbind = () => {\r\n if (!bound) return;\r\n manager.unbindDraggableElement(bound.element, bound.id);\r\n bound.element.removeEventListener('dragstart', preventNativeDrag);\r\n bound = null;\r\n };\r\n\r\n watch(\r\n [getElement, id],\r\n ([element, currentId]) => {\r\n unbind();\r\n if (!element) return;\r\n manager.bindDraggableElement(element, currentId);\r\n element.addEventListener('dragstart', preventNativeDrag);\r\n bound = { element, id: currentId };\r\n },\r\n { immediate: true, flush: 'post' },\r\n );\r\n\r\n // Attributes go on the focus target (the handle when there is one). One effect, so\r\n // moving them to a new target, updating the dynamic ones and turning them off can't race.\r\n let attributeTarget: HTMLElement | null = null;\r\n const roleDescription = internals.roleDescription ?? 'draggable';\r\n // A computed of its own: a drag starting or ending runs the effect below for this item\r\n // when its own state changes, not for every draggable of the provider.\r\n const pressed = computed(() => manager.active.value?.id === id.value);\r\n watchEffect(\r\n () => {\r\n const element = read(options.attributes) === false ? null : (getHandleElement() ?? getElement());\r\n if (element !== attributeTarget) {\r\n if (attributeTarget) releaseAttributes(attributeTarget);\r\n attributeTarget = element;\r\n }\r\n if (!element) return;\r\n applyStaticAttributes(element, manager.instructionsId, roleDescription);\r\n setOwnAttribute(element, 'aria-disabled', String(entry.isDisabled()));\r\n // `aria-pressed` only means something on a button, and only while dragging.\r\n if (pressed.value && hasButtonRole(element)) {\r\n setOwnAttribute(element, 'aria-pressed', 'true');\r\n } else {\r\n removeOwnAttribute(element, 'aria-pressed');\r\n }\r\n },\r\n { flush: 'post' },\r\n );\r\n\r\n // The selection is keyed by id, so it survives unmounts (virtual lists).\r\n onScopeDispose(() => {\r\n unbind();\r\n unregister();\r\n if (attributeTarget) releaseAttributes(attributeTarget);\r\n attributeTarget = null;\r\n });\r\n\r\n // Dragged, or landing: until its overlay is there, its element is still the one being moved.\r\n const isDragging = computed(() => !!manager.active.value?.ids.includes(id.value) || !!manager.flightOf(id.value));\r\n // The overlay as the drag took it at its start. The element moves with the content it\r\n // is in (scrolling): what that content moved is taken off, so it stays under the pointer.\r\n const transform = computed(() => {\r\n // The browser's own drag (`native`) leaves the element in place and draws its image.\r\n if (manager.active.value?.id !== id.value || manager.hasOverlay || manager.active.value.native) return null;\r\n const { x, y } = manager.transform.value;\r\n const shift = manager.containerShift.value;\r\n return shift.x || shift.y ? { x: x - shift.x, y: y - shift.y } : manager.transform.value;\r\n });\r\n const selected = computed({\r\n get: () => manager.selection.has(id.value),\r\n set: (value) => {\r\n if (value) manager.selection.add(id.value);\r\n else manager.selection.delete(id.value);\r\n },\r\n });\r\n\r\n return { id, isDragging, transform, selected };\r\n}\r\n\r\n/** Makes an element draggable. Free drag by default; sortable lists build on top of it. */\r\nexport function makeDraggable<TData = unknown>(\r\n target: MaybeElementRef,\r\n options: DraggableOptions<TData> = {},\r\n): DraggableReturn {\r\n return createDraggable(target, options);\r\n}\r\n","import { computed, markRaw, onScopeDispose, unref, watch } from 'vue';\r\nimport type {\r\n Active,\r\n DroppableOptions,\r\n DroppableReturn,\r\n Key,\r\n MaybeElementRef,\r\n Placement,\r\n} from '../types';\r\nimport type { DroppableEntry } from './manager';\r\nimport { useManager } from './context';\r\nimport { matchesRule } from './accept';\r\nimport { createId, toElement } from '../utils/dom';\r\nimport { read } from '../utils/read';\r\nimport { getCenter } from '../animation/layout';\r\nimport { takesExternal } from './native/data';\r\n\r\n/** Hooks used by the sortable layer: it accepts by group rules instead of `accept`. */\r\nexport interface DroppableInternals {\r\n accepts?: (active: Active) => boolean;\r\n /** The list's group: its lists take its items from another window of the app. */\r\n getGroup?: () => string;\r\n}\r\n\r\nexport function createDroppable<TData>(\r\n target: MaybeElementRef,\r\n options: DroppableOptions<TData>,\r\n internals: DroppableInternals = {},\r\n): DroppableReturn {\r\n const manager = useManager();\r\n const fallbackId = createId('droppable');\r\n const id = computed<Key>(() => read(options.id) ?? fallbackId);\r\n\r\n // A drag from outside the page by its own rule (`external`); a list's group rules take\r\n // that in too, as they make items for it.\r\n const accepts =\r\n internals.accepts ??\r\n ((active: Active) =>\r\n active.external && !active.external.group\r\n ? takesExternal(read(options.external), active.external)\r\n : matchesRule(\r\n unref(options.accept),\r\n { active, items: active.items, types: active.items.flatMap((item) => item.type) },\r\n read(options.acceptMode),\r\n ));\r\n\r\n const entry: DroppableEntry = {\r\n id: id.value,\r\n getPriority: () => read(options.priority) ?? 0,\r\n // Lists and trees accept by group rules.\r\n sortable: !!internals.accepts,\r\n options,\r\n getElement: () => toElement(target),\r\n getData: () => read(options.data),\r\n getLabel: () => read(options.label),\r\n isDisabled: () => !!read(options.disabled),\r\n accepts,\r\n getExternal: () => read(options.external),\r\n getGroup: internals.getGroup,\r\n getOverlay: () => {\r\n const overlay = unref(options.overOverlay);\r\n return overlay ? markRaw(overlay) : undefined;\r\n },\r\n getDropAnimation: () => unref(options.overDropAnimation),\r\n onDragEnter: options.onDragEnter,\r\n onDragLeave: options.onDragLeave,\r\n onBeforeDrop: options.onBeforeDrop,\r\n onDrop: options.onDrop,\r\n };\r\n\r\n let unregister = manager.registerDroppable(entry);\r\n watch(id, (next) => {\r\n unregister();\r\n entry.id = next;\r\n unregister = manager.registerDroppable(entry);\r\n });\r\n onScopeDispose(() => unregister());\r\n\r\n const isOver = computed(() => manager.over.value?.id === id.value);\r\n // While an async `onBeforeDrop` decides, nothing has changed yet and the rules still\r\n // hold. Once the drop is decided the drag state is gone (`active` is `null`): they stop.\r\n const isAccepting = computed(() => {\r\n const active = manager.active.value;\r\n return !!active && !entry.isDisabled() && accepts(active);\r\n });\r\n const placement = computed<Placement | null>(() => {\r\n const over = manager.over.value;\r\n const pointer = manager.pointer.value;\r\n if (!pointer || over?.id !== id.value) return null;\r\n const center = getCenter(over.rect);\r\n return {\r\n top: pointer.y <= center.y,\r\n bottom: pointer.y > center.y,\r\n left: pointer.x <= center.x,\r\n right: pointer.x > center.x,\r\n };\r\n });\r\n\r\n return { id, isOver, isAccepting, placement };\r\n}\r\n\r\n/** Makes an element a drop target. */\r\nexport function makeDroppable<TData = unknown>(\r\n target: MaybeElementRef,\r\n options: DroppableOptions<TData> = {},\r\n): DroppableReturn {\r\n return createDroppable(target, options);\r\n}\r\n","/**\r\n * A draft change usually moves a few keys (a reorder), so what is derived from a draft\r\n * (the key → index map, the rendered items) is patched over the changed run instead of\r\n * rebuilt: with 50k rows a rebuild per reorder costs more than a frame.\r\n */\r\n\r\nimport type { Key } from '../types';\r\n\r\n/** `previous[start, end)` became `next[start, nextEnd)`; the rest matches position by position. */\r\nexport interface ChangedRun {\r\n start: number;\r\n end: number;\r\n nextEnd: number;\r\n}\r\n\r\n/**\r\n * The run where `next` differs from `previous`. When their lengths differ every later\r\n * index shifts, so the run reaches the end of both.\r\n */\r\nexport const changedRun = (previous: readonly Key[], next: readonly Key[]): ChangedRun => {\r\n const shared = Math.min(previous.length, next.length);\r\n let start = 0;\r\n while (start < shared && previous[start] === next[start]) start++;\r\n let end = previous.length;\r\n let nextEnd = next.length;\r\n if (end === nextEnd) {\r\n while (end > start && previous[end - 1] === next[end - 1]) {\r\n end--;\r\n nextEnd--;\r\n }\r\n }\r\n return { start, end, nextEnd };\r\n};\r\n\r\n/**\r\n * Turns `map` (key → index in `previous`) into the map of `next`, if their changed run\r\n * is at most half of `next`; `false` when building a new map is cheaper.\r\n */\r\nexport const patchIndexMap = (map: Map<Key, number>, previous: readonly Key[], next: readonly Key[]): boolean => {\r\n const { start, end, nextEnd } = changedRun(previous, next);\r\n if (nextEnd - start > next.length / 2) return false;\r\n for (let index = start; index < end; index++) map.delete(previous[index]!);\r\n for (let index = start; index < nextEnd; index++) map.set(next[index]!, index);\r\n return true;\r\n};\r\n","/**\r\n * The state of a sortable group and the session of a drag. Every module of the group\r\n * gets the group (`GroupContext`) passed in and keeps no state of its own, so the\r\n * groups of several providers stay independent.\r\n */\r\n\r\nimport { shallowRef, type ShallowRef } from 'vue';\r\nimport type { Coordinates, DnDEvent, Key, Rect, Size, SortableIndicator } from '../types';\r\nimport type { DnDManager } from '../core/manager';\r\nimport type { ListEntry } from './entry';\r\nimport type { DropResult } from './drop';\r\nimport type { Hysteresis } from './stability';\r\nimport type { SortableAnnouncement, SortableSpot } from './announcements';\r\nimport type { SortableMode } from './modes/mode';\r\nimport type { NearSet } from './flip';\r\nimport type { AutoPass } from './autoAnimate';\r\nimport { patchIndexMap } from './draft';\r\n\r\nexport interface Session {\r\n activeKey: Key;\r\n /**\r\n * Dragged key the slot stands for: the active key, unless that is a tree node riding in\r\n * another selected one (VS Code), which then leads the drag with the active node inside.\r\n */\r\n lead: Key;\r\n /** Every moved key in document order (multi-drag), the lead included. */\r\n keys: Key[];\r\n /** Where the lead started; `list` is `null` for an external draggable. */\r\n origin: { list: Key | null; index: number };\r\n /** Key holding the active slot in the drafts: the lead, its copy or a created item. */\r\n slot: Key;\r\n /** List whose draft holds the slot; `null` while no draft does (copy over its palette, external item outside). */\r\n list: Key | null;\r\n lock: Key | null;\r\n /** Item objects at drag start (plus copies and created items), so keys can be mapped back across lists. */\r\n items: Map<Key, unknown>;\r\n size: Size;\r\n result: DropResult | null;\r\n\r\n /** The other dragged keys (multi-drag). */\r\n others: Set<Key>;\r\n /** List and index every dragged key started at; rejected keys go back there. */\r\n sources: Map<Key, { list: Key; index: number }>;\r\n /** Multi-drag `'stack'`: the others are collapsed out of the drafts. */\r\n stacked: boolean;\r\n /** Multi-drag `'group'`: the others travel with the slot in the drafts. */\r\n grouped: boolean;\r\n /**\r\n * Keys travelling with the slot, in drop order, the slot included: contiguous in the\r\n * draft of `list`. The slot alone unless `grouped`.\r\n */\r\n block: Key[];\r\n /** Move-mode drafts at drag start; swaps and copy toggles rebuild from them. */\r\n base: Map<Key, Key[]>;\r\n /**\r\n * What the slot is (`modes/`): the dragged item itself (`sort`), its copy (`copy`) or an\r\n * item made for a plain draggable (`insert`). An exchange held is `swap` (see `modeOf`).\r\n */\r\n mode: SortableMode;\r\n /** Copy of each dragged key, made once per session so the key stays stable; `null` when `clone` refused. */\r\n copies: Map<Key, Key | null>;\r\n /** Item made for an external draggable, per list. */\r\n created: Map<Key, Key | null>;\r\n /** The other items a list made for it (`createItem` gave several), which the drop puts after the slot. */\r\n extra: Map<Key, Key[]>;\r\n /** Item the active one is exchanged with (`behavior: 'swap'`). */\r\n swap: Key | null;\r\n /** Last valid indicator; kept after leaving the list for `dropOutside: 'placeholder'`. */\r\n indicator: SortableIndicator | null;\r\n /** Indicator the drop commits at, decided in `onBeforeDrop`. */\r\n marker: SortableIndicator | null;\r\n hysteresis: Hysteresis | null;\r\n /** Last valid target and the pointer there: bridges one-frame gaps at list boundaries. */\r\n target: { list: Key; at: Coordinates } | null;\r\n /** A trash zone or `dropOutside: 'remove'` asked to remove the dragged items. */\r\n removed: boolean;\r\n /** `event.preventDefault()` in `onBeforeDrop` or `onDrop`: the drop isn't written. */\r\n prevented: boolean;\r\n /** Keyboard: resting on a drop target in the item `key`, reached with the arrow `direction`. */\r\n stop: { key: Key; direction: Coordinates } | null;\r\n /** Keyboard: on the plain drop target `away` (a trash zone) the arrows took the drag to, past the list. */\r\n away: Key | null;\r\n /**\r\n * Multi-drag `'group'` over a zone of its own or a refusing target: the block came apart,\r\n * the lists show every dragged item where it started until a list is hovered again.\r\n */\r\n apart: boolean;\r\n}\r\n\r\n/** What every session starts with, whatever is dragged. */\r\nexport type SessionStart = Omit<\r\n Session,\r\n 'lead' | 'keys' | 'origin' | 'slot' | 'list' | 'others' | 'stacked' | 'grouped' | 'block' | 'base' | 'mode'\r\n>;\r\n\r\nexport interface GroupContext {\r\n name: string;\r\n manager: DnDManager;\r\n lists: Map<Key, ListEntry>;\r\n /** Elements of the registered items, by key. */\r\n items: Map<Key, () => HTMLElement | null>;\r\n session: ShallowRef<Session | null>;\r\n /** Insertion line of `placeholder: 'indicator'` lists, while the pointer is over one. */\r\n indicator: ShallowRef<SortableIndicator | null>;\r\n indexCache: WeakMap<readonly Key[], Map<Key, number>>;\r\n /** Per list, its last draft that has a map in `indexCache`: the next draft takes the map over. */\r\n indexedDrafts: WeakMap<ListEntry, readonly Key[]>;\r\n /** Live state of the provider's `copyModifier`. */\r\n copyHeld: () => boolean;\r\n\r\n // FLIP (flip.ts)\r\n /** Bumped by every change of the drafts: a FLIP pass runs around the render. */\r\n version: ShallowRef<number>;\r\n /** Others of a finished `'stack'` drag: they fly out of the overlay into their slots. */\r\n returning: { keys: Set<Key>; from: Rect } | null;\r\n /** The next FLIP pass is the pickup of a `'group'` drag: the others travel into the block, from other lists too. */\r\n gathering: boolean;\r\n /** Items worth a FLIP during a drag: those near the visible area (see `flip.ts`). */\r\n near: NearSet | null;\r\n /** Keys registered while a FLIP pass waits for its render: the items that render creates. */\r\n fresh: Set<Key> | null;\r\n /** A drag's FLIP pass waits for its render: changes of the sources it renders are the drag's. */\r\n dragPass: boolean;\r\n\r\n // Changes no drag made (autoAnimate.ts)\r\n /** Lists whose items changed, measured before the change renders. */\r\n auto: AutoPass | null;\r\n /** Copies of items that left, still animating out, by key. */\r\n leaving: Map<Key, () => void>;\r\n\r\n /** List whose strategy and gap the overlay column follows. */\r\n columnList: Key | null;\r\n\r\n /**\r\n * Drop targets inside items, as of the target detection at `at` (that frame's pointer):\r\n * the middle band of each item holding one that takes the drag, by key, and the `ids`\r\n * of the targets that counted.\r\n */\r\n targets: { at: Coordinates | null; bands: Map<Key, Rect>; ids: Set<Key> };\r\n\r\n /** Pointer of the last move, and the projections run again for it (`followBlock`). */\r\n movedAt: Coordinates | null;\r\n followed: number;\r\n /** A pending `followBlock` pass: the drop waits for it. */\r\n following: Promise<void> | null;\r\n\r\n /** Text for the end or cancel announcement, and what it is about, computed while the session still existed. */\r\n announced: ({ key: Key } & SortableAnnouncement) | null;\r\n /** Last position announced (or picked up at), so an unchanged position isn't spoken again. */\r\n spokenSpot: string | null;\r\n}\r\n\r\nexport const createContext = (manager: DnDManager, name: string): GroupContext => ({\r\n name,\r\n manager,\r\n lists: new Map(),\r\n items: new Map(),\r\n session: shallowRef(null),\r\n indicator: shallowRef(null),\r\n indexCache: new WeakMap(),\r\n indexedDrafts: new WeakMap(),\r\n copyHeld: () => false,\r\n version: shallowRef(0),\r\n returning: null,\r\n gathering: false,\r\n near: null,\r\n fresh: null,\r\n dragPass: false,\r\n auto: null,\r\n leaving: new Map(),\r\n columnList: null,\r\n targets: { at: null, bands: new Map(), ids: new Set() },\r\n movedAt: null,\r\n followed: 0,\r\n following: null,\r\n announced: null,\r\n spokenSpot: null,\r\n});\r\n\r\nexport const sameKeys = (a: readonly Key[], b: readonly Key[]) =>\r\n a.length === b.length && a.every((key, index) => key === b[index]);\r\n\r\nexport const keysOf = (list: ListEntry) => list.draft.value ?? list.getKeys();\r\n\r\n/** The drag is over a drop target that is no list of this group (a trash zone, a target inside an item). */\r\nexport const isForeign = (g: GroupContext, event: DnDEvent) => !!event.over && !g.lists.has(event.over.id);\r\n\r\n/** The list with this id; none for `null` (no list holds the slot, an external drag's origin). */\r\nexport const listOf = (g: GroupContext, id: Key | null) => (id == null ? undefined : g.lists.get(id));\r\n\r\n/** A position in a list as announced, out of the list's current length. */\r\n/** What people call a list of the group: its `label` (its drop target's). */\r\nexport const listLabel = (g: GroupContext, list: Key): string | undefined => g.manager.getDroppable(list)?.getLabel?.();\r\n\r\n/** What people call an item: its `label` (its draggable's). */\r\nexport const itemLabel = (g: GroupContext, key: Key): string | undefined => g.manager.getDraggable(key)?.getLabel?.();\r\n\r\nexport const spotIn = (g: GroupContext, list: Key, index: number): SortableSpot => ({\r\n list,\r\n label: listLabel(g, list),\r\n index,\r\n length: g.lists.get(list)?.getKeys().length ?? 0,\r\n});\r\n\r\nexport const indexMap = (g: GroupContext, keys: readonly Key[]) => {\r\n let map = g.indexCache.get(keys);\r\n if (!map) {\r\n map = new Map(keys.map((key, index) => [key, index]));\r\n g.indexCache.set(keys, map);\r\n }\r\n return map;\r\n};\r\n\r\n/**\r\n * Key → index in `list`'s current order. A new draft takes over the map of the list's\r\n * previous one, patched over the run that changed (see `patchIndexMap`).\r\n */\r\nexport const indicesOf = (g: GroupContext, list: ListEntry): Map<Key, number> => {\r\n const draft = list.draft.value;\r\n if (!draft) return indexMap(g, list.getKeys());\r\n if (g.indexCache.has(draft)) return g.indexCache.get(draft)!;\r\n const previous = g.indexedDrafts.get(list);\r\n const map = previous && g.indexCache.get(previous);\r\n if (map && patchIndexMap(map, previous!, draft)) {\r\n g.indexCache.delete(previous!);\r\n g.indexCache.set(draft, map);\r\n }\r\n g.indexedDrafts.set(list, draft);\r\n return indexMap(g, draft);\r\n};\r\n\r\nexport const indexOf = (g: GroupContext, list: ListEntry, key: Key) => indicesOf(g, list).get(key) ?? -1;\r\n\r\nexport const lookup = (g: GroupContext, key: Key): unknown => {\r\n const snapshot = g.session.value?.items;\r\n if (snapshot?.has(key)) return snapshot.get(key);\r\n for (const list of g.lists.values()) {\r\n const item = list.getItem(key);\r\n if (item !== undefined) return item;\r\n }\r\n return undefined;\r\n};\r\n\r\nexport const listOfKey = (g: GroupContext, key: Key, useDraft: boolean): ListEntry | undefined => {\r\n for (const list of g.lists.values()) {\r\n if ((useDraft ? indicesOf(g, list) : indexMap(g, list.getKeys())).has(key)) return list;\r\n }\r\n return undefined;\r\n};\r\n\r\n/** Lists in document order, so multi-drag keys from several lists insert in the order the user sees. */\r\nexport const orderedLists = (g: GroupContext): ListEntry[] =>\r\n [...g.lists.values()].sort((a, b) => {\r\n const x = a.getElement();\r\n const y = b.getElement();\r\n if (!x || !y || x === y) return 0;\r\n return x.compareDocumentPosition(y) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;\r\n });\r\n","/**\r\n * Which lists of a group take the drag, and which of its keys: `group.pull` of the list\r\n * the drag comes from, `group.put` and `acceptMode` of the one it goes to.\r\n */\r\n\r\nimport type { Active, Key, SortableGroupOptions, SortablePutContext } from '../types';\r\nimport type { DnDManager } from '../core/manager';\r\nimport { listOf, lookup, type GroupContext, type Session } from './context';\r\nimport type { ListEntry } from './entry';\r\n\r\n/**\r\n * `group.put` of a list or tree for the items of `context`: a boolean, a function, or type\r\n * rules that each item must meet as a drop target's `accept` has them (an item without a\r\n * type fits any). An item not rendered (a virtual row) counts with the types of the drag.\r\n */\r\nexport const putAllows = (\r\n put: SortableGroupOptions['put'],\r\n context: SortablePutContext,\r\n manager: DnDManager,\r\n): boolean => {\r\n if (put === undefined || typeof put === 'boolean') return put ?? true;\r\n if (typeof put === 'function') return put(context);\r\n const allowed = typeof put === 'string' ? [put] : put;\r\n return context.keys.every((key) => {\r\n const types = manager.getDraggable(key)?.getTypes() ?? context.types;\r\n return !types.length || types.some((type) => allowed.includes(type));\r\n });\r\n};\r\n\r\nexport interface Partition {\r\n accepted: Key[];\r\n rejected: Key[];\r\n}\r\n\r\nexport const itemTypes = (g: GroupContext, key: Key): string[] => g.manager.getDraggable(key)?.getTypes() ?? [g.name];\r\n\r\n/** Which dragged keys `list` takes, by the rules of the session's mode; none for a disabled list. */\r\nexport const partition = (g: GroupContext, list: ListEntry, current: Session): Partition =>\r\n list.isDisabled() ? { accepted: [], rejected: current.keys } : current.mode.partition(g, list, current);\r\n\r\n/**\r\n * The rules for the dragged items themselves (or their copies): `group.pull` of their\r\n * list, then `group.put` of `list`, per key with `acceptMode: 'some'`, all or none otherwise.\r\n */\r\nexport const partitionMoved = (g: GroupContext, list: ListEntry, current: Session): Partition => {\r\n const all = { accepted: current.keys, rejected: [] as Key[] };\r\n const none = { accepted: [] as Key[], rejected: current.keys };\r\n if (list.id === current.origin.list) return all;\r\n if (listOf(g, current.origin.list)?.pull() === false) return none;\r\n const context = (keys: Key[]): SortablePutContext => ({\r\n keys,\r\n items: keys.map((key) => lookup(g, key)),\r\n types: [...new Set(keys.flatMap((key) => itemTypes(g, key)))],\r\n from: current.origin.list,\r\n to: list.id,\r\n });\r\n if ((list.acceptMode?.() ?? 'all') === 'all') return list.canPut(context(current.keys)) ? all : none;\r\n const accepted: Key[] = [];\r\n const rejected: Key[] = [];\r\n for (const key of current.keys) (list.canPut(context([key])) ? accepted : rejected).push(key);\r\n return { accepted, rejected };\r\n};\r\n\r\nexport const accepts = (g: GroupContext, list: ListEntry, active: Active) => {\r\n const current = g.session.value;\r\n if (!current || current.activeKey !== active.id) return false;\r\n const { accepted, rejected } = partition(g, list, current);\r\n return (list.acceptMode?.() ?? 'all') === 'some' ? accepted.length > 0 : !rejected.length;\r\n};\r\n\r\n/** The current drag can never enter `list` (another group, or a plain draggable it can't create items for). */\r\nexport const isInert = (g: GroupContext, list: ListEntry) => {\r\n const active = g.manager.active.value;\r\n if (!active) return false;\r\n const current = g.session.value;\r\n if (!current || current.activeKey !== active.id) return true;\r\n return !!current.mode.inert?.(list, g);\r\n};\r\n\r\nexport const isSwapping = (g: GroupContext, current: Session, list: ListEntry | undefined) =>\r\n // Swap is a single-item exchange; multi-drag falls back to sorting (rfcs/0001-v3.md §6, §14 item 6).\r\n // Between lists both must swap: the partner takes the active item's place in its list.\r\n list?.behavior?.() === 'swap' &&\r\n listOf(g, current.origin.list)?.behavior?.() === 'swap' &&\r\n current.keys.length === 1 &&\r\n current.mode.moves;\r\n\r\n/**\r\n * Whether `partner`, an item of `list`, can take the active item's place. From another\r\n * list it leaves `list` and enters the origin list, under the rules any item entering\r\n * it follows: `list` must let it go, the origin must take it.\r\n */\r\nexport const canSwap = (g: GroupContext, current: Session, list: ListEntry, partner: Key): boolean => {\r\n const origin = listOf(g, current.origin.list)!;\r\n return (\r\n list === origin ||\r\n (list.pull() === true &&\r\n !origin.isDisabled() &&\r\n origin.canPut({\r\n keys: [partner],\r\n items: [lookup(g, partner)],\r\n types: itemTypes(g, partner),\r\n from: list.id,\r\n to: origin.id,\r\n }))\r\n );\r\n};\r\n","/**\r\n * Multi-drag animations that FLIP can't do on its own: in `'stack'` mode the other\r\n * dragged items unmount on pickup, so clones of them fly into the overlay instead.\r\n * The way back (cancel, reject, drop) is a regular FLIP from the overlay rect,\r\n * run by the group once the items have mounted again.\r\n */\r\n\r\nimport type { LayoutAnimation, Rect } from '../types';\r\nimport { clonePreviews } from '../core/clone';\r\nimport {\r\n DEFAULT_LAYOUT_ANIMATION,\r\n canAnimate,\r\n getRect,\r\n getWindowRect,\r\n intersects,\r\n resolveAnimation,\r\n} from '../animation/layout';\r\n\r\n/** Clones beyond this count add cost without being noticeable. */\r\nconst MAX_GHOSTS = 12;\r\n\r\n/**\r\n * Flies clones of `elements` into `overlay` and fades them out. Call it before the\r\n * drafts change, while the elements are still mounted.\r\n */\r\nexport const collapseIntoOverlay = (\r\n elements: HTMLElement[],\r\n overlay: Rect,\r\n option: LayoutAnimation | undefined,\r\n): void => {\r\n const resolved = resolveAnimation(option, DEFAULT_LAYOUT_ANIMATION);\r\n if (!resolved || resolved.custom || typeof document === 'undefined') return;\r\n const viewport = getWindowRect();\r\n // All reads (rects, computed styles in clonePreviews) happen before the first append. Each\r\n // clone gets the styles its source has in the list (`snapshot.ts`): ghosts fly in <body>.\r\n const shown = elements\r\n .map((element) => ({ element, rect: getRect(element) }))\r\n .filter(({ rect }) => rect.width > 0 && intersects(rect, viewport))\r\n .slice(0, MAX_GHOSTS);\r\n if (!shown.length) return;\r\n // Cloned together: the page lays out once per snapshot pass for all of them.\r\n const clones = clonePreviews(shown.map(({ element }) => element));\r\n const ghosts = shown.map(({ rect }, index) => ({ ghost: clones[index]!, rect }));\r\n\r\n for (const { ghost, rect } of ghosts) {\r\n if (!canAnimate(ghost)) continue;\r\n Object.assign(ghost.style, {\r\n position: 'fixed',\r\n top: '0',\r\n left: '0',\r\n // The clone fills its box (100%): appended to <body>, it needs its own size.\r\n width: `${rect.width}px`,\r\n height: `${rect.height}px`,\r\n zIndex: '9998',\r\n transformOrigin: '0 0',\r\n pointerEvents: 'none',\r\n });\r\n ghost.setAttribute('data-dnd-ghost', '');\r\n document.body.appendChild(ghost);\r\n const scale = `scale(${overlay.width / rect.width || 1}, ${overlay.height / rect.height || 1})`;\r\n const animation = ghost.animate(\r\n [\r\n { transform: `translate3d(${rect.left}px, ${rect.top}px, 0)`, opacity: 1 },\r\n { transform: `translate3d(${overlay.left}px, ${overlay.top}px, 0) ${scale}`, opacity: 0 },\r\n ],\r\n { ...resolved.options, fill: 'forwards' },\r\n );\r\n const remove = () => ghost.remove();\r\n animation.addEventListener('finish', remove);\r\n animation.addEventListener('cancel', remove);\r\n }\r\n};\r\n","/**\r\n * Multi-drag (rfcs/0001-v3.md §6): which dragged keys travel and how. In `'group'` mode\r\n * the others travel with the slot as a block, contiguous in the draft and in drop order;\r\n * projection and keyboard moves count the block once (`viewOf`, `collect`). `'stack'`\r\n * collapses the others into the overlay, `'gaps'` leaves them in place until the drop.\r\n */\r\n\r\nimport type { DnDEvent, DragItem, Key } from '../types';\r\nimport { getRect } from '../animation/layout';\r\nimport { indicesOf, keysOf, listOf, sameKeys, type GroupContext, type Session } from './context';\r\nimport type { ListEntry } from './entry';\r\nimport type { ProjectionItem } from './projection';\r\nimport { itemTypes, partition } from './accept';\r\nimport { collapseIntoOverlay } from './multiple';\r\n\r\n/** `view` (a draft counting the block once, as `slot`) with the whole block in the slot's place. */\r\nexport const expand = (view: Key[], slot: Key, block: Key[]): Key[] =>\r\n block.length > 1 ? view.flatMap((key) => (key === slot ? block : [key])) : view;\r\n\r\n/** The dragged keys a drag starts with, and the drafts its multi-drag mode starts from. */\r\nexport type PickUp = Pick<Session, 'lead' | 'keys' | 'others' | 'stacked' | 'grouped' | 'block' | 'base'> & {\r\n origin: { list: Key; index: number };\r\n};\r\n\r\n/**\r\n * The drag starts with the active key, one of `sources` (keys at drag start by list, of\r\n * `ordered`, the lists in document order).\r\n */\r\nexport const pickUp = (\r\n g: GroupContext,\r\n event: DnDEvent,\r\n ordered: ListEntry[],\r\n sources: Session['sources'],\r\n snapshot: Session['items'],\r\n): PickUp => {\r\n const { lists, manager } = g;\r\n const activeKey = event.active.id;\r\n const order = (key: Key) => {\r\n const source = sources.get(key)!;\r\n return ordered.findIndex((list) => list.id === source.list) * 1e9 + source.index;\r\n };\r\n let keys = event.active.ids.filter((key) => sources.has(key)).sort((a, b) => order(a) - order(b));\r\n // A selected tree node inside another selected one travels in its subtree, not on its\r\n // own. The grabbed one too (as in VS Code): the node it rides in leads the drag, and\r\n // the grabbed node stays inside it, under the pointer.\r\n const ridesIn = new Map<Key, Key>();\r\n for (const list of ordered) list.layout.carried(keys).forEach((carrier, key) => ridesIn.set(key, carrier));\r\n if (ridesIn.size) keys = keys.filter((key) => !ridesIn.has(key));\r\n const lead = ridesIn.get(activeKey) ?? activeKey;\r\n const origin = sources.get(lead)!;\r\n const originList = lists.get(origin.list)!;\r\n\r\n // Multi-drag ids may belong to unmounted rows or other groups (or ride inside others): keep ours only.\r\n const ids = [activeKey, ...keys.filter((key) => key !== activeKey)];\r\n if (!sameKeys(ids, event.active.ids)) {\r\n const dragItems: DragItem[] = ids.map((key) => ({\r\n id: key,\r\n item: snapshot.get(key),\r\n data: manager.getDraggable(key)?.getData(),\r\n label: manager.getDraggable(key)?.getLabel?.(),\r\n type: itemTypes(g, key),\r\n }));\r\n manager.updateActive({ ids, items: dragItems });\r\n }\r\n\r\n const others = new Set(keys.filter((key) => key !== lead));\r\n // Indicator lists don't move: their others stay in place whatever the mode.\r\n const multiple = others.size > 0 && originList.placeholder() === 'item' ? (originList.multiple?.() ?? 'stack') : null;\r\n const stacked = multiple === 'stack';\r\n const grouped = multiple === 'group';\r\n const base = new Map<Key, Key[]>();\r\n for (const list of lists.values()) {\r\n const source = list.getKeys();\r\n let draft = stacked || grouped ? source.filter((key) => !others.has(key)) : [...source];\r\n // The block forms around the lead: the others leave their places and join it in drop order.\r\n if (grouped && list === originList) draft = expand(draft, lead, keys);\r\n base.set(list.id, list.layout.prepareDraft(draft, { lead, keys, copying: false }));\r\n }\r\n return { lead, keys, origin, others, stacked, grouped, block: grouped ? keys : [lead], base };\r\n};\r\n\r\n/**\r\n * The others leave for the overlay as the drag starts: in `'stack'` mode they unmount,\r\n * so clones of them fly into it; in `'group'` mode the next FLIP pass takes them into\r\n * the block, from other lists too.\r\n */\r\nexport const gather = (g: GroupContext, current: Session, event: DnDEvent) => {\r\n if (current.stacked) {\r\n const elements = [...current.others]\r\n .map((key) => g.items.get(key)?.())\r\n .filter((element): element is HTMLElement => !!element?.isConnected);\r\n collapseIntoOverlay(elements, event.active.rect, listOf(g, current.origin.list)!.animation());\r\n }\r\n g.gathering = current.grouped;\r\n};\r\n\r\n/** The drag ends: the others of a `'stack'` drag fly out of the overlay into their slots (copied ones never left). */\r\nexport const scatter = (g: GroupContext, current: Session) => {\r\n if (!current.stacked || !current.mode.moves) return;\r\n const overlay = g.manager.overlayElement.value;\r\n if (overlay?.isConnected) g.returning = { keys: new Set(current.others), from: getRect(overlay) };\r\n};\r\n\r\n/**\r\n * What travels with the slot into `target`: the slot alone, or in multi-drag `'group'`\r\n * every dragged key in drop order. A list taking only some of them (`group.put` with\r\n * `acceptMode: 'some'`) gets those, if the lead is one: the rest stay where they\r\n * started, as the drop would leave them. Copies when copying.\r\n */\r\nexport const blockFor = (g: GroupContext, current: Session, target: ListEntry | undefined): Key[] => {\r\n if (!current.grouped) return [current.slot];\r\n let keys = current.keys;\r\n if (target) {\r\n const { accepted } = partition(g, target, current);\r\n if (accepted.length < keys.length && accepted.includes(current.lead)) keys = accepted;\r\n }\r\n return current.mode.inserted(g, current, keys);\r\n};\r\n\r\n/** A source's draft with the block's keys out of it: those the list doesn't take stay there. */\r\nexport const withoutBlock = (current: Session, list: ListEntry, moving: ReadonlySet<Key>): Key[] =>\r\n (current.grouped ? list.getKeys() : (current.base.get(list.id) ?? list.getKeys())).filter((key) => !moving.has(key));\r\n\r\n/** `list`'s draft as projection and keyboard moves count it: a block once, as the slot. */\r\nexport const viewOf = (list: ListEntry, current: Session): Key[] => {\r\n const keys = keysOf(list);\r\n if (current.block.length < 2 || current.list !== list.id) return keys;\r\n const members = new Set(current.block);\r\n return keys.filter((key) => key === current.slot || !members.has(key));\r\n};\r\n\r\n/**\r\n * Inserts the dragged `key` into `keys` (a draft of its source `list`) where it started:\r\n * after its nearest original predecessor that is there and isn't in `moving`.\r\n */\r\nexport const putBack = (keys: Key[], list: ListEntry, key: Key, index: number, moving: ReadonlySet<Key>) => {\r\n const original = list.getKeys();\r\n let at = 0;\r\n for (let i = index - 1; i >= 0; i--) {\r\n const previous = original[i]!;\r\n if (moving.has(previous)) continue;\r\n const position = keys.indexOf(previous);\r\n if (position !== -1) {\r\n at = position + 1;\r\n break;\r\n }\r\n }\r\n keys.splice(at, 0, key);\r\n};\r\n\r\n/**\r\n * Mounted items of `list` with layout rects, in draft order. The block holding the\r\n * slot counts once (see `viewOf`): its other members share the slot's index and are\r\n * tagged with their side of it.\r\n */\r\nexport const collect = (g: GroupContext, list: ListEntry): ProjectionItem[] => {\r\n const indices = indicesOf(g, list);\r\n const current = g.session.value;\r\n const block = current && current.block.length > 1 && current.list === list.id ? current.block : null;\r\n const first = block ? (indices.get(block[0]!) ?? -1) : -1;\r\n const slot = block ? (indices.get(current!.slot) ?? -1) : -1;\r\n const found: Array<[number, ProjectionItem]> = [];\r\n for (const [key, getElement] of g.items) {\r\n const at = indices.get(key);\r\n if (at === undefined) continue;\r\n const element = getElement();\r\n // Clipped to the visible area; rows fully clipped (overscan) can't be targeted.\r\n const rect = element?.isConnected ? g.manager.measureVisible(element) : null;\r\n if (!rect) continue;\r\n let index = at;\r\n let side: -1 | 1 | undefined;\r\n if (first !== -1 && at >= first) {\r\n if (at >= first + block!.length) index = at - block!.length + 1;\r\n else {\r\n index = first;\r\n if (at !== slot) side = at < slot ? -1 : 1;\r\n }\r\n }\r\n found.push([at, side ? { key, index, rect, side } : { key, index, rect }]);\r\n }\r\n return found.sort((a, b) => a[0] - b[0]).map(([, item]) => item);\r\n};\r\n","/**\r\n * The default overlay of a multi-drag in `'group'` and `'gaps'` mode: every dragged item\r\n * in a column along the list, or in a pile in grids. Only the sortable layer sets\r\n * `overlayColumn`, so the column lives here: plain draggables don't bundle it.\r\n */\r\n\r\nimport { defineComponent, h, onMounted, shallowRef, type CSSProperties } from 'vue';\r\nimport type { Key, Size } from '../types';\r\nimport type { OverlayColumn } from '../core/manager/state';\r\nimport { useManager } from '../core/context';\r\nimport { DragPreview } from '../core/DragPreview';\r\nimport { useOverlayScope } from '../core/overlayScope';\r\nimport { BADGE_STYLE, FILL, PILE } from '../core/DragOverlay';\r\nimport { DEFAULT_LAYOUT_ANIMATION, canAnimate, getRect, resolveAnimation } from '../animation/layout';\r\n\r\nexport interface ColumnCell {\r\n id: Key;\r\n x: number;\r\n y: number;\r\n width: number;\r\n height: number;\r\n /** Degrees: the items of a pile are turned a little. */\r\n rotate?: number;\r\n}\r\n\r\n/**\r\n * Cells of a pile (multi-drag in grids, where a row of whole cells would cover the page):\r\n * the active item on top in the box, up to three others behind it at the box's size.\r\n */\r\nexport const layoutPile = (items: Array<{ id: Key }>, active: Key, box: Size): ColumnCell[] => {\r\n const behind = items.filter(({ id }) => id !== active).slice(0, PILE.length);\r\n return [\r\n ...behind.map(({ id }, i) => ({ id, ...PILE[i]!, width: box.width, height: box.height })),\r\n { id: active, x: 0, y: 0, width: box.width, height: box.height },\r\n ];\r\n};\r\n\r\n/** The cells `column` lays its items out in (see `layoutColumn`, `layoutPile`). */\r\nexport const layoutCells = (\r\n column: OverlayColumn,\r\n items: Array<{ id: Key; size: Size }>,\r\n active: Key,\r\n box: Size,\r\n source: Size,\r\n): ColumnCell[] =>\r\n column.layout === 'pile'\r\n ? layoutPile(items, active, box)\r\n : layoutColumn(items, active, box, source, column.axis, column.gap);\r\n\r\n/**\r\n * Cells of the multi-drag column, relative to the overlay box (the active item's cell,\r\n * at 0, 0). Items run along `axis` in drop order, `gap` apart; across it they take the\r\n * box's size, along it their own size scaled like the active item's (`box` / `source`).\r\n */\r\nexport const layoutColumn = (\r\n items: Array<{ id: Key; size: Size }>,\r\n active: Key,\r\n box: Size,\r\n source: Size,\r\n axis: 'x' | 'y',\r\n gap: number,\r\n): ColumnCell[] => {\r\n const along = axis === 'y' ? 'height' : 'width';\r\n const ratio = source[along] > 0 ? box[along] / source[along] : 1;\r\n const lengths = items.map(({ id, size }) => (id === active ? box[along] : size[along] * ratio));\r\n const offsets = lengths.map(() => 0);\r\n const at = Math.max(items.findIndex((item) => item.id === active), 0);\r\n for (let i = at + 1; i < items.length; i++) offsets[i] = offsets[i - 1]! + lengths[i - 1]! + gap;\r\n for (let i = at - 1; i >= 0; i--) offsets[i] = offsets[i + 1]! - lengths[i]! - gap;\r\n return items.map(({ id }, i) =>\r\n axis === 'y'\r\n ? { id, x: 0, y: offsets[i]!, width: box.width, height: lengths[i]! }\r\n : { id, x: offsets[i]!, y: 0, width: lengths[i]!, height: box.height },\r\n );\r\n};\r\n\r\n/** A count badge centered on a corner of `cell` (overlay box coordinates). */\r\nconst badgeAt = (cell: ColumnCell, right: boolean, bottom: boolean, text: string) =>\r\n h(\r\n 'span',\r\n {\r\n style: {\r\n ...BADGE_STYLE,\r\n top: `${cell.y + (bottom ? cell.height : 0)}px`,\r\n right: 'auto',\r\n left: `${cell.x + (right ? cell.width : 0)}px`,\r\n transform: 'translate(-50%, -50%)',\r\n zIndex: 2,\r\n } as CSSProperties,\r\n },\r\n text,\r\n );\r\n\r\n/**\r\n * Counts of the dragged items the overlay doesn't show. A pile shows the whole count on\r\n * top; a column shows `+N` at the end where its hidden items are: before the first cell\r\n * for those that drop before it, after the last for the rest.\r\n */\r\nconst badges = (column: OverlayColumn, cells: ColumnCell[], active: Key, ids: readonly Key[]) => {\r\n if (column.layout === 'pile') {\r\n const top = cells.find((cell) => cell.id === active)!;\r\n return ids.length > 1 ? [badgeAt(top, true, false, String(ids.length))] : [];\r\n }\r\n const shown = new Set(cells.map((cell) => cell.id));\r\n const order = column.ids.length ? column.ids : ids;\r\n const at = Math.max(order.indexOf(active), 0);\r\n const before = order.slice(0, at).filter((id) => !shown.has(id)).length;\r\n const after = order.slice(at + 1).filter((id) => !shown.has(id)).length;\r\n const along = column.axis === 'x';\r\n const first = cells[0]!;\r\n const last = cells[cells.length - 1]!;\r\n return [\r\n before > 0 ? badgeAt(first, !along, false, `+${before}`) : null,\r\n after > 0 ? badgeAt(last, true, !along, `+${after}`) : null,\r\n ];\r\n};\r\n\r\n/**\r\n * Every cloned item in a column along the list, the active one in the box and the others\r\n * around it in drop order, so the overlay looks like the block the drop makes; in grids, a\r\n * pile behind the active one. The items past the clone cap are counted where they are:\r\n * `+N` at each end of the column, the whole count on a pile. On pickup the clones gather\r\n * from their items' places; on drop each lands on its own slot.\r\n */\r\nexport const ColumnPreview = /* @__PURE__ */ defineComponent({\r\n name: 'DnDColumnPreview',\r\n setup() {\r\n const manager = useManager();\r\n // The box it renders in: the drag's, or a landing one's.\r\n const scope = useOverlayScope();\r\n const root = shallowRef<HTMLElement | null>(null);\r\n const cells = new Map<Key, HTMLElement>();\r\n\r\n const register = (id: Key, element: Element | null) => {\r\n const { items } = scope();\r\n const previous = cells.get(id);\r\n if (previous && items.get(id) === previous) items.delete(id);\r\n cells.delete(id);\r\n if (!(element instanceof HTMLElement)) return;\r\n cells.set(id, element);\r\n items.set(id, element);\r\n };\r\n\r\n // The clones gather from where their items were picked up into the column.\r\n onMounted(() => {\r\n const { column, getPreview } = scope();\r\n const resolved = resolveAnimation(column?.animation ?? manager.props.animation, DEFAULT_LAYOUT_ANIMATION);\r\n if (!resolved || resolved.custom || !root.value) return;\r\n const origin = getRect(root.value);\r\n for (const [id, element] of cells) {\r\n const preview = getPreview(id);\r\n if (!preview || !canAnimate(element)) continue;\r\n const { left, top, width, height } = preview.rect;\r\n const { transform, width: toWidth, height: toHeight } = element.style;\r\n element.animate(\r\n [\r\n { transform: `translate(${left - origin.left}px, ${top - origin.top}px)`, width: `${width}px`, height: `${height}px` },\r\n { transform, width: toWidth, height: toHeight },\r\n ],\r\n resolved.options,\r\n );\r\n }\r\n });\r\n\r\n return () => {\r\n const { active: current, column, fitSize, getPreview, previewIds } = scope();\r\n if (!current || !column) return null;\r\n // The size on screen: a resize glides frame by frame, and the column with it.\r\n const box = fitSize ?? current.rect;\r\n const source = getPreview(current.id)?.rect ?? current.rect;\r\n const items = previewIds.map((id) => ({ id, size: getPreview(id)!.rect }));\r\n const cells = layoutCells(column, items, current.id, box, source);\r\n return h('div', { ref: root, 'aria-hidden': 'true', style: { ...FILL, position: 'relative' } }, [\r\n ...cells.map((cell) =>\r\n cell.id === current.id\r\n ? // Above the cells around it: a pile lies behind it.\r\n h(DragPreview, { key: cell.id, id: cell.id, style: { ...FILL, position: 'relative', zIndex: 1 } })\r\n : h(\r\n 'div',\r\n {\r\n key: cell.id,\r\n ref: (element) => register(cell.id, element as Element | null),\r\n 'data-dnd-overlay-item': '',\r\n style: {\r\n position: 'absolute',\r\n top: '0',\r\n left: '0',\r\n width: `${cell.width}px`,\r\n height: `${cell.height}px`,\r\n transform: `translate(${cell.x}px, ${cell.y}px)${cell.rotate ? ` rotate(${cell.rotate}deg)` : ''}`,\r\n },\r\n },\r\n h(DragPreview, { id: cell.id, style: FILL }),\r\n ),\r\n ),\r\n ...badges(column, cells, current.id, current.ids),\r\n ]);\r\n };\r\n },\r\n});\r\n","/**\r\n * Where the active item should go, given the pointer and the mounted items of a list.\r\n * Pure functions: the group feeds them layout rects (without in-flight FLIP offsets).\r\n */\r\n\r\nimport type { Coordinates, Key, Rect, SortableIndicator, SortableStrategy } from '../types';\r\nimport { containsPoint, createRect, getCenter } from '../animation/layout';\r\n\r\nexport interface ProjectionItem {\r\n key: Key;\r\n /** Index in the list's draft. A multi-drag block counts once: its members share the slot's index. */\r\n index: number;\r\n rect: Rect;\r\n /**\r\n * Multi-drag `'group'`: a dragged item travelling with the slot, before (`-1`) or\r\n * after (`1`) it in the block.\r\n */\r\n side?: -1 | 1;\r\n}\r\n\r\nexport interface ProjectArgs {\r\n strategy: SortableStrategy;\r\n pointer: Coordinates;\r\n /** Mounted items of the target list in draft order (may include the active item). */\r\n items: ProjectionItem[];\r\n activeKey: Key;\r\n /** Index of the active item in the target draft; -1 when it comes from another list. */\r\n activeIndex: number;\r\n /** Draft length of the target list. */\r\n length: number;\r\n /** Grid only: the item that just moved under the pointer, ignored until the pointer leaves it. */\r\n lock: Key | null;\r\n /**\r\n * Items holding a drop target for this drag, with their middle band, where the drop\r\n * goes into the item: nothing moves while the pointer is there (should a sibling still\r\n * sliding into place cover the target from the hit test). Only the pointer moves past\r\n * them: in grids their edges put the active item before or after them, as in lists,\r\n * instead of taking their cell (it would run from the pointer), and a multi-drag block\r\n * never steps past them ahead of the pointer.\r\n */\r\n targets?: ReadonlyMap<Key, Rect>;\r\n}\r\n\r\n/** The pointer is in the middle band of an item you can drop into. */\r\nconst inTarget = (args: Pick<ProjectArgs, 'pointer' | 'targets'>, item: ProjectionItem) => {\r\n const band = args.targets?.get(item.key);\r\n return !!band && containsPoint(band, args.pointer);\r\n};\r\n\r\nexport interface Projection {\r\n /** New index of the active item in the target draft; `null` keeps the current position. */\r\n index: number | null;\r\n lock: Key | null;\r\n /** Item whose crossing triggered the move (`null` for edges): hysteresis applies to it. */\r\n key: Key | null;\r\n}\r\n\r\nconst AXES = {\r\n vertical: { axis: 'y', start: 'top', end: 'bottom' },\r\n horizontal: { axis: 'x', start: 'left', end: 'right' },\r\n} as const;\r\n\r\ntype Axis = (typeof AXES)[keyof typeof AXES];\r\n\r\nconst axisOf = (strategy: SortableStrategy): Axis =>\r\n AXES[strategy === 'horizontal' ? 'horizontal' : 'vertical'];\r\n\r\nconst inBand = (rect: Rect, p: number, { start, end }: Axis) => p >= rect[start] && p <= rect[end];\r\n\r\n/** Pointer outside every item: before the first, after the last, or (cross-list) in a gap. */\r\nconst projectEdges = (\r\n p: number,\r\n items: ProjectionItem[],\r\n { start, end }: Axis,\r\n activeIndex: number,\r\n length: number,\r\n): number | null => {\r\n if (!items.length) return activeIndex === -1 ? 0 : null;\r\n const first = items[0]!;\r\n const last = items[items.length - 1]!;\r\n if (p > last.rect[end] && last.index === length - 1) {\r\n if (activeIndex === -1) return length;\r\n return activeIndex === length - 1 ? null : length - 1;\r\n }\r\n if (p < first.rect[start] && first.index === 0) {\r\n return activeIndex === 0 ? null : 0;\r\n }\r\n if (activeIndex === -1) {\r\n const next = items.find((item) => p < (item.rect[start] + item.rect[end]) / 2);\r\n if (next) return next.index;\r\n return last.index === length - 1 ? length : null;\r\n }\r\n // Same list, pointer in the gap between two items: it is past the center of both,\r\n // so the slot goes between them. A frame can jump from the far half of an item\r\n // straight into the gap beyond it (fast swipes, coalesced input), which must not\r\n // leave the slot an item behind. Beyond mounted items (virtual lists) the position\r\n // stays: moving to the nearest edge is what made v2 items \"teleport\". The members of\r\n // a multi-drag block share the slot's index, so gaps inside the block and at its edges\r\n // keep the position too.\r\n const after = items.findIndex((item) => p < item.rect[start]);\r\n const next = items[after];\r\n const previous = items[after - 1];\r\n if (!next || !previous || next.index === activeIndex || previous.index === activeIndex) return null;\r\n const index = next.index > activeIndex ? next.index - 1 : next.index;\r\n return index === activeIndex ? null : index;\r\n};\r\n\r\n/** Mounted items of the block holding the slot (the slot and its `side` members), in draft order. */\r\nconst blockOf = (items: ProjectionItem[], activeIndex: number) => items.filter((item) => item.index === activeIndex);\r\n\r\n/**\r\n * Multi-drag `'group'`: the pointer is over an item travelling with the slot, so the\r\n * block lags behind the overlay. It steps toward the pointer, past the neighbour on\r\n * that side, once that neighbour's center would end up behind the pointer: the\r\n * crossing rule of single items, seen from the block's edge, so a taller neighbour\r\n * can't swap back.\r\n */\r\nconst stepList = (args: ProjectArgs, side: -1 | 1, { axis, start, end }: Axis): Projection => {\r\n const { items, activeIndex } = args;\r\n const neighbour = items.find((item) => item.index === activeIndex + side);\r\n const block = blockOf(items, activeIndex);\r\n if (!neighbour || !block.length || args.targets?.has(neighbour.key)) return { index: null, lock: null, key: null };\r\n const size = neighbour.rect[end] - neighbour.rect[start];\r\n // After the step the neighbour starts where the block starts (forward) or ends where it ends.\r\n const center =\r\n side > 0 ? Math.min(...block.map((item) => item.rect[start])) + size / 2 : Math.max(...block.map((item) => item.rect[end])) - size / 2;\r\n const p = args.pointer[axis];\r\n return (side > 0 ? p > center : p < center)\r\n ? { index: activeIndex + side, lock: null, key: neighbour.key }\r\n : { index: null, lock: null, key: null };\r\n};\r\n\r\n/**\r\n * Grids: the same step as `stepList`. The neighbour takes the cell of the block's first\r\n * (forward) or last member; the block steps unless that puts the neighbour under the pointer.\r\n */\r\nconst stepGrid = (args: ProjectArgs, side: -1 | 1, lock: Key | null): Projection => {\r\n const { items, activeIndex } = args;\r\n const neighbour = items.find((item) => item.index === activeIndex + side);\r\n const block = blockOf(items, activeIndex);\r\n const cell = side > 0 ? block[0] : block[block.length - 1];\r\n if (!neighbour || !cell || args.targets?.has(neighbour.key)) return { index: null, lock, key: null };\r\n const landing = createRect(cell.rect.left, cell.rect.top, neighbour.rect.width, neighbour.rect.height);\r\n return containsPoint(landing, args.pointer)\r\n ? { index: null, lock, key: null }\r\n : { index: activeIndex + side, lock: null, key: neighbour.key };\r\n};\r\n\r\n/**\r\n * Lists: an item counts as hovered when the pointer is within its band on the main\r\n * axis, so drifting sideways keeps sorting. The active item moves past a neighbour\r\n * only once the pointer crosses the neighbour's center in the direction of travel.\r\n * After the move the neighbour's center is on the other side of the pointer, so\r\n * items of different sizes can't swap back and forth.\r\n *\r\n * Generally the slot goes next to the hovered item, on the side of its center the\r\n * pointer is on. Frames can be far apart (fast flicks, a busy main thread, WebKit\r\n * coalescing input), so the pointer may skip items and land in the near half of one\r\n * that isn't adjacent: the slot still catches up. For an adjacent item this is the\r\n * crossing rule above.\r\n */\r\nconst projectList = (args: ProjectArgs): Projection => {\r\n const axis = axisOf(args.strategy);\r\n const { pointer, items, activeKey, activeIndex, length } = args;\r\n const p = pointer[axis.axis];\r\n const keep: Projection = { index: null, lock: null, key: null };\r\n let hit: ProjectionItem | undefined;\r\n for (const item of items) {\r\n if (!inBand(item.rect, p, axis)) continue;\r\n // After a reorder the active slot itself is the target: nothing moves while the pointer is on it.\r\n if (item.key === activeKey) return keep;\r\n if (item.side) return stepList(args, item.side, axis);\r\n hit ??= item;\r\n }\r\n if (!hit) return { index: projectEdges(p, items, axis, activeIndex, length), lock: null, key: null };\r\n if (inTarget(args, hit)) return keep;\r\n\r\n const center = (hit.rect[axis.start] + hit.rect[axis.end]) / 2;\r\n if (activeIndex === -1) return { index: p < center ? hit.index : hit.index + 1, lock: null, key: hit.key };\r\n // The slot goes to the side of the hovered item the pointer is on. For a direct\r\n // neighbour that means \"past it once its center is crossed\"; a pointer that skipped\r\n // whole items within one frame (fast drags, engines that coalesce input) still\r\n // lands next to the item it ended up over.\r\n const index =\r\n hit.index > activeIndex ? (p > center ? hit.index : hit.index - 1) : p < center ? hit.index : hit.index + 1;\r\n return index === activeIndex ? keep : { index, lock: null, key: hit.key };\r\n};\r\n\r\n/**\r\n * Grids: entering an item moves the active item to its slot. The item that moved\r\n * is locked until the pointer leaves it, which stops ping-pong between cells of\r\n * different sizes. Items from another list, and items you can drop into (`targets`),\r\n * go before or after the hovered item instead.\r\n */\r\nconst projectGrid = (args: ProjectArgs): Projection => {\r\n const { pointer, items, activeKey, activeIndex, length } = args;\r\n let lock = args.lock;\r\n if (lock != null) {\r\n const locked = items.find((item) => item.key === lock);\r\n if (!locked || !containsPoint(locked.rect, pointer)) lock = null;\r\n }\r\n let hit: ProjectionItem | undefined;\r\n for (const item of items) {\r\n if (!containsPoint(item.rect, pointer)) continue;\r\n if (item.key === activeKey) return { index: null, lock, key: null };\r\n if (item.side) return stepGrid(args, item.side, lock);\r\n hit ??= item;\r\n }\r\n if (hit) {\r\n if (hit.key === lock || inTarget(args, hit)) return { index: null, lock, key: null };\r\n if (activeIndex !== -1 && !args.targets?.has(hit.key)) return { index: hit.index, lock: hit.key, key: hit.key };\r\n // Before or after the item, by the side of its center the pointer is on. Passing it\r\n // leaves the slot under the pointer, so it needs no lock (an entering item does).\r\n let index = pointer.x < getCenter(hit.rect).x ? hit.index : hit.index + 1;\r\n if (activeIndex !== -1 && hit.index > activeIndex) index--;\r\n if (index === activeIndex) return { index: null, lock, key: null };\r\n return { index, lock: activeIndex === -1 ? hit.key : lock, key: hit.key };\r\n }\r\n if (!items.length) return { index: activeIndex === -1 ? 0 : null, lock, key: null };\r\n const last = items[items.length - 1]!;\r\n const afterLast =\r\n pointer.y > last.rect.bottom ||\r\n (pointer.y >= last.rect.top && pointer.x > last.rect.right);\r\n if (afterLast && last.index === length - 1 && activeIndex !== length - 1) {\r\n return { index: activeIndex === -1 ? length : length - 1, lock, key: null };\r\n }\r\n return { index: null, lock, key: null };\r\n};\r\n\r\nexport const projectIndex = (args: ProjectArgs): Projection =>\r\n args.strategy === 'grid' ? projectGrid(args) : projectList(args);\r\n\r\n/** A `SortableIndicator` before the group adds its list (`index`: the active item still in place). */\r\nexport type IndicatorProjection = Omit<SortableIndicator, 'list'>;\r\n\r\n/**\r\n * Indicator mode: the list doesn't move, so a plain before/after split of the\r\n * hovered item is stable. `undefined` keeps the previous indicator (pointer in a gap).\r\n */\r\nexport const projectIndicator = (\r\n args: Omit<ProjectArgs, 'lock' | 'activeIndex'>,\r\n): IndicatorProjection | null | undefined => {\r\n const { strategy, pointer, items, activeKey, length } = args;\r\n const hit =\r\n strategy === 'grid'\r\n ? items.find((item) => containsPoint(item.rect, pointer))\r\n : items.find((item) => inBand(item.rect, pointer[axisOf(strategy).axis], axisOf(strategy)));\r\n const alongX = strategy !== 'vertical';\r\n if (hit) {\r\n if (hit.key === activeKey || inTarget(args, hit)) return null;\r\n const center = getCenter(hit.rect);\r\n const before = alongX ? pointer.x < center.x : pointer.y < center.y;\r\n return { index: before ? hit.index : hit.index + 1, key: hit.key, side: before ? 'before' : 'after' };\r\n }\r\n if (!items.length) return { index: 0, key: null, side: 'before' };\r\n const first = items[0]!;\r\n const last = items[items.length - 1]!;\r\n const afterLast = alongX\r\n ? pointer.y > last.rect.bottom || (pointer.y >= last.rect.top && pointer.x > last.rect.right)\r\n : pointer.y > last.rect.bottom;\r\n if (afterLast && last.index === length - 1) return { index: length, key: last.key, side: 'after' };\r\n const beforeFirst = alongX ? pointer.x < first.rect.left && pointer.y <= first.rect.bottom : pointer.y < first.rect.top;\r\n if (beforeFirst && first.index === 0) return { index: 0, key: first.key, side: 'before' };\r\n return undefined;\r\n};\r\n\r\nexport interface SwapArgs {\r\n strategy: SortableStrategy;\r\n pointer: Coordinates;\r\n items: ProjectionItem[];\r\n activeKey: Key;\r\n /** Item the active one is currently exchanged with. */\r\n partner: Key | null;\r\n}\r\n\r\n/**\r\n * Swap behaviour: hovering an item exchanges it with the active one. The current\r\n * partner sits in the active item's original slot, so hovering it reverts the swap.\r\n * `partner: undefined` keeps the current state (pointer on the active slot or in a gap).\r\n */\r\n/** The item under `pointer`: in its band along the list, anywhere in it in grids. */\r\nexport const hitItem = (strategy: SortableStrategy, pointer: Coordinates, items: ProjectionItem[]) => {\r\n const axis = axisOf(strategy);\r\n return items.find((item) =>\r\n strategy === 'grid' ? containsPoint(item.rect, pointer) : inBand(item.rect, pointer[axis.axis], axis),\r\n );\r\n};\r\n\r\nexport const projectSwap = ({ strategy, pointer, items, activeKey, partner }: SwapArgs): {\r\n partner: Key | null | undefined;\r\n key: Key | null;\r\n} => {\r\n const hit = hitItem(strategy, pointer, items);\r\n if (!hit || hit.key === activeKey) return { partner: undefined, key: null };\r\n return { partner: hit.key === partner ? null : hit.key, key: hit.key };\r\n};\r\n\r\n// ─── Keyboard ──────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Grids: index of the nearest item (by center x) in the next row above or below\r\n * the active item. `null` when there is no row in that direction.\r\n */\r\nexport const nextRowIndex = (items: ProjectionItem[], active: Rect, direction: 1 | -1): number | null => {\r\n const x = getCenter(active).x;\r\n let row: number | null = null;\r\n let best: ProjectionItem | null = null;\r\n for (const item of items) {\r\n const ahead = direction > 0 ? item.rect.top >= active.bottom - 1 : item.rect.bottom <= active.top + 1;\r\n if (!ahead) continue;\r\n const edge = direction > 0 ? item.rect.top : -item.rect.bottom;\r\n // Items in the same row share their leading edge (within a pixel); masonry rows don't, so take the closest edge.\r\n if (row === null || edge < row - 1) {\r\n row = edge;\r\n best = item;\r\n } else if (edge <= row + 1) {\r\n const center = getCenter(item.rect).x;\r\n if (!best || Math.abs(center - x) < Math.abs(getCenter(best.rect).x - x)) best = item;\r\n }\r\n }\r\n return best?.index ?? null;\r\n};\r\n\r\n/** Closest container in the arrow's direction, by center distance (cross-axis offsets weigh double). */\r\nexport const pickAdjacent = <T extends { rect: Rect }>(\r\n from: Rect,\r\n candidates: T[],\r\n direction: Coordinates,\r\n): T | null => {\r\n const origin = getCenter(from);\r\n let best: T | null = null;\r\n let score = Infinity;\r\n for (const candidate of candidates) {\r\n const center = getCenter(candidate.rect);\r\n const along = (center.x - origin.x) * direction.x + (center.y - origin.y) * direction.y;\r\n if (along <= 1) continue;\r\n const across = Math.abs((center.x - origin.x) * direction.y) + Math.abs((center.y - origin.y) * direction.x);\r\n const value = along + across * 2;\r\n if (value < score) {\r\n score = value;\r\n best = candidate;\r\n }\r\n }\r\n return best;\r\n};\r\n","/**\r\n * Where the pointer puts the dragged nodes in a tree: the list projection, plus\r\n * hover-to-nest (the middle band of a row drops into it).\r\n */\r\n\r\nimport type { Coordinates, Key } from '../../types';\r\nimport { projectIndex, projectIndicator, type IndicatorProjection, type ProjectionItem } from '../projection';\r\nimport type { KeySet } from './depth';\r\n\r\n/** Middle band of a row, as a fraction of its height: hovering it nests into the row. */\r\nexport const NEST_BAND = { start: 0.25, end: 0.75 } as const;\r\n\r\nconst inNestBand = ({ rect }: ProjectionItem, { y }: Coordinates) =>\r\n rect.height > 0 &&\r\n (y - rect.top) / rect.height >= NEST_BAND.start &&\r\n (y - rect.top) / rect.height <= NEST_BAND.end;\r\n\r\n/** Mounted row under the pointer, skipping `skip` (the active one) and the members of a block. */\r\nconst rowUnder = (items: ProjectionItem[], { y }: Coordinates, skip?: Key) =>\r\n items.find((item) => item.key !== skip && !item.side && y >= item.rect.top && y <= item.rect.bottom) ?? null;\r\n\r\nexport interface TreeIndexArgs {\r\n pointer: Coordinates;\r\n /** Mounted rows in draft order with layout rects (may include the active row). */\r\n items: ProjectionItem[];\r\n activeKey: Key;\r\n /** Index of the active key in the draft, -1 when it comes from another list. */\r\n activeIndex: number;\r\n /** Draft length. */\r\n length: number;\r\n /** Hover-to-nest: whether the active node may become a child of `key`. Omit to disable. */\r\n canNestInto?: (key: Key) => boolean;\r\n /** Rows that keep the slot where it is while hovered, as the active row does (the originals of a copy). */\r\n still?: KeySet;\r\n}\r\n\r\nexport interface TreeIndexProjection {\r\n /** New draft index of the active key; `null` keeps it. */\r\n index: number | null;\r\n /** Row whose middle band is hovered and that accepts the active node as a child. */\r\n nest: Key | null;\r\n /** Row under the pointer (not the active one), if any. */\r\n hit: ProjectionItem | null;\r\n}\r\n\r\n/**\r\n * Hover-to-nest on top of the list projection. The middle band of a row that accepts\r\n * the active node places it right after that row (as its first child). Everything\r\n * else follows the vertical list rule (cross a neighbour's center to pass it), so the\r\n * slot is stable after the layout shifts. The edge bands therefore mean before/after.\r\n * The other members of a multi-drag block are never nested into: over them the block\r\n * steps as in lists. Over a `still` row (the original of a copy) nothing moves: a copy\r\n * doesn't go into its own original just because the drag started over it.\r\n */\r\nexport function projectTreeIndex(args: TreeIndexArgs): TreeIndexProjection {\r\n const { pointer, items, activeKey, activeIndex, length, canNestInto, still } = args;\r\n const hit = rowUnder(items, pointer, activeKey);\r\n if (hit && still?.has(hit.key)) return { index: null, nest: null, hit };\r\n if (hit && canNestInto && inNestBand(hit, pointer) && canNestInto(hit.key)) {\r\n // Right after the row: removing the active slot above it shifts the row up by one.\r\n const index = activeIndex !== -1 && activeIndex < hit.index ? hit.index : hit.index + 1;\r\n return { index: index === activeIndex ? null : index, nest: hit.key, hit };\r\n }\r\n const { index } = projectIndex({\r\n strategy: 'vertical',\r\n pointer,\r\n items,\r\n activeKey,\r\n activeIndex,\r\n length,\r\n lock: null,\r\n });\r\n return { index, nest: null, hit };\r\n}\r\n\r\nexport interface TreeIndicatorArgs {\r\n pointer: Coordinates;\r\n /** Mounted rows in draft order with layout rects. */\r\n items: ProjectionItem[];\r\n activeKey: Key;\r\n /** Draft length. */\r\n length: number;\r\n /** Rows that travel with the drag (the dragged nodes and their subtrees; the originals of a copy): no line on them. */\r\n moving: KeySet;\r\n /** Hover-to-nest, as in `projectTreeIndex`. */\r\n canNestInto?: (key: Key) => boolean;\r\n}\r\n\r\n/**\r\n * Indicator mode: the tree doesn't move, so the line goes before or after the hovered\r\n * row as in lists, and the middle band of a row that accepts the dragged nodes means\r\n * into it (`'inside'`, right after the row). No line over the rows that travel with\r\n * the drag. `undefined` keeps the previous line (pointer in a gap). The depth comes\r\n * on top, from the position (`gapPosition`).\r\n */\r\nexport function projectTreeIndicator(args: TreeIndicatorArgs): IndicatorProjection | null | undefined {\r\n const { pointer, items, moving, canNestInto } = args;\r\n const hit = rowUnder(items, pointer);\r\n if (hit && moving.has(hit.key)) return null;\r\n if (hit && canNestInto && inNestBand(hit, pointer) && canNestInto(hit.key)) {\r\n return { index: hit.index + 1, key: hit.key, side: 'inside' };\r\n }\r\n return projectIndicator({ ...args, strategy: 'vertical' });\r\n}\r\n","/**\r\n * Drop targets inside sortable items, \"drop into an item\" (rfcs/0001-v3.md §6): the\r\n * middle of an item drops into it, its edges sort as usual. The middle is the band\r\n * trees nest with, taken along the list's main axis (x in grids, whose rows run along x).\r\n *\r\n * The target is no list, so the drop is the target's (the lists change only if its\r\n * `onDrop` calls `e.source.remove()`). The group keeps the target from counting outside\r\n * the middle band (`targetRule`) and the projection still over the band (`bandsAt`),\r\n * and lets the keyboard stop on the target (`intoPoint`) and the announcements name it\r\n * (`isInto`).\r\n */\r\n\r\nimport type { Active, Coordinates, DnDEvent, Key, Rect, SortableStrategy } from '../types';\r\nimport type { TargetRule } from '../core/manager';\r\nimport { containsPoint, createRect, getCenter, getRect, intersectRect, stopLayoutAnimation } from '../animation/layout';\r\nimport { revealElement } from '../core/autoscroll';\r\nimport { listOfKey, type GroupContext } from './context';\r\nimport type { ListEntry } from './entry';\r\nimport { accepts } from './accept';\r\nimport { NEST_BAND } from './tree/projection';\r\n\r\n/** The middle band of an item: across the whole item, `NEST_BAND` of it along the main axis. */\r\nexport const dropBand = (item: Rect, strategy: SortableStrategy): Rect => {\r\n const { start, end } = NEST_BAND;\r\n return strategy === 'vertical'\r\n ? createRect(item.left, item.top + item.height * start, item.width, item.height * (end - start))\r\n : createRect(item.left + item.width * start, item.top, item.width * (end - start), item.height);\r\n};\r\n\r\n/** Keyboard: where the pointer goes to drop into the item, on `target` inside its band; `null` when they don't meet. */\r\nexport const dropBandPoint = (item: Rect, target: Rect, strategy: SortableStrategy): Coordinates | null => {\r\n const area = intersectRect(dropBand(item, strategy), target);\r\n return area && getCenter(area);\r\n};\r\n\r\n/** The bands for projecting `event`: of its own target detection. */\r\nexport const bandsAt = (g: GroupContext, event: DnDEvent) =>\r\n g.targets.at === event.pointer ? g.targets.bands : undefined;\r\n\r\n/**\r\n * A drop target inside an item of a list that takes the drag (rfcs/0001-v3.md §6)\r\n * counts only while the pointer is in the item's middle: the drop goes into the item\r\n * there, and at its edges the list sorts as usual. A target that doesn't take the drag\r\n * is left out, so the list sorts over it like over any item. Nested lists are lists.\r\n */\r\nexport const targetRule = (g: GroupContext): TargetRule => {\r\n // Whether each list takes the drag, as of the target detection at `acceptsAt`: the same\r\n // for every target in its items, so its `group.put` is asked once per detection.\r\n let acceptsAt: Coordinates | null = null;\r\n const accepting = new Map<ListEntry, boolean>();\r\n const listAccepts = (list: ListEntry, point: Coordinates, active: Active) => {\r\n if (acceptsAt !== point) {\r\n acceptsAt = point;\r\n accepting.clear();\r\n }\r\n let result = accepting.get(list);\r\n if (result === undefined) accepting.set(list, (result = accepts(g, list, active)));\r\n return result;\r\n };\r\n return (entry, element, point, active) => {\r\n const current = g.session.value;\r\n if (!current || current.activeKey !== active.id || entry.sortable) return true;\r\n const found = g.manager.findDraggable(element);\r\n const key = found?.entry.id;\r\n const list = key != null && g.items.get(key)?.() === found!.element ? listOfKey(g, key, true) : undefined;\r\n if (!list || !listAccepts(list, point, active)) return true;\r\n if (!entry.accepts(active)) return false;\r\n if (g.targets.at !== point) g.targets = { at: point, bands: new Map(), ids: new Set() };\r\n // Layout rects, as projection uses: an item still sliding into place counts where it lands.\r\n const band = dropBand(g.manager.measure(found!.element), list.strategy());\r\n g.targets.bands.set(key!, band);\r\n if (!containsPoint(band, point)) return false;\r\n g.targets.ids.add(entry.id);\r\n return true;\r\n };\r\n};\r\n\r\n/** The drag is over a drop target inside an item: dropping goes into that item. */\r\nexport const isInto = (g: GroupContext, event: DnDEvent) =>\r\n !!event.over && g.targets.at === event.pointer && g.targets.ids.has(event.over.id);\r\n\r\n/** Keyboard: where the pointer drops into item `key`, on a target in its middle that takes the drag; `null` without one. */\r\nexport const intoPoint = (g: GroupContext, key: Key, list: ListEntry, active: Active): Coordinates | null => {\r\n const { manager } = g;\r\n const element = g.items.get(key)?.();\r\n if (!element?.isConnected) return null;\r\n let rect: Rect | null = null;\r\n for (const entry of manager.getDroppables()) {\r\n const target = entry.getElement();\r\n if (!target?.isConnected || entry.sortable || entry.isDisabled() || manager.isOwned(target, active)) continue;\r\n if (manager.findDraggable(target)?.element !== element || !entry.accepts(active)) continue;\r\n if (!rect) {\r\n // The hit test sees the item where it lands: a passed item may still be sliding there.\r\n stopLayoutAnimation(element);\r\n revealElement(element);\r\n rect = getRect(element);\r\n }\r\n const point = dropBandPoint(rect, getRect(target), list.strategy());\r\n if (point) return point;\r\n }\r\n return null;\r\n};\r\n","/**\r\n * Default position-aware announcements for sortable lists (rfcs/0001-v3.md §10).\r\n * The provider's `announcements` prop overrides them (its texts that return `undefined`\r\n * fall back to them); the manager falls back to its generic texts when a drag doesn't\r\n * involve a sortable list.\r\n */\r\n\r\nimport type { AnnouncedPosition, AnnouncementContext, Announcer, DnDEndEvent, DnDEvent, Key } from '../types';\r\nimport { isForeign, itemLabel, keysOf, listLabel, spotIn, type GroupContext, type Session } from './context';\r\nimport type { DropResult } from './drop';\r\nimport { isInto } from './combine';\r\n\r\nexport type SortableSpot = AnnouncedPosition;\r\n\r\nexport interface SortableSubject {\r\n key: Key;\r\n /** Its `label`: said instead of the key, as written. */\r\n label?: string;\r\n count: number;\r\n copy: boolean;\r\n}\r\n\r\nconst subject = ({ key, label, count, copy }: SortableSubject, capital = true): string => {\r\n const base = count > 1 ? `${count} items` : (label ?? `item ${key}`);\r\n const text = copy ? `copy of ${base}` : base;\r\n // A label is said as written (\"iPhone\").\r\n return capital && text !== label ? text.charAt(0).toUpperCase() + text.slice(1) : text;\r\n};\r\n\r\n/** The item a swap exchanged the dragged one with, and where it went. */\r\nexport interface SortablePartner {\r\n key: Key;\r\n label?: string;\r\n spot: SortableSpot;\r\n}\r\n\r\n/** A list by its `label`, else by its id. */\r\nconst listName = (list: Key, label?: string) => label ?? `list ${list}`;\r\n\r\nconst where = ({ list, label, index, length }: SortableSpot) =>\r\n `position ${index + 1} of ${length} in ${listName(list, label)}`;\r\n\r\nconst swapped = (partner?: SortablePartner) =>\r\n partner ? `, swapped with ${partner.label ?? `item ${partner.key}`} (now at ${where(partner.spot)})` : '';\r\n\r\nconst sortableTexts = {\r\n start: (who: SortableSubject, spot: SortableSpot) =>\r\n `Picked up ${subject({ ...who, copy: false }, false)} at ${where(spot)}.`,\r\n over: (who: SortableSubject, spot: SortableSpot, partner?: SortablePartner) =>\r\n `${subject(who)} moved to ${where(spot)}${swapped(partner)}.`,\r\n end: (who: SortableSubject, spot: SortableSpot, partner?: SortablePartner) =>\r\n `${subject(who)} dropped at ${where(spot)}${swapped(partner)}.`,\r\n removed: (who: SortableSubject, list: Key, label?: string) => `${subject(who)} removed from ${listName(list, label)}.`,\r\n /** Over a drop target inside an item (drop into the item): its `label`, else its id. */\r\n target: (who: SortableSubject, target: string) => `Over ${target}: dropping puts ${subject(who, false)} inside.`,\r\n into: (who: SortableSubject, target: string) => `${subject(who)} dropped into ${target}.`,\r\n cancel: (who: SortableSubject, spot: SortableSpot) =>\r\n `Dragging was cancelled. ${subject({ ...who, copy: false })} returned to ${where(spot)}.`,\r\n};\r\n\r\n// ─── The group's announcer ──────────────────────────────────────────────────────\r\n\r\nconst spotKey = ({ list, index, length }: SortableSpot) => `${String(list)}\\u0000${index}\\u0000${length}`;\r\n\r\n// What moves: the lead, which carries the active node when that rides in it.\r\nconst subjectOf = (g: GroupContext, current: Session): SortableSubject => ({\r\n key: current.lead,\r\n label: itemLabel(g, current.lead),\r\n count: current.keys.length,\r\n copy: current.mode.name === 'copy',\r\n});\r\n\r\n/** A drop target inside an item, as the texts say it. */\r\nconst targetName = (event: DnDEvent) => event.over!.label ?? String(event.over!.id);\r\n\r\nexport const spotOf = (g: GroupContext, current: Session): SortableSpot | null => {\r\n const shown = g.indicator.value;\r\n if (shown) {\r\n const list = g.lists.get(shown.list);\r\n const keys = list ? keysOf(list) : [];\r\n const own = keys.indexOf(current.slot);\r\n const index = own >= 0 && own < shown.index ? shown.index - 1 : shown.index;\r\n return { list: shown.list, label: listLabel(g, shown.list), index, length: own >= 0 ? keys.length : keys.length + 1 };\r\n }\r\n if (current.list == null) return null;\r\n const keys = keysOf(g.lists.get(current.list)!);\r\n // A block is placed where it starts.\r\n return { list: current.list, label: listLabel(g, current.list), index: keys.indexOf(current.block[0]!), length: keys.length };\r\n};\r\n\r\n/** What a text says, for the provider's own texts (`AnnouncementContext`). */\r\nconst contextOf = (\r\n who: SortableSubject,\r\n spot?: SortableSpot | null,\r\n partner?: SortablePartner,\r\n): Partial<AnnouncementContext> => ({\r\n count: who.count,\r\n copy: who.copy,\r\n ...(spot && { position: spot }),\r\n ...(partner && { partner: { key: partner.key, label: partner.label, position: partner.spot } }),\r\n});\r\n\r\n/** A swap partner sits where the active item started. */\r\nconst partnerOf = (g: GroupContext, current: Session): SortablePartner | undefined =>\r\n current.swap == null\r\n ? undefined\r\n : { key: current.swap, label: itemLabel(g, current.swap), spot: spotIn(g, current.origin.list!, current.origin.index) };\r\n\r\n/** The text of a drag's end, and what it is about. */\r\nexport interface SortableAnnouncement {\r\n text: string | undefined;\r\n context: Partial<AnnouncementContext>;\r\n}\r\n\r\n/** The pickup announcement names where the drag starts: the first target of the drag doesn't repeat it. */\r\nexport const pickedUpAt = (g: GroupContext, current: Session) => {\r\n const origin = current.origin.list!;\r\n const formed = current.base.get(origin)!;\r\n g.spokenSpot = current.grouped\r\n ? spotKey({ list: origin, index: formed.indexOf(current.keys[0]!), length: formed.length })\r\n : spotKey(spotIn(g, origin, current.origin.index));\r\n};\r\n\r\n/** What the end of the drag says, computed while the session still exists. */\r\nexport const endAnnouncement = (\r\n g: GroupContext,\r\n current: Session,\r\n event: DnDEndEvent,\r\n result: DropResult | null,\r\n): SortableAnnouncement => {\r\n const who = subjectOf(g, current);\r\n if (isInto(g, event)) return { text: sortableTexts.into(who, targetName(event)), context: contextOf(who) };\r\n if (current.removed) {\r\n return { text: result ? sortableTexts.removed(who, result.event.to.list, listLabel(g, result.event.to.list)) : undefined, context: contextOf(who) };\r\n }\r\n if (result && result.event.to.index >= 0) {\r\n const list = g.lists.get(result.event.to.list);\r\n // The committed keys: a `defineModel` ref only shows the new array after the parent re-renders.\r\n const committed = list ? (result.next.get(list) ?? list.getKeys()) : [];\r\n const to = result.event.to.list;\r\n const spot = { list: to, label: listLabel(g, to), index: result.event.to.index, length: committed.length };\r\n // A swap changes no list's length.\r\n const swapped = result.event.partner;\r\n const partner = swapped && { key: swapped.key, label: itemLabel(g, swapped.key), spot: spotIn(g, swapped.to.list, swapped.to.index) };\r\n return { text: sortableTexts.end(who, spot, partner), context: contextOf(who, spot, partner) };\r\n }\r\n if (!result && !isForeign(g, event) && current.mode.moves && current.origin.list != null) {\r\n const spot = spotIn(g, current.origin.list, current.origin.index);\r\n return { text: sortableTexts.end(who, spot), context: contextOf(who, spot) };\r\n }\r\n return { text: undefined, context: contextOf(who) };\r\n};\r\n\r\n/** What a cancel says: the items went back home. */\r\nexport const cancelAnnouncement = (g: GroupContext, current: Session): SortableAnnouncement => {\r\n const who = subjectOf(g, current);\r\n const spot = spotIn(g, current.origin.list!, current.origin.index);\r\n return { text: sortableTexts.cancel(who, spot), context: contextOf(who, spot) };\r\n};\r\n\r\nconst ours = (g: GroupContext, event: DnDEvent) => {\r\n const current = g.session.value;\r\n return current && current.activeKey === event.active.id && !isForeign(g, event) ? current : null;\r\n};\r\n\r\nexport const createAnnouncer = (g: GroupContext): Announcer => ({\r\n describe: (name, event) => {\r\n if (name === 'onDragEnd' || name === 'onDragCancel') {\r\n return g.announced?.key === event.active.id ? g.announced.context : undefined;\r\n }\r\n const current = ours(g, event);\r\n if (!current) return undefined;\r\n const who = subjectOf(g, current);\r\n if (name === 'onDragStart') {\r\n return contextOf(who, current.origin.list == null ? null : spotIn(g, current.origin.list, current.origin.index));\r\n }\r\n // Over a drop target in an item, the drop goes into it: no position in the list.\r\n return isInto(g, event) ? contextOf(who) : contextOf(who, spotOf(g, current), partnerOf(g, current));\r\n },\r\n onDragStart: (event) => {\r\n const current = ours(g, event);\r\n if (!current || current.origin.list == null) return undefined;\r\n return sortableTexts.start(subjectOf(g, current), spotIn(g, current.origin.list, current.origin.index));\r\n },\r\n onDragOver: (event) => {\r\n const into = g.session.value;\r\n if (into?.activeKey === event.active.id && isInto(g, event)) {\r\n // Back over the list, the position is spoken again.\r\n g.spokenSpot = null;\r\n return sortableTexts.target(subjectOf(g, into), targetName(event));\r\n }\r\n const current = ours(g, event);\r\n const spot = current && spotOf(g, current);\r\n if (!spot) return undefined;\r\n // '' tells the manager there is nothing new, without cancelling a pending text.\r\n const key = spotKey(spot);\r\n if (key === g.spokenSpot) return '';\r\n g.spokenSpot = key;\r\n return sortableTexts.over(subjectOf(g, current), spot, partnerOf(g, current));\r\n },\r\n onDragEnd: (event) => (g.announced?.key === event.active.id ? g.announced.text : undefined),\r\n onDragCancel: (event) => (g.announced?.key === event.active.id ? g.announced.text : undefined),\r\n});\r\n","/**\r\n * Guards against oscillation (rfcs/0001-v3.md §6). The draft order changes the\r\n * layout under a still pointer, so a move can make another move look valid.\r\n * Pure helpers: the group keeps the state in its session.\r\n */\r\n\r\nimport type { Coordinates, Key } from '../types';\r\nimport { distance } from '../animation/layout';\r\n\r\nexport { distance };\r\n\r\n/** Pixels the pointer must travel before a key the slot just passed can trigger again. */\r\nexport const HYSTERESIS = 10;\r\n\r\n/**\r\n * The pointer is still within `HYSTERESIS` of where it last was over a target: with no\r\n * target under it, it counts as on that one (one-frame gaps at list boundaries).\r\n */\r\nexport const nearLastTarget = (target: { at: Coordinates } | null, pointer: Coordinates | null): boolean =>\r\n !!target && !!pointer && distance(pointer, target.at) < HYSTERESIS;\r\n\r\n/** Most keys remembered per move; a fast drag past more of them can't come back in 10px anyway. */\r\nconst MAX_KEYS = 64;\r\n\r\nexport interface Hysteresis {\r\n /** Keys whose position the last move changed. */\r\n keys: ReadonlySet<Key>;\r\n /** List the slot just left (cross-list moves). */\r\n list: Key | null;\r\n /** Pointer position at the move. */\r\n at: Coordinates;\r\n}\r\n\r\n/** Keys that change index when the item at `from` moves to `to` (same list). */\r\nexport const passedKeys = (keys: readonly Key[], from: number, to: number): Set<Key> => {\r\n const result = new Set<Key>();\r\n const [start, end] = from < to ? [from + 1, to] : [to, from - 1];\r\n for (let index = start; index <= end && result.size < MAX_KEYS; index++) {\r\n const key = keys[index];\r\n if (key !== undefined) result.add(key);\r\n }\r\n return result;\r\n};\r\n\r\n/** Neighbours of an insertion point: the keys a cross-list entry slides past. */\r\nexport const neighbourKeys = (keys: readonly Key[], index: number): Set<Key> => {\r\n const result = new Set<Key>();\r\n for (const key of [keys[index - 1], keys[index]]) if (key !== undefined) result.add(key);\r\n return result;\r\n};\r\n\r\n/** Keeps the hysteresis while the pointer stays within `HYSTERESIS` px of the move. */\r\nexport const settleHysteresis = (\r\n hysteresis: Hysteresis | null,\r\n pointer: Coordinates,\r\n): Hysteresis | null =>\r\n hysteresis && distance(pointer, hysteresis.at) < HYSTERESIS ? hysteresis : null;\r\n\r\nexport const blocksKey = (hysteresis: Hysteresis | null, key: Key | null | undefined): boolean =>\r\n !!hysteresis && key != null && hysteresis.keys.has(key);\r\n\r\nexport const blocksList = (hysteresis: Hysteresis | null, list: Key): boolean =>\r\n !!hysteresis && hysteresis.list === list;\r\n","/**\r\n * The overlay's side of a sortable session: where its clones land (the slot, the\r\n * placeholders of a block), the `mode` it shows, and the column of a multi-drag.\r\n */\r\n\r\nimport type { Coordinates, DnDEvent, DropDestination, Key } from '../types';\r\nimport { landOverlayItems } from '../animation/drop';\r\nimport { listOf, type GroupContext, type Session } from './context';\r\nimport type { ListEntry } from './entry';\r\nimport type { DropResult } from './drop';\r\nimport { ColumnPreview, layoutCells } from './column';\r\nimport { spotOf } from './announcements';\r\nimport { nearLastTarget } from './stability';\r\n\r\nconst NO_OFFSET: Coordinates = { x: 0, y: 0 };\r\n\r\n/** Sets where the other dragged items land (slot → dragged id), keeping the map when nothing changed. */\r\nexport const setLandings = (g: GroupContext, entries: Array<[Key, Key]>) => {\r\n const { manager } = g;\r\n const previous = manager.landings.value;\r\n if (previous.size === entries.length && entries.every(([slot, id]) => previous.get(slot) === id)) return;\r\n manager.landings.value = new Map(entries);\r\n};\r\n\r\n/** Spacing between items of `list` along `axis`, from its CSS `gap`. */\r\nconst gapOf = (list: ListEntry, axis: 'x' | 'y'): number => {\r\n const element = list.getElement();\r\n if (!element) return 0;\r\n const style = getComputedStyle(element);\r\n return parseFloat(axis === 'y' ? style.rowGap : style.columnGap) || 0;\r\n};\r\n\r\n/** Ids in the overlay's column, in drop order: the active node goes right after the tree node it rides in. */\r\nconst columnIds = (current: Session): Key[] =>\r\n current.lead === current.activeKey\r\n ? current.keys\r\n : current.keys.flatMap((key) => (key === current.lead ? [key, current.activeKey] : [key]));\r\n\r\n/**\r\n * The default overlay of a multi-drag that isn't `'stack'`: every item in drop order,\r\n * in a column along the list holding the slot (a row in horizontal lists), with that\r\n * list's gap. In grids a row of whole cells would cover the page: they pile up instead.\r\n */\r\nconst syncColumn = (g: GroupContext, current: Session) => {\r\n if (current.stacked) return;\r\n const ids = columnIds(current);\r\n if (ids.length < 2) return;\r\n const list = listOf(g, current.list ?? current.origin.list);\r\n if (!list || list.id === g.columnList) return;\r\n g.columnList = list.id;\r\n const strategy = list.strategy();\r\n const axis = strategy === 'vertical' ? 'y' : 'x';\r\n g.manager.overlayColumn.value = {\r\n ids,\r\n axis,\r\n gap: gapOf(list, axis),\r\n layout: strategy === 'grid' ? 'pile' : 'column',\r\n animation: list.animation(),\r\n preview: ColumnPreview,\r\n land: landOverlayItems,\r\n };\r\n};\r\n\r\n/**\r\n * Where a drop would put the dragged items (the overlay's `to`): the slot's place while\r\n * the drag is over the list that holds it (or shows its line), a tree adding the depth\r\n * and the parent. Outside every target too, where `dropOutside: 'placeholder'` keeps\r\n * the slot. Reactive: the drafts (`version`), the line, the target, a tree's placement.\r\n */\r\nexport const destinationOf = (g: GroupContext): DropDestination | null => {\r\n void g.version.value;\r\n const current = g.session.value;\r\n if (!current) return null;\r\n const over = g.manager.over.value;\r\n // A refusing target, or outside every target where the drop cancels or removes: it\r\n // lands nowhere. (Just past the edge of the last target still counts as on it.)\r\n const nowhere = over\r\n ? !over.accepted\r\n : !nearLastTarget(current.target, g.manager.pointer.value) &&\r\n listOf(g, current.list ?? current.origin.list)?.dropOutside() !== 'placeholder';\r\n if (nowhere) return null;\r\n const spot = spotOf(g, current);\r\n // Over a plain target the drop goes there, not to the slot.\r\n if (!spot || (over && spot.list !== over.id)) return null;\r\n const placement = listOf(g, spot.list)?.layout.placement?.();\r\n return placement ? { list: spot.list, ...placement } : { list: spot.list, index: spot.index };\r\n};\r\n\r\nconst sameDestination = (a: DropDestination, b: DropDestination) =>\r\n a.list === b.list && a.index === b.index && a.parentKey === b.parentKey && a.depth === b.depth;\r\n\r\n/** `destinationOf`, the same object while nothing changed: the overlay's props stay as they are. */\r\nexport const stableDestination = (g: GroupContext) => (previous: DropDestination | null | undefined) => {\r\n const next = destinationOf(g);\r\n return previous && next && sameDestination(previous, next) ? previous : next;\r\n};\r\n\r\n/** Mirrors the session into the manager: overlay `mode`, where the overlay lands, the placeholders of a block. */\r\nexport const syncManager = (g: GroupContext) => {\r\n const { manager } = g;\r\n const current = g.session.value;\r\n if (!current) return;\r\n const placed = current.list != null;\r\n // The overlay lands on a copy or a created item; on the active item's own element\r\n // otherwise, also when it rides in the lead: the drop shows it again inside it.\r\n manager.landingKey.value = placed && current.slot !== current.lead ? current.slot : null;\r\n // Placeholders of the others: a block's, and the lead's when it isn't the active item\r\n // (its clone rides in the overlay's column too).\r\n const carrier = current.lead !== current.activeKey;\r\n setLandings(\r\n g,\r\n placed && (current.grouped || carrier)\r\n ? current.block\r\n .filter((key) => key !== current.slot || carrier)\r\n .map((key) => [key, current.mode.original?.(current, key) ?? key])\r\n : [],\r\n );\r\n syncColumn(g, current);\r\n manager.mode.value = current.mode.dragMode(g, current);\r\n};\r\n\r\n/**\r\n * The other dragged items that go back where they started (a cancel, the keys a drop left\r\n * out): their clones fly home, and they stay placeholders until then. Originals of copies\r\n * never left.\r\n */\r\nconst goingBack = (current: Session, kept: Key[]): Array<[Key, Key]> =>\r\n current.mode.moves\r\n ? current.keys.filter((key) => key !== current.activeKey && !kept.includes(key)).map((key) => [key, key])\r\n : [];\r\n\r\n/** The drag was cancelled: every other dragged item lands back on its own element; copies vanish. */\r\nexport const landCancel = (g: GroupContext, current: Session) => setLandings(g, goingBack(current, []));\r\n\r\n/**\r\n * The drop is decided: where the overlay's clones land. The accepted items on their\r\n * slots (copies when copying); the rest on their own elements, back where they started.\r\n * The active item goes with its lead.\r\n */\r\nexport const landDrop = (g: GroupContext, current: Session, result: DropResult | null) => {\r\n const accepted = result && !current.removed ? result.event.accepted : [];\r\n if (result) {\r\n // The lead lands where the drop put it: its copy, the item made for it, or itself. An\r\n // indicator list never showed the copy while dragging, so only the drop knows it.\r\n const placed = accepted.includes(current.lead) ? current.mode.placed(current, current.lead) : null;\r\n if (placed == null) g.manager.landingKey.value = null;\r\n else if (placed !== current.lead) g.manager.landingKey.value = placed;\r\n }\r\n setLandings(g, [\r\n ...accepted.filter((key) => key !== current.activeKey).map((key): [Key, Key] => [current.mode.placed(current, key), key]),\r\n ...goingBack(current, accepted),\r\n ]);\r\n};\r\n\r\n/**\r\n * Where the lead's clone sits in the overlay, from the pointer: nowhere else than under\r\n * it, unless the grabbed node rides in another one (a tree), whose clone shows before\r\n * it in the column. Projection places the slot by that point, so the block lines up\r\n * with the column (the pointer holds the grabbed row inside it), and keyboard moves put\r\n * the pointer that far from the slot.\r\n */\r\nexport const leadOffset = (g: GroupContext, current: Session | null): Coordinates => {\r\n if (!current) return NO_OFFSET;\r\n const { manager } = g;\r\n const active = manager.active.value;\r\n const column = manager.overlayColumn.value;\r\n if (current.lead === current.activeKey || !active || !column) return NO_OFFSET;\r\n const items = manager.previewIds.map((id) => ({ id, size: manager.getPreview(id)!.rect }));\r\n const box = manager.fitSize.value ?? active.rect;\r\n const source = manager.getPreview(active.id)?.rect ?? active.rect;\r\n const cell = layoutCells(column, items, active.id, box, source).find((at) => at.id === current.lead);\r\n return cell ? { x: cell.x, y: cell.y } : NO_OFFSET;\r\n};\r\n\r\n/** `event` with the pointer at the lead's clone, for projection (see `leadOffset`). */\r\nexport const atLead = (g: GroupContext, current: Session, event: DnDEvent): DnDEvent => {\r\n const offset = leadOffset(g, current);\r\n if (offset === NO_OFFSET) return event;\r\n return { ...event, pointer: { x: event.pointer.x + offset.x, y: event.pointer.y + offset.y } };\r\n};\r\n\r\n/**\r\n * `event` with the pointer brought into the part of `target` that shows, along its axis\r\n * (lists and trees; grids keep it). A pointer past the edge of a scrolled list points at\r\n * the item at that edge: auto-scroll brings the items past it one by one, and the slot goes\r\n * along. Beyond the edge the items are out of sight (a virtual list mounts a few there, or\r\n * none). At the real end of a list its last item is at the edge, so the slot still goes\r\n * after it. Keyboard drags put the pointer on the slot they go to: theirs stays.\r\n */\r\nexport const inView = (g: GroupContext, target: ListEntry, event: DnDEvent): DnDEvent => {\r\n const strategy = target.strategy();\r\n if (strategy === 'grid' || event.active.sensor === 'keyboard') return event;\r\n const element = target.getElement();\r\n const view = element?.isConnected ? g.manager.measureVisible(element) : null;\r\n if (!view) return event;\r\n const [axis, start, end] = strategy === 'horizontal' ? (['x', 'left', 'right'] as const) : (['y', 'top', 'bottom'] as const);\r\n if (view[end] - view[start] < 2) return event;\r\n const point = event.pointer[axis];\r\n const held = Math.min(Math.max(point, view[start] + 1), view[end] - 1);\r\n return held === point ? event : { ...event, pointer: { ...event.pointer, [axis]: held } };\r\n};\r\n","/**\r\n * A list's own size follows its items (`animateSize`): when a render adds or takes an item\r\n * (a slot coming in, the drop, a change `animate` shows), the list grows or shrinks to its\r\n * new size instead of jumping. Measured before the render, animated after it, before the\r\n * items' FLIP measures them: the items of an outer list then move with it as it resizes.\r\n */\r\n\r\nimport type { AnimationOptions, LayoutAnimation } from '../types';\r\nimport { DEFAULT_LAYOUT_ANIMATION, canAnimate, resolveAnimation } from '../animation/layout';\r\nimport type { ListEntry } from './entry';\r\nimport type { GroupContext } from './context';\r\n\r\nexport interface SizeSnapshot {\r\n list: ListEntry;\r\n element: HTMLElement;\r\n /** Its layout size (`offsetWidth`, `offsetHeight`), as it shows: a resize under way included. */\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/** The resize running on a list's element. */\r\nconst running = new WeakMap<Element, Animation>();\r\n\r\n/** Sizes of `lists` near the visible area, before a render. */\r\nexport const captureSizes = (g: GroupContext, lists: Iterable<ListEntry>): SizeSnapshot[] => {\r\n const sizes: SizeSnapshot[] = [];\r\n for (const list of lists) {\r\n if (list.animateSize?.() === false) continue;\r\n const element = list.getElement();\r\n if (!element?.isConnected || !g.manager.isNearViewport(element)) continue;\r\n sizes.push({ list, element, width: element.offsetWidth, height: element.offsetHeight });\r\n }\r\n return sizes;\r\n};\r\n\r\n/** The CSS `width`/`height` for a layout size: less the padding and border of a `content-box`. */\r\nconst cssSize = (style: CSSStyleDeclaration, axis: 'width' | 'height', size: number) => {\r\n if (style.boxSizing === 'border-box') return size;\r\n const [a, b] = axis === 'width' ? (['Left', 'Right'] as const) : (['Top', 'Bottom'] as const);\r\n const box = (name: string) => parseFloat(style.getPropertyValue(name)) || 0;\r\n return size - box(`padding-${a.toLowerCase()}`) - box(`padding-${b.toLowerCase()}`) - box(`border-${a.toLowerCase()}-width`) - box(`border-${b.toLowerCase()}-width`);\r\n};\r\n\r\n/**\r\n * After the render: each list that changed size grows or shrinks to it from where it was,\r\n * with its animation's duration and easing (`option`; a custom function: the defaults).\r\n */\r\nexport const animateSizes = (sizes: SizeSnapshot[], option: (list: ListEntry) => LayoutAnimation | AnimationOptions | boolean | undefined) => {\r\n for (const { list, element, width, height } of sizes) {\r\n if (!element.isConnected || !canAnimate(element)) continue;\r\n // Its size as the render left it, not as a resize under way shows it.\r\n running.get(element)?.cancel();\r\n running.delete(element);\r\n const to = { width: element.offsetWidth, height: element.offsetHeight };\r\n const changed = (['width', 'height'] as const).filter((axis) => Math.abs(to[axis] - (axis === 'width' ? width : height)) >= 1);\r\n if (!changed.length) continue;\r\n const resolved = resolveAnimation(option(list), DEFAULT_LAYOUT_ANIMATION);\r\n if (!resolved) continue;\r\n const style = getComputedStyle(element);\r\n const from: Keyframe = {};\r\n const end: Keyframe = {};\r\n for (const axis of changed) {\r\n from[axis] = `${cssSize(style, axis, axis === 'width' ? width : height)}px`;\r\n end[axis] = `${cssSize(style, axis, to[axis])}px`;\r\n }\r\n const { duration, easing } = resolved.options;\r\n const animation = element.animate([from, end], { duration, easing });\r\n running.set(element, animation);\r\n animation.addEventListener('finish', () => running.get(element) === animation && running.delete(element));\r\n }\r\n};\r\n","/**\r\n * FLIP for every change a sortable group makes: the items are measured before the\r\n * render a draft change causes and animated from there after it (`bump`). Changes the\r\n * library didn't cause (virtualizer re-measures) go through `captureLayout`.\r\n *\r\n * Only items near the visible area animate; far ones just move (rfcs/0001-v3.md §8). A\r\n * pass doesn't even look at the far ones: it goes over the near set, the items that were\r\n * near when all of them were last scanned. Scans run at the start and the end of a drag,\r\n * when a list moved or scrolled by half its visible size, and once the drafts may have\r\n * carried far items into view: a draft change moves items by the dragged block at most,\r\n * and the near margin is a whole scroller size.\r\n */\r\n\r\nimport { nextTick, watch } from 'vue';\r\nimport type { Key, Rect } from '../types';\r\nimport { fadeIn, flip, getRect, type FlipBatch, type FlipEntry } from '../animation/layout';\r\nimport { keysOf, listOfKey, type GroupContext, type Session } from './context';\r\nimport type { ListEntry } from './entry';\r\nimport { animateSizes, captureSizes, type SizeSnapshot } from './resize';\r\n\r\ninterface Snapshot {\r\n element: HTMLElement;\r\n rect: Rect;\r\n}\r\n\r\n/** A list where the near set was made: moved or scrolled further than its slack, it asks for a scan. */\r\ninterface Probe {\r\n element: HTMLElement;\r\n left: number;\r\n top: number;\r\n scrollLeft: number;\r\n scrollTop: number;\r\n /** Half the list's visible size: within that the near margin still covers what shows. */\r\n slackX: number;\r\n slackY: number;\r\n}\r\n\r\nexport interface NearSet {\r\n keys: Set<Key>;\r\n /** The drag it was made for. */\r\n session: Session | null;\r\n probes: Probe[];\r\n /** Slots the items may still move by before a scan. */\r\n drift: number;\r\n}\r\n\r\n/** At most this many slots of drift between scans. */\r\nconst MAX_DRIFT = 8;\r\n\r\nconst NO_KEYS: ReadonlySet<Key> = new Set();\r\n\r\nconst probeList = (g: GroupContext, list: ListEntry): Probe[] => {\r\n const element = list.getElement();\r\n if (!element?.isConnected) return [];\r\n const { left, top } = getRect(element);\r\n const visible = g.manager.measureVisible(element);\r\n const { scrollLeft, scrollTop } = element;\r\n return [{ element, left, top, scrollLeft, scrollTop, slackX: (visible?.width ?? 0) / 2, slackY: (visible?.height ?? 0) / 2 }];\r\n};\r\n\r\n/** Its items moved with the list, or with its own scroll. */\r\nconst moved = ({ element, left, top, scrollLeft, scrollTop, slackX, slackY }: Probe) => {\r\n const rect = getRect(element);\r\n return (\r\n Math.abs(rect.left - left - element.scrollLeft + scrollLeft) > slackX + 0.5 ||\r\n Math.abs(rect.top - top - element.scrollTop + scrollTop) > slackY + 0.5\r\n );\r\n};\r\n\r\n/**\r\n * Slots of drift a near set made of `keys` can take: half a scroller size of items. A\r\n * list with far items has up to three sizes of near ones (its visible area and the margin\r\n * on each side); the one with the fewest sets the pace. Lists without far items, or\r\n * without near ones (their probes watch them), don't count.\r\n */\r\nconst driftFor = (g: GroupContext, keys: ReadonlySet<Key>): number => {\r\n const counts = new Map<ListEntry, number>();\r\n for (const key of keys) {\r\n const list = listOfKey(g, key, true);\r\n if (list) counts.set(list, (counts.get(list) ?? 0) + 1);\r\n }\r\n let fewest = Infinity;\r\n for (const [list, count] of counts) if (count < keysOf(list).length) fewest = Math.min(fewest, count);\r\n return Math.max(1, Math.min(MAX_DRIFT, Math.floor(fewest / 6)));\r\n};\r\n\r\n/** The near set still covers every item that may show after this pass. */\r\nconst holds = (g: GroupContext, near: NearSet): boolean => {\r\n if (near.session !== g.session.value) return false;\r\n near.drift -= g.session.value?.block.length ?? 1;\r\n return near.drift >= 0 && !near.probes.some(moved);\r\n};\r\n\r\n/** Visual rects of the items near the visible area, by key. */\r\nconst capture = (g: GroupContext): Map<Key, Snapshot> => {\r\n const { manager, items } = g;\r\n const snapshot = new Map<Key, Snapshot>();\r\n const near = g.near;\r\n if (near && holds(g, near)) {\r\n for (const key of near.keys) {\r\n const element = items.get(key)?.();\r\n if (element?.isConnected) {\r\n if (manager.isNearViewport(element)) snapshot.set(key, { element, rect: getRect(element) });\r\n } else if (!items.has(key)) {\r\n near.keys.delete(key);\r\n }\r\n }\r\n return snapshot;\r\n }\r\n const keys = new Set<Key>();\r\n for (const [key, getElement] of items) {\r\n const element = getElement();\r\n if (!element?.isConnected || !manager.isNearViewport(element)) continue;\r\n keys.add(key);\r\n snapshot.set(key, { element, rect: getRect(element) });\r\n }\r\n const probes = [...g.lists.values()].flatMap((list) => probeList(g, list));\r\n g.near = { keys, session: g.session.value, probes, drift: driftFor(g, keys) };\r\n return snapshot;\r\n};\r\n\r\n/**\r\n * Animates the items captured in `snapshot` to where the render put them. Of the items\r\n * the render created (`fresh`), a `'stack'` drag's others come back out of the overlay,\r\n * and the rest fade in with `fadeAppearing` (copies, items returning to their lists).\r\n */\r\nconst animate = (g: GroupContext, snapshot: Map<Key, Snapshot>, fresh: ReadonlySet<Key>, fadeAppearing: boolean) => {\r\n const { manager, items } = g;\r\n const byList = new Map<ListEntry, FlipEntry[]>();\r\n const add = (list: ListEntry, entry: FlipEntry) => {\r\n const entries = byList.get(list);\r\n if (entries) entries.push(entry);\r\n else byList.set(list, [entry]);\r\n };\r\n const appearing: Array<{ element: HTMLElement; list: ListEntry }> = [];\r\n const landing = manager.landingKey.value ?? manager.active.value?.id;\r\n const back = g.returning;\r\n g.returning = null;\r\n const pickup = g.gathering;\r\n g.gathering = false;\r\n // The overlay carries a clone of the item landing on `key` (multi-drag column): the\r\n // drag's, or a landing one's (the commit renders after its drag handed the box over).\r\n const carried = (key: Key) =>\r\n key === landing || manager.overlayItems.has(manager.landings.value.get(key) ?? key) || manager.isCarried(key);\r\n for (const [key, before] of snapshot) {\r\n const element = items.get(key)?.();\r\n if (!element?.isConnected) continue;\r\n const list = listOfKey(g, key, true);\r\n if (!list) continue;\r\n // A recreated element came from another list (a swap partner, a key a list didn't take).\r\n const crossing = before.element !== element;\r\n // The active slot entering another list was recreated: sliding it in from the\r\n // old list would be clipped by the new scroller, and the overlay shows it anyway.\r\n // The same goes for the items whose clones the overlay carries, except at pickup,\r\n // where the others visibly travel into the block.\r\n if (crossing && !pickup && carried(key)) continue;\r\n add(list, { key, element, first: before.rect, crossing });\r\n }\r\n for (const key of fresh) {\r\n const element = snapshot.has(key) ? null : items.get(key)?.();\r\n const list = element?.isConnected && listOfKey(g, key, true);\r\n if (!list) continue;\r\n g.near?.keys.add(key);\r\n if (back?.keys.has(key)) {\r\n // Multi-drag items coming back out of the overlay.\r\n add(list, { key, element: element!, first: back.from });\r\n appearing.push({ element: element!, list });\r\n } else if (fadeAppearing && key !== landing && manager.isNearViewport(element!)) {\r\n fadeIn(element!, list.animation());\r\n }\r\n }\r\n const batches: FlipBatch[] = [];\r\n for (const [list, entries] of byList) batches.push({ entries, option: list.animation() });\r\n flip(batches);\r\n for (const { element, list } of appearing) fadeIn(element, list.animation());\r\n manager.invalidateMeasurements();\r\n if (!g.session.value) g.near = null;\r\n};\r\n\r\n/** The drafts changed: a FLIP pass runs around the render. */\r\nexport const bump = (g: GroupContext) => {\r\n g.dragPass = true;\r\n g.version.value++;\r\n};\r\n\r\n/** Runs a FLIP pass around every render `bump` causes. Call inside the group's effect scope. */\r\nexport const watchLayout = (g: GroupContext) => {\r\n let snapshot = new Map<Key, Snapshot>();\r\n let sizes: SizeSnapshot[] = [];\r\n watch(\r\n g.version,\r\n () => {\r\n snapshot = capture(g);\r\n sizes = captureSizes(g, g.lists.values());\r\n g.fresh = new Set();\r\n },\r\n { flush: 'pre' },\r\n );\r\n watch(\r\n g.version,\r\n () => {\r\n const fresh = g.fresh ?? NO_KEYS;\r\n g.fresh = null;\r\n g.dragPass = false;\r\n // The lists resize first: the items measure where that leaves them.\r\n animateSizes(sizes, (list) => list.animation());\r\n animate(g, snapshot, fresh, true);\r\n },\r\n { flush: 'post' },\r\n );\r\n};\r\n\r\n/** For layout changes the library didn't cause (virtualizer re-measures). Free while idle. */\r\nexport const captureLayout = (g: GroupContext) => {\r\n if (g.manager.status.value === 'idle') return;\r\n const snapshot = capture(g);\r\n void nextTick(() => animate(g, snapshot, NO_KEYS, false));\r\n};\r\n","/**\r\n * Moves of the slot, and of the block travelling with it, through the drafts of a group.\r\n * Every move mirrors the session into the manager and runs a FLIP pass.\r\n */\r\n\r\nimport type { Coordinates, Key } from '../types';\r\nimport { keysOf, listOf, type GroupContext, type Session } from './context';\r\nimport type { ListEntry } from './entry';\r\nimport { blockFor, expand, putBack, viewOf } from './block';\r\nimport { syncManager } from './landing';\r\nimport { bump } from './flip';\r\nimport { neighbourKeys, passedKeys } from './stability';\r\n\r\n/**\r\n * Moves the slot to `index` of `target`'s draft (counted as `viewOf` counts it),\r\n * removing it from the list that held it. A block moves along as one unit; entering a\r\n * list, the members before the slot go before `index`, so the block lines up with the\r\n * overlay's column around the pointer. `blockStart`: `index` is where the block starts.\r\n */\r\nexport const moveActive = (\r\n g: GroupContext,\r\n target: ListEntry,\r\n index: number,\r\n pointer: Coordinates | null,\r\n blockStart = false,\r\n) => {\r\n const current = g.session.value!;\r\n const slot = current.slot;\r\n const from = listOf(g, current.list);\r\n let passed: Set<Key>;\r\n if (from === target) {\r\n const view = [...viewOf(from, current)];\r\n const position = view.indexOf(slot);\r\n if (position === -1 || position === index) return;\r\n passed = passedKeys(view, position, index);\r\n view.splice(position, 1);\r\n view.splice(index, 0, slot);\r\n from.draft.value = expand(view, slot, current.block);\r\n } else {\r\n const old = current.block;\r\n const block = blockFor(g, current, target);\r\n const leaving = new Set(old);\r\n // Keys put back while another list didn't take them join the block again.\r\n const joining = new Set(block.filter((key) => !leaving.has(key)));\r\n const before = keysOf(target);\r\n // Keys about to join don't count: the block starts `members before the slot` keys\r\n // ahead of `index`, before the first key from there that stays.\r\n let start = Math.min(index, before.length);\r\n for (let skip = blockStart ? 0 : block.indexOf(slot); skip > 0 && start > 0; ) {\r\n if (!joining.has(before[--start]!)) skip--;\r\n }\r\n let anchor: Key | null = null;\r\n for (let i = start; i < before.length; i++) {\r\n if (!joining.has(before[i]!)) {\r\n anchor = before[i]!;\r\n break;\r\n }\r\n }\r\n if (from) from.draft.value = keysOf(from).filter((key) => !leaving.has(key));\r\n if (joining.size) {\r\n for (const list of g.lists.values()) {\r\n const keys = keysOf(list);\r\n if (keys.some((key) => joining.has(key))) list.draft.value = keys.filter((key) => !joining.has(key));\r\n }\r\n }\r\n if (current.mode.name !== 'copy') {\r\n // Keys this list doesn't take go back to where they started (copies just leave).\r\n const moving = new Set(block);\r\n const dropped = old\r\n .filter((key) => !moving.has(key))\r\n .map((key) => ({ key, source: current.sources.get(key) }))\r\n .sort((a, b) => (a.source?.index ?? 0) - (b.source?.index ?? 0));\r\n for (const { key, source } of dropped) {\r\n const list = source && g.lists.get(source.list);\r\n if (!list) continue;\r\n const keys = [...keysOf(list)];\r\n putBack(keys, list, key, source.index, moving);\r\n list.draft.value = keys;\r\n }\r\n }\r\n const keys = [...keysOf(target)];\r\n const at = anchor == null ? keys.length : keys.indexOf(anchor);\r\n passed = neighbourKeys(keys, at);\r\n keys.splice(at, 0, ...block);\r\n target.draft.value = keys;\r\n current.block = block;\r\n current.list = target.id;\r\n }\r\n current.hysteresis = pointer\r\n ? { keys: passed, list: from && from !== target ? from.id : null, at: pointer }\r\n : null;\r\n current.indicator = null;\r\n syncManager(g);\r\n bump(g);\r\n g.manager.announce('onDragOver');\r\n};\r\n\r\n/** Takes the slot (and its block) out of every draft (a copy over its palette, an external item leaving). */\r\nexport const removeSlot = (g: GroupContext) => {\r\n const current = g.session.value!;\r\n const list = listOf(g, current.list);\r\n if (!list) return;\r\n const block = new Set(current.block);\r\n list.draft.value = keysOf(list).filter((key) => !block.has(key));\r\n current.list = null;\r\n syncManager(g);\r\n bump(g);\r\n};\r\n\r\n/** Over a list that can't be sorted: the active item (and its block) goes back to where it started. */\r\nexport const returnToOrigin = (g: GroupContext, pointer: Coordinates | null) => {\r\n const current = g.session.value!;\r\n if (current.slot !== current.lead) return removeSlot(g);\r\n const origin = listOf(g, current.origin.list);\r\n const base = origin && current.base.get(origin.id);\r\n const start = base ? base.indexOf(current.lead) : -1;\r\n if (!origin || !base || start < 0) return;\r\n const members = new Set(current.grouped ? current.keys : []);\r\n members.delete(current.lead);\r\n if (current.list === origin.id) {\r\n // Counted as `viewOf` counts it: the block once.\r\n moveActive(g, origin, base.slice(0, start).filter((key) => !members.has(key)).length, pointer);\r\n return;\r\n }\r\n // From another list: before the key that followed the block at the start.\r\n const anchor = base.slice(start + 1).find((key) => !members.has(key));\r\n const keys = keysOf(origin);\r\n const index = anchor === undefined ? -1 : keys.indexOf(anchor);\r\n moveActive(g, origin, index === -1 ? keys.length : index, pointer, true);\r\n};\r\n\r\n/** A `'group'` block comes apart: the lists show their items as they are, the dragged ones dimmed in place. */\r\nexport const takeApart = (g: GroupContext, current: Session) => {\r\n if (current.apart) return;\r\n for (const list of g.lists.values()) list.draft.value = [...list.getKeys()];\r\n current.list = current.origin.list;\r\n current.block = [current.lead];\r\n current.apart = true;\r\n syncManager(g);\r\n bump(g);\r\n};\r\n\r\n/** Back over a list: the block forms again where the drag picked it up, as it did at the start. */\r\nexport const regather = (g: GroupContext, current: Session) => {\r\n for (const list of g.lists.values()) list.draft.value = current.base.get(list.id) ?? [...list.getKeys()];\r\n current.list = current.origin.list;\r\n current.block = current.keys;\r\n current.apart = false;\r\n g.gathering = true;\r\n syncManager(g);\r\n bump(g);\r\n};\r\n\r\n/**\r\n * The dragged items go home: over a target that refuses the drag, or a drop target of its\r\n * own outside the lists (by pointer or by the arrows), the lists show where a drop there\r\n * leaves them, not the last list that took them. A `'group'` block comes apart, each item\r\n * back in its own place. Trees keep the slot: their places have a depth.\r\n */\r\nexport const goHome = (g: GroupContext, current: Session, pointer: Coordinates | null) => {\r\n if (current.list == null || listOf(g, current.list)?.layout.nested || listOf(g, current.origin.list)?.layout.nested) return;\r\n if (current.grouped && current.mode.name === 'move') return takeApart(g, current);\r\n returnToOrigin(g, pointer);\r\n};\r\n\r\n/** Indicator lists don't move: the slot stays (or goes back) where it started. */\r\nexport const keepSlotHome = (g: GroupContext, current: Session) => {\r\n if (current.slot !== current.lead) {\r\n if (current.list != null) removeSlot(g);\r\n } else if (current.list !== current.origin.list) {\r\n returnToOrigin(g, null);\r\n }\r\n};\r\n","/**\r\n * `placeholder: 'indicator'`: the list doesn't move, a line shows where the drop goes.\r\n * The slot stays (or goes back) where it started; the line is the group's `indicator`.\r\n */\r\n\r\nimport type { Coordinates, DnDEvent, Key, SortableIndicator } from '../types';\r\nimport { getCenter, getLayoutRect } from '../animation/layout';\r\nimport { revealElement } from '../core/autoscroll';\r\nimport { keysOf, type GroupContext } from './context';\r\nimport type { ListEntry } from './entry';\r\nimport { collect } from './block';\r\nimport { keepSlotHome } from './slot';\r\nimport { atLead, inView } from './landing';\r\nimport { bandsAt } from './combine';\r\nimport { canSwap, isSwapping } from './accept';\r\nimport { hitItem } from './projection';\r\n\r\nconst INDICATOR_FIELDS = ['list', 'index', 'key', 'side', 'depth', 'parentKey'] as const;\r\n\r\nconst sameIndicator = (a: SortableIndicator | null, b: SortableIndicator | null) =>\r\n a === b || (!!a && !!b && INDICATOR_FIELDS.every((field) => a[field] === b[field]));\r\n\r\nexport const setIndicator = (g: GroupContext, value: SortableIndicator | null) => {\r\n if (sameIndicator(g.indicator.value, value)) return false;\r\n g.indicator.value = value;\r\n // What a drop would do may follow the line (an item made for a plain draggable goes in).\r\n const current = g.session.value;\r\n if (current) g.manager.mode.value = current.mode.dragMode(g, current);\r\n return true;\r\n};\r\n\r\n/** Shows the insertion line (trees move it with their own keys). */\r\nexport const showIndicator = (g: GroupContext, value: SortableIndicator | null) => {\r\n const current = g.session.value!;\r\n if (value) current.indicator = value;\r\n if (setIndicator(g, value) && value) g.manager.announce('onDragOver');\r\n};\r\n\r\n/**\r\n * In a list that swaps, the mark is on the item the drop would exchange with\r\n * (`side: 'swap'`); `null` over the dragged item itself or over one that can't take its place.\r\n */\r\nexport const swapMark = (g: GroupContext, target: ListEntry, key: Key | null): SortableIndicator | null => {\r\n const current = g.session.value!;\r\n if (key == null || key === current.slot || !canSwap(g, current, target, key)) return null;\r\n return { list: target.id, index: keysOf(target).indexOf(key), key, side: 'swap' };\r\n};\r\n\r\n/** The pointer moves over `target`, an indicator list: the line goes where it points. */\r\nexport const updateIndicator = (g: GroupContext, target: ListEntry, event: DnDEvent) => {\r\n const current = g.session.value!;\r\n keepSlotHome(g, current);\r\n const items = collect(g, target);\r\n if (isSwapping(g, current, target)) {\r\n // Between two items the mark stays; over the dragged item it goes.\r\n const hit = hitItem(target.strategy(), event.pointer, items);\r\n if (hit) showIndicator(g, swapMark(g, target, hit.key));\r\n return;\r\n }\r\n const result = target.layout.indicate(inView(g, target, atLead(g, current, event)), {\r\n keys: keysOf(target),\r\n items,\r\n activeKey: current.slot,\r\n activeIndex: -1,\r\n strategy: target.strategy(),\r\n lock: null,\r\n targets: bandsAt(g, event),\r\n });\r\n if (result !== undefined) showIndicator(g, result && { list: target.id, ...result });\r\n};\r\n\r\n/** Keyboard, a list that swaps: marks `key` (the dragged item: no mark); returns where the overlay goes. */\r\nexport const markSwapAt = (g: GroupContext, target: ListEntry, key: Key): Coordinates | undefined => {\r\n showIndicator(g, swapMark(g, target, key));\r\n const element = g.items.get(key)?.();\r\n if (!element?.isConnected) return undefined;\r\n revealElement(element);\r\n return getCenter(getLayoutRect(element));\r\n};\r\n\r\n/** Keyboard: shows the insertion line at `index` of `target`; returns where the overlay goes. */\r\nexport const indicateAt = (g: GroupContext, target: ListEntry, index: number): Coordinates | undefined => {\r\n const line = target.layout.indicateAt(keysOf(target), index);\r\n if (!line) return undefined;\r\n showIndicator(g, { list: target.id, ...line });\r\n const element = (line.key == null ? null : g.items.get(line.key)?.()) ?? target.getElement();\r\n if (!element?.isConnected) return undefined;\r\n revealElement(element);\r\n return getCenter(getLayoutRect(element));\r\n};\r\n","/**\r\n * `animate` (rfcs/0001-v3.md §8): changes of a list's items that no drag made. Moves go\r\n * through the FLIP engine (`layout.ts`); this module resolves the option per kind of\r\n * change and plays the other two: items appearing, and items leaving. A leaving item is\r\n * gone from the DOM by the time it is animated, so a copy of it stands in its place.\r\n */\r\n\r\nimport type {\r\n AnimationOptions,\r\n AutoAnimation,\r\n EnterAnimationContext,\r\n Key,\r\n LayoutAnimation,\r\n LeaveAnimationContext,\r\n Rect,\r\n} from '../types';\r\nimport { copyElement, removeTransient } from '../core/clone';\r\nimport {\r\n DEFAULT_LAYOUT_ANIMATION,\r\n STALL_MARGIN,\r\n canAnimate,\r\n getRect,\r\n prefersReducedMotion,\r\n resolveAnimation,\r\n settle,\r\n} from './layout';\r\n\r\ntype Result = Animation | Promise<unknown> | void;\r\ntype Resolved<TContext> = NonNullable<\r\n ReturnType<typeof resolveAnimation<(context: TContext) => Result>>\r\n>;\r\n\r\n/** `animate` resolved per kind of change. */\r\nexport interface AutoAnimationParts {\r\n /** For `flip`: the move option and the timing it falls back to. */\r\n move: { option: LayoutAnimation; defaults: Required<AnimationOptions> };\r\n enter: Resolved<EnterAnimationContext> | null;\r\n leave: Resolved<LeaveAnimationContext> | null;\r\n}\r\n\r\n/** `duration` and `easing` given in `option`, leaving out the unset ones. */\r\nconst timing = ({ duration, easing }: AnimationOptions): AnimationOptions => ({\r\n ...(duration !== undefined && { duration }),\r\n ...(easing !== undefined && { easing }),\r\n});\r\n\r\n/**\r\n * `animate` per kind of change; `null` when it is off. Reduced motion turns off the\r\n * default animations (functions of yours still run): with none of yours, nothing is even\r\n * measured.\r\n */\r\nexport const resolveAutoAnimation = (option: AutoAnimation | undefined): AutoAnimationParts | null => {\r\n if (!option) return null;\r\n const parts = option === true ? {} : option;\r\n const defaults = { ...DEFAULT_LAYOUT_ANIMATION, ...timing(parts) };\r\n const move = parts.move ?? true;\r\n const resolved: AutoAnimationParts = {\r\n move: { option: typeof move !== 'function' && prefersReducedMotion() ? false : move, defaults },\r\n enter: resolveAnimation(parts.enter, defaults),\r\n leave: resolveAnimation(parts.leave, defaults),\r\n };\r\n return resolved.move.option !== false || resolved.enter || resolved.leave ? resolved : null;\r\n};\r\n\r\n/** Plays the entrance of an item that appeared: by default a fade in, in its place. */\r\nexport const enter = (part: Resolved<EnterAnimationContext>, key: Key, element: HTMLElement, to: Rect): void => {\r\n const { custom, options } = part;\r\n if (custom) void custom({ key, element, to, options, reducedMotion: prefersReducedMotion() });\r\n else if (canAnimate(element)) element.animate([{ opacity: 0 }, { opacity: 1 }], options);\r\n};\r\n\r\nexport interface Leaving {\r\n key: Key;\r\n /** The item's element, which Vue has just removed (detached, still whole). */\r\n element: HTMLElement;\r\n /** The parent it was in: the copy goes there, so the page's styles and clipping apply. */\r\n parent: Element;\r\n /** Where it was. */\r\n from: Rect;\r\n}\r\n\r\n/** Applied with `!important`: the copy keeps the item's look, but not its place in the flow. */\r\nconst GHOST_STYLE: Record<string, string> = {\r\n position: 'absolute',\r\n left: '0px',\r\n top: '0px',\r\n margin: '0px',\r\n 'box-sizing': 'border-box',\r\n 'pointer-events': 'none',\r\n transition: 'none',\r\n // A CSS entrance animation of the item would replay on the copy.\r\n animation: 'none',\r\n};\r\n\r\n/** A copy animating out: `remove` takes it away at once (the key came back), `ended` settles when it is gone. */\r\nexport interface Ghost {\r\n remove(): void;\r\n ended: Promise<void>;\r\n}\r\n\r\n/**\r\n * Plays the exit of items that left: a copy of each stands where it was (absolutely\r\n * positioned in its old parent) and is animated out, by default fading as it shrinks a\r\n * little, then removed. Table rows and SVG elements get no copy: they can't be taken out\r\n * of their layout.\r\n */\r\nexport const leave = (part: Resolved<LeaveAnimationContext>, items: Leaving[]): Map<Key, Ghost> => {\r\n const copies = new Map<Key, Ghost>();\r\n const ghosts = items.flatMap(({ key, element, parent, from }) => {\r\n if (!(element instanceof HTMLElement) || element.tagName === 'TR' || !parent.isConnected) return [];\r\n const ghost = copyElement(element);\r\n removeTransient(ghost);\r\n ghost.setAttribute('data-dnd-leaving', '');\r\n ghost.setAttribute('inert', '');\r\n const style: Record<string, string> = { ...GHOST_STYLE, width: `${from.width}px`, height: `${from.height}px` };\r\n for (const name in style) ghost.style.setProperty(name, style[name]!, 'important');\r\n parent.appendChild(ghost);\r\n return [{ key, ghost, from }];\r\n });\r\n // Every copy is in before the first read: one layout for all of them.\r\n const placed = ghosts.map(({ ghost }) => getRect(ghost));\r\n ghosts.forEach(({ key, ghost, from }, index) => {\r\n const at = placed[index]!;\r\n ghost.style.setProperty('left', `${from.left - at.left}px`, 'important');\r\n ghost.style.setProperty('top', `${from.top - at.top}px`, 'important');\r\n const { custom, options } = part;\r\n const result = custom\r\n ? custom({ key, element: ghost, from, options, reducedMotion: prefersReducedMotion() })\r\n : canAnimate(ghost)\r\n ? ghost.animate(\r\n [\r\n { opacity: 1, scale: '1' },\r\n { opacity: 0, scale: '0.96' },\r\n ],\r\n { ...options, fill: 'forwards' },\r\n )\r\n : undefined;\r\n const remove = () => ghost.remove();\r\n copies.set(key, { remove, ended: settle(result, options.duration + STALL_MARGIN).then(remove) });\r\n });\r\n return copies;\r\n};\r\n","/**\r\n * `animate` (rfcs/0001-v3.md §8): changes of a list's items that no drag made animate. A\r\n * list with it on watches its keys; a change measures the list's items near the visible\r\n * area before it renders, and once it has rendered moves them to their new places (FLIP,\r\n * across lists of the group too), fades in the items the render created and plays the\r\n * exit of the items it removed (`animation/presence.ts`). With it off, nothing runs.\r\n *\r\n * A drag's changes are the drag's own: drafts show while it runs, and its FLIP pass\r\n * animates the drop. Unmounted rows of a virtual list have nothing to animate.\r\n */\r\n\r\nimport { computed, nextTick, watch, type WatchHandle } from 'vue';\r\nimport type { Key, Rect } from '../types';\r\nimport { NEAR_VIEWPORT } from '../core/measure';\r\nimport { expandRect, flip, getRect, intersects, type FlipBatch, type FlipEntry } from '../animation/layout';\r\nimport { enter, leave, resolveAutoAnimation, type AutoAnimationParts, type Leaving } from '../animation/presence';\r\nimport { indexMap, listOfKey, sameKeys, type GroupContext } from './context';\r\nimport type { ListEntry } from './entry';\r\nimport { animateSizes, captureSizes, type SizeSnapshot } from './resize';\r\n\r\ninterface Captured {\r\n element: HTMLElement;\r\n /** Visual rect before the change. */\r\n rect: Rect;\r\n parent: Element | null;\r\n list: ListEntry;\r\n}\r\n\r\nexport interface AutoPass {\r\n /** Lists whose items changed, with their `animate` and the keys they showed before. */\r\n lists: Map<ListEntry, { parts: AutoAnimationParts; previous: readonly Key[] }>;\r\n /** Items of those lists that were near the visible area before the change. */\r\n snapshot: Map<Key, Captured>;\r\n /** Sizes of those lists before the change (`animateSize`). */\r\n sizes: SizeSnapshot[];\r\n}\r\n\r\nconst NO_KEYS: ReadonlySet<Key> = new Set();\r\n\r\n/** The visible area of `list` grown by the near margin; `null` when none of it shows. */\r\nconst nearRegion = (g: GroupContext, list: ListEntry): Rect | null => {\r\n const element = list.getElement();\r\n const visible = element?.isConnected ? g.manager.measureVisible(element) : null;\r\n return visible && expandRect(visible, visible.width * NEAR_VIEWPORT, visible.height * NEAR_VIEWPORT);\r\n};\r\n\r\n/** Before the change renders: the items `list` showed (`previous`) near the visible area. */\r\nconst measure = (g: GroupContext, list: ListEntry, previous: readonly Key[]) => {\r\n // Drafts show while a drag runs, and its own FLIP pass animates the drop's writes.\r\n if (g.dragPass || g.session.value) return;\r\n const parts = resolveAutoAnimation(list.animate?.());\r\n if (!parts) return;\r\n let pass = g.auto;\r\n if (!pass) {\r\n const created: AutoPass = (pass = g.auto = { lists: new Map(), snapshot: new Map(), sizes: [] });\r\n g.fresh ??= new Set();\r\n // The render may unmount this list before its post-flush watcher plays the pass.\r\n void nextTick(() => {\r\n if (g.auto !== created) return;\r\n g.auto = null;\r\n g.fresh = null;\r\n });\r\n }\r\n if (!pass.lists.has(list)) pass.sizes.push(...captureSizes(g, [list]));\r\n pass.lists.set(list, { parts, previous });\r\n const region = nearRegion(g, list);\r\n if (!region) return;\r\n for (const key of previous) {\r\n const element = g.items.get(key)?.();\r\n if (!element?.isConnected) continue;\r\n const rect = getRect(element);\r\n if (intersects(rect, region)) pass.snapshot.set(key, { element, rect, parent: element.parentElement, list });\r\n }\r\n};\r\n\r\n/** After the render: moves, entrances and exits of the lists in the pass. */\r\nconst play = (g: GroupContext) => {\r\n const pass = g.auto;\r\n // No pass: the render was a drag's, whose own FLIP pass reads `fresh`.\r\n if (!pass) return;\r\n const fresh = g.fresh ?? NO_KEYS;\r\n g.auto = null;\r\n g.fresh = null;\r\n const { lists, snapshot } = pass;\r\n const moves = new Map<ListEntry, FlipEntry[]>();\r\n const leaving = new Map<ListEntry, Leaving[]>();\r\n const comeBack = (key: Key) => {\r\n g.leaving.get(key)?.();\r\n g.leaving.delete(key);\r\n };\r\n\r\n for (const [key, before] of snapshot) {\r\n const element = g.items.get(key)?.();\r\n if (element?.isConnected) {\r\n // A recreated element moved here from another list.\r\n const list = element === before.element ? before.list : listOfKey(g, key, false);\r\n const move = list && lists.get(list)?.parts.move;\r\n if (!move || move.option === false) continue;\r\n comeBack(key);\r\n const entries = moves.get(list) ?? [];\r\n entries.push({ key, element, first: before.rect, crossing: element !== before.element });\r\n moves.set(list, entries);\r\n } else if (!listOfKey(g, key, false) && lists.get(before.list)?.parts.leave) {\r\n // Gone from every list of the group (still in one: a virtual list unmounted its row).\r\n const parent = before.parent?.isConnected ? before.parent : before.list.getElement();\r\n if (!parent) continue;\r\n const items = leaving.get(before.list) ?? [];\r\n items.push({ key, element: before.element, parent, from: before.rect });\r\n leaving.set(before.list, items);\r\n }\r\n }\r\n\r\n // Items the render created that no list showed before: a virtual list's newly mounted\r\n // rows were there all along.\r\n const entering: Array<{ key: Key; element: HTMLElement; to: Rect; parts: AutoAnimationParts }> = [];\r\n const regions = new Map<ListEntry, Rect | null>();\r\n for (const key of fresh) {\r\n if (snapshot.has(key)) continue;\r\n const element = g.items.get(key)?.();\r\n const list = element?.isConnected ? listOfKey(g, key, false) : undefined;\r\n const parts = list && lists.get(list)?.parts;\r\n if (!list || !parts?.enter) continue;\r\n if ([...lists.values()].some(({ previous }) => indexMap(g, previous).has(key))) continue;\r\n if (!regions.has(list)) regions.set(list, nearRegion(g, list));\r\n const region = regions.get(list);\r\n const to = getRect(element!);\r\n if (region && intersects(to, region)) entering.push({ key, element: element!, to, parts });\r\n }\r\n\r\n // The lists resize first: the items measure where that leaves them.\r\n animateSizes(pass.sizes, (list) => lists.get(list)?.parts.move?.option);\r\n const batches: FlipBatch[] = [];\r\n for (const [list, entries] of moves) {\r\n const { option, defaults } = lists.get(list)!.parts.move;\r\n batches.push({ entries, option, defaults });\r\n }\r\n flip(batches, 'change');\r\n for (const { key, element, to, parts } of entering) {\r\n comeBack(key);\r\n enter(parts.enter!, key, element, to);\r\n }\r\n for (const [list, items] of leaving) {\r\n for (const [key, { remove, ended }] of leave(lists.get(list)!.parts.leave!, items)) {\r\n comeBack(key);\r\n g.leaving.set(key, remove);\r\n void ended.then(() => {\r\n if (g.leaving.get(key) === remove) g.leaving.delete(key);\r\n });\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Animates the changes of `list`'s items that no drag made, while its `animate` is on.\r\n * Call in the list's setup: the watchers stop with it.\r\n */\r\nexport const watchChanges = (g: GroupContext, list: ListEntry): void => {\r\n const on = computed(() => !!list.animate?.());\r\n let stops: WatchHandle[] = [];\r\n watch(\r\n on,\r\n (value) => {\r\n stops.forEach((stop) => stop());\r\n stops = [];\r\n if (!value) return;\r\n const keys = () => list.getKeys();\r\n stops = [\r\n watch(keys, (next, previous) => !sameKeys(next, previous) && measure(g, list, previous), { flush: 'pre' }),\r\n watch(keys, () => play(g), { flush: 'post' }),\r\n ];\r\n },\r\n { immediate: true },\r\n );\r\n};\r\n","import { effectScope, onScopeDispose, watch } from 'vue';\r\nimport { defaultDocument, defaultWindow } from '@vueuse/core';\r\nimport type { DnDManager } from '../core/manager';\r\n\r\n/** Keys `getModifierState` knows; any other `copyModifier` is tracked by keydown/keyup. */\r\nconst MODIFIERS = new Set(['Alt', 'AltGraph', 'Control', 'Meta', 'Shift', 'CapsLock']);\r\n\r\ninterface Tracker {\r\n held: () => boolean;\r\n /** Sortable groups of the provider that read it. */\r\n users: number;\r\n stop: () => void;\r\n}\r\n\r\n/** One per provider, shared by its sortable groups. */\r\nconst trackers = new WeakMap<DnDManager, Tracker>();\r\n\r\nfunction createTracker(manager: DnDManager): Tracker {\r\n let held = false;\r\n const name = () => (manager.props.copyModifier === undefined ? 'Alt' : manager.props.copyModifier);\r\n\r\n const set = (value: boolean) => {\r\n if (value === held) return;\r\n held = value;\r\n if (manager.status.value === 'dragging') manager.scheduleFrame();\r\n };\r\n\r\n const onKey = (event: KeyboardEvent) => {\r\n const key = name();\r\n if (!key) return;\r\n if (event.key === key) {\r\n // A lone Alt press would move focus to the browser menu on Windows.\r\n if (manager.status.value === 'dragging') event.preventDefault();\r\n set(event.type === 'keydown');\r\n } else if (MODIFIERS.has(key)) {\r\n set(event.getModifierState(key));\r\n }\r\n };\r\n\r\n const onPointer = (event: PointerEvent) => {\r\n const key = name();\r\n if (key && MODIFIERS.has(key)) set(event.getModifierState(key));\r\n };\r\n\r\n const onBlur = () => set(false);\r\n\r\n const listeners = [\r\n [defaultDocument, 'keydown', onKey, { capture: true }],\r\n [defaultDocument, 'keyup', onKey, { capture: true }],\r\n [defaultDocument, 'pointerdown', onPointer, { capture: true, passive: true }],\r\n [defaultDocument, 'pointermove', onPointer, { capture: true, passive: true }],\r\n [defaultWindow, 'blur', onBlur, {}],\r\n ] as Array<[EventTarget | undefined, string, EventListener, AddEventListenerOptions]>;\r\n\r\n let listening = false;\r\n const listen = (on: boolean) => {\r\n if (on === listening) return;\r\n listening = on;\r\n for (const [target, type, listener, options] of listeners) {\r\n if (on) target?.addEventListener(type, listener, options);\r\n else target?.removeEventListener(type, listener, options);\r\n }\r\n if (!on) held = false;\r\n };\r\n\r\n // Only while a press waits or a drag runs: idle pages don't pay for every pointer move.\r\n // Not `flush: 'sync'`: a drag starting after its activation passes through `idle` for a\r\n // moment, which would drop the state read while the press waited.\r\n const scope = effectScope(true);\r\n scope.run(() => watch(() => manager.status.value !== 'idle', listen, { immediate: true }));\r\n\r\n return {\r\n held: () => held && !!name(),\r\n users: 0,\r\n stop: () => {\r\n scope.stop();\r\n listen(false);\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Live state of the provider's `copyModifier` (default Alt), for a sortable group. Key\r\n * and pointer events both carry it, so a copy can toggle while the pointer stands still.\r\n * The provider's groups share one tracker, which listens only from a press (`activating`)\r\n * until the provider is idle again: a key held before that shows with the next pointer\r\n * move or key press, which carry it too. Call inside the group's effect scope: the last\r\n * group to go stops the tracker.\r\n */\r\nexport function useCopyModifier(manager: DnDManager): () => boolean {\r\n let tracker = trackers.get(manager);\r\n if (!tracker) trackers.set(manager, (tracker = createTracker(manager)));\r\n const current = tracker;\r\n current.users++;\r\n onScopeDispose(() => {\r\n if (--current.users) return;\r\n current.stop();\r\n if (trackers.get(manager) === current) trackers.delete(manager);\r\n });\r\n return current.held;\r\n}\r\n","/**\r\n * The modes of a sortable session (rfcs/0001-v3.md §6): what its slot is, how the slot\r\n * moves over a list, and what the drop puts there. A session (`Session.mode`) sorts the\r\n * dragged item itself (`sort`), its copy (`copy`) or the item a list made for a plain\r\n * draggable (`insert`); while it holds an exchange (`behavior: 'swap'`) its mode is\r\n * `swap` (`modeOf`). The group calls the steps of the mode; multi-drag blocks\r\n * (`block.ts`), insertion lines (`indicator.ts`), trees and drops into an item\r\n * (`combine.ts`) are handled apart from the modes.\r\n */\r\n\r\nimport type { Coordinates, DnDEvent, DragMode, Key, KeyboardMoveContext } from '../../types';\r\nimport { listOf, type GroupContext, type Session } from '../context';\r\nimport type { ListEntry } from '../entry';\r\nimport type { DropFacts } from '../drop';\r\nimport { isSwapping, type Partition } from '../accept';\r\n\r\nexport interface SortableMode {\r\n /** The drop event's `mode`. */\r\n readonly name: DragMode;\r\n /**\r\n * The dragged items leave their places on drop (keys a list rejects go back there), and\r\n * a removal (trash zones, `dropOutside: 'remove'`) takes them out of their lists.\r\n */\r\n readonly moves: boolean;\r\n /** `manager.mode` while the session is as it is. */\r\n dragMode(g: GroupContext, current: Session): DragMode;\r\n /** Which dragged keys `list`, which isn't disabled, takes. */\r\n partition(g: GroupContext, list: ListEntry, current: Session): Partition;\r\n /** The drag can never enter `list`. */\r\n inert?(list: ListEntry, g: GroupContext): boolean;\r\n /** The drag enters `target`: makes its slot there; `false` when it can have none. */\r\n enter?(g: GroupContext, current: Session, target: ListEntry): boolean;\r\n /**\r\n * The pointer moves over `target`, a list that takes the drag and shows items (no\r\n * insertion line). `blocked`: the list the slot just left, which can't take it back\r\n * yet. `true`: the slot moved to where the pointer projects it, so a block lines up\r\n * with the pointer again once rendered (`followBlock`).\r\n */\r\n over(g: GroupContext, current: Session, target: ListEntry, event: DnDEvent, blocked: boolean): boolean;\r\n /** The pointer left the lists, or is over one that refuses the drag. */\r\n leave?(g: GroupContext, current: Session): void;\r\n /** Keys put at the slot for the dragged `keys`: the block that travels, what a drop inserts. */\r\n inserted(g: GroupContext, current: Session, keys: Key[]): Key[];\r\n /** Key standing for the dragged `key` where it lands: whose item the drop event reports, where its clone lands. */\r\n placed(current: Session, key: Key): Key;\r\n /** Dragged key the block member `key` stands for (by default `key` itself). */\r\n original?(current: Session, key: Key): Key;\r\n /** What the drop event tells in this mode on top of the rest (a swap's partner). */\r\n facts?(g: GroupContext, current: Session): Partial<DropFacts>;\r\n /** Keyboard, while no list holds the slot: the arrow may take the drag into one. */\r\n enterByKey?(g: GroupContext, current: Session, context: KeyboardMoveContext): Promise<Coordinates | undefined>;\r\n}\r\n\r\n/** The drag enters `target` (see `SortableMode.enter`); `false` when it can have no slot there. */\r\nexport const enters = (g: GroupContext, current: Session, target: ListEntry): boolean =>\r\n current.mode.enter?.(g, current, target) ?? true;\r\n\r\n// Steps of the modes in which the dragged items themselves move (`sort`, `swap`). Each\r\n// mode lists them: a spread would keep the modes from being tree-shaken.\r\n\r\n/** In a list that swaps (as the origin does), the drop exchanges. */\r\nexport const movingDragMode = (g: GroupContext, current: Session): DragMode =>\r\n isSwapping(g, current, listOf(g, current.list)) ? 'swap' : 'move';\r\n\r\n/** The dragged keys themselves travel and land. */\r\nexport const itself = (_g: GroupContext, _current: Session, keys: Key[]) => keys;\r\n\r\n/** A dragged key lands as itself. */\r\nexport const asItself = (_current: Session, key: Key) => key;\r\n","/**\r\n * Swapping (`behavior: 'swap'`): hovering an item exchanges it with the dragged one, each\r\n * taking the other's place, in one list or across two. A sorting session enters this mode\r\n * over a list that swaps as its origin does (`sort.over`), and holds it while it holds an\r\n * exchange (`modeOf`).\r\n */\r\n\r\nimport type { Coordinates, DnDEvent, Key, SortableDropEvent } from '../../types';\r\nimport { indexMap, lookup, type GroupContext, type Session } from '../context';\r\nimport type { ListEntry } from '../entry';\r\nimport { projectSwap } from '../projection';\r\nimport { blocksKey, passedKeys } from '../stability';\r\nimport { canSwap, partitionMoved } from '../accept';\r\nimport { collect } from '../block';\r\nimport { syncManager } from '../landing';\r\nimport { bump } from '../flip';\r\nimport { asItself, itself, movingDragMode, type SortableMode } from './mode';\r\n\r\n/**\r\n * Restores the drafts to the drag start, then exchanges the active item with `partner`:\r\n * each takes the other's place, in one list or across two.\r\n */\r\nexport const applySwap = (g: GroupContext, partner: Key | null, pointer: Coordinates | null) => {\r\n const { lists } = g;\r\n const current = g.session.value!;\r\n const previous = current.swap;\r\n for (const list of lists.values()) {\r\n const base = current.base.get(list.id);\r\n if (base && list.draft.value !== base) list.draft.value = base;\r\n }\r\n current.list = current.origin.list;\r\n const passed = new Set<Key>();\r\n if (previous != null) passed.add(previous);\r\n if (partner != null) {\r\n const own = lists.get(current.origin.list!)!;\r\n const other = [...lists.values()].find((list) => indexMap(g, current.base.get(list.id) ?? []).has(partner));\r\n if (other) {\r\n const a = [...current.base.get(own.id)!];\r\n const b = other === own ? a : [...current.base.get(other.id)!];\r\n const i = a.indexOf(current.activeKey);\r\n const j = b.indexOf(partner);\r\n a[i] = partner;\r\n b[j] = current.activeKey;\r\n own.draft.value = a;\r\n if (b !== a) other.draft.value = b;\r\n current.list = other.id;\r\n if (other === own) for (const key of passedKeys(a, i, j)) passed.add(key);\r\n passed.add(partner);\r\n }\r\n }\r\n current.swap = partner;\r\n current.hysteresis = pointer ? { keys: passed, list: null, at: pointer } : null;\r\n syncManager(g);\r\n bump(g);\r\n g.manager.announce('onDragOver');\r\n};\r\n\r\n/** The swap partner as the drop event tells it: it went to where the active item started. */\r\nconst partnerOf = (g: GroupContext, current: Session, partner: Key): SortableDropEvent['partner'] => ({\r\n key: partner,\r\n item: lookup(g, partner),\r\n from: { ...current.sources.get(partner)! },\r\n to: { list: current.origin.list!, index: current.origin.index },\r\n});\r\n\r\n/** The hovered item of `target` becomes the partner; hovering the partner reverts the exchange. */\r\nconst updateSwap = (g: GroupContext, current: Session, target: ListEntry, event: DnDEvent) => {\r\n const { partner, key } = projectSwap({\r\n strategy: target.strategy(),\r\n pointer: event.pointer,\r\n items: collect(g, target),\r\n activeKey: current.slot,\r\n partner: current.swap,\r\n });\r\n if (partner === undefined || blocksKey(current.hysteresis, key)) return false;\r\n // An item that can't take the active item's place makes no exchange: hovering it reverts one.\r\n const next = partner != null && !canSwap(g, current, target, partner) ? null : partner;\r\n if (next !== current.swap) applySwap(g, next, event.pointer);\r\n return false;\r\n};\r\n\r\nexport const swap: SortableMode = {\r\n name: 'swap',\r\n moves: true,\r\n dragMode: movingDragMode,\r\n partition: partitionMoved,\r\n over: updateSwap,\r\n // Off the lists, or over a list that sorts: the exchange is undone.\r\n leave: (g) => applySwap(g, null, null),\r\n inserted: itself,\r\n placed: asItself,\r\n facts: (g, current) => ({ partner: partnerOf(g, current, current.swap!) }),\r\n};\r\n\r\n/** The mode `current` drops in: `swap` while it holds an exchange. */\r\nexport const modeOf = (current: Session): SortableMode => (current.swap != null ? swap : current.mode);\r\n","/**\r\n * Sorting (`'move'`): the dragged item itself, with its block, moves through the drafts\r\n * to where the pointer projects it. Copies and created items move the same way\r\n * (`sortOver`); only the item itself can be exchanged instead, over a list that swaps.\r\n */\r\n\r\nimport type { DnDEvent, SortableStrategy } from '../../types';\r\nimport type { GroupContext, Session } from '../context';\r\nimport type { ListEntry } from '../entry';\r\nimport { blocksKey } from '../stability';\r\nimport { isSwapping, partitionMoved } from '../accept';\r\nimport { collect, viewOf } from '../block';\r\nimport { moveActive, returnToOrigin } from '../slot';\r\nimport { atLead, inView } from '../landing';\r\nimport { bandsAt } from '../combine';\r\nimport { asItself, itself, movingDragMode, type SortableMode } from './mode';\r\nimport { swap } from './swap';\r\n\r\n/**\r\n * The event to project, its point along the list's axis. A modifier that keeps the overlay\r\n * in a box (`restrictToParent`, a drag area's `restrictToArea`) holds the point where the\r\n * item is held while the pointer goes on past the box's edge: held near its leading edge,\r\n * the item could never pass the center of the last item (or of the first). Once the pointer\r\n * has left the overlay along the axis, the projection follows the pointer. Grids keep the\r\n * point: there the overlay held at the edge covers the edge cell, and the point is in it.\r\n */\r\nconst heldBack = (g: GroupContext, event: DnDEvent, strategy: SortableStrategy): DnDEvent => {\r\n const { manager } = g;\r\n const active = manager.active.value;\r\n if (strategy === 'grid' || !active) return event;\r\n const [axis, start, end] = strategy === 'horizontal' ? (['x', 'left', 'right'] as const) : (['y', 'top', 'bottom'] as const);\r\n const pointer = manager.getRawPointer()[axis];\r\n const box = manager.getOverlayRect(active, manager.transform.value);\r\n if (pointer >= box[start] && pointer <= box[end]) return event;\r\n return { ...event, pointer: { ...event.pointer, [axis]: pointer } };\r\n};\r\n\r\n/** The slot goes to the index the pointer projects in `target` (see `SortableMode.over`). */\r\nexport const sortOver = (\r\n g: GroupContext,\r\n current: Session,\r\n target: ListEntry,\r\n event: DnDEvent,\r\n blocked: boolean,\r\n): boolean => {\r\n const sameList = target.id === current.list;\r\n // `sort: false`: items can enter the list but not move inside it; back over its\r\n // own origin list the item returns to where it started (palettes).\r\n if (!target.canSort()) {\r\n if (!sameList && target.id === current.origin.list) {\r\n if (!blocked) returnToOrigin(g, event.pointer);\r\n return false;\r\n }\r\n if (sameList && !target.layout.nested) return false;\r\n }\r\n\r\n const keys = viewOf(target, current);\r\n const items = collect(g, target);\r\n const activeIndex = sameList ? keys.indexOf(current.slot) : -1;\r\n const strategy = target.strategy();\r\n const projection = target.layout.project(inView(g, target, atLead(g, current, heldBack(g, event, strategy))), {\r\n keys,\r\n items,\r\n activeKey: current.slot,\r\n activeIndex,\r\n strategy,\r\n lock: current.lock,\r\n targets: bandsAt(g, event),\r\n });\r\n current.lock = projection.lock;\r\n // A list that can't sort still projects (tree depth), but keeps its order.\r\n const index = sameList && !target.canSort() ? null : projection.index;\r\n if (index == null || blocked || blocksKey(current.hysteresis, projection.key)) return false;\r\n moveActive(g, target, index, event.pointer);\r\n return true;\r\n};\r\n\r\nexport const sort: SortableMode = {\r\n name: 'move',\r\n moves: true,\r\n dragMode: movingDragMode,\r\n partition: partitionMoved,\r\n over: (g, current, target, event, blocked) => {\r\n // A list that swaps (as the origin does) exchanges the item instead; over one that\r\n // sorts, an exchange made there is undone.\r\n if (isSwapping(g, current, target)) return swap.over(g, current, target, event, blocked);\r\n if (current.swap != null) swap.leave!(g, current);\r\n return sortOver(g, current, target, event, blocked);\r\n },\r\n inserted: itself,\r\n placed: asItself,\r\n};\r\n","/**\r\n * Keyboard sorting by items (rfcs/0001-v3.md §10): the arrow along a list moves the slot\r\n * by one, the perpendicular one moves it to the adjacent list (kanban), and in grids\r\n * up/down go to the nearest item of the next row. Into an indicator list only the line\r\n * moves. Trees navigate rows and depth themselves (`makeSortableTree`), and a drag from\r\n * outside the lists enters them through its mode (`insert.enterByKey`).\r\n */\r\n\r\nimport { nextTick } from 'vue';\r\nimport type { Active, Coordinates, KeyboardMoveContext, Rect } from '../types';\r\nimport { createRect, getCenter, getLayoutRect } from '../animation/layout';\r\nimport { revealElement } from '../core/autoscroll';\r\nimport { isFocusLost } from '../utils/dom';\r\nimport { keysOf, type GroupContext, type Session } from './context';\r\nimport type { ListEntry } from './entry';\r\nimport { nextRowIndex, pickAdjacent, projectIndex } from './projection';\r\nimport { accepts, canSwap, isSwapping } from './accept';\r\nimport { applySwap } from './modes/swap';\r\nimport { findDroppable } from '../core/sensors/steps';\r\nimport { collect, viewOf } from './block';\r\nimport { goHome, keepSlotHome, moveActive, regather, returnToOrigin } from './slot';\r\nimport { indicateAt, markSwapAt, setIndicator } from './indicator';\r\nimport { intoPoint } from './combine';\r\nimport { enters } from './modes/mode';\r\n\r\nconst clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), max);\r\n\r\n/** Insertion index in `target` for the slot coming from `from` (cross-list keyboard moves). */\r\nexport const insertionIndex = (g: GroupContext, target: ListEntry, from: Rect, current: Session): number => {\r\n const keys = keysOf(target);\r\n const element = target.getElement();\r\n const center = getCenter(from);\r\n const strategy = target.strategy();\r\n if (strategy !== 'grid') {\r\n // Before the first item whose center is level with or past the slot's (rows that line up tie).\r\n const axis = strategy === 'vertical' ? 'y' : 'x';\r\n const next = collect(g, target).find((item) => getCenter(item.rect)[axis] >= center[axis] - 1);\r\n return next ? next.index : keys.length;\r\n }\r\n let pointer = center;\r\n if (element) {\r\n const box = getLayoutRect(element);\r\n pointer = { x: clamp(center.x, box.left + 1, box.right - 1), y: clamp(center.y, box.top + 1, box.bottom - 1) };\r\n }\r\n const projection = projectIndex({\r\n strategy: target.strategy(),\r\n pointer,\r\n items: collect(g, target),\r\n activeKey: current.slot,\r\n activeIndex: -1,\r\n length: keys.length,\r\n lock: null,\r\n });\r\n return projection.index ?? keys.length;\r\n};\r\n\r\n/** Closest list of the group in the arrow's direction that takes the drag: from `list`, or from `origin` outside the lists. */\r\nexport const adjacentList = (\r\n g: GroupContext,\r\n list: ListEntry | null,\r\n active: Active,\r\n direction: Coordinates,\r\n origin?: Rect,\r\n): ListEntry | null => {\r\n const element = list?.getElement();\r\n const from = element ? getLayoutRect(element) : origin;\r\n if (!from) return null;\r\n const candidates: Array<{ list: ListEntry; rect: Rect }> = [];\r\n for (const other of g.lists.values()) {\r\n const node = other.getElement();\r\n if (other === list || !node?.isConnected || other.isDisabled() || !accepts(g, other, active)) continue;\r\n // Lists inside the dragged element (a column's own cards) can't take it.\r\n if (active.element.isConnected && active.element.contains(node)) continue;\r\n candidates.push({ list: other, rect: getLayoutRect(node) });\r\n }\r\n return pickAdjacent(from, candidates, direction)?.list ?? null;\r\n};\r\n\r\n/**\r\n * Once a keyboard move has rendered: reveals the slot and returns its center. A slot\r\n * that was recreated (in another list, or by a list that remounts its rows) gets the\r\n * focus back, as the old element took it along; an external draggable (no origin in\r\n * the lists) is still where it was and keeps it.\r\n */\r\nexport const slotCenter = (g: GroupContext, current: Session, recreated: boolean): Coordinates | undefined => {\r\n const element = g.items.get(current.slot)?.();\r\n if (!element?.isConnected) return undefined;\r\n revealElement(element);\r\n if (recreated && current.origin.list != null) {\r\n g.manager.getDraggable(current.slot)?.getFocusTarget()?.focus({ preventScroll: true });\r\n }\r\n return getCenter(getLayoutRect(element));\r\n};\r\n\r\n/**\r\n * While no list holds the slot (a plain draggable from outside, a copy over the palette it\r\n * comes from), the arrow takes the drag into the closest list in its direction that takes\r\n * it, level with the drag, as moves between lists do. `undefined` without one.\r\n */\r\nexport const enterNearest = async (\r\n g: GroupContext,\r\n current: Session,\r\n { active, pointer, direction }: KeyboardMoveContext,\r\n): Promise<Coordinates | undefined> => {\r\n const from = createRect(pointer.x, pointer.y, 0, 0);\r\n const target = adjacentList(g, null, active, direction, from);\r\n if (!target || !enters(g, current, target)) return undefined;\r\n const index = insertionIndex(g, target, from, current);\r\n if (target.placeholder() === 'indicator') return indicateAt(g, target, index) ?? pointer;\r\n moveActive(g, target, index, null);\r\n await nextTick();\r\n if (g.session.value !== current) return undefined;\r\n // The dragged element is still where it was, and keeps the focus.\r\n return slotCenter(g, current, false) ?? pointer;\r\n};\r\n\r\n/**\r\n * The arrow takes the drag across into an indicator list, level with `from`. Such\r\n * lists never move: the slot stays (or goes back) home and only the line goes there.\r\n */\r\nconst indicateAcross = async (\r\n g: GroupContext,\r\n current: Session,\r\n target: ListEntry,\r\n from: Rect,\r\n): Promise<Coordinates | undefined> => {\r\n const home = current.list;\r\n keepSlotHome(g, current);\r\n // Measured once the slot is back home.\r\n await nextTick();\r\n if (g.session.value !== current) return undefined;\r\n if (current.list !== home) slotCenter(g, current, true);\r\n return indicateAt(g, target, insertionIndex(g, target, from, current));\r\n};\r\n\r\nconst keyboardIndicator = async (\r\n g: GroupContext,\r\n current: Session,\r\n list: ListEntry,\r\n { active, pointer, direction }: KeyboardMoveContext,\r\n): Promise<Coordinates | undefined> => {\r\n const strategy = list.strategy();\r\n const step = strategy === 'vertical' ? direction.y : direction.x;\r\n const keys = keysOf(list);\r\n const shown = g.indicator.value;\r\n if (isSwapping(g, current, list)) {\r\n // A list that swaps: the mark goes from item to item (by rows in grids); back on the\r\n // dragged item, there is none.\r\n const from = shown?.list === list.id && shown.side === 'swap' ? shown.index : keys.indexOf(current.slot);\r\n const element = from < 0 ? null : g.items.get(keys[from]!)?.();\r\n let next: number | null = null;\r\n if (strategy === 'grid' && direction.y && element?.isConnected) {\r\n const others = collect(g, list).filter((item) => item.index !== from);\r\n next = nextRowIndex(others, getLayoutRect(element), direction.y > 0 ? 1 : -1);\r\n } else if (step && from >= 0) {\r\n next = from + step;\r\n }\r\n if (next !== null && next >= 0 && next < keys.length) return markSwapAt(g, list, keys[next]!);\r\n } else if (step) {\r\n const own = list.id === current.list ? keys.indexOf(current.slot) : -1;\r\n const marker = shown?.list === list.id ? shown : null;\r\n let next = (marker ? marker.index : Math.max(own, 0)) + step;\r\n // Right before or after the active item the drop changes nothing: skip those positions.\r\n while (own >= 0 && (next === own || next === own + 1)) next += step;\r\n if (next >= 0 && next <= keys.length) return indicateAt(g, list, next);\r\n }\r\n // Across, or past the end (lists stacked along the axis): the next list that way.\r\n const other = adjacentList(g, list, active, direction);\r\n if (!other || !enters(g, current, other)) return undefined;\r\n // The line, where the keyboard took the drag, stands for the slot.\r\n const from = createRect(pointer.x, pointer.y, 0, 0);\r\n // Into another list that swaps: the mark goes on its item level with the line.\r\n if (isSwapping(g, current, other)) {\r\n const others = keysOf(other);\r\n const level = others[Math.min(insertionIndex(g, other, from, current), others.length - 1)];\r\n return level === undefined ? undefined : markSwapAt(g, other, level);\r\n }\r\n if (other.placeholder() === 'indicator') return indicateAcross(g, current, other, from);\r\n // A list that moves takes the slot; the line goes away.\r\n setIndicator(g, null);\r\n moveActive(g, other, insertionIndex(g, other, from, current), null);\r\n await nextTick();\r\n return g.session.value === current ? slotCenter(g, current, true) : undefined;\r\n};\r\n\r\n/**\r\n * Past the end of the lists: the arrow takes the drag to the next plain drop target that way\r\n * (a trash zone), which a drop then goes to, and the items go home there as with the\r\n * pointer (`goHome`). `undefined` without one.\r\n */\r\nconst jumpAway = (\r\n g: GroupContext,\r\n current: Session,\r\n active: Active,\r\n from: Coordinates,\r\n direction: Coordinates,\r\n): Coordinates | undefined => {\r\n const found = findDroppable(g.manager, active, from, direction, (id) => g.lists.has(id));\r\n if (!found) return undefined;\r\n current.away = found.id;\r\n goHome(g, current, null);\r\n return found.point;\r\n};\r\n\r\n/**\r\n * Keyboard sorting by items (see above). The item a list made for an external draggable\r\n * moves like any other.\r\n */\r\nexport const getKeyboardCoordinates = async (\r\n g: GroupContext,\r\n context: KeyboardMoveContext,\r\n): Promise<Coordinates | undefined> => {\r\n const { active, pointer, direction } = context;\r\n const { lists, items } = g;\r\n const current = g.session.value;\r\n if (!current || current.activeKey !== active.id) return;\r\n const marker = g.indicator.value;\r\n const list = marker ? lists.get(marker.list) : current.list == null ? undefined : lists.get(current.list);\r\n if (!list) return current.mode.enterByKey?.(g, current, context);\r\n // Trees navigate depth themselves; copies over their palette have no slot to move.\r\n if (list.layout.nested) return;\r\n // Staying put still answers, so the sensor doesn't fall back to pixel steps.\r\n const center = () => {\r\n const element = items.get(current.slot)?.() ?? items.get(current.activeKey)?.();\r\n return element?.isConnected ? getCenter(getLayoutRect(element)) : pointer;\r\n };\r\n // On a plain drop target the arrows took the drag to: on to the next one that way, or back\r\n // to the slot when it is nearer that way.\r\n if (current.away != null) {\r\n const back = current.away;\r\n current.away = null;\r\n if (g.manager.over.value?.id === back) {\r\n const home = center();\r\n const along = (point: Coordinates) => (point.x - pointer.x) * direction.x + (point.y - pointer.y) * direction.y;\r\n const next = jumpAway(g, current, active, pointer, direction);\r\n if (next && !(along(home) > 0 && along(home) < along(next))) return next;\r\n current.away = null;\r\n // Back from it: a `'group'` block forms again around the slot.\r\n if (current.apart) regather(g, current);\r\n return home;\r\n }\r\n }\r\n if (list.placeholder() === 'indicator') {\r\n // Nowhere to go: the overlay stays on the line (at home without one).\r\n const stay = () => (marker ? pointer : center());\r\n return (await keyboardIndicator(g, current, list, context)) ?? jumpAway(g, current, active, pointer, direction) ?? stay();\r\n }\r\n\r\n const strategy = list.strategy();\r\n // A block moves by items as one unit.\r\n const keys = viewOf(list, current);\r\n const position = keys.indexOf(current.slot);\r\n const slot = items.get(current.slot)?.();\r\n if (position === -1 || !slot?.isConnected) return center();\r\n const slotRect = getLayoutRect(slot);\r\n // Resting on a drop target in an item: the arrow that went there goes on past the\r\n // item, the opposite one comes back to the slot, any other moves from the slot.\r\n const stop = current.stop;\r\n current.stop = null;\r\n // Leaving the target: detect again even where the pointer stays (the slot that took\r\n // the item's place has its center where the target's was).\r\n if (stop) g.manager.scheduleFrame();\r\n const onward = !!stop && direction.x === stop.direction.x && direction.y === stop.direction.y;\r\n if (stop && !onward && direction.x === -stop.direction.x && direction.y === -stop.direction.y) return center();\r\n\r\n let target = list;\r\n let index: number | null = null;\r\n let across = false;\r\n if (strategy === 'grid' && direction.y) {\r\n const others = collect(g, list).filter((item) => item.index !== position);\r\n index = nextRowIndex(others, slotRect, direction.y > 0 ? 1 : -1);\r\n across = index === null;\r\n } else {\r\n const step = strategy === 'vertical' ? direction.y : direction.x;\r\n if (step) {\r\n const next = position + step;\r\n if (next >= 0 && next < keys.length) index = next;\r\n // Past its end: the next list that way (lists stacked along the axis).\r\n else across = true;\r\n } else {\r\n across = true;\r\n }\r\n }\r\n if (across) {\r\n const other = adjacentList(g, list, active, direction);\r\n if (other?.placeholder() === 'indicator') {\r\n const line = enters(g, current, other) ? await indicateAcross(g, current, other, slotRect) : undefined;\r\n return line ?? center();\r\n }\r\n if (other) {\r\n target = other;\r\n index = insertionIndex(g, other, slotRect, current);\r\n }\r\n }\r\n if (index !== null) {\r\n if (target === list && !list.canSort()) index = null;\r\n else if (target !== list && target.id === current.origin.list && !target.canSort()) {\r\n returnToOrigin(g, null);\r\n index = null;\r\n }\r\n }\r\n // Past the end of the list, and no list that way: on to a plain drop target (a trash zone).\r\n if (index === null) {\r\n const away = jumpAway(g, current, active, getCenter(slotRect), direction);\r\n if (away) return away;\r\n }\r\n // A list that swaps (as the origin does): the arrow exchanges the item with the one it\r\n // reaches; reaching the partner, back where the item started, undoes the exchange.\r\n if (index !== null && isSwapping(g, current, target)) {\r\n const shown = target === list ? keys : keysOf(target);\r\n const reached = shown[Math.min(index, shown.length - 1)];\r\n if (reached === undefined || reached === current.slot) return center();\r\n const partner = reached === current.swap ? null : reached;\r\n if (partner != null && !canSwap(g, current, target, partner)) return center();\r\n applySwap(g, partner, null);\r\n await nextTick();\r\n if (g.session.value !== current) return;\r\n return slotCenter(g, current, target !== list || isFocusLost()) ?? center();\r\n }\r\n // Passing an item with a drop target that takes the drag stops on the target first:\r\n // the next press drops into the item (or goes on past it, as the pointer does).\r\n const passed = index !== null && target === list && !onward ? keys[index] : undefined;\r\n const into = passed === undefined ? null : intoPoint(g, passed, list, active);\r\n if (into) {\r\n current.stop = { key: passed!, direction };\r\n return into;\r\n }\r\n // An external item takes the item the other list makes for it.\r\n if (index !== null && enters(g, current, target)) moveActive(g, target, index, null);\r\n\r\n await nextTick();\r\n if (g.session.value !== current) return;\r\n // In this list too when it keys its rows by index (Vuetify's v-data-table-virtual\r\n // remounts every row whose index changed).\r\n return slotCenter(g, current, target !== list || isFocusLost()) ?? center();\r\n};\r\n","/**\r\n * Copying (`pull: 'clone'`, the copy modifier): the dragged items stay where they are,\r\n * their copies travel and land. The modifier switches a drag between moving and copying\r\n * at any time (`syncCopy`).\r\n */\r\n\r\nimport type { Key } from '../../types';\r\nimport { keysOf, listOf, lookup, type GroupContext, type Session } from '../context';\r\nimport type { ListEntry } from '../entry';\r\nimport type { DraftContext } from '../layout';\r\nimport { partitionMoved } from '../accept';\r\nimport { blockFor, withoutBlock } from '../block';\r\nimport { syncManager } from '../landing';\r\nimport { bump } from '../flip';\r\nimport { enterNearest } from '../keyboard';\r\nimport type { SortableMode } from './mode';\r\nimport { sort, sortOver } from './sort';\r\n\r\n/** The copy of dragged `key`, made once per session so its key stays stable; `null` when `clone` refused. */\r\nconst copyOf = (g: GroupContext, current: Session, key: Key): Key | null => {\r\n if (!current.copies.has(key)) {\r\n const made = listOf(g, current.sources.get(key)?.list ?? null)?.clone?.(lookup(g, key));\r\n current.copies.set(key, made ? made.key : null);\r\n if (made) current.items.set(made.key, made.item);\r\n }\r\n return current.copies.get(key) ?? null;\r\n};\r\n\r\nconst wantsCopy = (g: GroupContext, current: Session) => {\r\n const origin = listOf(g, current.origin.list);\r\n if (!origin?.clone) return false;\r\n return origin.pull() === 'clone' || g.copyHeld();\r\n};\r\n\r\n/** What `prepareDraft` is told about `current`. */\r\nexport const draftContext = (current: Session): DraftContext => ({\r\n lead: current.lead,\r\n keys: current.keys,\r\n copying: current.mode === copy,\r\n});\r\n\r\n/** Drafts while copying: every source as it is (nothing leaves). */\r\nconst copyBase = (list: ListEntry, current: Session) => {\r\n const draft = [...list.getKeys()];\r\n return list.layout.prepareDraft(draft, draftContext(current));\r\n};\r\n\r\n/** The drag starts copying when its list copies or the modifier is held; `false` when it moves. */\r\nexport const startCopy = (g: GroupContext, current: Session): boolean => {\r\n const slot = wantsCopy(g, current) ? copyOf(g, current, current.lead) : null;\r\n if (slot == null) return false;\r\n // Copying: the source stays as it is; the copy appears once a list is hovered.\r\n current.mode = copy;\r\n current.slot = slot;\r\n current.list = null;\r\n current.block = blockFor(g, current, undefined);\r\n for (const list of g.lists.values()) list.draft.value = copyBase(list, current);\r\n return true;\r\n};\r\n\r\n/**\r\n * Switches between moving and copying mid-drag (copy modifier pressed or released).\r\n * The new slot (and block) takes the old one's place: after the nearest key that stays put.\r\n */\r\nconst switchCopy = (g: GroupContext, copying: boolean) => {\r\n const current = g.session.value!;\r\n const slot = copying ? copyOf(g, current, current.lead) : current.lead;\r\n if (slot == null) return;\r\n const from = listOf(g, current.list);\r\n // Keys before the block that stay put, nearest first.\r\n let anchor: { list: ListEntry; after: Key[] } | null = null;\r\n if (from) {\r\n const keys = keysOf(from);\r\n const after = keys\r\n .slice(0, Math.max(keys.indexOf(current.block[0]!), 0))\r\n .reverse()\r\n .filter((key) => key !== current.lead && !current.others.has(key));\r\n anchor = { list: from, after };\r\n }\r\n current.mode = copying ? copy : sort;\r\n current.slot = slot;\r\n current.swap = null;\r\n current.hysteresis = null;\r\n // Built afresh from the slot's list: a block taken apart (`apart`) forms again.\r\n current.apart = false;\r\n current.block = blockFor(g, current, anchor?.list ?? (copying ? undefined : listOf(g, current.origin.list)));\r\n const moving = new Set(current.block);\r\n for (const list of g.lists.values()) {\r\n let draft: Key[];\r\n if (copying) draft = copyBase(list, current);\r\n else if (!anchor) draft = current.base.get(list.id) ?? [...list.getKeys()];\r\n else {\r\n // A block's keys leave their sources; the ones the list doesn't take stay there.\r\n draft = withoutBlock(current, list, moving);\r\n // Moving again: a tree hides the subtrees that travel.\r\n draft = list.layout.prepareDraft(draft, draftContext(current));\r\n }\r\n list.draft.value = draft;\r\n }\r\n if (anchor) {\r\n const keys = [...keysOf(anchor.list)];\r\n // The nearest of them still shown (a tree hides the rows inside the moving nodes).\r\n const present = new Set(keys);\r\n const after = anchor.after.find((key) => present.has(key));\r\n const at = after === undefined ? 0 : keys.indexOf(after) + 1;\r\n keys.splice(at, 0, ...current.block);\r\n anchor.list.draft.value = keys;\r\n current.list = anchor.list.id;\r\n } else {\r\n current.list = copying ? null : current.origin.list;\r\n }\r\n syncManager(g);\r\n bump(g);\r\n};\r\n\r\n/** Follows the copy modifier (and `pull: 'clone'`): a drag of the items of a list that can copy them. */\r\nexport const syncCopy = (g: GroupContext, current: Session) => {\r\n const wanted = wantsCopy(g, current);\r\n if (wanted !== (current.mode === copy)) switchCopy(g, wanted);\r\n};\r\n\r\nexport const copy: SortableMode = {\r\n name: 'copy',\r\n moves: false,\r\n dragMode: () => 'copy',\r\n partition: partitionMoved,\r\n over: sortOver,\r\n inserted: (g, current, keys) => keys.map((key) => copyOf(g, current, key)).filter((key): key is Key => key != null),\r\n placed: (current, key) => current.copies.get(key) ?? key,\r\n original: (current, key) => {\r\n for (const [original, made] of current.copies) if (made === key) return original;\r\n return key;\r\n },\r\n // Over its palette the copy has no slot: the arrow takes it into a list, or it stays.\r\n enterByKey: async (g, current, context) => (await enterNearest(g, current, context)) ?? context.pointer,\r\n};\r\n\r\n","/**\r\n * Inserting (`createItem`): a plain draggable from outside the group, or a drag from\r\n * outside the page (`external`). Each list it enters makes its items, the first of which\r\n * takes the slot there; the drop inserts them all. Outside the lists the drag is what it\r\n * is. Items of the group dragged in from another window of the app come in as themselves.\r\n */\r\n\r\nimport type { Active, Key, SortablePutContext } from '../../types';\r\nimport { lookup, type GroupContext, type Session, type SessionStart } from '../context';\r\nimport type { CreatedItem, ListEntry } from '../entry';\r\nimport { takesExternal } from '../../core/native/data';\r\nimport { removeSlot } from '../slot';\r\nimport { enterNearest } from '../keyboard';\r\nimport type { SortableMode } from './mode';\r\nimport { sortOver } from './sort';\r\n\r\n/**\r\n * Whether `list` may take the drag `active` in as items of its own: with `createItem`, a\r\n * drag from outside the page only if its `external` takes it; another window's items of\r\n * its group always. Asks no `createItem`.\r\n */\r\nexport const mayMake = (g: GroupContext, list: ListEntry, active: Active): boolean => {\r\n const { external } = active;\r\n if (external?.group) return external.group === g.name && !!(list.create || list.keyOf);\r\n if (external) return !!list.create && takesExternal(list.external?.(), external);\r\n return !!list.create;\r\n};\r\n\r\n/** The items `list` makes for `active` (see `mayMake`); none when it makes none. */\r\nexport const makeFor = (g: GroupContext, list: ListEntry, active: Active): CreatedItem[] => {\r\n if (!mayMake(g, list, active)) return [];\r\n if (list.create) return list.create(active) ?? [];\r\n // Another window's items, as they are.\r\n return active.items.map(({ item }) => ({ key: list.keyOf!(item), item }));\r\n};\r\n\r\n/** The item `list` makes for the drag, once per session; `null` when it makes none. */\r\nconst createdIn = (g: GroupContext, list: ListEntry, current: Session): Key | null => {\r\n if (!current.created.has(list.id)) {\r\n const active = g.manager.active.value;\r\n const made = active ? makeFor(g, list, active) : [];\r\n current.created.set(list.id, made[0]?.key ?? null);\r\n for (const { key, item } of made) current.items.set(key, item);\r\n current.extra.set(list.id, made.slice(1).map(({ key }) => key));\r\n }\r\n return current.created.get(list.id) ?? null;\r\n};\r\n\r\n/**\r\n * A drag from outside the page brings its data with the drop: `list`, where it goes, makes\r\n * its items again from it (`createItem` is asked with `external.ready`), and those go in.\r\n */\r\nexport const remake = (g: GroupContext, list: ListEntry, current: Session, active: Active) => {\r\n const made = makeFor(g, list, active);\r\n if (!made.length) return;\r\n const [first, ...rest] = made;\r\n for (const { key, item } of made) current.items.set(key, item);\r\n const slot = current.slot;\r\n if (first!.key !== slot) {\r\n if (list.draft.value?.includes(slot)) list.draft.value = list.draft.value.map((key) => (key === slot ? first!.key : key));\r\n current.created.set(list.id, first!.key);\r\n current.slot = first!.key;\r\n }\r\n current.extra.set(list.id, rest.map(({ key }) => key));\r\n};\r\n\r\n/** The session of a plain draggable: no list holds its slot until one makes an item for it. */\r\nexport const startInsert = (g: GroupContext, common: SessionStart): Session => {\r\n const { activeKey } = common;\r\n const base = new Map<Key, Key[]>();\r\n for (const list of g.lists.values()) {\r\n const draft = [...list.getKeys()];\r\n list.draft.value = list.layout.prepareDraft(draft, { lead: activeKey, keys: [activeKey], copying: false });\r\n base.set(list.id, list.draft.value);\r\n }\r\n return {\r\n ...common,\r\n lead: activeKey,\r\n keys: [activeKey],\r\n origin: { list: null, index: -1 },\r\n slot: activeKey,\r\n list: null,\r\n others: new Set(),\r\n stacked: false,\r\n grouped: false,\r\n block: [activeKey],\r\n base,\r\n mode: insert,\r\n };\r\n};\r\n\r\nexport const insert: SortableMode = {\r\n name: 'insert',\r\n moves: false,\r\n // In a list that shows a line instead of moving, the item made is in no draft: the line says it goes in.\r\n dragMode: (g, current) => (current.list != null || g.indicator.value != null ? 'insert' : 'move'),\r\n // The list must make an item, and take it.\r\n partition: (g, list, current) => {\r\n const all = { accepted: current.keys, rejected: [] as Key[] };\r\n const none = { accepted: [] as Key[], rejected: current.keys };\r\n const created = createdIn(g, list, current);\r\n if (created == null) return none;\r\n const made = [created, ...(current.extra.get(list.id) ?? [])];\r\n const context: SortablePutContext = {\r\n keys: current.keys,\r\n items: made.map((key) => lookup(g, key)),\r\n types: g.manager.active.value?.type ?? [],\r\n from: null,\r\n to: list.id,\r\n };\r\n return list.canPut(context) ? all : none;\r\n },\r\n inert: (list, g) => {\r\n const active = g.manager.active.value;\r\n return !active || !mayMake(g, list, active);\r\n },\r\n // The slot becomes the item `target` makes for the drag.\r\n enter: (g, current, target) => {\r\n const created = createdIn(g, target, current);\r\n if (created == null) return false;\r\n if (current.slot !== created) {\r\n if (current.list != null) removeSlot(g);\r\n current.slot = created;\r\n }\r\n return true;\r\n },\r\n over: sortOver,\r\n leave: (g, current) => {\r\n if (current.list != null) removeSlot(g);\r\n },\r\n // The slot, then the other items the list made: all of them go in.\r\n inserted: (g, current, keys) => {\r\n if (!keys.length) return [];\r\n const list = current.list ?? current.marker?.list ?? g.indicator.value?.list ?? null;\r\n return [current.slot, ...((list != null && current.extra.get(list)) || [])];\r\n },\r\n placed: (current) => current.slot,\r\n /**\r\n * Outside the lists, the arrow takes the drag into the closest list in its direction.\r\n * Without one that way it moves as the plain draggable it is (pixels, droppables).\r\n */\r\n enterByKey: enterNearest,\r\n};\r\n","/**\r\n * The session core: a drag starts a session (`start`), and every move of the pointer\r\n * runs it over the list under the pointer (`move`), through the steps of its mode\r\n * (`modes/`). The drop ends it (`drop.ts`); keyboard drags move it by items\r\n * (`keyboard.ts`).\r\n *\r\n * The active slot is a key in the drafts. Usually it is the active item itself; when\r\n * copying it is the item's copy, and for a plain draggable from outside it is the\r\n * item `createItem` made. Projection, commit and FLIP only ever deal with that key.\r\n */\r\n\r\nimport { nextTick } from 'vue';\r\nimport type { DnDEvent, Key } from '../types';\r\nimport { listOf, listOfKey, orderedLists, type GroupContext, type Session, type SessionStart } from './context';\r\nimport { gather, pickUp } from './block';\r\nimport { setIndicator, updateIndicator } from './indicator';\r\nimport { syncManager } from './landing';\r\nimport { goHome, regather } from './slot';\r\nimport { pickedUpAt } from './announcements';\r\nimport { bump } from './flip';\r\nimport { HYSTERESIS, blocksList, distance, settleHysteresis } from './stability';\r\nimport { enters } from './modes/mode';\r\nimport { sort } from './modes/sort';\r\nimport { modeOf } from './modes/swap';\r\nimport { startCopy, syncCopy } from './modes/copy';\r\nimport { mayMake, startInsert } from './modes/insert';\r\n\r\nexport const start = (g: GroupContext, event: DnDEvent) => {\r\n const { lists, session } = g;\r\n const activeKey = event.active.id;\r\n // A drag from outside the page (another window's items too) is never one of its own,\r\n // whatever its keys.\r\n const local = !event.active.external && !!listOfKey(g, activeKey, false);\r\n // Drags that don't involve this group leave it untouched (no snapshot of its lists).\r\n if (!local && ![...lists.values()].some((list) => mayMake(g, list, event.active))) return;\r\n const ordered = orderedLists(g);\r\n const snapshot = new Map<Key, unknown>();\r\n const sources = new Map<Key, { list: Key; index: number }>();\r\n for (const list of ordered) {\r\n list.getKeys().forEach((key, index) => {\r\n snapshot.set(key, list.getItem(key));\r\n sources.set(key, { list: list.id, index });\r\n });\r\n }\r\n const common: SessionStart = {\r\n activeKey,\r\n lock: null,\r\n items: snapshot,\r\n size: { width: event.active.rect.width, height: event.active.rect.height },\r\n result: null,\r\n sources,\r\n copies: new Map<Key, Key | null>(),\r\n created: new Map<Key, Key | null>(),\r\n extra: new Map<Key, Key[]>(),\r\n swap: null,\r\n indicator: null,\r\n marker: null,\r\n hysteresis: null,\r\n target: null,\r\n removed: false,\r\n prevented: false,\r\n stop: null,\r\n away: null,\r\n apart: false,\r\n };\r\n\r\n if (!local) {\r\n // A plain draggable: only lists with `createItem` take part. An item of another group\r\n // (a sortable item, with its item behind it) is none: the group stays out of its drag.\r\n if (!ordered.some((list) => mayMake(g, list, event.active)) || g.manager.getDraggable(activeKey)?.getItem) return;\r\n g.spokenSpot = null;\r\n g.columnList = null;\r\n session.value = startInsert(g, common);\r\n } else {\r\n const { origin, ...picked } = pickUp(g, event, ordered, sources, snapshot);\r\n const current: Session = {\r\n ...common,\r\n ...picked,\r\n origin: { list: origin.list, index: origin.index },\r\n slot: picked.lead,\r\n list: origin.list,\r\n mode: sort,\r\n };\r\n session.value = current;\r\n g.columnList = null;\r\n pickedUpAt(g, current);\r\n if (!startCopy(g, current)) {\r\n gather(g, current, event);\r\n for (const list of lists.values()) list.draft.value = picked.base.get(list.id)!;\r\n }\r\n }\r\n syncManager(g);\r\n bump(g);\r\n};\r\n\r\n/** The pointer is over no list of this group (or one that refuses the drag). */\r\nconst leave = (g: GroupContext, current: Session) => {\r\n setIndicator(g, null);\r\n modeOf(current).leave?.(g, current);\r\n};\r\n\r\n/**\r\n * Over a target that refuses the drag, the drop is cancelled and the items fly back; over a\r\n * zone of its own (a trash can, a playlist), the drop is the zone's, and the lists keep them\r\n * unless its `onDrop` takes them out: either way they go home (`goHome`).\r\n */\r\nconst sendHome = (g: GroupContext, current: Session, event: DnDEvent) => {\r\n leave(g, current);\r\n goHome(g, current, event.pointer);\r\n};\r\n\r\n/**\r\n * A drop target that is no list of the group and stands apart from them: not inside one\r\n * (a target in an item, \"drop into an item\"), not around one (a panel holding the lists,\r\n * between them).\r\n */\r\nexport const standsApart = (g: GroupContext, element: Element) =>\r\n ![...g.lists.values()].some((list) => {\r\n const container = list.getElement();\r\n return !!container && (container.contains(element) || element.contains(container));\r\n });\r\n\r\n/** Extension hook: runs on every move over a valid target, guarded or not (trees update depth here). */\r\nconst afterMove = (g: GroupContext, current: Session, event: DnDEvent) => {\r\n listOf(g, current.list)?.layout.afterMove(event);\r\n};\r\n\r\n/**\r\n * A block that moved can leave the pointer over one of its members (items of other\r\n * sizes passed, the end of a list): project again once it has rendered, as the pointer\r\n * may not move again (WebKit delivers a whole glide within a frame or two, and a\r\n * release right after it runs the last frame inside the drop). Each pass steps toward\r\n * the pointer, so it ends within a pass per member.\r\n */\r\nconst followBlock = (g: GroupContext, current: Session, event: DnDEvent) => {\r\n if (current.block.length < 2 || g.followed++ > current.block.length) return;\r\n const pass: Promise<void> = nextTick(() => {\r\n if (g.following === pass) g.following = null;\r\n if (g.session.value === current && g.manager.status.value !== 'idle' && g.manager.pointer.value === event.pointer) {\r\n move(g, event);\r\n }\r\n });\r\n g.following = pass;\r\n};\r\n\r\n/** Resolves once no `followBlock` pass is pending. */\r\nexport const settleBlock = async (g: GroupContext) => {\r\n while (g.following) await g.following;\r\n};\r\n\r\nexport const move = (g: GroupContext, event: DnDEvent) => {\r\n const { lists } = g;\r\n const current = g.session.value;\r\n if (!current || current.activeKey !== event.active.id) return;\r\n if (event.pointer !== g.movedAt) {\r\n g.movedAt = event.pointer;\r\n g.followed = 0;\r\n }\r\n // Keyboard drags move the slot in getKeyboardCoordinates. Trees (`nested`) answer\r\n // the keyboard themselves and keep the pointer path below (in indicator mode they\r\n // move the line themselves), and so does an external item (no origin) outside the\r\n // lists: its own keyboard moves (pixels, droppables) may take it in.\r\n if (event.active.sensor === 'keyboard' && (current.origin.list != null || current.list != null || g.indicator.value)) {\r\n const list = current.list == null ? undefined : lists.get(current.list);\r\n if (!list?.layout.nested || list.placeholder() === 'indicator' || g.indicator.value) return afterMove(g, current, event);\r\n }\r\n syncCopy(g, current);\r\n // No frame is ever skipped: the target follows pointer movement only, so a skipped\r\n // frame that carried the final position would leave the slot stale until the\r\n // pointer moves again (WebKit delivers a whole glide within a frame or two). The\r\n // frame after a cross-list move is safe without a guard: the FLIP pass invalidates\r\n // measurements post-flush, and the manager's target stabilizer plus the list\r\n // hysteresis below keep a layout shift from bouncing the item back.\r\n current.hysteresis = settleHysteresis(current.hysteresis, event.pointer);\r\n\r\n const over = event.over;\r\n if (!over) {\r\n // Last valid target: a pointer a few pixels past a list boundary keeps it.\r\n if (current.target && distance(event.pointer, current.target.at) < HYSTERESIS) return afterMove(g, current, event);\r\n current.target = null;\r\n return leave(g, current);\r\n }\r\n if (!over.accepted) {\r\n current.target = null;\r\n return sendHome(g, current, event);\r\n }\r\n const target = lists.get(over.id);\r\n if (!target || target.isDisabled()) {\r\n current.target = null;\r\n return !target && standsApart(g, over.element) ? sendHome(g, current, event) : leave(g, current);\r\n }\r\n // Back from a zone of its own: the block forms again first; the next pass projects it.\r\n if (current.apart) {\r\n regather(g, current);\r\n return followBlock(g, current, event);\r\n }\r\n // The list the slot just left can't take it back until the pointer moves on.\r\n const blocked = target.id !== current.list && blocksList(current.hysteresis, target.id);\r\n // Trees keep projecting while blocked: depth changes without a reorder.\r\n if (blocked && !target.layout.nested) return afterMove(g, current, event);\r\n if (!blocked) current.target = { list: target.id, at: event.pointer };\r\n\r\n // Each list makes its own item for an external draggable.\r\n if (!blocked && !enters(g, current, target)) return leave(g, current);\r\n\r\n if (target.placeholder() === 'indicator') {\r\n updateIndicator(g, target, event);\r\n return afterMove(g, current, event);\r\n }\r\n setIndicator(g, null);\r\n if (current.mode.over(g, current, target, event, blocked)) followBlock(g, current, event);\r\n afterMove(g, current, event);\r\n};\r\n","/**\r\n * The drop of a sortable session. It is computed once, as the new items of every list it\r\n * changes (`result`), and goes through `onBeforeDrop`, then `onDrop`, then the write\r\n * (the default action, which `preventDefault()` skips: the user applies `result`), then\r\n * the reset of the drafts. The FLIP pass of that reset animates whatever the sources hold\r\n * by then.\r\n */\r\n\r\nimport type { BeforeDropResult, DnDEndEvent, DnDEvent, Key, MaybePromise, SortableDropEvent, SortableIndicator } from '../types';\r\nimport { isForeign, keysOf, listOf, lookup, sameKeys, type GroupContext, type Session } from './context';\r\nimport type { ListEntry } from './entry';\r\nimport { partition } from './accept';\r\nimport { putBack, scatter } from './block';\r\nimport { setIndicator } from './indicator';\r\nimport { landCancel, landDrop } from './landing';\r\nimport { bump } from './flip';\r\nimport { nearLastTarget } from './stability';\r\nimport { cancelAnnouncement, endAnnouncement } from './announcements';\r\nimport { settleBlock } from './session';\r\nimport { modeOf } from './modes/swap';\r\nimport { insert, remake } from './modes/insert';\r\nimport { isFinal, toVerdict } from '../core/verdict';\r\n\r\nexport interface DropResult {\r\n next: Map<ListEntry, Key[]>;\r\n /** The new items of each list in `next` (`build`): the event's `result`, what the write puts. */\r\n built: Map<ListEntry, unknown[]>;\r\n /** Keys put at the slot of the target list (`event.to.list`). */\r\n inserted: Key[];\r\n event: SortableDropEvent;\r\n}\r\n\r\n/** A drop event before its list results are built. */\r\nexport type DropFacts = Omit<SortableDropEvent, 'result' | 'preventDefault' | 'defaultPrevented'>;\r\n\r\n/** Bundlers replace it: development builds keep the warnings, production drops them. */\r\ndeclare const process: { env: { NODE_ENV?: string } };\r\n\r\nconst isPromise = <T>(value: MaybePromise<T>): value is Promise<T> =>\r\n !!value && typeof (value as Promise<T>).then === 'function';\r\n\r\n/** `keys` with `slot` moved (or inserted) to `index`, counted in `keys` as given. */\r\nconst placeAt = (keys: Key[], slot: Key, index: number): Key[] => {\r\n const position = keys.indexOf(slot);\r\n const result = position === -1 ? [...keys] : keys.filter((key) => key !== slot);\r\n const at = position !== -1 && position < index ? index - 1 : index;\r\n result.splice(Math.max(0, Math.min(at, result.length)), 0, slot);\r\n return result;\r\n};\r\n\r\n/**\r\n * Builds the new items of every list in `next` (what the write would put there) and\r\n * the drop event around them: its `result`, and `preventDefault()` for the session.\r\n */\r\nconst dropResult = (\r\n g: GroupContext,\r\n current: Session,\r\n next: Map<ListEntry, Key[]>,\r\n inserted: Key[],\r\n facts: DropFacts,\r\n): DropResult => {\r\n const find = (key: Key) => lookup(g, key);\r\n const built = new Map<ListEntry, unknown[]>();\r\n for (const [list, keys] of next) built.set(list, list.build(keys, find, list.id === facts.to.list ? inserted : []));\r\n const external = g.manager.active.value?.external;\r\n const event: SortableDropEvent = {\r\n ...facts,\r\n ...(external && { external }),\r\n result: new Map([...built].map(([list, items]) => [list.id, items])),\r\n preventDefault: () => {\r\n current.prevented = true;\r\n },\r\n get defaultPrevented() {\r\n return current.prevented;\r\n },\r\n };\r\n return { next, built, inserted, event };\r\n};\r\n\r\n/**\r\n * The new order of every list that changes. `accepted` limits the moved keys\r\n * (partial accept); `marker` is the indicator to insert at (`placeholder: 'indicator'`).\r\n */\r\nconst computeResult = (\r\n g: GroupContext,\r\n accepted: ReadonlySet<Key> | null,\r\n marker: SortableIndicator | null,\r\n): DropResult | null => {\r\n const { lists } = g;\r\n const current = g.session.value!;\r\n const slot = current.slot;\r\n const drafts = new Map<ListEntry, Key[]>();\r\n for (const list of lists.values()) drafts.set(list, keysOf(list));\r\n let target = listOf(g, current.list);\r\n if (marker?.side === 'swap') {\r\n // An indicator list that swaps: the drop exchanges the item with the marked one.\r\n const own = listOf(g, current.origin.list);\r\n const list = lists.get(marker.list);\r\n if (own && list && marker.key != null) {\r\n const a = [...drafts.get(own)!];\r\n const b = list === own ? a : [...drafts.get(list)!];\r\n const i = a.indexOf(current.activeKey);\r\n const j = b.indexOf(marker.key);\r\n a[i] = marker.key;\r\n b[j] = current.activeKey;\r\n drafts.set(own, a);\r\n drafts.set(list, b);\r\n current.swap = marker.key;\r\n target = list;\r\n }\r\n } else if (marker) {\r\n const list = lists.get(marker.list);\r\n if (list) {\r\n if (target && target !== list) drafts.set(target, drafts.get(target)!.filter((key) => key !== slot));\r\n drafts.set(list, placeAt(drafts.get(list)!, slot, marker.index));\r\n target = list;\r\n }\r\n }\r\n if (!target) return null;\r\n\r\n const allowed = accepted ?? new Set(partition(g, target, current).accepted);\r\n const moved = current.keys.filter((key) => allowed.has(key));\r\n const rejected = current.keys.filter((key) => !allowed.has(key));\r\n const mode = modeOf(current);\r\n const moving = mode.moves;\r\n const insert = mode.inserted(g, current, moved);\r\n // Everything but the slot leaves its place: the rest of a block, and when moving every\r\n // dragged key (in 'gaps' mode and indicator lists they are still where they started).\r\n // The slot then makes room for what is inserted; rejected keys go back below.\r\n const strip = new Set(current.block);\r\n if (moving) for (const key of current.keys) strip.add(key);\r\n strip.delete(slot);\r\n const back = moving\r\n ? rejected\r\n .map((key) => ({ key, source: current.sources.get(key)! }))\r\n .sort((a, b) => a.source.index - b.source.index)\r\n : [];\r\n const settled = new Set(moved);\r\n\r\n const next = new Map<ListEntry, Key[]>();\r\n for (const [list, draft] of drafts) {\r\n let keys = draft.filter((key) => !strip.has(key));\r\n keys = list === target ? keys.flatMap((key) => (key === slot ? insert : [key])) : keys.filter((key) => key !== slot);\r\n // Rejected keys fly back to where they started: after their nearest original\r\n // predecessor that is still in the list and stays (other keys may have left it).\r\n for (const { key, source } of back) if (source.list === list.id) putBack(keys, list, key, source.index, settled);\r\n if (list.layout.hasChanges(keys, list === target ? insert : [], list.getKeys())) next.set(list, keys);\r\n }\r\n if (!next.size) return null;\r\n const finalKeys = next.get(target) ?? target.getKeys();\r\n return dropResult(g, current, next, insert, {\r\n keys: current.keys,\r\n items: current.keys.map((key) => lookup(g, mode.placed(current, key))),\r\n accepted: moved,\r\n rejected,\r\n from: { ...current.origin },\r\n to: { list: target.id, index: insert.length ? finalKeys.indexOf(insert[0]!) : -1 },\r\n sameList: current.origin.list === target.id,\r\n mode: mode.name,\r\n ...mode.facts?.(g, current),\r\n });\r\n};\r\n\r\n/**\r\n * Trash zones, `e.source.remove()` and `dropOutside: 'remove'`: the dragged items (those\r\n * accepted) leave the lists they started in, and only those: a target's `onDrop` may\r\n * have put them in another list of the group already (a node dropped into a node of\r\n * nested lists). The event goes to the list the drag started in.\r\n */\r\nconst computeRemoval = (g: GroupContext, accepted: readonly Key[]): DropResult | null => {\r\n const current = g.session.value!;\r\n if (!current.mode.moves || current.origin.list == null) return null;\r\n const gone = new Set(accepted);\r\n const from = new Set(accepted.map((key) => current.sources.get(key)?.list));\r\n const next = new Map<ListEntry, Key[]>();\r\n for (const list of g.lists.values()) {\r\n if (!from.has(list.id)) continue;\r\n const source = list.getKeys();\r\n const keys = source.filter((key) => !gone.has(key));\r\n if (list.layout.hasChanges(keys, [], source)) next.set(list, keys);\r\n }\r\n if (!next.size) return null;\r\n return dropResult(g, current, next, [], {\r\n keys: current.keys,\r\n items: current.keys.map((key) => lookup(g, key)),\r\n accepted: current.keys.filter((key) => gone.has(key)),\r\n rejected: current.keys.filter((key) => !gone.has(key)),\r\n from: { ...current.origin },\r\n to: { list: current.origin.list, index: -1 },\r\n sameList: true,\r\n mode: 'move',\r\n });\r\n};\r\n\r\n/**\r\n * The default action of a drop: every list it changes takes its new items. All or\r\n * none: a read-only source among them (one the user didn't take the drop for, with\r\n * `preventDefault()`) blocks the others too, or items would be lost or duplicated.\r\n */\r\nconst write = (g: GroupContext, result: DropResult) => {\r\n const blocked = [...result.next.keys()].filter((list) => list.isReadonly());\r\n if (blocked.length) {\r\n if (process.env.NODE_ENV !== 'production') {\r\n console.warn(\r\n `[vue-dnd-kit] A drop wasn't written: \\`items\\` is read-only (a getter, a readonly ref or a computed) in ${blocked.map((list) => `\"${String(list.id)}\"`).join(', ')}. Call \\`event.preventDefault()\\` in onBeforeDrop or onDrop and apply \\`event.result\\` yourself.`,\r\n );\r\n }\r\n return;\r\n }\r\n const find = (key: Key) => lookup(g, key);\r\n for (const [list, keys] of result.next) {\r\n list.commit(result.built.get(list)!, keys, find, list.id === result.event.to.list ? result.inserted : []);\r\n }\r\n};\r\n\r\n/** The session ends (drop, cancel, reject): the lists show their sources again. */\r\nconst reset = (g: GroupContext) => {\r\n const current = g.session.value;\r\n if (!current) return;\r\n scatter(g, current);\r\n for (const list of g.lists.values()) {\r\n list.draft.value = null;\r\n list.layout.reset();\r\n }\r\n g.session.value = null;\r\n setIndicator(g, null);\r\n bump(g);\r\n};\r\n\r\nconst isOutside = (current: Session, event: DnDEvent) => !event.over && !nearLastTarget(current.target, event.pointer);\r\n\r\n/** The verdict of `onBeforeDrop`, the keys a partial accept took unless it named its own. */\r\nconst withPartial = (value: BeforeDropResult, partial: Key[] | undefined): BeforeDropResult => {\r\n const verdict = toVerdict(value);\r\n return isFinal(verdict) || Array.isArray(verdict) ? verdict : (partial ?? verdict);\r\n};\r\n\r\n/**\r\n * `onBeforeDrop` answered `'continue'`: the drop it was asked about won't happen. What it\r\n * prepared goes, and the session moves on; the next drop decides afresh.\r\n */\r\nexport const resume = (g: GroupContext) => {\r\n const current = g.session.value;\r\n if (!current) return;\r\n // An exchange that only the drop made (an indicator list) is undone with it.\r\n if (current.marker?.side === 'swap') current.swap = null;\r\n current.result = null;\r\n current.marker = null;\r\n current.removed = false;\r\n};\r\n\r\nconst decide = (g: GroupContext, current: Session, event: DnDEvent): MaybePromise<BeforeDropResult> => {\r\n if (g.session.value !== current) return;\r\n // A refusing list cancels the drop in the manager; don't ask the user about it.\r\n if (event.over && !event.over.accepted) return;\r\n // A drag out of the page (`native`) dropped somewhere else: a move takes the items out of\r\n // their lists (the place that took them has them now), a copy or a link leaves them.\r\n const elsewhere = g.manager.getDroppedOutside();\r\n if (elsewhere && elsewhere !== 'move') return;\r\n const outside = !elsewhere && isOutside(current, event);\r\n const rule = elsewhere ? 'remove' : outside ? listOf(g, current.list ?? current.origin.list)?.dropOutside() : undefined;\r\n if (rule === 'cancel') return false;\r\n let result: DropResult | null;\r\n if (rule === 'remove') {\r\n // The list the items leave is asked, as for any drop of its own.\r\n current.removed = true;\r\n result = computeRemoval(g, current.keys);\r\n } else {\r\n current.marker = g.indicator.value ?? (outside ? current.indicator : null);\r\n // A drag from outside the page brings its data now: the list it goes into makes its\r\n // items again from it.\r\n if (event.active.external?.ready && current.mode === insert) {\r\n const list = listOf(g, current.list) ?? (current.marker ? g.lists.get(current.marker.list) : undefined);\r\n if (list) remake(g, list, current, event.active);\r\n }\r\n result = computeResult(g, null, current.marker);\r\n }\r\n current.result = result;\r\n if (!result) return;\r\n const partial = result.event.rejected.length ? result.event.accepted : undefined;\r\n const verdict = g.lists.get(result.event.to.list)?.beforeDrop?.(result.event);\r\n return isPromise(verdict) ? verdict.then((value) => withPartial(value, partial)) : withPartial(verdict, partial);\r\n};\r\n\r\nexport const beforeDrop = (g: GroupContext, event: DnDEvent): MaybePromise<BeforeDropResult> => {\r\n const current = g.session.value;\r\n if (!current || current.activeKey !== event.active.id || isForeign(g, event)) return;\r\n // The last move may still be lining the block up with the overlay.\r\n return g.following ? settleBlock(g).then(() => decide(g, current, event)) : decide(g, current, event);\r\n};\r\n\r\nexport const end = (g: GroupContext, event: DnDEndEvent) => {\r\n const current = g.session.value;\r\n if (!current || current.activeKey !== event.active.id) return;\r\n let result: DropResult | null = null;\r\n // The result `onBeforeDrop` saw holds unless it accepted fewer keys.\r\n const kept = new Set(event.accepted);\r\n const prepared = current.result;\r\n const unchanged = !!prepared && sameKeys(prepared.event.accepted, current.keys.filter((key) => kept.has(key)));\r\n if (current.removed) {\r\n result = unchanged ? prepared : computeRemoval(g, event.accepted);\r\n } else if (!isForeign(g, event) && !g.manager.getDroppedOutside()) {\r\n result = unchanged ? prepared : computeResult(g, kept, current.marker);\r\n }\r\n if (result) {\r\n // `onDrop` comes first: the sources still hold the old order, `result` the new one.\r\n try {\r\n g.lists.get(result.event.to.list)?.afterDrop?.(result.event);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n if (!current.prevented) write(g, result);\r\n }\r\n // The drop as it was made, for the devtools: they read it as the session ends.\r\n current.result = result;\r\n landDrop(g, current, result);\r\n g.announced = { key: current.activeKey, ...endAnnouncement(g, current, event, result) };\r\n reset(g);\r\n};\r\n\r\nexport const cancel = (g: GroupContext, event: DnDEvent) => {\r\n const current = g.session.value;\r\n if (current && current.activeKey === event.active.id) {\r\n landCancel(g, current);\r\n if (current.origin.list != null) g.announced = { key: current.activeKey, ...cancelAnnouncement(g, current) };\r\n }\r\n reset(g);\r\n};\r\n","/**\r\n * Programmatic moves (`SensorDrag.place`, `moveItem` of `@vue-dnd-kit/actions`): the slot\r\n * goes straight to a position of a list, the way keyboard moves take it there\r\n * (`keyboard.ts`). Another list takes it only if it accepts the drag; an indicator list\r\n * shows its line there instead; trees aren't placed (their positions have a depth).\r\n */\r\n\r\nimport { nextTick } from 'vue';\r\nimport type { Active, Coordinates, SortablePosition } from '../types';\r\nimport { getCenter } from '../animation/layout';\r\nimport { isFocusLost } from '../utils/dom';\r\nimport { keysOf, listOf, type GroupContext } from './context';\r\nimport { accepts } from './accept';\r\nimport { viewOf } from './block';\r\nimport { keepSlotHome, moveActive, returnToOrigin } from './slot';\r\nimport { indicateAt, setIndicator } from './indicator';\r\nimport { slotCenter } from './keyboard';\r\nimport { enters } from './modes/mode';\r\n\r\n/** `index` within 0…`max`; none (or not a number) is the end. */\r\nconst clampIndex = (index: number | undefined, max: number) =>\r\n index === undefined || Number.isNaN(index) ? max : Math.min(Math.max(Math.trunc(index), 0), max);\r\n\r\n/** Puts the slot of `active` at `position`; returns where the drag goes, `undefined` when it can't go there. */\r\nexport const placeAt = async (\r\n g: GroupContext,\r\n active: Active,\r\n position: SortablePosition,\r\n): Promise<Coordinates | undefined> => {\r\n const current = g.session.value;\r\n if (!current || current.activeKey !== active.id) return undefined;\r\n const from = listOf(g, current.list);\r\n const target = position.list == null ? (from ?? listOf(g, current.origin.list)) : g.lists.get(position.list);\r\n if (!target || target.layout.nested || target.isDisabled() || !accepts(g, target, active)) return undefined;\r\n const settled = async () => {\r\n await nextTick();\r\n return g.session.value === current;\r\n };\r\n\r\n if (target.placeholder() === 'indicator') {\r\n if (!enters(g, current, target)) return undefined;\r\n // The list doesn't move: the slot stays (or goes back) home, the line goes there.\r\n const home = current.list;\r\n keepSlotHome(g, current);\r\n if (!(await settled())) return undefined;\r\n if (current.list !== home) slotCenter(g, current, true);\r\n const keys = keysOf(target);\r\n const own = target.id === current.list ? keys.indexOf(current.slot) : -1;\r\n // Counted without the item: past its own place, the line goes one further.\r\n let line = clampIndex(position.index, own >= 0 ? keys.length - 1 : keys.length);\r\n if (own >= 0 && line > own) line++;\r\n return indicateAt(g, target, line);\r\n }\r\n\r\n setIndicator(g, null);\r\n if (target === from) {\r\n if (!target.canSort()) return undefined;\r\n moveActive(g, target, clampIndex(position.index, viewOf(target, current).length - 1), null);\r\n } else if (target.id === current.origin.list && !target.canSort()) {\r\n // Its own list, which doesn't sort: the item can only go back to its place.\r\n returnToOrigin(g, null);\r\n } else {\r\n if (!enters(g, current, target)) return undefined;\r\n moveActive(g, target, clampIndex(position.index, keysOf(target).length), null);\r\n }\r\n if (!(await settled())) return undefined;\r\n return (\r\n slotCenter(g, current, target !== from || isFocusLost()) ?? g.manager.pointer.value ?? getCenter(active.rect)\r\n );\r\n};\r\n","/**\r\n * A sortable group: lists that exchange items. Holds the draft order of every list\r\n * during a drag, projects the pointer onto it, commits the result on drop, and runs\r\n * FLIP for every change it causes.\r\n *\r\n * This module wires a group to its manager; the group's state is a `GroupContext`\r\n * (`context.ts`) that every part gets passed: the session core (`session.ts`) running\r\n * the modes (`modes/`), the multi-drag block (`block.ts`) and slot moves (`slot.ts`),\r\n * insertion lines (`indicator.ts`), drops into items (`combine.ts`), keyboard moves\r\n * (`keyboard.ts`), the drop (`drop.ts`), the overlay (`landing.ts`), FLIP (`flip.ts`)\r\n * and announcements (`announcements.ts`).\r\n *\r\n * Multi-drag `'group'`: the other dragged items travel with the slot as a block,\r\n * contiguous in the draft and in drop order. Projection and keyboard moves count the\r\n * block once (`viewOf`), and every move takes the whole block along.\r\n */\r\n\r\nimport { computed, effectScope, type ComputedRef, type ShallowRef } from 'vue';\r\nimport type { Active, Coordinates, Key, SortableIndicator } from '../types';\r\nimport type { DnDManager } from '../core/manager';\r\nimport { devtoolsHook } from '../core/devtoolsHook';\r\nimport { createContext, indexOf, keysOf, lookup, type Session } from './context';\r\nimport type { ListEntry } from './entry';\r\nimport { accepts, isInert } from './accept';\r\nimport { viewOf } from './block';\r\nimport { showIndicator } from './indicator';\r\nimport { leadOffset, stableDestination } from './landing';\r\nimport { targetRule } from './combine';\r\nimport { captureLayout, watchLayout } from './flip';\r\nimport { watchChanges } from './autoAnimate';\r\nimport { useCopyModifier } from './modifier';\r\nimport { move, standsApart, start } from './session';\r\nimport { beforeDrop, cancel, end, resume } from './drop';\r\nimport { getKeyboardCoordinates } from './keyboard';\r\nimport { placeAt } from './place';\r\nimport { createAnnouncer } from './announcements';\r\n\r\nexport interface SortableGroup {\r\n name: string;\r\n manager: DnDManager;\r\n session: ShallowRef<Session | null>;\r\n /** Insertion line of `placeholder: 'indicator'` lists, while the pointer is over one. */\r\n indicator: ShallowRef<SortableIndicator | null>;\r\n /**\r\n * The drag is over a drop target that is no list and keeps the slot where it is (one\r\n * inside an item, a folder in a grid of files): the drop goes there, the slot only holds\r\n * its place, so the layout under the pointer stays still.\r\n */\r\n into: ComputedRef<boolean>;\r\n /** Shows the insertion line (trees move it with their own keys). */\r\n showIndicator(value: SortableIndicator | null): void;\r\n addList(entry: ListEntry): () => void;\r\n /** Animates `entry`'s changes that no drag made, while its `animate` is on. Call in the list's setup. */\r\n animateChanges(entry: ListEntry): void;\r\n registerItem(key: Key, getElement: () => HTMLElement | null): () => void;\r\n lookup(key: Key): unknown;\r\n keysOf(list: ListEntry): Key[];\r\n /** `list`'s draft as projection counts it: a multi-drag block once, as the slot. */\r\n viewOf(list: ListEntry): Key[];\r\n indexOf(list: ListEntry, key: Key): number;\r\n accepts(list: ListEntry, active: Active): boolean;\r\n /** The current drag can never enter this list (another group, or a plain draggable it can't create items for). */\r\n isInert(list: ListEntry): boolean;\r\n /** Where the lead's clone sits in the overlay, from the pointer (see `leadOffset`). */\r\n leadOffset(): Coordinates;\r\n captureLayout(): void;\r\n}\r\n\r\nconst registries = new WeakMap<DnDManager, Map<string, SortableGroup>>();\r\n\r\nfunction createGroup(manager: DnDManager, name: string, release: () => void): SortableGroup {\r\n const g = createContext(manager, name);\r\n devtoolsHook()?.group(g);\r\n const { lists, items, session } = g;\r\n const scope = effectScope(true);\r\n scope.run(() => {\r\n watchLayout(g);\r\n g.copyHeld = useCopyModifier(manager);\r\n });\r\n\r\n // An integration: the drop is written before the user's monitors hear `onDragEnd`.\r\n const removeMonitor = manager.addMonitor(\r\n {\r\n onDragStart: (event) => start(g, event),\r\n onDragMove: (event) => move(g, event),\r\n onBeforeDrop: (event) => beforeDrop(g, event),\r\n onDragEnd: (event) => end(g, event),\r\n onDragCancel: (event) => cancel(g, event),\r\n onDragResume: () => resume(g),\r\n getKeyboardCoordinates: (_event, context) => getKeyboardCoordinates(g, context),\r\n placeAt: (active, position) => placeAt(g, active, position),\r\n },\r\n true,\r\n );\r\n const removeAnnouncer = manager.addAnnouncer(createAnnouncer(g));\r\n const removeRule = manager.addTargetRule(targetRule(g));\r\n // The overlay's `to`: where this group would put the drag.\r\n const destination = scope.run(() => computed(stableDestination(g)))!;\r\n // A target apart from the lists (a trash can) sends the slot home instead (`sendHome`).\r\n const into = scope.run(() =>\r\n computed(() => {\r\n const over = manager.over.value;\r\n return !!session.value && !!over?.accepted && !lists.has(over.id) && !standsApart(g, over.element);\r\n }),\r\n )!;\r\n const removeDestination = manager.addDestinationResolver(() => destination.value);\r\n // `e.source.remove()` in a trash zone's onDrop marks the dragged items for removal.\r\n const removeSource = manager.addSourceResolver((active) => {\r\n const current = session.value;\r\n if (!current || current.activeKey !== active.id || current.origin.list == null) return undefined;\r\n return {\r\n list: current.origin.list,\r\n remove: () => {\r\n current.removed = true;\r\n },\r\n };\r\n });\r\n\r\n return {\r\n name,\r\n manager,\r\n session,\r\n indicator: g.indicator,\r\n into,\r\n addList(entry) {\r\n lists.set(entry.id, entry);\r\n return () => {\r\n if (lists.get(entry.id) !== entry) return;\r\n lists.delete(entry.id);\r\n if (lists.size) return;\r\n removeMonitor();\r\n removeAnnouncer();\r\n removeRule();\r\n removeDestination();\r\n removeSource();\r\n scope.stop();\r\n release();\r\n };\r\n },\r\n animateChanges: (entry) => watchChanges(g, entry),\r\n registerItem(key, getElement) {\r\n items.set(key, getElement);\r\n // Created by the render a FLIP pass waits for.\r\n g.fresh?.add(key);\r\n return () => {\r\n if (items.get(key) === getElement) items.delete(key);\r\n };\r\n },\r\n showIndicator: (value) => showIndicator(g, value),\r\n lookup: (key) => lookup(g, key),\r\n keysOf,\r\n viewOf: (list) => (session.value ? viewOf(list, session.value) : keysOf(list)),\r\n indexOf: (list, key) => indexOf(g, list, key),\r\n accepts: (list, active) => accepts(g, list, active),\r\n isInert: (list) => isInert(g, list),\r\n leadOffset: () => leadOffset(g, session.value),\r\n captureLayout: () => captureLayout(g),\r\n };\r\n}\r\n\r\nexport function useSortableGroup(manager: DnDManager, name: string): SortableGroup {\r\n let groups = registries.get(manager);\r\n if (!groups) {\r\n groups = new Map();\r\n registries.set(manager, groups);\r\n }\r\n const existing = groups.get(name);\r\n if (existing) return existing;\r\n const group = createGroup(manager, name, () => groups!.delete(name));\r\n groups.set(name, group);\r\n return group;\r\n}\r\n","/**\r\n * The layout of a list, as the group sees it: a flat list (`flatLayout`) or a tree\r\n * (`tree/layout.ts`), whose rows have a depth and whose nodes carry their subtrees. The\r\n * session core, the modes and the keyboard ask the list's layout for projections, drafts\r\n * and indicator lines, so none of them branches on trees. What a drop writes is the\r\n * list's own (`ListEntry.build`, `commit`): an array, or a tree.\r\n */\r\n\r\nimport type { DnDEvent, Key, Rect, SortableStrategy, TreeProjection } from '../types';\r\nimport { projectIndex, projectIndicator, type IndicatorProjection, type Projection, type ProjectionItem } from './projection';\r\nimport { sameKeys } from './context';\r\n\r\n/** What `prepareDraft` is told about the drag. */\r\nexport interface DraftContext {\r\n /** Dragged key the slot stands for: the active key, or the tree node it rides in. */\r\n lead: Key;\r\n /** Dragged keys that travel on their own, in drop order (the lead included). */\r\n keys: Key[];\r\n /** The dragged items stay where they are; their copies travel. */\r\n copying: boolean;\r\n}\r\n\r\nexport interface ProjectContext {\r\n /**\r\n * Current draft of this list: as projection counts it (a multi-drag block once, see\r\n * `viewOf`), and as it is for an insertion line.\r\n */\r\n keys: Key[];\r\n /** Mounted items of this list, with layout rects, in draft order. */\r\n items: ProjectionItem[];\r\n /** Key of the active slot (the active key unless copying or inserting). */\r\n activeKey: Key;\r\n /** Index of the active key in this draft, -1 when it is in another list (or for a line). */\r\n activeIndex: number;\r\n strategy: SortableStrategy;\r\n /** Grid only: the item that just moved under the pointer, ignored until the pointer leaves it. */\r\n lock: Key | null;\r\n /** Items holding a drop target for this drag, with their middle band (`combine.ts`). */\r\n targets?: ReadonlyMap<Key, Rect>;\r\n}\r\n\r\nexport interface ListLayout {\r\n /**\r\n * Rows have a depth (trees): the list keeps projecting where its order can't change\r\n * (the list the slot just left, `sort: false`: the depth still can), and moves the slot\r\n * by keyboard itself (its arrow keys pick a row and a depth, which the next move applies).\r\n */\r\n readonly nested: boolean;\r\n /**\r\n * Dragged keys of this list that travel inside another dragged one (a tree's selected\r\n * descendants), each with the dragged key it rides in: they leave the drag. The active\r\n * key may be one: the key it rides in then leads the drag.\r\n */\r\n carried(keys: readonly Key[]): ReadonlyMap<Key, Key>;\r\n /** Adjusts a draft at drag start or when copying turns on or off, e.g. hides the descendants of the dragged nodes. */\r\n prepareDraft(keys: Key[], context: DraftContext): Key[];\r\n /** The new index of the active key (`null` keeps it), the grid lock, and the item that made it move (hysteresis). */\r\n project(event: DnDEvent, context: ProjectContext): Projection;\r\n /** Indicator mode: the line under the pointer (trees add the depth); `undefined` keeps the last one. */\r\n indicate(event: DnDEvent, context: ProjectContext): IndicatorProjection | null | undefined;\r\n /** Indicator mode: the line at `index` of the draft `keys` when the keyboard enters the list; `null` when none fits. */\r\n indicateAt(keys: Key[], index: number): IndicatorProjection | null;\r\n /** Runs on every move while this list holds the active slot (after any reorder). */\r\n afterMove(event: DnDEvent): void;\r\n /** Whether committing `keys` to the list that holds `source` changes anything. */\r\n hasChanges(keys: Key[], inserted: readonly Key[], source: Key[]): boolean;\r\n /** Runs when the session ends (drop, cancel, reject). */\r\n reset(): void;\r\n /** Trees: where the dragged nodes would land, with depth and parent (`index` among the siblings). Reactive. */\r\n placement?(): (TreeProjection & { index: number }) | null;\r\n}\r\n\r\nconst NO_CARRIERS: ReadonlyMap<Key, Key> = new Map();\r\n\r\nconst nothing = () => {};\r\n\r\nexport const flatLayout: ListLayout = {\r\n nested: false,\r\n carried: () => NO_CARRIERS,\r\n prepareDraft: (keys) => keys,\r\n project: ({ pointer }, { keys, items, activeKey, activeIndex, strategy, lock, targets }) =>\r\n projectIndex({ strategy, pointer, items, activeKey, activeIndex, length: keys.length, lock, targets }),\r\n indicate: ({ pointer }, { keys, strategy, items, activeKey, targets }) =>\r\n projectIndicator({ strategy, pointer, items, activeKey, length: keys.length, targets }),\r\n indicateAt: (keys, index) =>\r\n index < keys.length\r\n ? { index, key: keys[index]!, side: 'before' }\r\n : { index, key: keys[keys.length - 1] ?? null, side: 'after' },\r\n afterMove: nothing,\r\n hasChanges: (keys, _inserted, source) => !sameKeys(keys, source),\r\n reset: nothing,\r\n};\r\n","import {\r\n computed,\r\n getCurrentInstance,\r\n isReadonly,\r\n isRef,\r\n onScopeDispose,\r\n provide,\r\n shallowRef,\r\n unref,\r\n type Component,\r\n type InjectionKey,\r\n type Ref,\r\n} from 'vue';\r\nimport type {\r\n ActivationOptions,\r\n DropAnimation,\r\n Key,\r\n MaybeElementRef,\r\n MaybeReadonlyRef,\r\n Modifier,\r\n SortableDropEvent,\r\n SortableGroupOptions,\r\n SortableListOptions,\r\n SortableListReturn,\r\n} from '../types';\r\nimport { useManager } from '../core/context';\r\nimport { createDroppable } from '../core/makeDroppable';\r\nimport { createId, toElement } from '../utils/dom';\r\nimport { read } from '../utils/read';\r\nimport { useSortableGroup, type SortableGroup } from './group';\r\nimport { putAllows } from './accept';\r\nimport type { ListEntry } from './entry';\r\nimport { flatLayout } from './layout';\r\nimport { changedRun } from './draft';\r\n\r\n/** What a list (or tree) gives its items. */\r\nexport interface SortableContext {\r\n group: SortableGroup;\r\n list: ListEntry;\r\n /** The list's `getKey`: keys `makeSortableItem({ item })`. */\r\n getKey: (item: unknown) => Key;\r\n /** The list's `overlay` component, used when the item has none. */\r\n getOverlay: () => Component | undefined;\r\n /** The list's `dropAnimation`, used when the item has none. */\r\n getDropAnimation: () => DropAnimation | undefined;\r\n /** The list's `modifiers`, used when the item has none. */\r\n getModifiers?: () => Modifier[] | undefined;\r\n /** The list's `axis`, used when the item has none. */\r\n getAxis?: () => 'x' | 'y' | undefined;\r\n /** The list's `activation`, used when the item has none. */\r\n getActivation?: () => ActivationOptions | undefined;\r\n}\r\n\r\n/** What the lists (and trees) of a component give the items it renders: several are told apart by the DOM. */\r\nexport interface SortableScope {\r\n contexts: SortableContext[];\r\n}\r\n\r\nexport const SORTABLE_CONTEXT: InjectionKey<SortableScope> = Symbol('vue-dnd-kit-sortable');\r\n\r\n/** The scope of each component with lists: provided once, its later lists join it. */\r\nconst scopes = new WeakMap<object, SortableScope>();\r\n\r\n/**\r\n * The context of the list an item is in: the component's only list, or of several the\r\n * innermost whose element holds the item's element (the first while it isn't rendered).\r\n */\r\nexport const contextOf = (scope: SortableScope, element: Element | null): SortableContext => {\r\n const { contexts } = scope;\r\n if (contexts.length === 1 || !element) return contexts[0]!;\r\n let found: SortableContext | undefined;\r\n let container: Element | null = null;\r\n for (const context of contexts) {\r\n const own = context.list.getElement();\r\n if (own?.contains(element) && (!container || container.contains(own))) {\r\n found = context;\r\n container = own;\r\n }\r\n }\r\n return found ?? contexts[0]!;\r\n};\r\n\r\n/** `item.id`, or the item itself for primitives (lists and trees). */\r\nexport const defaultGetKey = (item: unknown): Key =>\r\n item !== null && typeof item === 'object' && 'id' in item\r\n ? ((item as { id: Key }).id)\r\n : (item as Key);\r\n\r\nexport const provideSortableContext = (\r\n group: SortableGroup,\r\n list: ListEntry,\r\n getKey: (item: never) => Key,\r\n overlay: MaybeReadonlyRef<Component | undefined>,\r\n dropAnimation: MaybeReadonlyRef<DropAnimation | undefined>,\r\n getModifiers?: () => Modifier[] | undefined,\r\n getAxis?: () => 'x' | 'y' | undefined,\r\n getActivation?: () => ActivationOptions | undefined,\r\n): void => {\r\n const context: SortableContext = {\r\n group,\r\n list,\r\n getKey: getKey as (item: unknown) => Key,\r\n getOverlay: () => unref(overlay),\r\n getDropAnimation: () => unref(dropAnimation),\r\n getModifiers,\r\n getAxis,\r\n getActivation,\r\n };\r\n // Several lists in one component: its items find theirs by the DOM (`contextOf`).\r\n const instance = getCurrentInstance();\r\n const own = instance && scopes.get(instance);\r\n if (own) {\r\n own.contexts.push(context);\r\n return;\r\n }\r\n const scope: SortableScope = { contexts: [context] };\r\n if (instance) scopes.set(instance, scope);\r\n provide(SORTABLE_CONTEXT, scope);\r\n};\r\n\r\n/**\r\n * A drop into a list with `filter`: the new order of the shown keys (`next`) as the whole\r\n * array. Each hidden item stays after the shown one it followed, or, when that one moved\r\n * (`inserted`) or left, after the nearest before it that stayed (first, without one).\r\n */\r\nexport const withHidden = <T>(\r\n all: readonly T[],\r\n shown: readonly Key[],\r\n next: readonly Key[],\r\n inserted: readonly Key[],\r\n getKey: (item: T) => Key,\r\n lookup: (key: Key) => unknown,\r\n): unknown[] => {\r\n const visible = new Set(shown);\r\n const stayed = new Set(next);\r\n for (const key of inserted) stayed.delete(key);\r\n const first: T[] = [];\r\n const after = new Map<Key, T[]>();\r\n let anchor: Key | null = null;\r\n for (const item of all) {\r\n const key = getKey(item);\r\n if (visible.has(key)) {\r\n if (stayed.has(key)) anchor = key;\r\n } else if (anchor === null) {\r\n first.push(item);\r\n } else {\r\n let hidden = after.get(anchor);\r\n if (!hidden) after.set(anchor, (hidden = []));\r\n hidden.push(item);\r\n }\r\n }\r\n return [...first, ...next.flatMap((key) => [lookup(key), ...(after.get(key) ?? [])])];\r\n};\r\n\r\n/** Bundlers replace it: development builds keep the warnings, production drops them. */\r\ndeclare const process: { env: { NODE_ENV?: string } };\r\n\r\nlet warnedClone = false;\r\n\r\n/** `group.pull` of a list or tree: `'clone'` needs a `clone` option, without one the items stay (with a warning). */\r\nexport const pullOf = (group: Pick<SortableGroupOptions, 'pull'> | undefined, canClone: boolean): boolean | 'clone' => {\r\n const pull = group?.pull ?? true;\r\n if (pull === 'clone' && !canClone) {\r\n if (process.env.NODE_ENV !== 'production' && !warnedClone) {\r\n console.warn('[vue-dnd-kit] group.pull: \\'clone\\' needs a `clone` option; items stay in the list.');\r\n }\r\n warnedClone = true;\r\n return false;\r\n }\r\n return pull;\r\n};\r\n\r\n/** `external` of a list or tree makes its items with `createItem`: without one it takes nothing, and development builds say so. */\r\nexport const checkExternal = (options: { external?: unknown; createItem?: unknown }, kind: 'list' | 'tree') => {\r\n if (process.env.NODE_ENV !== 'production' && read(options.external) && !options.createItem) {\r\n console.warn(`[vue-dnd-kit] A sortable ${kind} with \\`external\\` needs \\`createItem\\` to make items of what comes from outside the page; without one it takes nothing.`);\r\n }\r\n};\r\n\r\n/**\r\n * Makes a container a sortable list. Render the returned `items` (the draft order), not\r\n * your array: the drop is written back to `options.items`, after `onDrop`, unless\r\n * `event.preventDefault()` leaves `event.result` to you.\r\n */\r\nexport function makeSortableList<T>(\r\n target: MaybeElementRef,\r\n options: SortableListOptions<T>,\r\n): SortableListReturn<T> {\r\n const manager = useManager();\r\n const id = options.id ?? createId('sortable');\r\n const groupOptions = typeof options.group === 'string' ? { name: options.group } : options.group;\r\n const group = useSortableGroup(manager, groupOptions?.name ?? `sortable:${id}`);\r\n checkExternal(options, 'list');\r\n const getKey = (options.getKey ?? defaultGetKey) as (item: T) => Key;\r\n const source = () => read<readonly T[]>(options.items) as T[];\r\n // `filter`: the list shows, and sorts, only these.\r\n const shown = computed(() => (options.filter ? source().filter(options.filter) : source()));\r\n\r\n const keys = computed(() => shown.value.map(getKey));\r\n const byKey = computed(() => {\r\n const map = new Map<Key, T>();\r\n for (const item of source()) map.set(getKey(item), item);\r\n return map;\r\n });\r\n const draft = shallowRef<Key[] | null>(null);\r\n\r\n const entry: ListEntry = {\r\n id,\r\n draft,\r\n getElement: () => toElement(target),\r\n getKeys: () => keys.value,\r\n getItem: (key) => byKey.value.get(key),\r\n layout: flatLayout,\r\n options,\r\n strategy: () => read(options.strategy) ?? 'vertical',\r\n placeholder: () => read(options.placeholder) ?? 'item',\r\n animation: () => unref(options.animation) ?? manager.props.animation,\r\n animate: () => read(options.animateChanges) ?? manager.props.animateChanges,\r\n animateSize: () => read(options.animateSize) ?? true,\r\n isDisabled: () => !!read(options.disabled),\r\n canSort: () => read(options.sort) !== false,\r\n pull: () => pullOf(groupOptions, !!options.clone),\r\n canPut: (context) => putAllows(groupOptions?.put as SortableGroupOptions['put'], context, manager),\r\n dropOutside: () =>\r\n read(options.dropOutside) ?? (read(options.placeholder) === 'indicator' ? 'cancel' : 'placeholder'),\r\n behavior: () => read(options.behavior) ?? 'sort',\r\n multiple: () => read(options.multiple) ?? 'group',\r\n acceptMode: () => read(options.acceptMode) ?? 'all',\r\n clone: options.clone\r\n ? (item) => {\r\n const copy = options.clone!(item as T);\r\n return { key: getKey(copy), item: copy };\r\n }\r\n : undefined,\r\n create: options.createItem\r\n ? (active) => {\r\n const made = options.createItem!(active);\r\n return made === undefined ? undefined : (Array.isArray(made) ? made : [made]).map((item: T) => ({ key: getKey(item), item }));\r\n }\r\n : undefined,\r\n external: () => read(options.external),\r\n keyOf: (item) => getKey(item as T),\r\n isReadonly: () => !isRef(options.items) || isReadonly(options.items),\r\n build: (next, lookup, inserted) => (options.filter ? withHidden(source(), keys.value, next, inserted, getKey, lookup) : next.map(lookup)),\r\n // The very array the drop's `result` holds.\r\n commit: (built) => {\r\n (options.items as Ref<T[]>).value = built as T[];\r\n },\r\n beforeDrop: options.onBeforeDrop as ListEntry['beforeDrop'],\r\n afterDrop: options.onDrop as ((event: SortableDropEvent) => void) | undefined,\r\n };\r\n onScopeDispose(group.addList(entry));\r\n group.animateChanges(entry);\r\n onScopeDispose(manager.registerAutoScroll(entry.getElement, () => read(options.autoScroll)));\r\n\r\n const droppable = createDroppable(\r\n // The list takes drops in its `dropzone` (a column around it), else in its element.\r\n () => toElement(options.dropzone) ?? toElement(target),\r\n // Lists the current drag can never enter are not drop targets at all: in nested\r\n // sortables a column dragged over another column must reach the columns list,\r\n // not stop at the inner card list it happens to be over.\r\n {\r\n id,\r\n label: options.label,\r\n data: options.data,\r\n disabled: () => !!read(options.disabled) || group.isInert(entry),\r\n // As a target: what the overlay shows over it, and how it lands in it.\r\n overOverlay: options.overOverlay,\r\n overDropAnimation: options.overDropAnimation,\r\n // Drags from outside the page it takes (with `createItem`).\r\n external: options.external,\r\n },\r\n { accepts: (active) => group.accepts(entry, active), getGroup: () => group.name },\r\n );\r\n\r\n provideSortableContext(\r\n group,\r\n entry,\r\n getKey,\r\n options.overlay,\r\n options.dropAnimation,\r\n () => read(options.modifiers),\r\n () => read(options.axis),\r\n () => read(options.activation),\r\n );\r\n\r\n // A new draft usually differs from the previous one in a short run (a reorder): only\r\n // that run is looked up, the rest is copied. Items of a session never change by key.\r\n let rendered: { order: Key[]; items: T[]; session: unknown } | null = null;\r\n const items = computed<T[]>(() => {\r\n const order = draft.value;\r\n if (!order) {\r\n rendered = null;\r\n return shown.value;\r\n }\r\n const session = group.session.value;\r\n const lookup = (key: Key) => group.lookup(key) as T;\r\n let next: T[];\r\n if (rendered?.session === session) {\r\n const { start, end, nextEnd } = changedRun(rendered.order, order);\r\n const previous = rendered.items;\r\n next = previous.slice(0, start).concat(order.slice(start, nextEnd).map(lookup), previous.slice(end));\r\n } else {\r\n next = order.map(lookup);\r\n }\r\n rendered = { order, items: next, session };\r\n return next;\r\n });\r\n // The row a virtualizer must keep mounted: in the list holding a copy or an\r\n // external item, that row is the copy/item (the slot), not the original.\r\n // The session is mutated in place, so the slot is read from its reactive mirror.\r\n const activeKey = computed(() => {\r\n const current = group.session.value;\r\n if (!current) return null;\r\n const slot = manager.landingKey.value;\r\n return slot != null && group.indexOf(entry, slot) !== -1 ? slot : current.activeKey;\r\n });\r\n const activeIndex = computed(() => {\r\n const key = activeKey.value;\r\n return key == null ? -1 : group.indexOf(entry, key);\r\n });\r\n const activeSize = computed(() => group.session.value?.size ?? null);\r\n const indicator = computed(() => {\r\n const value = group.indicator.value;\r\n return value?.list === id ? value : null;\r\n });\r\n\r\n return {\r\n id,\r\n items,\r\n isOver: droppable.isOver,\r\n isAccepting: droppable.isAccepting,\r\n indicator,\r\n activeKey,\r\n activeIndex,\r\n activeSize,\r\n captureLayout: group.captureLayout,\r\n };\r\n}\r\n","import { computed, inject, onScopeDispose, watch, watchEffect } from 'vue';\r\nimport type { Key, MaybeElementRef, SortableItemOptions, SortableItemReturn } from '../types';\r\nimport { createDraggable } from '../core/makeDraggable';\r\nimport { toElement } from '../utils/dom';\r\nimport { read } from '../utils/read';\r\nimport { SORTABLE_CONTEXT, contextOf } from './makeSortableList';\r\n\r\n/**\r\n * Makes an element a row of a sortable list or tree: it drags, makes room and lands in\r\n * its slot. Call it in a component rendered inside the one that called `makeSortableList`\r\n * (or `makeSortableTree`); of several lists made there, the row joins the innermost one\r\n * whose element holds it. Identify the row with `item` (keyed by the list's `getKey`,\r\n * `item.id` by default) or `id`.\r\n */\r\nexport function makeSortableItem<TData = unknown>(\r\n target: MaybeElementRef,\r\n options: SortableItemOptions<TData>,\r\n): SortableItemReturn {\r\n const scope = inject(SORTABLE_CONTEXT, null);\r\n if (!scope) {\r\n throw new Error(\r\n '[vue-dnd-kit] makeSortableItem() must be used inside a component rendered by a list that called makeSortableList().',\r\n );\r\n }\r\n if (options.id == null && options.item == null) {\r\n throw new Error(\r\n '[vue-dnd-kit] makeSortableItem() needs `id` or `item`. Sortable keys must come from your data: ' +\r\n 'an automatic id would change when the component is recreated (moved to another list, recycled ' +\r\n 'by a virtual list), and the drag would lose the item.',\r\n );\r\n }\r\n const getElement = () => toElement(target);\r\n // The list it is in: of several lists in one component, known once it has rendered.\r\n const context = computed(() => contextOf(scope, getElement()));\r\n const group = () => context.value.group;\r\n const list = () => context.value.list;\r\n const manager = group().manager;\r\n const key = computed<Key>(() => (options.id != null ? read(options.id) : context.value.getKey(read(options.item))));\r\n\r\n const draggable = createDraggable(\r\n target,\r\n {\r\n id: key,\r\n handle: options.handle,\r\n disabled: () => !!read(options.disabled) || list().isDisabled(),\r\n type: () => read(options.type) ?? group().name,\r\n data: options.data,\r\n label: options.label,\r\n activation: () => read(options.activation) ?? context.value.getActivation?.(),\r\n canDrag: options.canDrag,\r\n attributes: options.attributes,\r\n overlay: options.overlay,\r\n dropAnimation: options.dropAnimation,\r\n modifiers: () => read(options.modifiers) ?? context.value.getModifiers?.(),\r\n axis: () => read(options.axis) ?? context.value.getAxis?.(),\r\n native: options.native,\r\n },\r\n {\r\n getItem: () => group().lookup(key.value),\r\n getGroup: () => group().name,\r\n getContainer: () => list().getElement(),\r\n getOverlay: () => context.value.getOverlay(),\r\n getDropAnimation: () => context.value.getDropAnimation(),\r\n roleDescription: 'sortable',\r\n },\r\n );\r\n\r\n let unregister = group().registerItem(key.value, getElement);\r\n watch([key, group], ([next, to]) => {\r\n unregister();\r\n unregister = to.registerItem(next, getElement);\r\n });\r\n onScopeDispose(() => unregister());\r\n\r\n // The slot: the active item, or its copy / the item made for an external draggable;\r\n // in a `'group'` multi-drag also the slots of the items travelling with it. Stays\r\n // true through the drop animation, until the overlay has landed (`isLanding`), while\r\n // the next drag may already run. A copied item stays as it is: while its copy has no\r\n // slot (over its palette, over an indicator list), nothing is.\r\n const isPlaceholder = computed(() => {\r\n if (manager.isLanding(key.value)) return true;\r\n const active = manager.active.value;\r\n if (!active) return false;\r\n const slot = manager.landingKey.value ?? (manager.mode.value === 'copy' ? null : active.id);\r\n return slot === key.value || manager.landings.value.has(key.value);\r\n });\r\n // Multi-drag `'gaps'`: the other dragged items stay in place until the drop. Copied\r\n // items don't leave at all, so they aren't marked (the default style dims the mark).\r\n const isLeftBehind = computed(() => {\r\n if (!draggable.isDragging.value || isPlaceholder.value) return false;\r\n const copying = manager.active.value?.ids.includes(key.value)\r\n ? manager.mode.value === 'copy'\r\n : manager.flightOf(key.value)?.mode === 'copy';\r\n return !copying;\r\n });\r\n\r\n watchEffect(\r\n () => {\r\n const element = getElement();\r\n if (!element) return;\r\n // `\"into\"`: the drop goes into a target the slot only holds the place next to.\r\n if (!isPlaceholder.value) element.removeAttribute('data-dnd-placeholder');\r\n else element.setAttribute('data-dnd-placeholder', group().into.value ? 'into' : '');\r\n element.toggleAttribute('data-dnd-dragging', isLeftBehind.value);\r\n },\r\n { flush: 'post' },\r\n );\r\n\r\n const indicator = computed(() => {\r\n const value = group().indicator.value;\r\n return value && value.list === list().id && value.key === key.value ? value : null;\r\n });\r\n\r\n return {\r\n isDragging: draggable.isDragging,\r\n isPlaceholder,\r\n selected: draggable.selected,\r\n indicator,\r\n index: computed(() => group().indexOf(list(), key.value)),\r\n };\r\n}\r\n","/**\r\n * The flat view of a tree for `makeSortableTree`: the visible nodes in depth-first order,\r\n * each with its depth, parent and index among its siblings. The draft of a tree is the\r\n * list of their keys.\r\n */\r\n\r\nimport type { FlatNode, Key } from '../../types';\r\n\r\nexport interface TreeAccessors<T> {\r\n getKey: (node: T) => Key;\r\n getChildren: (node: T) => readonly T[] | undefined;\r\n setChildren: (node: T, children: T[]) => void;\r\n}\r\n\r\n/** What the projection needs to know about a visible node. */\r\nexport type TreeRow = Pick<FlatNode<unknown>, 'key' | 'depth' | 'parentKey' | 'index'>;\r\n\r\nexport interface FlatTree<T> {\r\n nodes: FlatNode<T>[];\r\n byKey: Map<Key, FlatNode<T>>;\r\n}\r\n\r\n/** Visible nodes in depth-first order; children of collapsed nodes are skipped. O(N). */\r\nexport function flattenTree<T>(\r\n nodes: readonly T[],\r\n getKey: (node: T) => Key,\r\n getChildren: (node: T) => readonly T[] | undefined,\r\n collapsed?: ReadonlySet<Key>,\r\n): FlatNode<T>[] {\r\n const result: FlatNode<T>[] = [];\r\n // Iterative, so deep trees can't overflow the stack.\r\n const stack: Array<{ siblings: readonly T[]; index: number; depth: number; parentKey: Key | null }> = [\r\n { siblings: nodes, index: 0, depth: 0, parentKey: null },\r\n ];\r\n while (stack.length) {\r\n const frame = stack[stack.length - 1]!;\r\n if (frame.index >= frame.siblings.length) {\r\n stack.pop();\r\n continue;\r\n }\r\n const index = frame.index++;\r\n const item = frame.siblings[index]!;\r\n const key = getKey(item);\r\n const children = getChildren(item);\r\n const isCollapsed = !!collapsed?.has(key);\r\n result.push({\r\n key,\r\n item,\r\n depth: frame.depth,\r\n parentKey: frame.parentKey,\r\n index,\r\n hasChildren: !!children?.length,\r\n collapsed: isCollapsed,\r\n });\r\n if (children?.length && !isCollapsed) {\r\n stack.push({ siblings: children, index: 0, depth: frame.depth + 1, parentKey: key });\r\n }\r\n }\r\n return result;\r\n}\r\n\r\nexport function createFlatTree<T>(nodes: FlatNode<T>[]): FlatTree<T> {\r\n return { nodes, byKey: new Map(nodes.map((node) => [node.key, node])) };\r\n}\r\n\r\n/** End (exclusive) of the visible subtree of the node at `index` in a flat list. */\r\nexport function subtreeEnd(nodes: readonly Pick<TreeRow, 'depth'>[], index: number): number {\r\n const depth = nodes[index]!.depth;\r\n let end = index + 1;\r\n while (end < nodes.length && nodes[end]!.depth > depth) end++;\r\n return end;\r\n}\r\n\r\n/** Keys of the visible descendants of the node at `index` in a flat list. */\r\nexport function getDescendantKeys(nodes: readonly TreeRow[], index: number): Key[] {\r\n return nodes.slice(index + 1, subtreeEnd(nodes, index)).map((node) => node.key);\r\n}\r\n\r\n/** Levels below the deepest of `nodes` (a multi-drag block), collapsed children included. */\r\nexport const blockHeight = <T>(nodes: readonly T[], getChildren: (node: T) => readonly T[] | undefined): number =>\r\n nodes.reduce((height, node) => Math.max(height, subtreeHeight(node, getChildren)), 0);\r\n\r\n/** Levels below `node`, collapsed children included (0 for a leaf). Used against `maxDepth`. */\r\nexport function subtreeHeight<T>(node: T, getChildren: (node: T) => readonly T[] | undefined): number {\r\n let height = 0;\r\n const stack: Array<{ node: T; level: number }> = [{ node, level: 0 }];\r\n while (stack.length) {\r\n const { node: current, level } = stack.pop()!;\r\n if (level > height) height = level;\r\n for (const child of getChildren(current) ?? []) stack.push({ node: child, level: level + 1 });\r\n }\r\n return height;\r\n}\r\n","/**\r\n * Depth projection: a node's depth and parent follow from its neighbours in the draft\r\n * (the flat list of visible keys), so a move is a new index in the draft plus a depth\r\n * between those of the rows around it.\r\n */\r\n\r\nimport type { Key, TreeProjection } from '../../types';\r\nimport type { TreeRow } from './flatten';\r\n\r\n/**\r\n * Draft context: visible keys with the active key at `index`, and the rows of every\r\n * other key. The active key itself is never looked up (it may come from another list).\r\n */\r\nexport interface DraftPosition {\r\n keys: readonly Key[];\r\n index: number;\r\n rows: ReadonlyMap<Key, TreeRow>;\r\n /** `keys` leaves the active key out: it would be inserted at `index` (no copy per candidate slot). */\r\n inserted?: boolean;\r\n}\r\n\r\n/** Whether the active node may sit at `depth` under `parentKey` (`canNest`, `maxDepth`). */\r\nexport type DepthFilter = (depth: number, parentKey: Key | null) => boolean;\r\n\r\n/** A set of keys, or a map keyed by them. */\r\nexport type KeySet = Pick<ReadonlySet<Key>, 'has' | 'size'>;\r\n\r\n/**\r\n * `maxDepth` and `canNest` for the dragged nodes, a multi-drag block as one: the deepest\r\n * descendant (`height` levels below them) must stay within `maxDepth`, and `canNest`\r\n * must take every one of them under the parent.\r\n */\r\nexport const blockFilter =\r\n <T>(\r\n items: readonly T[],\r\n height: number,\r\n rows: ReadonlyMap<Key, { item: T }>,\r\n maxDepth?: number,\r\n canNest?: (node: T, parent: T) => boolean,\r\n ): DepthFilter =>\r\n (depth, parentKey) => {\r\n if (maxDepth != null && depth + height > maxDepth) return false;\r\n const parent = parentKey == null || !canNest ? undefined : rows.get(parentKey);\r\n return !parent || items.every((item) => canNest!(item, parent.item));\r\n };\r\n\r\nconst rowAt = ({ keys, rows }: DraftPosition, index: number): TreeRow | undefined => {\r\n const key = keys[index];\r\n return key === undefined ? undefined : rows.get(key);\r\n};\r\n\r\n/** Depths the active node can take between its neighbours: `[next.depth, prev.depth + 1]`. */\r\nexport function depthRange(position: DraftPosition): { min: number; max: number } {\r\n const prev = rowAt(position, position.index - 1);\r\n const next = rowAt(position, position.inserted ? position.index : position.index + 1);\r\n const max = prev ? prev.depth + 1 : 0;\r\n return { min: Math.min(next ? next.depth : 0, max), max };\r\n}\r\n\r\n/**\r\n * Ancestors before the active slot by depth: `chain[d]` is the nearest preceding node\r\n * with depth `d`, i.e. the parent the active node gets at depth `d + 1`. Walks back\r\n * only until the root level is found.\r\n */\r\nconst ancestorChain = (position: DraftPosition): Key[] => {\r\n const chain: Key[] = [];\r\n let want = Infinity;\r\n for (let i = position.index - 1; i >= 0 && want > 0; i--) {\r\n const row = rowAt(position, i);\r\n if (!row || row.depth >= want) continue;\r\n chain[row.depth] = row.key;\r\n want = row.depth;\r\n }\r\n return chain;\r\n};\r\n\r\n/** Parent of the active node at its draft position with the given depth. */\r\nexport function parentAt(position: DraftPosition, depth: number): Key | null {\r\n return depth <= 0 ? null : (ancestorChain(position)[depth - 1] ?? null);\r\n}\r\n\r\n/** Depth from the horizontal drag offset, relative to a base depth. */\r\nexport const offsetDepth = (baseDepth: number, offsetX: number, indentation: number): number =>\r\n baseDepth + Math.round(offsetX / indentation);\r\n\r\n/**\r\n * Clamps `depth` between the neighbours, then lowers it while `filter` rejects it.\r\n * `null` when no depth fits at this position (the position itself is invalid).\r\n */\r\nexport function projectDepth(\r\n position: DraftPosition,\r\n depth: number,\r\n filter?: DepthFilter,\r\n): TreeProjection | null {\r\n const { min, max } = depthRange(position);\r\n const chain = ancestorChain(position);\r\n for (let d = Math.max(min, Math.min(depth, max)); d >= min; d--) {\r\n const parentKey = d === 0 ? null : (chain[d - 1] ?? null);\r\n if (!filter || filter(d, parentKey)) return { depth: d, parentKey };\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * The slot to move to when the pointer asks for `target`: the first one from `target`\r\n * back towards `from` where some depth fits. The pointer can skip several rows in one\r\n * frame; the slot then stops at the last valid one on the way, as it would row by row.\r\n * `null` when none fits (keep the current slot). `keys` is the draft with the active\r\n * key at `from` (-1: it comes from another list, only `target` is tried).\r\n */\r\nexport function nearestValidSlot(\r\n keys: readonly Key[],\r\n activeKey: Key,\r\n from: number,\r\n target: number,\r\n rows: ReadonlyMap<Key, TreeRow>,\r\n filter?: DepthFilter,\r\n): number | null {\r\n const others = from === -1 ? keys : keys.filter((key) => key !== activeKey);\r\n const fits = (index: number) => !!projectDepth({ keys: others, index, rows, inserted: true }, Infinity, filter);\r\n if (from === -1) return fits(target) ? target : null;\r\n const step = target < from ? 1 : -1;\r\n for (let index = target; index !== from; index += step) {\r\n if (fits(index)) return index;\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * Index the active node gets among its new siblings. `origins` are where the moved\r\n * nodes of this tree were before the drag (none for items from another list): every\r\n * earlier slot of the same parent they leave shifts the later siblings up by one.\r\n */\r\nexport function siblingIndexAt(\r\n position: DraftPosition,\r\n projection: TreeProjection,\r\n origins: ReadonlyArray<{ parentKey: Key | null; index: number }>,\r\n): number {\r\n for (let i = position.index - 1; i >= 0; i--) {\r\n const row = rowAt(position, i);\r\n if (!row || row.depth > projection.depth) continue;\r\n if (row.depth < projection.depth) return 0;\r\n let shift = 0;\r\n for (const origin of origins) if (origin.parentKey === projection.parentKey && origin.index < row.index) shift++;\r\n return row.index + 1 - shift;\r\n }\r\n return 0;\r\n}\r\n\r\n/**\r\n * The draft position of a line at `gap` (an insertion index in `keys`, indicator mode),\r\n * with the `moving` rows (the dragged nodes and their subtrees) left out.\r\n */\r\nexport function gapPosition(\r\n keys: readonly Key[],\r\n gap: number,\r\n moving: KeySet,\r\n rows: ReadonlyMap<Key, TreeRow>,\r\n): DraftPosition {\r\n if (!moving.size) return { keys, index: gap, rows, inserted: true };\r\n const others: Key[] = [];\r\n let index = 0;\r\n keys.forEach((key, i) => {\r\n if (moving.has(key)) return;\r\n if (i < gap) index++;\r\n others.push(key);\r\n });\r\n return { keys: others, index, rows, inserted: true };\r\n}\r\n\r\n/** The draft with `key` moved from `from` to `to` (or inserted at `to` when `from` is -1). */\r\nexport function moveKey(keys: readonly Key[], key: Key, from: number, to: number): Key[] {\r\n const next = [...keys];\r\n if (from !== -1) next.splice(from, 1);\r\n next.splice(Math.max(0, Math.min(to, next.length)), 0, key);\r\n return next;\r\n}\r\n","/**\r\n * The state of one sortable tree (`makeSortableTree`), passed to its layout, drop and\r\n * keyboard modules, and where the dragged nodes would land in it (`placement`).\r\n */\r\n\r\nimport type { ComputedRef, ShallowRef } from 'vue';\r\nimport type { Key, SortableTreeOptions, TreeProjection } from '../../types';\r\nimport type { DnDManager } from '../../core/manager';\r\nimport { read } from '../../utils/read';\r\nimport type { SortableGroup } from '../group';\r\nimport type { ListEntry } from '../entry';\r\nimport { blockHeight, type FlatTree, type TreeAccessors } from './flatten';\r\nimport { blockFilter, projectDepth, siblingIndexAt, type DepthFilter, type DraftPosition, type KeySet } from './depth';\r\nimport type { TreeMove } from './move';\r\n\r\nconst DEFAULT_INDENTATION = 24;\r\n\r\n/** No rows travel: copies leave the dragged nodes where they are. */\r\nconst NO_ROWS: KeySet = new Set<Key>();\r\n\r\n/** Projection plus the index among the new siblings. */\r\nexport interface Placement extends TreeProjection {\r\n index: number;\r\n}\r\n\r\nexport interface Origin {\r\n parentKey: Key | null;\r\n index: number;\r\n}\r\n\r\n/** A projection and the draft position it was made in: the drop recounts the sibling index from it. */\r\nexport interface Spot {\r\n position: DraftPosition;\r\n projection: TreeProjection;\r\n}\r\n\r\nexport interface DragState {\r\n /**\r\n * The dragged node the slot stands for: the grabbed one, or the selected node it rides\r\n * in (VS Code). It may come from another list, or be a plain draggable.\r\n */\r\n lead: Key;\r\n /** Place of the lead before the drag; `null` when it comes from another list. */\r\n origin: Origin | null;\r\n /** Places of the dragged nodes of this tree: they all leave them on drop (copies don't). */\r\n origins: Map<Key, Origin>;\r\n /**\r\n * Rows that travel with the drag → the dragged node they travel with: the dragged\r\n * nodes of this tree and their visible descendants. Hidden in item mode; in indicator\r\n * mode they stay, and the line never goes on them. Copying, nothing travels.\r\n */\r\n moving: Map<Key, Key>;\r\n startDepth: number;\r\n /**\r\n * Origin of the offset rule. Nodes of this tree: the start depth and pointer x (x is\r\n * filled by the first move). Items from another list have no meaningful start here:\r\n * the last hovered row's level, from the pointer x when that row was entered.\r\n */\r\n base: { depth: number; x: number | null; key: Key | null };\r\n /** The active item entered from another list (possibly coming back): anchor on rows. */\r\n followRows: boolean;\r\n /**\r\n * Row whose middle band was hovered last, and the pointer x at that moment. Until\r\n * the pointer hovers another row, the offset rule counts from that row's child\r\n * depth, so the nested placeholder doesn't jump back while the pointer rests on it.\r\n */\r\n nest: { key: Key; x: number } | null;\r\n /** `nesting: 'hover'`: level asked for by the last hovered edge band. */\r\n hoverDepth: number;\r\n /** Keyboard: slot and depth chosen by the last arrow key, applied by the next move. */\r\n pending: { index: number; depth: number } | null;\r\n}\r\n\r\nexport interface DropInfo {\r\n from: Origin | null;\r\n to: Placement | null;\r\n}\r\n\r\nexport interface TreeContext<T> {\r\n id: Key;\r\n manager: DnDManager;\r\n group: SortableGroup;\r\n options: SortableTreeOptions<T>;\r\n accessors: TreeAccessors<T>;\r\n /** A shallow copy that `setChildren` gives the children: `{ ...node, children }` by default. */\r\n withChildren: (node: T, children: T[]) => T;\r\n /** Flattened only when the data or the collapsed set changes. */\r\n flat: ComputedRef<FlatTree<T>>;\r\n draft: ShallowRef<Key[] | null>;\r\n /** Where the dragged nodes would land here: depth, parent, index among the new siblings. */\r\n placement: ShallowRef<Placement | null>;\r\n /** The drag, from the moment it starts in the tree's group. */\r\n state: DragState | null;\r\n /** The projection behind `placement`, with its draft position. */\r\n spot: Spot | null;\r\n /** `from` and `to` of the drop being decided (see `tree/drop.ts`). */\r\n dropInfo: DropInfo | null;\r\n /** The nodes a drop would put here (see `incomingNodes`). */\r\n incoming: { slot: Key; items: T[]; height: number } | null;\r\n /** The move a drop's `next` makes here; the event's `from` and `to` come with it. */\r\n prepared: { next: Key[]; move: TreeMove<T> } | null;\r\n /** The tree in its group. */\r\n entry: ListEntry;\r\n}\r\n\r\nexport const source = <T>(t: TreeContext<T>) => read<readonly T[]>(t.options.items);\r\n\r\n// Options are read when needed, so a ref or a getter applies from then on.\r\nexport const indentation = <T>(t: TreeContext<T>) => read(t.options.indentation) ?? DEFAULT_INDENTATION;\r\n\r\nexport const nesting = <T>(t: TreeContext<T>) => read(t.options.nesting) ?? 'both';\r\n\r\n// The tree stays as it is; the line shows the drop.\r\nexport const indicating = <T>(t: TreeContext<T>) => read(t.options.placeholder) === 'indicator';\r\n\r\nexport const rows = <T>(t: TreeContext<T>) => t.flat.value.byKey;\r\n\r\n/** Key of the slot in the drafts: the lead, its copy, or the node made for a plain draggable. */\r\nexport const slotKey = <T>(t: TreeContext<T>, current: DragState) => t.group.session.value?.slot ?? current.lead;\r\n\r\n/** Copying: the dragged nodes stay where they are, their copies travel. */\r\nexport const copying = <T>(t: TreeContext<T>) => t.group.session.value?.mode.name === 'copy';\r\n\r\n/** Rows that travel with the drag (see `DragState.moving`); none while copying. */\r\nexport const movingRows = <T>(t: TreeContext<T>, current: DragState): KeySet =>\r\n copying(t) ? NO_ROWS : current.moving;\r\n\r\n/**\r\n * Rows the line never goes on (indicator mode): the travelling ones; while copying, the\r\n * originals, so a copy doesn't go into its own original just because the drag started\r\n * over it (the rows inside it take the copy).\r\n */\r\nexport const stillRows = <T>(t: TreeContext<T>, current: DragState): KeySet =>\r\n copying(t) ? current.origins : current.moving;\r\n\r\n/** Places the dragged nodes of this tree leave on drop; none while copying. */\r\nexport const leaving = <T>(t: TreeContext<T>, current: DragState): Origin[] =>\r\n copying(t) ? [] : [...current.origins.values()];\r\n\r\n/**\r\n * The nodes a drop would put here, for `canNest` and `maxDepth`: the dragged ones, their\r\n * copies, or the node `createItem` made; with the levels below the deepest of them\r\n * (collapsed ones included). Kept while the slot stays the same.\r\n */\r\nconst incomingNodes = <T>(t: TreeContext<T>) => {\r\n const session = t.group.session.value!;\r\n if (t.incoming?.slot !== session.slot) {\r\n const keys = session.keys.map((key) => session.mode.placed(session, key));\r\n const items = keys.map((key) => t.group.lookup(key) as T).filter((item) => item !== undefined);\r\n t.incoming = { slot: session.slot, items, height: blockHeight(items, t.accessors.getChildren) };\r\n }\r\n return t.incoming;\r\n};\r\n\r\nexport const depthFilter = <T>(t: TreeContext<T>): DepthFilter => {\r\n const { items, height } = incomingNodes(t);\r\n return blockFilter(items, height, rows(t), read(t.options.maxDepth), t.options.canNest);\r\n};\r\n\r\nexport const canNestInto = <T>(t: TreeContext<T>, key: Key) => {\r\n const row = rows(t).get(key);\r\n return !!row && depthFilter(t)(row.depth + 1, key);\r\n};\r\n\r\n/** The multi-drag block while it is in this tree (the slot alone in a single drag). */\r\nexport const blockHere = <T>(t: TreeContext<T>): Key[] => {\r\n const session = t.group.session.value;\r\n return session && session.list === t.id ? session.block : [];\r\n};\r\n\r\n/** Index of the slot in the draft as projection counts it (a block once); -1 when it isn't here. */\r\nexport const viewIndex = <T>(t: TreeContext<T>, current: DragState) => {\r\n const slot = slotKey(t, current);\r\n const at = t.draft.value ? t.group.indexOf(t.entry, slot) : -1;\r\n return at === -1 ? -1 : at - Math.max(blockHere(t).indexOf(slot), 0);\r\n};\r\n\r\nexport const setSpot = <T>(\r\n t: TreeContext<T>,\r\n current: DragState,\r\n position: DraftPosition,\r\n projection: TreeProjection,\r\n) => {\r\n t.spot = { position, projection };\r\n // Every dragged node of this tree leaves its place.\r\n const next: Placement = {\r\n ...projection,\r\n index: siblingIndexAt(position, projection, leaving(t, current)),\r\n };\r\n const previous = t.placement.value;\r\n if (\r\n !previous ||\r\n previous.depth !== next.depth ||\r\n previous.parentKey !== next.parentKey ||\r\n previous.index !== next.index\r\n ) {\r\n t.placement.value = next;\r\n }\r\n};\r\n\r\nexport const clearSpot = <T>(t: TreeContext<T>) => {\r\n t.spot = null;\r\n t.placement.value = null;\r\n};\r\n\r\nexport const place = <T>(t: TreeContext<T>, current: DragState, draftKeys: Key[], index: number, depth: number) => {\r\n const position: DraftPosition = { keys: draftKeys, index, rows: rows(t) };\r\n // An invalid slot (data that already breaks the rules) still gets the nearest depth.\r\n setSpot(t, current, position, projectDepth(position, depth, depthFilter(t)) ?? projectDepth(position, depth)!);\r\n};\r\n","/**\r\n * Applying a move to the user's tree: the moved nodes (each with its subtree) leave their\r\n * parents and land side by side under a new one, in place (`applyTreeMove`) or as a new\r\n * tree (`buildTreeMove`).\r\n */\r\n\r\nimport type { Key } from '../../types';\r\nimport type { TreeAccessors } from './flatten';\r\n\r\ninterface Located<T> {\r\n node: T;\r\n parent: T | null;\r\n index: number;\r\n}\r\n\r\n/** Depth-first search for `key`; O(N). */\r\nexport function findTreeNode<T>(\r\n roots: readonly T[],\r\n key: Key,\r\n { getKey, getChildren }: Pick<TreeAccessors<T>, 'getKey' | 'getChildren'>,\r\n): Located<T> | null {\r\n const stack: Array<{ siblings: readonly T[]; parent: T | null }> = [{ siblings: roots, parent: null }];\r\n while (stack.length) {\r\n const { siblings, parent } = stack.pop()!;\r\n for (let index = 0; index < siblings.length; index++) {\r\n const node = siblings[index]!;\r\n if (getKey(node) === key) return { node, parent, index };\r\n const children = getChildren(node);\r\n if (children?.length) stack.push({ siblings: children, parent: node });\r\n }\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * `findTreeNode` for several keys in one walk, in the same order: each key gets the node\r\n * `findTreeNode` would find for it. Stops once every key is found; O(N).\r\n */\r\nfunction locateTreeNodes<T>(\r\n roots: readonly T[],\r\n keys: readonly Key[],\r\n { getKey, getChildren }: Pick<TreeAccessors<T>, 'getKey' | 'getChildren'>,\r\n): Map<Key, Located<T>> {\r\n const wanted = new Set(keys);\r\n const found = new Map<Key, Located<T>>();\r\n const stack: Array<{ siblings: readonly T[]; parent: T | null }> = [{ siblings: roots, parent: null }];\r\n while (stack.length && found.size < wanted.size) {\r\n const { siblings, parent } = stack.pop()!;\r\n for (let index = 0; index < siblings.length; index++) {\r\n const node = siblings[index]!;\r\n const key = getKey(node);\r\n if (wanted.has(key) && !found.has(key)) {\r\n found.set(key, { node, parent, index });\r\n if (found.size === wanted.size) return found;\r\n }\r\n const children = getChildren(node);\r\n if (children?.length) stack.push({ siblings: children, parent: node });\r\n }\r\n }\r\n return found;\r\n}\r\n\r\nexport interface TreeMove<T> {\r\n /** Moved nodes in drop order, each with its subtree. */\r\n keys: readonly Key[];\r\n /** Node to insert for a key that isn't in the tree yet (it comes from another list). */\r\n node?: (key: Key) => T | undefined;\r\n /**\r\n * Where the first node lands, side by side with the rest (the index among the\r\n * siblings left once every moved node is out); `null` removes the nodes (they left\r\n * for another list).\r\n */\r\n to: { parentKey: Key | null; index: number } | null;\r\n}\r\n\r\n/**\r\n * The new children of every parent a move changes (`null`: the root array), read from\r\n * the nodes as they are; `null` for an invalid move (an unknown parent, or a parent\r\n * inside a moved subtree) or one that moves nothing. A moved node inside another moved\r\n * one leaves it.\r\n */\r\nfunction treeChanges<T>(\r\n roots: readonly T[],\r\n move: TreeMove<T>,\r\n accessors: Pick<TreeAccessors<T>, 'getKey' | 'getChildren'>,\r\n): Map<T | null, T[]> | null {\r\n // Found before anything moves: a moved node may sit inside another one. The new parent\r\n // is looked for in the same walk.\r\n const parentKey = move.to?.parentKey ?? null;\r\n const places = locateTreeNodes(roots, parentKey == null ? move.keys : [...move.keys, parentKey], accessors);\r\n const located = move.keys.map((key) => places.get(key) ?? null);\r\n const nodes = move.keys\r\n .map((key, i) => located[i]?.node ?? move.node?.(key))\r\n .filter((node): node is T => node !== undefined);\r\n if (!nodes.length) return null;\r\n\r\n let parent: T | null = null;\r\n if (move.to && move.to.parentKey != null) {\r\n parent = places.get(move.to.parentKey)?.node ?? null;\r\n if (parent === null || findTreeNode(nodes, move.to.parentKey, accessors)) return null;\r\n }\r\n\r\n const changes = new Map<T | null, T[]>();\r\n const childrenOf = (owner: T | null): readonly T[] =>\r\n changes.get(owner) ?? (owner === null ? roots : (accessors.getChildren(owner) ?? []));\r\n // Every parent drops all its moved children at once: the order of nested moves doesn't matter.\r\n const moved = new Set(nodes);\r\n for (const owner of new Set(located.flatMap((place) => (place ? [place.parent] : [])))) {\r\n changes.set(owner, childrenOf(owner).filter((child) => !moved.has(child)));\r\n }\r\n if (move.to) {\r\n const siblings = [...childrenOf(parent)];\r\n siblings.splice(Math.max(0, Math.min(move.to.index, siblings.length)), 0, ...nodes);\r\n changes.set(parent, siblings);\r\n }\r\n return changes;\r\n}\r\n\r\n/**\r\n * Moves nodes (each with its whole subtree) and returns the new root array. Children\r\n * arrays that change are replaced through `setChildren`; nodes are never copied, so\r\n * collapsed subtrees and the moved nodes' own children stay as they are. The root array\r\n * is always a new array, so `shallowRef` sources update too. Invalid moves return\r\n * `roots` unchanged.\r\n */\r\nexport function applyTreeMove<T>(roots: readonly T[], move: TreeMove<T>, accessors: TreeAccessors<T>): T[] {\r\n const changes = treeChanges(roots, move, accessors);\r\n if (!changes) return [...roots];\r\n for (const [owner, children] of changes) if (owner !== null) accessors.setChildren(owner, children);\r\n return changes.get(null) ?? [...roots];\r\n}\r\n\r\n/**\r\n * `applyTreeMove` without touching `roots`: a new tree in which every node on the path\r\n * to a changed parent is a copy (`withChildren`), the changed parents included. Other\r\n * subtrees, the moved nodes' own ones among them, are shared.\r\n */\r\nexport function buildTreeMove<T>(\r\n roots: readonly T[],\r\n move: TreeMove<T>,\r\n accessors: Pick<TreeAccessors<T>, 'getKey' | 'getChildren'> & { withChildren: (node: T, children: T[]) => T },\r\n): T[] {\r\n const { getChildren, withChildren } = accessors;\r\n const changes = treeChanges(roots, move, accessors);\r\n if (!changes) return [...roots];\r\n\r\n // Parents in the tree as it is: each changed parent and its ancestors get copies.\r\n const parents = new Map<T, T | null>();\r\n const stack: Array<{ siblings: readonly T[]; parent: T | null }> = [{ siblings: roots, parent: null }];\r\n while (stack.length) {\r\n const { siblings, parent } = stack.pop()!;\r\n for (const node of siblings) {\r\n parents.set(node, parent);\r\n const children = getChildren(node);\r\n if (children?.length) stack.push({ siblings: children, parent: node });\r\n }\r\n }\r\n const copied = new Set<T>();\r\n for (const owner of changes.keys()) {\r\n for (let node = owner; node !== null && !copied.has(node); node = parents.get(node) ?? null) copied.add(node);\r\n }\r\n\r\n // Bottom-up through the new shape, not the old depths: a moved node may land deeper.\r\n const childrenAfter = (node: T): readonly T[] => changes.get(node) ?? getChildren(node) ?? [];\r\n const copies = new Map<T, T>();\r\n const next = changes.get(null) ?? [...roots];\r\n const pending = next.filter((node) => copied.has(node)).map((node) => ({ node, open: false }));\r\n while (pending.length) {\r\n const top = pending[pending.length - 1]!;\r\n const children = childrenAfter(top.node);\r\n if (!top.open) {\r\n top.open = true;\r\n for (const child of children) if (copied.has(child)) pending.push({ node: child, open: false });\r\n continue;\r\n }\r\n pending.pop();\r\n copies.set(top.node, withChildren(top.node, children.map((child) => copies.get(child) ?? child)));\r\n }\r\n return next.map((node) => copies.get(node) ?? node);\r\n}\r\n","/**\r\n * The drop in a tree: the group's flat result becomes a move of nodes with their\r\n * subtrees (`TreeMove`), built as a new tree for `event.result` and applied through\r\n * `setChildren` by the default write. The event's `from` and `to` count among siblings.\r\n */\r\n\r\nimport type { Ref } from 'vue';\r\nimport type { Key, SortableDropEvent, SortableTreeDropEvent } from '../../types';\r\nimport { gapPosition, siblingIndexAt } from './depth';\r\nimport { applyTreeMove, buildTreeMove, type TreeMove } from './move';\r\nimport {\r\n indicating,\r\n movingRows,\r\n place,\r\n rows,\r\n setSpot,\r\n source,\r\n viewIndex,\r\n type DragState,\r\n type DropInfo,\r\n type Placement,\r\n type Spot,\r\n type TreeContext,\r\n} from './context';\r\n\r\n/** Where the dragged nodes would land in this tree, `null` when not here. */\r\nconst landingSpot = <T>(t: TreeContext<T>, current: DragState): Spot | null => {\r\n const { group, entry } = t;\r\n if (indicating(t)) {\r\n // No line: the lead's own place.\r\n if (!t.spot && current.origin) {\r\n const position = gapPosition(group.keysOf(entry), group.indexOf(entry, current.lead), movingRows(t, current), rows(t));\r\n setSpot(t, current, position, { depth: current.startDepth, parentKey: current.origin.parentKey });\r\n }\r\n return t.spot;\r\n }\r\n const index = viewIndex(t, current);\r\n if (index === -1) return null;\r\n // Projected again on the draft as it is now, at the last depth.\r\n place(t, current, group.viewOf(entry), index, t.placement.value?.depth ?? current.startDepth);\r\n return t.spot;\r\n};\r\n\r\n/**\r\n * What committing `next` does here (one list holds the slot, so nodes either land here\r\n * or leave): the nodes `inserted` at the slot land side by side at `to`, and the\r\n * dragged nodes of this tree leave their places, unless rejected back into them.\r\n */\r\nconst outcome = <T>(t: TreeContext<T>, current: DragState, next: Key[], inserted: readonly Key[]) => {\r\n const present = new Set(next);\r\n const landing = inserted.filter((key) => present.has(key));\r\n const removed = [...current.origins.keys()].filter((key) => landing.includes(key) || !present.has(key));\r\n const at = landing.length ? landingSpot(t, current) : null;\r\n const to: Placement | null = at && {\r\n ...at.projection,\r\n index: siblingIndexAt(at.position, at.projection, removed.map((key) => current.origins.get(key)!)),\r\n };\r\n return { landing, removed, to };\r\n};\r\n\r\nexport const hasChanges = <T>(t: TreeContext<T>, next: Key[], inserted: readonly Key[]) => {\r\n const current = t.state!;\r\n const { landing, removed, to } = outcome(t, current, next, inserted);\r\n // Nodes leave the tree, or the landing ones aren't already side by side right there.\r\n return (\r\n (!to && removed.length > 0) ||\r\n landing.some((key, i) => {\r\n const origin = current.origins.get(key);\r\n return !origin || origin.parentKey !== to!.parentKey || origin.index !== to!.index + i;\r\n })\r\n );\r\n};\r\n\r\n/** The move a drop's `next` makes here; the event's `from` and `to` come with it. */\r\nconst moveOf = <T>(\r\n t: TreeContext<T>,\r\n current: DragState,\r\n next: Key[],\r\n lookup: (key: Key) => unknown,\r\n inserted: readonly Key[],\r\n) => {\r\n const { landing, removed, to } = outcome(t, current, next, inserted);\r\n t.dropInfo = { from: current.origin, to };\r\n const move: TreeMove<T> = {\r\n keys: to ? landing : removed,\r\n node: (key) => lookup(key) as T | undefined,\r\n to: to && { parentKey: to.parentKey, index: to.index },\r\n };\r\n t.prepared = { next, move };\r\n return move;\r\n};\r\n\r\n/** The drop's `result` here: a new tree, the user's nodes untouched. */\r\nexport const build = <T>(t: TreeContext<T>, next: Key[], lookup: (key: Key) => unknown, inserted: readonly Key[]) => {\r\n const current = t.state;\r\n if (!current) return [...source(t)];\r\n return buildTreeMove(source(t), moveOf(t, current, next, lookup, inserted), { ...t.accessors, withChildren: t.withChildren });\r\n};\r\n\r\n/** The default write: the same move, through `setChildren`. */\r\nexport const commit = <T>(t: TreeContext<T>, next: Key[], lookup: (key: Key) => unknown, inserted: readonly Key[]) => {\r\n const current = t.state;\r\n if (!current) return;\r\n const move = t.prepared?.next === next ? t.prepared.move : moveOf(t, current, next, lookup, inserted);\r\n (t.options.items as Ref<T[]>).value = applyTreeMove(source(t), move, t.accessors);\r\n};\r\n\r\n/** Turns the group's flat indices into indices among siblings, plus parent keys. */\r\nconst toTreeEvent = <T>(event: SortableDropEvent, info: DropInfo | null): SortableTreeDropEvent<T> => {\r\n const treeEvent = event as SortableTreeDropEvent<T>;\r\n treeEvent.from.parentKey = info?.from?.parentKey ?? null;\r\n if (info?.from) treeEvent.from.index = info.from.index;\r\n treeEvent.to.parentKey = info?.to?.parentKey ?? null;\r\n if (info?.to) treeEvent.to.index = info.to.index;\r\n return treeEvent;\r\n};\r\n\r\nconst liveDropInfo = <T>(t: TreeContext<T>): DropInfo | null =>\r\n t.state ? { from: t.state.origin, to: landingSpot(t, t.state) && t.placement.value } : null;\r\n\r\n/** The user's `onBeforeDrop`: `result` was built for this event, its `from` and `to` go with it. */\r\nexport const beforeDrop = <T>(t: TreeContext<T>, event: SortableDropEvent) =>\r\n t.options.onBeforeDrop?.(toTreeEvent(event, t.dropInfo ?? liveDropInfo(t)));\r\n\r\n/** The user's `onDrop`, with the `from` and `to` of the move. */\r\nexport const afterDrop = <T>(t: TreeContext<T>, event: SortableDropEvent) => {\r\n const info = t.dropInfo;\r\n t.dropInfo = null;\r\n t.options.onDrop?.(toTreeEvent(event, info));\r\n};\r\n","/**\r\n * The layout of a tree for its group (`ListLayout`): the dragged nodes carry their\r\n * subtrees, and where they land has a depth, from the pointer's horizontal offset or\r\n * from hovering the middle of a row (`nesting`). In indicator mode the line shows it.\r\n */\r\n\r\nimport type { Coordinates, DnDEvent, Key } from '../../types';\r\nimport type { ListLayout } from '../layout';\r\nimport type { IndicatorProjection } from '../projection';\r\nimport { subtreeEnd } from './flatten';\r\nimport { gapPosition, nearestValidSlot, offsetDepth, projectDepth, type DraftPosition } from './depth';\r\nimport { projectTreeIndex, projectTreeIndicator } from './projection';\r\nimport {\r\n canNestInto,\r\n clearSpot,\r\n copying,\r\n depthFilter,\r\n indentation,\r\n indicating,\r\n movingRows,\r\n nesting,\r\n place,\r\n rows,\r\n setSpot,\r\n slotKey,\r\n stillRows,\r\n viewIndex,\r\n type DragState,\r\n type Origin,\r\n type TreeContext,\r\n} from './context';\r\nimport { hasChanges } from './drop';\r\n\r\n/**\r\n * Selected nodes inside another dragged node ride in its subtree, the grabbed one too\r\n * (VS Code): each → the outermost dragged node it is in.\r\n */\r\nconst carried = <T>(t: TreeContext<T>, dragged: readonly Key[]): Map<Key, Key> => {\r\n const all = new Set(dragged);\r\n const result = new Map<Key, Key>();\r\n for (const key of dragged) {\r\n let carrier: Key | undefined;\r\n for (let parent = rows(t).get(key)?.parentKey; parent != null; parent = rows(t).get(parent)?.parentKey) {\r\n if (all.has(parent)) carrier = parent;\r\n }\r\n if (carrier !== undefined) result.set(key, carrier);\r\n }\r\n return result;\r\n};\r\n\r\n/** Takes the dragged nodes of this tree, with the rows they carry. */\r\nconst begin = <T>(t: TreeContext<T>, lead: Key, dragged: readonly Key[], copied: boolean) => {\r\n const { nodes, byKey } = t.flat.value;\r\n const node = byKey.get(lead);\r\n const origins = new Map<Key, Origin>();\r\n const moving = new Map<Key, Key>();\r\n for (const key of dragged) {\r\n const row = byKey.get(key);\r\n if (!row) continue;\r\n origins.set(key, { parentKey: row.parentKey, index: row.index });\r\n moving.set(key, key);\r\n if (!row.hasChildren || row.collapsed) continue;\r\n // Every dragged node carries its subtree.\r\n const at = nodes.indexOf(row);\r\n for (let i = at + 1, end = subtreeEnd(nodes, at); i < end; i++) {\r\n if (!moving.has(nodes[i]!.key)) moving.set(nodes[i]!.key, key);\r\n }\r\n }\r\n const depth = node?.depth ?? 0;\r\n t.dropInfo = null;\r\n t.spot = null;\r\n t.incoming = null;\r\n t.state = {\r\n lead,\r\n origin: node ? { parentKey: node.parentKey, index: node.index } : null,\r\n origins,\r\n moving,\r\n startDepth: depth,\r\n base: { depth, x: null, key: null },\r\n // A drag from another list may enter this tree later, at the level of the rows it meets.\r\n followRows: !node,\r\n nest: null,\r\n hoverDepth: depth,\r\n pending: null,\r\n };\r\n // A single node starts where it is; a block takes its place on the first move, a copy once it is here.\r\n t.placement.value =\r\n node && dragged.length === 1 && !copied && !indicating(t) ? { depth, parentKey: node.parentKey, index: node.index } : null;\r\n};\r\n\r\n/** Re-anchors the offset rule on a newly hovered row (items entering from another list). */\r\nconst followRow = <T>(t: TreeContext<T>, current: DragState, key: Key | undefined, pointer: Coordinates) => {\r\n const row = key == null ? undefined : rows(t).get(key);\r\n if (current.followRows && row && row.key !== current.base.key) {\r\n current.base = { depth: row.depth, x: pointer.x, key: row.key };\r\n }\r\n};\r\n\r\n/** Depth the horizontal offset asks for, from the base (filled by the first move). */\r\nconst offsetFromBase = <T>(t: TreeContext<T>, current: DragState, event: DnDEvent) => {\r\n const base = current.base;\r\n base.x ??= event.pointer.x - event.delta.x;\r\n return offsetDepth(base.depth, event.pointer.x - base.x, indentation(t));\r\n};\r\n\r\n/** Depth of the row next to the slot at `index` of `view`: the one after it, else the one before. */\r\nconst levelAt = <T>(t: TreeContext<T>, view: Key[], index: number) => {\r\n const key = view[index + 1] ?? view[index - 1];\r\n return (key === undefined ? undefined : rows(t).get(key)?.depth) ?? 0;\r\n};\r\n\r\nconst afterMove = <T>(t: TreeContext<T>, event: DnDEvent) => {\r\n const current = t.state;\r\n if (!current || !t.draft.value || indicating(t)) return;\r\n const index = viewIndex(t, current);\r\n if (index === -1) return;\r\n const view = t.group.viewOf(t.entry);\r\n\r\n let depth: number;\r\n if (event.active.sensor === 'keyboard') {\r\n if (current.pending) {\r\n depth = current.pending.depth;\r\n current.pending = null;\r\n } else if (t.placement.value) {\r\n return;\r\n } else {\r\n // Taken in from outside (another list, a plain draggable): level with the rows there.\r\n depth = current.origin ? current.startDepth : levelAt(t, view, index);\r\n }\r\n } else {\r\n const nestRow = current.nest ? rows(t).get(current.nest.key) : undefined;\r\n if (nesting(t) === 'hover') {\r\n depth = nestRow ? nestRow.depth + 1 : current.hoverDepth;\r\n } else if (nestRow) {\r\n depth = offsetDepth(nestRow.depth + 1, event.pointer.x - current.nest!.x, indentation(t));\r\n } else {\r\n depth = offsetFromBase(t, current, event);\r\n }\r\n }\r\n place(t, current, view, index, depth);\r\n};\r\n\r\n// ─── Indicator mode ──────────────────────────────────────────────────────────\r\n\r\n/** The line at a gap (`position`) with the depth nearest to `depth` that fits; `null` when none does. */\r\nexport const lineAt = <T>(\r\n t: TreeContext<T>,\r\n current: DragState,\r\n position: DraftPosition,\r\n depth: number,\r\n line: IndicatorProjection,\r\n): IndicatorProjection | null => {\r\n const projection = projectDepth(position, depth, depthFilter(t));\r\n if (!projection) {\r\n clearSpot(t);\r\n return null;\r\n }\r\n setSpot(t, current, position, projection);\r\n return { ...line, ...projection };\r\n};\r\n\r\n/** The line before the row at a gap of `position` (which leaves the moving rows out), or after the last one. */\r\nexport const lineBefore = <T>(t: TreeContext<T>, { keys: others, index }: DraftPosition): IndicatorProjection => {\r\n const after = index >= others.length;\r\n const key = others[after ? others.length - 1 : index] ?? null;\r\n return { index: key == null ? 0 : t.group.indexOf(t.entry, key) + +after, key, side: after ? 'after' : 'before' };\r\n};\r\n\r\n/** The tree as its group lays it out (see `ListLayout`). */\r\nexport const treeLayout = <T>(t: TreeContext<T>): ListLayout => ({\r\n nested: true,\r\n carried: (dragged) => carried(t, dragged),\r\n prepareDraft: (draftKeys, { lead, keys: dragged, copying: copied }) => {\r\n // Once per drag: copying turning on or off asks again.\r\n if (t.state?.lead !== lead) begin(t, lead, dragged, copied);\r\n const current = t.state!;\r\n // The dragged nodes carry their subtrees: hide the visible descendants while they\r\n // move. Copied nodes stay as they are.\r\n if (copied || indicating(t) || current.moving.size === current.origins.size) return draftKeys;\r\n return draftKeys.filter((key) => current.moving.get(key) === undefined || current.origins.has(key));\r\n },\r\n project: (event, context) => {\r\n const keep = { index: null, lock: context.lock, key: null };\r\n const current = t.state;\r\n if (!current) return keep;\r\n if (event.active.sensor === 'keyboard') {\r\n // Arrow keys pick the slot themselves; the pointer only moves the overlay there.\r\n const pending = current.pending;\r\n return pending && pending.index !== context.activeIndex ? { ...keep, index: pending.index } : keep;\r\n }\r\n const result = projectTreeIndex({\r\n pointer: event.pointer,\r\n items: context.items,\r\n activeKey: context.activeKey,\r\n activeIndex: context.activeIndex,\r\n length: context.keys.length,\r\n canNestInto: nesting(t) === 'offset' ? undefined : (key) => canNestInto(t, key),\r\n // Copying, the originals hold the slot as the active row does (see `stillRows`).\r\n still: copying(t) ? current.origins : undefined,\r\n });\r\n const hitRow = result.hit ? rows(t).get(result.hit.key) : undefined;\r\n if (result.nest != null) {\r\n current.nest = { key: result.nest, x: event.pointer.x };\r\n } else if (hitRow) {\r\n current.nest = null;\r\n current.hoverDepth = hitRow.depth;\r\n }\r\n // The drag start in another list says nothing about depth here: re-anchor the\r\n // offset rule on every newly hovered row, at that row's level.\r\n if (context.activeIndex === -1) current.followRows = true;\r\n followRow(t, current, hitRow?.key, event.pointer);\r\n if (result.index == null) return keep;\r\n // A nest slot always fits. Otherwise stop at the last slot towards the pointer\r\n // where some depth satisfies `canNest` and `maxDepth`.\r\n const index =\r\n result.nest != null\r\n ? result.index\r\n : nearestValidSlot(context.keys, context.activeKey, context.activeIndex, result.index, rows(t), depthFilter(t));\r\n if (index == null) return keep;\r\n if (context.activeIndex === -1 && !hitRow) {\r\n // Entering an empty tree or a gap between rows: the root level, from here.\r\n current.base = { depth: 0, x: event.pointer.x, key: null };\r\n current.hoverDepth = 0;\r\n }\r\n return { ...keep, index };\r\n },\r\n indicate: (event, { items }) => {\r\n const current = t.state;\r\n if (!current) return undefined;\r\n const draftKeys = t.group.keysOf(t.entry);\r\n const own = !copying(t) && nesting(t) !== 'hover' ? items.find((item) => item.key === current.lead) : undefined;\r\n if (own && event.pointer.y >= own.rect.top && event.pointer.y <= own.rect.bottom) {\r\n // Over the dragged row itself, sideways nests it where it stands (or takes it out a\r\n // level): the line at its own place, once the offset asks for another depth.\r\n const position = gapPosition(draftKeys, own.index, movingRows(t, current), rows(t));\r\n const depth = projectDepth(position, offsetFromBase(t, current, event), depthFilter(t))?.depth;\r\n if (depth == null || depth === current.startDepth) {\r\n clearSpot(t);\r\n return null;\r\n }\r\n return lineAt(t, current, position, depth, lineBefore(t, position));\r\n }\r\n const line = projectTreeIndicator({\r\n pointer: event.pointer,\r\n items,\r\n activeKey: slotKey(t, current),\r\n length: draftKeys.length,\r\n moving: stillRows(t, current),\r\n canNestInto: nesting(t) === 'offset' ? undefined : (key) => canNestInto(t, key),\r\n });\r\n if (!line) {\r\n if (line === null) clearSpot(t);\r\n return line;\r\n }\r\n const row = line.key == null ? undefined : rows(t).get(line.key);\r\n let depth: number;\r\n if (line.side === 'inside') depth = row!.depth + 1;\r\n // 'hover': a sibling of the row the line is on.\r\n else if (nesting(t) === 'hover') depth = row?.depth ?? 0;\r\n else {\r\n followRow(t, current, row?.key, event.pointer);\r\n depth = offsetFromBase(t, current, event);\r\n }\r\n return lineAt(t, current, gapPosition(draftKeys, line.index, movingRows(t, current), rows(t)), depth, line);\r\n },\r\n // The keyboard enters the tree: the line at `index`, level with the row it goes on.\r\n indicateAt: (_keys, index) => {\r\n const current = t.state!;\r\n const position = gapPosition(t.group.keysOf(t.entry), index, movingRows(t, current), rows(t));\r\n const row = rows(t).get(position.keys[position.index] ?? position.keys[position.index - 1]!);\r\n return lineAt(t, current, position, row?.depth ?? 0, lineBefore(t, position));\r\n },\r\n afterMove: (event) => afterMove(t, event),\r\n placement: () => t.placement.value,\r\n hasChanges: (next, inserted) => hasChanges(t, next, inserted),\r\n reset: () => {\r\n t.state = null;\r\n t.spot = null;\r\n t.incoming = null;\r\n t.prepared = null;\r\n t.placement.value = null;\r\n },\r\n});\r\n","/**\r\n * Keyboard moves in a tree: rows and depth. The tree answers the keyboard itself (the\r\n * group's keyboard skips nested layouts): the arrow picks a row and a depth, and the next\r\n * move applies them (`DragState.pending`).\r\n */\r\n\r\nimport type { Coordinates, Key, KeyboardMoveContext } from '../../types';\r\nimport { getLayoutRect } from '../../animation/layout';\r\nimport { revealElement } from '../../core/autoscroll';\r\nimport { depthRange, gapPosition, moveKey, parentAt, projectDepth, type DraftPosition } from './depth';\r\nimport {\r\n blockHere,\r\n depthFilter,\r\n indentation,\r\n indicating,\r\n movingRows,\r\n rows,\r\n slotKey,\r\n viewIndex,\r\n type DragState,\r\n type Spot,\r\n type TreeContext,\r\n} from './context';\r\nimport { lineAt, lineBefore } from './layout';\r\n\r\n/**\r\n * Pointer that puts the overlay over the slot `index` (FLIP-free layout rects): the\r\n * lead's clone over it, `offset` away from the pointer (see `group.leadOffset`).\r\n */\r\nconst slotCoordinates = <T>(\r\n t: TreeContext<T>,\r\n current: DragState,\r\n view: Key[],\r\n from: number,\r\n next: { index: number; depth: number },\r\n pointer: Coordinates,\r\n x: number,\r\n offset: Coordinates,\r\n): Coordinates => {\r\n const rectOf = (key: Key | undefined) => {\r\n const element = key == null ? null : t.manager.getDraggable(key)?.getElement();\r\n return element?.isConnected ? getLayoutRect(element) : null;\r\n };\r\n const active = rectOf(slotKey(t, current));\r\n const passed = next.index === from ? null : rectOf(view[next.index]);\r\n if (!active || (next.index !== from && !passed)) return { x, y: pointer.y };\r\n // A multi-drag block moves as one: its first and last rows bound it.\r\n const block = blockHere(t);\r\n const first = rectOf(block[0]) ?? active;\r\n const last = rectOf(block[block.length - 1]) ?? active;\r\n let top = active.top;\r\n // Moving down, the passed row shifts up by the block: the block ends where the row ended.\r\n if (passed && next.index > from) top = passed.bottom - (last.bottom - active.top);\r\n else if (passed) top = passed.top + (active.top - first.top);\r\n // The keyboard drag starts at the row center, so the overlay's top follows `y - height / 2`.\r\n return { x, y: top + active.height / 2 - offset.y };\r\n};\r\n\r\n/**\r\n * Arrow keys: up/down move the slot by one visible row, keeping its depth where the\r\n * new neighbours allow it; left/right change the depth. In indicator mode the line\r\n * moves the same way, through the gaps between the rows that stay, skipping the\r\n * dragged node's own place at its own level (that drop would change nothing). A copy\r\n * or a created node moves like any node once it is here.\r\n */\r\nexport const keyboardCoordinates = <T>(\r\n t: TreeContext<T>,\r\n { active, pointer, direction }: KeyboardMoveContext,\r\n): Coordinates | undefined => {\r\n const { group, entry } = t;\r\n const current = t.state;\r\n const session = group.session.value;\r\n if (!current || !session || !t.draft.value || active.id !== session.activeKey) return undefined;\r\n const slot = session.slot;\r\n const draftKeys = group.keysOf(entry);\r\n const at = group.indexOf(entry, slot);\r\n const from = viewIndex(t, current);\r\n const view = group.viewOf(entry);\r\n let positionAt = (index: number): DraftPosition => ({\r\n keys: index === from ? view : moveKey(view, slot, from, index),\r\n index,\r\n rows: rows(t),\r\n });\r\n let base = current.pending ?? { index: from, depth: t.placement.value?.depth ?? current.startDepth };\r\n let end = view.length - 1;\r\n let home = -1;\r\n if (indicating(t)) {\r\n const shown = group.indicator.value;\r\n const mine = shown?.list === t.id ? shown : null;\r\n // The line is in another list, or the dragged node isn't here.\r\n if (!mine && (shown || at === -1)) return undefined;\r\n const moving = movingRows(t, current);\r\n const gaps = gapPosition(draftKeys, mine ? mine.index : at, moving, rows(t));\r\n positionAt = (index) => ({ ...gaps, index });\r\n base = { index: gaps.index, depth: mine ? mine.depth! : current.startDepth };\r\n end = gaps.keys.length;\r\n // One node moving: its own place at its own level changes nothing (a copy there does).\r\n if (at !== -1 && session.mode.name !== 'copy' && session.keys.length < 2) {\r\n home = gapPosition(draftKeys, at, moving, rows(t)).index;\r\n }\r\n } else if (from === -1) {\r\n return undefined;\r\n }\r\n const filter = depthFilter(t);\r\n\r\n let next: Spot | null = null;\r\n if (direction.y) {\r\n const step = direction.y > 0 ? 1 : -1;\r\n for (let index = base.index + step; index >= 0 && index <= end; index += step) {\r\n const position = positionAt(index);\r\n const projection = projectDepth(position, base.depth, filter);\r\n if (projection && (index !== home || projection.depth !== current.startDepth)) {\r\n next = { position, projection };\r\n break;\r\n }\r\n }\r\n } else if (direction.x) {\r\n // One level in or out, only when that exact level is allowed here.\r\n const position = positionAt(base.index);\r\n const depth = base.depth + (direction.x > 0 ? 1 : -1);\r\n const { min, max } = depthRange(position);\r\n const parentKey = parentAt(position, depth);\r\n if (depth >= min && depth <= max && filter(depth, parentKey)) next = { position, projection: { depth, parentKey } };\r\n }\r\n // Staying put still answers, so the sensor doesn't fall back to pixel steps.\r\n if (!next) return pointer;\r\n const { position, projection } = next;\r\n // The overlay shifts by the levels it changes (from where it is: a node from another\r\n // list or a created one came in over the tree).\r\n const x = pointer.x + (projection.depth - base.depth) * indentation(t);\r\n // The grabbed row may ride in the lead: the lead's clone goes over the slot.\r\n const offset = group.leadOffset();\r\n if (!indicating(t)) {\r\n current.pending = { index: position.index, depth: projection.depth };\r\n return slotCoordinates(t, current, view, from, current.pending, pointer, x, offset);\r\n }\r\n const line = lineAt(t, current, position, projection.depth, lineBefore(t, position))!;\r\n group.showIndicator({ list: t.id, ...line });\r\n // The overlay goes over the row with the line.\r\n const element = (line.key == null ? null : t.manager.getDraggable(line.key)?.getElement()) ?? entry.getElement();\r\n if (!element?.isConnected) return pointer;\r\n revealElement(element);\r\n const rect = getLayoutRect(element);\r\n return { x, y: rect.top + rect.height / 2 - offset.y };\r\n};\r\n","import { computed, isReadonly, isRef, onScopeDispose, shallowRef, unref } from 'vue';\r\nimport type {\r\n FlatNode,\r\n Key,\r\n MaybeElementRef,\r\n SortableGroupOptions,\r\n SortableTreeOptions,\r\n SortableTreeReturn,\r\n TreeProjection,\r\n} from '../types';\r\nimport { useManager } from '../core/context';\r\nimport { createDroppable } from '../core/makeDroppable';\r\nimport { createId, toElement } from '../utils/dom';\r\nimport { read } from '../utils/read';\r\nimport { useSortableGroup } from './group';\r\nimport { putAllows } from './accept';\r\nimport type { ListEntry } from './entry';\r\nimport { checkExternal, defaultGetKey, provideSortableContext, pullOf } from './makeSortableList';\r\nimport { createFlatTree, flattenTree, type TreeAccessors } from './tree/flatten';\r\nimport { blockHere, indicating, rows, source, type TreeContext } from './tree/context';\r\nimport { treeLayout } from './tree/layout';\r\nimport { afterDrop, beforeDrop, build, commit } from './tree/drop';\r\nimport { keyboardCoordinates } from './tree/keyboard';\r\n\r\nconst defaultGetChildren = (node: unknown): unknown[] | undefined =>\r\n node !== null && typeof node === 'object' ? (node as { children?: unknown[] }).children : undefined;\r\n\r\nconst defaultSetChildren = (node: unknown, children: unknown[]) => {\r\n (node as { children?: unknown[] }).children = children;\r\n};\r\n\r\n/**\r\n * Makes a container a sortable tree. Render the returned `items` (visible nodes in\r\n * draft order, indented by `depth`) with a row component that calls `makeSortableItem`.\r\n * On drop, after `onDrop`, the moved nodes (with their subtrees) are written into\r\n * `options.items`, unless `event.preventDefault()` leaves `event.result` to you.\r\n */\r\nexport function makeSortableTree<T>(\r\n target: MaybeElementRef,\r\n options: SortableTreeOptions<T>,\r\n): SortableTreeReturn<T> {\r\n const manager = useManager();\r\n const id = options.id ?? createId('tree');\r\n const groupOptions = typeof options.group === 'string' ? { name: options.group } : options.group;\r\n const group = useSortableGroup(manager, groupOptions?.name ?? `sortable:${id}`);\r\n checkExternal(options, 'tree');\r\n const accessors: TreeAccessors<T> = {\r\n getKey: (options.getKey ?? defaultGetKey) as (node: T) => Key,\r\n getChildren: (options.getChildren ?? defaultGetChildren) as (node: T) => T[] | undefined,\r\n setChildren: (options.setChildren ?? defaultSetChildren) as (node: T, children: T[]) => void,\r\n };\r\n const t: TreeContext<T> = {\r\n id,\r\n manager,\r\n group,\r\n options,\r\n accessors,\r\n withChildren:\r\n options.withChildren ??\r\n ((node: T, children: T[]): T => {\r\n const copy = { ...node };\r\n accessors.setChildren(copy, children);\r\n return copy;\r\n }),\r\n flat: computed(() =>\r\n createFlatTree(flattenTree(source(t), accessors.getKey, accessors.getChildren, read(options.collapsed))),\r\n ),\r\n draft: shallowRef<Key[] | null>(null),\r\n placement: shallowRef(null),\r\n state: null,\r\n spot: null,\r\n dropInfo: null,\r\n incoming: null,\r\n prepared: null,\r\n entry: null!,\r\n };\r\n const { flat, draft, placement } = t;\r\n const keys = computed(() => flat.value.nodes.map((node) => node.key));\r\n\r\n const entry: ListEntry = {\r\n id,\r\n draft,\r\n getElement: () => toElement(target),\r\n getKeys: () => keys.value,\r\n getItem: (key) => rows(t).get(key)?.item,\r\n layout: treeLayout(t),\r\n options,\r\n strategy: () => 'vertical',\r\n placeholder: () => read(options.placeholder) ?? 'item',\r\n animation: () => unref(options.animation) ?? manager.props.animation,\r\n animate: () => read(options.animateChanges) ?? manager.props.animateChanges,\r\n animateSize: () => read(options.animateSize) ?? true,\r\n isDisabled: () => !!read(options.disabled),\r\n canSort: () => true,\r\n pull: () => pullOf(groupOptions, !!options.clone),\r\n canPut: (context) => putAllows(groupOptions?.put as SortableGroupOptions['put'], context, manager),\r\n dropOutside: () => read(options.dropOutside) ?? (indicating(t) ? 'cancel' : 'placeholder'),\r\n multiple: () => 'group',\r\n acceptMode: () => read(options.acceptMode) ?? 'all',\r\n // A copy brings its subtree: `clone` copies the whole node.\r\n clone: options.clone\r\n ? (node) => {\r\n const copy = options.clone!(node as T);\r\n return { key: accessors.getKey(copy), item: copy };\r\n }\r\n : undefined,\r\n create: options.createItem\r\n ? (active) => {\r\n const node = options.createItem!(active);\r\n return node === undefined ? undefined : [{ key: accessors.getKey(node), item: node }];\r\n }\r\n : undefined,\r\n external: () => read(options.external),\r\n keyOf: (node) => accessors.getKey(node as T),\r\n isReadonly: () => !isRef(options.items) || isReadonly(options.items),\r\n build: (next, lookup, inserted) => build(t, next, lookup, inserted),\r\n commit: (_items, next, lookup, inserted) => commit(t, next, lookup, inserted),\r\n beforeDrop: (event) => beforeDrop(t, event),\r\n afterDrop: (event) => afterDrop(t, event),\r\n };\r\n t.entry = entry;\r\n onScopeDispose(group.addList(entry));\r\n group.animateChanges(entry);\r\n\r\n onScopeDispose(\r\n manager.addMonitor({\r\n getKeyboardCoordinates: (_event, context) => keyboardCoordinates(t, context),\r\n }),\r\n );\r\n\r\n // ─── Droppable, context, output ──────────────────────────────────────────────\r\n\r\n const droppable = createDroppable(\r\n // As lists: its `dropzone`, else its element.\r\n () => toElement(options.dropzone) ?? toElement(target),\r\n // Trees the current drag can never enter (a plain draggable without `createItem`)\r\n // are no drop targets, as lists.\r\n {\r\n id,\r\n label: options.label,\r\n data: options.data,\r\n disabled: () => !!read(options.disabled) || group.isInert(entry),\r\n // As a target: what the overlay shows over it, and how it lands in it.\r\n overOverlay: options.overOverlay,\r\n overDropAnimation: options.overDropAnimation,\r\n // Drags from outside the page it takes (with `createItem`).\r\n external: options.external,\r\n },\r\n { accepts: (active) => group.accepts(entry, active), getGroup: () => group.name },\r\n );\r\n\r\n // Read when a drag starts; `undefined` leaves the provider's.\r\n onScopeDispose(manager.registerAutoScroll(entry.getElement, () => read(options.autoScroll)));\r\n\r\n provideSortableContext(\r\n group,\r\n entry,\r\n accessors.getKey,\r\n options.overlay,\r\n options.dropAnimation,\r\n () => read(options.modifiers),\r\n () => read(options.axis),\r\n () => read(options.activation),\r\n );\r\n\r\n // The row a virtualizer must keep mounted. The session is mutated in place: a copy or a\r\n // created node is read from the slot's reactive mirror (the lead never changes).\r\n const activeKey = computed(() => {\r\n const current = group.session.value;\r\n if (!current) return null;\r\n const slot = manager.landingKey.value ?? current.lead;\r\n return group.indexOf(entry, slot) !== -1 ? slot : current.activeKey;\r\n });\r\n const inTree = computed(() => {\r\n const current = group.session.value;\r\n return !!current && draft.value != null && group.indexOf(entry, current.slot) !== -1;\r\n });\r\n const indicator = computed(() => {\r\n const value = group.indicator.value;\r\n return value?.list === id ? value : null;\r\n });\r\n\r\n /** A row for a node that isn't in this tree's data yet: from another list, a copy, a created node. */\r\n const newRow = (key: Key): FlatNode<T> => {\r\n const item = group.lookup(key) as T;\r\n const children = item === undefined ? undefined : accessors.getChildren(item);\r\n return { key, item, depth: 0, parentKey: null, index: 0, hasChildren: !!children?.length, collapsed: false };\r\n };\r\n\r\n const items = computed<FlatNode<T>[]>(() => {\r\n const order = draft.value;\r\n const { nodes, byKey } = flat.value;\r\n if (!order) return nodes;\r\n const current = t.state;\r\n let visible = order;\r\n // Indicator mode: a dragged node that went to another list takes its subtree along.\r\n if (indicating(t) && current) {\r\n visible = order.filter((key) => {\r\n const carrier = current.moving.get(key);\r\n return carrier === undefined || carrier === key || group.indexOf(entry, carrier) !== -1;\r\n });\r\n }\r\n const projection = indicating(t) ? null : placement.value;\r\n // The dragged nodes here (a multi-drag block) carry the projected depth, side by side.\r\n const block = new Map((projection ? blockHere(t) : []).map((key, index) => [key, index]));\r\n return visible.map((nodeKey) => {\r\n const node = byKey.get(nodeKey) ?? newRow(nodeKey);\r\n const at = block.get(nodeKey);\r\n return at === undefined ? node : { ...node, ...projection!, index: projection!.index + at };\r\n });\r\n });\r\n\r\n const activeIndex = computed(() => {\r\n const key = activeKey.value;\r\n return key == null ? -1 : items.value.findIndex((row) => row.key === key);\r\n });\r\n const activeSize = computed(() => group.session.value?.size ?? null);\r\n\r\n const projected = computed<TreeProjection | null>(() => {\r\n const projection = placement.value;\r\n // Indicator mode: the line's place, while it is in this tree.\r\n return projection && (indicating(t) ? indicator.value : inTree.value)\r\n ? { depth: projection.depth, parentKey: projection.parentKey }\r\n : null;\r\n });\r\n\r\n return {\r\n id,\r\n items,\r\n projected,\r\n indicator,\r\n isOver: droppable.isOver,\r\n isAccepting: droppable.isAccepting,\r\n activeKey,\r\n activeIndex,\r\n activeSize,\r\n captureLayout: group.captureLayout,\r\n };\r\n}\r\n","/**\r\n * Rubber-band selection (rfcs/0001-v3.md §4.5): a press on the empty space of an area\r\n * draws a rectangle, and the draggables it crosses are selected by id.\r\n *\r\n * The rectangle lives in the area's content coordinates (origin at the padding edge,\r\n * scroll offset included). The anchor therefore stays on the content when the area or\r\n * the page scrolls, and `style` places the rectangle with `position: absolute` inside\r\n * the area, which needs a non-static `position` (e.g. `relative`).\r\n */\r\n\r\nimport { computed, onScopeDispose, shallowRef, unref, watch } from 'vue';\r\nimport { defaultWindow, useEventListener } from '@vueuse/core';\r\nimport type {\r\n AcceptRule,\r\n Active,\r\n Coordinates,\r\n DragItem,\r\n Key,\r\n MaybeElementRef,\r\n Rect,\r\n SelectionAreaOptions,\r\n SelectionAreaReturn,\r\n SelectionModifier,\r\n SelectionStrategy,\r\n} from '../types';\r\nimport type { DnDManager, DraggableEntry } from './manager';\r\nimport { useManager } from './context';\r\nimport { matchesRule } from './accept';\r\nimport { matches } from './sensors/keyboard';\r\nimport { createRect, getLayoutRect, intersects, offsetRect } from '../animation/layout';\r\nimport { isInsideInteractive, parentOf, toElement } from '../utils/dom';\r\nimport { read } from '../utils/read';\r\n\r\n// ─── Geometry and strategies (pure) ────────────────────────────────────────────\r\n\r\n/** Where an area's content sits in the viewport and how far it is scrolled. */\r\nexport interface ContentBox {\r\n /** Viewport position of the padding edge, i.e. of content point (scrollLeft, scrollTop). */\r\n left: number;\r\n top: number;\r\n scrollLeft: number;\r\n scrollTop: number;\r\n /** Size of the scrollable content. */\r\n width: number;\r\n height: number;\r\n}\r\n\r\nexport const measureContentBox = (element: Element): ContentBox => {\r\n const rect = element.getBoundingClientRect();\r\n return {\r\n left: rect.left + element.clientLeft,\r\n top: rect.top + element.clientTop,\r\n scrollLeft: element.scrollLeft,\r\n scrollTop: element.scrollTop,\r\n width: element.scrollWidth,\r\n height: element.scrollHeight,\r\n };\r\n};\r\n\r\n/** Viewport point → content coordinates of the area. */\r\nexport const toContentPoint = (point: Coordinates, box: ContentBox): Coordinates => ({\r\n x: point.x - box.left + box.scrollLeft,\r\n y: point.y - box.top + box.scrollTop,\r\n});\r\n\r\n/** Content rect → viewport rect. */\r\nexport const toViewportRect = (rect: Rect, box: ContentBox): Rect =>\r\n offsetRect(rect, box.left - box.scrollLeft, box.top - box.scrollTop);\r\n\r\nconst clamp = (value: number, max: number) => Math.min(Math.max(value, 0), max);\r\n\r\n/** The band between two content points, clamped to the content. */\r\nexport const getBandRect = (\r\n anchor: Coordinates,\r\n current: Coordinates,\r\n bounds: Pick<ContentBox, 'width' | 'height'>,\r\n): Rect => {\r\n const left = clamp(Math.min(anchor.x, current.x), bounds.width);\r\n const top = clamp(Math.min(anchor.y, current.y), bounds.height);\r\n const right = clamp(Math.max(anchor.x, current.x), bounds.width);\r\n const bottom = clamp(Math.max(anchor.y, current.y), bounds.height);\r\n return createRect(left, top, right - left, bottom - top);\r\n};\r\n\r\nexport { intersects };\r\n\r\n/**\r\n * Selection for the current band. `hits` holds every item measured during this band\r\n * (`true` when inside it); items never measured keep their state, so the ids of\r\n * unmounted rows survive.\r\n * - `toggle`: XOR against the selection at band start;\r\n * - `select`: of the measured items, only those inside the band.\r\n */\r\nexport const applyStrategy = (\r\n strategy: SelectionStrategy,\r\n base: ReadonlySet<Key>,\r\n hits: ReadonlyMap<Key, boolean>,\r\n): Set<Key> => {\r\n const next = new Set(base);\r\n for (const [id, hit] of hits) {\r\n if (strategy === 'select' ? hit : base.has(id) !== hit) next.add(id);\r\n else next.delete(id);\r\n }\r\n return next;\r\n};\r\n\r\ntype ModifierState = Pick<MouseEvent, 'shiftKey' | 'ctrlKey' | 'altKey' | 'metaKey'>;\r\n\r\nconst FLAGS: Record<string, keyof ModifierState> = {\r\n Shift: 'shiftKey',\r\n Control: 'ctrlKey',\r\n Alt: 'altKey',\r\n Meta: 'metaKey',\r\n};\r\n\r\n/**\r\n * Whether `key` is held: a `KeyboardEvent.key` (`'Shift'`, `'Meta'`, `'a'`) or `.code`\r\n * (`'ControlLeft'`, `'KeyA'`). Modifiers come from the pointer event itself, so a key\r\n * released while the window was blurred never counts as held.\r\n */\r\nexport const isKeyHeld = (\r\n key: string,\r\n event: ModifierState,\r\n pressed: ReadonlySet<string>,\r\n): boolean => {\r\n const flag = FLAGS[key];\r\n if (flag) return event[flag];\r\n const side = /^(Shift|Control|Alt|Meta)(Left|Right)$/.exec(key);\r\n if (side) return event[FLAGS[side[1]!]!] && pressed.has(key);\r\n return pressed.has(key);\r\n};\r\n\r\nexport const matchesModifier = (\r\n modifier: SelectionModifier | undefined,\r\n held: (key: string) => boolean,\r\n): boolean => {\r\n if (!modifier?.keys.length) return true;\r\n return modifier.method === 'some' ? modifier.keys.some(held) : modifier.keys.every(held);\r\n};\r\n\r\n// ─── Areas ─────────────────────────────────────────────────────────────────────\r\n\r\n/** Area elements per provider: the innermost area owns a press and the items in it. */\r\nconst registries = new WeakMap<DnDManager, Set<Element>>();\r\n\r\nconst areasOf = (manager: DnDManager): Set<Element> => {\r\n let areas = registries.get(manager);\r\n if (!areas) registries.set(manager, (areas = new Set()));\r\n return areas;\r\n};\r\n\r\nconst closestArea = (element: Element | null, areas: ReadonlySet<Element>): Element | null => {\r\n for (let node = element; node; node = parentOf(node)) {\r\n if (areas.has(node)) return node;\r\n }\r\n return null;\r\n};\r\n\r\nconst isWithin = (element: Element, ancestor: Element): boolean => {\r\n for (let node = parentOf(element); node; node = parentOf(node)) {\r\n if (node === ancestor) return true;\r\n }\r\n return false;\r\n};\r\n\r\n/** A press on the area's own scrollbar scrolls; it must not draw a band. */\r\nconst isOnScrollbar = (element: HTMLElement, event: PointerEvent): boolean => {\r\n const rect = element.getBoundingClientRect();\r\n const x = event.clientX - rect.left - element.clientLeft;\r\n const y = event.clientY - rect.top - element.clientTop;\r\n return x > element.clientWidth || y > element.clientHeight;\r\n};\r\n\r\nconst suppressNextClick = () => {\r\n const stop = (event: Event) => {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n };\r\n window.addEventListener('click', stop, { capture: true, once: true });\r\n setTimeout(() => window.removeEventListener('click', stop, { capture: true }), 0);\r\n};\r\n\r\nconst syncSet = (target: Set<Key>, next: ReadonlySet<Key>) => {\r\n for (const id of [...target]) if (!next.has(id)) target.delete(id);\r\n for (const id of next) if (!target.has(id)) target.add(id);\r\n};\r\n\r\n/** Movement (px) below which a press counts as a click, not a band. */\r\nconst CLICK_TOLERANCE = 3;\r\n\r\ninterface Band {\r\n element: HTMLElement;\r\n pointerId: number;\r\n /** Start point in content coordinates: it stays on the content while things scroll. */\r\n anchor: Coordinates;\r\n origin: Coordinates;\r\n /** Latest pointer position in the viewport. */\r\n pointer: Coordinates;\r\n strategy: SelectionStrategy;\r\n accept: AcceptRule | undefined;\r\n base: Set<Key>;\r\n hits: Map<Key, boolean>;\r\n moved: boolean;\r\n frame: number;\r\n stops: Array<() => void>;\r\n}\r\n\r\n/**\r\n * Makes an element a rubber-band selection area for the draggables inside it.\r\n * Render the rectangle yourself: `<div v-if=\"isSelecting\" class=\"band\" :style=\"style\" />`.\r\n */\r\nexport function makeSelectionArea(\r\n target: MaybeElementRef,\r\n options: SelectionAreaOptions = {},\r\n): SelectionAreaReturn {\r\n const manager = useManager();\r\n const areas = areasOf(manager);\r\n const getElement = () => toElement(target);\r\n\r\n const selecting = shallowRef(false);\r\n const rect = shallowRef<Rect | null>(null);\r\n const pressed = new Set<string>();\r\n let band: Band | null = null;\r\n\r\n const readSelection = (): ReadonlySet<Key> => manager.selection;\r\n\r\n const writeSelection = (next: ReadonlySet<Key>) => syncSet(manager.selection, next);\r\n\r\n const accepts = (rule: AcceptRule | undefined, entry: DraggableEntry, element: HTMLElement, itemRect: Rect): boolean => {\r\n if (rule == null || rule === '*') return true;\r\n const item: DragItem = { id: entry.id, data: undefined, type: entry.getTypes() };\r\n // Only a function rule reads data; skip the lookups for type rules.\r\n if (typeof rule === 'function') {\r\n item.data = entry.getData();\r\n item.item = entry.getItem?.();\r\n }\r\n const active: Active = {\r\n id: entry.id,\r\n ids: [entry.id],\r\n items: [item],\r\n data: item.data,\r\n type: item.type,\r\n element,\r\n rect: itemRect,\r\n sensor: 'pointer',\r\n };\r\n return matchesRule(rule, { active, items: [item], types: item.type });\r\n };\r\n\r\n const update = () => {\r\n const current = band;\r\n if (!current) return;\r\n current.frame = 0;\r\n const area = current.element;\r\n\r\n // Reads first, in one pass: the area box, then every item rect.\r\n const box = measureContentBox(area);\r\n const next = getBandRect(current.anchor, toContentPoint(current.pointer, box), box);\r\n const viewportBand = toViewportRect(next, box);\r\n for (const entry of manager.getDraggables()) {\r\n const element = entry.getElement();\r\n if (!element?.isConnected || element === area) continue;\r\n // Outside this area, or owned by a nested one.\r\n if (closestArea(parentOf(element), areas) !== area) continue;\r\n if (entry.isDisabled()) continue;\r\n const itemRect = getLayoutRect(element);\r\n if (!itemRect.width && !itemRect.height) continue;\r\n if (!accepts(current.accept, entry, element, itemRect)) continue;\r\n current.hits.set(entry.id, intersects(viewportBand, itemRect));\r\n }\r\n\r\n rect.value = next;\r\n writeSelection(applyStrategy(current.strategy, current.base, current.hits));\r\n };\r\n\r\n const schedule = () => {\r\n if (band && !band.frame) band.frame = requestAnimationFrame(update);\r\n };\r\n\r\n /** Ends the band: `commit` keeps the selection and fires `onSelected`, otherwise it is restored. */\r\n const end = (commit: boolean) => {\r\n const current = band;\r\n if (!current) return;\r\n if (current.frame) cancelAnimationFrame(current.frame);\r\n current.frame = 0;\r\n if (commit) update();\r\n else writeSelection(current.base);\r\n\r\n band = null;\r\n current.stops.forEach((stop) => stop());\r\n if (document.body.hasPointerCapture?.(current.pointerId)) {\r\n document.body.releasePointerCapture(current.pointerId);\r\n }\r\n selecting.value = false;\r\n rect.value = null;\r\n if (manager.status.value === 'selecting') manager.status.value = manager.restStatus();\r\n if (!commit) return;\r\n\r\n if (current.moved) suppressNextClick();\r\n try {\r\n options.onSelected?.([...readSelection()]);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n };\r\n\r\n const cancel = () => end(false);\r\n\r\n const onPointerMove = (event: PointerEvent) => {\r\n const current = band;\r\n if (!current || event.pointerId !== current.pointerId) return;\r\n current.pointer = { x: event.clientX, y: event.clientY };\r\n const { x, y } = current.origin;\r\n if (!current.moved && Math.hypot(current.pointer.x - x, current.pointer.y - y) > CLICK_TOLERANCE) {\r\n current.moved = true;\r\n // Captured once it is a band, not at the press: a press that doesn't move stays a\r\n // click on what was pressed.\r\n try {\r\n document.body.setPointerCapture(current.pointerId);\r\n } catch {\r\n // The pointer may already be gone; document listeners still work.\r\n }\r\n }\r\n schedule();\r\n };\r\n\r\n const onPointerUp = (event: PointerEvent) => {\r\n if (!band || event.pointerId !== band.pointerId) return;\r\n band.pointer = { x: event.clientX, y: event.clientY };\r\n end(true);\r\n };\r\n\r\n const onPointerCancel = (event: PointerEvent) => {\r\n if (band && event.pointerId === band.pointerId) cancel();\r\n };\r\n\r\n const onKeyDown = (event: KeyboardEvent) => {\r\n const keyboard = manager.props.keyboard || undefined;\r\n if (!matches(keyboard?.keys?.cancel ?? ['Escape'], event)) return;\r\n event.preventDefault();\r\n cancel();\r\n };\r\n\r\n const preventDefault = (event: Event) => event.preventDefault();\r\n\r\n const begin = (area: HTMLElement, event: PointerEvent) => {\r\n const point = { x: event.clientX, y: event.clientY };\r\n const current: Band = {\r\n element: area,\r\n pointerId: event.pointerId,\r\n anchor: toContentPoint(point, measureContentBox(area)),\r\n origin: point,\r\n pointer: point,\r\n strategy: read(options.strategy) ?? 'toggle',\r\n accept: unref(options.accept),\r\n base: new Set(readSelection()),\r\n hits: new Map(),\r\n moved: false,\r\n frame: 0,\r\n stops: [],\r\n };\r\n band = current;\r\n manager.status.value = 'selecting';\r\n selecting.value = true;\r\n document.getSelection()?.removeAllRanges();\r\n current.stops.push(\r\n useEventListener(document, 'pointermove', onPointerMove),\r\n useEventListener(document, 'pointerup', onPointerUp),\r\n useEventListener(document, 'pointercancel', onPointerCancel),\r\n // Capture catches scrolling of any container, the page included.\r\n useEventListener(document, 'scroll', schedule, { capture: true, passive: true }),\r\n useEventListener(window, 'resize', schedule, { passive: true }),\r\n useEventListener(document, 'keydown', onKeyDown, { capture: true }),\r\n useEventListener(document, 'selectstart', preventDefault),\r\n useEventListener(document, 'dragstart', preventDefault),\r\n );\r\n update();\r\n };\r\n\r\n const onPointerDown = (event: PointerEvent) => {\r\n const area = getElement();\r\n // Overlays still landing don't hold a band back.\r\n if (!area || band || !manager.isAtRest()) return;\r\n if (!event.isPrimary || event.button !== 0 || read(options.disabled)) return;\r\n const origin = event.composedPath()[0];\r\n if (!(origin instanceof Element)) return;\r\n // The innermost area owns the press; items, controls and scrollbars keep theirs.\r\n if (closestArea(origin, areas) !== area) return;\r\n const found = manager.findDraggable(origin);\r\n if (found && isWithin(found.element, area)) return;\r\n if (isInsideInteractive(origin, area)) return;\r\n if (origin === area && isOnScrollbar(area, event)) return;\r\n if (!matchesModifier(read(options.modifier), (key) => isKeyHeld(key, event, pressed))) return;\r\n begin(area, event);\r\n };\r\n\r\n useEventListener(getElement, 'pointerdown', onPointerDown);\r\n\r\n // Keys that aren't modifier flags (e.g. `'KeyA'`) are tracked while the area lives.\r\n if ('modifier' in options) {\r\n useEventListener(defaultWindow, 'keydown', (event: KeyboardEvent) => {\r\n pressed.add(event.key);\r\n pressed.add(event.code);\r\n });\r\n useEventListener(defaultWindow, 'keyup', (event: KeyboardEvent) => {\r\n pressed.delete(event.key);\r\n pressed.delete(event.code);\r\n });\r\n useEventListener(defaultWindow, 'blur', () => pressed.clear());\r\n }\r\n\r\n // Tracked separately: the template ref may already be cleared when the scope is disposed.\r\n let registered: Element | null = null;\r\n watch(\r\n getElement,\r\n (element) => {\r\n if (registered) areas.delete(registered);\r\n registered = element;\r\n if (element) areas.add(element);\r\n if (band && band.element !== element) cancel();\r\n },\r\n { immediate: true, flush: 'post' },\r\n );\r\n\r\n watch(\r\n () => !!read(options.disabled),\r\n (disabled) => disabled && cancel(),\r\n );\r\n\r\n manager.selectionAborts.add(cancel);\r\n onScopeDispose(() => {\r\n cancel();\r\n manager.selectionAborts.delete(cancel);\r\n if (registered) areas.delete(registered);\r\n registered = null;\r\n });\r\n\r\n const style = computed((): Record<string, string> => {\r\n const value = rect.value;\r\n if (!value) return { display: 'none' };\r\n return {\r\n position: 'absolute',\r\n left: `${value.left}px`,\r\n top: `${value.top}px`,\r\n width: `${value.width}px`,\r\n height: `${value.height}px`,\r\n boxSizing: 'border-box',\r\n pointerEvents: 'none',\r\n };\r\n });\r\n\r\n return { isSelecting: computed(() => selecting.value), style };\r\n}\r\n","import { computed, onScopeDispose, shallowRef, watch } from 'vue';\r\nimport type { DragAreaOptions, DragAreaReturn, MaybeElementRef } from '../types';\r\nimport type { AreaEntry } from './manager';\r\nimport { useManager } from './context';\r\nimport { isPageRoot, readScrollStyle } from './autoscroll/dom';\r\nimport { parentOf, toElement } from '../utils/dom';\r\nimport { read } from '../utils/read';\r\n\r\n/** The container auto-scroll moves for `element`: the element itself or its closest scrollable ancestor. */\r\nconst scrollContainerOf = (element: Element): Element | null => {\r\n for (let node: Element | null = element; node && !isPageRoot(node); node = parentOf(node)) {\r\n const style = readScrollStyle(node);\r\n if (style.x || style.y) return node;\r\n }\r\n return null;\r\n};\r\n\r\n/**\r\n * Makes an element a drag area: the drags that start inside it (draggables and sortable\r\n * items) follow its rules, see `DragAreaOptions`. One provider can then serve the whole\r\n * app, with boards, canvases and feeds that drag their own way. The closest area wins\r\n * when areas are nested.\r\n */\r\nexport function makeDragArea(target: MaybeElementRef, options: DragAreaOptions = {}): DragAreaReturn {\r\n const manager = useManager();\r\n const getElement = () => toElement(target);\r\n\r\n const entry: AreaEntry = {\r\n getElement,\r\n isDisabled: () => !!read(options.disabled),\r\n getActivation: () => read(options.activation),\r\n getModifiers: () => read(options.modifiers),\r\n getAxis: () => read(options.axis),\r\n restricts: () => !!read(options.restrictToArea),\r\n };\r\n\r\n let bound: HTMLElement | null = null;\r\n const unbind = () => {\r\n if (bound) manager.unbindArea(bound, entry);\r\n bound = null;\r\n };\r\n watch(\r\n getElement,\r\n (element) => {\r\n unbind();\r\n if (!element) return;\r\n manager.bindArea(element, entry);\r\n bound = element;\r\n },\r\n { immediate: true, flush: 'post' },\r\n );\r\n onScopeDispose(unbind);\r\n onScopeDispose(manager.registerAutoScroll(getElement, () => read(options.autoScroll)));\r\n\r\n // The area the dragged element was in when the drag started: it may leave it since.\r\n const startedHere = shallowRef(false);\r\n onScopeDispose(\r\n manager.addMonitor({\r\n onDragStart: ({ active }) => {\r\n startedHere.value = manager.findArea(active.element) === entry;\r\n },\r\n }),\r\n );\r\n const isDragging = computed(() => startedHere.value && !!manager.active.value);\r\n\r\n const isAutoScrolling = computed(() => {\r\n const scrollers = manager.autoScrollers.value;\r\n const element = getElement();\r\n if (!scrollers.length || !element) return false;\r\n const container = scrollContainerOf(element);\r\n return !!container && scrollers.includes(container);\r\n });\r\n\r\n return { isDragging, isAutoScrolling };\r\n}\r\n"],"names":["uid","createId","prefix","getCurrentInstance","useId","isClient","ELEMENT_NODE","fragmentEnd","value","instance","tree","toElement","target","node","unrefElement","end","toValue","next","parentOf","element","containsComposed","ancestor","getEventTarget","event","elementFromPoint","x","y","inner","elementBelow","skip","below","EDITABLE","INTERACTIVE","FOCUSABLE","isInsideInteractive","container","interactive","isEditable","isNativelyFocusable","isFocusLost","focused","FRAME_TIMEOUT","nextFrame","resolve","done","frame","timer","layoutAnimations","isRunning","animation","isAnimation","noop","ended","result","finished","STALL_MARGIN","settle","timeout","DEFAULT_LAYOUT_ANIMATION","createRect","left","top","width","height","toRect","rect","getRect","offsetRect","intersectRect","a","b","right","bottom","intersects","unionRect","expandRect","containsPoint","point","getCenter","distance","getWindowRect","getFraction","resizeAround","size","fraction","parseTranslate","getLayoutRect","layoutShifts","shifts","getSettledRect","offset","prefersReducedMotion","canAnimate","resolveAnimation","option","defaults","options","cancelTransformTransitions","elements","targets","roots","root","release","state","stopLayoutAnimation","track","trackAnimation","abort","tracked","trackCustom","settled","sameRect","flip","batches","reason","entries","entry","runs","resolved","measured","run","reducedMotion","index","key","first","crossing","at","last","running","passing","dx","dy","fadeIn","NEAR_VIEWPORT","ROOT","FIXED","clipsOverflow","createMeasurer","active","generation","flags","chains","scroll","clips","nearRegions","windowScroll","viewport","observer","sizes","shadowRoots","onShadowScroll","watchShadowRoot","clearFrame","prepare","flagsOf","style","boxed","paint","clipsContent","own","withSticky","chain","sticky","chainBelow","outer","clipping","chainOf","scrollOf","scroller","windowOffset","record","offsets","entryOf","exact","measureDelta","now","rectOf","viewportRect","clipOf","cached","border","client","box","clipX","clipY","measure","measureVisible","clip","nearRegionOf","margin","region","isNearViewport","invalidate","reset","onResize","observe","records","changed","contentRect","NO_LANDINGS","createDragState","shallowRef","shallowReactive","owners","live","checkShared","kind","map","previous","nextTick","before","after","effect","createRegistry","draggables","droppables","draggableIds","monitors","integrations","sourceResolvers","targetRules","announcers","destinationResolvers","activationAborts","autoScrollEntries","selectionAborts","owner","areas","areaCount","areasVersion","registerDraggable","registerDroppable","bindDraggableElement","id","unbindDraggableElement","findDraggable","elementOwner","bindArea","unbindArea","walkAreas","visit","area","getElement","getOptions","monitor","integration","resolver","rule","announcer","destination","DEFAULT_INSTRUCTIONS","item","Item","over","defaultAnnouncements","VISUALLY_HIDDEN","OVER_ANNOUNCE_DELAY","positionInTarget","createEvents","ctx","announceTimer","lastAnnouncement","positionIn","current","createEvent","origin","p","source","position","orderMonitors","integrationsFirst","rank","emit","name","error","setAnnouncement","text","announcement","custom","described","context","LIMIT","SHOWN","names","list","INHERITED","LOOK","RESOLVED","SIZES","read","into","collect","clone","parent","child","copy","readCustom","readSource","look","computedValue","compare","pass","passes","writes","from","inherited","computed","snapshotMany","jobs","all","job","hosts","host","write","radioGroup","copyFormState","sourceFields","cloneFields","suffix","field","copyCanvases","sourceCanvases","cloneCanvases","canvas","wrapTableRow","row","table","body","sourceCells","cell","PRESS_EFFECTS","leftOut","removeTransient","copyElement","clonePreview","clonePreviews","property","sources","mount","positioned","DEFAULT_PREVIEWS","FIT_MIN_RATIO","RESIZE_DURATION","createOverlay","previews","previewIds","previewEnabled","grab","containerStart","sourceModifiers","resize","overlayContainer","to","sourceOf","takePreview","takePreviews","order","wanted","limit","ids","missing","clones","getOverlayRect","getModifiers","modifiers","shiftOf","containerRect","applyModifiers","containerShift","modifier","overlay","fitSize","slot","sourceWidth","sourceHeight","shown","start","progress","eased","caught","browser","preview","coordinates","intersectionRatio","intersection","pointerWithin","hits","rectIntersection","overlayRect","candidates","candidate","closestCenter","pointer","center","corners","closestCorners","score","sum","corner","pointerFirst","args","within","HYSTERESIS","createTargetStabilizer","recent","createDetection","stabilizer","nesting","owned","hitTest","byElement","depth","depthOf","isOwned","flight","measurer","external","hidden","ranked","visible","parentElement","childElement","bounds","DEFAULT_PATTERNS","resolveHaptic","byDefault","vibrate","touch","pattern","samePoint","createFrameLoop","detectedAt","detectedRaw","refreshRequested","runFrame","raw","refresh","pickup","events","requestFrame","DEFAULT_DROP_ANIMATION","INTO_SCALE","INTO_STAGGER","INTO_SPREAD","intoStagger","count","CONTENT_WAIT","contentAnimations","runDropAnimation","delay","full","keyframes","companionTiming","c","d","e","f","opacity","placeOf","linear","w","h","landOverlayItems","items","timing","places","landed","finish","intoOverlayItems","step","way","base","fadeInPlace","opacities","BEHAVIOR_ID","LOOKS_ID","BEHAVIOR","LOOKS","inject","css","injectDefaultStyles","looks","PRESS_CURSORS","dragCursor","grabbed","cursor","markDocumentDragging","sensor","preventSelection","toVerdict","isFinal","verdict","round","createFollow","getBox","anchor","shares","unstarted","shift","place","leftover","frames","carried","share","pending","part","moved","halt","taken","FOCUS_FRAMES","createSession","session","waiting","releasedTo","releasedTarget","targetOverlay","restoreDocument","restStatus","isAtRest","status","buildItems","updateActive","patch","caughtAt","hit","move","restoreFocus","attempt","retry","clear","handOff","mode","landingKey","land","faded","landingRect","clonesOf","landItems","slotOf","elementOf","resting","released","dropAnimationOf","landing","zone","going","conclude","abortPending","aborts","cancel","resume","drop","accepted","endEvent","createDnDManager","props","lookups","members","detection","loop","told","warnIfDeciding","manager","asked","DND_CONTEXT","useManager","useDnDContext","provideDnDContext","app","createSelection","set","force","useDnD","readonly","useDnDMonitor","onScopeDispose","devtoolsHook","DEFAULT_ACTIVATION","DEFAULT_TOLERANCE","resolveActivation","provider","onHandle","resolveConstraint","activation","checkActivation","constraint","elapsed","required","tolerance","canStartFrom","type","handle","handleElement","leavePressed","pressed","init","dispatch","bubbles","Event","DEFAULT_AUTO_SCROLL","MIN_EDGE","MAX_EDGE","CROSS_AXIS_TOLERANCE","INTENT_DISTANCE","getEdgeSize","threshold","getEdgeSpeed","acceleration","maxSpeed","curve","axisVelocity","backward","forward","edge","getScrollVelocity","canScroll","intent","t","besideX","createScrollIntent","updateScrollIntent","min","max","directions","mergeOptions","resolveAutoScrollOptions","override","getRevealDelta","view","axis","viewStart","viewEnd","OVERFLOW","readScrollStyle","flex","hasSnapping","isPageRoot","room","reversed","low","high","clientRect","measureElement","maxX","maxY","up","down","readPageScroll","allowed","measureWindow","page","scrollBy","revealElement","delta","FRAME_MS","MAX_FRAME_MS","useAutoScroll","styleOf","isScrollContainer","addScrollers","suspendSnapping","snaps","restoreSnapping","priority","remainder","isPointerDrag","tick","picked","consider","velocity","scale","scrolled","autoScrollers","i","stop","watch","dragging","DEFAULT_STEP","FAST_STEP_FACTOR","MIN_JUMP","DIRECTIONS","ARROW_KEYS","arrowEvent","direction","fast","pickInDirection","best","bestScore","along","visibleCenter","findDroppable","overId","moveNow","report","createSensorDrag","setup","callbacks","started","dropped","startedAt","queue","queued","enqueue","task","fallback","isLive","stopTracking","drag","startNow","evaluate","trackDelay","begin","findTarget","found","createHost","control","forget","activate","scope","effectScope","cleanup","hostOf","useSensors","useEventListener","defaultDocument","sensors","useSensor","defineSensor","ITEMS_TYPE","HINT_PREFIX","HINT_LIMIT","toHex","byte","fromHex","hex","bytes","writeRemote","transfer","payload","json","hint","readRemoteHint","types","readRemote","carries","readHeld","group","fileTypes","tokensOf","accept","token","takesFile","file","tokens","takesExternal","files","readDropped","data","uriList","line","externalItems","externalLabel","made","allows","pointOf","remoteItems","idOf","useNativeDrags","madeDraggable","undoDraggable","ours","effectOf","copyKey","onPointerDown","startOwn","native","label","onDragEnd","onDragStart","probe","startExternal","remote","standIn","unregister","onDragEnter","onDragOver","onDragLeave","onDrop","onPointerMove","defaultWindow","CLICK_SUPPRESS_MS","CLICK_TOLERANCE","pointerKind","suppressNextClick","USER_SELECT","isUnselectable","makeSelectableForPress","saved","restored","pointerSensor","press","capture","pointerId","isOurs","onPointerUp","onPointerCancel","preventWhileActive","cancelSelection","preventTouchScroll","onCarriedDown","carry","stops","DEFAULT_KEYS","ARROWS","matches","bindings","consume","keyboardSensor","keys","restrictToRect","transform","baseRect","restrictToVerticalAxis","restrictToHorizontalAxis","withAxis","dragModifiers","restrictToElement","restrictToWindowEdges","windowRect","restrictToParent","isScrollable","scrollableAncestors","restrictToFirstScrollableAncestor","DEFAULT_SMOOTH","snap","snapToGrid","sx","sy","smooth","getOverlaySmoothing","snapCenterToCursor","OVERLAY_SCOPE","dragScope","flightScope","useOverlayScope","provided","DragPreview","defineComponent","slots","attach","column","getPreview","lands","onMounted","onBeforeUnmount","BADGE_STYLE","FILL","PILE","DefaultPreview","cells","register","plain","behind","rotate","isEmpty","nodes","isVNode","Comment","Fragment","overlayProps","component","declared","renderOverlay","content","CROSSFADE","crossfade","DEFAULT_TRANSITION","componentKeys","lastComponentKey","keyOf","transitionable","CONTENT_STYLE","boxStyle","OverlayBox","attrs","provide","DragOverlay","_","setElement","views","viewOf","transition","glide","landingTo","renderOwn","change","Transition","cloneVNode","dragBox","boxes","DEFAULT_SENSORS","LiveRegion","DnDProvider","_event","mounted","Teleport","normalizeTypes","itemMatches","partitionByRule","rejected","matchesRule","toOverlay","markRaw","ownedAttributes","ownsAttribute","setOwnAttribute","removeOwnAttribute","DESCRIBED_BY","describedBy","idsOf","appendId","describedByObserver","addDescription","removeDescription","rest","releaseAttributes","hasButtonRole","applyStaticAttributes","instructionsId","roleDescription","createDraggable","internals","fallbackId","getHandleElement","unref","preventNativeDrag","bound","unbind","currentId","attributeTarget","watchEffect","isDragging","selected","makeDraggable","createDroppable","accepts","isOver","isAccepting","placement","makeDroppable","changedRun","shared","nextEnd","patchIndexMap","createContext","sameKeys","keysOf","isForeign","g","listOf","listLabel","itemLabel","spotIn","indexMap","indicesOf","draft","indexOf","lookup","snapshot","listOfKey","useDraft","orderedLists","putAllows","put","itemTypes","partition","partitionMoved","none","isInert","isSwapping","canSwap","partner","MAX_GHOSTS","collapseIntoOverlay","ghosts","ghost","remove","expand","block","pickUp","ordered","lists","activeKey","ridesIn","carrier","lead","originList","dragItems","others","multiple","stacked","grouped","gather","scatter","blockFor","withoutBlock","moving","putBack","original","indices","side","layoutPile","layoutCells","layoutColumn","gap","ratio","lengths","badgeAt","badges","ColumnPreview","toWidth","toHeight","inTarget","band","AXES","axisOf","strategy","inBand","projectEdges","activeIndex","length","blockOf","stepList","neighbour","stepGrid","lock","projectList","keep","projectGrid","locked","projectIndex","projectIndicator","alongX","hitItem","projectSwap","nextRowIndex","pickAdjacent","across","NEST_BAND","inNestBand","rowUnder","projectTreeIndex","canNestInto","still","projectTreeIndicator","dropBand","dropBandPoint","bandsAt","targetRule","acceptsAt","accepting","listAccepts","isInto","intoPoint","subject","capital","listName","where","swapped","sortableTexts","who","spot","spotKey","subjectOf","targetName","spotOf","contextOf","partnerOf","pickedUpAt","formed","endAnnouncement","committed","cancelAnnouncement","createAnnouncer","nearLastTarget","MAX_KEYS","passedKeys","neighbourKeys","settleHysteresis","hysteresis","blocksKey","blocksList","NO_OFFSET","setLandings","gapOf","columnIds","syncColumn","destinationOf","sameDestination","stableDestination","syncManager","placed","goingBack","kept","landCancel","landDrop","leadOffset","atLead","inView","held","captureSizes","cssSize","animateSizes","duration","easing","MAX_DRIFT","NO_KEYS","probeList","scrollLeft","scrollTop","slackX","slackY","driftFor","counts","fewest","holds","near","probes","animate","fresh","fadeAppearing","byList","add","appearing","back","bump","watchLayout","captureLayout","moveActive","blockStart","passed","old","leaving","joining","removeSlot","returnToOrigin","takeApart","regather","goHome","keepSlotHome","INDICATOR_FIELDS","sameIndicator","setIndicator","showIndicator","swapMark","updateIndicator","markSwapAt","indicateAt","resolveAutoAnimation","parts","enter","GHOST_STYLE","leave","copies","nearRegion","created","play","moves","comeBack","entering","regions","watchChanges","on","MODIFIERS","trackers","createTracker","onKey","onPointer","onBlur","listeners","listening","listen","listener","useCopyModifier","tracker","enters","movingDragMode","itself","_g","_current","asItself","applySwap","other","j","updateSwap","swap","modeOf","heldBack","sortOver","blocked","sameList","projection","sort","clamp","insertionIndex","adjacentList","slotCenter","recreated","enterNearest","indicateAcross","home","keyboardIndicator","marker","level","jumpAway","getKeyboardCoordinates","stay","slotRect","onward","away","reached","copyOf","wantsCopy","draftContext","copyBase","startCopy","switchCopy","copying","present","syncCopy","mayMake","makeFor","createdIn","remake","startInsert","common","insert","local","sendHome","standsApart","afterMove","followBlock","settleBlock","isPromise","placeAt","dropResult","inserted","facts","find","built","computeResult","drafts","strip","finalKeys","computeRemoval","gone","isOutside","withPartial","partial","decide","elsewhere","outside","beforeDrop","prepared","unchanged","clampIndex","registries","createGroup","removeMonitor","removeAnnouncer","removeRule","removeDestination","removeSource","useSortableGroup","groups","existing","NO_CARRIERS","nothing","flatLayout","_inserted","SORTABLE_CONTEXT","scopes","contexts","defaultGetKey","provideSortableContext","getKey","dropAnimation","getAxis","getActivation","withHidden","stayed","warnedClone","pullOf","canClone","pull","checkExternal","makeSortableList","groupOptions","byKey","isRef","isReadonly","droppable","rendered","activeSize","indicator","makeSortableItem","draggable","isPlaceholder","isLeftBehind","flattenTree","getChildren","collapsed","stack","children","isCollapsed","createFlatTree","subtreeEnd","blockHeight","subtreeHeight","blockFilter","rows","maxDepth","canNest","parentKey","rowAt","depthRange","prev","ancestorChain","want","parentAt","offsetDepth","baseDepth","offsetX","indentation","projectDepth","filter","nearestValidSlot","fits","siblingIndexAt","origins","gapPosition","moveKey","DEFAULT_INDENTATION","NO_ROWS","indicating","slotKey","movingRows","stillRows","incomingNodes","depthFilter","blockHere","viewIndex","setSpot","clearSpot","draftKeys","findTreeNode","siblings","locateTreeNodes","treeChanges","accessors","located","changes","childrenOf","applyTreeMove","buildTreeMove","withChildren","parents","copied","childrenAfter","landingSpot","outcome","removed","hasChanges","moveOf","build","commit","toTreeEvent","info","treeEvent","liveDropInfo","afterDrop","dragged","followRow","offsetFromBase","levelAt","nestRow","lineAt","lineBefore","treeLayout","hitRow","_keys","slotCoordinates","keyboardCoordinates","positionAt","mine","gaps","defaultGetChildren","defaultSetChildren","makeSortableTree","flat","_items","inTree","newRow","nodeKey","projected","measureContentBox","toContentPoint","toViewportRect","getBandRect","applyStrategy","FLAGS","isKeyHeld","flag","matchesModifier","areasOf","closestArea","isWithin","isOnScrollbar","syncSet","makeSelectionArea","selecting","readSelection","writeSelection","itemRect","update","viewportBand","schedule","onKeyDown","keyboard","preventDefault","registered","disabled","scrollContainerOf","makeDragArea","startedHere","isAutoScrolling","scrollers"],"mappings":"iIAIA,IAAIA,GAAM,EAOH,MAAMC,GAAYC,GACvB,GAAGA,CAAM,IAAIC,EAAAA,mBAAA,EAAuBC,EAAAA,MAAA,EAAU,EAAEJ,EAAG,GAExCK,GAAW,OAAO,OAAW,IAEpCC,GAAe,EAOfC,GAAeC,GAA4C,CAC/D,MAAMC,EAAYD,GAAmD,EACrE,GAAI,CAACC,EAAU,OACf,IAAIC,EAA0BD,EAAS,QACvC,KAAOC,GAAM,WAAWA,EAAOA,EAAK,UAAU,QAC9C,OAAQA,GAAM,QAAsC,IACtD,EAUaC,GAAaC,GAAgD,CACxE,MAAMC,EAAOC,EAAAA,aAAaF,CAA4C,EACtE,GAAI,CAACC,EAAM,OAAO,KAClB,GAAIA,EAAK,WAAaP,GAAc,OAAOO,EAC3C,MAAME,EAAMR,GAAYS,EAAAA,QAAQJ,CAAM,CAAC,EAEvC,GAAIG,IAAQ,KAAM,OAAO,KACzB,QAASE,EAAOJ,EAAK,YAAaI,GAAQA,IAASF,EAAKE,EAAOA,EAAK,YAClE,GAAIA,EAAK,WAAaX,GAAc,OAAOW,EAE7C,OAAO,IACT,EAOaC,EAAYC,GACvBA,EAAQ,cACRA,EAAQ,eACNA,EAAQ,cAA6B,MACvC,KAGWC,GAAmB,CAACC,EAAmBR,IAA2B,CAC7E,GAAIQ,EAAS,SAASR,CAAI,EAAG,MAAO,GAEpC,GAAIQ,EAAS,YAAA,IAAkBR,EAAK,YAAA,EAAe,MAAO,GAC1D,QAASM,EAAUD,EAASL,CAAI,EAAGM,EAASA,EAAUD,EAASC,CAAO,EACpE,GAAIA,IAAYE,EAAU,MAAO,GAEnC,MAAO,EACT,EAGaC,GAAkBC,GAC7BA,EAAM,iBAAiB,CAAC,GAAKA,EAAM,OAGxBC,GAAmB,CAACC,EAAWC,IAA8B,CACxE,IAAIP,EAAU,SAAS,iBAAiBM,EAAGC,CA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