@toolbox-web/grid 3.8.1 → 3.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +1 -1
- package/all.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/core/defaults.d.ts +1 -1
- package/lib/core/internal/aria.d.ts +1 -1
- package/lib/core/internal/config-manager.d.ts +0 -4
- package/lib/core/types.d.ts +6 -0
- package/lib/features/registry.js +1 -1
- package/lib/plugins/clipboard/clipboard-plugin.d.ts +2 -3
- package/lib/plugins/clipboard/index.js +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/index.js +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder-columns/index.js +1 -1
- package/lib/plugins/reorder-columns/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-drag-drop/index.js +1 -1
- package/lib/plugins/row-drag-drop/index.js.map +1 -1
- package/lib/plugins/row-drag-drop/row-drag-drop-plugin.d.ts +1 -0
- package/lib/plugins/row-drag-drop/types.d.ts +3 -2
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/selection-plugin.d.ts +2 -2
- package/lib/plugins/server-side/index.js +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/shell/index.js +1 -1
- package/lib/plugins/shell/index.js.map +1 -1
- package/lib/plugins/sticky-rows/index.js +1 -1
- package/lib/plugins/sticky-rows/index.js.map +1 -1
- package/lib/plugins/tooltip/index.js +1 -1
- package/lib/plugins/tooltip/index.js.map +1 -1
- package/lib/plugins/tree/index.js +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +1 -1
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -1
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +1 -1
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/row-drag-drop.umd.js +1 -1
- package/umd/plugins/row-drag-drop.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/tooltip.umd.js +1 -1
- package/umd/plugins/tooltip.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-drag-drop.umd.js","names":[],"sources":["../../../../../libs/grid/src/lib/plugins/shared/drag-drop-protocol.ts","../../../../../libs/grid/src/lib/plugins/shared/drag-alternative-menu.ts","../../../../../libs/grid/src/lib/plugins/row-drag-drop/row-drag-drop.css?inline","../../../../../libs/grid/src/lib/plugins/row-drag-drop/row-drag-drop-plugin.ts"],"sourcesContent":["/**\n * Drag-Drop Protocol — shared utilities for cross-grid row drag-and-drop.\n *\n * Used by `RowDragDropPlugin` (and any future plugin that participates in the\n * tbw row-drag protocol). Centralises:\n *\n * - MIME type constants and zone tagging (visible in `dataTransfer.types`)\n * - Payload codec for cross-window / cross-iframe transfers\n * - Drop-position math (midpoint algorithm)\n * - Auto-scroll engine (rAF loop, edge detection, boundary clamp)\n * - Plain-text TSV fallback for drags out to Notepad / Excel / Slack\n *\n * @internal Plugin shared utility (not part of the public API).\n */\n\nimport type { ColumnConfig } from '../../core/types';\n\n// ---------------------------------------------------------------------------\n// Same-window current-session tracker\n// ---------------------------------------------------------------------------\n\n/**\n * Module-level \"active drag session\" — set on dragstart by the source grid,\n * cleared on dragend. Lets target grids read the full payload synchronously\n * during `dragover` (browsers hide `dataTransfer.getData()` during dragover\n * for security). Cross-window drags don't have access to this module and\n * fall back to a generic accept-check followed by a drop-time canDrop call.\n *\n * @internal\n */\nlet currentSession: { sessionId: string; payload: RowDragPayload<unknown> } | null = null;\n\n/** @internal */\nexport function setCurrentDragSession<T>(sessionId: string, payload: RowDragPayload<T>): void {\n currentSession = { sessionId, payload: payload as RowDragPayload<unknown> };\n}\n\n/** @internal */\nexport function getCurrentDragSession<T = unknown>(): { sessionId: string; payload: RowDragPayload<T> } | null {\n return currentSession as { sessionId: string; payload: RowDragPayload<T> } | null;\n}\n\n/** @internal */\nexport function clearCurrentDragSession(): void {\n currentSession = null;\n}\n\n// ---------------------------------------------------------------------------\n// MIME types\n// ---------------------------------------------------------------------------\n\n/** Base MIME type carried on `dataTransfer` for tbw row drags. */\nexport const TBW_ROW_DRAG_MIME = 'application/x-tbw-grid-rows+json';\n\n/** Build a zone-tagged MIME type, visible in `dataTransfer.types` during dragover. */\nexport function mimeForZone(zone: string): string {\n return `${TBW_ROW_DRAG_MIME};zone=${encodeURIComponent(zone)}`;\n}\n\n/** Extract the zone from a tagged MIME, or `null` if untagged. */\nexport function parseZoneFromMime(mime: string): string | null {\n const match = mime.match(/^application\\/x-tbw-grid-rows\\+json;zone=(.*)$/);\n if (!match) return null;\n try {\n return decodeURIComponent(match[1]);\n } catch {\n return match[1];\n }\n}\n\n/**\n * Find the first MIME entry in `types` whose zone matches `zone`.\n * Used during `dragover` for the accept-check (browsers hide `getData()`\n * during dragover, but `types` is always visible).\n */\nexport function findMatchingZoneMime(types: readonly string[], zone: string): string | null {\n for (const t of types) {\n if (parseZoneFromMime(t) === zone) return t;\n }\n return null;\n}\n\n/** Returns true if any tbw row-drag MIME is present in `types`. */\nexport function hasAnyRowDragMime(types: readonly string[]): boolean {\n for (const t of types) {\n if (t === TBW_ROW_DRAG_MIME || t.startsWith(`${TBW_ROW_DRAG_MIME};`)) return true;\n }\n return false;\n}\n\n// ---------------------------------------------------------------------------\n// Payload\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-grid drag payload, carried on `dataTransfer` and (for same-window\n * recovery) keyed in the WeakRef registry by `sessionId`.\n *\n * Re-exported as public API from `plugins/row-drag-drop`.\n * @since 2.4.0\n */\nexport interface RowDragPayload<T = unknown> {\n /** Drag session id (matches the WeakRef registry key). */\n sessionId: string;\n /** Source grid id (`grid.id` or auto-generated UUID). */\n sourceGridId: string;\n /** Drop zone the source grid is participating in. */\n dropZone: string;\n /** Serialized row payload (JSON-safe). For same-window drops, recovered live via the registry. */\n rows: T[];\n /** Original indices in the source grid's `_rows` array. */\n rowIndices: number[];\n /** Move (default) removes from source; copy leaves source intact. */\n operation: 'move' | 'copy';\n}\n\n/** Encode a payload to the JSON string written to `dataTransfer`. */\nexport function encodePayload<T>(payload: RowDragPayload<T>): string {\n return JSON.stringify(payload);\n}\n\n/** Decode a payload from the JSON string read off `dataTransfer`. */\nexport function decodePayload<T = unknown>(raw: string): RowDragPayload<T> | null {\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as RowDragPayload<T>;\n if (\n typeof parsed?.sessionId !== 'string' ||\n typeof parsed?.sourceGridId !== 'string' ||\n typeof parsed?.dropZone !== 'string' ||\n !Array.isArray(parsed?.rows) ||\n !Array.isArray(parsed?.rowIndices) ||\n (parsed.operation !== 'move' && parsed.operation !== 'copy')\n ) {\n return null;\n }\n // `rowIndices` is later used for sorting and splicing — reject anything\n // that isn't a finite, non-negative integer to avoid JS coercion bugs\n // (NaN ordering, float splice indices, string concatenation, etc.).\n for (const idx of parsed.rowIndices) {\n if (typeof idx !== 'number' || !Number.isInteger(idx) || idx < 0) return null;\n }\n return parsed;\n } catch {\n return null;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Drop position math\n// ---------------------------------------------------------------------------\n\nexport interface DropPosition {\n /** Target visual row index that the cursor is over, or `null` for empty area. */\n overIndex: number | null;\n /** Final insertion index in the target grid's `_rows`. */\n insertIndex: number;\n /** True when the cursor is above the row midpoint. */\n isBefore: boolean;\n}\n\n/**\n * Compute the insertion index for a drop, given the row element under the\n * cursor (if any), the cursor's clientY, and the total row count when the\n * cursor is in empty space below the last row.\n *\n * - Cursor above row midpoint → insert at `targetIndex`\n * - Cursor below row midpoint → insert at `targetIndex + 1`\n * - Cursor over empty area below the last row → append (`insertIndex = totalRows`)\n */\nexport function computeDropPosition(\n rowEl: HTMLElement | null,\n clientY: number,\n rowIndexResolver: (el: HTMLElement) => number,\n totalRows: number,\n): DropPosition {\n if (!rowEl) {\n return { overIndex: null, insertIndex: totalRows, isBefore: false };\n }\n const targetIndex = rowIndexResolver(rowEl);\n if (targetIndex < 0) {\n return { overIndex: null, insertIndex: totalRows, isBefore: false };\n }\n const rect = rowEl.getBoundingClientRect();\n const midY = rect.top + rect.height / 2;\n const isBefore = clientY < midY;\n return {\n overIndex: targetIndex,\n insertIndex: isBefore ? targetIndex : targetIndex + 1,\n isBefore,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Auto-scroll engine\n// ---------------------------------------------------------------------------\n\nexport interface AutoScrollOptions {\n /** Pixels from the top/bottom edge that activate auto-scroll. */\n edgeSize?: number;\n /** Base scroll speed in pixels-per-frame near the edge. */\n speed?: number;\n /** Max speed at the very edge (linear ramp from `speed` → `maxSpeed`). */\n maxSpeed?: number;\n}\n\nexport interface AutoScroller {\n /** Update pointer position; starts the rAF loop if needed. */\n onPointerMove(clientY: number): void;\n /** Stop the rAF loop and reset state. */\n stop(): void;\n /** True when actively auto-scrolling. */\n readonly isScrolling: boolean;\n}\n\n/**\n * Create an auto-scroller for a viewport element.\n *\n * The scroller runs a `requestAnimationFrame` loop only while the pointer is\n * within `edgeSize` of the viewport's top or bottom and there is room to\n * scroll. Speed ramps linearly from `speed` (at the edge boundary) to\n * `maxSpeed` (at the very edge).\n */\nexport function createAutoScroller(\n viewport: HTMLElement,\n options: AutoScrollOptions = {},\n onScrollChange?: (active: boolean) => void,\n): AutoScroller {\n const edgeSize = options.edgeSize ?? 60;\n const baseSpeed = options.speed ?? 8;\n const maxSpeed = options.maxSpeed ?? 24;\n\n let rafId: number | null = null;\n let pointerY: number | null = null;\n let active = false;\n\n const setActive = (next: boolean): void => {\n if (next === active) return;\n active = next;\n onScrollChange?.(next);\n };\n\n const tick = (): void => {\n rafId = null;\n if (pointerY === null) {\n setActive(false);\n return;\n }\n const rect = viewport.getBoundingClientRect();\n let delta = 0;\n\n if (pointerY < rect.top + edgeSize) {\n const distance = Math.max(0, pointerY - rect.top);\n const ratio = 1 - distance / edgeSize;\n delta = -Math.round(baseSpeed + (maxSpeed - baseSpeed) * ratio);\n } else if (pointerY > rect.bottom - edgeSize) {\n const distance = Math.max(0, rect.bottom - pointerY);\n const ratio = 1 - distance / edgeSize;\n delta = Math.round(baseSpeed + (maxSpeed - baseSpeed) * ratio);\n }\n\n if (delta === 0) {\n setActive(false);\n return;\n }\n\n const before = viewport.scrollTop;\n viewport.scrollTop = before + delta;\n\n // Stop if we hit a boundary (no movement happened)\n if (viewport.scrollTop === before) {\n setActive(false);\n return;\n }\n\n setActive(true);\n rafId = requestAnimationFrame(tick);\n };\n\n return {\n onPointerMove(clientY: number): void {\n pointerY = clientY;\n if (rafId === null) {\n rafId = requestAnimationFrame(tick);\n }\n },\n stop(): void {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n rafId = null;\n }\n pointerY = null;\n setActive(false);\n },\n get isScrolling(): boolean {\n return active;\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// TSV fallback\n// ---------------------------------------------------------------------------\n\n/**\n * Format rows as a TSV string for the `text/plain` drag fallback.\n * Used when the drop target is an external app (Excel, Notepad, Slack).\n *\n * - One row per line, fields separated by `\\t`.\n * - Tabs and newlines in cell values are replaced with spaces.\n * - Skips columns flagged as `utility` (drag handle, checkbox, etc.).\n */\nexport function formatRowsAsTSV<T extends Record<string, unknown>>(\n rows: readonly T[],\n columns: readonly ColumnConfig[],\n): string {\n const dataColumns = columns.filter(\n (c) => !(c as { utility?: boolean }).utility && typeof c.field === 'string' && c.field !== '',\n );\n const lines: string[] = [];\n for (const row of rows) {\n const cells = dataColumns.map((col) => {\n const value = row[col.field];\n if (value === null || value === undefined) return '';\n const str = String(value);\n return str.replace(/[\\t\\r\\n]+/g, ' ');\n });\n lines.push(cells.join('\\t'));\n }\n return lines.join('\\n');\n}\n","/**\n * Generic click-only action menu — the shared building block for WCAG 2.2\n * SC 2.5.7 \"Dragging Movements\" alternatives in plugins.\n *\n * Every drag affordance in the grid needs a path that works with plain clicks\n * or taps. A keyboard equivalent is **not** enough: SC 2.5.7 is specifically\n * about pointer input, and the W3C Understanding text calls out \"a pop-up menu\n * after tap\" as a conforming alternative. This module is that pop-up.\n *\n * Lives under `plugins/shared/` on purpose: each plugin bundle is built\n * self-contained, so this code is duplicated into the plugins that use it and\n * never lands in the core `index.js` budget.\n *\n * @since 3.6.0\n * @internal\n */\n\n/** Gap between the anchor element and the menu, in px. */\nconst ANCHOR_GAP_PX = 6;\n\n/** Runtime check — happy-dom and older browsers may lack the Popover API. */\nfunction supportsPopover(): boolean {\n return typeof HTMLElement.prototype?.showPopover === 'function';\n}\n\nlet hoverlessQuery: MediaQueryList | null | undefined;\n\n/** Whether the primary pointer cannot hover (touch, most switch devices). */\nfunction isHoverless(): boolean {\n if (hoverlessQuery === undefined) hoverlessQuery = globalThis.matchMedia?.('(hover: none)') ?? null;\n return hoverlessQuery?.matches ?? false;\n}\n\n/**\n * Whether a plugin should also expose its drag alternative as a dedicated\n * inline control, on top of the menu that is always available.\n *\n * Hover-less pointers get one unconditionally — a control revealed on hover is\n * unreachable when nothing can hover, and long-press is the wrong fallback for\n * the tremor and low-dexterity users SC 2.5.7 exists for.\n *\n * Driven by `a11y.dragAlternatives` on the grid config.\n */\nexport function prefersInlineDragAlternative(grid: {\n effectiveConfig?: { a11y?: { dragAlternatives?: 'menu' | 'inline' } };\n}): boolean {\n return grid.effectiveConfig?.a11y?.dragAlternatives === 'inline' || isHoverless();\n}\n\n/** One clickable entry in the menu. */\nexport interface DragAlternativeAction {\n /** Visible text, also the accessible name. */\n label: string;\n /** Render the entry but refuse the click (e.g. \"Move up\" on the first row). */\n disabled?: boolean;\n /** Invoked on click; the menu closes first so focus handling is predictable. */\n run(): void;\n}\n\nexport interface DragAlternativeMenu {\n /**\n * Show `actions` anchored to `anchor`, with `label` as the group's accessible\n * name. Mounted inside the anchor's grid host so it inherits theme tokens.\n */\n open(anchor: HTMLElement, label: string, actions: readonly DragAlternativeAction[]): void;\n /** Hide the menu. Safe to call when already closed. */\n close(): void;\n /** Remove the element and every document-level listener. */\n dispose(): void;\n /** The menu element, or `null` before the first {@link DragAlternativeMenu.open}. */\n readonly element: HTMLElement | null;\n}\n\n/**\n * Create a menu instance.\n *\n * @param id - DOM id for the menu element, unique per owning plugin.\n * @param className - Root class name, so each plugin can style its own menu.\n */\nexport function createDragAlternativeMenu(id: string, className: string): DragAlternativeMenu {\n let root: HTMLDivElement | null = null;\n let opened = false;\n let disposed = false;\n const abort = new AbortController();\n\n function close(): void {\n if (!opened || !root) return;\n opened = false;\n if (supportsPopover()) root.hidePopover();\n root.hidden = true;\n }\n\n function build(): HTMLDivElement {\n const el = document.createElement('div');\n el.id = id;\n el.className = className;\n el.setAttribute('popover', 'manual');\n el.setAttribute('role', 'group');\n // Without the Popover API there is no UA `display: none`, so hide it here.\n el.hidden = true;\n // Tabbing past either end dismisses instead of stranding the user — the\n // menu has no visible trigger to tab back to. A null `relatedTarget` (click\n // focus in Firefox/Safari, focus leaving the document) is ignored.\n el.addEventListener(\n 'focusout',\n (e) => {\n const next = (e as FocusEvent).relatedTarget;\n if (next instanceof Node && !el.contains(next)) close();\n },\n { signal: abort.signal },\n );\n return el;\n }\n\n /**\n * Position against the anchor in viewport coordinates. The menu lives in the\n * top layer, so its containing block is the viewport regardless of where the\n * anchor sits in the DOM.\n */\n function place(anchor: HTMLElement): void {\n if (!root) return;\n const a = anchor.getBoundingClientRect();\n const box = root.getBoundingClientRect();\n const left = Math.max(4, Math.min(a.left, window.innerWidth - box.width - 4));\n const below = a.bottom + ANCHOR_GAP_PX;\n const top = below + box.height <= window.innerHeight ? below : Math.max(4, a.top - ANCHOR_GAP_PX - box.height);\n root.style.left = `${Math.round(left)}px`;\n root.style.top = `${Math.round(top)}px`;\n }\n\n // Any pointer press outside the menu dismisses it. Capture phase so the press\n // that lands on a grid cell still reaches its own handler afterwards.\n document.addEventListener(\n 'pointerdown',\n (e) => {\n if (opened && root && !e.composedPath().includes(root)) close();\n },\n { capture: true, signal: abort.signal },\n );\n document.addEventListener(\n 'keydown',\n (e) => {\n if ((e as KeyboardEvent).key === 'Escape') close();\n },\n { capture: true, signal: abort.signal },\n );\n\n return {\n get element() {\n return root;\n },\n open(anchor, label, actions) {\n if (disposed || actions.length === 0) return;\n if (!root) root = build();\n // Mount inside the grid host (light DOM) so theme custom properties and\n // `color-scheme` cascade in; the top layer keeps it out of overflow.\n const host = anchor.closest<HTMLElement>('tbw-grid, [data-tbw-grid]') ?? document.body;\n if (root.parentNode !== host) host.appendChild(root);\n root.setAttribute('aria-label', label);\n root.replaceChildren();\n for (const action of actions) {\n const btn = document.createElement('button');\n btn.type = 'button';\n btn.className = `${className}-item`;\n btn.textContent = action.label;\n btn.disabled = action.disabled === true;\n btn.addEventListener('click', () => {\n close();\n action.run();\n });\n root.appendChild(btn);\n }\n root.hidden = false;\n if (!opened && supportsPopover()) root.showPopover();\n opened = true;\n place(anchor);\n root.querySelector<HTMLButtonElement>('button:not([disabled])')?.focus();\n },\n close,\n dispose() {\n disposed = true;\n close();\n abort.abort();\n root?.remove();\n root = null;\n },\n };\n}\n","/**\n * Row Drag-Drop Plugin CSS\n *\n * Styles for drag handle, drop indicators (intra- and cross-grid), grid-level\n * drag/drop state classes, and FLIP animation on landing rows.\n */\n\n@layer tbw-plugins {\n /* ------------------------------------------------------------------ */\n /* Drag handle column */\n /* ------------------------------------------------------------------ */\n [data-field='__tbw_row_drag'] {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .dg-row-drag-handle {\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 1em;\n min-height: 1em;\n cursor: grab;\n user-select: none;\n color: var(--tbw-row-reorder-handle-color, var(--tbw-color-fg-muted));\n transition: color var(--tbw-transition-duration, 120ms) var(--tbw-transition-ease, ease);\n font-size: var(--tbw-font-size, 1em);\n letter-spacing: -2px;\n\n /* SC 2.5.8: grow the target, not the box, so the row keeps its height. */\n position: relative;\n\n &::after {\n content: '';\n position: absolute;\n inset-block-start: 50%;\n inset-inline-start: 50%;\n translate: -50% -50%;\n inline-size: var(--tbw-touch-target-min, 24px);\n block-size: var(--tbw-touch-target-min, 24px);\n }\n\n &:hover {\n color: var(--tbw-row-reorder-handle-hover, var(--tbw-color-fg));\n }\n\n &:active {\n cursor: grabbing;\n }\n }\n\n /* Coarse pointer (touch): handle always in active colour and large enough to tap */\n @media (hover: none) {\n .dg-row-drag-handle {\n color: var(--tbw-row-reorder-handle-hover, var(--tbw-color-fg));\n }\n }\n\n @media (pointer: coarse) {\n .dg-row-drag-handle {\n min-width: var(--tbw-touch-target-min, 24px);\n min-height: var(--tbw-touch-target-min, 24px);\n }\n }\n\n /* ------------------------------------------------------------------ */\n /* Source row state */\n /* ------------------------------------------------------------------ */\n .data-grid-row.dragging {\n opacity: 0.6;\n }\n\n /* When the row itself is the drag handle, hint at the affordance. */\n .data-grid-row[draggable='true'] {\n cursor: grab;\n }\n\n .data-grid-row[draggable='true'].dragging {\n cursor: grabbing;\n }\n\n /* Off-screen full-row clone used as the HTML5 drag image. */\n /* The browser already applies its own translucency to the snapshot, */\n /* so this clone keeps full opacity and skips the box-shadow — both */\n /* would otherwise composite on top of the browser's effect and make */\n /* the drag image look washed-out / fade at the edges. */\n .tbw-row-drag-clone {\n position: fixed;\n top: -10000px;\n left: -10000px;\n pointer-events: none;\n }\n\n /* Multi-row drag count badge */\n .tbw-row-drag-count {\n position: fixed;\n top: -1000px; /* off-screen until the browser snapshots it */\n left: -1000px;\n pointer-events: none;\n background: var(--tbw-row-reorder-indicator, var(--tbw-color-accent));\n color: var(--tbw-color-accent-fg);\n font:\n 600 12px/1.4 system-ui,\n sans-serif;\n border-radius: 999px;\n padding: 2px 8px;\n box-shadow: 0 2px 6px var(--tbw-color-shadow);\n z-index: 9999;\n }\n\n /* ------------------------------------------------------------------ */\n /* Drop position indicator (rows under cursor) */\n /* ------------------------------------------------------------------ */\n .data-grid-row.drop-target {\n position: relative;\n\n &.drop-before::before,\n &.drop-after::after {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n height: var(--tbw-drop-indicator-width, 2px);\n background-color: var(--tbw-drop-indicator-color, var(--tbw-row-reorder-indicator, var(--tbw-color-accent)));\n z-index: 10;\n pointer-events: none;\n }\n\n &.drop-before::before {\n top: 0;\n }\n\n &.drop-after::after {\n bottom: 0;\n }\n }\n\n /* ------------------------------------------------------------------ */\n /* Grid-level state classes */\n /* ------------------------------------------------------------------ */\n\n /* Source grid while a drag originating here is in progress */\n .tbw-grid--drag-source {\n /* Reserved hook for consumer styling. */\n }\n\n /* Target grid while a valid drag hovers (matching dropZone, canDrop ok) */\n .tbw-grid--drop-target-active {\n outline: 2px dashed var(--tbw-drop-indicator-color, var(--tbw-color-accent));\n outline-offset: -2px;\n }\n\n /* Briefly applied when a drop attempt is rejected */\n .tbw-grid--drop-target-rejected {\n outline: 2px dashed var(--tbw-color-danger);\n outline-offset: -2px;\n }\n\n /* Applied while the auto-scroll engine is actively scrolling this grid */\n .tbw-grid--auto-scrolling {\n cursor: ns-resize;\n }\n\n /* ------------------------------------------------------------------ */\n /* FLIP animation on landing rows */\n /* ------------------------------------------------------------------ */\n .data-grid-row.flip-animating {\n transition: transform var(--tbw-animation-duration, 200ms) ease-out;\n will-change: transform;\n z-index: 1;\n }\n\n /* ------------------------------------------------------------------ */\n /* Click-only move menu (WCAG 2.2 SC 2.5.7) */\n /* ------------------------------------------------------------------ */\n /* Rendered into `document.body` and promoted to the top layer, so it sits\n outside the grid's custom-property scope — every var needs a literal\n fallback here, the same way the tooltip popover does it. */\n .tbw-row-move-menu {\n position: fixed;\n margin: 0;\n display: flex;\n flex-direction: column;\n min-width: 10rem;\n padding: var(--tbw-spacing-xs, 0.25rem);\n background: var(--tbw-color-panel-bg, light-dark(#fff, #1f1f1f));\n color: var(--tbw-color-fg, light-dark(#1a1a1a, #f0f0f0));\n border: 1px solid var(--tbw-color-border, light-dark(#d0d0d0, #3a3a3a));\n border-radius: var(--tbw-border-radius, 0.25rem);\n box-shadow: var(--tbw-shadow-md, 0 4px 12px rgb(0 0 0 / 25%));\n font: inherit;\n z-index: 10001;\n\n &[hidden] {\n display: none;\n }\n }\n\n .tbw-row-move-menu-item {\n min-height: var(--tbw-touch-target-min, 24px);\n padding: var(--tbw-spacing-xs, 0.25rem) var(--tbw-spacing-sm, 0.5rem);\n text-align: start;\n background: none;\n border: none;\n /* Themes set radii for much larger surfaces (Material uses 12px), which\n turns a 24px row into a lozenge. */\n border-radius: min(var(--tbw-border-radius, 0.25rem), 6px);\n color: inherit;\n font: inherit;\n cursor: pointer;\n\n &:hover:not(:disabled) {\n background: var(--tbw-color-row-hover, light-dark(#f0f0f0, #2a2a2a));\n }\n\n &:disabled {\n opacity: 0.5;\n cursor: default;\n }\n }\n}\n","/**\n * Row Drag-Drop Plugin\n *\n * Drag rows within a single grid **and** between grids that share a\n * `dropZone`.\n *\n * Architecture overview is documented in the issue body and in\n * `.github/knowledge/grid-plugins.md`. Key invariants:\n *\n * - Mutations write to `grid._rows`; the user's input `sourceRows` array is\n * never mutated on either side. Persistence is consumer-driven via the\n * `row-move` (intra-grid) and `row-transfer` (cross-grid) events.\n * - Same-window cross-grid drops use the WeakRef registry in\n * `core/internal/drag-drop-registry` to recover live row references.\n * Cross-window drops fall back to `JSON.parse(JSON.stringify(row))` (or the\n * `serializeRow`/`deserializeRow` hooks for non-JSON values).\n * - Duplicate instances of this plugin collapse via the PluginManager\n * alias-collapse pre-pass, which merges their configs.\n *\n * @see {@link RowDragDropConfig} for all configuration options.\n */\n\nimport { GridClasses } from '../../core/constants';\nimport {\n clearDragSession,\n lookupDragSession,\n newDragSessionId,\n registerDragSession,\n} from '../../core/internal/drag-drop-registry';\nimport { ensureCellVisible } from '../../core/internal/keyboard';\nimport { BaseGridPlugin, type GridElement, type PluginManifest } from '../../core/plugin/base-plugin';\nimport type { ColumnConfig, GridHost } from '../../core/types';\nimport {\n type AutoScroller,\n type RowDragPayload,\n TBW_ROW_DRAG_MIME,\n clearCurrentDragSession,\n computeDropPosition,\n createAutoScroller,\n decodePayload,\n encodePayload,\n findMatchingZoneMime,\n formatRowsAsTSV,\n getCurrentDragSession,\n hasAnyRowDragMime,\n mimeForZone,\n setCurrentDragSession,\n} from '../shared/drag-drop-protocol';\nimport { type DragAlternativeAction, type DragAlternativeMenu, createDragAlternativeMenu } from '../shared/drag-alternative-menu';\nimport styles from './row-drag-drop.css?inline';\nimport type {\n PendingMove,\n RowDragDropConfig,\n RowDragEndDetail,\n RowDragStartDetail,\n RowDropDetail,\n RowMoveDetail,\n RowTransferDetail,\n} from './types';\n\n/**\n * Field name for the drag handle column.\n *\n * @since 2.4.0\n */\nexport const ROW_DRAG_HANDLE_FIELD = '__tbw_row_drag';\n\n// ---------------------------------------------------------------------------\n// Cross-window coordination via BroadcastChannel\n// ---------------------------------------------------------------------------\n//\n// Same-window cross-grid drops can locate the source grid and its plugin via\n// `document.getElementById(sourceGridId)` — the target plugin handles both\n// sides of the transfer in `onDrop` (insert into target + remove from source\n// + emit `row-transfer` on both grids).\n//\n// Cross-window drops can't reach the source DOM that way. The target window\n// broadcasts a `tbw-row-drag-drop:transfer` message; each window has a single\n// channel and fans the message out to every attached plugin instance, which\n// matches on `sourceGridId === this.gridId` and runs the source-side path\n// (row removal on `move`, `row-transfer` emit, `dragAccepted` flip).\n//\n// The channel is created lazily on the first plugin that needs it and shared\n// across all instances in the window. It's torn down when the last instance\n// detaches so we don't leak a handle in environments where the plugin is\n// repeatedly attached/detached.\n\n/** @internal */\ninterface RemoteTransferMessage {\n type: 'tbw-row-drag-drop:transfer';\n sessionId: string;\n sourceGridId: string;\n toGridId: string;\n dropZone: string;\n rowIndices: number[];\n toIndex: number;\n operation: 'move' | 'copy';\n /** Pre-serialized rows (the same shape `serializeRow` produced on dragstart). */\n serializedRows: unknown[];\n}\n\ntype RemoteTransferListener = (msg: RemoteTransferMessage) => void;\n\nconst CROSS_WINDOW_CHANNEL_NAME = 'tbw-row-drag-drop';\nlet sharedChannel: BroadcastChannel | null = null;\nconst remoteListeners = new Set<RemoteTransferListener>();\n\nfunction ensureCrossWindowChannel(): BroadcastChannel | null {\n if (typeof BroadcastChannel === 'undefined') return null;\n if (sharedChannel) return sharedChannel;\n try {\n sharedChannel = new BroadcastChannel(CROSS_WINDOW_CHANNEL_NAME);\n sharedChannel.addEventListener('message', (event: MessageEvent) => {\n const data = event.data as RemoteTransferMessage | undefined;\n if (!data || data.type !== 'tbw-row-drag-drop:transfer') return;\n // Snapshot to tolerate listeners that detach during dispatch.\n for (const listener of Array.from(remoteListeners)) {\n try {\n listener(data);\n } catch {\n /* listener errors must not break sibling listeners */\n }\n }\n });\n } catch {\n sharedChannel = null;\n }\n return sharedChannel;\n}\n\nfunction registerRemoteTransferListener(listener: RemoteTransferListener): void {\n remoteListeners.add(listener);\n ensureCrossWindowChannel();\n}\n\n/**\n * Every plugin instance attached in this window.\n *\n * Drag-and-drop discovers its target from the pointer position, so it never\n * needed a registry. The click-only transfer control (WCAG 2.2 SC 2.5.7) does:\n * it has to *list* the grids a row can be sent to before the user picks one.\n *\n * Typed as `unknown` because the class is generic over the row type and every\n * instance in the window may have a different one; `peersInDropZone()` narrows.\n */\nconst attachedPlugins = new Set<unknown>();\n\nfunction unregisterRemoteTransferListener(listener: RemoteTransferListener): void {\n remoteListeners.delete(listener);\n if (remoteListeners.size === 0 && sharedChannel) {\n try {\n sharedChannel.close();\n } catch {\n /* noop */\n }\n sharedChannel = null;\n }\n}\n\nfunction broadcastRemoteTransfer(msg: RemoteTransferMessage): void {\n const channel = ensureCrossWindowChannel();\n if (!channel) return;\n try {\n channel.postMessage(msg);\n } catch {\n /* postMessage may throw on uncloneable payloads — acceptable; user can\n * supply `serializeRow` to provide a structured-cloneable shape. */\n }\n}\n\n/**\n * Row Drag-Drop Plugin for `<tbw-grid>`.\n *\n * @example Intra-grid reordering\n * ```ts\n * import { RowDragDropPlugin } from '@toolbox-web/grid/plugins/row-drag-drop';\n *\n * grid.gridConfig = {\n * plugins: [new RowDragDropPlugin()],\n * };\n * ```\n *\n * @example Cross-grid transfer list\n * ```ts\n * gridA.gridConfig = { plugins: [new RowDragDropPlugin({ dropZone: 'tasks' })] };\n * gridB.gridConfig = { plugins: [new RowDragDropPlugin({ dropZone: 'tasks' })] };\n *\n * gridA.addEventListener('row-transfer', (e) => persist(e.detail));\n * gridB.addEventListener('row-transfer', (e) => persist(e.detail));\n * ```\n *\n * @category Plugin\n */\nexport class RowDragDropPlugin<T = unknown> extends BaseGridPlugin<RowDragDropConfig<T>> {\n /** @internal */\n readonly name = 'rowDragDrop';\n\n /** @internal */\n override readonly styles = styles;\n\n /** @internal */\n static override readonly manifest: PluginManifest<RowDragDropConfig> = {\n events: [\n { type: 'row-move', description: 'Intra-grid row reorder.', cancelable: true },\n { type: 'row-drag-start', description: 'Cross-grid drag started on this grid.', cancelable: true },\n { type: 'row-drag-end', description: 'Drag finished on this grid (regardless of outcome).' },\n { type: 'row-drop', description: 'Cross-grid drop landing on this grid.', cancelable: true },\n { type: 'row-transfer', description: 'Cross-grid transfer completed (fires on both grids).' },\n ],\n };\n\n /** @internal */\n protected override get defaultConfig(): Partial<RowDragDropConfig<T>> {\n return {\n enableKeyboard: true,\n // `showDragHandle` default depends on `dragFrom` — resolved by\n // `shouldRenderDragHandle()` rather than here so a single `dragFrom`\n // change reshapes both at once.\n dragHandlePosition: 'left',\n dragHandleWidth: 40,\n debounceMs: 150,\n animation: 'flip',\n operation: 'move',\n autoScroll: true,\n dragFrom: 'handle',\n };\n }\n\n /**\n * Resolve whether the grip column should be rendered. The handle is shown\n * unless the user explicitly set `showDragHandle: false`, OR `dragFrom`\n * is `'row'` and `showDragHandle` was not explicitly set to `true`.\n */\n private shouldRenderDragHandle(): boolean {\n const explicit = this.config.showDragHandle;\n if (explicit === false) return false;\n if (explicit === true) return true;\n return this.config.dragFrom !== 'row';\n }\n\n /** Whether the row element itself should accept native HTML5 drag. */\n private get rowIsDraggable(): boolean {\n return this.config.dragFrom === 'row' || this.config.dragFrom === 'both';\n }\n\n /** Resolve animation type from plugin config (respects grid-level reduced-motion). */\n private get animationType(): false | 'flip' {\n if (!this.isAnimationEnabled) return false;\n if (this.config.animation !== undefined) return this.config.animation;\n return 'flip';\n }\n\n // #region Internal State\n private isDragging = false;\n private draggedRowIndex: number | null = null;\n private draggedRows: T[] = [];\n private draggedIndices: number[] = [];\n private dragSessionId: string | null = null;\n private dragAccepted = false;\n private dropRowIndex: number | null = null;\n private pendingMove: PendingMove | null = null;\n private debounceTimer: ReturnType<typeof setTimeout> | null = null;\n private lastFocusCol = 0;\n private autoScroller: AutoScroller | null = null;\n /** Stable id for this grid instance (used as `sourceGridId` in payloads). */\n private gridId = '';\n\n /** Bound listener so we can register/unregister the same reference. */\n private readonly remoteTransferListener: RemoteTransferListener = (msg) => this.onRemoteTransfer(msg);\n\n /** Click-only move menu (WCAG 2.2 SC 2.5.7), created lazily on first tap. */\n private moveMenu: DragAlternativeMenu | null = null;\n\n /** Typed internal grid accessor. */\n private get internalGrid(): GridHost {\n return this.grid;\n }\n // #endregion\n\n // #region Lifecycle\n /** @internal */\n override attach(grid: GridElement): void {\n super.attach(grid);\n const host = this.gridElement;\n if (host) {\n this.gridId = host.id || `tbw-grid-${newDragSessionId().slice(0, 8)}`;\n if (!host.id) host.id = this.gridId;\n this.setupDelegatedDragListeners();\n registerRemoteTransferListener(this.remoteTransferListener);\n attachedPlugins.add(this);\n }\n }\n\n /** @internal */\n override detach(): void {\n this.clearDebounceTimer();\n this.autoScroller?.stop();\n this.autoScroller = null;\n unregisterRemoteTransferListener(this.remoteTransferListener);\n attachedPlugins.delete(this);\n this.moveMenu?.dispose();\n this.moveMenu = null;\n if (this.dragSessionId) clearDragSession(this.dragSessionId);\n clearCurrentDragSession();\n this.resetDragState();\n super.detach();\n }\n // #endregion\n\n // #region Hooks\n\n /** @internal */\n override processColumns(columns: readonly ColumnConfig[]): ColumnConfig[] {\n if (!this.shouldRenderDragHandle()) return [...columns];\n\n const dragHandleColumn: ColumnConfig = {\n field: ROW_DRAG_HANDLE_FIELD,\n header: '',\n width: this.config.dragHandleWidth ?? 40,\n resizable: false,\n sortable: false,\n filterable: false,\n lockPosition: true,\n utility: true,\n viewRenderer: () => {\n const container = document.createElement('div');\n container.className = 'dg-row-drag-handle';\n container.setAttribute('aria-label', 'Drag to reorder, or activate for move options');\n container.setAttribute('role', 'button');\n container.setAttribute('tabindex', '-1');\n container.draggable = true;\n // Press-and-release without moving is a tap, not a drag — HTML5 DnD\n // only fires `dragstart` on a real drag, so a plain `click` here means\n // the pointer user could not (or chose not to) drag. Offer the\n // click-only alternative instead (WCAG 2.2 SC 2.5.7).\n container.addEventListener('click', (e) => {\n e.stopPropagation();\n this.openMoveMenu(container);\n });\n this.setIcon(container, 'dragHandle');\n return container;\n },\n };\n\n return this.config.dragHandlePosition === 'right' ? [...columns, dragHandleColumn] : [dragHandleColumn, ...columns];\n }\n\n /** @internal */\n override afterRender(): void {\n this.applyRowDraggable();\n }\n\n /** @internal */\n override onScrollRender(): void {\n // Virtualization recycles row DOM elements during scroll; re-apply the\n // `draggable` attribute so newly-shown rows still accept HTML5 drag.\n this.applyRowDraggable();\n }\n\n /**\n * Set or clear the `draggable` attribute on every visible row, depending on\n * `config.dragFrom`. Idempotent and cheap (one attribute write per row).\n */\n private applyRowDraggable(): void {\n const body = this.internalGrid._bodyEl;\n if (!body) return;\n const wantDraggable = this.rowIsDraggable;\n const rows = body.querySelectorAll<HTMLElement>('.data-grid-row');\n for (const row of rows) {\n if (wantDraggable) {\n if (row.getAttribute('draggable') !== 'true') row.setAttribute('draggable', 'true');\n } else if (row.hasAttribute('draggable')) {\n row.removeAttribute('draggable');\n }\n }\n }\n\n /** @internal */\n override onKeyDown(event: KeyboardEvent): boolean | void {\n if (!this.config.enableKeyboard) return;\n if (!event.ctrlKey || (event.key !== 'ArrowUp' && event.key !== 'ArrowDown')) return;\n\n const grid = this.internalGrid;\n const focusRow = grid._focusRow;\n const rows = grid._rows ?? this.sourceRows;\n if (focusRow < 0 || focusRow >= rows.length) return;\n\n const direction = event.key === 'ArrowUp' ? 'up' : 'down';\n const toIndex = direction === 'up' ? focusRow - 1 : focusRow + 1;\n if (toIndex < 0 || toIndex >= rows.length) return;\n\n const row = rows[focusRow];\n if (!this.canMoveRow(focusRow, toIndex)) return;\n\n this.handleKeyboardMove(row, focusRow, toIndex, grid._focusCol);\n event.preventDefault();\n event.stopPropagation();\n return true;\n }\n\n /** @internal */\n override onCellClick(): void {\n this.flushPendingMove();\n }\n // #endregion\n\n // #region Public API\n /** Move a row to a new position programmatically (intra-grid). */\n moveRow(fromIndex: number, toIndex: number): void {\n const rows = [...this.sourceRows];\n if (fromIndex < 0 || fromIndex >= rows.length) return;\n if (toIndex < 0 || toIndex >= rows.length) return;\n if (fromIndex === toIndex) return;\n if (!this.canMoveRow(fromIndex, toIndex)) return;\n this.executeIntraGridMove(rows[fromIndex], fromIndex, toIndex, 'keyboard');\n }\n\n /**\n * Check if a row can be moved within this grid.\n * Consults the `canDrag` veto for the source row, the plugin query system\n * (`canMoveRow`), and `canDrop` for the target.\n */\n canMoveRow(fromIndex: number, toIndex: number): boolean {\n // During debounced keyboard moves, `grid._rows` diverges from\n // `sourceRows` (the user-facing snapshot) because the plugin mutates\n // resolves the focused row from `_rows ?? sourceRows`, so validation must\n // read from the same array — otherwise we'd run `canDrag`/queries against\n // the wrong row.\n const rows = this.internalGrid._rows ?? this.sourceRows;\n if (fromIndex < 0 || fromIndex >= rows.length) return false;\n if (toIndex < 0 || toIndex >= rows.length) return false;\n if (fromIndex === toIndex) return false;\n\n // Plugin query veto (Tree, GroupingRows)\n const row = rows[fromIndex] as T;\n const queryResults = this.grid?.query?.<boolean>('canMoveRow', row);\n if (Array.isArray(queryResults) && queryResults.includes(false)) return false;\n\n // canDrag veto (dragstart side)\n if (this.config.canDrag && !this.config.canDrag(row, fromIndex)) return false;\n\n // canDrop callback (intra-grid synthesised payload)\n if (this.config.canDrop) {\n const payload: RowDragPayload<T> = {\n sessionId: 'intra',\n sourceGridId: this.gridId,\n dropZone: this.config.dropZone ?? '',\n rows: [row],\n rowIndices: [fromIndex],\n operation: 'move',\n };\n if (!this.config.canDrop(payload, toIndex)) return false;\n }\n\n return true;\n }\n // #endregion\n\n // #region Drag Setup\n\n private setupDelegatedDragListeners(): void {\n const gridEl = this.gridElement;\n if (!gridEl) return;\n const signal = this.disconnectSignal;\n\n gridEl.addEventListener('dragstart', (e) => this.onDragStart(e as DragEvent), { signal });\n gridEl.addEventListener('dragend', () => this.onDragEnd(), { signal });\n gridEl.addEventListener('dragover', (e) => this.onDragOver(e as DragEvent), { signal });\n gridEl.addEventListener('dragleave', (e) => this.onDragLeave(e as DragEvent), { signal });\n gridEl.addEventListener('drop', (e) => this.onDrop(e as DragEvent), { signal });\n }\n\n private onDragStart(de: DragEvent): void {\n const target = de.target as HTMLElement | null;\n if (!target) return;\n\n // Resolve the row element being picked up. Order matters: a click on the\n // grip column inside a row-draggable grid should still go through the\n // handle path so the cursor offset feels right.\n const handle = target.closest('.dg-row-drag-handle') as HTMLElement | null;\n let rowEl: HTMLElement | null = null;\n let initiatedFromHandle = false;\n if (handle) {\n rowEl = handle.closest('.data-grid-row') as HTMLElement | null;\n initiatedFromHandle = true;\n } else if (this.rowIsDraggable) {\n // Row-as-handle: any cell may start the drag, but interactive\n // descendants (inputs, buttons, anchors, contenteditable, open\n // editors, selection checkboxes) keep their native behaviour.\n if (this.isInteractiveDragOrigin(target)) return;\n rowEl = target.closest('.data-grid-row') as HTMLElement | null;\n }\n if (!rowEl) return;\n\n const rowIndex = this.getRowIndex(rowEl);\n if (rowIndex < 0) return;\n\n // Resolve the rows being dragged: whole selection if dragged row is selected.\n const { rows, indices } = this.resolveDraggedRows(rowIndex);\n if (rows.length === 0) return;\n\n // canDrag veto on the originating row\n if (this.config.canDrag && !this.config.canDrag(rows[0], rowIndex)) {\n de.preventDefault();\n return;\n }\n\n const operation = this.config.operation ?? 'move';\n const dropZone = this.config.dropZone ?? '';\n const sessionId = newDragSessionId();\n\n // Emit cancelable row-drag-start (source-side veto)\n const startDetail: RowDragStartDetail<T> = { rows, indices, operation, dropZone };\n if (this.emitCancelable('row-drag-start', startDetail)) {\n de.preventDefault();\n return;\n }\n\n this.isDragging = true;\n this.draggedRowIndex = rowIndex;\n this.draggedRows = rows;\n this.draggedIndices = indices;\n this.dragSessionId = sessionId;\n this.dragAccepted = false;\n\n // Build the cross-grid payload (always built, even when dropZone is empty —\n // intra-grid drops still benefit from the registry round-trip)\n const serialize = this.config.serializeRow ?? ((r: T) => r);\n const payload: RowDragPayload<T> = {\n sessionId,\n sourceGridId: this.gridId,\n dropZone,\n rows: rows.map(serialize) as T[],\n rowIndices: indices,\n operation,\n };\n\n if (de.dataTransfer) {\n de.dataTransfer.effectAllowed = operation === 'copy' ? 'copyMove' : 'move';\n try {\n de.dataTransfer.setData(TBW_ROW_DRAG_MIME, encodePayload(payload));\n if (dropZone) de.dataTransfer.setData(mimeForZone(dropZone), encodePayload(payload));\n // Plain-text TSV fallback for external drop targets\n de.dataTransfer.setData('text/plain', formatRowsAsTSV(rows as Record<string, unknown>[], this.columns));\n } catch {\n /* JSDOM/happy-dom may throw on setData; harmless */\n }\n\n // Drag image: full-row clone for single-row drags (more legible than\n // the handle alone); count badge for multi-row drags.\n if (rows.length > 1) {\n const badge = document.createElement('div');\n badge.className = 'tbw-row-drag-count';\n badge.textContent = `${rows.length} rows`;\n document.body.appendChild(badge);\n try {\n de.dataTransfer.setDragImage(badge, 10, 10);\n } catch {\n /* ignore */\n }\n setTimeout(() => badge.remove(), 0);\n } else {\n this.attachRowCloneDragImage(de, rowEl, initiatedFromHandle ? handle : null);\n }\n }\n\n // Same-window registry + current-session marker\n registerDragSession(sessionId, rows as unknown[]);\n setCurrentDragSession(sessionId, payload);\n\n rowEl.classList.add(GridClasses.DRAGGING);\n this.gridElement.classList.add('tbw-grid--drag-source');\n }\n\n /**\n * Selectors whose dragstart should NOT initiate a row drag in `dragFrom: 'row'`\n * mode. Keeps native interactions (text input, button clicks, link drag,\n * cell editing, selection checkboxes) working unchanged.\n */\n private static readonly INTERACTIVE_DRAG_SELECTORS =\n 'input,textarea,select,button,a,[contenteditable=\"\"],[contenteditable=\"true\"],.dg-cell-editor,.tbw-checkbox-cell';\n\n /** @internal */\n private isInteractiveDragOrigin(target: HTMLElement): boolean {\n return target.closest(RowDragDropPlugin.INTERACTIVE_DRAG_SELECTORS) !== null;\n }\n\n /**\n * Build a full-row drag image by cloning `rowEl` so the user sees the\n * actual row — not just the grip icon — while dragging.\n *\n * The clone is appended off-screen, snapshotted by the browser via\n * `setDragImage`, then removed on the next tick (after the snapshot).\n * The cursor offset is preserved relative to where the user pressed.\n */\n private attachRowCloneDragImage(de: DragEvent, rowEl: HTMLElement, handle: HTMLElement | null): void {\n if (!de.dataTransfer) return;\n const rect = rowEl.getBoundingClientRect();\n const clone = rowEl.cloneNode(true) as HTMLElement;\n clone.classList.add('tbw-row-drag-clone');\n // Strip transient classes that would look wrong in the drag image.\n clone.classList.remove('dragging', 'drop-target', 'drop-before', 'drop-after', 'flip-animating', 'row-focus');\n clone.removeAttribute('aria-selected');\n // Preserve the actual rendered width so cells don't reflow in the snapshot.\n clone.style.width = `${rect.width}px`;\n clone.style.height = `${rect.height}px`;\n // The clone MUST stay inside the grid host: every core row/cell rule is\n // scoped under `tbw-grid …` (see core/styles/*.css), and the\n // `--tbw-column-template` custom property is set on the host. If the\n // clone is moved to `document.body`, none of those rules match and the\n // drag image collapses to an empty box. Off-screen positioning via\n // `position: fixed` works the same regardless of the DOM parent.\n this.gridElement.appendChild(clone);\n // Cursor offset: where the user pressed inside the source row. Falls\n // back to the centre of the handle when initiated from the grip.\n let offsetX = de.clientX - rect.left;\n let offsetY = de.clientY - rect.top;\n if (handle) {\n const handleRect = handle.getBoundingClientRect();\n offsetX = handleRect.left - rect.left + handleRect.width / 2;\n offsetY = handleRect.top - rect.top + handleRect.height / 2;\n }\n // Clamp into the row bounds so the cursor stays inside the drag image.\n offsetX = Math.max(0, Math.min(rect.width, offsetX));\n offsetY = Math.max(0, Math.min(rect.height, offsetY));\n try {\n de.dataTransfer.setDragImage(clone, offsetX, offsetY);\n } catch {\n /* JSDOM/happy-dom: harmless */\n }\n setTimeout(() => clone.remove(), 0);\n }\n\n private onDragOver(de: DragEvent): void {\n const dt = de.dataTransfer;\n if (!dt) return;\n\n // Identify whether a tbw row drag is in progress and whether it matches our zone.\n const types = dt.types ? Array.from(dt.types) : [];\n if (!hasAnyRowDragMime(types) && !this.isDragging) return;\n\n const dropZone = this.config.dropZone ?? '';\n const session = getCurrentDragSession<T>();\n\n // For cross-grid drags we require a matching zone-tagged MIME OR the\n // session payload's dropZone must match ours.\n const isIntra = this.isDragging && session?.payload.sourceGridId === this.gridId;\n if (!isIntra) {\n if (!dropZone) return; // intra-grid only — ignore external drags\n const matchingMime = findMatchingZoneMime(types, dropZone);\n if (!matchingMime && !(session && session.payload.dropZone === dropZone)) return;\n }\n\n de.preventDefault();\n if (dt) dt.dropEffect = (session?.payload.operation ?? this.config.operation ?? 'move') as 'copy' | 'move';\n\n // Compute drop position\n const rowEl = (de.target as HTMLElement).closest('.data-grid-row') as HTMLElement | null;\n const rows = this.internalGrid._rows ?? [];\n const pos = computeDropPosition(rowEl, de.clientY, (el) => this.getRowIndex(el), rows.length);\n\n // Same-row no-op for intra-grid\n if (isIntra && pos.overIndex !== null && pos.overIndex === this.draggedRowIndex) {\n this.clearDropTargetClasses();\n return;\n }\n\n // canDrop check (same-window only — payload visible)\n if (session && this.config.canDrop) {\n const accepted = this.config.canDrop(session.payload, pos.insertIndex);\n this.gridElement.classList.toggle('tbw-grid--drop-target-active', accepted);\n this.gridElement.classList.toggle('tbw-grid--drop-target-rejected', !accepted);\n if (!accepted) {\n this.clearDropTargetClasses();\n return;\n }\n } else {\n this.gridElement.classList.add('tbw-grid--drop-target-active');\n }\n\n this.dropRowIndex = pos.insertIndex;\n this.applyDropPositionClasses(rowEl, pos.isBefore);\n\n // Auto-scroll the target viewport\n if (this.config.autoScroll !== false) {\n this.ensureAutoScroller();\n this.autoScroller?.onPointerMove(de.clientY);\n }\n }\n\n private onDragLeave(de: DragEvent): void {\n const rowEl = (de.target as HTMLElement).closest('.data-grid-row') as HTMLElement | null;\n if (rowEl) rowEl.classList.remove('drop-target', 'drop-before', 'drop-after');\n // Tear down grid-level state when the cursor leaves the grid entirely\n if (de.currentTarget && !this.gridElement.contains(de.relatedTarget as Node)) {\n this.gridElement.classList.remove('tbw-grid--drop-target-active', 'tbw-grid--drop-target-rejected');\n this.autoScroller?.stop();\n }\n }\n\n private onDrop(de: DragEvent): void {\n de.preventDefault();\n this.autoScroller?.stop();\n this.gridElement.classList.remove('tbw-grid--drop-target-active', 'tbw-grid--drop-target-rejected');\n this.clearDropTargetClasses();\n\n const dt = de.dataTransfer;\n if (!dt) return;\n\n // Resolve payload — prefer same-window session, fall back to dataTransfer JSON\n const session = getCurrentDragSession<T>();\n let payload: RowDragPayload<T> | null = session?.payload ?? null;\n let liveRows: T[] | null = null;\n\n if (payload) {\n const lookup = lookupDragSession<T>(payload.sessionId);\n if (lookup) liveRows = lookup;\n } else {\n const raw = dt.getData(TBW_ROW_DRAG_MIME);\n payload = decodePayload<T>(raw);\n if (payload) {\n const lookup = lookupDragSession<T>(payload.sessionId);\n if (lookup) liveRows = lookup;\n }\n }\n if (!payload) return;\n\n // Drop position (recompute in case dragover wasn't called for a few frames)\n const rowEl = (de.target as HTMLElement).closest('.data-grid-row') as HTMLElement | null;\n const rows = this.internalGrid._rows ?? [];\n const pos = computeDropPosition(rowEl, de.clientY, (el) => this.getRowIndex(el), rows.length);\n let targetIndex = this.dropRowIndex ?? pos.insertIndex;\n\n const isIntra = payload.sourceGridId === this.gridId;\n const dropZone = this.config.dropZone ?? '';\n\n if (isIntra) {\n // Intra-grid path — emit `row-move`.\n const fromIndex = payload.rowIndices[0];\n // Adjust toIndex when dropping after the dragged row (single-row only)\n if (payload.rowIndices.length === 1 && targetIndex > fromIndex) targetIndex--;\n if (fromIndex === targetIndex) return;\n const row = (liveRows ?? payload.rows)[0];\n if (!this.canMoveRow(fromIndex, targetIndex)) return;\n this.executeIntraGridMove(row, fromIndex, targetIndex, 'drag');\n return;\n }\n\n // Cross-grid path\n if (!dropZone || dropZone !== payload.dropZone) return;\n\n // canDrop final check\n if (this.config.canDrop && !this.config.canDrop(payload, targetIndex)) {\n this.gridElement.classList.add('tbw-grid--drop-target-rejected');\n setTimeout(() => this.gridElement.classList.remove('tbw-grid--drop-target-rejected'), 200);\n return;\n }\n\n // Resolve final row references — live (same-window) or deserialized JSON\n const deserialize = this.config.deserializeRow ?? ((r: unknown) => r as T);\n const incomingRows: T[] = liveRows ?? payload.rows.map((r) => deserialize(r as unknown));\n\n const dropDetail: RowDropDetail<T> = {\n payload,\n sourceGridId: payload.sourceGridId,\n targetIndex,\n operation: payload.operation,\n };\n if (this.emitCancelable('row-drop', dropDetail)) return;\n\n // Insert into target grid's _rows\n const targetRows = [...rows];\n targetRows.splice(targetIndex, 0, ...(incomingRows as unknown[]));\n this.grid.rows = targetRows;\n\n // Locate the source plugin in THIS window. If it's here we handle the\n // source-side mutation directly; if it isn't, we broadcast a message and\n // let the source-window plugin (if any) handle removal + transfer emit.\n const sourcePlugin = this.findPeerOnGrid(payload.sourceGridId);\n\n // Remove from source grid's _rows when operation === 'move' (same-window)\n if (payload.operation === 'move' && sourcePlugin) {\n const sourceGrid = document.getElementById(payload.sourceGridId) as\n (HTMLElement & { rows?: unknown[]; _rows?: unknown[] }) | null;\n if (sourceGrid) {\n const srcRows = (sourceGrid._rows ?? sourceGrid.rows ?? []).slice();\n // Remove from highest index down so earlier indices stay stable\n const sortedIndices = [...payload.rowIndices].sort((a, b) => b - a);\n for (const idx of sortedIndices) {\n if (idx >= 0 && idx < srcRows.length) srcRows.splice(idx, 1);\n }\n sourceGrid.rows = srcRows;\n }\n }\n\n // Mark accepted on the source plugin so dragend knows (same-window only —\n // cross-window source flips its own flag in `onRemoteTransfer`).\n if (sourcePlugin) sourcePlugin.dragAccepted = true;\n\n // Emit row-transfer on the target. The source's `row-transfer` is fired\n // either here (same-window) or by the source plugin in `onRemoteTransfer`\n // (cross-window).\n const transferDetail: RowTransferDetail<T> = {\n rows: incomingRows,\n fromGridId: payload.sourceGridId,\n toGridId: this.gridId,\n fromIndices: payload.rowIndices,\n toIndex: targetIndex,\n operation: payload.operation,\n };\n this.emit('row-transfer', transferDetail);\n\n if (sourcePlugin) {\n sourcePlugin.emitTransfer(transferDetail);\n } else {\n // Cross-window: broadcast so the source window can finish its half of\n // the transfer (row removal on `move`, `row-transfer` emit, accepted flip).\n broadcastRemoteTransfer({\n type: 'tbw-row-drag-drop:transfer',\n sessionId: payload.sessionId,\n sourceGridId: payload.sourceGridId,\n toGridId: this.gridId,\n dropZone,\n rowIndices: payload.rowIndices,\n toIndex: targetIndex,\n operation: payload.operation,\n // Re-use the payload's already-serialized rows so the source side can\n // round-trip them through `deserializeRow` for its `row-transfer` event.\n serializedRows: payload.rows as unknown[],\n });\n }\n }\n\n /**\n * Source-window handler for a remote `row-transfer` broadcast from a target\n * window. Only runs on the plugin instance whose grid id matches the message.\n * @internal\n */\n private onRemoteTransfer(msg: RemoteTransferMessage): void {\n if (msg.sourceGridId !== this.gridId) return;\n // Defensive: only act when the message zone matches our zone. This prevents\n // a stray message from a grid sharing the same id but a different zone\n // (e.g. independent demos in different tabs) from mutating our rows.\n const dropZone = this.config.dropZone ?? '';\n if (!dropZone || msg.dropZone !== dropZone) return;\n\n // Resolve incoming rows (for the `row-transfer` event payload).\n const deserialize = this.config.deserializeRow ?? ((r: unknown) => r as T);\n const incomingRows: T[] = msg.serializedRows.map((r) => deserialize(r));\n\n if (msg.operation === 'move') {\n const srcRows = (this.internalGrid._rows ?? this.sourceRows).slice();\n const sortedIndices = [...msg.rowIndices].sort((a, b) => b - a);\n for (const idx of sortedIndices) {\n if (idx >= 0 && idx < srcRows.length) srcRows.splice(idx, 1);\n }\n this.grid.rows = srcRows as unknown[];\n }\n\n // Flip accepted before dragend (best-effort — the message may arrive after\n // dragend has already fired with `accepted: false`; `row-transfer` is the\n // authoritative success signal).\n this.dragAccepted = true;\n\n this.emit('row-transfer', {\n rows: incomingRows,\n fromGridId: msg.sourceGridId,\n toGridId: msg.toGridId,\n fromIndices: msg.rowIndices,\n toIndex: msg.toIndex,\n operation: msg.operation,\n } as RowTransferDetail<T>);\n }\n\n private onDragEnd(): void {\n if (this.dragSessionId) clearDragSession(this.dragSessionId);\n clearCurrentDragSession();\n this.autoScroller?.stop();\n this.gridElement.classList.remove('tbw-grid--drag-source');\n\n if (this.isDragging) {\n const endDetail: RowDragEndDetail<T> = {\n rows: this.draggedRows,\n indices: this.draggedIndices,\n accepted: this.dragAccepted,\n };\n this.emit('row-drag-end', endDetail);\n }\n this.clearDragClasses();\n this.resetDragState();\n }\n // #endregion\n\n // #region Helpers\n\n /** Public wrapper so a peer plugin can dispatch `row-transfer` on this grid. @internal */\n emitTransfer(detail: RowTransferDetail<T>): void {\n this.emit('row-transfer', detail);\n }\n\n /** Find the peer `RowDragDropPlugin` instance on another grid by id. */\n private findPeerOnGrid(gridId: string): RowDragDropPlugin<T> | null {\n const peerEl = document.getElementById(gridId) as\n (HTMLElement & { getPluginByName?: (name: string) => RowDragDropPlugin<T> | undefined }) | null;\n if (!peerEl?.getPluginByName) return null;\n return peerEl.getPluginByName('rowDragDrop') ?? null;\n }\n\n // #region Click-only move menu (WCAG 2.2 SC 2.5.7)\n\n /** Grids in this window sharing our (non-empty) `dropZone`. */\n private peersInDropZone(): RowDragDropPlugin<T>[] {\n const dropZone = this.config.dropZone ?? '';\n if (!dropZone) return [];\n const peers: RowDragDropPlugin<T>[] = [];\n for (const candidate of attachedPlugins) {\n const peer = candidate as RowDragDropPlugin<T>;\n if (peer === this) continue;\n if ((peer.config.dropZone ?? '') === dropZone) peers.push(peer);\n }\n return peers;\n }\n\n /** Human-readable name for this grid, used in the transfer menu. */\n private get gridLabel(): string {\n const host = this.gridElement;\n return host?.getAttribute('aria-label') || host?.id || 'grid';\n }\n\n /**\n * Open the click-only alternative to dragging a row: reorder within this grid\n * and, when a `dropZone` is configured, send the row to a peer grid — all\n * with single clicks or taps, no press-hold-move gesture.\n */\n private openMoveMenu(handle: HTMLElement): void {\n const rowEl = handle.closest('.data-grid-row') as HTMLElement | null;\n if (!rowEl) return;\n const rowIndex = this.getRowIndex(rowEl);\n if (rowIndex < 0) return;\n\n const rows = this.internalGrid._rows ?? this.sourceRows;\n const actions: DragAlternativeAction[] = [\n {\n label: 'Move up',\n disabled: rowIndex === 0 || !this.canMoveRow(rowIndex, rowIndex - 1),\n run: () => this.moveRow(rowIndex, rowIndex - 1),\n },\n {\n label: 'Move down',\n disabled: rowIndex >= rows.length - 1 || !this.canMoveRow(rowIndex, rowIndex + 1),\n run: () => this.moveRow(rowIndex, rowIndex + 1),\n },\n {\n label: 'Move to top',\n disabled: rowIndex === 0 || !this.canMoveRow(rowIndex, 0),\n run: () => this.moveRow(rowIndex, 0),\n },\n {\n label: 'Move to bottom',\n disabled: rowIndex >= rows.length - 1 || !this.canMoveRow(rowIndex, rows.length - 1),\n run: () => this.moveRow(rowIndex, rows.length - 1),\n },\n ];\n\n const verb = (this.config.operation ?? 'move') === 'copy' ? 'Copy to' : 'Send to';\n for (const peer of this.peersInDropZone()) {\n actions.push({\n label: `${verb} ${peer.gridLabel}`,\n run: () => this.transferToPeer(peer, rowIndex),\n });\n }\n\n this.moveMenu ??= createDragAlternativeMenu('tbw-row-move-menu', 'tbw-row-move-menu');\n this.moveMenu.open(handle, `Move row ${rowIndex + 1}`, actions);\n }\n\n /**\n * Click-only equivalent of dropping the row onto `peer`. Runs the same vetoes\n * and emits the same events as the drag path (`row-drag-start`, `row-drop`,\n * `row-transfer`) so consumers cannot tell the two apart.\n */\n private transferToPeer(peer: RowDragDropPlugin<T>, rowIndex: number): void {\n const dropZone = this.config.dropZone ?? '';\n if (!dropZone) return;\n\n const { rows, indices } = this.resolveDraggedRows(rowIndex);\n if (rows.length === 0) return;\n if (this.config.canDrag && !this.config.canDrag(rows[0], rowIndex)) return;\n\n const operation = this.config.operation ?? 'move';\n if (this.emitCancelable('row-drag-start', { rows, indices, operation, dropZone } as RowDragStartDetail<T>)) return;\n\n const serialize = this.config.serializeRow ?? ((r: T) => r);\n const payload: RowDragPayload<T> = {\n sessionId: newDragSessionId(),\n sourceGridId: this.gridId,\n dropZone,\n rows: rows.map(serialize) as T[],\n rowIndices: indices,\n operation,\n };\n\n const toIndex = peer.acceptTransfer(payload, rows);\n if (toIndex < 0) return;\n\n if (operation === 'move') {\n const srcRows = [...(this.internalGrid._rows ?? this.sourceRows)];\n for (const idx of [...indices].sort((a, b) => b - a)) {\n if (idx >= 0 && idx < srcRows.length) srcRows.splice(idx, 1);\n }\n this.grid.rows = srcRows as unknown[];\n }\n\n const detail: RowTransferDetail<T> = {\n rows,\n fromGridId: this.gridId,\n toGridId: peer.gridId,\n fromIndices: indices,\n toIndex,\n operation,\n };\n peer.emitTransfer(detail);\n this.emit('row-transfer', detail);\n }\n\n /**\n * Target half of {@link RowDragDropPlugin.transferToPeer}. Returns the insert\n * index, or `-1` when the transfer was rejected (zone mismatch, `canDrop`\n * veto, or a cancelled `row-drop`).\n *\n * @internal\n */\n acceptTransfer(payload: RowDragPayload<T>, liveRows: readonly T[]): number {\n const dropZone = this.config.dropZone ?? '';\n if (!dropZone || dropZone !== payload.dropZone) return -1;\n\n const rows = this.internalGrid._rows ?? this.sourceRows;\n const targetIndex = rows.length;\n if (this.config.canDrop && !this.config.canDrop(payload, targetIndex)) return -1;\n\n const dropDetail: RowDropDetail<T> = {\n payload,\n sourceGridId: payload.sourceGridId,\n targetIndex,\n operation: payload.operation,\n };\n if (this.emitCancelable('row-drop', dropDetail)) return -1;\n\n this.grid.rows = [...(rows as unknown[]), ...(liveRows as unknown[])];\n return targetIndex;\n }\n // #endregion\n\n private resolveDraggedRows(originIndex: number): { rows: T[]; indices: number[] } {\n const rows = this.internalGrid._rows ?? this.sourceRows;\n const originRow = rows[originIndex] as T;\n\n // If a selection plugin is loaded and the dragged row is selected, drag the whole selection.\n const selection = this.grid?.getPluginByName?.('selection') as\n { getSelectedRowIndices?: () => number[]; getSelectedRows?: <U>() => U[] } | undefined;\n if (selection?.getSelectedRowIndices) {\n const selectedIndices = selection.getSelectedRowIndices();\n if (selectedIndices.includes(originIndex) && selectedIndices.length > 1) {\n const sorted = [...selectedIndices].sort((a, b) => a - b);\n return {\n rows: sorted.map((i) => rows[i] as T),\n indices: sorted,\n };\n }\n }\n return { rows: [originRow], indices: [originIndex] };\n }\n\n private ensureAutoScroller(): void {\n if (this.autoScroller) return;\n const viewport = this.gridElement.querySelector<HTMLElement>('.rows-viewport');\n if (!viewport) return;\n const opts = typeof this.config.autoScroll === 'object' ? this.config.autoScroll : undefined;\n this.autoScroller = createAutoScroller(viewport, opts, (active) => {\n this.gridElement.classList.toggle('tbw-grid--auto-scrolling', active);\n });\n }\n\n private applyDropPositionClasses(rowEl: HTMLElement | null, isBefore: boolean): void {\n this.clearDropTargetClasses();\n if (!rowEl) return;\n rowEl.classList.add('drop-target');\n rowEl.classList.toggle('drop-before', isBefore);\n rowEl.classList.toggle('drop-after', !isBefore);\n }\n\n private clearDropTargetClasses(): void {\n this.gridElement?.querySelectorAll('.data-grid-row.drop-target').forEach((row) => {\n row.classList.remove('drop-target', 'drop-before', 'drop-after');\n });\n }\n\n private clearDragClasses(): void {\n this.gridElement?.querySelectorAll('.data-grid-row').forEach((row) => {\n row.classList.remove(GridClasses.DRAGGING, 'drop-target', 'drop-before', 'drop-after');\n });\n }\n\n private resetDragState(): void {\n this.isDragging = false;\n this.draggedRowIndex = null;\n this.draggedRows = [];\n this.draggedIndices = [];\n this.dragSessionId = null;\n this.dragAccepted = false;\n this.dropRowIndex = null;\n this.pendingMove = null;\n }\n\n private getRowIndex(rowEl: HTMLElement): number {\n const cell = rowEl.querySelector('.cell[data-row]');\n return cell ? parseInt(cell.getAttribute('data-row') ?? '-1', 10) : -1;\n }\n\n private clearDebounceTimer(): void {\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = null;\n }\n }\n\n // #endregion\n\n // #region Intra-Grid Move\n\n private handleKeyboardMove(row: T, fromIndex: number, toIndex: number, focusCol: number): void {\n if (!this.pendingMove) {\n this.pendingMove = { originalIndex: fromIndex, currentIndex: toIndex, row };\n } else {\n this.pendingMove.currentIndex = toIndex;\n }\n this.lastFocusCol = focusCol;\n\n const grid = this.internalGrid;\n const rows = [...(grid._rows ?? this.sourceRows)];\n const [movedRow] = rows.splice(fromIndex, 1);\n rows.splice(toIndex, 0, movedRow);\n\n grid._rows = rows;\n grid._focusRow = toIndex;\n grid._focusCol = focusCol;\n grid.refreshVirtualWindow(true);\n ensureCellVisible(grid);\n\n this.clearDebounceTimer();\n this.debounceTimer = setTimeout(() => this.flushPendingMove(), this.config.debounceMs ?? 300);\n }\n\n private flushPendingMove(): void {\n this.clearDebounceTimer();\n if (!this.pendingMove) return;\n const { originalIndex, currentIndex, row: movedRow } = this.pendingMove;\n this.pendingMove = null;\n if (originalIndex === currentIndex) return;\n\n const grid = this.internalGrid;\n // `grid._rows` already reflects the post-move order (mutated incrementally\n // by `handleKeyboardMove`); report it as `detail.rows` so consumers see\n // the actual reordered array, not the original `sourceRows` snapshot.\n const postMoveRows = (grid._rows ?? this.sourceRows) as T[];\n const detail: RowMoveDetail<T> = {\n row: movedRow as T,\n fromIndex: originalIndex,\n toIndex: currentIndex,\n rows: [...postMoveRows],\n source: 'keyboard',\n };\n const cancelled = this.emitCancelable('row-move', detail);\n if (cancelled) {\n // Revert: restore the original snapshot. `sourceRows` was never mutated\n // during the pending move (only `grid._rows` was), so resetting from it\n // is the correct rollback regardless of how many incremental keyboard\n // moves accumulated.\n grid._rows = [...this.sourceRows];\n grid._focusRow = originalIndex;\n grid._focusCol = this.lastFocusCol;\n grid.refreshVirtualWindow(true);\n ensureCellVisible(grid);\n }\n }\n\n private executeIntraGridMove(row: unknown, fromIndex: number, toIndex: number, source: 'keyboard' | 'drag'): void {\n const rows = [...this.sourceRows];\n const [movedRow] = rows.splice(fromIndex, 1);\n rows.splice(toIndex, 0, movedRow);\n const detail: RowMoveDetail<T> = {\n row: row as T,\n fromIndex,\n toIndex,\n rows: rows as T[],\n source,\n };\n const cancelled = this.emitCancelable('row-move', detail);\n if (cancelled) return;\n if (this.animationType === 'flip' && this.gridElement) {\n const oldPositions = this.captureRowPositions();\n this.grid.rows = rows;\n requestAnimationFrame(() => {\n void this.gridElement.offsetHeight;\n this.animateFLIP(oldPositions, fromIndex, toIndex);\n });\n } else {\n this.grid.rows = rows;\n }\n }\n\n private captureRowPositions(): Map<number, number> {\n const positions = new Map<number, number>();\n this.gridElement?.querySelectorAll('.data-grid-row').forEach((row) => {\n const rowIndex = this.getRowIndex(row as HTMLElement);\n if (rowIndex >= 0) positions.set(rowIndex, row.getBoundingClientRect().top);\n });\n return positions;\n }\n\n private animateFLIP(oldPositions: Map<number, number>, fromIndex: number, toIndex: number): void {\n const gridEl = this.gridElement;\n if (!gridEl || oldPositions.size === 0) return;\n\n const minIndex = Math.min(fromIndex, toIndex);\n const maxIndex = Math.max(fromIndex, toIndex);\n const rowsToAnimate: { el: HTMLElement; deltaY: number }[] = [];\n\n gridEl.querySelectorAll('.data-grid-row').forEach((row) => {\n const rowEl = row as HTMLElement;\n const newRowIndex = this.getRowIndex(rowEl);\n if (newRowIndex < 0 || newRowIndex < minIndex || newRowIndex > maxIndex) return;\n let oldIndex: number;\n if (newRowIndex === toIndex) oldIndex = fromIndex;\n else if (fromIndex < toIndex) oldIndex = newRowIndex + 1;\n else oldIndex = newRowIndex - 1;\n const oldTop = oldPositions.get(oldIndex);\n if (oldTop === undefined) return;\n const newTop = rowEl.getBoundingClientRect().top;\n const deltaY = oldTop - newTop;\n if (Math.abs(deltaY) > 1) rowsToAnimate.push({ el: rowEl, deltaY });\n });\n\n if (rowsToAnimate.length === 0) return;\n\n rowsToAnimate.forEach(({ el, deltaY }) => {\n el.style.transform = `translateY(${deltaY}px)`;\n });\n void gridEl.offsetHeight;\n\n const duration = this.animationDuration;\n requestAnimationFrame(() => {\n rowsToAnimate.forEach(({ el }) => {\n el.classList.add('flip-animating');\n el.style.transform = '';\n });\n setTimeout(() => {\n rowsToAnimate.forEach(({ el }) => {\n el.style.transform = '';\n el.classList.remove('flip-animating');\n });\n }, duration + 50);\n });\n }\n\n // #endregion\n}\n"],"mappings":"koBA8BA,IAAI,EAAiF,KAQrF,SAAgB,IACd,OAAO,CACT,CAGA,SAAgB,IACd,EAAiB,IACnB,CAOA,IAAa,EAAoB,mCAQjC,SAAgB,EAAkB,GAChC,MAAM,EAAQ,EAAK,MAAM,kDACzB,IAAK,EAAO,OAAO,KACnB,IACE,OAAO,mBAAmB,EAAM,GAClC,CAAA,MACE,OAAO,EAAM,EACf,CACF,CAiDA,SAAgB,EAAiB,GAC/B,OAAO,KAAK,UAAU,EACxB,CAmDA,SAAgB,EACd,EACA,EACA,EACA,GAEA,IAAK,EACH,MAAO,CAAE,UAAW,KAAM,YAAa,EAAW,UAAU,GAE9D,MAAM,EAAc,EAAiB,GACrC,GAAI,EAAc,EAChB,MAAO,CAAE,UAAW,KAAM,YAAa,EAAW,UAAU,GAE9D,MAAM,EAAO,EAAM,wBAEb,EAAW,EADJ,EAAK,IAAM,EAAK,OAAS,EAEtC,MAAO,CACL,UAAW,EACX,YAAa,EAAW,EAAc,EAAc,EACpD,WAEJ,CC1KA,SAAS,IACP,MAAqD,mBAAvC,YAAY,WAAW,WACvC,CAwDA,SAAgB,EAA0B,EAAY,GACpD,IAAI,EAA8B,KAC9B,GAAS,EACT,GAAW,EACf,MAAM,EAAQ,IAAI,gBAElB,SAAS,IACF,GAAW,IAChB,GAAS,EACL,KAAmB,EAAK,cAC5B,EAAK,QAAS,EAChB,CAyDA,OAfA,SAAS,iBACP,cACC,IACK,GAAU,IAAS,EAAE,eAAe,SAAS,IAAO,KAE1D,CAAE,SAAS,EAAM,OAAQ,EAAM,SAEjC,SAAS,iBACP,UACC,IACkC,WAA5B,EAAoB,KAAkB,KAE7C,CAAE,SAAS,EAAM,OAAQ,EAAM,SAG1B,CACL,WAAI,GACF,OAAO,CACT,EACA,IAAA,CAA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AO,CAErB,CAEA,mBAAA,GACE,MAAM,EAAY,IAAI,IAKtB,OAJA,KAAK,aAAa,iBAAiB,kBAAkB,QAAS,IAC5D,MAAM,EAAW,KAAK,YAAY,GAC9B,GAAY,GAAG,EAAU,IAAI,EAAU,EAAI,wBAAwB,OAElE,CACT,CAEA,WAAA,CAAoB,EAAmC,EAAmB,GACxE,MAAM,EAAS,KAAK,YACpB,IAAK,GAAgC,IAAtB,EAAa,KAAY,OAExC,MAAM,EAAW,KAAK,IAAI,EAAW,GAC/B,EAAW,KAAK,IAAI,EAAW,GAC/B,EAAuD,GAiB7D,GAfA,EAAO,iBAAiB,kBAAkB,QAAS,IACjD,MAAM,EAAQ,EACR,EAAc,KAAK,YAAY,GACrC,GAAI,EAAc,GAAK,EAAc,GAAY,EAAc,EAAU,OACzE,IAAI,EACyB,EAAzB,IAAgB,EAAoB,EAC/B,EAAY,EAAoB,EAAc,EACvC,EAAc,EAC9B,MAAM,EAAS,EAAa,IAAI,GAChC,QAAe,IAAX,EAAsB,OAE1B,MAAM,EAAS,EADA,EAAM,wBAAwB,IAEzC,KAAK,IAAI,GAAU,GAAG,EAAc,KAAK,CAAE,GAAI,EAAO,aAG/B,IAAzB,EAAc,OAAc,OAEhC,EAAc,QAAA,EAAW,KAAI,aAC3B,EAAG,MAAM,UAAY,cAAc,SAErC,EAAY,aAEZ,MAAM,EAAW,KAAK,kBACtB,sBAAA,KACE,EAAc,QAAA,EAAW,SACvB,EAAG,UAAU,IAAI,kBACjB,EAAG,MAAM,UAAY,KAEvB,WAAA,KACE,EAAc,QAAA,EAAW,SACvB,EAAG,MAAM,UAAY,GACrB,EAAG,UAAU,OAAO,qBAErB,EAAW,KAElB"}
|
|
1
|
+
{"version":3,"file":"row-drag-drop.umd.js","names":[],"sources":["../../../../../libs/grid/src/lib/plugins/shared/drag-alternative-menu.ts","../../../../../libs/grid/src/lib/plugins/shared/drag-drop-protocol.ts","../../../../../libs/grid/src/lib/plugins/row-drag-drop/row-drag-drop.css?inline","../../../../../libs/grid/src/lib/plugins/row-drag-drop/row-drag-drop-plugin.ts"],"sourcesContent":["/**\n * Generic click-only action menu — the shared building block for WCAG 2.2\n * SC 2.5.7 \"Dragging Movements\" alternatives in plugins.\n *\n * Every drag affordance in the grid needs a path that works with plain clicks\n * or taps. A keyboard equivalent is **not** enough: SC 2.5.7 is specifically\n * about pointer input, and the W3C Understanding text calls out \"a pop-up menu\n * after tap\" as a conforming alternative. This module is that pop-up.\n *\n * Lives under `plugins/shared/` on purpose: each plugin bundle is built\n * self-contained, so this code is duplicated into the plugins that use it and\n * never lands in the core `index.js` budget.\n *\n * @since 3.6.0\n * @internal\n */\n\n/** Gap between the anchor element and the menu, in px. */\nconst ANCHOR_GAP_PX = 6;\n\n/** Runtime check — happy-dom and older browsers may lack the Popover API. */\nfunction supportsPopover(): boolean {\n return typeof HTMLElement.prototype?.showPopover === 'function';\n}\n\nlet hoverlessQuery: MediaQueryList | null | undefined;\n\n/** Whether the primary pointer cannot hover (touch, most switch devices). */\nfunction isHoverless(): boolean {\n if (hoverlessQuery === undefined) hoverlessQuery = globalThis.matchMedia?.('(hover: none)') ?? null;\n return hoverlessQuery?.matches ?? false;\n}\n\n/**\n * Whether a plugin should also expose its drag alternative as a dedicated\n * inline control, on top of the menu that is always available.\n *\n * Hover-less pointers get one unconditionally — a control revealed on hover is\n * unreachable when nothing can hover, and long-press is the wrong fallback for\n * the tremor and low-dexterity users SC 2.5.7 exists for.\n *\n * Driven by `a11y.dragAlternatives` on the grid config.\n */\nexport function prefersInlineDragAlternative(grid: {\n effectiveConfig?: { a11y?: { dragAlternatives?: 'menu' | 'inline' } };\n}): boolean {\n return grid.effectiveConfig?.a11y?.dragAlternatives === 'inline' || isHoverless();\n}\n\n/** One clickable entry in the menu. */\nexport interface DragAlternativeAction {\n /** Visible text, also the accessible name. */\n label: string;\n /** Render the entry but refuse the click (e.g. \"Move up\" on the first row). */\n disabled?: boolean;\n /** Invoked on click; the menu closes first so focus handling is predictable. */\n run(): void;\n}\n\nexport interface DragAlternativeMenu {\n /**\n * Show `actions` anchored to `anchor`, with `label` as the group's accessible\n * name. Mounted inside the anchor's grid host so it inherits theme tokens.\n */\n open(anchor: HTMLElement, label: string, actions: readonly DragAlternativeAction[]): void;\n /** Hide the menu. Safe to call when already closed. */\n close(): void;\n /** Remove the element and every document-level listener. */\n dispose(): void;\n /** The menu element, or `null` before the first {@link DragAlternativeMenu.open}. */\n readonly element: HTMLElement | null;\n}\n\n/**\n * Create a menu instance.\n *\n * @param id - DOM id for the menu element, unique per owning plugin.\n * @param className - Root class name, so each plugin can style its own menu.\n */\nexport function createDragAlternativeMenu(id: string, className: string): DragAlternativeMenu {\n let root: HTMLDivElement | null = null;\n let opened = false;\n let disposed = false;\n const abort = new AbortController();\n\n function close(): void {\n if (!opened || !root) return;\n opened = false;\n if (supportsPopover()) root.hidePopover();\n root.hidden = true;\n }\n\n function build(): HTMLDivElement {\n const el = document.createElement('div');\n el.id = id;\n el.className = className;\n el.setAttribute('popover', 'manual');\n el.setAttribute('role', 'group');\n // Without the Popover API there is no UA `display: none`, so hide it here.\n el.hidden = true;\n // Tabbing past either end dismisses instead of stranding the user — the\n // menu has no visible trigger to tab back to. A null `relatedTarget` (click\n // focus in Firefox/Safari, focus leaving the document) is ignored.\n el.addEventListener(\n 'focusout',\n (e) => {\n const next = (e as FocusEvent).relatedTarget;\n if (next instanceof Node && !el.contains(next)) close();\n },\n { signal: abort.signal },\n );\n return el;\n }\n\n /**\n * Position against the anchor in viewport coordinates. The menu lives in the\n * top layer, so its containing block is the viewport regardless of where the\n * anchor sits in the DOM.\n */\n function place(anchor: HTMLElement): void {\n if (!root) return;\n const a = anchor.getBoundingClientRect();\n const box = root.getBoundingClientRect();\n const left = Math.max(4, Math.min(a.left, window.innerWidth - box.width - 4));\n const below = a.bottom + ANCHOR_GAP_PX;\n const top = below + box.height <= window.innerHeight ? below : Math.max(4, a.top - ANCHOR_GAP_PX - box.height);\n root.style.left = `${Math.round(left)}px`;\n root.style.top = `${Math.round(top)}px`;\n }\n\n // Any pointer press outside the menu dismisses it. Capture phase so the press\n // that lands on a grid cell still reaches its own handler afterwards.\n document.addEventListener(\n 'pointerdown',\n (e) => {\n if (opened && root && !e.composedPath().includes(root)) close();\n },\n { capture: true, signal: abort.signal },\n );\n document.addEventListener(\n 'keydown',\n (e) => {\n if ((e as KeyboardEvent).key === 'Escape') close();\n },\n { capture: true, signal: abort.signal },\n );\n\n return {\n get element() {\n return root;\n },\n open(anchor, label, actions) {\n if (disposed || actions.length === 0) return;\n if (!root) root = build();\n // Mount inside the grid host (light DOM) so theme custom properties and\n // `color-scheme` cascade in; the top layer keeps it out of overflow.\n const host = anchor.closest<HTMLElement>('tbw-grid, [data-tbw-grid]') ?? document.body;\n if (root.parentNode !== host) host.appendChild(root);\n root.setAttribute('aria-label', label);\n root.replaceChildren();\n for (const action of actions) {\n const btn = document.createElement('button');\n btn.type = 'button';\n btn.className = `${className}-item`;\n btn.textContent = action.label;\n btn.disabled = action.disabled === true;\n btn.addEventListener('click', () => {\n close();\n action.run();\n });\n root.appendChild(btn);\n }\n root.hidden = false;\n if (!opened && supportsPopover()) root.showPopover();\n opened = true;\n place(anchor);\n root.querySelector<HTMLButtonElement>('button:not([disabled])')?.focus();\n },\n close,\n dispose() {\n disposed = true;\n close();\n abort.abort();\n root?.remove();\n root = null;\n },\n };\n}\n","/**\n * Drag-Drop Protocol — shared utilities for cross-grid row drag-and-drop.\n *\n * Used by `RowDragDropPlugin` (and any future plugin that participates in the\n * tbw row-drag protocol). Centralises:\n *\n * - MIME type constants and zone tagging (visible in `dataTransfer.types`)\n * - Payload codec for cross-window / cross-iframe transfers\n * - Drop-position math (midpoint algorithm)\n * - Auto-scroll engine (rAF loop, edge detection, boundary clamp)\n * - Plain-text TSV fallback for drags out to Notepad / Excel / Slack\n *\n * @internal Plugin shared utility (not part of the public API).\n */\n\nimport type { ColumnConfig } from '../../core/types';\n\n// ---------------------------------------------------------------------------\n// Same-window current-session tracker\n// ---------------------------------------------------------------------------\n\n/**\n * Module-level \"active drag session\" — set on dragstart by the source grid,\n * cleared on dragend. Lets target grids read the full payload synchronously\n * during `dragover` (browsers hide `dataTransfer.getData()` during dragover\n * for security). Cross-window drags don't have access to this module and\n * fall back to a generic accept-check followed by a drop-time canDrop call.\n *\n * @internal\n */\nlet currentSession: { sessionId: string; payload: RowDragPayload<unknown> } | null = null;\n\n/** @internal */\nexport function setCurrentDragSession<T>(sessionId: string, payload: RowDragPayload<T>): void {\n currentSession = { sessionId, payload: payload as RowDragPayload<unknown> };\n}\n\n/** @internal */\nexport function getCurrentDragSession<T = unknown>(): { sessionId: string; payload: RowDragPayload<T> } | null {\n return currentSession as { sessionId: string; payload: RowDragPayload<T> } | null;\n}\n\n/** @internal */\nexport function clearCurrentDragSession(): void {\n currentSession = null;\n}\n\n// ---------------------------------------------------------------------------\n// MIME types\n// ---------------------------------------------------------------------------\n\n/** Base MIME type carried on `dataTransfer` for tbw row drags. */\nexport const TBW_ROW_DRAG_MIME = 'application/x-tbw-grid-rows+json';\n\n/** Build a zone-tagged MIME type, visible in `dataTransfer.types` during dragover. */\nexport function mimeForZone(zone: string): string {\n return `${TBW_ROW_DRAG_MIME};zone=${encodeURIComponent(zone)}`;\n}\n\n/** Extract the zone from a tagged MIME, or `null` if untagged. */\nexport function parseZoneFromMime(mime: string): string | null {\n const match = mime.match(/^application\\/x-tbw-grid-rows\\+json;zone=(.*)$/);\n if (!match) return null;\n try {\n return decodeURIComponent(match[1]);\n } catch {\n return match[1];\n }\n}\n\n/**\n * Find the first MIME entry in `types` whose zone matches `zone`.\n * Used during `dragover` for the accept-check (browsers hide `getData()`\n * during dragover, but `types` is always visible).\n */\nexport function findMatchingZoneMime(types: readonly string[], zone: string): string | null {\n for (const t of types) {\n if (parseZoneFromMime(t) === zone) return t;\n }\n return null;\n}\n\n/** Returns true if any tbw row-drag MIME is present in `types`. */\nexport function hasAnyRowDragMime(types: readonly string[]): boolean {\n for (const t of types) {\n if (t === TBW_ROW_DRAG_MIME || t.startsWith(`${TBW_ROW_DRAG_MIME};`)) return true;\n }\n return false;\n}\n\n// ---------------------------------------------------------------------------\n// Payload\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-grid drag payload, carried on `dataTransfer` and (for same-window\n * recovery) keyed in the WeakRef registry by `sessionId`.\n *\n * Re-exported as public API from `plugins/row-drag-drop`.\n * @since 2.4.0\n */\nexport interface RowDragPayload<T = unknown> {\n /** Drag session id (matches the WeakRef registry key). */\n sessionId: string;\n /** Source grid id (`grid.id` or auto-generated UUID). */\n sourceGridId: string;\n /** Drop zone the source grid is participating in. */\n dropZone: string;\n /** Serialized row payload (JSON-safe). For same-window drops, recovered live via the registry. */\n rows: T[];\n /** Original indices in the source grid's `_rows` array. */\n rowIndices: number[];\n /** Move (default) removes from source; copy leaves source intact. */\n operation: 'move' | 'copy';\n}\n\n/** Encode a payload to the JSON string written to `dataTransfer`. */\nexport function encodePayload<T>(payload: RowDragPayload<T>): string {\n return JSON.stringify(payload);\n}\n\n/** Decode a payload from the JSON string read off `dataTransfer`. */\nexport function decodePayload<T = unknown>(raw: string): RowDragPayload<T> | null {\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as RowDragPayload<T>;\n if (\n typeof parsed?.sessionId !== 'string' ||\n typeof parsed?.sourceGridId !== 'string' ||\n typeof parsed?.dropZone !== 'string' ||\n !Array.isArray(parsed?.rows) ||\n !Array.isArray(parsed?.rowIndices) ||\n (parsed.operation !== 'move' && parsed.operation !== 'copy')\n ) {\n return null;\n }\n // `rowIndices` is later used for sorting and splicing — reject anything\n // that isn't a finite, non-negative integer to avoid JS coercion bugs\n // (NaN ordering, float splice indices, string concatenation, etc.).\n for (const idx of parsed.rowIndices) {\n if (typeof idx !== 'number' || !Number.isInteger(idx) || idx < 0) return null;\n }\n return parsed;\n } catch {\n return null;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Drop position math\n// ---------------------------------------------------------------------------\n\nexport interface DropPosition {\n /** Target visual row index that the cursor is over, or `null` for empty area. */\n overIndex: number | null;\n /** Final insertion index in the target grid's `_rows`. */\n insertIndex: number;\n /** True when the cursor is above the row midpoint. */\n isBefore: boolean;\n}\n\n/**\n * Compute the insertion index for a drop, given the row element under the\n * cursor (if any), the cursor's clientY, and the total row count when the\n * cursor is in empty space below the last row.\n *\n * - Cursor above row midpoint → insert at `targetIndex`\n * - Cursor below row midpoint → insert at `targetIndex + 1`\n * - Cursor over empty area below the last row → append (`insertIndex = totalRows`)\n */\nexport function computeDropPosition(\n rowEl: HTMLElement | null,\n clientY: number,\n rowIndexResolver: (el: HTMLElement) => number,\n totalRows: number,\n): DropPosition {\n if (!rowEl) {\n return { overIndex: null, insertIndex: totalRows, isBefore: false };\n }\n const targetIndex = rowIndexResolver(rowEl);\n if (targetIndex < 0) {\n return { overIndex: null, insertIndex: totalRows, isBefore: false };\n }\n const rect = rowEl.getBoundingClientRect();\n const midY = rect.top + rect.height / 2;\n const isBefore = clientY < midY;\n return {\n overIndex: targetIndex,\n insertIndex: isBefore ? targetIndex : targetIndex + 1,\n isBefore,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Auto-scroll engine\n// ---------------------------------------------------------------------------\n\nexport interface AutoScrollOptions {\n /** Pixels from the top/bottom edge that activate auto-scroll. */\n edgeSize?: number;\n /** Base scroll speed in pixels-per-frame near the edge. */\n speed?: number;\n /** Max speed at the very edge (linear ramp from `speed` → `maxSpeed`). */\n maxSpeed?: number;\n}\n\nexport interface AutoScroller {\n /** Update pointer position; starts the rAF loop if needed. */\n onPointerMove(clientY: number): void;\n /** Stop the rAF loop and reset state. */\n stop(): void;\n /** True when actively auto-scrolling. */\n readonly isScrolling: boolean;\n}\n\n/**\n * Create an auto-scroller for a viewport element.\n *\n * The scroller runs a `requestAnimationFrame` loop only while the pointer is\n * within `edgeSize` of the viewport's top or bottom and there is room to\n * scroll. Speed ramps linearly from `speed` (at the edge boundary) to\n * `maxSpeed` (at the very edge).\n */\nexport function createAutoScroller(\n viewport: HTMLElement,\n options: AutoScrollOptions = {},\n onScrollChange?: (active: boolean) => void,\n): AutoScroller {\n const edgeSize = options.edgeSize ?? 60;\n const baseSpeed = options.speed ?? 8;\n const maxSpeed = options.maxSpeed ?? 24;\n\n let rafId: number | null = null;\n let pointerY: number | null = null;\n let active = false;\n\n const setActive = (next: boolean): void => {\n if (next === active) return;\n active = next;\n onScrollChange?.(next);\n };\n\n const tick = (): void => {\n rafId = null;\n if (pointerY === null) {\n setActive(false);\n return;\n }\n const rect = viewport.getBoundingClientRect();\n let delta = 0;\n\n if (pointerY < rect.top + edgeSize) {\n const distance = Math.max(0, pointerY - rect.top);\n const ratio = 1 - distance / edgeSize;\n delta = -Math.round(baseSpeed + (maxSpeed - baseSpeed) * ratio);\n } else if (pointerY > rect.bottom - edgeSize) {\n const distance = Math.max(0, rect.bottom - pointerY);\n const ratio = 1 - distance / edgeSize;\n delta = Math.round(baseSpeed + (maxSpeed - baseSpeed) * ratio);\n }\n\n if (delta === 0) {\n setActive(false);\n return;\n }\n\n const before = viewport.scrollTop;\n viewport.scrollTop = before + delta;\n\n // Stop if we hit a boundary (no movement happened)\n if (viewport.scrollTop === before) {\n setActive(false);\n return;\n }\n\n setActive(true);\n rafId = requestAnimationFrame(tick);\n };\n\n return {\n onPointerMove(clientY: number): void {\n pointerY = clientY;\n if (rafId === null) {\n rafId = requestAnimationFrame(tick);\n }\n },\n stop(): void {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n rafId = null;\n }\n pointerY = null;\n setActive(false);\n },\n get isScrolling(): boolean {\n return active;\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// TSV fallback\n// ---------------------------------------------------------------------------\n\n/**\n * Format rows as a TSV string for the `text/plain` drag fallback.\n * Used when the drop target is an external app (Excel, Notepad, Slack).\n *\n * - One row per line, fields separated by `\\t`.\n * - Tabs and newlines in cell values are replaced with spaces.\n * - Skips columns flagged as `utility` (drag handle, checkbox, etc.).\n */\nexport function formatRowsAsTSV<T extends Record<string, unknown>>(\n rows: readonly T[],\n columns: readonly ColumnConfig[],\n): string {\n const dataColumns = columns.filter(\n (c) => !(c as { utility?: boolean }).utility && typeof c.field === 'string' && c.field !== '',\n );\n const lines: string[] = [];\n for (const row of rows) {\n const cells = dataColumns.map((col) => {\n const value = row[col.field];\n if (value === null || value === undefined) return '';\n const str = String(value);\n return str.replace(/[\\t\\r\\n]+/g, ' ');\n });\n lines.push(cells.join('\\t'));\n }\n return lines.join('\\n');\n}\n","/**\n * Row Drag-Drop Plugin CSS\n *\n * Styles for drag handle, drop indicators (intra- and cross-grid), grid-level\n * drag/drop state classes, and FLIP animation on landing rows.\n */\n\n@layer tbw-plugins {\n /* ------------------------------------------------------------------ */\n /* Drag handle column */\n /* ------------------------------------------------------------------ */\n [data-field='__tbw_row_drag'] {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .dg-row-drag-handle {\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 1em;\n min-height: 1em;\n cursor: grab;\n user-select: none;\n color: var(--tbw-row-reorder-handle-color, var(--tbw-color-fg-muted));\n transition: color var(--tbw-transition-duration, 120ms) var(--tbw-transition-ease, ease);\n font-size: var(--tbw-font-size, 1em);\n letter-spacing: -2px;\n\n /* SC 2.5.8: grow the target, not the box, so the row keeps its height. */\n position: relative;\n\n &::after {\n content: '';\n position: absolute;\n inset-block-start: 50%;\n inset-inline-start: 50%;\n translate: -50% -50%;\n inline-size: var(--tbw-touch-target-min, 24px);\n block-size: var(--tbw-touch-target-min, 24px);\n }\n\n &:hover {\n color: var(--tbw-row-reorder-handle-hover, var(--tbw-color-fg));\n }\n\n &:active {\n cursor: grabbing;\n }\n }\n\n /* Coarse pointer (touch): handle always in active colour and large enough to tap */\n @media (hover: none) {\n .dg-row-drag-handle {\n color: var(--tbw-row-reorder-handle-hover, var(--tbw-color-fg));\n }\n }\n\n @media (pointer: coarse) {\n .dg-row-drag-handle {\n min-width: var(--tbw-touch-target-min, 24px);\n min-height: var(--tbw-touch-target-min, 24px);\n }\n }\n\n /* ------------------------------------------------------------------ */\n /* Source row state */\n /* ------------------------------------------------------------------ */\n .data-grid-row.dragging {\n opacity: 0.6;\n }\n\n /* When the row itself is the drag handle, hint at the affordance. */\n .data-grid-row[draggable='true'] {\n cursor: grab;\n }\n\n .data-grid-row[draggable='true'].dragging {\n cursor: grabbing;\n }\n\n /* Off-screen full-row clone used as the HTML5 drag image. */\n /* The browser already applies its own translucency to the snapshot, */\n /* so this clone keeps full opacity and skips the box-shadow — both */\n /* would otherwise composite on top of the browser's effect and make */\n /* the drag image look washed-out / fade at the edges. */\n .tbw-row-drag-clone {\n position: fixed;\n top: -10000px;\n left: -10000px;\n pointer-events: none;\n }\n\n /* Multi-row drag count badge */\n .tbw-row-drag-count {\n position: fixed;\n top: -1000px; /* off-screen until the browser snapshots it */\n left: -1000px;\n pointer-events: none;\n background: var(--tbw-row-reorder-indicator, var(--tbw-color-accent));\n color: var(--tbw-color-accent-fg);\n font:\n 600 12px/1.4 system-ui,\n sans-serif;\n border-radius: 999px;\n padding: 2px 8px;\n box-shadow: 0 2px 6px var(--tbw-color-shadow);\n z-index: 9999;\n }\n\n /* ------------------------------------------------------------------ */\n /* Drop position indicator (rows under cursor) */\n /* ------------------------------------------------------------------ */\n .data-grid-row.drop-target {\n position: relative;\n\n &.drop-before::before,\n &.drop-after::after {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n height: var(--tbw-drop-indicator-width, 2px);\n background-color: var(--tbw-drop-indicator-color, var(--tbw-row-reorder-indicator, var(--tbw-color-accent)));\n z-index: 10;\n pointer-events: none;\n }\n\n &.drop-before::before {\n top: 0;\n }\n\n &.drop-after::after {\n bottom: 0;\n }\n }\n\n /* ------------------------------------------------------------------ */\n /* Grid-level state classes */\n /* ------------------------------------------------------------------ */\n\n /* Source grid while a drag originating here is in progress */\n .tbw-grid--drag-source {\n /* Reserved hook for consumer styling. */\n }\n\n /* Target grid while a valid drag hovers (matching dropZone, canDrop ok) */\n .tbw-grid--drop-target-active {\n outline: 2px dashed var(--tbw-drop-indicator-color, var(--tbw-color-accent));\n outline-offset: -2px;\n }\n\n /* Briefly applied when a drop attempt is rejected */\n .tbw-grid--drop-target-rejected {\n outline: 2px dashed var(--tbw-color-danger);\n outline-offset: -2px;\n }\n\n /* Applied while the auto-scroll engine is actively scrolling this grid */\n .tbw-grid--auto-scrolling {\n cursor: ns-resize;\n }\n\n /* ------------------------------------------------------------------ */\n /* FLIP animation on landing rows */\n /* ------------------------------------------------------------------ */\n .data-grid-row.flip-animating {\n transition: transform var(--tbw-animation-duration, 200ms) ease-out;\n will-change: transform;\n z-index: 1;\n }\n\n /* ------------------------------------------------------------------ */\n /* Click-only move menu (WCAG 2.2 SC 2.5.7) */\n /* ------------------------------------------------------------------ */\n /* Rendered into `document.body` and promoted to the top layer, so it sits\n outside the grid's custom-property scope — every var needs a literal\n fallback here, the same way the tooltip popover does it. */\n .tbw-row-move-menu {\n position: fixed;\n margin: 0;\n display: flex;\n flex-direction: column;\n min-width: 10rem;\n padding: var(--tbw-spacing-xs, 0.25rem);\n background: var(--tbw-color-panel-bg, light-dark(#fff, #1f1f1f));\n color: var(--tbw-color-fg, light-dark(#1a1a1a, #f0f0f0));\n border: 1px solid var(--tbw-color-border, light-dark(#d0d0d0, #3a3a3a));\n border-radius: var(--tbw-border-radius, 0.25rem);\n box-shadow: var(--tbw-shadow-md, 0 4px 12px rgb(0 0 0 / 25%));\n font: inherit;\n z-index: 10001;\n\n &[hidden] {\n display: none;\n }\n }\n\n .tbw-row-move-menu-item {\n min-height: var(--tbw-touch-target-min, 24px);\n padding: var(--tbw-spacing-xs, 0.25rem) var(--tbw-spacing-sm, 0.5rem);\n text-align: start;\n background: none;\n border: none;\n /* Themes set radii for much larger surfaces (Material uses 12px), which\n turns a 24px row into a lozenge. */\n border-radius: min(var(--tbw-border-radius, 0.25rem), 6px);\n color: inherit;\n font: inherit;\n cursor: pointer;\n\n &:hover:not(:disabled) {\n background: var(--tbw-color-row-hover, light-dark(#f0f0f0, #2a2a2a));\n }\n\n &:disabled {\n opacity: 0.5;\n cursor: default;\n }\n }\n}\n","/**\n * Row Drag-Drop Plugin\n *\n * Drag rows within a single grid **and** between grids that share a\n * `dropZone`.\n *\n * Architecture overview is documented in the issue body and in\n * `.github/knowledge/grid-plugins.md`. Key invariants:\n *\n * - Mutations write to `grid._rows`; the user's input `sourceRows` array is\n * never mutated on either side. Persistence is consumer-driven via the\n * `row-move` (intra-grid) and `row-transfer` (cross-grid) events.\n * - Same-window cross-grid drops use the WeakRef registry in\n * `core/internal/drag-drop-registry` to recover live row references.\n * Cross-window drops fall back to `JSON.parse(JSON.stringify(row))` (or the\n * `serializeRow`/`deserializeRow` hooks for non-JSON values).\n * - Duplicate instances of this plugin collapse via the PluginManager\n * alias-collapse pre-pass, which merges their configs.\n *\n * @see {@link RowDragDropConfig} for all configuration options.\n */\n\nimport { GridClasses } from '../../core/constants';\nimport {\n clearDragSession,\n lookupDragSession,\n newDragSessionId,\n registerDragSession,\n} from '../../core/internal/drag-drop-registry';\nimport { ensureCellVisible } from '../../core/internal/keyboard';\nimport { BaseGridPlugin, type GridElement, type PluginManifest } from '../../core/plugin/base-plugin';\nimport type { ColumnConfig, GridHost } from '../../core/types';\nimport {\n type DragAlternativeAction,\n type DragAlternativeMenu,\n createDragAlternativeMenu,\n} from '../shared/drag-alternative-menu';\nimport {\n type AutoScroller,\n type RowDragPayload,\n TBW_ROW_DRAG_MIME,\n clearCurrentDragSession,\n computeDropPosition,\n createAutoScroller,\n decodePayload,\n encodePayload,\n findMatchingZoneMime,\n formatRowsAsTSV,\n getCurrentDragSession,\n hasAnyRowDragMime,\n mimeForZone,\n setCurrentDragSession,\n} from '../shared/drag-drop-protocol';\nimport styles from './row-drag-drop.css?inline';\nimport type {\n PendingMove,\n RowDragDropConfig,\n RowDragEndDetail,\n RowDragStartDetail,\n RowDropDetail,\n RowMoveDetail,\n RowTransferDetail,\n} from './types';\n\n/**\n * Field name for the drag handle column.\n *\n * @since 2.4.0\n */\nexport const ROW_DRAG_HANDLE_FIELD = '__tbw_row_drag';\n\n// ---------------------------------------------------------------------------\n// Cross-window coordination via BroadcastChannel\n// ---------------------------------------------------------------------------\n//\n// Same-window cross-grid drops can locate the source grid and its plugin via\n// `document.getElementById(sourceGridId)` — the target plugin handles both\n// sides of the transfer in `onDrop` (insert into target + remove from source\n// + emit `row-transfer` on both grids).\n//\n// Cross-window drops can't reach the source DOM that way. The target window\n// broadcasts a `tbw-row-drag-drop:transfer` message; each window has a single\n// channel and fans the message out to every attached plugin instance, which\n// matches on `sourceGridId === this.gridId` and runs the source-side path\n// (row removal on `move`, `row-transfer` emit, `dragAccepted` flip).\n//\n// The channel is created lazily on the first plugin that needs it and shared\n// across all instances in the window. It's torn down when the last instance\n// detaches so we don't leak a handle in environments where the plugin is\n// repeatedly attached/detached.\n\n/** @internal */\ninterface RemoteTransferMessage {\n type: 'tbw-row-drag-drop:transfer';\n sessionId: string;\n sourceGridId: string;\n toGridId: string;\n dropZone: string;\n rowIndices: number[];\n toIndex: number;\n operation: 'move' | 'copy';\n /** Pre-serialized rows (the same shape `serializeRow` produced on dragstart). */\n serializedRows: unknown[];\n}\n\ntype RemoteTransferListener = (msg: RemoteTransferMessage) => void;\n\nconst CROSS_WINDOW_CHANNEL_NAME = 'tbw-row-drag-drop';\nlet sharedChannel: BroadcastChannel | null = null;\nconst remoteListeners = new Set<RemoteTransferListener>();\n\nfunction ensureCrossWindowChannel(): BroadcastChannel | null {\n if (typeof BroadcastChannel === 'undefined') return null;\n if (sharedChannel) return sharedChannel;\n try {\n sharedChannel = new BroadcastChannel(CROSS_WINDOW_CHANNEL_NAME);\n sharedChannel.addEventListener('message', (event: MessageEvent) => {\n const data = event.data as RemoteTransferMessage | undefined;\n if (!data || data.type !== 'tbw-row-drag-drop:transfer') return;\n // Snapshot to tolerate listeners that detach during dispatch.\n for (const listener of Array.from(remoteListeners)) {\n try {\n listener(data);\n } catch {\n /* listener errors must not break sibling listeners */\n }\n }\n });\n } catch {\n sharedChannel = null;\n }\n return sharedChannel;\n}\n\nfunction registerRemoteTransferListener(listener: RemoteTransferListener): void {\n remoteListeners.add(listener);\n ensureCrossWindowChannel();\n}\n\n/**\n * Every plugin instance attached in this window.\n *\n * Drag-and-drop discovers its target from the pointer position, so it never\n * needed a registry. The click-only transfer control (WCAG 2.2 SC 2.5.7) does:\n * it has to *list* the grids a row can be sent to before the user picks one.\n *\n * Typed as `unknown` because the class is generic over the row type and every\n * instance in the window may have a different one; `peersInDropZone()` narrows.\n */\nconst attachedPlugins = new Set<unknown>();\n\nfunction unregisterRemoteTransferListener(listener: RemoteTransferListener): void {\n remoteListeners.delete(listener);\n if (remoteListeners.size === 0 && sharedChannel) {\n try {\n sharedChannel.close();\n } catch {\n /* noop */\n }\n sharedChannel = null;\n }\n}\n\nfunction broadcastRemoteTransfer(msg: RemoteTransferMessage): void {\n const channel = ensureCrossWindowChannel();\n if (!channel) return;\n try {\n channel.postMessage(msg);\n } catch {\n /* postMessage may throw on uncloneable payloads — acceptable; user can\n * supply `serializeRow` to provide a structured-cloneable shape. */\n }\n}\n\n/**\n * Row Drag-Drop Plugin for `<tbw-grid>`.\n *\n * @example Intra-grid reordering\n * ```ts\n * import { RowDragDropPlugin } from '@toolbox-web/grid/plugins/row-drag-drop';\n *\n * grid.gridConfig = {\n * plugins: [new RowDragDropPlugin()],\n * };\n * ```\n *\n * @example Cross-grid transfer list\n * ```ts\n * gridA.gridConfig = { plugins: [new RowDragDropPlugin({ dropZone: 'tasks' })] };\n * gridB.gridConfig = { plugins: [new RowDragDropPlugin({ dropZone: 'tasks' })] };\n *\n * gridA.addEventListener('row-transfer', (e) => persist(e.detail));\n * gridB.addEventListener('row-transfer', (e) => persist(e.detail));\n * ```\n *\n * @category Plugin\n */\nexport class RowDragDropPlugin<T = unknown> extends BaseGridPlugin<RowDragDropConfig<T>> {\n /** @internal */\n readonly name = 'rowDragDrop';\n\n /** @internal */\n override readonly styles = styles;\n\n /** @internal */\n static override readonly manifest: PluginManifest<RowDragDropConfig> = {\n events: [\n { type: 'row-move', description: 'Intra-grid row reorder.', cancelable: true },\n { type: 'row-drag-start', description: 'Cross-grid drag started on this grid.', cancelable: true },\n { type: 'row-drag-end', description: 'Drag finished on this grid (regardless of outcome).' },\n { type: 'row-drop', description: 'Cross-grid drop landing on this grid.', cancelable: true },\n { type: 'row-transfer', description: 'Cross-grid transfer completed (fires on both grids).' },\n ],\n };\n\n /** @internal */\n protected override get defaultConfig(): Partial<RowDragDropConfig<T>> {\n return {\n enableKeyboard: true,\n // `showDragHandle` default depends on `dragFrom` — resolved by\n // `shouldRenderDragHandle()` rather than here so a single `dragFrom`\n // change reshapes both at once.\n dragHandlePosition: 'left',\n dragHandleWidth: 40,\n debounceMs: 150,\n animation: 'flip',\n operation: 'move',\n autoScroll: true,\n dragFrom: 'handle',\n };\n }\n\n /**\n * Resolve whether the grip column should be rendered. The handle is shown\n * unless the user explicitly set `showDragHandle: false`, OR `dragFrom`\n * is `'row'` and `showDragHandle` was not explicitly set to `true`.\n */\n private shouldRenderDragHandle(): boolean {\n const explicit = this.config.showDragHandle;\n if (explicit === false) return false;\n if (explicit === true) return true;\n return this.config.dragFrom !== 'row';\n }\n\n /** Whether the row element itself should accept native HTML5 drag. */\n private get rowIsDraggable(): boolean {\n return this.config.dragFrom === 'row' || this.config.dragFrom === 'both';\n }\n\n /** Resolve animation type from plugin config (respects grid-level reduced-motion). */\n private get animationType(): false | 'flip' {\n if (!this.isAnimationEnabled) return false;\n if (this.config.animation !== undefined) return this.config.animation;\n return 'flip';\n }\n\n // #region Internal State\n private isDragging = false;\n private draggedRowIndex: number | null = null;\n private draggedRows: T[] = [];\n private draggedIndices: number[] = [];\n private dragSessionId: string | null = null;\n private dragAccepted = false;\n private dropRowIndex: number | null = null;\n private pendingMove: PendingMove | null = null;\n private debounceTimer: ReturnType<typeof setTimeout> | null = null;\n private lastFocusCol = 0;\n private autoScroller: AutoScroller | null = null;\n /** Stable id for this grid instance (used as `sourceGridId` in payloads). */\n private gridId = '';\n\n /** Bound listener so we can register/unregister the same reference. */\n private readonly remoteTransferListener: RemoteTransferListener = (msg) => this.onRemoteTransfer(msg);\n\n /** Click-only move menu (WCAG 2.2 SC 2.5.7), created lazily on first tap. */\n private moveMenu: DragAlternativeMenu | null = null;\n\n /** Typed internal grid accessor. */\n private get internalGrid(): GridHost {\n return this.grid;\n }\n // #endregion\n\n // #region Lifecycle\n /** @internal */\n override attach(grid: GridElement): void {\n super.attach(grid);\n const host = this.gridElement;\n if (host) {\n this.gridId = host.id || `tbw-grid-${newDragSessionId().slice(0, 8)}`;\n if (!host.id) host.id = this.gridId;\n this.setupDelegatedDragListeners();\n registerRemoteTransferListener(this.remoteTransferListener);\n attachedPlugins.add(this);\n }\n }\n\n /** @internal */\n override detach(): void {\n this.clearDebounceTimer();\n this.autoScroller?.stop();\n this.autoScroller = null;\n unregisterRemoteTransferListener(this.remoteTransferListener);\n attachedPlugins.delete(this);\n this.moveMenu?.dispose();\n this.moveMenu = null;\n if (this.dragSessionId) clearDragSession(this.dragSessionId);\n clearCurrentDragSession();\n this.resetDragState();\n super.detach();\n }\n // #endregion\n\n // #region Hooks\n\n /** @internal */\n override processColumns(columns: readonly ColumnConfig[]): ColumnConfig[] {\n if (!this.shouldRenderDragHandle()) return [...columns];\n\n const dragHandleColumn: ColumnConfig = {\n field: ROW_DRAG_HANDLE_FIELD,\n header: '',\n width: this.config.dragHandleWidth ?? 40,\n resizable: false,\n sortable: false,\n filterable: false,\n lockPosition: true,\n utility: true,\n viewRenderer: () => {\n const container = document.createElement('div');\n container.className = 'dg-row-drag-handle';\n container.setAttribute('aria-label', 'Drag to reorder, or activate for move options');\n container.setAttribute('role', 'button');\n container.setAttribute('tabindex', '-1');\n container.draggable = true;\n // Press-and-release without moving is a tap, not a drag — HTML5 DnD\n // only fires `dragstart` on a real drag, so a plain `click` here means\n // the pointer user could not (or chose not to) drag. Offer the\n // click-only alternative instead (WCAG 2.2 SC 2.5.7).\n container.addEventListener('click', (e) => {\n e.stopPropagation();\n this.openMoveMenu(container);\n });\n this.setIcon(container, 'dragHandle');\n return container;\n },\n };\n\n return this.config.dragHandlePosition === 'right' ? [...columns, dragHandleColumn] : [dragHandleColumn, ...columns];\n }\n\n /** @internal */\n override afterRender(): void {\n this.applyRowDraggable();\n }\n\n /** @internal */\n override onScrollRender(): void {\n // Virtualization recycles row DOM elements during scroll; re-apply the\n // `draggable` attribute so newly-shown rows still accept HTML5 drag.\n this.applyRowDraggable();\n }\n\n /**\n * Set or clear the `draggable` attribute on every visible row, depending on\n * `config.dragFrom`. Idempotent and cheap (one attribute write per row).\n */\n private applyRowDraggable(): void {\n const body = this.internalGrid._bodyEl;\n if (!body) return;\n const wantDraggable = this.rowIsDraggable;\n const rows = body.querySelectorAll<HTMLElement>('.data-grid-row');\n for (const row of rows) {\n if (wantDraggable) {\n if (row.getAttribute('draggable') !== 'true') row.setAttribute('draggable', 'true');\n } else if (row.hasAttribute('draggable')) {\n row.removeAttribute('draggable');\n }\n }\n }\n\n /** @internal */\n override onKeyDown(event: KeyboardEvent): boolean | void {\n if (!this.config.enableKeyboard) return;\n // Ctrl is deprecated (macOS reserves Ctrl+↑/↓); remove in the next major.\n if (!(event.altKey || event.ctrlKey) || (event.key !== 'ArrowUp' && event.key !== 'ArrowDown')) return;\n if (this.#isKeyboardMoveBlocked(event)) return;\n\n const grid = this.internalGrid;\n const focusRow = grid._focusRow;\n const rows = grid._rows ?? this.sourceRows;\n if (focusRow < 0 || focusRow >= rows.length) return;\n\n const direction = event.key === 'ArrowUp' ? 'up' : 'down';\n const toIndex = direction === 'up' ? focusRow - 1 : focusRow + 1;\n if (toIndex < 0 || toIndex >= rows.length) return;\n\n const row = rows[focusRow];\n if (!this.canMoveRow(focusRow, toIndex)) return;\n\n this.handleKeyboardMove(row, focusRow, toIndex, grid._focusCol);\n event.preventDefault();\n event.stopPropagation();\n return true;\n }\n\n /** Editors, form controls and non-body chrome own the chord (e.g. `<select>` Alt+↓ opens it). */\n #isKeyboardMoveBlocked(event: KeyboardEvent): boolean {\n if (this.queryBoolean('isEditing')) return true;\n const target = (event.composedPath?.()[0] ?? event.target) as HTMLElement | null;\n if (!target?.closest || target === this.gridElement) return false;\n if (!target.closest('.rows-body')) return true;\n const tag = target.tagName;\n return tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA' || target.isContentEditable;\n }\n\n /** @internal */\n override onCellClick(): void {\n this.flushPendingMove();\n }\n // #endregion\n\n // #region Public API\n /** Move a row to a new position programmatically (intra-grid). */\n moveRow(fromIndex: number, toIndex: number): void {\n const rows = [...this.sourceRows];\n if (fromIndex < 0 || fromIndex >= rows.length) return;\n if (toIndex < 0 || toIndex >= rows.length) return;\n if (fromIndex === toIndex) return;\n if (!this.canMoveRow(fromIndex, toIndex)) return;\n this.executeIntraGridMove(rows[fromIndex], fromIndex, toIndex, 'keyboard');\n }\n\n /**\n * Check if a row can be moved within this grid.\n * Consults the `canDrag` veto for the source row, the plugin query system\n * (`canMoveRow`), and `canDrop` for the target.\n */\n canMoveRow(fromIndex: number, toIndex: number): boolean {\n // During debounced keyboard moves, `grid._rows` diverges from\n // `sourceRows` (the user-facing snapshot) because the plugin mutates\n // resolves the focused row from `_rows ?? sourceRows`, so validation must\n // read from the same array — otherwise we'd run `canDrag`/queries against\n // the wrong row.\n const rows = this.internalGrid._rows ?? this.sourceRows;\n if (fromIndex < 0 || fromIndex >= rows.length) return false;\n if (toIndex < 0 || toIndex >= rows.length) return false;\n if (fromIndex === toIndex) return false;\n\n // Plugin query veto (Tree, GroupingRows)\n const row = rows[fromIndex] as T;\n const queryResults = this.grid?.query?.<boolean>('canMoveRow', row);\n if (Array.isArray(queryResults) && queryResults.includes(false)) return false;\n\n // canDrag veto (dragstart side)\n if (this.config.canDrag && !this.config.canDrag(row, fromIndex)) return false;\n\n // canDrop callback (intra-grid synthesised payload)\n if (this.config.canDrop) {\n const payload: RowDragPayload<T> = {\n sessionId: 'intra',\n sourceGridId: this.gridId,\n dropZone: this.config.dropZone ?? '',\n rows: [row],\n rowIndices: [fromIndex],\n operation: 'move',\n };\n if (!this.config.canDrop(payload, toIndex)) return false;\n }\n\n return true;\n }\n // #endregion\n\n // #region Drag Setup\n\n private setupDelegatedDragListeners(): void {\n const gridEl = this.gridElement;\n if (!gridEl) return;\n const signal = this.disconnectSignal;\n\n gridEl.addEventListener('dragstart', (e) => this.onDragStart(e as DragEvent), { signal });\n gridEl.addEventListener('dragend', () => this.onDragEnd(), { signal });\n gridEl.addEventListener('dragover', (e) => this.onDragOver(e as DragEvent), { signal });\n gridEl.addEventListener('dragleave', (e) => this.onDragLeave(e as DragEvent), { signal });\n gridEl.addEventListener('drop', (e) => this.onDrop(e as DragEvent), { signal });\n }\n\n private onDragStart(de: DragEvent): void {\n const target = de.target as HTMLElement | null;\n if (!target) return;\n\n // Resolve the row element being picked up. Order matters: a click on the\n // grip column inside a row-draggable grid should still go through the\n // handle path so the cursor offset feels right.\n const handle = target.closest('.dg-row-drag-handle') as HTMLElement | null;\n let rowEl: HTMLElement | null = null;\n let initiatedFromHandle = false;\n if (handle) {\n rowEl = handle.closest('.data-grid-row') as HTMLElement | null;\n initiatedFromHandle = true;\n } else if (this.rowIsDraggable) {\n // Row-as-handle: any cell may start the drag, but interactive\n // descendants (inputs, buttons, anchors, contenteditable, open\n // editors, selection checkboxes) keep their native behaviour.\n if (this.isInteractiveDragOrigin(target)) return;\n rowEl = target.closest('.data-grid-row') as HTMLElement | null;\n }\n if (!rowEl) return;\n\n const rowIndex = this.getRowIndex(rowEl);\n if (rowIndex < 0) return;\n\n // Resolve the rows being dragged: whole selection if dragged row is selected.\n const { rows, indices } = this.resolveDraggedRows(rowIndex);\n if (rows.length === 0) return;\n\n // canDrag veto on the originating row\n if (this.config.canDrag && !this.config.canDrag(rows[0], rowIndex)) {\n de.preventDefault();\n return;\n }\n\n const operation = this.config.operation ?? 'move';\n const dropZone = this.config.dropZone ?? '';\n const sessionId = newDragSessionId();\n\n // Emit cancelable row-drag-start (source-side veto)\n const startDetail: RowDragStartDetail<T> = { rows, indices, operation, dropZone };\n if (this.emitCancelable('row-drag-start', startDetail)) {\n de.preventDefault();\n return;\n }\n\n this.isDragging = true;\n this.draggedRowIndex = rowIndex;\n this.draggedRows = rows;\n this.draggedIndices = indices;\n this.dragSessionId = sessionId;\n this.dragAccepted = false;\n\n // Build the cross-grid payload (always built, even when dropZone is empty —\n // intra-grid drops still benefit from the registry round-trip)\n const serialize = this.config.serializeRow ?? ((r: T) => r);\n const payload: RowDragPayload<T> = {\n sessionId,\n sourceGridId: this.gridId,\n dropZone,\n rows: rows.map(serialize) as T[],\n rowIndices: indices,\n operation,\n };\n\n if (de.dataTransfer) {\n de.dataTransfer.effectAllowed = operation === 'copy' ? 'copyMove' : 'move';\n try {\n de.dataTransfer.setData(TBW_ROW_DRAG_MIME, encodePayload(payload));\n if (dropZone) de.dataTransfer.setData(mimeForZone(dropZone), encodePayload(payload));\n // Plain-text TSV fallback for external drop targets\n de.dataTransfer.setData('text/plain', formatRowsAsTSV(rows as Record<string, unknown>[], this.columns));\n } catch {\n /* JSDOM/happy-dom may throw on setData; harmless */\n }\n\n // Drag image: full-row clone for single-row drags (more legible than\n // the handle alone); count badge for multi-row drags.\n if (rows.length > 1) {\n const badge = document.createElement('div');\n badge.className = 'tbw-row-drag-count';\n badge.textContent = `${rows.length} rows`;\n document.body.appendChild(badge);\n try {\n de.dataTransfer.setDragImage(badge, 10, 10);\n } catch {\n /* ignore */\n }\n setTimeout(() => badge.remove(), 0);\n } else {\n this.attachRowCloneDragImage(de, rowEl, initiatedFromHandle ? handle : null);\n }\n }\n\n // Same-window registry + current-session marker\n registerDragSession(sessionId, rows as unknown[]);\n setCurrentDragSession(sessionId, payload);\n\n rowEl.classList.add(GridClasses.DRAGGING);\n this.gridElement.classList.add('tbw-grid--drag-source');\n }\n\n /**\n * Selectors whose dragstart should NOT initiate a row drag in `dragFrom: 'row'`\n * mode. Keeps native interactions (text input, button clicks, link drag,\n * cell editing, selection checkboxes) working unchanged.\n */\n private static readonly INTERACTIVE_DRAG_SELECTORS =\n 'input,textarea,select,button,a,[contenteditable=\"\"],[contenteditable=\"true\"],.dg-cell-editor,.tbw-checkbox-cell';\n\n /** @internal */\n private isInteractiveDragOrigin(target: HTMLElement): boolean {\n return target.closest(RowDragDropPlugin.INTERACTIVE_DRAG_SELECTORS) !== null;\n }\n\n /**\n * Build a full-row drag image by cloning `rowEl` so the user sees the\n * actual row — not just the grip icon — while dragging.\n *\n * The clone is appended off-screen, snapshotted by the browser via\n * `setDragImage`, then removed on the next tick (after the snapshot).\n * The cursor offset is preserved relative to where the user pressed.\n */\n private attachRowCloneDragImage(de: DragEvent, rowEl: HTMLElement, handle: HTMLElement | null): void {\n if (!de.dataTransfer) return;\n const rect = rowEl.getBoundingClientRect();\n const clone = rowEl.cloneNode(true) as HTMLElement;\n clone.classList.add('tbw-row-drag-clone');\n // Strip transient classes that would look wrong in the drag image.\n clone.classList.remove('dragging', 'drop-target', 'drop-before', 'drop-after', 'flip-animating', 'row-focus');\n clone.removeAttribute('aria-selected');\n // Preserve the actual rendered width so cells don't reflow in the snapshot.\n clone.style.width = `${rect.width}px`;\n clone.style.height = `${rect.height}px`;\n // The clone MUST stay inside the grid host: every core row/cell rule is\n // scoped under `tbw-grid …` (see core/styles/*.css), and the\n // `--tbw-column-template` custom property is set on the host. If the\n // clone is moved to `document.body`, none of those rules match and the\n // drag image collapses to an empty box. Off-screen positioning via\n // `position: fixed` works the same regardless of the DOM parent.\n this.gridElement.appendChild(clone);\n // Cursor offset: where the user pressed inside the source row. Falls\n // back to the centre of the handle when initiated from the grip.\n let offsetX = de.clientX - rect.left;\n let offsetY = de.clientY - rect.top;\n if (handle) {\n const handleRect = handle.getBoundingClientRect();\n offsetX = handleRect.left - rect.left + handleRect.width / 2;\n offsetY = handleRect.top - rect.top + handleRect.height / 2;\n }\n // Clamp into the row bounds so the cursor stays inside the drag image.\n offsetX = Math.max(0, Math.min(rect.width, offsetX));\n offsetY = Math.max(0, Math.min(rect.height, offsetY));\n try {\n de.dataTransfer.setDragImage(clone, offsetX, offsetY);\n } catch {\n /* JSDOM/happy-dom: harmless */\n }\n setTimeout(() => clone.remove(), 0);\n }\n\n private onDragOver(de: DragEvent): void {\n const dt = de.dataTransfer;\n if (!dt) return;\n\n // Identify whether a tbw row drag is in progress and whether it matches our zone.\n const types = dt.types ? Array.from(dt.types) : [];\n if (!hasAnyRowDragMime(types) && !this.isDragging) return;\n\n const dropZone = this.config.dropZone ?? '';\n const session = getCurrentDragSession<T>();\n\n // For cross-grid drags we require a matching zone-tagged MIME OR the\n // session payload's dropZone must match ours.\n const isIntra = this.isDragging && session?.payload.sourceGridId === this.gridId;\n if (!isIntra) {\n if (!dropZone) return; // intra-grid only — ignore external drags\n const matchingMime = findMatchingZoneMime(types, dropZone);\n if (!matchingMime && !(session && session.payload.dropZone === dropZone)) return;\n }\n\n de.preventDefault();\n if (dt) dt.dropEffect = (session?.payload.operation ?? this.config.operation ?? 'move') as 'copy' | 'move';\n\n // Compute drop position\n const rowEl = (de.target as HTMLElement).closest('.data-grid-row') as HTMLElement | null;\n const rows = this.internalGrid._rows ?? [];\n const pos = computeDropPosition(rowEl, de.clientY, (el) => this.getRowIndex(el), rows.length);\n\n // Same-row no-op for intra-grid\n if (isIntra && pos.overIndex !== null && pos.overIndex === this.draggedRowIndex) {\n this.clearDropTargetClasses();\n return;\n }\n\n // canDrop check (same-window only — payload visible)\n if (session && this.config.canDrop) {\n const accepted = this.config.canDrop(session.payload, pos.insertIndex);\n this.gridElement.classList.toggle('tbw-grid--drop-target-active', accepted);\n this.gridElement.classList.toggle('tbw-grid--drop-target-rejected', !accepted);\n if (!accepted) {\n this.clearDropTargetClasses();\n return;\n }\n } else {\n this.gridElement.classList.add('tbw-grid--drop-target-active');\n }\n\n this.dropRowIndex = pos.insertIndex;\n this.applyDropPositionClasses(rowEl, pos.isBefore);\n\n // Auto-scroll the target viewport\n if (this.config.autoScroll !== false) {\n this.ensureAutoScroller();\n this.autoScroller?.onPointerMove(de.clientY);\n }\n }\n\n private onDragLeave(de: DragEvent): void {\n const rowEl = (de.target as HTMLElement).closest('.data-grid-row') as HTMLElement | null;\n if (rowEl) rowEl.classList.remove('drop-target', 'drop-before', 'drop-after');\n // Tear down grid-level state when the cursor leaves the grid entirely\n if (de.currentTarget && !this.gridElement.contains(de.relatedTarget as Node)) {\n this.gridElement.classList.remove('tbw-grid--drop-target-active', 'tbw-grid--drop-target-rejected');\n this.autoScroller?.stop();\n }\n }\n\n private onDrop(de: DragEvent): void {\n de.preventDefault();\n this.autoScroller?.stop();\n this.gridElement.classList.remove('tbw-grid--drop-target-active', 'tbw-grid--drop-target-rejected');\n this.clearDropTargetClasses();\n\n const dt = de.dataTransfer;\n if (!dt) return;\n\n // Resolve payload — prefer same-window session, fall back to dataTransfer JSON\n const session = getCurrentDragSession<T>();\n let payload: RowDragPayload<T> | null = session?.payload ?? null;\n let liveRows: T[] | null = null;\n\n if (payload) {\n const lookup = lookupDragSession<T>(payload.sessionId);\n if (lookup) liveRows = lookup;\n } else {\n const raw = dt.getData(TBW_ROW_DRAG_MIME);\n payload = decodePayload<T>(raw);\n if (payload) {\n const lookup = lookupDragSession<T>(payload.sessionId);\n if (lookup) liveRows = lookup;\n }\n }\n if (!payload) return;\n\n // Drop position (recompute in case dragover wasn't called for a few frames)\n const rowEl = (de.target as HTMLElement).closest('.data-grid-row') as HTMLElement | null;\n const rows = this.internalGrid._rows ?? [];\n const pos = computeDropPosition(rowEl, de.clientY, (el) => this.getRowIndex(el), rows.length);\n let targetIndex = this.dropRowIndex ?? pos.insertIndex;\n\n const isIntra = payload.sourceGridId === this.gridId;\n const dropZone = this.config.dropZone ?? '';\n\n if (isIntra) {\n // Intra-grid path — emit `row-move`.\n const fromIndex = payload.rowIndices[0];\n // Adjust toIndex when dropping after the dragged row (single-row only)\n if (payload.rowIndices.length === 1 && targetIndex > fromIndex) targetIndex--;\n if (fromIndex === targetIndex) return;\n const row = (liveRows ?? payload.rows)[0];\n if (!this.canMoveRow(fromIndex, targetIndex)) return;\n this.executeIntraGridMove(row, fromIndex, targetIndex, 'drag');\n return;\n }\n\n // Cross-grid path\n if (!dropZone || dropZone !== payload.dropZone) return;\n\n // canDrop final check\n if (this.config.canDrop && !this.config.canDrop(payload, targetIndex)) {\n this.gridElement.classList.add('tbw-grid--drop-target-rejected');\n setTimeout(() => this.gridElement.classList.remove('tbw-grid--drop-target-rejected'), 200);\n return;\n }\n\n // Resolve final row references — live (same-window) or deserialized JSON\n const deserialize = this.config.deserializeRow ?? ((r: unknown) => r as T);\n const incomingRows: T[] = liveRows ?? payload.rows.map((r) => deserialize(r as unknown));\n\n const dropDetail: RowDropDetail<T> = {\n payload,\n sourceGridId: payload.sourceGridId,\n targetIndex,\n operation: payload.operation,\n };\n if (this.emitCancelable('row-drop', dropDetail)) return;\n\n // Insert into target grid's _rows\n const targetRows = [...rows];\n targetRows.splice(targetIndex, 0, ...(incomingRows as unknown[]));\n this.grid.rows = targetRows;\n\n // Locate the source plugin in THIS window. If it's here we handle the\n // source-side mutation directly; if it isn't, we broadcast a message and\n // let the source-window plugin (if any) handle removal + transfer emit.\n const sourcePlugin = this.findPeerOnGrid(payload.sourceGridId);\n\n // Remove from source grid's _rows when operation === 'move' (same-window)\n if (payload.operation === 'move' && sourcePlugin) {\n const sourceGrid = document.getElementById(payload.sourceGridId) as\n (HTMLElement & { rows?: unknown[]; _rows?: unknown[] }) | null;\n if (sourceGrid) {\n const srcRows = (sourceGrid._rows ?? sourceGrid.rows ?? []).slice();\n // Remove from highest index down so earlier indices stay stable\n const sortedIndices = [...payload.rowIndices].sort((a, b) => b - a);\n for (const idx of sortedIndices) {\n if (idx >= 0 && idx < srcRows.length) srcRows.splice(idx, 1);\n }\n sourceGrid.rows = srcRows;\n }\n }\n\n // Mark accepted on the source plugin so dragend knows (same-window only —\n // cross-window source flips its own flag in `onRemoteTransfer`).\n if (sourcePlugin) sourcePlugin.dragAccepted = true;\n\n // Emit row-transfer on the target. The source's `row-transfer` is fired\n // either here (same-window) or by the source plugin in `onRemoteTransfer`\n // (cross-window).\n const transferDetail: RowTransferDetail<T> = {\n rows: incomingRows,\n fromGridId: payload.sourceGridId,\n toGridId: this.gridId,\n fromIndices: payload.rowIndices,\n toIndex: targetIndex,\n operation: payload.operation,\n };\n this.emit('row-transfer', transferDetail);\n\n if (sourcePlugin) {\n sourcePlugin.emitTransfer(transferDetail);\n } else {\n // Cross-window: broadcast so the source window can finish its half of\n // the transfer (row removal on `move`, `row-transfer` emit, accepted flip).\n broadcastRemoteTransfer({\n type: 'tbw-row-drag-drop:transfer',\n sessionId: payload.sessionId,\n sourceGridId: payload.sourceGridId,\n toGridId: this.gridId,\n dropZone,\n rowIndices: payload.rowIndices,\n toIndex: targetIndex,\n operation: payload.operation,\n // Re-use the payload's already-serialized rows so the source side can\n // round-trip them through `deserializeRow` for its `row-transfer` event.\n serializedRows: payload.rows as unknown[],\n });\n }\n }\n\n /**\n * Source-window handler for a remote `row-transfer` broadcast from a target\n * window. Only runs on the plugin instance whose grid id matches the message.\n * @internal\n */\n private onRemoteTransfer(msg: RemoteTransferMessage): void {\n if (msg.sourceGridId !== this.gridId) return;\n // Defensive: only act when the message zone matches our zone. This prevents\n // a stray message from a grid sharing the same id but a different zone\n // (e.g. independent demos in different tabs) from mutating our rows.\n const dropZone = this.config.dropZone ?? '';\n if (!dropZone || msg.dropZone !== dropZone) return;\n\n // Resolve incoming rows (for the `row-transfer` event payload).\n const deserialize = this.config.deserializeRow ?? ((r: unknown) => r as T);\n const incomingRows: T[] = msg.serializedRows.map((r) => deserialize(r));\n\n if (msg.operation === 'move') {\n const srcRows = (this.internalGrid._rows ?? this.sourceRows).slice();\n const sortedIndices = [...msg.rowIndices].sort((a, b) => b - a);\n for (const idx of sortedIndices) {\n if (idx >= 0 && idx < srcRows.length) srcRows.splice(idx, 1);\n }\n this.grid.rows = srcRows as unknown[];\n }\n\n // Flip accepted before dragend (best-effort — the message may arrive after\n // dragend has already fired with `accepted: false`; `row-transfer` is the\n // authoritative success signal).\n this.dragAccepted = true;\n\n this.emit('row-transfer', {\n rows: incomingRows,\n fromGridId: msg.sourceGridId,\n toGridId: msg.toGridId,\n fromIndices: msg.rowIndices,\n toIndex: msg.toIndex,\n operation: msg.operation,\n } as RowTransferDetail<T>);\n }\n\n private onDragEnd(): void {\n if (this.dragSessionId) clearDragSession(this.dragSessionId);\n clearCurrentDragSession();\n this.autoScroller?.stop();\n this.gridElement.classList.remove('tbw-grid--drag-source');\n\n if (this.isDragging) {\n const endDetail: RowDragEndDetail<T> = {\n rows: this.draggedRows,\n indices: this.draggedIndices,\n accepted: this.dragAccepted,\n };\n this.emit('row-drag-end', endDetail);\n }\n this.clearDragClasses();\n this.resetDragState();\n }\n // #endregion\n\n // #region Helpers\n\n /** Public wrapper so a peer plugin can dispatch `row-transfer` on this grid. @internal */\n emitTransfer(detail: RowTransferDetail<T>): void {\n this.emit('row-transfer', detail);\n }\n\n /** Find the peer `RowDragDropPlugin` instance on another grid by id. */\n private findPeerOnGrid(gridId: string): RowDragDropPlugin<T> | null {\n const peerEl = document.getElementById(gridId) as\n (HTMLElement & { getPluginByName?: (name: string) => RowDragDropPlugin<T> | undefined }) | null;\n if (!peerEl?.getPluginByName) return null;\n return peerEl.getPluginByName('rowDragDrop') ?? null;\n }\n\n // #region Click-only move menu (WCAG 2.2 SC 2.5.7)\n\n /** Grids in this window sharing our (non-empty) `dropZone`. */\n private peersInDropZone(): RowDragDropPlugin<T>[] {\n const dropZone = this.config.dropZone ?? '';\n if (!dropZone) return [];\n const peers: RowDragDropPlugin<T>[] = [];\n for (const candidate of attachedPlugins) {\n const peer = candidate as RowDragDropPlugin<T>;\n if (peer === this) continue;\n if ((peer.config.dropZone ?? '') === dropZone) peers.push(peer);\n }\n return peers;\n }\n\n /** Human-readable name for this grid, used in the transfer menu. */\n private get gridLabel(): string {\n const host = this.gridElement;\n return host?.getAttribute('aria-label') || host?.id || 'grid';\n }\n\n /**\n * Open the click-only alternative to dragging a row: reorder within this grid\n * and, when a `dropZone` is configured, send the row to a peer grid — all\n * with single clicks or taps, no press-hold-move gesture.\n */\n private openMoveMenu(handle: HTMLElement): void {\n const rowEl = handle.closest('.data-grid-row') as HTMLElement | null;\n if (!rowEl) return;\n const rowIndex = this.getRowIndex(rowEl);\n if (rowIndex < 0) return;\n\n const rows = this.internalGrid._rows ?? this.sourceRows;\n const actions: DragAlternativeAction[] = [\n {\n label: 'Move up',\n disabled: rowIndex === 0 || !this.canMoveRow(rowIndex, rowIndex - 1),\n run: () => this.moveRow(rowIndex, rowIndex - 1),\n },\n {\n label: 'Move down',\n disabled: rowIndex >= rows.length - 1 || !this.canMoveRow(rowIndex, rowIndex + 1),\n run: () => this.moveRow(rowIndex, rowIndex + 1),\n },\n {\n label: 'Move to top',\n disabled: rowIndex === 0 || !this.canMoveRow(rowIndex, 0),\n run: () => this.moveRow(rowIndex, 0),\n },\n {\n label: 'Move to bottom',\n disabled: rowIndex >= rows.length - 1 || !this.canMoveRow(rowIndex, rows.length - 1),\n run: () => this.moveRow(rowIndex, rows.length - 1),\n },\n ];\n\n const verb = (this.config.operation ?? 'move') === 'copy' ? 'Copy to' : 'Send to';\n for (const peer of this.peersInDropZone()) {\n actions.push({\n label: `${verb} ${peer.gridLabel}`,\n run: () => this.transferToPeer(peer, rowIndex),\n });\n }\n\n this.moveMenu ??= createDragAlternativeMenu('tbw-row-move-menu', 'tbw-row-move-menu');\n this.moveMenu.open(handle, `Move row ${rowIndex + 1}`, actions);\n }\n\n /**\n * Click-only equivalent of dropping the row onto `peer`. Runs the same vetoes\n * and emits the same events as the drag path (`row-drag-start`, `row-drop`,\n * `row-transfer`) so consumers cannot tell the two apart.\n */\n private transferToPeer(peer: RowDragDropPlugin<T>, rowIndex: number): void {\n const dropZone = this.config.dropZone ?? '';\n if (!dropZone) return;\n\n const { rows, indices } = this.resolveDraggedRows(rowIndex);\n if (rows.length === 0) return;\n if (this.config.canDrag && !this.config.canDrag(rows[0], rowIndex)) return;\n\n const operation = this.config.operation ?? 'move';\n if (this.emitCancelable('row-drag-start', { rows, indices, operation, dropZone } as RowDragStartDetail<T>)) return;\n\n const serialize = this.config.serializeRow ?? ((r: T) => r);\n const payload: RowDragPayload<T> = {\n sessionId: newDragSessionId(),\n sourceGridId: this.gridId,\n dropZone,\n rows: rows.map(serialize) as T[],\n rowIndices: indices,\n operation,\n };\n\n const toIndex = peer.acceptTransfer(payload, rows);\n if (toIndex < 0) return;\n\n if (operation === 'move') {\n const srcRows = [...(this.internalGrid._rows ?? this.sourceRows)];\n for (const idx of [...indices].sort((a, b) => b - a)) {\n if (idx >= 0 && idx < srcRows.length) srcRows.splice(idx, 1);\n }\n this.grid.rows = srcRows as unknown[];\n }\n\n const detail: RowTransferDetail<T> = {\n rows,\n fromGridId: this.gridId,\n toGridId: peer.gridId,\n fromIndices: indices,\n toIndex,\n operation,\n };\n peer.emitTransfer(detail);\n this.emit('row-transfer', detail);\n }\n\n /**\n * Target half of {@link RowDragDropPlugin.transferToPeer}. Returns the insert\n * index, or `-1` when the transfer was rejected (zone mismatch, `canDrop`\n * veto, or a cancelled `row-drop`).\n *\n * @internal\n */\n acceptTransfer(payload: RowDragPayload<T>, liveRows: readonly T[]): number {\n const dropZone = this.config.dropZone ?? '';\n if (!dropZone || dropZone !== payload.dropZone) return -1;\n\n const rows = this.internalGrid._rows ?? this.sourceRows;\n const targetIndex = rows.length;\n if (this.config.canDrop && !this.config.canDrop(payload, targetIndex)) return -1;\n\n const dropDetail: RowDropDetail<T> = {\n payload,\n sourceGridId: payload.sourceGridId,\n targetIndex,\n operation: payload.operation,\n };\n if (this.emitCancelable('row-drop', dropDetail)) return -1;\n\n this.grid.rows = [...(rows as unknown[]), ...(liveRows as unknown[])];\n return targetIndex;\n }\n // #endregion\n\n private resolveDraggedRows(originIndex: number): { rows: T[]; indices: number[] } {\n const rows = this.internalGrid._rows ?? this.sourceRows;\n const originRow = rows[originIndex] as T;\n\n // If a selection plugin is loaded and the dragged row is selected, drag the whole selection.\n const selection = this.grid?.getPluginByName?.('selection') as\n { getSelectedRowIndices?: () => number[]; getSelectedRows?: <U>() => U[] } | undefined;\n if (selection?.getSelectedRowIndices) {\n const selectedIndices = selection.getSelectedRowIndices();\n if (selectedIndices.includes(originIndex) && selectedIndices.length > 1) {\n const sorted = [...selectedIndices].sort((a, b) => a - b);\n return {\n rows: sorted.map((i) => rows[i] as T),\n indices: sorted,\n };\n }\n }\n return { rows: [originRow], indices: [originIndex] };\n }\n\n private ensureAutoScroller(): void {\n if (this.autoScroller) return;\n const viewport = this.gridElement.querySelector<HTMLElement>('.rows-viewport');\n if (!viewport) return;\n const opts = typeof this.config.autoScroll === 'object' ? this.config.autoScroll : undefined;\n this.autoScroller = createAutoScroller(viewport, opts, (active) => {\n this.gridElement.classList.toggle('tbw-grid--auto-scrolling', active);\n });\n }\n\n private applyDropPositionClasses(rowEl: HTMLElement | null, isBefore: boolean): void {\n this.clearDropTargetClasses();\n if (!rowEl) return;\n rowEl.classList.add('drop-target');\n rowEl.classList.toggle('drop-before', isBefore);\n rowEl.classList.toggle('drop-after', !isBefore);\n }\n\n private clearDropTargetClasses(): void {\n this.gridElement?.querySelectorAll('.data-grid-row.drop-target').forEach((row) => {\n row.classList.remove('drop-target', 'drop-before', 'drop-after');\n });\n }\n\n private clearDragClasses(): void {\n this.gridElement?.querySelectorAll('.data-grid-row').forEach((row) => {\n row.classList.remove(GridClasses.DRAGGING, 'drop-target', 'drop-before', 'drop-after');\n });\n }\n\n private resetDragState(): void {\n this.isDragging = false;\n this.draggedRowIndex = null;\n this.draggedRows = [];\n this.draggedIndices = [];\n this.dragSessionId = null;\n this.dragAccepted = false;\n this.dropRowIndex = null;\n this.pendingMove = null;\n }\n\n private getRowIndex(rowEl: HTMLElement): number {\n const cell = rowEl.querySelector('.cell[data-row]');\n return cell ? parseInt(cell.getAttribute('data-row') ?? '-1', 10) : -1;\n }\n\n private clearDebounceTimer(): void {\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = null;\n }\n }\n\n // #endregion\n\n // #region Intra-Grid Move\n\n private handleKeyboardMove(row: T, fromIndex: number, toIndex: number, focusCol: number): void {\n if (!this.pendingMove) {\n this.pendingMove = { originalIndex: fromIndex, currentIndex: toIndex, row };\n } else {\n this.pendingMove.currentIndex = toIndex;\n }\n this.lastFocusCol = focusCol;\n\n const grid = this.internalGrid;\n const rows = [...(grid._rows ?? this.sourceRows)];\n const [movedRow] = rows.splice(fromIndex, 1);\n rows.splice(toIndex, 0, movedRow);\n\n grid._rows = rows;\n grid._focusRow = toIndex;\n grid._focusCol = focusCol;\n grid.refreshVirtualWindow(true);\n ensureCellVisible(grid);\n\n this.clearDebounceTimer();\n this.debounceTimer = setTimeout(() => this.flushPendingMove(), this.config.debounceMs ?? 300);\n }\n\n private flushPendingMove(): void {\n this.clearDebounceTimer();\n if (!this.pendingMove) return;\n const { originalIndex, currentIndex, row: movedRow } = this.pendingMove;\n this.pendingMove = null;\n if (originalIndex === currentIndex) return;\n\n const grid = this.internalGrid;\n // `grid._rows` already reflects the post-move order (mutated incrementally\n // by `handleKeyboardMove`); report it as `detail.rows` so consumers see\n // the actual reordered array, not the original `sourceRows` snapshot.\n const postMoveRows = (grid._rows ?? this.sourceRows) as T[];\n const detail: RowMoveDetail<T> = {\n row: movedRow as T,\n fromIndex: originalIndex,\n toIndex: currentIndex,\n rows: [...postMoveRows],\n source: 'keyboard',\n };\n const cancelled = this.emitCancelable('row-move', detail);\n if (cancelled) {\n // Revert: restore the original snapshot. `sourceRows` was never mutated\n // during the pending move (only `grid._rows` was), so resetting from it\n // is the correct rollback regardless of how many incremental keyboard\n // moves accumulated.\n grid._rows = [...this.sourceRows];\n grid._focusRow = originalIndex;\n grid._focusCol = this.lastFocusCol;\n grid.refreshVirtualWindow(true);\n ensureCellVisible(grid);\n }\n }\n\n private executeIntraGridMove(row: unknown, fromIndex: number, toIndex: number, source: 'keyboard' | 'drag'): void {\n const rows = [...this.sourceRows];\n const [movedRow] = rows.splice(fromIndex, 1);\n rows.splice(toIndex, 0, movedRow);\n const detail: RowMoveDetail<T> = {\n row: row as T,\n fromIndex,\n toIndex,\n rows: rows as T[],\n source,\n };\n const cancelled = this.emitCancelable('row-move', detail);\n if (cancelled) return;\n if (this.animationType === 'flip' && this.gridElement) {\n const oldPositions = this.captureRowPositions();\n this.grid.rows = rows;\n requestAnimationFrame(() => {\n void this.gridElement.offsetHeight;\n this.animateFLIP(oldPositions, fromIndex, toIndex);\n });\n } else {\n this.grid.rows = rows;\n }\n }\n\n private captureRowPositions(): Map<number, number> {\n const positions = new Map<number, number>();\n this.gridElement?.querySelectorAll('.data-grid-row').forEach((row) => {\n const rowIndex = this.getRowIndex(row as HTMLElement);\n if (rowIndex >= 0) positions.set(rowIndex, row.getBoundingClientRect().top);\n });\n return positions;\n }\n\n private animateFLIP(oldPositions: Map<number, number>, fromIndex: number, toIndex: number): void {\n const gridEl = this.gridElement;\n if (!gridEl || oldPositions.size === 0) return;\n\n const minIndex = Math.min(fromIndex, toIndex);\n const maxIndex = Math.max(fromIndex, toIndex);\n const rowsToAnimate: { el: HTMLElement; deltaY: number }[] = [];\n\n gridEl.querySelectorAll('.data-grid-row').forEach((row) => {\n const rowEl = row as HTMLElement;\n const newRowIndex = this.getRowIndex(rowEl);\n if (newRowIndex < 0 || newRowIndex < minIndex || newRowIndex > maxIndex) return;\n let oldIndex: number;\n if (newRowIndex === toIndex) oldIndex = fromIndex;\n else if (fromIndex < toIndex) oldIndex = newRowIndex + 1;\n else oldIndex = newRowIndex - 1;\n const oldTop = oldPositions.get(oldIndex);\n if (oldTop === undefined) return;\n const newTop = rowEl.getBoundingClientRect().top;\n const deltaY = oldTop - newTop;\n if (Math.abs(deltaY) > 1) rowsToAnimate.push({ el: rowEl, deltaY });\n });\n\n if (rowsToAnimate.length === 0) return;\n\n rowsToAnimate.forEach(({ el, deltaY }) => {\n el.style.transform = `translateY(${deltaY}px)`;\n });\n void gridEl.offsetHeight;\n\n const duration = this.animationDuration;\n requestAnimationFrame(() => {\n rowsToAnimate.forEach(({ el }) => {\n el.classList.add('flip-animating');\n el.style.transform = '';\n });\n setTimeout(() => {\n rowsToAnimate.forEach(({ el }) => {\n el.style.transform = '';\n el.classList.remove('flip-animating');\n });\n }, duration + 50);\n });\n }\n\n // #endregion\n}\n"],"mappings":"koBAqBA,SAAS,IACP,MAAqD,mBAAvC,YAAY,WAAW,WACvC,CAwDA,SAAgB,EAA0B,EAAY,GACpD,IAAI,EAA8B,KAC9B,GAAS,EACT,GAAW,EACf,MAAM,EAAQ,IAAI,gBAElB,SAAS,IACF,GAAW,IAChB,GAAS,EACL,KAAmB,EAAK,cAC5B,EAAK,QAAS,EAChB,CAyDA,OAfA,SAAS,iBACP,cACC,IACK,GAAU,IAAS,EAAE,eAAe,SAAS,IAAO,KAE1D,CAAE,SAAS,EAAM,OAAQ,EAAM,SAEjC,SAAS,iBACP,UACC,IACkC,WAA5B,EAAoB,KAAkB,KAE7C,CAAE,SAAS,EAAM,OAAQ,EAAM,SAG1B,CACL,WAAI,GACF,OAAO,CACT,EACA,IAAA,CAAK,EAAQ,EAAO,GAClB,GAAI,GAA+B,IAAnB,EAAQ,OAAc,OACjC,IAAM,EA7Df,WACE,MAAM,EAAK,SAAS,cAAc,OAkBlC,OAjBA,EAAG,GAAK,EACR,EAAG,UAAY,EACf,EAAG,aAAa,UAAW,UAC3B,EAAG,aAAa,OAAQ,SAExB,EAAG,QAAS,EAIZ,EAAG,iBACD,WACC,IACC,MAAM,EAAQ,EAAiB,cAC3B,aAAgB,OAAS,EAAG,SAAS,IAAO,KAElD,CAAE,OAAQ,EAAM,SAEX,CACT,CAyCsB,IAGlB,MAAM,EAAO,EAAO,QAAqB,8BAAgC,SAAS,KAC9E,EAAK,aAAe,GAAM,EAAK,YAAY,GAC/C,EAAK,aAAa,aAAc,GAChC,EAAK,kBACL,IAAK,MAAM,KAAU,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