@toolbox-web/grid 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.d.ts +1 -0
- package/all.js +2 -2
- package/all.js.map +1 -1
- package/custom-elements.json +21 -2
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/core/adapter-conformance.d.ts +23 -0
- package/lib/core/grid.d.ts +15 -16
- package/lib/core/internal/diagnostics.d.ts +5 -1
- package/lib/core/internal/dom-builder.d.ts +0 -25
- package/lib/core/internal/drag-drop-registry.d.ts +66 -0
- package/lib/core/internal/render-scheduler.d.ts +9 -8
- package/lib/core/plugin/base-plugin.d.ts +23 -0
- package/lib/core/plugin/plugin-manager.d.ts +9 -0
- package/lib/core/types.d.ts +139 -58
- package/lib/features/registry.js.map +1 -1
- package/lib/features/reorder-rows.d.ts +3 -3
- package/lib/features/reorder-rows.js +1 -1
- package/lib/features/reorder-rows.js.map +1 -1
- package/lib/features/row-drag-drop.d.ts +9 -0
- package/lib/features/row-drag-drop.js +2 -0
- package/lib/features/row-drag-drop.js.map +1 -0
- package/lib/features/server-side.js.map +1 -1
- 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/ExportPlugin.d.ts +89 -0
- package/lib/plugins/export/index.d.ts +3 -2
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/export/types.d.ts +30 -0
- 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 +2 -2
- 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/PinnedColumnsPlugin.d.ts +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-columns/types.d.ts +7 -0
- 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/ReorderPlugin.d.ts +13 -1
- package/lib/plugins/reorder-columns/column-drag.d.ts +7 -1
- package/lib/plugins/reorder-columns/index.js +1 -1
- package/lib/plugins/reorder-columns/index.js.map +1 -1
- package/lib/plugins/reorder-columns/types.d.ts +12 -0
- package/lib/plugins/reorder-rows/RowReorderPlugin.d.ts +14 -156
- package/lib/plugins/reorder-rows/index.d.ts +10 -4
- package/lib/plugins/reorder-rows/index.js +1 -1
- package/lib/plugins/reorder-rows/index.js.map +1 -1
- package/lib/plugins/reorder-rows/types.d.ts +9 -86
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-drag-drop/RowDragDropPlugin.d.ts +106 -0
- package/lib/plugins/row-drag-drop/index.d.ts +9 -0
- package/lib/plugins/row-drag-drop/index.js +2 -0
- package/lib/plugins/row-drag-drop/index.js.map +1 -0
- package/lib/plugins/row-drag-drop/types.d.ts +255 -0
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +8 -0
- package/lib/plugins/server-side/ServerSidePlugin.d.ts +13 -0
- package/lib/plugins/server-side/datasource-types.d.ts +54 -7
- package/lib/plugins/server-side/datasource.d.ts +10 -2
- package/lib/plugins/server-side/index.d.ts +1 -1
- package/lib/plugins/server-side/index.js +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/server-side/types.d.ts +1 -1
- package/lib/plugins/shared/drag-drop-protocol.d.ts +98 -0
- package/lib/plugins/tooltip/index.js +1 -1
- package/lib/plugins/tooltip/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +19 -6
- 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/VisibilityPlugin.d.ts +11 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +1 -0
- 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/export.umd.js +1 -1
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/print.umd.js +1 -1
- package/umd/plugins/print.umd.js.map +1 -1
- package/umd/plugins/reorder-columns.umd.js +1 -1
- package/umd/plugins/reorder-columns.umd.js.map +1 -1
- package/umd/plugins/reorder-rows.umd.js +1 -1
- package/umd/plugins/reorder-rows.umd.js.map +1 -1
- package/umd/plugins/row-drag-drop.umd.js +2 -0
- package/umd/plugins/row-drag-drop.umd.js.map +1 -0
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/server-side.umd.js +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pinned-columns.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/pinned-columns/pinned-columns.ts","../../../../../libs/grid/src/lib/plugins/pinned-columns/PinnedColumnsPlugin.ts"],"sourcesContent":["/**\n * Pinned Columns Core Logic\n *\n * Pure functions for applying pinned (sticky) column positioning.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { GridClasses } from '../../core/constants';\nimport { getDirection, resolveInlinePosition, type TextDirection } from '../../core/internal/utils';\nimport type { PinnedPosition, ResolvedPinnedPosition } from './types';\n\n/**\n * Get the effective pinned position from a column.\n *\n * @param col - Column configuration object\n * @returns The pinned position, or undefined if not pinned\n */\nexport function getColumnPinned(col: any): PinnedPosition | undefined {\n return col.pinned ?? col.meta?.pinned;\n}\n\n/**\n * Resolve a pinned position to a physical position based on text direction.\n *\n * - `'left'` / `'right'` → unchanged (physical values)\n * - `'start'` → `'left'` in LTR, `'right'` in RTL\n * - `'end'` → `'right'` in LTR, `'left'` in RTL\n *\n * @param position - The pinned position (logical or physical)\n * @param direction - Text direction ('ltr' or 'rtl')\n * @returns Physical pinned position ('left' or 'right')\n */\nexport function resolveStickyPosition(position: PinnedPosition, direction: TextDirection): ResolvedPinnedPosition {\n return resolveInlinePosition(position, direction);\n}\n\n/**\n * Check if a column is pinned on the left (after resolving logical positions).\n */\nfunction isResolvedLeft(col: any, direction: TextDirection): boolean {\n const pinned = getColumnPinned(col);\n if (!pinned) return false;\n return resolveStickyPosition(pinned, direction) === 'left';\n}\n\n/**\n * Check if a column is pinned on the right (after resolving logical positions).\n */\nfunction isResolvedRight(col: any, direction: TextDirection): boolean {\n const pinned = getColumnPinned(col);\n if (!pinned) return false;\n return resolveStickyPosition(pinned, direction) === 'right';\n}\n\n/**\n * Get columns that should be sticky on the left.\n *\n * @param columns - Array of column configurations\n * @param direction - Text direction (default: 'ltr')\n * @returns Array of columns with sticky='left' or sticky='start' (in LTR)\n */\nexport function getLeftStickyColumns(columns: any[], direction: TextDirection = 'ltr'): any[] {\n return columns.filter((col) => isResolvedLeft(col, direction));\n}\n\n/**\n * Get columns that should be sticky on the right.\n *\n * @param columns - Array of column configurations\n * @param direction - Text direction (default: 'ltr')\n * @returns Array of columns with sticky='right' or sticky='end' (in LTR)\n */\nexport function getRightStickyColumns(columns: any[], direction: TextDirection = 'ltr'): any[] {\n return columns.filter((col) => isResolvedRight(col, direction));\n}\n\n/**\n * Check if any columns have sticky positioning.\n *\n * @param columns - Array of column configurations\n * @returns True if any column has sticky position\n */\nexport function hasStickyColumns(columns: any[]): boolean {\n for (let i = 0; i < columns.length; i++) {\n if (columns[i].pinned != null || columns[i].meta?.pinned != null) return true;\n }\n return false;\n}\n\n/**\n * Get the sticky position of a column.\n *\n * @param column - Column configuration\n * @returns The sticky position or null if not sticky\n */\nexport function getColumnStickyPosition(column: any): PinnedPosition | null {\n return getColumnPinned(column) ?? null;\n}\n\n/**\n * Calculate left offsets for sticky-left columns.\n * Returns a map of field -> offset in pixels.\n *\n * @param columns - Array of column configurations (in order)\n * @param getColumnWidth - Function to get column width by field\n * @param direction - Text direction (default: 'ltr')\n * @returns Map of field to left offset\n */\nexport function calculateLeftStickyOffsets(\n columns: any[],\n getColumnWidth: (field: string) => number,\n direction: TextDirection = 'ltr',\n): Map<string, number> {\n const offsets = new Map<string, number>();\n let currentOffset = 0;\n\n for (const col of columns) {\n if (isResolvedLeft(col, direction)) {\n offsets.set(col.field, currentOffset);\n currentOffset += getColumnWidth(col.field);\n }\n }\n\n return offsets;\n}\n\n/**\n * Calculate right offsets for sticky-right columns.\n * Processes columns in reverse order.\n *\n * @param columns - Array of column configurations (in order)\n * @param getColumnWidth - Function to get column width by field\n * @param direction - Text direction (default: 'ltr')\n * @returns Map of field to right offset\n */\nexport function calculateRightStickyOffsets(\n columns: any[],\n getColumnWidth: (field: string) => number,\n direction: TextDirection = 'ltr',\n): Map<string, number> {\n const offsets = new Map<string, number>();\n let currentOffset = 0;\n\n // Process in reverse for right-sticky columns\n const reversed = [...columns].reverse();\n for (const col of reversed) {\n if (isResolvedRight(col, direction)) {\n offsets.set(col.field, currentOffset);\n currentOffset += getColumnWidth(col.field);\n }\n }\n\n return offsets;\n}\n\n/**\n * Adjustments to `group-end` borders at pin boundaries within implicit groups.\n * - `addGroupEnd`: fields that should gain `group-end` (last pinned column at boundary)\n * - `removeGroupEnd`: fields that should lose `group-end` (lone non-pinned remnant)\n */\nexport interface GroupEndAdjustments {\n addGroupEnd: Set<string>;\n removeGroupEnd: Set<string>;\n}\n\n/**\n * Result of applying sticky offsets — includes both the group-end adjustments\n * and the measured left/right offset maps for use in per-cell rendering hooks.\n */\nexport interface StickyOffsetsResult {\n groupEndAdjustments: GroupEndAdjustments;\n leftOffsets: Map<string, number>;\n rightOffsets: Map<string, number>;\n splitGroups: SplitGroupState[];\n}\n\n/**\n * State for an explicit group header that was split at a pin boundary.\n *\n * The pinned fragment is sticky and initially empty. The non-pinned fragment\n * holds the label in a CSS-sticky span that floats toward the pinned area on\n * horizontal scroll. When the non-pinned fragment scrolls far enough, the\n * plugin's `onScroll` handler transfers the label into the pinned fragment.\n */\nexport interface SplitGroupState {\n /** Group identifier (data-group attribute value). */\n groupId: string;\n /** Original group label text. */\n label: string;\n /** The sticky (pinned) fragment element. */\n pinnedFragment: HTMLElement;\n /** The scrollable (non-pinned) fragment element. */\n scrollableFragment: HTMLElement;\n /** The floating <span> inside the scrollable fragment. */\n floatLabel: HTMLElement;\n /** Field of the last pinned column — used to toggle `.group-end`. */\n pinnedField: string;\n /** Whether the label is currently shown inside the pinned fragment. */\n isTransferred: boolean;\n /** Current translateX offset applied to the floating label (px). */\n floatOffset: number;\n}\n\n/**\n * Apply sticky offsets to header and body cells.\n * This modifies the DOM elements in place.\n *\n * @param host - The grid host element (render root for DOM queries)\n * @param columns - Array of column configurations\n * @returns Sticky offsets result with group-end adjustments and measured offset maps\n */\nexport function applyStickyOffsets(host: HTMLElement, columns: any[]): StickyOffsetsResult {\n const emptyResult: StickyOffsetsResult = {\n groupEndAdjustments: { addGroupEnd: new Set(), removeGroupEnd: new Set() },\n leftOffsets: new Map(),\n rightOffsets: new Map(),\n splitGroups: [],\n };\n\n // With light DOM, query the host element directly\n const headerCells = Array.from(host.querySelectorAll('.header-row .cell')) as HTMLElement[];\n if (!headerCells.length) return emptyResult;\n\n // Detect text direction from the host element\n const direction = getDirection(host);\n\n // Collect measured offsets for caching in the plugin\n const leftOffsets = new Map<string, number>();\n const rightOffsets = new Map<string, number>();\n\n // Apply left sticky (includes 'start' in LTR, 'end' in RTL)\n let left = 0;\n for (const col of columns) {\n if (isResolvedLeft(col, direction)) {\n const cell = headerCells.find((c) => c.getAttribute('data-field') === col.field);\n if (cell) {\n leftOffsets.set(col.field, left);\n cell.classList.add(GridClasses.STICKY_LEFT);\n cell.style.position = 'sticky';\n cell.style.left = left + 'px';\n // Body cells: use data-field for reliable matching (data-col indices may differ\n // between _columns and _visibleColumns due to hidden/utility columns)\n host.querySelectorAll(`.data-grid-row .cell[data-field=\"${col.field}\"]`).forEach((el) => {\n el.classList.add(GridClasses.STICKY_LEFT);\n (el as HTMLElement).style.position = 'sticky';\n (el as HTMLElement).style.left = left + 'px';\n });\n left += cell.offsetWidth;\n }\n }\n }\n\n // Apply right sticky (includes 'end' in LTR, 'start' in RTL) - process in reverse\n let right = 0;\n for (const col of [...columns].reverse()) {\n if (isResolvedRight(col, direction)) {\n const cell = headerCells.find((c) => c.getAttribute('data-field') === col.field);\n if (cell) {\n rightOffsets.set(col.field, right);\n cell.classList.add(GridClasses.STICKY_RIGHT);\n cell.style.position = 'sticky';\n cell.style.right = right + 'px';\n // Body cells: use data-field for reliable matching\n host.querySelectorAll(`.data-grid-row .cell[data-field=\"${col.field}\"]`).forEach((el) => {\n el.classList.add(GridClasses.STICKY_RIGHT);\n (el as HTMLElement).style.position = 'sticky';\n (el as HTMLElement).style.right = right + 'px';\n });\n right += cell.offsetWidth;\n }\n }\n }\n\n // Apply sticky offsets to column group header cells and collect group-end adjustments\n const splitGroups: SplitGroupState[] = [];\n const adjustments = applyGroupHeaderStickyOffsets(host, columns, headerCells, direction, splitGroups);\n\n // Apply group-end adjustments to header cells and visible body cells\n if (adjustments.addGroupEnd.size > 0 || adjustments.removeGroupEnd.size > 0) {\n for (const field of adjustments.addGroupEnd) {\n const hCell = headerCells.find((c) => c.getAttribute('data-field') === field);\n if (hCell) hCell.classList.add('group-end');\n host.querySelectorAll(`.data-grid-row .cell[data-field=\"${field}\"]`).forEach((el) => {\n el.classList.add('group-end');\n });\n }\n for (const field of adjustments.removeGroupEnd) {\n const hCell = headerCells.find((c) => c.getAttribute('data-field') === field);\n if (hCell) hCell.classList.remove('group-end');\n host.querySelectorAll(`.data-grid-row .cell[data-field=\"${field}\"]`).forEach((el) => {\n el.classList.remove('group-end');\n });\n }\n }\n\n return { groupEndAdjustments: adjustments, leftOffsets, rightOffsets, splitGroups };\n}\n\n/**\n * Apply sticky offsets to column group header cells.\n * - If ALL columns in a group are pinned the same direction, the whole cell is pinned.\n * - If an implicit (unlabelled) group mixes pinned and non-pinned columns,\n * the cell is split at pin boundaries so pinned portions can be sticky.\n *\n * @param host - The grid host element\n * @param columns - Array of column configurations\n * @param headerCells - Already-queried header cells (with sticky offsets applied)\n * @param direction - Text direction\n * @returns Group-end adjustments for pin boundaries within implicit groups\n */\nfunction applyGroupHeaderStickyOffsets(\n host: HTMLElement,\n columns: any[],\n headerCells: HTMLElement[],\n direction: TextDirection,\n splitGroups: SplitGroupState[],\n): GroupEndAdjustments {\n const adjustments: GroupEndAdjustments = { addGroupEnd: new Set(), removeGroupEnd: new Set() };\n const groupCells = Array.from(host.querySelectorAll('.header-group-row .header-group-cell')) as HTMLElement[];\n if (!groupCells.length) return adjustments;\n\n for (const groupCell of groupCells) {\n // Parse gridColumn to find which column range this group spans\n // Format: \"startCol / span N\" (1-based)\n const gridCol = groupCell.style.gridColumn;\n if (!gridCol) continue;\n\n const match = gridCol.match(/^(\\d+)\\s*\\/\\s*span\\s+(\\d+)$/);\n if (!match) continue;\n\n const startIdx = parseInt(match[1], 10) - 1; // Convert to 0-based\n const span = parseInt(match[2], 10);\n const endIdx = startIdx + span - 1;\n\n // Get the columns this group spans\n const spannedColumns = columns.slice(startIdx, endIdx + 1);\n if (!spannedColumns.length) continue;\n\n const allLeft = spannedColumns.every((col: any) => isResolvedLeft(col, direction));\n const allRight = spannedColumns.every((col: any) => isResolvedRight(col, direction));\n\n if (allLeft) {\n const firstField = spannedColumns[0].field;\n const firstCell = headerCells.find((c) => c.getAttribute('data-field') === firstField);\n if (firstCell) {\n groupCell.classList.add(GridClasses.STICKY_LEFT);\n groupCell.style.position = 'sticky';\n groupCell.style.left = firstCell.style.left;\n }\n } else if (allRight) {\n const lastField = spannedColumns[spannedColumns.length - 1].field;\n const lastCell = headerCells.find((c) => c.getAttribute('data-field') === lastField);\n if (lastCell) {\n groupCell.classList.add(GridClasses.STICKY_RIGHT);\n groupCell.style.position = 'sticky';\n groupCell.style.right = lastCell.style.right;\n }\n } else if (groupCell.classList.contains('implicit-group')) {\n // Implicit group with mixed pinning: split into separate cells so pinned\n // portions become sticky while non-pinned portions scroll normally.\n splitMixedPinImplicitGroup(groupCell, spannedColumns, startIdx, headerCells, direction, adjustments);\n } else {\n // Explicit (labelled) group with mixed pinning: split the group header so\n // the pinned fragment keeps the label and sticks, while the non-pinned\n // remainder scrolls away. This makes the group header visually shrink to\n // the pinned column width when scrolled horizontally.\n const someLeft = spannedColumns.some((col: any) => isResolvedLeft(col, direction));\n const someRight = spannedColumns.some((col: any) => isResolvedRight(col, direction));\n if (someLeft || someRight) {\n splitMixedPinExplicitGroup(\n groupCell,\n spannedColumns,\n startIdx,\n headerCells,\n direction,\n adjustments,\n splitGroups,\n );\n }\n }\n }\n\n return adjustments;\n}\n\n/** Classify a column's pin state after resolving logical positions. */\ntype PinState = 'left' | 'right' | 'none';\n\nfunction getPinState(col: any, direction: TextDirection): PinState {\n if (isResolvedLeft(col, direction)) return 'left';\n if (isResolvedRight(col, direction)) return 'right';\n return 'none';\n}\n\n/**\n * Split an implicit (unlabelled) group header cell into fragments at pin-state\n * boundaries. Each fragment becomes its own header-group-cell; pinned fragments\n * get sticky positioning.\n *\n * Also populates `adjustments` with group-end border changes:\n * - Last column of a left-pinned run gets `group-end` (visual separator at pin edge)\n * - Last column of a subsequent non-pinned run that contains only utility columns\n * loses `group-end` (it visually merges with the adjacent explicit group)\n */\nfunction splitMixedPinImplicitGroup(\n groupCell: HTMLElement,\n spannedColumns: any[],\n startIdx: number,\n headerCells: HTMLElement[],\n direction: TextDirection,\n adjustments: GroupEndAdjustments,\n): void {\n // Partition columns into contiguous runs of the same pin state\n const runs: { state: PinState; cols: any[]; colStart: number }[] = [];\n for (let i = 0; i < spannedColumns.length; i++) {\n const state = getPinState(spannedColumns[i], direction);\n const prev = runs[runs.length - 1];\n if (prev && prev.state === state) {\n prev.cols.push(spannedColumns[i]);\n } else {\n runs.push({ state, cols: [spannedColumns[i]], colStart: startIdx + i });\n }\n }\n\n if (runs.length <= 1) return; // Nothing to split\n\n const parent = groupCell.parentElement;\n if (!parent) return;\n\n const nextSibling = groupCell.nextSibling;\n parent.removeChild(groupCell);\n\n for (const run of runs) {\n const cell = document.createElement('div');\n cell.className = groupCell.className; // Preserves implicit-group, cell, header-group-cell\n cell.setAttribute('data-group', groupCell.getAttribute('data-group') || '');\n cell.style.gridColumn = `${run.colStart + 1} / span ${run.cols.length}`;\n\n if (run.state === 'left') {\n const firstField = run.cols[0].field;\n const firstCell = headerCells.find((c) => c.getAttribute('data-field') === firstField);\n if (firstCell) {\n cell.classList.add(GridClasses.STICKY_LEFT);\n cell.style.position = 'sticky';\n cell.style.left = firstCell.style.left;\n }\n } else if (run.state === 'right') {\n const lastField = run.cols[run.cols.length - 1].field;\n const lastCell = headerCells.find((c) => c.getAttribute('data-field') === lastField);\n if (lastCell) {\n cell.classList.add(GridClasses.STICKY_RIGHT);\n cell.style.position = 'sticky';\n cell.style.right = lastCell.style.right;\n }\n } else if (run.state === 'none') {\n // Suppress border on utility-only non-pinned remnants — they visually merge\n // with the adjacent explicit group.\n const allUtility = run.cols.every((c: any) => String(c.field || '').startsWith('__tbw_'));\n if (allUtility) {\n cell.style.borderRightStyle = 'none';\n }\n }\n\n if (nextSibling) {\n parent.insertBefore(cell, nextSibling);\n } else {\n parent.appendChild(cell);\n }\n }\n\n // Compute group-end adjustments at pin boundaries.\n // When a pinned run is followed by a non-pinned run, the last column of the\n // pinned run should be the visual group boundary (group-end).\n // The non-pinned remnant's last column should lose group-end if all its\n // columns are utility columns (e.g. __tbw_expander) — they visually merge\n // with the adjacent explicit group.\n for (let ri = 0; ri < runs.length; ri++) {\n const run = runs[ri];\n const nextRun = runs[ri + 1];\n\n if (run.state !== 'none' && nextRun && nextRun.state === 'none') {\n // Last column of pinned run gets group-end\n const lastPinnedField = run.cols[run.cols.length - 1].field;\n if (lastPinnedField) adjustments.addGroupEnd.add(lastPinnedField);\n }\n\n if (run.state === 'none') {\n // Check if all columns in this non-pinned run are utility columns\n const allUtility = run.cols.every((c: any) => String(c.field || '').startsWith('__tbw_'));\n if (allUtility) {\n // Remove group-end from the last column — it visually merges with the next group\n const lastField = run.cols[run.cols.length - 1].field;\n if (lastField) adjustments.removeGroupEnd.add(lastField);\n }\n }\n }\n}\n\n/**\n * Split an explicit (labelled) group header cell at pin boundaries.\n *\n * **Pinned fragment:** sticky, initially empty (no label, no `.group-end`).\n * **Non-pinned fragment:** carries the label inside a CSS-sticky elevated `<span>`.\n * The span floats left over the pinned fragment as the user scrolls horizontally.\n *\n * When the non-pinned fragment's left edge reaches the pinned fragment's right\n * edge (i.e. only the pinned column width remains), the plugin's `onScroll` hook\n * transfers the label into the pinned fragment and adds `.group-end`.\n */\nfunction splitMixedPinExplicitGroup(\n groupCell: HTMLElement,\n spannedColumns: any[],\n startIdx: number,\n headerCells: HTMLElement[],\n direction: TextDirection,\n _adjustments: GroupEndAdjustments,\n splitGroups: SplitGroupState[],\n): void {\n // Partition columns into contiguous runs of the same pin state\n const runs: { state: PinState; cols: any[]; colStart: number }[] = [];\n for (let i = 0; i < spannedColumns.length; i++) {\n const state = getPinState(spannedColumns[i], direction);\n const prev = runs[runs.length - 1];\n if (prev && prev.state === state) {\n prev.cols.push(spannedColumns[i]);\n } else {\n runs.push({ state, cols: [spannedColumns[i]], colStart: startIdx + i });\n }\n }\n\n if (runs.length <= 1) return; // Nothing to split\n\n const parent = groupCell.parentElement;\n if (!parent) return;\n\n const label = groupCell.textContent || '';\n const groupId = groupCell.getAttribute('data-group') || '';\n const nextSibling = groupCell.nextSibling;\n parent.removeChild(groupCell);\n\n // Identify the pinned run and the adjacent non-pinned run.\n const firstLeftRunIdx = runs.findIndex((r) => r.state === 'left');\n let lastRightRunIdx = -1;\n for (let i = runs.length - 1; i >= 0; i--) {\n if (runs[i].state === 'right') {\n lastRightRunIdx = i;\n break;\n }\n }\n const pinnedRunIdx = firstLeftRunIdx >= 0 ? firstLeftRunIdx : lastRightRunIdx;\n const floatRunIdx =\n firstLeftRunIdx >= 0 && firstLeftRunIdx + 1 < runs.length\n ? firstLeftRunIdx + 1\n : lastRightRunIdx >= 0 && lastRightRunIdx - 1 >= 0\n ? lastRightRunIdx - 1\n : -1;\n\n let pinnedStickyOffset = '0px';\n let pinnedFragment: HTMLElement | undefined;\n let scrollableFragment: HTMLElement | undefined;\n let floatLabel: HTMLElement | undefined;\n let pinnedField = '';\n\n for (let ri = 0; ri < runs.length; ri++) {\n const run = runs[ri];\n const cell = document.createElement('div');\n cell.className = groupCell.className;\n cell.setAttribute('data-group', groupId);\n cell.style.gridColumn = `${run.colStart + 1} / span ${run.cols.length}`;\n\n if (run.state === 'left') {\n const firstField = run.cols[0].field;\n const firstCell = headerCells.find((c) => c.getAttribute('data-field') === firstField);\n if (firstCell) {\n cell.classList.add(GridClasses.STICKY_LEFT);\n cell.style.position = 'sticky';\n cell.style.left = firstCell.style.left;\n pinnedStickyOffset = firstCell.style.left;\n }\n\n if (ri === pinnedRunIdx) {\n // Pinned fragment: empty, no group-end, hide border so it merges visually\n cell.style.borderRightStyle = 'none';\n pinnedFragment = cell;\n pinnedField = run.cols[run.cols.length - 1].field;\n }\n } else if (run.state === 'right') {\n const lastField = run.cols[run.cols.length - 1].field;\n const lastCell = headerCells.find((c) => c.getAttribute('data-field') === lastField);\n if (lastCell) {\n cell.classList.add(GridClasses.STICKY_RIGHT);\n cell.style.position = 'sticky';\n cell.style.right = lastCell.style.right;\n }\n\n if (ri === pinnedRunIdx) {\n cell.style.borderLeftStyle = 'none';\n pinnedFragment = cell;\n pinnedField = run.cols[0].field;\n }\n }\n\n // The non-pinned run that carries the floating label.\n // CSS sticky won't work here because .header-group-cell has overflow:hidden\n // (set by grouping-columns.css for text clipping). So the plugin's onScroll\n // handler manually translates the span to simulate sticky behavior.\n if (ri === floatRunIdx) {\n // Allow the span to overflow outside the cell when translated left\n cell.style.overflow = 'visible';\n\n const span = document.createElement('span');\n span.textContent = label;\n span.style.position = 'relative';\n span.style.zIndex = '36';\n span.style.display = 'block';\n span.style.overflow = 'hidden';\n span.style.textOverflow = 'ellipsis';\n span.style.whiteSpace = 'nowrap';\n\n cell.appendChild(span);\n scrollableFragment = cell;\n floatLabel = span;\n }\n\n if (nextSibling) {\n parent.insertBefore(cell, nextSibling);\n } else {\n parent.appendChild(cell);\n }\n }\n\n // Register the split group state so the plugin can manage label transfer on scroll.\n if (pinnedFragment && scrollableFragment && floatLabel && pinnedField) {\n splitGroups.push({\n groupId,\n label,\n pinnedFragment,\n scrollableFragment,\n floatLabel,\n pinnedField,\n isTransferred: false,\n floatOffset: 0,\n });\n }\n}\n\n/**\n * Reorder columns so that pinned-left columns come first and pinned-right columns come last.\n * Maintains the relative order within each group (left-pinned, unpinned, right-pinned).\n *\n * @param columns - Array of column configurations (in their current order)\n * @param direction - Text direction ('ltr' or 'rtl'), used to resolve logical positions\n * @returns New array with pinned columns moved to the edges\n */\nexport function reorderColumnsForPinning(columns: readonly any[], direction: TextDirection = 'ltr'): any[] {\n const left: any[] = [];\n const middle: any[] = [];\n const right: any[] = [];\n\n for (const col of columns) {\n const pinned = getColumnPinned(col);\n if (pinned) {\n const resolved = resolveStickyPosition(pinned, direction);\n if (resolved === 'left') left.push(col);\n else right.push(col);\n } else {\n middle.push(col);\n }\n }\n\n return [...left, ...middle, ...right];\n}\n\n/**\n * Clear sticky positioning from all cells.\n *\n * @param host - The grid host element (render root for DOM queries)\n */\nexport function clearStickyOffsets(host: HTMLElement): void {\n // With light DOM, query the host element directly\n const cells = host.querySelectorAll(`.${GridClasses.STICKY_LEFT}, .${GridClasses.STICKY_RIGHT}`);\n cells.forEach((cell) => {\n cell.classList.remove(GridClasses.STICKY_LEFT, GridClasses.STICKY_RIGHT);\n (cell as HTMLElement).style.position = '';\n (cell as HTMLElement).style.left = '';\n (cell as HTMLElement).style.right = '';\n });\n}\n","/**\n * Pinned Columns Plugin (Class-based)\n *\n * Enables column pinning (sticky left/right positioning).\n */\n\nimport { GridClasses } from '../../core/constants';\nimport { getDirection } from '../../core/internal/utils';\nimport type { AfterCellRenderContext, PluginManifest, PluginQuery, ScrollEvent } from '../../core/plugin/base-plugin';\nimport { BaseGridPlugin } from '../../core/plugin/base-plugin';\nimport type { ColumnConfig } from '../../core/types';\nimport type { ContextMenuParams, HeaderContextMenuItem } from '../context-menu/types';\nimport {\n applyStickyOffsets,\n clearStickyOffsets,\n getColumnPinned,\n getLeftStickyColumns,\n getRightStickyColumns,\n hasStickyColumns,\n reorderColumnsForPinning,\n type GroupEndAdjustments,\n type SplitGroupState,\n} from './pinned-columns';\nimport type { PinnedColumnsConfig, PinnedPosition } from './types';\n\n/** Query type constant for checking if a column can be moved */\nconst QUERY_CAN_MOVE_COLUMN = 'canMoveColumn';\n\n/**\n * Pinned Columns Plugin for tbw-grid\n *\n * Freezes columns to the left or right edge of the grid—essential for keeping key\n * identifiers or action buttons visible while scrolling through wide datasets. Just set\n * `pinned: 'left'` or `pinned: 'right'` on your column definitions.\n *\n * ## Installation\n *\n * ```ts\n * import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';\n * ```\n *\n * ## Column Configuration\n *\n * | Property | Type | Description |\n * |----------|------|-------------|\n * | `pinned` | `'left' \\| 'right' \\| 'start' \\| 'end'` | Pin column to edge (logical or physical) |\n * | `meta.lockPinning` | `boolean` | `false` | Prevent user from pin/unpin via context menu |\n *\n * ### RTL Support\n *\n * Use logical values (`start`/`end`) for grids that work in both LTR and RTL layouts:\n * - `'start'` - Pins to left in LTR, right in RTL\n * - `'end'` - Pins to right in LTR, left in RTL\n *\n * ## CSS Custom Properties\n *\n * | Property | Default | Description |\n * |----------|---------|-------------|\n * | `--tbw-pinned-shadow` | `4px 0 8px rgba(0,0,0,0.1)` | Shadow on pinned column edge |\n * | `--tbw-pinned-border` | `var(--tbw-color-border)` | Border between pinned and scrollable |\n *\n * @example Pin ID Left and Actions Right\n * ```ts\n * import { queryGrid } from '@toolbox-web/grid';\n * import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';\n *\n * const grid = queryGrid('tbw-grid');\n * grid.gridConfig = {\n * columns: [\n * { field: 'id', header: 'ID', pinned: 'left', width: 80 },\n * { field: 'name', header: 'Name' },\n * { field: 'email', header: 'Email' },\n * { field: 'department', header: 'Department' },\n * { field: 'actions', header: 'Actions', pinned: 'right', width: 120 },\n * ],\n * plugins: [new PinnedColumnsPlugin()],\n * };\n * ```\n *\n * @example RTL-Compatible Pinning\n * ```ts\n * // Same config works in LTR and RTL\n * grid.gridConfig = {\n * columns: [\n * { field: 'id', header: 'ID', pinned: 'start' }, // Left in LTR, Right in RTL\n * { field: 'name', header: 'Name' },\n * { field: 'actions', header: 'Actions', pinned: 'end' }, // Right in LTR, Left in RTL\n * ],\n * plugins: [new PinnedColumnsPlugin()],\n * };\n * ```\n *\n * @see {@link PinnedColumnsConfig} for configuration options\n *\n * @internal Extends BaseGridPlugin\n */\nexport class PinnedColumnsPlugin extends BaseGridPlugin<PinnedColumnsConfig> {\n /**\n * Plugin manifest - declares owned properties and handled queries.\n * @internal\n */\n static override readonly manifest: PluginManifest = {\n hookPriority: {\n // Reorder columns before other plugins (e.g. TreePlugin) wrap them\n processColumns: -10,\n },\n ownedProperties: [\n {\n property: 'pinned',\n level: 'column',\n description: 'the \"pinned\" column property',\n isUsed: (v) => v === 'left' || v === 'right' || v === 'start' || v === 'end',\n },\n ],\n queries: [\n {\n type: QUERY_CAN_MOVE_COLUMN,\n description: 'Prevents pinned columns from being moved/reordered',\n },\n {\n type: 'getStickyOffsets',\n description: 'Returns the offsets for left/right pinned columns',\n },\n {\n type: 'getContextMenuItems',\n description: 'Contributes pin/unpin items to the header context menu',\n },\n ],\n };\n\n /** @internal */\n readonly name = 'pinnedColumns';\n\n /** @internal */\n protected override get defaultConfig(): Partial<PinnedColumnsConfig> {\n return {};\n }\n\n // #region Internal State\n private isApplied = false;\n private leftOffsets = new Map<string, number>();\n private rightOffsets = new Map<string, number>();\n /** Group-end adjustments for pin boundaries within implicit groups. */\n #groupEndAdjustments: GroupEndAdjustments = { addGroupEnd: new Set(), removeGroupEnd: new Set() };\n /** Split explicit-group state for scroll-driven label transfer. */\n #splitGroups: SplitGroupState[] = [];\n /**\n * Snapshot of the column field order before the first context-menu pin.\n * Used to restore original positions when unpinning.\n */\n #originalColumnOrder: string[] = [];\n // #endregion\n\n // #region Lifecycle\n\n /** @internal */\n override detach(): void {\n this.leftOffsets.clear();\n this.rightOffsets.clear();\n this.isApplied = false;\n this.#groupEndAdjustments = { addGroupEnd: new Set(), removeGroupEnd: new Set() };\n this.#splitGroups = [];\n this.#originalColumnOrder = [];\n }\n // #endregion\n\n // #region Detection\n\n /**\n * Auto-detect sticky columns from column configuration.\n */\n static detect(rows: readonly unknown[], config: { columns?: ColumnConfig[] }): boolean {\n const columns = config?.columns;\n if (!Array.isArray(columns)) return false;\n return hasStickyColumns(columns);\n }\n // #endregion\n\n // #region Hooks\n\n /** @internal */\n override processColumns(columns: readonly ColumnConfig[]): ColumnConfig[] {\n const cols = [...columns];\n this.isApplied = hasStickyColumns(cols);\n if (!this.isApplied) return cols;\n\n const host = this.gridElement;\n const direction = host ? getDirection(host) : 'ltr';\n return reorderColumnsForPinning(cols, direction) as ColumnConfig[];\n }\n\n /** @internal */\n override afterRender(): void {\n if (!this.isApplied) {\n return;\n }\n\n const host = this.gridElement;\n const columns = [...this.columns];\n\n if (!hasStickyColumns(columns)) {\n clearStickyOffsets(host);\n this.isApplied = false;\n return;\n }\n\n // Apply sticky offsets after a microtask to ensure DOM is ready\n queueMicrotask(() => {\n const result = applyStickyOffsets(host, columns);\n this.#groupEndAdjustments = result.groupEndAdjustments;\n this.leftOffsets = result.leftOffsets;\n this.rightOffsets = result.rightOffsets;\n this.#splitGroups = result.splitGroups;\n // Re-apply scroll-driven state (transfer + translateX) to the fresh DOM elements\n this.#updateSplitGroupScroll();\n });\n }\n\n /**\n * Apply sticky positioning and group-end adjustments on cells rendered during scroll.\n * When virtualization recycles row pool elements, newly rendered cells lack the\n * inline sticky styles applied by `applyStickyOffsets` in `afterRender`. This hook\n * ensures every cell gets correct sticky positioning using the cached offset maps.\n * @internal\n */\n override afterCellRender(context: AfterCellRenderContext): void {\n if (!this.isApplied) return;\n const field = context.column.field;\n const cellEl = context.cellElement;\n\n // Apply sticky positioning from cached offset maps\n const leftOffset = this.leftOffsets.get(field);\n if (leftOffset !== undefined) {\n if (!cellEl.classList.contains(GridClasses.STICKY_LEFT)) {\n cellEl.classList.add(GridClasses.STICKY_LEFT);\n }\n cellEl.style.position = 'sticky';\n cellEl.style.left = leftOffset + 'px';\n } else {\n const rightOffset = this.rightOffsets.get(field);\n if (rightOffset !== undefined) {\n if (!cellEl.classList.contains(GridClasses.STICKY_RIGHT)) {\n cellEl.classList.add(GridClasses.STICKY_RIGHT);\n }\n cellEl.style.position = 'sticky';\n cellEl.style.right = rightOffset + 'px';\n }\n }\n\n // Maintain group-end adjustments at pin boundaries\n if (this.#groupEndAdjustments.addGroupEnd.has(field)) {\n context.cellElement.classList.add('group-end');\n } else if (this.#groupEndAdjustments.removeGroupEnd.has(field)) {\n context.cellElement.classList.remove('group-end');\n }\n }\n\n /**\n * Handle horizontal scroll to manage floating group labels.\n *\n * When an explicit column group has a mix of pinned and non-pinned columns,\n * the label starts in the scrollable fragment and floats toward the pinned\n * column via CSS `position: sticky`. Once the scrollable fragment scrolls\n * far enough that the label would be clipped, this hook transfers the label\n * into the sticky pinned fragment and applies `.group-end` to the pinned\n * column cells, creating a visual separator. Scrolling back reverses the\n * transfer.\n * @internal\n */\n override onScroll(_event: ScrollEvent): void {\n this.#updateSplitGroupScroll();\n }\n\n /**\n * Apply scroll-driven state to split group headers.\n *\n * Handles both the manual translateX positioning (simulating sticky) and the\n * transfer of the label into/out of the pinned fragment with `.group-end`.\n * Called from `onScroll` on every scroll event and from `afterRender` after\n * the split group DOM is rebuilt (e.g. after selection click triggers re-render).\n */\n #updateSplitGroupScroll(): void {\n if (!this.isApplied || this.#splitGroups.length === 0) return;\n\n const host = this.gridElement;\n\n for (const sg of this.#splitGroups) {\n const pinnedRect = sg.pinnedFragment.getBoundingClientRect();\n const scrollableRect = sg.scrollableFragment.getBoundingClientRect();\n\n // Transfer when the non-pinned fragment's right edge reaches the pinned\n // fragment's right edge — all non-pinned columns scrolled behind the pin.\n const shouldTransfer = scrollableRect.right <= pinnedRect.right;\n\n if (shouldTransfer && !sg.isTransferred) {\n // Move label into the pinned fragment\n sg.pinnedFragment.textContent = sg.label;\n sg.pinnedFragment.style.overflow = 'hidden';\n sg.pinnedFragment.style.textOverflow = 'ellipsis';\n sg.pinnedFragment.style.whiteSpace = 'nowrap';\n sg.pinnedFragment.style.borderRightStyle = '';\n sg.floatLabel.style.visibility = 'hidden';\n sg.floatLabel.style.transform = '';\n sg.floatOffset = 0;\n\n // Add group-end to pinned column header + body cells\n this.#groupEndAdjustments.addGroupEnd.add(sg.pinnedField);\n host\n .querySelectorAll(\n `.header-row .cell[data-field=\"${sg.pinnedField}\"], .data-grid-row .cell[data-field=\"${sg.pinnedField}\"]`,\n )\n .forEach((el) => el.classList.add('group-end'));\n\n sg.isTransferred = true;\n } else if (!shouldTransfer && sg.isTransferred) {\n // Reverse transfer — label goes back to the floating span\n sg.pinnedFragment.textContent = '';\n sg.pinnedFragment.style.overflow = '';\n sg.pinnedFragment.style.textOverflow = '';\n sg.pinnedFragment.style.whiteSpace = '';\n sg.pinnedFragment.style.borderRightStyle = 'none';\n sg.floatLabel.style.visibility = '';\n sg.floatLabel.style.transform = '';\n sg.floatOffset = 0;\n\n // Remove group-end from pinned column cells\n this.#groupEndAdjustments.addGroupEnd.delete(sg.pinnedField);\n host\n .querySelectorAll(\n `.header-row .cell[data-field=\"${sg.pinnedField}\"], .data-grid-row .cell[data-field=\"${sg.pinnedField}\"]`,\n )\n .forEach((el) => el.classList.remove('group-end'));\n\n sg.isTransferred = false;\n }\n\n // Manually position the floating label to simulate sticky behavior.\n // CSS sticky can't be used because .header-group-cell has overflow:hidden.\n // We track the current translateX offset to correctly compute the span's\n // natural (un-translated) position from its measured rect.\n if (!sg.isTransferred) {\n const spanRect = sg.floatLabel.getBoundingClientRect();\n const spanNaturalLeft = spanRect.left - sg.floatOffset;\n const targetLeft = pinnedRect.left;\n if (spanNaturalLeft < targetLeft) {\n sg.floatOffset = targetLeft - spanNaturalLeft;\n sg.floatLabel.style.transform = `translateX(${sg.floatOffset}px)`;\n } else {\n sg.floatOffset = 0;\n sg.floatLabel.style.transform = '';\n }\n }\n }\n }\n\n /**\n * Handle inter-plugin queries.\n * @internal\n */\n override handleQuery(query: PluginQuery): unknown {\n switch (query.type) {\n case QUERY_CAN_MOVE_COLUMN: {\n // Prevent pinned columns from being moved/reordered.\n // Pinned columns have fixed positions and should not be draggable.\n const column = query.context as ColumnConfig;\n if (getColumnPinned(column) != null) {\n return false;\n }\n return undefined; // Let other plugins or default behavior decide\n }\n case 'getStickyOffsets': {\n // Return the calculated sticky offsets for column virtualization\n return {\n left: Object.fromEntries(this.leftOffsets),\n right: Object.fromEntries(this.rightOffsets),\n };\n }\n case 'getContextMenuItems': {\n const params = query.context as ContextMenuParams;\n if (!params.isHeader) return undefined;\n\n const column = params.column as ColumnConfig;\n if (!column?.field) return undefined;\n\n // Don't offer pin/unpin for locked-pinning columns\n if (column.meta?.lockPinning) return undefined;\n\n const pinned = getColumnPinned(column);\n const isPinned = pinned != null;\n const items: HeaderContextMenuItem[] = [];\n\n if (isPinned) {\n items.push({\n id: 'pinned/unpin',\n label: 'Unpin Column',\n icon: '📌',\n order: 40,\n action: () => this.setPinPosition(column.field, undefined),\n });\n } else {\n items.push({\n id: 'pinned/pin-left',\n label: 'Pin Left',\n icon: '⬅',\n order: 40,\n action: () => this.setPinPosition(column.field, 'left'),\n });\n items.push({\n id: 'pinned/pin-right',\n label: 'Pin Right',\n icon: '➡',\n order: 41,\n action: () => this.setPinPosition(column.field, 'right'),\n });\n }\n\n return items;\n }\n default:\n return undefined;\n }\n }\n // #endregion\n\n // #region Public API\n\n /**\n * Set the pin position for a column.\n * Updates the column's `pinned` property and triggers a full re-render.\n *\n * @param field - The field name of the column to pin/unpin\n * @param position - The pin position (`'left'`, `'right'`, `'start'`, `'end'`), or `undefined` to unpin\n */\n setPinPosition(field: string, position: PinnedPosition | undefined): void {\n // Read the currently-visible columns from the plugin accessor.\n // These are the post-processColumns result, which is the authoritative column set.\n const currentColumns = this.columns;\n if (!currentColumns?.length) return;\n\n const currentIndex = currentColumns.findIndex((col) => col.field === field);\n if (currentIndex === -1) return;\n\n const gridEl = this.gridElement as HTMLElement & { columns?: ColumnConfig[] };\n\n if (position) {\n // PINNING: snapshot original column order if this is the first context-menu pin.\n // The snapshot lets us restore columns to their original positions on unpin.\n if (this.#originalColumnOrder.length === 0) {\n this.#originalColumnOrder = currentColumns.map((c) => c.field);\n }\n\n // Set the pinned property; processColumns will reorder on next render\n const updated = currentColumns.map((col) => {\n if (col.field !== field) return col;\n const copy = { ...col };\n (copy as ColumnConfig & { pinned?: PinnedPosition }).pinned = position;\n return copy;\n });\n\n gridEl.columns = updated;\n } else {\n // UNPINNING: restore column to its original position\n const col = currentColumns[currentIndex];\n const copy = { ...col };\n delete (copy as ColumnConfig & { pinned?: PinnedPosition }).pinned;\n\n // Remove from current position\n const remaining = [...currentColumns];\n remaining.splice(currentIndex, 1);\n\n // Find the best insertion point using the original order snapshot\n const originalIndex = this.#originalColumnOrder.indexOf(field);\n if (originalIndex >= 0) {\n // Scan remaining non-pinned columns and find the first whose original\n // position is greater than this column's original position.\n let insertIndex = remaining.length;\n for (let i = 0; i < remaining.length; i++) {\n if (getColumnPinned(remaining[i])) continue; // skip pinned columns\n const otherOriginal = this.#originalColumnOrder.indexOf(remaining[i].field);\n if (otherOriginal > originalIndex) {\n insertIndex = i;\n break;\n }\n }\n remaining.splice(insertIndex, 0, copy);\n } else {\n // Original position unknown — keep at current index\n remaining.splice(Math.min(currentIndex, remaining.length), 0, copy);\n }\n\n // If no more pinned columns remain, clear the snapshot\n if (!remaining.some((c) => getColumnPinned(c) != null)) {\n this.#originalColumnOrder = [];\n }\n\n gridEl.columns = remaining;\n }\n }\n\n /**\n * Re-apply sticky offsets (e.g., after column resize).\n */\n refreshStickyOffsets(): void {\n const columns = [...this.columns];\n const result = applyStickyOffsets(this.gridElement, columns);\n this.#groupEndAdjustments = result.groupEndAdjustments;\n this.leftOffsets = result.leftOffsets;\n this.rightOffsets = result.rightOffsets;\n this.#splitGroups = result.splitGroups;\n }\n\n /**\n * Get columns pinned to the left (after resolving logical positions for current direction).\n */\n getLeftPinnedColumns(): ColumnConfig[] {\n const columns = [...this.columns];\n const direction = getDirection(this.gridElement);\n return getLeftStickyColumns(columns, direction);\n }\n\n /**\n * Get columns pinned to the right (after resolving logical positions for current direction).\n */\n getRightPinnedColumns(): ColumnConfig[] {\n const columns = [...this.columns];\n const direction = getDirection(this.gridElement);\n return getRightStickyColumns(columns, direction);\n }\n\n /**\n * Clear all sticky positioning.\n */\n clearStickyPositions(): void {\n clearStickyOffsets(this.gridElement);\n }\n\n /**\n * Report horizontal scroll boundary offsets for pinned columns.\n * Used by keyboard navigation to ensure focused cells aren't hidden behind sticky columns.\n * @internal\n */\n override getHorizontalScrollOffsets(\n rowEl?: HTMLElement,\n focusedCell?: HTMLElement,\n ): { left: number; right: number; skipScroll?: boolean } | undefined {\n if (!this.isApplied) {\n return undefined;\n }\n\n let left = 0;\n let right = 0;\n\n if (rowEl) {\n // Calculate from rendered cells in the row\n const stickyLeftCells = rowEl.querySelectorAll(`.${GridClasses.STICKY_LEFT}`);\n const stickyRightCells = rowEl.querySelectorAll(`.${GridClasses.STICKY_RIGHT}`);\n stickyLeftCells.forEach((el) => {\n left += (el as HTMLElement).offsetWidth;\n });\n stickyRightCells.forEach((el) => {\n right += (el as HTMLElement).offsetWidth;\n });\n } else {\n // Fall back to header row if no row element provided\n const host = this.gridElement;\n const headerCells = host.querySelectorAll('.header-row .cell');\n headerCells.forEach((cell) => {\n if (cell.classList.contains(GridClasses.STICKY_LEFT)) {\n left += (cell as HTMLElement).offsetWidth;\n } else if (cell.classList.contains(GridClasses.STICKY_RIGHT)) {\n right += (cell as HTMLElement).offsetWidth;\n }\n });\n }\n\n // Skip horizontal scrolling if focused cell is pinned (it's always visible)\n const skipScroll =\n focusedCell?.classList.contains(GridClasses.STICKY_LEFT) ||\n focusedCell?.classList.contains(GridClasses.STICKY_RIGHT);\n\n return { left, right, skipScroll };\n }\n // #endregion\n}\n"],"names":["getColumnPinned","col","pinned","meta","resolveStickyPosition","position","direction","resolveInlinePosition","isResolvedLeft","isResolvedRight","hasStickyColumns","columns","i","length","applyStickyOffsets","host","emptyResult","groupEndAdjustments","addGroupEnd","Set","removeGroupEnd","leftOffsets","Map","rightOffsets","splitGroups","headerCells","Array","from","querySelectorAll","getDirection","left","cell","find","c","getAttribute","field","set","classList","add","GridClasses","STICKY_LEFT","style","forEach","el","offsetWidth","right","reverse","STICKY_RIGHT","adjustments","groupCells","groupCell","gridCol","gridColumn","match","startIdx","parseInt","endIdx","spannedColumns","slice","allLeft","every","allRight","firstField","firstCell","lastField","lastCell","contains","splitMixedPinImplicitGroup","someLeft","some","someRight","splitMixedPinExplicitGroup","applyGroupHeaderStickyOffsets","size","hCell","remove","getPinState","runs","state","prev","cols","push","colStart","parent","parentElement","nextSibling","removeChild","run","document","createElement","className","setAttribute","String","startsWith","borderRightStyle","insertBefore","appendChild","ri","nextRun","lastPinnedField","_adjustments","label","textContent","groupId","firstLeftRunIdx","findIndex","r","lastRightRunIdx","pinnedRunIdx","floatRunIdx","pinnedFragment","scrollableFragment","floatLabel","pinnedField","borderLeftStyle","overflow","span","zIndex","display","textOverflow","whiteSpace","isTransferred","floatOffset","clearStickyOffsets","QUERY_CAN_MOVE_COLUMN","PinnedColumnsPlugin","BaseGridPlugin","static","hookPriority","processColumns","ownedProperties","property","level","description","isUsed","v","queries","type","name","defaultConfig","isApplied","originalColumnOrder","detach","this","clear","detect","rows","config","isArray","gridElement","middle","reorderColumnsForPinning","afterRender","queueMicrotask","result","updateSplitGroupScroll","afterCellRender","context","column","cellEl","cellElement","leftOffset","get","rightOffset","has","onScroll","_event","sg","pinnedRect","getBoundingClientRect","shouldTransfer","visibility","transform","delete","spanNaturalLeft","targetLeft","handleQuery","query","Object","fromEntries","params","isHeader","lockPinning","items","id","icon","order","action","setPinPosition","currentColumns","currentIndex","gridEl","map","updated","copy","remaining","splice","originalIndex","indexOf","insertIndex","Math","min","refreshStickyOffsets","getLeftPinnedColumns","filter","getLeftStickyColumns","getRightPinnedColumns","getRightStickyColumns","clearStickyPositions","getHorizontalScrollOffsets","rowEl","focusedCell","stickyLeftCells","stickyRightCells","skipScroll"],"mapp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,EAEZ,GAAIqK,EAAO,CAET,MAAME,EAAkBF,EAAMtL,iBAAiB,IAAIW,EAAAA,YAAYC,eACzD6K,EAAmBH,EAAMtL,iBAAiB,IAAIW,EAAAA,YAAYQ,gBAChEqK,EAAgB1K,QAASC,IACvBb,GAASa,EAAmBC,cAE9ByK,EAAiB3K,QAASC,IACxBE,GAAUF,EAAmBC,aAEjC,KAAO,CAEQmG,KAAKM,YACOzH,iBAAiB,qBAC9Bc,QAASX,IACfA,EAAKM,UAAU6B,SAAS3B,EAAAA,YAAYC,aACtCV,GAASC,EAAqBa,YACrBb,EAAKM,UAAU6B,SAAS3B,EAAAA,YAAYQ,gBAC7CF,GAAUd,EAAqBa,cAGrC,CAGA,MAAM0K,EACJH,GAAa9K,UAAU6B,SAAS3B,EAAAA,YAAYC,cAC5C2K,GAAa9K,UAAU6B,SAAS3B,EAAAA,YAAYQ,cAE9C,MAAO,CAAEjB,OAAMe,QAAOyK,aACxB"}
|
|
1
|
+
{"version":3,"file":"pinned-columns.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/pinned-columns/pinned-columns.ts","../../../../../libs/grid/src/lib/plugins/pinned-columns/PinnedColumnsPlugin.ts"],"sourcesContent":["/**\n * Pinned Columns Core Logic\n *\n * Pure functions for applying pinned (sticky) column positioning.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { GridClasses } from '../../core/constants';\nimport { getDirection, resolveInlinePosition, type TextDirection } from '../../core/internal/utils';\nimport type { PinnedPosition, ResolvedPinnedPosition } from './types';\n\n/**\n * Get the effective pinned position from a column.\n *\n * @param col - Column configuration object\n * @returns The pinned position, or undefined if not pinned\n */\nexport function getColumnPinned(col: any): PinnedPosition | undefined {\n return col.pinned ?? col.meta?.pinned;\n}\n\n/**\n * Resolve a pinned position to a physical position based on text direction.\n *\n * - `'left'` / `'right'` → unchanged (physical values)\n * - `'start'` → `'left'` in LTR, `'right'` in RTL\n * - `'end'` → `'right'` in LTR, `'left'` in RTL\n *\n * @param position - The pinned position (logical or physical)\n * @param direction - Text direction ('ltr' or 'rtl')\n * @returns Physical pinned position ('left' or 'right')\n */\nexport function resolveStickyPosition(position: PinnedPosition, direction: TextDirection): ResolvedPinnedPosition {\n return resolveInlinePosition(position, direction);\n}\n\n/**\n * Check if a column is pinned on the left (after resolving logical positions).\n */\nfunction isResolvedLeft(col: any, direction: TextDirection): boolean {\n const pinned = getColumnPinned(col);\n if (!pinned) return false;\n return resolveStickyPosition(pinned, direction) === 'left';\n}\n\n/**\n * Check if a column is pinned on the right (after resolving logical positions).\n */\nfunction isResolvedRight(col: any, direction: TextDirection): boolean {\n const pinned = getColumnPinned(col);\n if (!pinned) return false;\n return resolveStickyPosition(pinned, direction) === 'right';\n}\n\n/**\n * Get columns that should be sticky on the left.\n *\n * @param columns - Array of column configurations\n * @param direction - Text direction (default: 'ltr')\n * @returns Array of columns with sticky='left' or sticky='start' (in LTR)\n */\nexport function getLeftStickyColumns(columns: any[], direction: TextDirection = 'ltr'): any[] {\n return columns.filter((col) => isResolvedLeft(col, direction));\n}\n\n/**\n * Get columns that should be sticky on the right.\n *\n * @param columns - Array of column configurations\n * @param direction - Text direction (default: 'ltr')\n * @returns Array of columns with sticky='right' or sticky='end' (in LTR)\n */\nexport function getRightStickyColumns(columns: any[], direction: TextDirection = 'ltr'): any[] {\n return columns.filter((col) => isResolvedRight(col, direction));\n}\n\n/**\n * Check if any columns have sticky positioning.\n *\n * @param columns - Array of column configurations\n * @returns True if any column has sticky position\n */\nexport function hasStickyColumns(columns: any[]): boolean {\n for (let i = 0; i < columns.length; i++) {\n if (columns[i].pinned != null || columns[i].meta?.pinned != null) return true;\n }\n return false;\n}\n\n/**\n * Get the sticky position of a column.\n *\n * @param column - Column configuration\n * @returns The sticky position or null if not sticky\n */\nexport function getColumnStickyPosition(column: any): PinnedPosition | null {\n return getColumnPinned(column) ?? null;\n}\n\n/**\n * Calculate left offsets for sticky-left columns.\n * Returns a map of field -> offset in pixels.\n *\n * @param columns - Array of column configurations (in order)\n * @param getColumnWidth - Function to get column width by field\n * @param direction - Text direction (default: 'ltr')\n * @returns Map of field to left offset\n */\nexport function calculateLeftStickyOffsets(\n columns: any[],\n getColumnWidth: (field: string) => number,\n direction: TextDirection = 'ltr',\n): Map<string, number> {\n const offsets = new Map<string, number>();\n let currentOffset = 0;\n\n for (const col of columns) {\n if (isResolvedLeft(col, direction)) {\n offsets.set(col.field, currentOffset);\n currentOffset += getColumnWidth(col.field);\n }\n }\n\n return offsets;\n}\n\n/**\n * Calculate right offsets for sticky-right columns.\n * Processes columns in reverse order.\n *\n * @param columns - Array of column configurations (in order)\n * @param getColumnWidth - Function to get column width by field\n * @param direction - Text direction (default: 'ltr')\n * @returns Map of field to right offset\n */\nexport function calculateRightStickyOffsets(\n columns: any[],\n getColumnWidth: (field: string) => number,\n direction: TextDirection = 'ltr',\n): Map<string, number> {\n const offsets = new Map<string, number>();\n let currentOffset = 0;\n\n // Process in reverse for right-sticky columns\n const reversed = [...columns].reverse();\n for (const col of reversed) {\n if (isResolvedRight(col, direction)) {\n offsets.set(col.field, currentOffset);\n currentOffset += getColumnWidth(col.field);\n }\n }\n\n return offsets;\n}\n\n/**\n * Adjustments to `group-end` borders at pin boundaries within implicit groups.\n * - `addGroupEnd`: fields that should gain `group-end` (last pinned column at boundary)\n * - `removeGroupEnd`: fields that should lose `group-end` (lone non-pinned remnant)\n */\nexport interface GroupEndAdjustments {\n addGroupEnd: Set<string>;\n removeGroupEnd: Set<string>;\n}\n\n/**\n * Result of applying sticky offsets — includes both the group-end adjustments\n * and the measured left/right offset maps for use in per-cell rendering hooks.\n */\nexport interface StickyOffsetsResult {\n groupEndAdjustments: GroupEndAdjustments;\n leftOffsets: Map<string, number>;\n rightOffsets: Map<string, number>;\n splitGroups: SplitGroupState[];\n}\n\n/**\n * State for an explicit group header that was split at a pin boundary.\n *\n * The pinned fragment is sticky and initially empty. The non-pinned fragment\n * holds the label in a CSS-sticky span that floats toward the pinned area on\n * horizontal scroll. When the non-pinned fragment scrolls far enough, the\n * plugin's `onScroll` handler transfers the label into the pinned fragment.\n */\nexport interface SplitGroupState {\n /** Group identifier (data-group attribute value). */\n groupId: string;\n /** Original group label text. */\n label: string;\n /** The sticky (pinned) fragment element. */\n pinnedFragment: HTMLElement;\n /** The scrollable (non-pinned) fragment element. */\n scrollableFragment: HTMLElement;\n /** The floating <span> inside the scrollable fragment. */\n floatLabel: HTMLElement;\n /** Field of the last pinned column — used to toggle `.group-end`. */\n pinnedField: string;\n /** Whether the label is currently shown inside the pinned fragment. */\n isTransferred: boolean;\n /** Current translateX offset applied to the floating label (px). */\n floatOffset: number;\n}\n\n/**\n * Apply sticky offsets to header and body cells.\n * This modifies the DOM elements in place.\n *\n * @param host - The grid host element (render root for DOM queries)\n * @param columns - Array of column configurations\n * @returns Sticky offsets result with group-end adjustments and measured offset maps\n */\nexport function applyStickyOffsets(host: HTMLElement, columns: any[]): StickyOffsetsResult {\n const emptyResult: StickyOffsetsResult = {\n groupEndAdjustments: { addGroupEnd: new Set(), removeGroupEnd: new Set() },\n leftOffsets: new Map(),\n rightOffsets: new Map(),\n splitGroups: [],\n };\n\n // With light DOM, query the host element directly\n const headerCells = Array.from(host.querySelectorAll('.header-row .cell')) as HTMLElement[];\n if (!headerCells.length) return emptyResult;\n\n // Detect text direction from the host element\n const direction = getDirection(host);\n\n // Collect measured offsets for caching in the plugin\n const leftOffsets = new Map<string, number>();\n const rightOffsets = new Map<string, number>();\n\n // Apply left sticky (includes 'start' in LTR, 'end' in RTL)\n let left = 0;\n for (const col of columns) {\n if (isResolvedLeft(col, direction)) {\n const cell = headerCells.find((c) => c.getAttribute('data-field') === col.field);\n if (cell) {\n leftOffsets.set(col.field, left);\n cell.classList.add(GridClasses.STICKY_LEFT);\n cell.style.position = 'sticky';\n cell.style.left = left + 'px';\n // Body cells: use data-field for reliable matching (data-col indices may differ\n // between _columns and _visibleColumns due to hidden/utility columns)\n host.querySelectorAll(`.data-grid-row .cell[data-field=\"${col.field}\"]`).forEach((el) => {\n el.classList.add(GridClasses.STICKY_LEFT);\n (el as HTMLElement).style.position = 'sticky';\n (el as HTMLElement).style.left = left + 'px';\n });\n left += cell.offsetWidth;\n }\n }\n }\n\n // Apply right sticky (includes 'end' in LTR, 'start' in RTL) - process in reverse\n let right = 0;\n for (const col of [...columns].reverse()) {\n if (isResolvedRight(col, direction)) {\n const cell = headerCells.find((c) => c.getAttribute('data-field') === col.field);\n if (cell) {\n rightOffsets.set(col.field, right);\n cell.classList.add(GridClasses.STICKY_RIGHT);\n cell.style.position = 'sticky';\n cell.style.right = right + 'px';\n // Body cells: use data-field for reliable matching\n host.querySelectorAll(`.data-grid-row .cell[data-field=\"${col.field}\"]`).forEach((el) => {\n el.classList.add(GridClasses.STICKY_RIGHT);\n (el as HTMLElement).style.position = 'sticky';\n (el as HTMLElement).style.right = right + 'px';\n });\n right += cell.offsetWidth;\n }\n }\n }\n\n // Apply sticky offsets to column group header cells and collect group-end adjustments\n const splitGroups: SplitGroupState[] = [];\n const adjustments = applyGroupHeaderStickyOffsets(host, columns, headerCells, direction, splitGroups);\n\n // Apply group-end adjustments to header cells and visible body cells\n if (adjustments.addGroupEnd.size > 0 || adjustments.removeGroupEnd.size > 0) {\n for (const field of adjustments.addGroupEnd) {\n const hCell = headerCells.find((c) => c.getAttribute('data-field') === field);\n if (hCell) hCell.classList.add('group-end');\n host.querySelectorAll(`.data-grid-row .cell[data-field=\"${field}\"]`).forEach((el) => {\n el.classList.add('group-end');\n });\n }\n for (const field of adjustments.removeGroupEnd) {\n const hCell = headerCells.find((c) => c.getAttribute('data-field') === field);\n if (hCell) hCell.classList.remove('group-end');\n host.querySelectorAll(`.data-grid-row .cell[data-field=\"${field}\"]`).forEach((el) => {\n el.classList.remove('group-end');\n });\n }\n }\n\n return { groupEndAdjustments: adjustments, leftOffsets, rightOffsets, splitGroups };\n}\n\n/**\n * Apply sticky offsets to column group header cells.\n * - If ALL columns in a group are pinned the same direction, the whole cell is pinned.\n * - If an implicit (unlabelled) group mixes pinned and non-pinned columns,\n * the cell is split at pin boundaries so pinned portions can be sticky.\n *\n * @param host - The grid host element\n * @param columns - Array of column configurations\n * @param headerCells - Already-queried header cells (with sticky offsets applied)\n * @param direction - Text direction\n * @returns Group-end adjustments for pin boundaries within implicit groups\n */\nfunction applyGroupHeaderStickyOffsets(\n host: HTMLElement,\n columns: any[],\n headerCells: HTMLElement[],\n direction: TextDirection,\n splitGroups: SplitGroupState[],\n): GroupEndAdjustments {\n const adjustments: GroupEndAdjustments = { addGroupEnd: new Set(), removeGroupEnd: new Set() };\n const groupCells = Array.from(host.querySelectorAll('.header-group-row .header-group-cell')) as HTMLElement[];\n if (!groupCells.length) return adjustments;\n\n for (const groupCell of groupCells) {\n // Parse gridColumn to find which column range this group spans\n // Format: \"startCol / span N\" (1-based)\n const gridCol = groupCell.style.gridColumn;\n if (!gridCol) continue;\n\n const match = gridCol.match(/^(\\d+)\\s*\\/\\s*span\\s+(\\d+)$/);\n if (!match) continue;\n\n const startIdx = parseInt(match[1], 10) - 1; // Convert to 0-based\n const span = parseInt(match[2], 10);\n const endIdx = startIdx + span - 1;\n\n // Get the columns this group spans\n const spannedColumns = columns.slice(startIdx, endIdx + 1);\n if (!spannedColumns.length) continue;\n\n const allLeft = spannedColumns.every((col: any) => isResolvedLeft(col, direction));\n const allRight = spannedColumns.every((col: any) => isResolvedRight(col, direction));\n\n if (allLeft) {\n const firstField = spannedColumns[0].field;\n const firstCell = headerCells.find((c) => c.getAttribute('data-field') === firstField);\n if (firstCell) {\n groupCell.classList.add(GridClasses.STICKY_LEFT);\n groupCell.style.position = 'sticky';\n groupCell.style.left = firstCell.style.left;\n }\n } else if (allRight) {\n const lastField = spannedColumns[spannedColumns.length - 1].field;\n const lastCell = headerCells.find((c) => c.getAttribute('data-field') === lastField);\n if (lastCell) {\n groupCell.classList.add(GridClasses.STICKY_RIGHT);\n groupCell.style.position = 'sticky';\n groupCell.style.right = lastCell.style.right;\n }\n } else if (groupCell.classList.contains('implicit-group')) {\n // Implicit group with mixed pinning: split into separate cells so pinned\n // portions become sticky while non-pinned portions scroll normally.\n splitMixedPinImplicitGroup(groupCell, spannedColumns, startIdx, headerCells, direction, adjustments);\n } else {\n // Explicit (labelled) group with mixed pinning: split the group header so\n // the pinned fragment keeps the label and sticks, while the non-pinned\n // remainder scrolls away. This makes the group header visually shrink to\n // the pinned column width when scrolled horizontally.\n const someLeft = spannedColumns.some((col: any) => isResolvedLeft(col, direction));\n const someRight = spannedColumns.some((col: any) => isResolvedRight(col, direction));\n if (someLeft || someRight) {\n splitMixedPinExplicitGroup(\n groupCell,\n spannedColumns,\n startIdx,\n headerCells,\n direction,\n adjustments,\n splitGroups,\n );\n }\n }\n }\n\n return adjustments;\n}\n\n/** Classify a column's pin state after resolving logical positions. */\ntype PinState = 'left' | 'right' | 'none';\n\nfunction getPinState(col: any, direction: TextDirection): PinState {\n if (isResolvedLeft(col, direction)) return 'left';\n if (isResolvedRight(col, direction)) return 'right';\n return 'none';\n}\n\n/**\n * Split an implicit (unlabelled) group header cell into fragments at pin-state\n * boundaries. Each fragment becomes its own header-group-cell; pinned fragments\n * get sticky positioning.\n *\n * Also populates `adjustments` with group-end border changes:\n * - Last column of a left-pinned run gets `group-end` (visual separator at pin edge)\n * - Last column of a subsequent non-pinned run that contains only utility columns\n * loses `group-end` (it visually merges with the adjacent explicit group)\n */\nfunction splitMixedPinImplicitGroup(\n groupCell: HTMLElement,\n spannedColumns: any[],\n startIdx: number,\n headerCells: HTMLElement[],\n direction: TextDirection,\n adjustments: GroupEndAdjustments,\n): void {\n // Partition columns into contiguous runs of the same pin state\n const runs: { state: PinState; cols: any[]; colStart: number }[] = [];\n for (let i = 0; i < spannedColumns.length; i++) {\n const state = getPinState(spannedColumns[i], direction);\n const prev = runs[runs.length - 1];\n if (prev && prev.state === state) {\n prev.cols.push(spannedColumns[i]);\n } else {\n runs.push({ state, cols: [spannedColumns[i]], colStart: startIdx + i });\n }\n }\n\n if (runs.length <= 1) return; // Nothing to split\n\n const parent = groupCell.parentElement;\n if (!parent) return;\n\n const nextSibling = groupCell.nextSibling;\n parent.removeChild(groupCell);\n\n for (const run of runs) {\n const cell = document.createElement('div');\n cell.className = groupCell.className; // Preserves implicit-group, cell, header-group-cell\n cell.setAttribute('data-group', groupCell.getAttribute('data-group') || '');\n cell.style.gridColumn = `${run.colStart + 1} / span ${run.cols.length}`;\n\n if (run.state === 'left') {\n const firstField = run.cols[0].field;\n const firstCell = headerCells.find((c) => c.getAttribute('data-field') === firstField);\n if (firstCell) {\n cell.classList.add(GridClasses.STICKY_LEFT);\n cell.style.position = 'sticky';\n cell.style.left = firstCell.style.left;\n }\n } else if (run.state === 'right') {\n const lastField = run.cols[run.cols.length - 1].field;\n const lastCell = headerCells.find((c) => c.getAttribute('data-field') === lastField);\n if (lastCell) {\n cell.classList.add(GridClasses.STICKY_RIGHT);\n cell.style.position = 'sticky';\n cell.style.right = lastCell.style.right;\n }\n } else if (run.state === 'none') {\n // Suppress border on utility-only non-pinned remnants — they visually merge\n // with the adjacent explicit group.\n const allUtility = run.cols.every((c: any) => String(c.field || '').startsWith('__tbw_'));\n if (allUtility) {\n cell.style.borderRightStyle = 'none';\n }\n }\n\n if (nextSibling) {\n parent.insertBefore(cell, nextSibling);\n } else {\n parent.appendChild(cell);\n }\n }\n\n // Compute group-end adjustments at pin boundaries.\n // When a pinned run is followed by a non-pinned run, the last column of the\n // pinned run should be the visual group boundary (group-end).\n // The non-pinned remnant's last column should lose group-end if all its\n // columns are utility columns (e.g. __tbw_expander) — they visually merge\n // with the adjacent explicit group.\n for (let ri = 0; ri < runs.length; ri++) {\n const run = runs[ri];\n const nextRun = runs[ri + 1];\n\n if (run.state !== 'none' && nextRun && nextRun.state === 'none') {\n // Last column of pinned run gets group-end\n const lastPinnedField = run.cols[run.cols.length - 1].field;\n if (lastPinnedField) adjustments.addGroupEnd.add(lastPinnedField);\n }\n\n if (run.state === 'none') {\n // Check if all columns in this non-pinned run are utility columns\n const allUtility = run.cols.every((c: any) => String(c.field || '').startsWith('__tbw_'));\n if (allUtility) {\n // Remove group-end from the last column — it visually merges with the next group\n const lastField = run.cols[run.cols.length - 1].field;\n if (lastField) adjustments.removeGroupEnd.add(lastField);\n }\n }\n }\n}\n\n/**\n * Split an explicit (labelled) group header cell at pin boundaries.\n *\n * **Pinned fragment:** sticky, initially empty (no label, no `.group-end`).\n * **Non-pinned fragment:** carries the label inside a CSS-sticky elevated `<span>`.\n * The span floats left over the pinned fragment as the user scrolls horizontally.\n *\n * When the non-pinned fragment's left edge reaches the pinned fragment's right\n * edge (i.e. only the pinned column width remains), the plugin's `onScroll` hook\n * transfers the label into the pinned fragment and adds `.group-end`.\n */\nfunction splitMixedPinExplicitGroup(\n groupCell: HTMLElement,\n spannedColumns: any[],\n startIdx: number,\n headerCells: HTMLElement[],\n direction: TextDirection,\n _adjustments: GroupEndAdjustments,\n splitGroups: SplitGroupState[],\n): void {\n // Partition columns into contiguous runs of the same pin state\n const runs: { state: PinState; cols: any[]; colStart: number }[] = [];\n for (let i = 0; i < spannedColumns.length; i++) {\n const state = getPinState(spannedColumns[i], direction);\n const prev = runs[runs.length - 1];\n if (prev && prev.state === state) {\n prev.cols.push(spannedColumns[i]);\n } else {\n runs.push({ state, cols: [spannedColumns[i]], colStart: startIdx + i });\n }\n }\n\n if (runs.length <= 1) return; // Nothing to split\n\n const parent = groupCell.parentElement;\n if (!parent) return;\n\n const label = groupCell.textContent || '';\n const groupId = groupCell.getAttribute('data-group') || '';\n const nextSibling = groupCell.nextSibling;\n parent.removeChild(groupCell);\n\n // Identify the pinned run and the adjacent non-pinned run.\n const firstLeftRunIdx = runs.findIndex((r) => r.state === 'left');\n let lastRightRunIdx = -1;\n for (let i = runs.length - 1; i >= 0; i--) {\n if (runs[i].state === 'right') {\n lastRightRunIdx = i;\n break;\n }\n }\n const pinnedRunIdx = firstLeftRunIdx >= 0 ? firstLeftRunIdx : lastRightRunIdx;\n const floatRunIdx =\n firstLeftRunIdx >= 0 && firstLeftRunIdx + 1 < runs.length\n ? firstLeftRunIdx + 1\n : lastRightRunIdx >= 0 && lastRightRunIdx - 1 >= 0\n ? lastRightRunIdx - 1\n : -1;\n\n let pinnedStickyOffset = '0px';\n let pinnedFragment: HTMLElement | undefined;\n let scrollableFragment: HTMLElement | undefined;\n let floatLabel: HTMLElement | undefined;\n let pinnedField = '';\n\n for (let ri = 0; ri < runs.length; ri++) {\n const run = runs[ri];\n const cell = document.createElement('div');\n cell.className = groupCell.className;\n cell.setAttribute('data-group', groupId);\n cell.style.gridColumn = `${run.colStart + 1} / span ${run.cols.length}`;\n\n if (run.state === 'left') {\n const firstField = run.cols[0].field;\n const firstCell = headerCells.find((c) => c.getAttribute('data-field') === firstField);\n if (firstCell) {\n cell.classList.add(GridClasses.STICKY_LEFT);\n cell.style.position = 'sticky';\n cell.style.left = firstCell.style.left;\n pinnedStickyOffset = firstCell.style.left;\n }\n\n if (ri === pinnedRunIdx) {\n // Pinned fragment: empty, no group-end, hide border so it merges visually\n cell.style.borderRightStyle = 'none';\n pinnedFragment = cell;\n pinnedField = run.cols[run.cols.length - 1].field;\n }\n } else if (run.state === 'right') {\n const lastField = run.cols[run.cols.length - 1].field;\n const lastCell = headerCells.find((c) => c.getAttribute('data-field') === lastField);\n if (lastCell) {\n cell.classList.add(GridClasses.STICKY_RIGHT);\n cell.style.position = 'sticky';\n cell.style.right = lastCell.style.right;\n }\n\n if (ri === pinnedRunIdx) {\n cell.style.borderLeftStyle = 'none';\n pinnedFragment = cell;\n pinnedField = run.cols[0].field;\n }\n }\n\n // The non-pinned run that carries the floating label.\n // CSS sticky won't work here because .header-group-cell has overflow:hidden\n // (set by grouping-columns.css for text clipping). So the plugin's onScroll\n // handler manually translates the span to simulate sticky behavior.\n if (ri === floatRunIdx) {\n // Allow the span to overflow outside the cell when translated left\n cell.style.overflow = 'visible';\n\n const span = document.createElement('span');\n span.textContent = label;\n span.style.position = 'relative';\n span.style.zIndex = '36';\n span.style.display = 'block';\n span.style.overflow = 'hidden';\n span.style.textOverflow = 'ellipsis';\n span.style.whiteSpace = 'nowrap';\n\n cell.appendChild(span);\n scrollableFragment = cell;\n floatLabel = span;\n }\n\n if (nextSibling) {\n parent.insertBefore(cell, nextSibling);\n } else {\n parent.appendChild(cell);\n }\n }\n\n // Register the split group state so the plugin can manage label transfer on scroll.\n if (pinnedFragment && scrollableFragment && floatLabel && pinnedField) {\n splitGroups.push({\n groupId,\n label,\n pinnedFragment,\n scrollableFragment,\n floatLabel,\n pinnedField,\n isTransferred: false,\n floatOffset: 0,\n });\n }\n}\n\n/**\n * Reorder columns so that pinned-left columns come first and pinned-right columns come last.\n * Maintains the relative order within each group (left-pinned, unpinned, right-pinned).\n *\n * @param columns - Array of column configurations (in their current order)\n * @param direction - Text direction ('ltr' or 'rtl'), used to resolve logical positions\n * @returns New array with pinned columns moved to the edges\n */\nexport function reorderColumnsForPinning(columns: readonly any[], direction: TextDirection = 'ltr'): any[] {\n const left: any[] = [];\n const middle: any[] = [];\n const right: any[] = [];\n\n for (const col of columns) {\n const pinned = getColumnPinned(col);\n if (pinned) {\n const resolved = resolveStickyPosition(pinned, direction);\n if (resolved === 'left') left.push(col);\n else right.push(col);\n } else {\n middle.push(col);\n }\n }\n\n return [...left, ...middle, ...right];\n}\n\n/**\n * Clear sticky positioning from all cells.\n *\n * @param host - The grid host element (render root for DOM queries)\n */\nexport function clearStickyOffsets(host: HTMLElement): void {\n // With light DOM, query the host element directly\n const cells = host.querySelectorAll(`.${GridClasses.STICKY_LEFT}, .${GridClasses.STICKY_RIGHT}`);\n cells.forEach((cell) => {\n cell.classList.remove(GridClasses.STICKY_LEFT, GridClasses.STICKY_RIGHT);\n (cell as HTMLElement).style.position = '';\n (cell as HTMLElement).style.left = '';\n (cell as HTMLElement).style.right = '';\n });\n}\n","/**\n * Pinned Columns Plugin (Class-based)\n *\n * Enables column pinning (sticky left/right positioning).\n */\n\nimport { GridClasses } from '../../core/constants';\nimport { getDirection } from '../../core/internal/utils';\nimport type { AfterCellRenderContext, PluginManifest, PluginQuery, ScrollEvent } from '../../core/plugin/base-plugin';\nimport { BaseGridPlugin } from '../../core/plugin/base-plugin';\nimport type { ColumnConfig } from '../../core/types';\nimport type { ContextMenuParams, HeaderContextMenuItem } from '../context-menu/types';\nimport {\n applyStickyOffsets,\n clearStickyOffsets,\n getColumnPinned,\n getLeftStickyColumns,\n getRightStickyColumns,\n hasStickyColumns,\n reorderColumnsForPinning,\n type GroupEndAdjustments,\n type SplitGroupState,\n} from './pinned-columns';\nimport type { PinnedColumnsConfig, PinnedPosition } from './types';\n\n/** Query type constant for checking if a column can be moved */\nconst QUERY_CAN_MOVE_COLUMN = 'canMoveColumn';\n\n/**\n * Pinned Columns Plugin for tbw-grid\n *\n * Freezes columns to the left or right edge of the grid—essential for keeping key\n * identifiers or action buttons visible while scrolling through wide datasets. Just set\n * `pinned: 'left'` or `pinned: 'right'` on your column definitions.\n *\n * ## Installation\n *\n * ```ts\n * import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';\n * ```\n *\n * ## Column Configuration\n *\n * | Property | Type | Description |\n * |----------|------|-------------|\n * | `pinned` | `'left' \\| 'right' \\| 'start' \\| 'end'` | Pin column to edge (logical or physical) |\n * | `lockPinning` | `boolean` | `false` | Prevent user from pin/unpin via context menu (legacy `meta.lockPinning` is honored) |\n *\n * ### RTL Support\n *\n * Use logical values (`start`/`end`) for grids that work in both LTR and RTL layouts:\n * - `'start'` - Pins to left in LTR, right in RTL\n * - `'end'` - Pins to right in LTR, left in RTL\n *\n * ## CSS Custom Properties\n *\n * | Property | Default | Description |\n * |----------|---------|-------------|\n * | `--tbw-pinned-shadow` | `4px 0 8px rgba(0,0,0,0.1)` | Shadow on pinned column edge |\n * | `--tbw-pinned-border` | `var(--tbw-color-border)` | Border between pinned and scrollable |\n *\n * @example Pin ID Left and Actions Right\n * ```ts\n * import { queryGrid } from '@toolbox-web/grid';\n * import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';\n *\n * const grid = queryGrid('tbw-grid');\n * grid.gridConfig = {\n * columns: [\n * { field: 'id', header: 'ID', pinned: 'left', width: 80 },\n * { field: 'name', header: 'Name' },\n * { field: 'email', header: 'Email' },\n * { field: 'department', header: 'Department' },\n * { field: 'actions', header: 'Actions', pinned: 'right', width: 120 },\n * ],\n * plugins: [new PinnedColumnsPlugin()],\n * };\n * ```\n *\n * @example RTL-Compatible Pinning\n * ```ts\n * // Same config works in LTR and RTL\n * grid.gridConfig = {\n * columns: [\n * { field: 'id', header: 'ID', pinned: 'start' }, // Left in LTR, Right in RTL\n * { field: 'name', header: 'Name' },\n * { field: 'actions', header: 'Actions', pinned: 'end' }, // Right in LTR, Left in RTL\n * ],\n * plugins: [new PinnedColumnsPlugin()],\n * };\n * ```\n *\n * @see {@link PinnedColumnsConfig} for configuration options\n *\n * @internal Extends BaseGridPlugin\n */\nexport class PinnedColumnsPlugin extends BaseGridPlugin<PinnedColumnsConfig> {\n /**\n * Plugin manifest - declares owned properties and handled queries.\n * @internal\n */\n static override readonly manifest: PluginManifest = {\n hookPriority: {\n // Reorder columns before other plugins (e.g. TreePlugin) wrap them\n processColumns: -10,\n },\n ownedProperties: [\n {\n property: 'pinned',\n level: 'column',\n description: 'the \"pinned\" column property',\n isUsed: (v) => v === 'left' || v === 'right' || v === 'start' || v === 'end',\n },\n ],\n queries: [\n {\n type: QUERY_CAN_MOVE_COLUMN,\n description: 'Prevents pinned columns from being moved/reordered',\n },\n {\n type: 'getStickyOffsets',\n description: 'Returns the offsets for left/right pinned columns',\n },\n {\n type: 'getContextMenuItems',\n description: 'Contributes pin/unpin items to the header context menu',\n },\n ],\n };\n\n /** @internal */\n readonly name = 'pinnedColumns';\n\n /** @internal */\n protected override get defaultConfig(): Partial<PinnedColumnsConfig> {\n return {};\n }\n\n // #region Internal State\n private isApplied = false;\n private leftOffsets = new Map<string, number>();\n private rightOffsets = new Map<string, number>();\n /** Group-end adjustments for pin boundaries within implicit groups. */\n #groupEndAdjustments: GroupEndAdjustments = { addGroupEnd: new Set(), removeGroupEnd: new Set() };\n /** Split explicit-group state for scroll-driven label transfer. */\n #splitGroups: SplitGroupState[] = [];\n /**\n * Snapshot of the column field order before the first context-menu pin.\n * Used to restore original positions when unpinning.\n */\n #originalColumnOrder: string[] = [];\n // #endregion\n\n // #region Lifecycle\n\n /** @internal */\n override detach(): void {\n this.leftOffsets.clear();\n this.rightOffsets.clear();\n this.isApplied = false;\n this.#groupEndAdjustments = { addGroupEnd: new Set(), removeGroupEnd: new Set() };\n this.#splitGroups = [];\n this.#originalColumnOrder = [];\n }\n // #endregion\n\n // #region Detection\n\n /**\n * Auto-detect sticky columns from column configuration.\n */\n static detect(rows: readonly unknown[], config: { columns?: ColumnConfig[] }): boolean {\n const columns = config?.columns;\n if (!Array.isArray(columns)) return false;\n return hasStickyColumns(columns);\n }\n // #endregion\n\n // #region Hooks\n\n /** @internal */\n override processColumns(columns: readonly ColumnConfig[]): ColumnConfig[] {\n const cols = [...columns];\n this.isApplied = hasStickyColumns(cols);\n if (!this.isApplied) return cols;\n\n const host = this.gridElement;\n const direction = host ? getDirection(host) : 'ltr';\n return reorderColumnsForPinning(cols, direction) as ColumnConfig[];\n }\n\n /** @internal */\n override afterRender(): void {\n if (!this.isApplied) {\n return;\n }\n\n const host = this.gridElement;\n const columns = [...this.columns];\n\n if (!hasStickyColumns(columns)) {\n clearStickyOffsets(host);\n this.isApplied = false;\n return;\n }\n\n // Apply sticky offsets after a microtask to ensure DOM is ready\n queueMicrotask(() => {\n const result = applyStickyOffsets(host, columns);\n this.#groupEndAdjustments = result.groupEndAdjustments;\n this.leftOffsets = result.leftOffsets;\n this.rightOffsets = result.rightOffsets;\n this.#splitGroups = result.splitGroups;\n // Re-apply scroll-driven state (transfer + translateX) to the fresh DOM elements\n this.#updateSplitGroupScroll();\n });\n }\n\n /**\n * Apply sticky positioning and group-end adjustments on cells rendered during scroll.\n * When virtualization recycles row pool elements, newly rendered cells lack the\n * inline sticky styles applied by `applyStickyOffsets` in `afterRender`. This hook\n * ensures every cell gets correct sticky positioning using the cached offset maps.\n * @internal\n */\n override afterCellRender(context: AfterCellRenderContext): void {\n if (!this.isApplied) return;\n const field = context.column.field;\n const cellEl = context.cellElement;\n\n // Apply sticky positioning from cached offset maps\n const leftOffset = this.leftOffsets.get(field);\n if (leftOffset !== undefined) {\n if (!cellEl.classList.contains(GridClasses.STICKY_LEFT)) {\n cellEl.classList.add(GridClasses.STICKY_LEFT);\n }\n cellEl.style.position = 'sticky';\n cellEl.style.left = leftOffset + 'px';\n } else {\n const rightOffset = this.rightOffsets.get(field);\n if (rightOffset !== undefined) {\n if (!cellEl.classList.contains(GridClasses.STICKY_RIGHT)) {\n cellEl.classList.add(GridClasses.STICKY_RIGHT);\n }\n cellEl.style.position = 'sticky';\n cellEl.style.right = rightOffset + 'px';\n }\n }\n\n // Maintain group-end adjustments at pin boundaries\n if (this.#groupEndAdjustments.addGroupEnd.has(field)) {\n context.cellElement.classList.add('group-end');\n } else if (this.#groupEndAdjustments.removeGroupEnd.has(field)) {\n context.cellElement.classList.remove('group-end');\n }\n }\n\n /**\n * Handle horizontal scroll to manage floating group labels.\n *\n * When an explicit column group has a mix of pinned and non-pinned columns,\n * the label starts in the scrollable fragment and floats toward the pinned\n * column via CSS `position: sticky`. Once the scrollable fragment scrolls\n * far enough that the label would be clipped, this hook transfers the label\n * into the sticky pinned fragment and applies `.group-end` to the pinned\n * column cells, creating a visual separator. Scrolling back reverses the\n * transfer.\n * @internal\n */\n override onScroll(_event: ScrollEvent): void {\n this.#updateSplitGroupScroll();\n }\n\n /**\n * Apply scroll-driven state to split group headers.\n *\n * Handles both the manual translateX positioning (simulating sticky) and the\n * transfer of the label into/out of the pinned fragment with `.group-end`.\n * Called from `onScroll` on every scroll event and from `afterRender` after\n * the split group DOM is rebuilt (e.g. after selection click triggers re-render).\n */\n #updateSplitGroupScroll(): void {\n if (!this.isApplied || this.#splitGroups.length === 0) return;\n\n const host = this.gridElement;\n\n for (const sg of this.#splitGroups) {\n const pinnedRect = sg.pinnedFragment.getBoundingClientRect();\n const scrollableRect = sg.scrollableFragment.getBoundingClientRect();\n\n // Transfer when the non-pinned fragment's right edge reaches the pinned\n // fragment's right edge — all non-pinned columns scrolled behind the pin.\n const shouldTransfer = scrollableRect.right <= pinnedRect.right;\n\n if (shouldTransfer && !sg.isTransferred) {\n // Move label into the pinned fragment\n sg.pinnedFragment.textContent = sg.label;\n sg.pinnedFragment.style.overflow = 'hidden';\n sg.pinnedFragment.style.textOverflow = 'ellipsis';\n sg.pinnedFragment.style.whiteSpace = 'nowrap';\n sg.pinnedFragment.style.borderRightStyle = '';\n sg.floatLabel.style.visibility = 'hidden';\n sg.floatLabel.style.transform = '';\n sg.floatOffset = 0;\n\n // Add group-end to pinned column header + body cells\n this.#groupEndAdjustments.addGroupEnd.add(sg.pinnedField);\n host\n .querySelectorAll(\n `.header-row .cell[data-field=\"${sg.pinnedField}\"], .data-grid-row .cell[data-field=\"${sg.pinnedField}\"]`,\n )\n .forEach((el) => el.classList.add('group-end'));\n\n sg.isTransferred = true;\n } else if (!shouldTransfer && sg.isTransferred) {\n // Reverse transfer — label goes back to the floating span\n sg.pinnedFragment.textContent = '';\n sg.pinnedFragment.style.overflow = '';\n sg.pinnedFragment.style.textOverflow = '';\n sg.pinnedFragment.style.whiteSpace = '';\n sg.pinnedFragment.style.borderRightStyle = 'none';\n sg.floatLabel.style.visibility = '';\n sg.floatLabel.style.transform = '';\n sg.floatOffset = 0;\n\n // Remove group-end from pinned column cells\n this.#groupEndAdjustments.addGroupEnd.delete(sg.pinnedField);\n host\n .querySelectorAll(\n `.header-row .cell[data-field=\"${sg.pinnedField}\"], .data-grid-row .cell[data-field=\"${sg.pinnedField}\"]`,\n )\n .forEach((el) => el.classList.remove('group-end'));\n\n sg.isTransferred = false;\n }\n\n // Manually position the floating label to simulate sticky behavior.\n // CSS sticky can't be used because .header-group-cell has overflow:hidden.\n // We track the current translateX offset to correctly compute the span's\n // natural (un-translated) position from its measured rect.\n if (!sg.isTransferred) {\n const spanRect = sg.floatLabel.getBoundingClientRect();\n const spanNaturalLeft = spanRect.left - sg.floatOffset;\n const targetLeft = pinnedRect.left;\n if (spanNaturalLeft < targetLeft) {\n sg.floatOffset = targetLeft - spanNaturalLeft;\n sg.floatLabel.style.transform = `translateX(${sg.floatOffset}px)`;\n } else {\n sg.floatOffset = 0;\n sg.floatLabel.style.transform = '';\n }\n }\n }\n }\n\n /**\n * Handle inter-plugin queries.\n * @internal\n */\n override handleQuery(query: PluginQuery): unknown {\n switch (query.type) {\n case QUERY_CAN_MOVE_COLUMN: {\n // Prevent pinned columns from being moved/reordered.\n // Pinned columns have fixed positions and should not be draggable.\n const column = query.context as ColumnConfig;\n if (getColumnPinned(column) != null) {\n return false;\n }\n return undefined; // Let other plugins or default behavior decide\n }\n case 'getStickyOffsets': {\n // Return the calculated sticky offsets for column virtualization\n return {\n left: Object.fromEntries(this.leftOffsets),\n right: Object.fromEntries(this.rightOffsets),\n };\n }\n case 'getContextMenuItems': {\n const params = query.context as ContextMenuParams;\n if (!params.isHeader) return undefined;\n\n const column = params.column as ColumnConfig;\n if (!column?.field) return undefined;\n\n // Don't offer pin/unpin for locked-pinning columns\n // (top-level `lockPinning` preferred; legacy `meta.lockPinning` honored for back-compat)\n if (column.lockPinning || column.meta?.lockPinning) return undefined;\n\n const pinned = getColumnPinned(column);\n const isPinned = pinned != null;\n const items: HeaderContextMenuItem[] = [];\n\n if (isPinned) {\n items.push({\n id: 'pinned/unpin',\n label: 'Unpin Column',\n icon: '📌',\n order: 40,\n action: () => this.setPinPosition(column.field, undefined),\n });\n } else {\n items.push({\n id: 'pinned/pin-left',\n label: 'Pin Left',\n icon: '⬅',\n order: 40,\n action: () => this.setPinPosition(column.field, 'left'),\n });\n items.push({\n id: 'pinned/pin-right',\n label: 'Pin Right',\n icon: '➡',\n order: 41,\n action: () => this.setPinPosition(column.field, 'right'),\n });\n }\n\n return items;\n }\n default:\n return undefined;\n }\n }\n // #endregion\n\n // #region Public API\n\n /**\n * Set the pin position for a column.\n * Updates the column's `pinned` property and triggers a full re-render.\n *\n * @param field - The field name of the column to pin/unpin\n * @param position - The pin position (`'left'`, `'right'`, `'start'`, `'end'`), or `undefined` to unpin\n */\n setPinPosition(field: string, position: PinnedPosition | undefined): void {\n // Read the currently-visible columns from the plugin accessor.\n // These are the post-processColumns result, which is the authoritative column set.\n const currentColumns = this.columns;\n if (!currentColumns?.length) return;\n\n const currentIndex = currentColumns.findIndex((col) => col.field === field);\n if (currentIndex === -1) return;\n\n const gridEl = this.gridElement as HTMLElement & { columns?: ColumnConfig[] };\n\n if (position) {\n // PINNING: snapshot original column order if this is the first context-menu pin.\n // The snapshot lets us restore columns to their original positions on unpin.\n if (this.#originalColumnOrder.length === 0) {\n this.#originalColumnOrder = currentColumns.map((c) => c.field);\n }\n\n // Set the pinned property; processColumns will reorder on next render\n const updated = currentColumns.map((col) => {\n if (col.field !== field) return col;\n const copy = { ...col };\n (copy as ColumnConfig & { pinned?: PinnedPosition }).pinned = position;\n return copy;\n });\n\n gridEl.columns = updated;\n } else {\n // UNPINNING: restore column to its original position\n const col = currentColumns[currentIndex];\n const copy = { ...col };\n delete (copy as ColumnConfig & { pinned?: PinnedPosition }).pinned;\n\n // Remove from current position\n const remaining = [...currentColumns];\n remaining.splice(currentIndex, 1);\n\n // Find the best insertion point using the original order snapshot\n const originalIndex = this.#originalColumnOrder.indexOf(field);\n if (originalIndex >= 0) {\n // Scan remaining non-pinned columns and find the first whose original\n // position is greater than this column's original position.\n let insertIndex = remaining.length;\n for (let i = 0; i < remaining.length; i++) {\n if (getColumnPinned(remaining[i])) continue; // skip pinned columns\n const otherOriginal = this.#originalColumnOrder.indexOf(remaining[i].field);\n if (otherOriginal > originalIndex) {\n insertIndex = i;\n break;\n }\n }\n remaining.splice(insertIndex, 0, copy);\n } else {\n // Original position unknown — keep at current index\n remaining.splice(Math.min(currentIndex, remaining.length), 0, copy);\n }\n\n // If no more pinned columns remain, clear the snapshot\n if (!remaining.some((c) => getColumnPinned(c) != null)) {\n this.#originalColumnOrder = [];\n }\n\n gridEl.columns = remaining;\n }\n }\n\n /**\n * Re-apply sticky offsets (e.g., after column resize).\n */\n refreshStickyOffsets(): void {\n const columns = [...this.columns];\n const result = applyStickyOffsets(this.gridElement, columns);\n this.#groupEndAdjustments = result.groupEndAdjustments;\n this.leftOffsets = result.leftOffsets;\n this.rightOffsets = result.rightOffsets;\n this.#splitGroups = result.splitGroups;\n }\n\n /**\n * Get columns pinned to the left (after resolving logical positions for current direction).\n */\n getLeftPinnedColumns(): ColumnConfig[] {\n const columns = [...this.columns];\n const direction = getDirection(this.gridElement);\n return getLeftStickyColumns(columns, direction);\n }\n\n /**\n * Get columns pinned to the right (after resolving logical positions for current direction).\n */\n getRightPinnedColumns(): ColumnConfig[] {\n const columns = [...this.columns];\n const direction = getDirection(this.gridElement);\n return getRightStickyColumns(columns, direction);\n }\n\n /**\n * Clear all sticky positioning.\n */\n clearStickyPositions(): void {\n clearStickyOffsets(this.gridElement);\n }\n\n /**\n * Report horizontal scroll boundary offsets for pinned columns.\n * Used by keyboard navigation to ensure focused cells aren't hidden behind sticky columns.\n * @internal\n */\n override getHorizontalScrollOffsets(\n rowEl?: HTMLElement,\n focusedCell?: HTMLElement,\n ): { left: number; right: number; skipScroll?: boolean } | undefined {\n if (!this.isApplied) {\n return undefined;\n }\n\n let left = 0;\n let right = 0;\n\n if (rowEl) {\n // Calculate from rendered cells in the row\n const stickyLeftCells = rowEl.querySelectorAll(`.${GridClasses.STICKY_LEFT}`);\n const stickyRightCells = rowEl.querySelectorAll(`.${GridClasses.STICKY_RIGHT}`);\n stickyLeftCells.forEach((el) => {\n left += (el as HTMLElement).offsetWidth;\n });\n stickyRightCells.forEach((el) => {\n right += (el as HTMLElement).offsetWidth;\n });\n } else {\n // Fall back to header row if no row element provided\n const host = this.gridElement;\n const headerCells = host.querySelectorAll('.header-row .cell');\n headerCells.forEach((cell) => {\n if (cell.classList.contains(GridClasses.STICKY_LEFT)) {\n left += (cell as HTMLElement).offsetWidth;\n } else if (cell.classList.contains(GridClasses.STICKY_RIGHT)) {\n right += (cell as HTMLElement).offsetWidth;\n }\n });\n }\n\n // Skip horizontal scrolling if focused cell is pinned (it's always visible)\n const skipScroll =\n focusedCell?.classList.contains(GridClasses.STICKY_LEFT) ||\n focusedCell?.classList.contains(GridClasses.STICKY_RIGHT);\n\n return { left, right, skipScroll };\n }\n // #endregion\n}\n"],"names":["getColumnPinned","col","pinned","meta","resolveStickyPosition","position","direction","resolveInlinePosition","isResolvedLeft","isResolvedRight","hasStickyColumns","columns","i","length","applyStickyOffsets","host","emptyResult","groupEndAdjustments","addGroupEnd","Set","removeGroupEnd","leftOffsets","Map","rightOffsets","splitGroups","headerCells","Array","from","querySelectorAll","getDirection","left","cell","find","c","getAttribute","field","set","classList","add","GridClasses","STICKY_LEFT","style","forEach","el","offsetWidth","right","reverse","STICKY_RIGHT","adjustments","groupCells","groupCell","gridCol","gridColumn","match","startIdx","parseInt","endIdx","spannedColumns","slice","allLeft","every","allRight","firstField","firstCell","lastField","lastCell","contains","splitMixedPinImplicitGroup","someLeft","some","someRight","splitMixedPinExplicitGroup","applyGroupHeaderStickyOffsets","size","hCell","remove","getPinState","runs","state","prev","cols","push","colStart","parent","parentElement","nextSibling","removeChild","run","document","createElement","className","setAttribute","String","startsWith","borderRightStyle","insertBefore","appendChild","ri","nextRun","lastPinnedField","_adjustments","label","textContent","groupId","firstLeftRunIdx","findIndex","r","lastRightRunIdx","pinnedRunIdx","floatRunIdx","pinnedFragment","scrollableFragment","floatLabel","pinnedField","borderLeftStyle","overflow","span","zIndex","display","textOverflow","whiteSpace","isTransferred","floatOffset","clearStickyOffsets","QUERY_CAN_MOVE_COLUMN","PinnedColumnsPlugin","BaseGridPlugin","static","hookPriority","processColumns","ownedProperties","property","level","description","isUsed","v","queries","type","name","defaultConfig","isApplied","originalColumnOrder","detach","this","clear","detect","rows","config","isArray","gridElement","middle","reorderColumnsForPinning","afterRender","queueMicrotask","result","updateSplitGroupScroll","afterCellRender","context","column","cellEl","cellElement","leftOffset","get","rightOffset","has","onScroll","_event","sg","pinnedRect","getBoundingClientRect","shouldTransfer","visibility","transform","delete","spanNaturalLeft","targetLeft","handleQuery","query","Object","fromEntries","params","isHeader","lockPinning","items","id","icon","order","action","setPinPosition","currentColumns","currentIndex","gridEl","map","updated","copy","remaining","splice","originalIndex","indexOf","insertIndex","Math","min","refreshStickyOffsets","getLeftPinnedColumns","filter","getLeftStickyColumns","getRightPinnedColumns","getRightStickyColumns","clearStickyPositions","getHorizontalScrollOffsets","rowEl","focusedCell","stickyLeftCells","stickyRightCells","skipScroll"],"mappings":"ueAkBO,SAASA,EAAgBC,GAC9B,OAAOA,EAAIC,QAAUD,EAAIE,MAAMD,MACjC,CAaO,SAASE,EAAsBC,EAA0BC,GAC9D,OAAOC,EAAAA,sBAAsBF,EAAUC,EACzC,CAKA,SAASE,EAAeP,EAAUK,GAChC,MAAMJ,EAASF,EAAgBC,GAC/B,QAAKC,GAC+C,SAA7CE,EAAsBF,EAAQI,EACvC,CAKA,SAASG,EAAgBR,EAAUK,GACjC,MAAMJ,EAASF,EAAgBC,GAC/B,QAAKC,GAC+C,UAA7CE,EAAsBF,EAAQI,EACvC,CA8BO,SAASI,EAAiBC,GAC/B,IAAA,IAASC,EAAI,EAAGA,EAAID,EAAQE,OAAQD,IAClC,GAAyB,MAArBD,EAAQC,GAAGV,QAA6C,MAA3BS,EAAQC,GAAGT,MAAMD,OAAgB,OAAO,EAE3E,OAAO,CACT,CA4HO,SAASY,EAAmBC,EAAmBJ,GACpD,MAAMK,EAAmC,CACvCC,oBAAqB,CAAEC,YAAa,IAAIC,IAAOC,eAAgB,IAAID,KACnEE,gBAAiBC,IACjBC,iBAAkBD,IAClBE,YAAa,IAITC,EAAcC,MAAMC,KAAKZ,EAAKa,iBAAiB,sBACrD,IAAKH,EAAYZ,OAAQ,OAAOG,E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BhM,EAAgBL,EAA2B,OAC9E,OAAOK,EAAQiM,OAAQ3M,GAAQO,EAAeP,EAAKK,GACrD,CCscWuM,CAFS,IAAI9D,KAAKpI,SACPkB,EAAAA,aAAakH,KAAKM,aAEtC,CAKA,qBAAAyD,GAGE,ODtcG,SAA+BnM,EAAgBL,EAA2B,OAC/E,OAAOK,EAAQiM,OAAQ3M,GAAQQ,EAAgBR,EAAKK,GACtD,CCocWyM,CAFS,IAAIhE,KAAKpI,SACPkB,EAAAA,aAAakH,KAAKM,aAEtC,CAKA,oBAAA2D,GACErF,EAAmBoB,KAAKM,YAC1B,CAOS,0BAAA4D,CACPC,EACAC,GAEA,IAAKpE,KAAKH,UACR,OAGF,IAAI9G,EAAO,EACPe,EAAQ,EAEZ,GAAIqK,EAAO,CAET,MAAME,EAAkBF,EAAMtL,iBAAiB,IAAIW,EAAAA,YAAYC,eACzD6K,EAAmBH,EAAMtL,iBAAiB,IAAIW,EAAAA,YAAYQ,gBAChEqK,EAAgB1K,QAASC,IACvBb,GAASa,EAAmBC,cAE9ByK,EAAiB3K,QAASC,IACxBE,GAAUF,EAAmBC,aAEjC,KAAO,CAEQmG,KAAKM,YACOzH,iBAAiB,qBAC9Bc,QAASX,IACfA,EAAKM,UAAU6B,SAAS3B,EAAAA,YAAYC,aACtCV,GAASC,EAAqBa,YACrBb,EAAKM,UAAU6B,SAAS3B,EAAAA,YAAYQ,gBAC7CF,GAAUd,EAAqBa,cAGrC,CAGA,MAAM0K,EACJH,GAAa9K,UAAU6B,SAAS3B,EAAAA,YAAYC,cAC5C2K,GAAa9K,UAAU6B,SAAS3B,EAAAA,YAAYQ,cAE9C,MAAO,CAAEjB,OAAMe,QAAOyK,aACxB"}
|
package/umd/plugins/print.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("../../core/internal/diagnostics"),require("../../core/plugin/base-plugin")):"function"==typeof define&&define.amd?define(["exports","../../core/internal/diagnostics","../../core/plugin/base-plugin"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).TbwGridPlugin_print={},t.TbwGrid,t.TbwGrid)}(this,function(t,i,e){"use strict";const n="tbw-print-isolation-style";async function r(t,e={}){const{orientation:r="landscape"}=e,o=t.id;document.querySelectorAll(`#${CSS.escape(o)}`).length>1&&i.warnDiagnostic(i.PRINT_DUPLICATE_ID,`Multiple elements found with id="${o}". Print isolation may not work correctly. Ensure each grid has a unique ID.`,o,"print"),document.getElementById(n)?.remove();const a=function(t,i){const e=document.createElement("style");return e.id=n,e.textContent=`\n /* Print isolation: hide everything except the target grid */\n @media print {\n /* Hide all body children by default */\n body > *:not(#${t}) {\n display: none !important;\n }\n\n /* But show the grid and ensure it's not hidden by ancestor rules */\n #${t} {\n display: block !important;\n position: static !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n width: 100% !important;\n max-height: none !important;\n margin: 0 !important;\n padding: 0 !important;\n transform: none !important;\n }\n\n /* If grid is nested, we need to show its ancestors too */\n #${t},\n #${t} * {\n visibility: visible !important;\n }\n\n /* Walk up the DOM and show all ancestors of the grid */\n body *:has(> #${t}),\n body *:has(#${t}) {\n display: block !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n position: static !important;\n transform: none !important;\n background: transparent !important;\n border: none !important;\n padding: 0 !important;\n margin: 0 !important;\n }\n\n /* Hide siblings of ancestors (everything that's not in the path to the grid) */\n body *:has(#${t}) > *:not(:has(#${t})):not(#${t}) {\n display: none !important;\n }\n\n /* Page settings */\n @page {\n size: ${i};\n margin: 1cm;\n }\n\n /* Ensure proper print styling */\n body {\n margin: 0 !important;\n padding: 0 !important;\n background: white !important;\n color-scheme: light !important;\n }\n }\n\n /* Screen: also apply isolation for print preview */\n @media screen {\n /* When this stylesheet is active, we're about to print */\n /* No screen-specific rules needed - isolation only applies to print */\n }\n `,e}(o,r);return document.head.appendChild(a),new Promise(t=>{const i=()=>{window.removeEventListener("afterprint",i),document.getElementById(n)?.remove(),t()};window.addEventListener("afterprint",i),window.print(),setTimeout(()=>{window.removeEventListener("afterprint",i),document.getElementById(n)?.remove(),t()},5e3)})}const o={button:!1,orientation:"landscape",warnThreshold:500,maxRows:0,includeTitle:!0,includeTimestamp:!0,title:"",isolate:!1};class a extends e.BaseGridPlugin{name="print";version="1.0.0";styles=".tbw-print-header,.tbw-print-footer{display:none}@media print{tbw-grid{overflow:visible!important;height:auto!important;border:none!important;border-radius:0!important;color-scheme:light only;-webkit-print-color-adjust:exact;print-color-adjust:exact}tbw-grid .tbw-grid-content{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .tbw-scroll-area{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .rows-body{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .rows-container,tbw-grid .rows-viewport,tbw-grid .rows{overflow:visible!important;height:auto!important;max-height:none!important;transform:none!important}tbw-grid .rows-viewport .rows{position:static!important}tbw-grid .resize-handle,tbw-grid [part=sort-indicator],tbw-grid .tbw-filter-btn,tbw-grid .tool-panel,tbw-grid .tool-panel-content,tbw-grid .tbw-shell-header,tbw-grid .shell-toolbar,tbw-grid .tool-panel-toggle,tbw-grid [data-print-hide],tbw-grid .expander-cell,tbw-grid .tree-toggle,tbw-grid .context-menu,tbw-grid .faux-vscroll{display:none!important}tbw-grid .tbw-print-header{display:flex;justify-content:space-between;align-items:baseline;padding:var(--tbw-spacing-md, .5em) 0;margin-bottom:var(--tbw-spacing-md, .5em);border-bottom:2px solid var(--tbw-print-border, var(--tbw-color-border-strong));font-family:inherit}.tbw-print-header-title{font-size:1.25em;font-weight:700}.tbw-print-header-timestamp{font-size:var(--tbw-font-size-sm, .875em);color:var(--tbw-print-muted, var(--tbw-color-fg-muted))}tbw-grid .tbw-print-footer{display:block;margin-top:var(--tbw-spacing-md, .5em);padding-top:var(--tbw-spacing-md, .5em);border-top:1px solid var(--tbw-print-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75em);color:var(--tbw-print-muted, var(--tbw-color-fg-muted));text-align:end}tbw-grid .data-grid-row{break-inside:avoid;page-break-inside:avoid}tbw-grid .cell{border:1px solid var(--tbw-print-cell-border, var(--tbw-color-border))!important}tbw-grid .header-row,tbw-grid .data-grid-row{padding-inline-end:1px}tbw-grid .data-grid-row:hover,tbw-grid .cell:hover{background:inherit!important}@page{margin:1cm}@page{tbw-grid.print-landscape{size:landscape}}@page{tbw-grid.print-portrait{size:portrait}}}";#t=!1;#i=null;#e=null;#n=null;#r=null;#o=null;#a=null;get#s(){return this.grid}isPrinting(){return this.#t}async print(t){if(this.#t)return void this.warn(i.PRINT_IN_PROGRESS,"Print already in progress");const e=this.gridElement;if(!e)return void this.warn(i.PRINT_NO_GRID,"Grid not available");const n={...o,...this.config,...t},r=this.rows.length;let a=r,s=!1;if(n.warnThreshold>0&&r>n.warnThreshold){const t=n.maxRows>0?`\n\nNote: Output will be limited to ${n.maxRows.toLocaleString()} rows.`:"";if(!confirm(`This grid has ${r.toLocaleString()} rows. Printing large datasets may cause performance issues or browser slowdowns.${t}\n\nClick OK to continue, or Cancel to abort.`))return}n.maxRows>0&&r>n.maxRows&&(a=n.maxRows,s=!0),this.#t=!0;const d=performance.now();this.emit("print-start",{rowCount:a,limitApplied:s,originalRowCount:r});try{const t=this.#s;this.#e={bypassThreshold:t._virtualization?.bypassThreshold??24},this.#d(),s&&(this.#n=this.sourceRows,this.grid.rows=this.sourceRows.slice(0,a),await new Promise(t=>setTimeout(t,50))),(n.includeTitle||n.includeTimestamp)&&this.#l(n),await this.#p(),await new Promise(t=>requestAnimationFrame(t)),await new Promise(t=>requestAnimationFrame(t)),e.classList.add(`print-${n.orientation}`),await new Promise(t=>requestAnimationFrame(t)),await new Promise(t=>requestAnimationFrame(t)),n.isolate?await this.#m(n):await this.#h(),this.emit("print-complete",{success:!0,rowCount:a,duration:Math.round(performance.now()-d)})}catch(l){i.errorDiagnostic(i.PRINT_FAILED,`Print failed: ${l}`,this.gridElement?.id,this.name),this.emit("print-complete",{success:!1,rowCount:0,duration:Math.round(performance.now()-d)})}finally{this.#c(),this.#t=!1}}#l(t){const i=this.gridElement;if(i){if(this.#r=document.createElement("div"),this.#r.className="tbw-print-header",t.includeTitle){const i=t.title||this.grid.effectiveConfig?.shell?.header?.title||"Grid Data",e=document.createElement("div");e.className="tbw-print-header-title",e.textContent=i,this.#r.appendChild(e)}if(t.includeTimestamp){const t=document.createElement("div");t.className="tbw-print-header-timestamp",t.textContent=`Printed: ${(new Date).toLocaleString()}`,this.#r.appendChild(t)}i.insertBefore(this.#r,i.firstChild),this.#o=document.createElement("div"),this.#o.className="tbw-print-footer",this.#o.textContent=`Page generated from ${window.location.hostname}`,i.appendChild(this.#o)}}async#p(){const t=this.#s;if(!t._virtualization)return;const i=this.rows.length;t._virtualization.bypassThreshold=i+100,t.refreshVirtualWindow(!0),await new Promise(t=>setTimeout(t,100))}async#h(){return new Promise(t=>{const i=()=>{window.removeEventListener("afterprint",i),t()};window.addEventListener("afterprint",i),window.print(),setTimeout(()=>{"undefined"!=typeof window&&window.removeEventListener("afterprint",i),t()},1e3)})}async#m(t){const i=this.gridElement;i&&await r(i,{orientation:t.orientation})}#d(){const t=this.columns;if(t){this.#i=new Map;for(const i of t)i.printHidden&&i.field&&(this.#i.set(i.field,!i.hidden),this.grid.setColumnVisible(i.field,!1))}}#w(){if(this.#i){for(const[t,i]of this.#i)this.grid.setColumnVisible(t,i);this.#i=null}}#c(){const t=this.gridElement;if(!t)return;this.#w(),t.classList.remove("print-portrait","print-landscape"),null!==this.#a&&(t.style.transform="",t.style.transformOrigin="",t.style.width="",this.#a=null),this.#r&&(this.#r.remove(),this.#r=null),this.#o&&(this.#o.remove(),this.#o=null);const i=this.#s;this.#e&&i._virtualization&&(i._virtualization.bypassThreshold=this.#e.bypassThreshold,i.refreshVirtualWindow(!0),this.#e=null),null!==this.#n&&(this.grid.rows=this.#n,this.#n=null)}afterRender(){this.config?.button&&!this.#g&&(this.#u(),this.#g=!0)}#g=!1;#u(){const t=this.#s;t.registerToolbarContent?.({id:"print-button",order:900,render:t=>{const i=document.createElement("button");i.className="tbw-toolbar-btn tbw-print-btn",i.title="Print grid",i.type="button",this.setIcon(i,"print"),i.addEventListener("click",()=>{this.print()},{signal:this.disconnectSignal}),t.appendChild(i)}})}}t.PrintPlugin=a,t.printGridIsolated=r,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("../../core/internal/diagnostics"),require("../../core/plugin/base-plugin")):"function"==typeof define&&define.amd?define(["exports","../../core/internal/diagnostics","../../core/plugin/base-plugin"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).TbwGridPlugin_print={},t.TbwGrid,t.TbwGrid)}(this,function(t,i,e){"use strict";const n="tbw-print-isolation-style";async function r(t,e={}){const{orientation:r="landscape"}=e,o=t.id;document.querySelectorAll(`#${CSS.escape(o)}`).length>1&&i.warnDiagnostic(i.PRINT_DUPLICATE_ID,`Multiple elements found with id="${o}". Print isolation may not work correctly. Ensure each grid has a unique ID.`,o,"print"),document.getElementById(n)?.remove();const a=function(t,i){const e=document.createElement("style");return e.id=n,e.textContent=`\n /* Print isolation: hide everything except the target grid */\n @media print {\n /* Hide all body children by default */\n body > *:not(#${t}) {\n display: none !important;\n }\n\n /* But show the grid and ensure it's not hidden by ancestor rules */\n #${t} {\n display: block !important;\n position: static !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n width: 100% !important;\n max-height: none !important;\n margin: 0 !important;\n padding: 0 !important;\n transform: none !important;\n }\n\n /* If grid is nested, we need to show its ancestors too */\n #${t},\n #${t} * {\n visibility: visible !important;\n }\n\n /* Walk up the DOM and show all ancestors of the grid */\n body *:has(> #${t}),\n body *:has(#${t}) {\n display: block !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n position: static !important;\n transform: none !important;\n background: transparent !important;\n border: none !important;\n padding: 0 !important;\n margin: 0 !important;\n }\n\n /* Hide siblings of ancestors (everything that's not in the path to the grid) */\n body *:has(#${t}) > *:not(:has(#${t})):not(#${t}) {\n display: none !important;\n }\n\n /* Page settings */\n @page {\n size: ${i};\n margin: 1cm;\n }\n\n /* Ensure proper print styling */\n body {\n margin: 0 !important;\n padding: 0 !important;\n background: white !important;\n color-scheme: light !important;\n }\n }\n\n /* Screen: also apply isolation for print preview */\n @media screen {\n /* When this stylesheet is active, we're about to print */\n /* No screen-specific rules needed - isolation only applies to print */\n }\n `,e}(o,r);return document.head.appendChild(a),new Promise(t=>{const i=()=>{window.removeEventListener("afterprint",i),document.getElementById(n)?.remove(),t()};window.addEventListener("afterprint",i),window.print(),setTimeout(()=>{window.removeEventListener("afterprint",i),document.getElementById(n)?.remove(),t()},5e3)})}const o={button:!1,orientation:"landscape",warnThreshold:500,maxRows:0,includeTitle:!0,includeTimestamp:!0,title:"",isolate:!1};class a extends e.BaseGridPlugin{name="print";version="1.0.0";styles=".tbw-print-header,.tbw-print-footer{display:none}@media print{tbw-grid{overflow:visible!important;height:auto!important;border:none!important;border-radius:0!important;color-scheme:light only;-webkit-print-color-adjust:exact;print-color-adjust:exact}tbw-grid .tbw-grid-content{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .tbw-scroll-area{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .rows-body{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .rows-container,tbw-grid .rows-viewport,tbw-grid .rows{overflow:visible!important;height:auto!important;max-height:none!important;transform:none!important}tbw-grid .rows-viewport .rows{position:static!important}tbw-grid .resize-handle,tbw-grid [part=sort-indicator],tbw-grid .tbw-filter-btn,tbw-grid .tool-panel,tbw-grid .tool-panel-content,tbw-grid .tbw-shell-header,tbw-grid .shell-toolbar,tbw-grid .tool-panel-toggle,tbw-grid [data-print-hide],tbw-grid .expander-cell,tbw-grid .tree-toggle,tbw-grid .context-menu,tbw-grid .faux-vscroll{display:none!important}tbw-grid .tbw-print-header{display:flex;justify-content:space-between;align-items:baseline;padding:var(--tbw-spacing-md, .5em) 0;margin-bottom:var(--tbw-spacing-md, .5em);border-bottom:2px solid var(--tbw-print-border, var(--tbw-color-border-strong));font-family:inherit}.tbw-print-header-title{font-size:1.25em;font-weight:700}.tbw-print-header-timestamp{font-size:var(--tbw-font-size-sm, .875em);color:var(--tbw-print-muted, var(--tbw-color-fg-muted))}tbw-grid .tbw-print-footer{display:block;margin-top:var(--tbw-spacing-md, .5em);padding-top:var(--tbw-spacing-md, .5em);border-top:1px solid var(--tbw-print-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75em);color:var(--tbw-print-muted, var(--tbw-color-fg-muted));text-align:end}tbw-grid .data-grid-row{break-inside:avoid;page-break-inside:avoid}tbw-grid .cell{border:1px solid var(--tbw-print-cell-border, var(--tbw-color-border))!important}tbw-grid .header-row,tbw-grid .data-grid-row{padding-inline-end:1px}tbw-grid .data-grid-row:hover,tbw-grid .cell:hover{background:inherit!important}@page{margin:1cm}@page{tbw-grid.print-landscape{size:landscape}}@page{tbw-grid.print-portrait{size:portrait}}}";#t=!1;#i=null;#e=null;#n=null;#r=null;#o=null;#a=null;get#s(){return this.grid}isPrinting(){return this.#t}async print(t){if(this.#t)return void this.warn(i.PRINT_IN_PROGRESS,"Print already in progress");const e=this.gridElement;if(!e)return void this.warn(i.PRINT_NO_GRID,"Grid not available");const n={...o,...this.config,...t},r=this.rows.length;let a=r,s=!1;if(n.warnThreshold>0&&r>n.warnThreshold){const t=n.maxRows>0?`\n\nNote: Output will be limited to ${n.maxRows.toLocaleString()} rows.`:"";if(!confirm(`This grid has ${r.toLocaleString()} rows. Printing large datasets may cause performance issues or browser slowdowns.${t}\n\nClick OK to continue, or Cancel to abort.`))return}n.maxRows>0&&r>n.maxRows&&(a=n.maxRows,s=!0),this.#t=!0;const d=performance.now();this.emit("print-start",{rowCount:a,limitApplied:s,originalRowCount:r});try{const t=this.#s;this.#e={bypassThreshold:t._virtualization?.bypassThreshold??24},this.#d(),s&&(this.#n=this.sourceRows,this.grid.rows=this.sourceRows.slice(0,a),await new Promise(t=>setTimeout(t,50))),(n.includeTitle||n.includeTimestamp)&&this.#l(n),await this.#p(),await new Promise(t=>requestAnimationFrame(t)),await new Promise(t=>requestAnimationFrame(t)),e.classList.add(`print-${n.orientation}`),await new Promise(t=>requestAnimationFrame(t)),await new Promise(t=>requestAnimationFrame(t)),n.isolate?await this.#m(n):await this.#h(),this.emit("print-complete",{success:!0,rowCount:a,duration:Math.round(performance.now()-d)})}catch(l){i.errorDiagnostic(i.PRINT_FAILED,`Print failed: ${l}`,this.gridElement?.id,this.name),this.emit("print-complete",{success:!1,rowCount:0,duration:Math.round(performance.now()-d)})}finally{this.#c(),this.#t=!1}}#l(t){const i=this.gridElement;if(i){if(this.#r=document.createElement("div"),this.#r.className="tbw-print-header",t.includeTitle){const i=t.title||this.grid.effectiveConfig?.shell?.header?.title||"Grid Data",e=document.createElement("div");e.className="tbw-print-header-title",e.textContent=i,this.#r.appendChild(e)}if(t.includeTimestamp){const t=document.createElement("div");t.className="tbw-print-header-timestamp",t.textContent=`Printed: ${(new Date).toLocaleString()}`,this.#r.appendChild(t)}i.insertBefore(this.#r,i.firstChild),this.#o=document.createElement("div"),this.#o.className="tbw-print-footer",this.#o.textContent=`Page generated from ${window.location.hostname}`,i.appendChild(this.#o)}}async#p(){const t=this.#s;if(!t._virtualization)return;const i=this.rows.length;t._virtualization.bypassThreshold=i+100,t.refreshVirtualWindow(!0),await new Promise(t=>setTimeout(t,100))}async#h(){return new Promise(t=>{const i=()=>{window.removeEventListener("afterprint",i),t()};window.addEventListener("afterprint",i),window.print(),setTimeout(()=>{"undefined"!=typeof window&&window.removeEventListener("afterprint",i),t()},1e3)})}async#m(t){const i=this.gridElement;i&&await r(i,{orientation:t.orientation})}#d(){const t=this.columns;if(t){this.#i=new Map;for(const i of t){if(!i.field)continue;(!0===i.printHidden||!0===i.utility&&!1!==i.printHidden)&&(this.#i.set(i.field,!i.hidden),this.grid.setColumnVisible(i.field,!1))}}}#w(){if(this.#i){for(const[t,i]of this.#i)this.grid.setColumnVisible(t,i);this.#i=null}}#c(){const t=this.gridElement;if(!t)return;this.#w(),t.classList.remove("print-portrait","print-landscape"),null!==this.#a&&(t.style.transform="",t.style.transformOrigin="",t.style.width="",this.#a=null),this.#r&&(this.#r.remove(),this.#r=null),this.#o&&(this.#o.remove(),this.#o=null);const i=this.#s;this.#e&&i._virtualization&&(i._virtualization.bypassThreshold=this.#e.bypassThreshold,i.refreshVirtualWindow(!0),this.#e=null),null!==this.#n&&(this.grid.rows=this.#n,this.#n=null)}afterRender(){this.config?.button&&!this.#g&&(this.#u(),this.#g=!0)}#g=!1;#u(){const t=this.#s;t.registerToolbarContent?.({id:"print-button",order:900,render:t=>{const i=document.createElement("button");i.className="tbw-toolbar-btn tbw-print-btn",i.title="Print grid",i.type="button",this.setIcon(i,"print"),i.addEventListener("click",()=>{this.print()},{signal:this.disconnectSignal}),t.appendChild(i)}})}}t.PrintPlugin=a,t.printGridIsolated=r,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=print.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/print/print-isolated.ts","../../../../../libs/grid/src/lib/plugins/print/PrintPlugin.ts"],"sourcesContent":["/**\n * Utility for printing a grid in isolation by hiding all other page content.\n *\n * This approach keeps the grid in place (with virtualization disabled by PrintPlugin)\n * and uses CSS to hide everything else on the page during printing.\n */\n\nimport { PRINT_DUPLICATE_ID, warnDiagnostic } from '../../core/internal/diagnostics';\nimport type { PrintOrientation } from './types';\n\nexport interface PrintIsolatedOptions {\n /** Page orientation hint */\n orientation?: PrintOrientation;\n}\n\n/** ID for the isolation stylesheet */\nconst ISOLATION_STYLE_ID = 'tbw-print-isolation-style';\n\n/**\n * Create a stylesheet that hides everything except the target grid.\n * Uses the grid's ID to target it specifically.\n */\nfunction createIsolationStylesheet(gridId: string, orientation: PrintOrientation): HTMLStyleElement {\n const style = document.createElement('style');\n style.id = ISOLATION_STYLE_ID;\n style.textContent = `\n /* Print isolation: hide everything except the target grid */\n @media print {\n /* Hide all body children by default */\n body > *:not(#${gridId}) {\n display: none !important;\n }\n\n /* But show the grid and ensure it's not hidden by ancestor rules */\n #${gridId} {\n display: block !important;\n position: static !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n width: 100% !important;\n max-height: none !important;\n margin: 0 !important;\n padding: 0 !important;\n transform: none !important;\n }\n\n /* If grid is nested, we need to show its ancestors too */\n #${gridId},\n #${gridId} * {\n visibility: visible !important;\n }\n\n /* Walk up the DOM and show all ancestors of the grid */\n body *:has(> #${gridId}),\n body *:has(#${gridId}) {\n display: block !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n position: static !important;\n transform: none !important;\n background: transparent !important;\n border: none !important;\n padding: 0 !important;\n margin: 0 !important;\n }\n\n /* Hide siblings of ancestors (everything that's not in the path to the grid) */\n body *:has(#${gridId}) > *:not(:has(#${gridId})):not(#${gridId}) {\n display: none !important;\n }\n\n /* Page settings */\n @page {\n size: ${orientation};\n margin: 1cm;\n }\n\n /* Ensure proper print styling */\n body {\n margin: 0 !important;\n padding: 0 !important;\n background: white !important;\n color-scheme: light !important;\n }\n }\n\n /* Screen: also apply isolation for print preview */\n @media screen {\n /* When this stylesheet is active, we're about to print */\n /* No screen-specific rules needed - isolation only applies to print */\n }\n `;\n return style;\n}\n\n/**\n * Print a grid in isolation by hiding all other page content.\n *\n * This function adds a temporary stylesheet that uses CSS to hide everything\n * on the page except the target grid during printing. The grid stays in place\n * with all its data (virtualization should be disabled separately).\n *\n * @param gridElement - The tbw-grid element to print (must have an ID)\n * @param options - Optional configuration\n * @returns Promise that resolves when the print dialog closes\n *\n * @example\n * ```typescript\n * import { queryGrid } from '@toolbox-web/grid';\n * import { printGridIsolated } from '@toolbox-web/grid/plugins/print';\n *\n * const grid = queryGrid('tbw-grid');\n * await printGridIsolated(grid, { orientation: 'landscape' });\n * ```\n */\nexport async function printGridIsolated(gridElement: HTMLElement, options: PrintIsolatedOptions = {}): Promise<void> {\n const { orientation = 'landscape' } = options;\n\n const gridId = gridElement.id;\n\n // Warn if multiple elements share this ID (user-set IDs could collide)\n const elementsWithId = document.querySelectorAll(`#${CSS.escape(gridId)}`);\n if (elementsWithId.length > 1) {\n warnDiagnostic(\n PRINT_DUPLICATE_ID,\n `Multiple elements found with id=\"${gridId}\". ` +\n `Print isolation may not work correctly. Ensure each grid has a unique ID.`,\n gridId,\n 'print',\n );\n }\n\n // Remove any existing isolation stylesheet\n document.getElementById(ISOLATION_STYLE_ID)?.remove();\n\n // Add the isolation stylesheet\n const isolationStyle = createIsolationStylesheet(gridId, orientation);\n document.head.appendChild(isolationStyle);\n\n return new Promise((resolve) => {\n // Listen for afterprint event to cleanup\n const onAfterPrint = () => {\n window.removeEventListener('afterprint', onAfterPrint);\n // Remove isolation stylesheet\n document.getElementById(ISOLATION_STYLE_ID)?.remove();\n resolve();\n };\n window.addEventListener('afterprint', onAfterPrint);\n\n // Trigger print\n window.print();\n\n // Fallback timeout in case afterprint doesn't fire (some browsers)\n setTimeout(() => {\n window.removeEventListener('afterprint', onAfterPrint);\n document.getElementById(ISOLATION_STYLE_ID)?.remove();\n resolve();\n }, 5000);\n });\n}\n","/**\n * Print Plugin (Class-based)\n *\n * Provides print layout functionality for tbw-grid.\n * Temporarily disables virtualization to render all rows and uses\n * @media print CSS for print-optimized styling.\n */\n\nimport { PRINT_FAILED, PRINT_IN_PROGRESS, PRINT_NO_GRID, errorDiagnostic } from '../../core/internal/diagnostics';\nimport { BaseGridPlugin } from '../../core/plugin/base-plugin';\nimport type { InternalGrid, ToolbarContentDefinition } from '../../core/types';\nimport { printGridIsolated } from './print-isolated';\nimport styles from './print.css?inline';\nimport type { PrintCompleteDetail, PrintConfig, PrintParams, PrintStartDetail } from './types';\n\n/**\n * Extended grid interface for PrintPlugin internal access.\n * Includes registerToolbarContent which is available on the grid class\n * but not exposed in the standard plugin API.\n */\ninterface PrintGridRef extends InternalGrid {\n registerToolbarContent?(content: ToolbarContentDefinition): void;\n unregisterToolbarContent?(contentId: string): void;\n}\n\n/** Default configuration */\nconst DEFAULT_CONFIG: Required<PrintConfig> = {\n button: false,\n orientation: 'landscape',\n warnThreshold: 500,\n maxRows: 0,\n includeTitle: true,\n includeTimestamp: true,\n title: '',\n isolate: false,\n};\n\n/**\n * Print Plugin for tbw-grid\n *\n * Enables printing the full grid content by temporarily disabling virtualization\n * and applying print-optimized styles. Handles large datasets gracefully with\n * configurable row limits.\n *\n * ## Installation\n *\n * ```ts\n * import { PrintPlugin } from '@toolbox-web/grid/plugins/print';\n * ```\n *\n * ## Events\n *\n * | Event | Detail | Description |\n * |-------|--------|-------------|\n * | `print-start` | {@link PrintStartDetail} | Fired when print begins |\n * | `print-complete` | {@link PrintCompleteDetail} | Fired when print completes |\n *\n * @example Basic Print\n * ```ts\n * import { queryGrid } from '@toolbox-web/grid';\n * import { PrintPlugin } from '@toolbox-web/grid/plugins/print';\n *\n * const grid = queryGrid('tbw-grid');\n * grid.gridConfig = {\n * plugins: [new PrintPlugin()],\n * };\n *\n * // Trigger print\n * const printPlugin = grid.getPluginByName('print');\n * await printPlugin.print();\n * ```\n *\n * @example With Toolbar Button\n * ```ts\n * grid.gridConfig = {\n * plugins: [new PrintPlugin({ button: true, orientation: 'landscape' })],\n * };\n * ```\n *\n * @see {@link PrintConfig} for all configuration options\n */\nexport class PrintPlugin extends BaseGridPlugin<PrintConfig> {\n /** @internal */\n readonly name = 'print';\n\n /** @internal */\n override readonly version = '1.0.0';\n\n /** CSS styles for print mode */\n override readonly styles = styles;\n\n /** Current print state */\n #printing = false;\n\n /** Saved column visibility state */\n #savedHiddenColumns: Map<string, boolean> | null = null;\n\n /** Saved virtualization state */\n #savedVirtualization: { bypassThreshold: number } | null = null;\n\n /** Saved rows when maxRows limit is applied */\n #savedRows: unknown[] | null = null;\n\n /** Print header element */\n #printHeader: HTMLElement | null = null;\n\n /** Print footer element */\n #printFooter: HTMLElement | null = null;\n\n /** Applied scale factor (legacy, used for cleanup) */\n #appliedScale: number | null = null;\n\n /**\n * Get the grid typed as PrintGridRef for internal access.\n */\n get #internalGrid(): PrintGridRef {\n return this.grid as unknown as PrintGridRef;\n }\n\n /**\n * Check if print is currently in progress\n */\n isPrinting(): boolean {\n return this.#printing;\n }\n\n /**\n * Trigger the browser print dialog\n *\n * This method:\n * 1. Validates row count against maxRows limit\n * 2. Disables virtualization to render all rows\n * 3. Applies print-specific CSS classes\n * 4. Opens the browser print dialog (or isolated window if `isolate: true`)\n * 5. Restores normal state after printing\n *\n * @param params - Optional parameters to override config for this print\n * @param params.isolate - If true, prints in an isolated window containing only the grid\n * @returns Promise that resolves when print dialog closes\n */\n async print(params?: PrintParams): Promise<void> {\n if (this.#printing) {\n this.warn(PRINT_IN_PROGRESS, 'Print already in progress');\n return;\n }\n\n const grid = this.gridElement;\n if (!grid) {\n this.warn(PRINT_NO_GRID, 'Grid not available');\n return;\n }\n\n const config = { ...DEFAULT_CONFIG, ...this.config, ...params };\n const rows = this.rows;\n const originalRowCount = rows.length;\n let rowCount = originalRowCount;\n let limitApplied = false;\n\n // Check if we should warn about large datasets\n if (config.warnThreshold > 0 && originalRowCount > config.warnThreshold) {\n const limitInfo =\n config.maxRows > 0 ? `\\n\\nNote: Output will be limited to ${config.maxRows.toLocaleString()} rows.` : '';\n const proceed = confirm(\n `This grid has ${originalRowCount.toLocaleString()} rows. ` +\n `Printing large datasets may cause performance issues or browser slowdowns.${limitInfo}\\n\\n` +\n `Click OK to continue, or Cancel to abort.`,\n );\n if (!proceed) {\n return;\n }\n }\n\n // Apply hard row limit if configured\n if (config.maxRows > 0 && originalRowCount > config.maxRows) {\n rowCount = config.maxRows;\n limitApplied = true;\n }\n\n this.#printing = true;\n\n // Track timing for duration reporting\n const startTime = performance.now();\n\n // Emit print-start event\n this.emit<PrintStartDetail>('print-start', {\n rowCount,\n limitApplied,\n originalRowCount,\n });\n\n try {\n // Save current virtualization state\n const internalGrid = this.#internalGrid;\n this.#savedVirtualization = {\n bypassThreshold: internalGrid._virtualization?.bypassThreshold ?? 24,\n };\n\n // Hide columns marked with printHidden\n this.#hidePrintColumns();\n\n // Apply row limit if configured\n if (limitApplied) {\n this.#savedRows = this.sourceRows;\n // Set limited rows on the grid\n this.grid.rows = this.sourceRows.slice(0, rowCount);\n // Wait for grid to process new rows\n await new Promise((resolve) => setTimeout(resolve, 50));\n }\n\n // Add print header if configured\n if (config.includeTitle || config.includeTimestamp) {\n this.#addPrintHeader(config);\n }\n\n // Disable virtualization to render all rows\n // This forces the grid to render all rows in the DOM\n await this.#disableVirtualization();\n\n // Wait for next frame to ensure DOM is updated\n await new Promise((resolve) => requestAnimationFrame(resolve));\n await new Promise((resolve) => requestAnimationFrame(resolve));\n\n // Add orientation class for @page rules\n grid.classList.add(`print-${config.orientation}`);\n\n // Wait for next frame to ensure DOM is updated\n await new Promise((resolve) => requestAnimationFrame(resolve));\n await new Promise((resolve) => requestAnimationFrame(resolve));\n\n // Trigger browser print dialog (isolated or inline)\n if (config.isolate) {\n await this.#printInIsolatedWindow(config);\n } else {\n await this.#triggerPrint();\n }\n\n // Emit print-complete event\n this.emit<PrintCompleteDetail>('print-complete', {\n success: true,\n rowCount,\n duration: Math.round(performance.now() - startTime),\n });\n } catch (error) {\n errorDiagnostic(PRINT_FAILED, `Print failed: ${error}`, this.gridElement?.id, this.name);\n this.emit<PrintCompleteDetail>('print-complete', {\n success: false,\n rowCount: 0,\n duration: Math.round(performance.now() - startTime),\n });\n } finally {\n // Restore normal state\n this.#cleanup();\n this.#printing = false;\n }\n }\n\n /**\n * Add print header with title and timestamp\n */\n #addPrintHeader(config: Required<PrintConfig>): void {\n const grid = this.gridElement;\n if (!grid) return;\n\n // Create print header\n this.#printHeader = document.createElement('div');\n this.#printHeader.className = 'tbw-print-header';\n\n // Title\n if (config.includeTitle) {\n const title = config.title || this.grid.effectiveConfig?.shell?.header?.title || 'Grid Data';\n const titleEl = document.createElement('div');\n titleEl.className = 'tbw-print-header-title';\n titleEl.textContent = title;\n this.#printHeader.appendChild(titleEl);\n }\n\n // Timestamp\n if (config.includeTimestamp) {\n const timestampEl = document.createElement('div');\n timestampEl.className = 'tbw-print-header-timestamp';\n timestampEl.textContent = `Printed: ${new Date().toLocaleString()}`;\n this.#printHeader.appendChild(timestampEl);\n }\n\n // Insert at the beginning of the grid\n grid.insertBefore(this.#printHeader, grid.firstChild);\n\n // Create print footer\n this.#printFooter = document.createElement('div');\n this.#printFooter.className = 'tbw-print-footer';\n this.#printFooter.textContent = `Page generated from ${window.location.hostname}`;\n grid.appendChild(this.#printFooter);\n }\n\n /**\n * Disable virtualization to render all rows\n */\n async #disableVirtualization(): Promise<void> {\n const internalGrid = this.#internalGrid;\n if (!internalGrid._virtualization) return;\n\n // Set bypass threshold higher than total row count to disable virtualization\n // This makes the grid render all rows (up to maxRows) instead of just visible ones\n const totalRows = this.rows.length;\n internalGrid._virtualization.bypassThreshold = totalRows + 100;\n\n // Force a full refresh to re-render with virtualization disabled\n internalGrid.refreshVirtualWindow(true);\n\n // Wait for render to complete\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n\n /**\n * Trigger the browser print dialog\n */\n async #triggerPrint(): Promise<void> {\n return new Promise((resolve) => {\n // Listen for afterprint event\n const onAfterPrint = () => {\n window.removeEventListener('afterprint', onAfterPrint);\n resolve();\n };\n window.addEventListener('afterprint', onAfterPrint);\n\n // Trigger print\n window.print();\n\n // Fallback timeout in case afterprint doesn't fire (some browsers)\n setTimeout(() => {\n // Guard against test environment teardown where window may be undefined\n if (typeof window !== 'undefined') {\n window.removeEventListener('afterprint', onAfterPrint);\n }\n resolve();\n }, 1000);\n });\n }\n\n /**\n * Print in isolation by hiding all other page content.\n * This excludes navigation, sidebars, etc. while keeping the grid in place.\n */\n async #printInIsolatedWindow(config: Required<PrintConfig>): Promise<void> {\n const grid = this.gridElement;\n if (!grid) return;\n\n await printGridIsolated(grid, {\n orientation: config.orientation,\n });\n }\n\n /**\n * Hide columns marked with printHidden: true\n */\n #hidePrintColumns(): void {\n const columns = this.columns;\n if (!columns) return;\n\n // Save current hidden state and hide print columns\n this.#savedHiddenColumns = new Map();\n\n for (const col of columns) {\n if (col.printHidden && col.field) {\n // Save current visibility state (true = visible, false = hidden)\n this.#savedHiddenColumns.set(col.field, !col.hidden);\n // Hide the column for printing\n this.grid.setColumnVisible(col.field, false);\n }\n }\n }\n\n /**\n * Restore columns that were hidden for printing\n */\n #restorePrintColumns(): void {\n if (!this.#savedHiddenColumns) return;\n\n for (const [field, wasVisible] of this.#savedHiddenColumns) {\n // Restore original visibility\n this.grid.setColumnVisible(field, wasVisible);\n }\n\n this.#savedHiddenColumns = null;\n }\n\n /**\n * Cleanup after printing\n */\n #cleanup(): void {\n const grid = this.gridElement;\n if (!grid) return;\n\n // Restore columns that were hidden for printing\n this.#restorePrintColumns();\n\n // Remove orientation classes (both original and possibly switched)\n grid.classList.remove('print-portrait', 'print-landscape');\n\n // Remove scaling transform if applied (legacy)\n if (this.#appliedScale !== null) {\n grid.style.transform = '';\n grid.style.transformOrigin = '';\n grid.style.width = '';\n this.#appliedScale = null;\n }\n\n // Remove print header/footer\n if (this.#printHeader) {\n this.#printHeader.remove();\n this.#printHeader = null;\n }\n if (this.#printFooter) {\n this.#printFooter.remove();\n this.#printFooter = null;\n }\n\n // Restore virtualization\n const internalGrid = this.#internalGrid;\n if (this.#savedVirtualization && internalGrid._virtualization) {\n internalGrid._virtualization.bypassThreshold = this.#savedVirtualization.bypassThreshold;\n internalGrid.refreshVirtualWindow(true);\n this.#savedVirtualization = null;\n }\n\n // Restore original rows if they were limited\n if (this.#savedRows !== null) {\n this.grid.rows = this.#savedRows;\n this.#savedRows = null;\n }\n }\n\n /**\n * Register toolbar button if configured\n * @internal\n */\n override afterRender(): void {\n // Register toolbar on first render when button is enabled\n if (this.config?.button && !this.#toolbarRegistered) {\n this.#registerToolbarButton();\n this.#toolbarRegistered = true;\n }\n }\n\n /** Track if toolbar button is registered */\n #toolbarRegistered = false;\n\n /**\n * Register print button in toolbar\n */\n #registerToolbarButton(): void {\n const grid = this.#internalGrid;\n\n // Register toolbar content\n grid.registerToolbarContent?.({\n id: 'print-button',\n order: 900, // High order to appear at the end\n render: (container: HTMLElement) => {\n const button = document.createElement('button');\n button.className = 'tbw-toolbar-btn tbw-print-btn';\n button.title = 'Print grid';\n button.type = 'button';\n\n // Use print icon\n this.setIcon(button, 'print');\n\n button.addEventListener(\n 'click',\n () => {\n this.print();\n },\n { signal: this.disconnectSignal },\n );\n\n container.appendChild(button);\n },\n });\n }\n}\n"],"names":["ISOLATION_STYLE_ID","async","printGridIsolated","gridElement","options","orientation","gridId","id","document","querySelectorAll","CSS","escape","length","warnDiagnostic","PRINT_DUPLICATE_ID","getElementById","remove","isolationStyle","style","createElement","textContent","createIsolationStylesheet","head","appendChild","Promise","resolve","onAfterPrint","window","removeEventListener","addEventListener","print","setTimeout","DEFAULT_CONFIG","button","warnThreshold","maxRows","includeTitle","includeTimestamp","title","isolate","PrintPlugin","BaseGridPlugin","name","version","styles","printing","savedHiddenColumns","savedVirtualization","savedRows","printHeader","printFooter","appliedScale","internalGrid","this","grid","isPrinting","params","warn","PRINT_IN_PROGRESS","PRINT_NO_GRID","config","originalRowCount","rows","rowCount","limitApplied","limitInfo","toLocaleString","confirm","startTime","performance","now","emit","bypassThreshold","_virtualization","hidePrintColumns","sourceRows","slice","addPrintHeader","disableVirtualization","requestAnimationFrame","classList","add","printInIsolatedWindow","triggerPrint","success","duration","Math","round","error","errorDiagnostic","PRINT_FAILED","cleanup","className","effectiveConfig","shell","header","titleEl","timestampEl","Date","insertBefore","firstChild","location","hostname","totalRows","refreshVirtualWindow","columns","Map","col","printHidden","field","set","hidden","setColumnVisible","restorePrintColumns","wasVisible","transform","transformOrigin","width","afterRender","toolbarRegistered","registerToolbarButton","registerToolbarContent","order","render","container","type","setIcon","signal","disconnectSignal"],"mappings":"waAgBA,MAAMA,EAAqB,4BAuG3BC,eAAsBC,EAAkBC,EAA0BC,EAAgC,IAChG,MAAMC,YAAEA,EAAc,aAAgBD,EAEhCE,EAASH,EAAYI,GAGJC,SAASC,iBAAiB,IAAIC,IAAIC,OAAOL,MAC7CM,OAAS,GAC1BC,EAAAA,eACEC,EAAAA,mBACA,oCAAoCR,gFAEpCA,EACA,SAKJE,SAASO,eAAef,IAAqBgB,SAG7C,MAAMC,EAtHR,SAAmCX,EAAgBD,GACjD,MAAMa,EAAQV,SAASW,cAAc,SAyErC,OAxEAD,EAAMX,GAAKP,EACXkB,EAAME,YAAc,+JAIAd,0IAKbA,meAeAA,cACAA,kJAKaA,0BACFA,6gBAeAA,oBAAyBA,YAAiBA,+GAM9CD,yeAmBPa,CACT,CA2CyBG,CAA0Bf,EAAQD,GAGzD,OAFAG,SAASc,KAAKC,YAAYN,GAEnB,IAAIO,QAASC,IAElB,MAAMC,EAAe,KACnBC,OAAOC,oBAAoB,aAAcF,GAEzClB,SAASO,eAAef,IAAqBgB,SAC7CS,KAEFE,OAAOE,iBAAiB,aAAcH,GAGtCC,OAAOG,QAGPC,WAAW,KACTJ,OAAOC,oBAAoB,aAAcF,GACzClB,SAASO,eAAef,IAAqBgB,SAC7CS,KACC,MAEP,OCzIMO,EAAwC,CAC5CC,QAAQ,EACR5B,YAAa,YACb6B,cAAe,IACfC,QAAS,EACTC,cAAc,EACdC,kBAAkB,EAClBC,MAAO,GACPC,SAAS,GA+CJ,MAAMC,UAAoBC,EAAAA,eAEtBC,KAAO,QAGEC,QAAU,QAGVC,kwEAGlBC,IAAY,EAGZC,GAAmD,KAGnDC,GAA2D,KAG3DC,GAA+B,KAG/BC,GAAmC,KAGnCC,GAAmC,KAGnCC,GAA+B,KAK/B,KAAIC,GACF,OAAOC,KAAKC,I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KF,EAAgB,MAInBE,MAAKJ,IACPI,MAAKJ,EAAajC,SAClBqC,MAAKJ,EAAe,MAElBI,MAAKH,IACPG,MAAKH,EAAalC,SAClBqC,MAAKH,EAAe,MAItB,MAAME,EAAeC,MAAKD,EACtBC,MAAKN,GAAwBK,EAAaqB,kBAC5CrB,EAAaqB,gBAAgBD,gBAAkBnB,MAAKN,EAAqByB,gBACzEpB,EAAaoD,sBAAqB,GAClCnD,MAAKN,EAAuB,MAIN,OAApBM,MAAKL,IACPK,KAAKC,KAAKQ,KAAOT,MAAKL,EACtBK,MAAKL,EAAa,KAEtB,CAMS,WAAAsE,GAEHjE,KAAKO,QAAQ3B,SAAWoB,MAAKkE,IAC/BlE,MAAKmE,IACLnE,MAAKkE,GAAqB,EAE9B,CAGAA,IAAqB,EAKrB,EAAAC,GACE,MAAMlE,EAAOD,MAAKD,EAGlBE,EAAKmE,yBAAyB,CAC5BlH,GAAI,eACJmH,MAAO,IACPC,OAASC,IACP,MAAM3F,EAASzB,SAASW,cAAc,UACtCc,EAAO2D,UAAY,gCACnB3D,EAAOK,MAAQ,aACfL,EAAO4F,KAAO,SAGdxE,KAAKyE,QAAQ7F,EAAQ,SAErBA,EAAOJ,iBACL,QACA,KACEwB,KAAKvB,SAEP,CAAEiG,OAAQ1E,KAAK2E,mBAGjBJ,EAAUrG,YAAYU,KAG5B"}
|
|
1
|
+
{"version":3,"file":"print.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/print/print-isolated.ts","../../../../../libs/grid/src/lib/plugins/print/PrintPlugin.ts"],"sourcesContent":["/**\n * Utility for printing a grid in isolation by hiding all other page content.\n *\n * This approach keeps the grid in place (with virtualization disabled by PrintPlugin)\n * and uses CSS to hide everything else on the page during printing.\n */\n\nimport { PRINT_DUPLICATE_ID, warnDiagnostic } from '../../core/internal/diagnostics';\nimport type { PrintOrientation } from './types';\n\nexport interface PrintIsolatedOptions {\n /** Page orientation hint */\n orientation?: PrintOrientation;\n}\n\n/** ID for the isolation stylesheet */\nconst ISOLATION_STYLE_ID = 'tbw-print-isolation-style';\n\n/**\n * Create a stylesheet that hides everything except the target grid.\n * Uses the grid's ID to target it specifically.\n */\nfunction createIsolationStylesheet(gridId: string, orientation: PrintOrientation): HTMLStyleElement {\n const style = document.createElement('style');\n style.id = ISOLATION_STYLE_ID;\n style.textContent = `\n /* Print isolation: hide everything except the target grid */\n @media print {\n /* Hide all body children by default */\n body > *:not(#${gridId}) {\n display: none !important;\n }\n\n /* But show the grid and ensure it's not hidden by ancestor rules */\n #${gridId} {\n display: block !important;\n position: static !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n width: 100% !important;\n max-height: none !important;\n margin: 0 !important;\n padding: 0 !important;\n transform: none !important;\n }\n\n /* If grid is nested, we need to show its ancestors too */\n #${gridId},\n #${gridId} * {\n visibility: visible !important;\n }\n\n /* Walk up the DOM and show all ancestors of the grid */\n body *:has(> #${gridId}),\n body *:has(#${gridId}) {\n display: block !important;\n visibility: visible !important;\n opacity: 1 !important;\n overflow: visible !important;\n height: auto !important;\n position: static !important;\n transform: none !important;\n background: transparent !important;\n border: none !important;\n padding: 0 !important;\n margin: 0 !important;\n }\n\n /* Hide siblings of ancestors (everything that's not in the path to the grid) */\n body *:has(#${gridId}) > *:not(:has(#${gridId})):not(#${gridId}) {\n display: none !important;\n }\n\n /* Page settings */\n @page {\n size: ${orientation};\n margin: 1cm;\n }\n\n /* Ensure proper print styling */\n body {\n margin: 0 !important;\n padding: 0 !important;\n background: white !important;\n color-scheme: light !important;\n }\n }\n\n /* Screen: also apply isolation for print preview */\n @media screen {\n /* When this stylesheet is active, we're about to print */\n /* No screen-specific rules needed - isolation only applies to print */\n }\n `;\n return style;\n}\n\n/**\n * Print a grid in isolation by hiding all other page content.\n *\n * This function adds a temporary stylesheet that uses CSS to hide everything\n * on the page except the target grid during printing. The grid stays in place\n * with all its data (virtualization should be disabled separately).\n *\n * @param gridElement - The tbw-grid element to print (must have an ID)\n * @param options - Optional configuration\n * @returns Promise that resolves when the print dialog closes\n *\n * @example\n * ```typescript\n * import { queryGrid } from '@toolbox-web/grid';\n * import { printGridIsolated } from '@toolbox-web/grid/plugins/print';\n *\n * const grid = queryGrid('tbw-grid');\n * await printGridIsolated(grid, { orientation: 'landscape' });\n * ```\n */\nexport async function printGridIsolated(gridElement: HTMLElement, options: PrintIsolatedOptions = {}): Promise<void> {\n const { orientation = 'landscape' } = options;\n\n const gridId = gridElement.id;\n\n // Warn if multiple elements share this ID (user-set IDs could collide)\n const elementsWithId = document.querySelectorAll(`#${CSS.escape(gridId)}`);\n if (elementsWithId.length > 1) {\n warnDiagnostic(\n PRINT_DUPLICATE_ID,\n `Multiple elements found with id=\"${gridId}\". ` +\n `Print isolation may not work correctly. Ensure each grid has a unique ID.`,\n gridId,\n 'print',\n );\n }\n\n // Remove any existing isolation stylesheet\n document.getElementById(ISOLATION_STYLE_ID)?.remove();\n\n // Add the isolation stylesheet\n const isolationStyle = createIsolationStylesheet(gridId, orientation);\n document.head.appendChild(isolationStyle);\n\n return new Promise((resolve) => {\n // Listen for afterprint event to cleanup\n const onAfterPrint = () => {\n window.removeEventListener('afterprint', onAfterPrint);\n // Remove isolation stylesheet\n document.getElementById(ISOLATION_STYLE_ID)?.remove();\n resolve();\n };\n window.addEventListener('afterprint', onAfterPrint);\n\n // Trigger print\n window.print();\n\n // Fallback timeout in case afterprint doesn't fire (some browsers)\n setTimeout(() => {\n window.removeEventListener('afterprint', onAfterPrint);\n document.getElementById(ISOLATION_STYLE_ID)?.remove();\n resolve();\n }, 5000);\n });\n}\n","/**\n * Print Plugin (Class-based)\n *\n * Provides print layout functionality for tbw-grid.\n * Temporarily disables virtualization to render all rows and uses\n * @media print CSS for print-optimized styling.\n */\n\nimport { PRINT_FAILED, PRINT_IN_PROGRESS, PRINT_NO_GRID, errorDiagnostic } from '../../core/internal/diagnostics';\nimport { BaseGridPlugin } from '../../core/plugin/base-plugin';\nimport type { InternalGrid, ToolbarContentDefinition } from '../../core/types';\nimport { printGridIsolated } from './print-isolated';\nimport styles from './print.css?inline';\nimport type { PrintCompleteDetail, PrintConfig, PrintParams, PrintStartDetail } from './types';\n\n/**\n * Extended grid interface for PrintPlugin internal access.\n * Includes registerToolbarContent which is available on the grid class\n * but not exposed in the standard plugin API.\n */\ninterface PrintGridRef extends InternalGrid {\n registerToolbarContent?(content: ToolbarContentDefinition): void;\n unregisterToolbarContent?(contentId: string): void;\n}\n\n/** Default configuration */\nconst DEFAULT_CONFIG: Required<PrintConfig> = {\n button: false,\n orientation: 'landscape',\n warnThreshold: 500,\n maxRows: 0,\n includeTitle: true,\n includeTimestamp: true,\n title: '',\n isolate: false,\n};\n\n/**\n * Print Plugin for tbw-grid\n *\n * Enables printing the full grid content by temporarily disabling virtualization\n * and applying print-optimized styles. Handles large datasets gracefully with\n * configurable row limits.\n *\n * ## Installation\n *\n * ```ts\n * import { PrintPlugin } from '@toolbox-web/grid/plugins/print';\n * ```\n *\n * ## Events\n *\n * | Event | Detail | Description |\n * |-------|--------|-------------|\n * | `print-start` | {@link PrintStartDetail} | Fired when print begins |\n * | `print-complete` | {@link PrintCompleteDetail} | Fired when print completes |\n *\n * @example Basic Print\n * ```ts\n * import { queryGrid } from '@toolbox-web/grid';\n * import { PrintPlugin } from '@toolbox-web/grid/plugins/print';\n *\n * const grid = queryGrid('tbw-grid');\n * grid.gridConfig = {\n * plugins: [new PrintPlugin()],\n * };\n *\n * // Trigger print\n * const printPlugin = grid.getPluginByName('print');\n * await printPlugin.print();\n * ```\n *\n * @example With Toolbar Button\n * ```ts\n * grid.gridConfig = {\n * plugins: [new PrintPlugin({ button: true, orientation: 'landscape' })],\n * };\n * ```\n *\n * @see {@link PrintConfig} for all configuration options\n */\nexport class PrintPlugin extends BaseGridPlugin<PrintConfig> {\n /** @internal */\n readonly name = 'print';\n\n /** @internal */\n override readonly version = '1.0.0';\n\n /** CSS styles for print mode */\n override readonly styles = styles;\n\n /** Current print state */\n #printing = false;\n\n /** Saved column visibility state */\n #savedHiddenColumns: Map<string, boolean> | null = null;\n\n /** Saved virtualization state */\n #savedVirtualization: { bypassThreshold: number } | null = null;\n\n /** Saved rows when maxRows limit is applied */\n #savedRows: unknown[] | null = null;\n\n /** Print header element */\n #printHeader: HTMLElement | null = null;\n\n /** Print footer element */\n #printFooter: HTMLElement | null = null;\n\n /** Applied scale factor (legacy, used for cleanup) */\n #appliedScale: number | null = null;\n\n /**\n * Get the grid typed as PrintGridRef for internal access.\n */\n get #internalGrid(): PrintGridRef {\n return this.grid as unknown as PrintGridRef;\n }\n\n /**\n * Check if print is currently in progress\n */\n isPrinting(): boolean {\n return this.#printing;\n }\n\n /**\n * Trigger the browser print dialog\n *\n * This method:\n * 1. Validates row count against maxRows limit\n * 2. Disables virtualization to render all rows\n * 3. Applies print-specific CSS classes\n * 4. Opens the browser print dialog (or isolated window if `isolate: true`)\n * 5. Restores normal state after printing\n *\n * @param params - Optional parameters to override config for this print\n * @param params.isolate - If true, prints in an isolated window containing only the grid\n * @returns Promise that resolves when print dialog closes\n */\n async print(params?: PrintParams): Promise<void> {\n if (this.#printing) {\n this.warn(PRINT_IN_PROGRESS, 'Print already in progress');\n return;\n }\n\n const grid = this.gridElement;\n if (!grid) {\n this.warn(PRINT_NO_GRID, 'Grid not available');\n return;\n }\n\n const config = { ...DEFAULT_CONFIG, ...this.config, ...params };\n const rows = this.rows;\n const originalRowCount = rows.length;\n let rowCount = originalRowCount;\n let limitApplied = false;\n\n // Check if we should warn about large datasets\n if (config.warnThreshold > 0 && originalRowCount > config.warnThreshold) {\n const limitInfo =\n config.maxRows > 0 ? `\\n\\nNote: Output will be limited to ${config.maxRows.toLocaleString()} rows.` : '';\n const proceed = confirm(\n `This grid has ${originalRowCount.toLocaleString()} rows. ` +\n `Printing large datasets may cause performance issues or browser slowdowns.${limitInfo}\\n\\n` +\n `Click OK to continue, or Cancel to abort.`,\n );\n if (!proceed) {\n return;\n }\n }\n\n // Apply hard row limit if configured\n if (config.maxRows > 0 && originalRowCount > config.maxRows) {\n rowCount = config.maxRows;\n limitApplied = true;\n }\n\n this.#printing = true;\n\n // Track timing for duration reporting\n const startTime = performance.now();\n\n // Emit print-start event\n this.emit<PrintStartDetail>('print-start', {\n rowCount,\n limitApplied,\n originalRowCount,\n });\n\n try {\n // Save current virtualization state\n const internalGrid = this.#internalGrid;\n this.#savedVirtualization = {\n bypassThreshold: internalGrid._virtualization?.bypassThreshold ?? 24,\n };\n\n // Hide columns marked with printHidden\n this.#hidePrintColumns();\n\n // Apply row limit if configured\n if (limitApplied) {\n this.#savedRows = this.sourceRows;\n // Set limited rows on the grid\n this.grid.rows = this.sourceRows.slice(0, rowCount);\n // Wait for grid to process new rows\n await new Promise((resolve) => setTimeout(resolve, 50));\n }\n\n // Add print header if configured\n if (config.includeTitle || config.includeTimestamp) {\n this.#addPrintHeader(config);\n }\n\n // Disable virtualization to render all rows\n // This forces the grid to render all rows in the DOM\n await this.#disableVirtualization();\n\n // Wait for next frame to ensure DOM is updated\n await new Promise((resolve) => requestAnimationFrame(resolve));\n await new Promise((resolve) => requestAnimationFrame(resolve));\n\n // Add orientation class for @page rules\n grid.classList.add(`print-${config.orientation}`);\n\n // Wait for next frame to ensure DOM is updated\n await new Promise((resolve) => requestAnimationFrame(resolve));\n await new Promise((resolve) => requestAnimationFrame(resolve));\n\n // Trigger browser print dialog (isolated or inline)\n if (config.isolate) {\n await this.#printInIsolatedWindow(config);\n } else {\n await this.#triggerPrint();\n }\n\n // Emit print-complete event\n this.emit<PrintCompleteDetail>('print-complete', {\n success: true,\n rowCount,\n duration: Math.round(performance.now() - startTime),\n });\n } catch (error) {\n errorDiagnostic(PRINT_FAILED, `Print failed: ${error}`, this.gridElement?.id, this.name);\n this.emit<PrintCompleteDetail>('print-complete', {\n success: false,\n rowCount: 0,\n duration: Math.round(performance.now() - startTime),\n });\n } finally {\n // Restore normal state\n this.#cleanup();\n this.#printing = false;\n }\n }\n\n /**\n * Add print header with title and timestamp\n */\n #addPrintHeader(config: Required<PrintConfig>): void {\n const grid = this.gridElement;\n if (!grid) return;\n\n // Create print header\n this.#printHeader = document.createElement('div');\n this.#printHeader.className = 'tbw-print-header';\n\n // Title\n if (config.includeTitle) {\n const title = config.title || this.grid.effectiveConfig?.shell?.header?.title || 'Grid Data';\n const titleEl = document.createElement('div');\n titleEl.className = 'tbw-print-header-title';\n titleEl.textContent = title;\n this.#printHeader.appendChild(titleEl);\n }\n\n // Timestamp\n if (config.includeTimestamp) {\n const timestampEl = document.createElement('div');\n timestampEl.className = 'tbw-print-header-timestamp';\n timestampEl.textContent = `Printed: ${new Date().toLocaleString()}`;\n this.#printHeader.appendChild(timestampEl);\n }\n\n // Insert at the beginning of the grid\n grid.insertBefore(this.#printHeader, grid.firstChild);\n\n // Create print footer\n this.#printFooter = document.createElement('div');\n this.#printFooter.className = 'tbw-print-footer';\n this.#printFooter.textContent = `Page generated from ${window.location.hostname}`;\n grid.appendChild(this.#printFooter);\n }\n\n /**\n * Disable virtualization to render all rows\n */\n async #disableVirtualization(): Promise<void> {\n const internalGrid = this.#internalGrid;\n if (!internalGrid._virtualization) return;\n\n // Set bypass threshold higher than total row count to disable virtualization\n // This makes the grid render all rows (up to maxRows) instead of just visible ones\n const totalRows = this.rows.length;\n internalGrid._virtualization.bypassThreshold = totalRows + 100;\n\n // Force a full refresh to re-render with virtualization disabled\n internalGrid.refreshVirtualWindow(true);\n\n // Wait for render to complete\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n\n /**\n * Trigger the browser print dialog\n */\n async #triggerPrint(): Promise<void> {\n return new Promise((resolve) => {\n // Listen for afterprint event\n const onAfterPrint = () => {\n window.removeEventListener('afterprint', onAfterPrint);\n resolve();\n };\n window.addEventListener('afterprint', onAfterPrint);\n\n // Trigger print\n window.print();\n\n // Fallback timeout in case afterprint doesn't fire (some browsers)\n setTimeout(() => {\n // Guard against test environment teardown where window may be undefined\n if (typeof window !== 'undefined') {\n window.removeEventListener('afterprint', onAfterPrint);\n }\n resolve();\n }, 1000);\n });\n }\n\n /**\n * Print in isolation by hiding all other page content.\n * This excludes navigation, sidebars, etc. while keeping the grid in place.\n */\n async #printInIsolatedWindow(config: Required<PrintConfig>): Promise<void> {\n const grid = this.gridElement;\n if (!grid) return;\n\n await printGridIsolated(grid, {\n orientation: config.orientation,\n });\n }\n\n /**\n * Hide columns marked with printHidden: true OR utility: true.\n *\n * Utility (system) columns — selection checkbox, expander, drag handle, custom\n * action menus, etc. — are excluded from print by default. Set `printHidden: false`\n * explicitly on a utility column if you need it to appear in the printout.\n */\n #hidePrintColumns(): void {\n const columns = this.columns;\n if (!columns) return;\n\n // Save current hidden state and hide print columns\n this.#savedHiddenColumns = new Map();\n\n for (const col of columns) {\n if (!col.field) continue;\n // Default: hide if printHidden === true OR utility === true.\n // Allow explicit opt-in for utility columns via `printHidden: false`.\n const shouldHide = col.printHidden === true || (col.utility === true && col.printHidden !== false);\n if (!shouldHide) continue;\n // Save current visibility state (true = visible, false = hidden)\n this.#savedHiddenColumns.set(col.field, !col.hidden);\n // Hide the column for printing\n this.grid.setColumnVisible(col.field, false);\n }\n }\n\n /**\n * Restore columns that were hidden for printing\n */\n #restorePrintColumns(): void {\n if (!this.#savedHiddenColumns) return;\n\n for (const [field, wasVisible] of this.#savedHiddenColumns) {\n // Restore original visibility\n this.grid.setColumnVisible(field, wasVisible);\n }\n\n this.#savedHiddenColumns = null;\n }\n\n /**\n * Cleanup after printing\n */\n #cleanup(): void {\n const grid = this.gridElement;\n if (!grid) return;\n\n // Restore columns that were hidden for printing\n this.#restorePrintColumns();\n\n // Remove orientation classes (both original and possibly switched)\n grid.classList.remove('print-portrait', 'print-landscape');\n\n // Remove scaling transform if applied (legacy)\n if (this.#appliedScale !== null) {\n grid.style.transform = '';\n grid.style.transformOrigin = '';\n grid.style.width = '';\n this.#appliedScale = null;\n }\n\n // Remove print header/footer\n if (this.#printHeader) {\n this.#printHeader.remove();\n this.#printHeader = null;\n }\n if (this.#printFooter) {\n this.#printFooter.remove();\n this.#printFooter = null;\n }\n\n // Restore virtualization\n const internalGrid = this.#internalGrid;\n if (this.#savedVirtualization && internalGrid._virtualization) {\n internalGrid._virtualization.bypassThreshold = this.#savedVirtualization.bypassThreshold;\n internalGrid.refreshVirtualWindow(true);\n this.#savedVirtualization = null;\n }\n\n // Restore original rows if they were limited\n if (this.#savedRows !== null) {\n this.grid.rows = this.#savedRows;\n this.#savedRows = null;\n }\n }\n\n /**\n * Register toolbar button if configured\n * @internal\n */\n override afterRender(): void {\n // Register toolbar on first render when button is enabled\n if (this.config?.button && !this.#toolbarRegistered) {\n this.#registerToolbarButton();\n this.#toolbarRegistered = true;\n }\n }\n\n /** Track if toolbar button is registered */\n #toolbarRegistered = false;\n\n /**\n * Register print button in toolbar\n */\n #registerToolbarButton(): void {\n const grid = this.#internalGrid;\n\n // Register toolbar content\n grid.registerToolbarContent?.({\n id: 'print-button',\n order: 900, // High order to appear at the end\n render: (container: HTMLElement) => {\n const button = document.createElement('button');\n button.className = 'tbw-toolbar-btn tbw-print-btn';\n button.title = 'Print grid';\n button.type = 'button';\n\n // Use print icon\n this.setIcon(button, 'print');\n\n button.addEventListener(\n 'click',\n () => {\n this.print();\n },\n { signal: this.disconnectSignal },\n );\n\n container.appendChild(button);\n },\n });\n }\n}\n"],"names":["ISOLATION_STYLE_ID","async","printGridIsolated","gridElement","options","orientation","gridId","id","document","querySelectorAll","CSS","escape","length","warnDiagnostic","PRINT_DUPLICATE_ID","getElementById","remove","isolationStyle","style","createElement","textContent","createIsolationStylesheet","head","appendChild","Promise","resolve","onAfterPrint","window","removeEventListener","addEventListener","print","setTimeout","DEFAULT_CONFIG","button","warnThreshold","maxRows","includeTitle","includeTimestamp","title","isolate","PrintPlugin","BaseGridPlugin","name","version","styles","printing","savedHiddenColumns","savedVirtualization","savedRows","printHeader","printFooter","appliedScale","internalGrid","this","grid","isPrinting","params","warn","PRINT_IN_PROGRESS","PRINT_NO_GRID","config","originalRowCount","rows","rowCount","limitApplied","limitInfo","toLocaleString","confirm","startTime","performance","now","emit","bypassThreshold","_virtualization","hidePrintColumns","sourceRows","slice","addPrintHeader","disableVirtualization","requestAnimationFrame","classList","add","printInIsolatedWindow","triggerPrint","success","duration","Math","round","error","errorDiagnostic","PRINT_FAILED","cleanup","className","effectiveConfig","shell","header","titleEl","timestampEl","Date","insertBefore","firstChild","location","hostname","totalRows","refreshVirtualWindow","columns","Map","col","field","printHidden","utility","set","hidden","setColumnVisible","restorePrintColumns","wasVisible","transform","transformOrigin","width","afterRender","toolbarRegistered","registerToolbarButton","registerToolbarContent","order","render","container","type","setIcon","signal","disconnectSignal"],"mappings":"waAgBA,MAAMA,EAAqB,4BAuG3BC,eAAsBC,EAAkBC,EAA0BC,EAAgC,IAChG,MAAMC,YAAEA,EAAc,aAAgBD,EAEhCE,EAASH,EAAYI,GAGJC,SAASC,iBAAiB,IAAIC,IAAIC,OAAOL,MAC7CM,OAAS,GAC1BC,EAAAA,eACEC,EAAAA,mBACA,oCAAoCR,gFAEpCA,EACA,SAKJE,SAASO,eAAef,IAAqBgB,SAG7C,MAAMC,EAtHR,SAAmCX,EAAgBD,GACjD,MAAMa,EAAQV,SAASW,cAAc,SAyErC,OAxEAD,EAAMX,GAAKP,EACXkB,EAAME,YAAc,+JAIAd,0IAKbA,meAeAA,cACAA,kJAKaA,0BACFA,6gBAeAA,oBAAyBA,YAAiBA,+GAM9CD,yeAmBPa,CACT,CA2CyBG,CAA0Bf,EAAQD,GAGzD,OAFAG,SAASc,KAAKC,YAAYN,GAEnB,IAAIO,QAASC,IAElB,MAAMC,EAAe,KACnBC,OAAOC,oBAAoB,aAAcF,GAEzClB,SAASO,eAAef,IAAqBgB,SAC7CS,KAEFE,OAAOE,iBAAiB,aAAcH,GAGtCC,OAAOG,QAGPC,WAAW,KACTJ,OAAOC,oBAAoB,aAAcF,GACzClB,SAASO,eAAef,IAAqBgB,SAC7CS,KACC,MAEP,OCzIMO,EAAwC,CAC5CC,QAAQ,EACR5B,YAAa,YACb6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
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("../../core/constants"),require("../../core/internal/keyboard"),require("../../core/plugin/base-plugin")):"function"==typeof define&&define.amd?define(["exports","../../core/constants","../../core/internal/keyboard","../../core/plugin/base-plugin"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TbwGridPlugin_reorderColumns={},e.TbwGrid,e.TbwGrid,e.TbwGrid)}(this,function(e,t,r,i){"use strict";function n(e,t,r){if(t===r)return e;if(t<0||t>=e.length)return e;if(r<0||r>e.length)return e;const i=[...e],[n]=i.splice(t,1);return i.splice(r,0,n),i}class d extends i.BaseGridPlugin{name="reorderColumns";aliases=["reorder"];styles='@layer tbw-plugins{.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.cell.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}@keyframes reorder-fade-in{0%{opacity:0}to{opacity:1}}.cell.fade-animating{animation:reorder-fade-in var(--tbw-animation-duration, .2s) ease-out backwards}}';get defaultConfig(){return{animation:"flip"}}get animationType(){return!!this.isAnimationEnabled&&(void 0!==this.config.animation?this.config.animation:"flip")}get animationDuration(){return void 0!==this.config.animationDuration?this.config.animationDuration:super.animationDuration}isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;draggedGroupFields=[];get#e(){return this.grid}canMoveColumnWithPlugins(e){if(!e||!function(e){const t=e.meta??{};return!0!==t.lockPosition&&!0!==t.suppressMovable}(e))return!1;return!this.grid.query("canMoveColumn",e).includes(!1)}clearDragClasses(){this.gridElement?.querySelectorAll(".header-row > .cell, .header-group-row > .cell").forEach(e=>{e.classList.remove(t.GridClasses.DRAGGING,"drop-target","drop-before","drop-after")})}attach(e){super.attach(e),this.gridElement.addEventListener("column-reorder-request",e=>{const t=e.detail;t?.field&&"number"==typeof t.toIndex&&this.moveColumn(t.field,t.toIndex)},{signal:this.disconnectSignal})}detach(){this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,this.draggedGroupFields=[]}afterRender(){const e=this.gridElement;if(!e)return;e.querySelectorAll(".header-row > .cell").forEach(e=>{const r=e,i=r.getAttribute("data-field");if(!i)return;const d=this.columns.find(e=>e.field===i);this.canMoveColumnWithPlugins(d)?(r.draggable=!0,r.getAttribute("data-dragstart-bound")||(r.setAttribute("data-dragstart-bound","true"),r.addEventListener("dragstart",e=>{const n=this.getColumnOrder().indexOf(i);this.isDragging=!0,this.draggedField=i,this.draggedIndex=n,this.draggedGroupFields=[],e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",i)),r.classList.add(t.GridClasses.DRAGGING)}),r.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,this.draggedGroupFields=[],this.clearDragClasses()}),r.addEventListener("dragover",e=>{if(e.preventDefault(),!this.isDragging)return;if(this.draggedField===i&&0===this.draggedGroupFields.length)return;if(this.draggedGroupFields.includes(i))return;const n=r.getBoundingClientRect(),d=n.left+n.width/2,s=this.getColumnOrder().indexOf(i);if(this.dropIndex=e.clientX<d?s:s+1,this.clearDragClasses(),this.draggedGroupFields.length>0)for(const r of this.draggedGroupFields)this.gridElement?.querySelector(`.header-row > .cell[data-field="${r}"]`)?.classList.add(t.GridClasses.DRAGGING);else this.draggedField&&this.gridElement?.querySelector(`.header-row > .cell[data-field="${this.draggedField}"]`)?.classList.add(t.GridClasses.DRAGGING);r.classList.add("drop-target"),r.classList.toggle("drop-before",e.clientX<d),r.classList.toggle("drop-after",e.clientX>=d)}),r.addEventListener("dragleave",()=>{r.classList.remove("drop-target","drop-before","drop-after")}),r.addEventListener("drop",e=>{if(e.preventDefault(),!this.isDragging)return;if(this.draggedGroupFields.length>0){if(this.draggedGroupFields.includes(i))return;const t=r.getBoundingClientRect(),n=e.clientX<t.left+t.width/2;return void this.executeGroupBlockMove(this.draggedGroupFields,[i],n)}const t=this.draggedField,d=this.draggedIndex,s=this.dropIndex;if(!this.isDragging||null===t||null===d||null===s)return;const a=s>d?s-1:s,o=n(this.getColumnOrder(),d,a),l={field:t,fromIndex:d,toIndex:a,columnOrder:o};this.emitCancelable("column-move",l)||this.updateColumnOrder(o)}))):r.draggable=!1}),queueMicrotask(()=>this.setupGroupHeaderDrag(e))}setupGroupHeaderDrag(e){e.querySelectorAll(".header-group-row > .cell[data-group]").forEach(r=>{const i=r,d=i.getAttribute("data-group");if(!d||d.startsWith("__implicit__"))return;if(i.getAttribute("data-group-drag-bound"))return;i.setAttribute("data-group-drag-bound","true");const s=this.getGroupFragmentFields(i,d);if(0===s.length)return;s.every(e=>{const t=this.columns.find(t=>t.field===e);return this.canMoveColumnWithPlugins(t)})&&(i.draggable=!0,i.style.cursor="grab",i.addEventListener("dragstart",r=>{this.isDragging=!0,this.draggedField=null,this.draggedIndex=null,this.draggedGroupFields=[...s],r.dataTransfer&&(r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",`group:${d}`)),i.classList.add(t.GridClasses.DRAGGING);for(const i of s)e.querySelector(`.header-row > .cell[data-field="${i}"]`)?.classList.add(t.GridClasses.DRAGGING)}),i.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,this.draggedGroupFields=[],this.clearDragClasses()}),i.addEventListener("dragover",e=>{if(e.preventDefault(),!this.isDragging)return;if(this.draggedGroupFields.length>0&&this.draggedGroupFields.length===s.length&&this.draggedGroupFields.every(e=>s.includes(e)))return;const t=i.getBoundingClientRect(),r=t.left+t.width/2,n=e.clientX<r;this.clearDragClasses(),i.classList.add("drop-target"),i.classList.toggle("drop-before",n),i.classList.toggle("drop-after",!n)}),i.addEventListener("dragleave",()=>{i.classList.remove("drop-target","drop-before","drop-after")}),i.addEventListener("drop",e=>{if(e.preventDefault(),!this.isDragging)return;const t=i.getBoundingClientRect(),r=e.clientX<t.left+t.width/2;if(this.draggedGroupFields.length>0){if(this.draggedGroupFields.length===s.length&&this.draggedGroupFields.every(e=>s.includes(e)))return;this.executeGroupBlockMove(this.draggedGroupFields,s,r)}else if(this.draggedField){const e=this.getColumnOrder(),t=r?s[0]:s[s.length-1],i=e.indexOf(this.draggedField),d=r?e.indexOf(t):e.indexOf(t)+1;if(-1===i||-1===d)return;const a=d>i?d-1:d,o=n(e,i,a);this.emitCancelable("column-move",{field:this.draggedField,fromIndex:i,toIndex:a,columnOrder:o})||this.updateColumnOrder(o)}}))})}getGroupFragmentFields(e,t){const r=e.style.gridColumn,i=/(\d+)\s*\/\s*span\s+(\d+)/.exec(r);if(!i)return[];const n=parseInt(i[1],10),d=parseInt(i[2],10),s=this.visibleColumns,a=[];for(let o=n-1;o<n-1+d&&o<s.length;o++){const e=s[o];e&&a.push(e.field)}return a}executeGroupBlockMove(e,t,r){const i=this.getColumnOrder(),n=i.filter(t=>!e.includes(t)),d=r?t[0]:t[t.length-1],s=n.indexOf(d);if(-1===s)return;const a=r?s:s+1,o=i.filter(t=>e.includes(t));n.splice(a,0,...o);this.emitCancelable("column-move",{field:e[0],fromIndex:i.indexOf(e[0]),toIndex:a,columnOrder:n})||this.updateColumnOrder(n)}onKeyDown(e){if(!e.altKey||"ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;const t=this.#e,i=t._focusCol,n=t._visibleColumns;if(i<0||i>=n.length)return;const d=n[i];if(!this.canMoveColumnWithPlugins(d))return;const s=this.getColumnOrder(),a=s.indexOf(d.field);if(-1===a)return;const o="ArrowLeft"===e.key?a-1:a+1;if(o<0||o>=s.length)return;const l=n.find(e=>e.field===s[o]);return this.canMoveColumnWithPlugins(l)?(this.moveColumn(d.field,o),t._focusCol=o,r.ensureCellVisible(this.#e),e.preventDefault(),e.stopPropagation(),!0):void 0}getColumnOrder(){return this.grid.getColumnOrder()}moveColumn(e,t){const r=this.getColumnOrder(),i=r.indexOf(e);if(-1===i)return;const d=n(r,i,t);this.emitCancelable("column-move",{field:e,fromIndex:i,toIndex:t,columnOrder:d})||this.updateColumnOrder(d)}setColumnOrder(e){this.updateColumnOrder(e)}resetColumnOrder(){const e=this.columns.map(e=>e.field);this.updateColumnOrder(e)}captureHeaderPositions(){const e=new Map;return this.gridElement?.querySelectorAll(".header-row > .cell[data-field]").forEach(t=>{const r=t.getAttribute("data-field");r&&e.set(r,t.getBoundingClientRect().left)}),e}animateFLIP(e){const t=this.gridElement;if(!t||0===e.size)return;const r=new Map;if(t.querySelectorAll(".header-row > .cell[data-field]").forEach(t=>{const i=t.getAttribute("data-field");if(!i)return;const n=e.get(i);if(void 0===n)return;const d=n-t.getBoundingClientRect().left;Math.abs(d)>1&&r.set(i,d)}),0===r.size)return;const i=[];if(t.querySelectorAll(".cell[data-field]").forEach(e=>{const t=r.get(e.getAttribute("data-field")??"");if(void 0!==t){const r=e;r.style.transform=`translateX(${t}px)`,i.push(r)}}),0===i.length)return;t.offsetHeight;const n=this.animationDuration;requestAnimationFrame(()=>{i.forEach(e=>{e.classList.add("flip-animating"),e.style.transform=""}),setTimeout(()=>{i.forEach(e=>{e.style.transform="",e.classList.remove("flip-animating")})},n+50)})}animateFade(e){const t=this.gridElement;if(!t)return void e();const r=this.captureHeaderPositions();e();const i=new Set;if(t.querySelectorAll(".header-row > .cell[data-field]").forEach(e=>{const t=e.getAttribute("data-field");if(!t)return;const n=r.get(t);if(void 0===n)return;const d=e.getBoundingClientRect().left;Math.abs(n-d)>1&&i.add(t)}),0===i.size)return;const n=[];if(t.querySelectorAll(".cell[data-field]").forEach(e=>{const t=e.getAttribute("data-field");if(t&&i.has(t)){const t=e;t.classList.add("fade-animating"),n.push(t)}}),0===n.length)return;const d=this.animationDuration;setTimeout(()=>{n.forEach(e=>e.classList.remove("fade-animating"))},d+50)}updateColumnOrder(e){const t=this.animationType;if("flip"===t&&this.gridElement){const t=this.captureHeaderPositions();this.grid.setColumnOrder(e),"function"==typeof this.grid.forceLayout?this.grid.forceLayout().then(()=>{this.animateFLIP(t)}):requestAnimationFrame(()=>{this.animateFLIP(t)})}else"fade"===t?this.animateFade(()=>this.grid.setColumnOrder(e)):this.grid.setColumnOrder(e);this.grid.requestStateChange?.()}}e.ReorderPlugin=d,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("../../core/constants"),require("../../core/internal/keyboard"),require("../../core/plugin/base-plugin")):"function"==typeof define&&define.amd?define(["exports","../../core/constants","../../core/internal/keyboard","../../core/plugin/base-plugin"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TbwGridPlugin_reorderColumns={},e.TbwGrid,e.TbwGrid,e.TbwGrid)}(this,function(e,t,r,i){"use strict";function n(e){if(!0===e.lockPosition)return!1;if(!0===e.utility)return!1;const t=e.meta??{};return!0!==t.lockPosition&&!0!==t.suppressMovable}function s(e,t,r){if(t===r)return e;if(t<0||t>=e.length)return e;if(r<0||r>e.length)return e;const i=[...e],[n]=i.splice(t,1);return i.splice(r,0,n),i}const d="canMoveColumn";class a extends i.BaseGridPlugin{name="reorderColumns";aliases=["reorder"];styles='@layer tbw-plugins{.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.cell.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}@keyframes reorder-fade-in{0%{opacity:0}to{opacity:1}}.cell.fade-animating{animation:reorder-fade-in var(--tbw-animation-duration, .2s) ease-out backwards}}';static manifest={queries:[{type:d,description:"Authoritative check for whether a column may be reordered (honors lockPosition)."}]};handleQuery(e){if(e.type===d){const t=e.context;return t?n(t):void 0}}get defaultConfig(){return{animation:"flip"}}get animationType(){return!!this.isAnimationEnabled&&(void 0!==this.config.animation?this.config.animation:"flip")}get animationDuration(){return void 0!==this.config.animationDuration?this.config.animationDuration:super.animationDuration}isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;draggedGroupFields=[];get#e(){return this.grid}canMoveColumnWithPlugins(e){if(!e||!n(e))return!1;return!this.grid.query(d,e).includes(!1)}clearDragClasses(){this.gridElement?.querySelectorAll(".header-row > .cell, .header-group-row > .cell").forEach(e=>{e.classList.remove(t.GridClasses.DRAGGING,"drop-target","drop-before","drop-after")})}attach(e){super.attach(e),this.gridElement.addEventListener("column-reorder-request",e=>{const t=e.detail;t?.field&&"number"==typeof t.toIndex&&this.moveColumn(t.field,t.toIndex)},{signal:this.disconnectSignal})}detach(){this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,this.draggedGroupFields=[]}afterRender(){const e=this.gridElement;if(!e)return;e.querySelectorAll(".header-row > .cell").forEach(e=>{const r=e,i=r.getAttribute("data-field");if(!i)return;const n=this.columns.find(e=>e.field===i);this.canMoveColumnWithPlugins(n)?(r.draggable=!0,r.getAttribute("data-dragstart-bound")||(r.setAttribute("data-dragstart-bound","true"),r.addEventListener("dragstart",e=>{const n=this.getColumnOrder().indexOf(i);this.isDragging=!0,this.draggedField=i,this.draggedIndex=n,this.draggedGroupFields=[],e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",i)),r.classList.add(t.GridClasses.DRAGGING)}),r.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,this.draggedGroupFields=[],this.clearDragClasses()}),r.addEventListener("dragover",e=>{if(e.preventDefault(),!this.isDragging)return;if(this.draggedField===i&&0===this.draggedGroupFields.length)return;if(this.draggedGroupFields.includes(i))return;const n=r.getBoundingClientRect(),s=n.left+n.width/2,d=this.getColumnOrder().indexOf(i);if(this.dropIndex=e.clientX<s?d:d+1,this.clearDragClasses(),this.draggedGroupFields.length>0)for(const r of this.draggedGroupFields)this.gridElement?.querySelector(`.header-row > .cell[data-field="${r}"]`)?.classList.add(t.GridClasses.DRAGGING);else this.draggedField&&this.gridElement?.querySelector(`.header-row > .cell[data-field="${this.draggedField}"]`)?.classList.add(t.GridClasses.DRAGGING);r.classList.add("drop-target"),r.classList.toggle("drop-before",e.clientX<s),r.classList.toggle("drop-after",e.clientX>=s)}),r.addEventListener("dragleave",()=>{r.classList.remove("drop-target","drop-before","drop-after")}),r.addEventListener("drop",e=>{if(e.preventDefault(),!this.isDragging)return;if(this.draggedGroupFields.length>0){if(this.draggedGroupFields.includes(i))return;const t=r.getBoundingClientRect(),n=e.clientX<t.left+t.width/2;return void this.executeGroupBlockMove(this.draggedGroupFields,[i],n)}const t=this.draggedField,n=this.draggedIndex,d=this.dropIndex;if(!this.isDragging||null===t||null===n||null===d)return;const a=d>n?d-1:d,o=s(this.getColumnOrder(),n,a),l={field:t,fromIndex:n,toIndex:a,columnOrder:o};this.emitCancelable("column-move",l)||this.updateColumnOrder(o)}))):r.draggable=!1}),queueMicrotask(()=>this.setupGroupHeaderDrag(e))}setupGroupHeaderDrag(e){e.querySelectorAll(".header-group-row > .cell[data-group]").forEach(r=>{const i=r,n=i.getAttribute("data-group");if(!n||n.startsWith("__implicit__"))return;if(i.getAttribute("data-group-drag-bound"))return;i.setAttribute("data-group-drag-bound","true");const d=this.getGroupFragmentFields(i,n);if(0===d.length)return;d.every(e=>{const t=this.columns.find(t=>t.field===e);return this.canMoveColumnWithPlugins(t)})&&(i.draggable=!0,i.style.cursor="grab",i.addEventListener("dragstart",r=>{this.isDragging=!0,this.draggedField=null,this.draggedIndex=null,this.draggedGroupFields=[...d],r.dataTransfer&&(r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",`group:${n}`)),i.classList.add(t.GridClasses.DRAGGING);for(const i of d)e.querySelector(`.header-row > .cell[data-field="${i}"]`)?.classList.add(t.GridClasses.DRAGGING)}),i.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,this.draggedGroupFields=[],this.clearDragClasses()}),i.addEventListener("dragover",e=>{if(e.preventDefault(),!this.isDragging)return;if(this.draggedGroupFields.length>0&&this.draggedGroupFields.length===d.length&&this.draggedGroupFields.every(e=>d.includes(e)))return;const t=i.getBoundingClientRect(),r=t.left+t.width/2,n=e.clientX<r;this.clearDragClasses(),i.classList.add("drop-target"),i.classList.toggle("drop-before",n),i.classList.toggle("drop-after",!n)}),i.addEventListener("dragleave",()=>{i.classList.remove("drop-target","drop-before","drop-after")}),i.addEventListener("drop",e=>{if(e.preventDefault(),!this.isDragging)return;const t=i.getBoundingClientRect(),r=e.clientX<t.left+t.width/2;if(this.draggedGroupFields.length>0){if(this.draggedGroupFields.length===d.length&&this.draggedGroupFields.every(e=>d.includes(e)))return;this.executeGroupBlockMove(this.draggedGroupFields,d,r)}else if(this.draggedField){const e=this.getColumnOrder(),t=r?d[0]:d[d.length-1],i=e.indexOf(this.draggedField),n=r?e.indexOf(t):e.indexOf(t)+1;if(-1===i||-1===n)return;const a=n>i?n-1:n,o=s(e,i,a);this.emitCancelable("column-move",{field:this.draggedField,fromIndex:i,toIndex:a,columnOrder:o})||this.updateColumnOrder(o)}}))})}getGroupFragmentFields(e,t){const r=e.style.gridColumn,i=/(\d+)\s*\/\s*span\s+(\d+)/.exec(r);if(!i)return[];const n=parseInt(i[1],10),s=parseInt(i[2],10),d=this.visibleColumns,a=[];for(let o=n-1;o<n-1+s&&o<d.length;o++){const e=d[o];e&&a.push(e.field)}return a}executeGroupBlockMove(e,t,r){const i=this.getColumnOrder(),n=i.filter(t=>!e.includes(t)),s=r?t[0]:t[t.length-1],d=n.indexOf(s);if(-1===d)return;const a=r?d:d+1,o=i.filter(t=>e.includes(t));n.splice(a,0,...o);this.emitCancelable("column-move",{field:e[0],fromIndex:i.indexOf(e[0]),toIndex:a,columnOrder:n})||this.updateColumnOrder(n)}onKeyDown(e){if(!e.altKey||"ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;const t=this.#e,i=t._focusCol,n=t._visibleColumns;if(i<0||i>=n.length)return;const s=n[i];if(!this.canMoveColumnWithPlugins(s))return;const d=this.getColumnOrder(),a=d.indexOf(s.field);if(-1===a)return;const o="ArrowLeft"===e.key?a-1:a+1;if(o<0||o>=d.length)return;const l=n.find(e=>e.field===d[o]);return this.canMoveColumnWithPlugins(l)?(this.moveColumn(s.field,o),t._focusCol=o,r.ensureCellVisible(this.#e),e.preventDefault(),e.stopPropagation(),!0):void 0}getColumnOrder(){return this.grid.getColumnOrder()}moveColumn(e,t){const r=this.getColumnOrder(),i=r.indexOf(e);if(-1===i)return;const n=s(r,i,t);this.emitCancelable("column-move",{field:e,fromIndex:i,toIndex:t,columnOrder:n})||this.updateColumnOrder(n)}setColumnOrder(e){this.updateColumnOrder(e)}resetColumnOrder(){const e=this.columns.map(e=>e.field);this.updateColumnOrder(e)}captureHeaderPositions(){const e=new Map;return this.gridElement?.querySelectorAll(".header-row > .cell[data-field]").forEach(t=>{const r=t.getAttribute("data-field");r&&e.set(r,t.getBoundingClientRect().left)}),e}animateFLIP(e){const t=this.gridElement;if(!t||0===e.size)return;const r=new Map;if(t.querySelectorAll(".header-row > .cell[data-field]").forEach(t=>{const i=t.getAttribute("data-field");if(!i)return;const n=e.get(i);if(void 0===n)return;const s=n-t.getBoundingClientRect().left;Math.abs(s)>1&&r.set(i,s)}),0===r.size)return;const i=[];if(t.querySelectorAll(".cell[data-field]").forEach(e=>{const t=r.get(e.getAttribute("data-field")??"");if(void 0!==t){const r=e;r.style.transform=`translateX(${t}px)`,i.push(r)}}),0===i.length)return;t.offsetHeight;const n=this.animationDuration;requestAnimationFrame(()=>{i.forEach(e=>{e.classList.add("flip-animating"),e.style.transform=""}),setTimeout(()=>{i.forEach(e=>{e.style.transform="",e.classList.remove("flip-animating")})},n+50)})}animateFade(e){const t=this.gridElement;if(!t)return void e();const r=this.captureHeaderPositions();e();const i=new Set;if(t.querySelectorAll(".header-row > .cell[data-field]").forEach(e=>{const t=e.getAttribute("data-field");if(!t)return;const n=r.get(t);if(void 0===n)return;const s=e.getBoundingClientRect().left;Math.abs(n-s)>1&&i.add(t)}),0===i.size)return;const n=[];if(t.querySelectorAll(".cell[data-field]").forEach(e=>{const t=e.getAttribute("data-field");if(t&&i.has(t)){const t=e;t.classList.add("fade-animating"),n.push(t)}}),0===n.length)return;const s=this.animationDuration;setTimeout(()=>{n.forEach(e=>e.classList.remove("fade-animating"))},s+50)}updateColumnOrder(e){const t=this.animationType;if("flip"===t&&this.gridElement){const t=this.captureHeaderPositions();this.grid.setColumnOrder(e),"function"==typeof this.grid.forceLayout?this.grid.forceLayout().then(()=>{this.animateFLIP(t)}):requestAnimationFrame(()=>{this.animateFLIP(t)})}else"fade"===t?this.animateFade(()=>this.grid.setColumnOrder(e)):this.grid.setColumnOrder(e);this.grid.requestStateChange?.()}}e.ReorderPlugin=a,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=reorder-columns.umd.js.map
|