@toolbox-web/grid 1.31.2 → 2.0.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +2 -2
- package/all.js.map +1 -1
- package/custom-elements.json +0 -11
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +1 -29
- package/lib/core/internal/aggregators.bench.d.ts +1 -0
- package/lib/core/internal/aggregators.d.ts +0 -5
- package/lib/core/internal/aria.d.ts +13 -1
- package/lib/core/internal/config.bench.d.ts +1 -0
- package/lib/core/internal/diagnostics.d.ts +1 -3
- package/lib/core/internal/render-pipeline.bench.d.ts +9 -0
- package/lib/core/internal/shell.d.ts +0 -2
- package/lib/core/internal/sorting.bench.d.ts +1 -0
- package/lib/core/internal/virtualization.bench.d.ts +1 -0
- package/lib/core/plugin/base-plugin.d.ts +0 -116
- package/lib/core/plugin/index.d.ts +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +0 -25
- package/lib/core/plugin/types.d.ts +0 -35
- package/lib/core/styles/index.d.ts +0 -1
- package/lib/core/types.d.ts +93 -25
- package/lib/features/multi-sort.d.ts +0 -2
- package/lib/features/multi-sort.js.map +1 -1
- package/lib/features/registry.d.ts +0 -1
- package/lib/features/registry.js +1 -1
- package/lib/features/registry.js.map +1 -1
- package/lib/features/reorder-columns.d.ts +0 -2
- package/lib/features/reorder-columns.js +1 -1
- package/lib/features/reorder-columns.js.map +1 -1
- package/lib/features/reorder-rows.d.ts +0 -2
- package/lib/features/reorder-rows.js +1 -1
- package/lib/features/reorder-rows.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/column-virtualization.bench.d.ts +1 -0
- 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.d.ts +1 -1
- package/lib/plugins/editing/index.js +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/editing/types.d.ts +0 -9
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/filter-model.bench.d.ts +1 -0
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/grouping-columns.bench.d.ts +1 -0
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/grouping-rows.bench.d.ts +1 -0
- package/lib/plugins/grouping-rows/grouping-rows.d.ts +3 -3
- package/lib/plugins/grouping-rows/index.js +2 -2
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/grouping-rows/types.d.ts +0 -2
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +0 -14
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/master-detail.bench.d.ts +1 -0
- package/lib/plugins/master-detail/master-detail.d.ts +3 -3
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.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/pinned-columns.bench.d.ts +1 -0
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +3 -6
- package/lib/plugins/pinned-columns/types.d.ts +0 -12
- package/lib/plugins/pinned-rows/index.js +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pinned-rows/pinned-rows.d.ts +0 -1
- package/lib/plugins/pivot/index.js +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/pivot/pivot-engine.bench.d.ts +1 -0
- package/lib/plugins/pivot/pivot-engine.d.ts +1 -4
- package/lib/plugins/print/index.js +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder-columns/index.js +1 -1
- package/lib/plugins/reorder-columns/index.js.map +1 -1
- package/lib/plugins/reorder-columns/types.d.ts +0 -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 +0 -4
- package/lib/plugins/responsive/ResponsivePlugin.d.ts +0 -23
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +2 -0
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/datasource.bench.d.ts +1 -0
- package/lib/plugins/server-side/index.js +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tooltip/index.js +1 -1
- package/lib/plugins/tooltip/index.js.map +1 -1
- package/lib/plugins/tree/index.js +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/tree-data.bench.d.ts +1 -0
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +3 -6
- 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/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.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/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/responsive.umd.js +1 -1
- package/umd/plugins/responsive.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.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// Keep deprecated imports working (StickyPosition = PinnedPosition)\ntype StickyPosition = PinnedPosition;\ntype ResolvedStickyPosition = ResolvedPinnedPosition;\n\n/**\n * Get the effective pinned position from a column, checking `pinned` first then `sticky` (deprecated).\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.sticky ?? col.meta?.pinned ?? col.meta?.sticky;\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: StickyPosition, direction: TextDirection): ResolvedStickyPosition {\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 return columns.some((col) => getColumnPinned(col) != null);\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): StickyPosition | 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 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 property: 'sticky',\n level: 'column',\n description: 'the \"sticky\" column property (deprecated, use \"pinned\")',\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 (sticky) columns from being moved/reordered',\n },\n {\n type: 'getStickyOffsets',\n description: 'Returns the sticky 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 delete (copy as ColumnConfig & { sticky?: PinnedPosition }).sticky;\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 delete (copy as ColumnConfig & { sticky?: PinnedPosition }).sticky;\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","sticky","meta","resolveStickyPosition","position","direction","resolveInlinePosition","isResolvedLeft","isResolvedRight","hasStickyColumns","columns","some","applyStickyOffsets","host","emptyResult","groupEndAdjustments","addGroupEnd","Set","removeGroupEnd","leftOffsets","Map","rightOffsets","splitGroups","headerCells","Array","from","querySelectorAll","length","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","someRight","splitMixedPinExplicitGroup","applyGroupHeaderStickyOffsets","size","hCell","remove","getPinState","runs","i","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","ownedProperties","property","level","description","isUsed","v","queries","type","name","defaultConfig","isApplied","originalColumnOrder","detach","this","clear","detect","rows","config","isArray","processColumns","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":"ueAsBO,SAASA,EAAgBC,GAC9B,OAAOA,EAAIC,QAAUD,EAAIE,QAAUF,EAAIG,MAAMF,QAAUD,EAAIG,MAAMD,MACnE,CAaO,SAASE,EAAsBC,EAA0BC,GAC9D,OAAOC,EAAAA,sBAAsBF,EAAUC,EACzC,CAKA,SAASE,EAAeR,EAAUM,GAChC,MAAML,EAASF,EAAgBC,GAC/B,QAAKC,GAC+C,SAA7CG,EAAsBH,EAAQK,EACvC,CAKA,SAASG,EAAgBT,EAAUM,GACjC,MAAML,EAASF,EAAgBC,GAC/B,QAAKC,GAC+C,UAA7CG,EAAsBH,EAAQK,EACvC,CA8BO,SAASI,EAAiBC,GAC/B,OAAOA,EAAQC,KAAMZ,GAAgC,MAAxBD,EAAgBC,GAC/C,CA4HO,SAASa,EAAmBC,EAAmBH,GACpD,MAAMI,EAAmC,CACvCC,oBAAqB,CAAEC,YAAa,IAAIC,IAAOC,eAAgB,IAAID,KACnEE,gBAAiBC,IACjBC,iBAAkBD,IAClBE,YAAa,IAITC,EAAcC,MAAMC,KAAKZ,EAAKa,iBAAiB,sBACrD,IAAKH,EAAYI,OAAQ,OAAOb,EAGhC,MAAMT,EAAYuB,EAAAA,aAAaf,GAGzBM,MAAkBC,IAClBC,MAAmBD,IAGzB,IAAIS,EAAO,EACX,IAAA,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gBL,EAA2B,OAC9E,OAAOK,EAAQgM,OAAQ3M,GAAQQ,EAAeR,EAAKM,GACrD,CCqcWsM,CAFS,IAAI/D,KAAKlI,SACPkB,EAAAA,aAAagH,KAAKO,aAEtC,CAKA,qBAAAyD,GAGE,ODrcG,SAA+BlM,EAAgBL,EAA2B,OAC/E,OAAOK,EAAQgM,OAAQ3M,GAAQS,EAAgBT,EAAKM,GACtD,CCmcWwM,CAFS,IAAIjE,KAAKlI,SACPkB,EAAAA,aAAagH,KAAKO,aAEtC,CAKA,oBAAA2D,GACEpF,EAAmBkB,KAAKO,YAC1B,CAOS,0BAAA4D,CACPC,EACAC,GAEA,IAAKrE,KAAKH,UACR,OAGF,IAAI5G,EAAO,EACPe,EAAQ,EAEZ,GAAIoK,EAAO,CAET,MAAME,EAAkBF,EAAMtL,iBAAiB,IAAIY,EAAAA,YAAYC,eACzD4K,EAAmBH,EAAMtL,iBAAiB,IAAIY,EAAAA,YAAYQ,gBAChEoK,EAAgBzK,QAASC,IACvBb,GAASa,EAAmBC,cAE9BwK,EAAiB1K,QAASC,IACxBE,GAAUF,EAAmBC,aAEjC,KAAO,CAEQiG,KAAKO,YACOzH,iBAAiB,qBAC9Be,QAASX,IACfA,EAAKM,UAAU6B,SAAS3B,EAAAA,YAAYC,aACtCV,GAASC,EAAqBa,YACrBb,EAAKM,UAAU6B,SAAS3B,EAAAA,YAAYQ,gBAC7CF,GAAUd,EAAqBa,cAGrC,CAGA,MAAMyK,EACJH,GAAa7K,UAAU6B,SAAS3B,EAAAA,YAAYC,cAC5C0K,GAAa7K,UAAU6B,SAAS3B,EAAAA,YAAYQ,cAE9C,MAAO,CAAEjB,OAAMe,QAAOwK,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 * | `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 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","ownedProperties","property","level","description","isUsed","v","queries","type","name","defaultConfig","isApplied","originalColumnOrder","detach","this","clear","detect","rows","config","isArray","processColumns","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,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cAC5C0K,GAAa7K,UAAU6B,SAAS3B,EAAAA,YAAYQ,cAE9C,MAAO,CAAEjB,OAAMe,QAAOwK,aACxB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("../../core/plugin/base-plugin"),require("../../core/internal/aggregators")):"function"==typeof define&&define.amd?define(["exports","../../core/plugin/base-plugin","../../core/internal/aggregators"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TbwGridPlugin_pinnedRows={},t.TbwGrid,t.TbwGrid)}(this,function(t,e,n){"use strict";function o(t,e){const n=document.createElement("div");n.className="tbw-pinned-rows",n.setAttribute("role","presentation"),n.setAttribute("aria-live","polite");const o=document.createElement("div");o.className="tbw-pinned-rows-left";const i=document.createElement("div");i.className="tbw-pinned-rows-center";const r=document.createElement("div");if(r.className="tbw-pinned-rows-right",!1!==t.showRowCount){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-row-count",t.textContent=`Total: ${e.totalRows} rows`,o.appendChild(t)}if(t.showFilteredCount&&e.filteredRows!==e.totalRows){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-filtered-count",t.textContent=`Filtered: ${e.filteredRows}`,o.appendChild(t)}if(t.showSelectedCount&&e.selectedRows>0){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-selected-count",t.textContent=`Selected: ${e.selectedRows}`,r.appendChild(t)}if(t.customPanels)for(const a of t.customPanels){const t=g(a,e);switch(a.position){case"left":o.appendChild(t);break;case"center":i.appendChild(t);break;case"right":r.appendChild(t)}}return n.appendChild(o),n.appendChild(i),n.appendChild(r),n}function i(t){const e=document.createElement("div");return e.className=`tbw-aggregation-rows tbw-aggregation-rows-${t}`,e.setAttribute("role","presentation"),e}function r(t,e,n,o,i=!1){t.innerHTML="";for(const r of e){const e=document.createElement("div");e.className="tbw-aggregation-row",e.setAttribute("role","presentation"),r.id&&e.setAttribute("data-aggregation-id",r.id);r.fullWidth??i?a(e,r,n,o):s(e,r,n,o),t.appendChild(e)}}function a(t,e,n,o){const i=document.createElement("div");i.className="tbw-aggregation-cell tbw-aggregation-cell-full",i.style.gridColumn="1 / -1";const r="function"==typeof e.label?e.label(o,n):e.label;if(r){const t=document.createElement("span");t.className="tbw-aggregation-label",t.textContent=r,i.appendChild(t)}const a=function(t,e,n){const o=t.aggregators&&Object.keys(t.aggregators).length>0,i=t.cells&&Object.keys(t.cells).length>0;if(!o&&!i)return null;const r=document.createElement("span");r.className="tbw-aggregation-aggregates";for(const a of e){const{value:e,formatter:o}=l(t,a,n);if(null!=e){const t=document.createElement("span");t.className="tbw-aggregation-aggregate",t.setAttribute("data-field",a.field);const n=a.header??a.field,i=o?o(e,a.field,a):String(e);t.textContent=`${n}: ${i}`,r.appendChild(t)}}return r.children.length>0?r:null}(e,n,o);a&&i.appendChild(a),t.appendChild(i)}function s(t,e,n,o){for(const r of n){const n=document.createElement("div");n.className="tbw-aggregation-cell",n.setAttribute("data-field",r.field);const{value:i,formatter:a}=l(e,r,o);n.textContent=null!=i?a?a(i,r.field,r):String(i):"",t.appendChild(n)}const i="function"==typeof e.label?e.label(o,n):e.label;if(i){const e=document.createElement("span");e.className="tbw-aggregation-label",e.textContent=i,t.appendChild(e)}}function l(t,e,o){let i,r;const a=t.aggregators?.[e.field];if(a)if("object"==typeof(s=a)&&null!==s&&"aggFunc"in s){const t=n.getAggregator(a.aggFunc);t&&(i=t(o,e.field,e)),r=a.formatter}else{const t=n.getAggregator(a);t&&(i=t(o,e.field,e))}else if(t.cells&&Object.prototype.hasOwnProperty.call(t.cells,e.field)){const n=t.cells[e.field];i="function"==typeof n?n(o,e.field,e):n}var s;return{value:i,formatter:r}}function g(t,e){const n=document.createElement("div");n.className="tbw-status-panel tbw-status-panel-custom",n.id=`status-panel-${t.id}`;const o=t.render(e);return"string"==typeof o?n.innerHTML=o:n.appendChild(o),n}function c(t,e,n,o,i){return{totalRows:t.length,filteredRows:i?.cachedResult?.length??t.length,selectedRows:o?.selected?.size??0,columns:e,rows:t,grid:n}}class d extends e.BaseGridPlugin{name="pinnedRows";styles="@layer tbw-plugins{.tbw-scroll-area{container-type:inline-size}.tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg);min-width:fit-content}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75rem);color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;position:sticky;left:0;min-width:0;width:100cqi}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:var(--tbw-spacing-xl, 1rem)}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-size:var(--tbw-aggregation-font-size, .8em);font-weight:var(--tbw-aggregation-font-weight, 600);position:relative;background:inherit}.tbw-aggregation-row>.tbw-aggregation-label{position:sticky;left:0;grid-row:1;grid-column:1;display:flex;align-items:center;padding:var(--tbw-cell-padding, .125rem .5rem);background:inherit;z-index:1;pointer-events:none}.tbw-aggregation-row>.tbw-aggregation-cell:first-child{grid-column:1;grid-row:1}.tbw-aggregation-cell:not(:empty){position:relative;z-index:2;background:inherit}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, .125rem .5rem);min-height:var(--tbw-row-height, 1.75rem);display:block;align-items:center;align-content:center;border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;text-overflow:ellipsis;white-space:var(--tbw-cell-white-space, nowrap)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0;display:flex;align-items:center;gap:var(--tbw-spacing-lg, .75rem)}.tbw-aggregation-label{white-space:nowrap}.tbw-aggregation-aggregates{display:flex;align-items:center;gap:var(--tbw-spacing-lg, .75rem);font-weight:400;opacity:.85}.tbw-aggregation-aggregate{white-space:nowrap}}";get defaultConfig(){return{position:"bottom",showRowCount:!0,showSelectedCount:!0,showFilteredCount:!0}}infoBarElement=null;topAggregationContainer=null;bottomAggregationContainer=null;footerWrapper=null;detach(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}afterRender(){const t=this.gridElement;if(!t)return;const e=t.querySelector(".tbw-scroll-area")??t.querySelector(".tbw-grid-content")??t.querySelector(".tbw-grid-root");if(!e)return;this.footerWrapper&&!e.contains(this.footerWrapper)&&(this.footerWrapper=null,this.bottomAggregationContainer=null,this.infoBarElement=null),this.topAggregationContainer&&!e.contains(this.topAggregationContainer)&&(this.topAggregationContainer=null),this.infoBarElement&&!e.contains(this.infoBarElement)&&(this.infoBarElement=null);const n=this.getSelectionState(),a=this.getFilterState(),s=c(this.sourceRows,this.columns,this.gridElement,n,a),l=this.config.aggregationRows||[],g=l.filter(t=>"top"===t.position),d=l.filter(t=>"top"!==t.position);if(g.length>0){if(!this.topAggregationContainer){this.topAggregationContainer=i("top");const n=t.querySelector(".header");n&&n.nextSibling?e.insertBefore(this.topAggregationContainer,n.nextSibling):e.appendChild(this.topAggregationContainer)}r(this.topAggregationContainer,g,this.visibleColumns,this.sourceRows,this.config.fullWidth)}else this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null);const p=!1!==this.config.showRowCount||this.config.showSelectedCount&&s.selectedRows>0||this.config.showFilteredCount&&s.filteredRows!==s.totalRows||this.config.customPanels&&this.config.customPanels.length>0,h=p&&"top"!==this.config.position,f=d.length>0||h;if(p&&"top"===this.config.position)if(this.infoBarElement){const t=o(this.config,s);this.infoBarElement.replaceWith(t),this.infoBarElement=t}else this.infoBarElement=o(this.config,s),e.insertBefore(this.infoBarElement,e.firstChild);else"top"===this.config.position&&this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null);f?(this.footerWrapper||(this.footerWrapper=document.createElement("div"),this.footerWrapper.className="tbw-footer",e.appendChild(this.footerWrapper)),this.footerWrapper.innerHTML="",d.length>0&&(this.bottomAggregationContainer||(this.bottomAggregationContainer=i("bottom")),this.footerWrapper.appendChild(this.bottomAggregationContainer),r(this.bottomAggregationContainer,d,this.visibleColumns,this.sourceRows,this.config.fullWidth)),h&&(this.infoBarElement=o(this.config,s),this.footerWrapper.appendChild(this.infoBarElement))):this.cleanupFooter()}cleanup(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}cleanupFooter(){this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.infoBarElement&&"top"!==this.config.position&&(this.infoBarElement.remove(),this.infoBarElement=null)}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}getFilterState(){try{return this.grid?.getPluginState?.("filtering")??null}catch{return null}}refresh(){this.requestRender()}getContext(){const t=this.getSelectionState(),e=this.getFilterState();return c(this.rows,this.columns,this.gridElement,t,e)}addPanel(t){this.config.customPanels||(this.config.customPanels=[]),this.config.customPanels.push(t),this.requestRender()}removePanel(t){this.config.customPanels&&(this.config.customPanels=this.config.customPanels.filter(e=>e.id!==t),this.requestRender())}addAggregationRow(t){this.config.aggregationRows||(this.config.aggregationRows=[]),this.config.aggregationRows.push(t),this.requestRender()}removeAggregationRow(t){this.config.aggregationRows&&(this.config.aggregationRows=this.config.aggregationRows.filter(e=>e.id!==t),this.requestRender())}}t.PinnedRowsPlugin=d,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("../../core/plugin/base-plugin"),require("../../core/internal/aggregators")):"function"==typeof define&&define.amd?define(["exports","../../core/plugin/base-plugin","../../core/internal/aggregators"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TbwGridPlugin_pinnedRows={},t.TbwGrid,t.TbwGrid)}(this,function(t,e,n){"use strict";function o(t,e){const n=document.createElement("div");n.className="tbw-pinned-rows",n.setAttribute("role","presentation"),n.setAttribute("aria-live","polite");const o=document.createElement("div");o.className="tbw-pinned-rows-left";const i=document.createElement("div");i.className="tbw-pinned-rows-center";const r=document.createElement("div");if(r.className="tbw-pinned-rows-right",!1!==t.showRowCount){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-row-count",t.textContent=`Total: ${e.totalRows} rows`,o.appendChild(t)}if(t.showFilteredCount&&e.filteredRows!==e.totalRows){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-filtered-count",t.textContent=`Filtered: ${e.filteredRows}`,o.appendChild(t)}if(t.showSelectedCount&&e.selectedRows>0){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-selected-count",t.textContent=`Selected: ${e.selectedRows}`,r.appendChild(t)}if(t.customPanels)for(const a of t.customPanels){const t=g(a,e);switch(a.position){case"left":o.appendChild(t);break;case"center":i.appendChild(t);break;case"right":r.appendChild(t)}}return n.appendChild(o),n.appendChild(i),n.appendChild(r),n}function i(t){const e=document.createElement("div");return e.className=`tbw-aggregation-rows tbw-aggregation-rows-${t}`,e.setAttribute("role","presentation"),e}function r(t,e,n,o,i=!1){t.innerHTML="";for(const r of e){const e=document.createElement("div");e.className="tbw-aggregation-row",e.setAttribute("role","presentation"),r.id&&e.setAttribute("data-aggregation-id",r.id);r.fullWidth??i?a(e,r,n,o):s(e,r,n,o),t.appendChild(e)}}function a(t,e,n,o){const i=document.createElement("div");i.className="tbw-aggregation-cell tbw-aggregation-cell-full",i.style.gridColumn="1 / -1";const r="function"==typeof e.label?e.label(o,n):e.label;if(r){const t=document.createElement("span");t.className="tbw-aggregation-label",t.textContent=r,i.appendChild(t)}const a=function(t,e,n){const o=t.aggregators&&Object.keys(t.aggregators).length>0,i=t.cells&&Object.keys(t.cells).length>0;if(!o&&!i)return null;const r=document.createElement("span");r.className="tbw-aggregation-aggregates";for(const a of e){const{value:e,formatter:o}=l(t,a,n);if(null!=e){const t=document.createElement("span");t.className="tbw-aggregation-aggregate",t.setAttribute("data-field",a.field);const n=a.header??a.field,i=o?o(e,a.field,a):String(e);t.textContent=`${n}: ${i}`,r.appendChild(t)}}return r.children.length>0?r:null}(e,n,o);a&&i.appendChild(a),t.appendChild(i)}function s(t,e,n,o){for(const r of n){const n=document.createElement("div");n.className="tbw-aggregation-cell",n.setAttribute("data-field",r.field);const{value:i,formatter:a}=l(e,r,o);n.textContent=null!=i?a?a(i,r.field,r):String(i):"",t.appendChild(n)}const i="function"==typeof e.label?e.label(o,n):e.label;if(i){const e=document.createElement("span");e.className="tbw-aggregation-label",e.textContent=i,t.appendChild(e)}}function l(t,e,o){let i,r;const a=t.aggregators?.[e.field];if(a)if("object"==typeof(s=a)&&null!==s&&"aggFunc"in s){const t=n.aggregatorRegistry.get(a.aggFunc);t&&(i=t(o,e.field,e)),r=a.formatter}else{const t=n.aggregatorRegistry.get(a);t&&(i=t(o,e.field,e))}else if(t.cells&&Object.prototype.hasOwnProperty.call(t.cells,e.field)){const n=t.cells[e.field];i="function"==typeof n?n(o,e.field,e):n}var s;return{value:i,formatter:r}}function g(t,e){const n=document.createElement("div");n.className="tbw-status-panel tbw-status-panel-custom",n.id=`status-panel-${t.id}`;const o=t.render(e);return"string"==typeof o?n.innerHTML=o:n.appendChild(o),n}function c(t,e,n,o,i){return{totalRows:t.length,filteredRows:i?.cachedResult?.length??t.length,selectedRows:o?.selected?.size??0,columns:e,rows:t,grid:n}}class d extends e.BaseGridPlugin{name="pinnedRows";styles="@layer tbw-plugins{.tbw-scroll-area{container-type:inline-size}.tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg);min-width:fit-content}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75rem);color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;position:sticky;left:0;min-width:0;width:100cqi}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:var(--tbw-spacing-xl, 1rem)}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-size:var(--tbw-aggregation-font-size, .8em);font-weight:var(--tbw-aggregation-font-weight, 600);position:relative;background:inherit}.tbw-aggregation-row>.tbw-aggregation-label{position:sticky;left:0;grid-row:1;grid-column:1;display:flex;align-items:center;padding:var(--tbw-cell-padding, .125rem .5rem);background:inherit;z-index:1;pointer-events:none}.tbw-aggregation-row>.tbw-aggregation-cell:first-child{grid-column:1;grid-row:1}.tbw-aggregation-cell:not(:empty){position:relative;z-index:2;background:inherit}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, .125rem .5rem);min-height:var(--tbw-row-height, 1.75rem);display:block;align-items:center;align-content:center;border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;text-overflow:ellipsis;white-space:var(--tbw-cell-white-space, nowrap)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0;display:flex;align-items:center;gap:var(--tbw-spacing-lg, .75rem)}.tbw-aggregation-label{white-space:nowrap}.tbw-aggregation-aggregates{display:flex;align-items:center;gap:var(--tbw-spacing-lg, .75rem);font-weight:400;opacity:.85}.tbw-aggregation-aggregate{white-space:nowrap}}";get defaultConfig(){return{position:"bottom",showRowCount:!0,showSelectedCount:!0,showFilteredCount:!0}}infoBarElement=null;topAggregationContainer=null;bottomAggregationContainer=null;footerWrapper=null;detach(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}afterRender(){const t=this.gridElement;if(!t)return;const e=t.querySelector(".tbw-scroll-area")??t.querySelector(".tbw-grid-content")??t.querySelector(".tbw-grid-root");if(!e)return;this.footerWrapper&&!e.contains(this.footerWrapper)&&(this.footerWrapper=null,this.bottomAggregationContainer=null,this.infoBarElement=null),this.topAggregationContainer&&!e.contains(this.topAggregationContainer)&&(this.topAggregationContainer=null),this.infoBarElement&&!e.contains(this.infoBarElement)&&(this.infoBarElement=null);const n=this.getSelectionState(),a=this.getFilterState(),s=c(this.sourceRows,this.columns,this.gridElement,n,a),l=this.config.aggregationRows||[],g=l.filter(t=>"top"===t.position),d=l.filter(t=>"top"!==t.position);if(g.length>0){if(!this.topAggregationContainer){this.topAggregationContainer=i("top");const n=t.querySelector(".header");n&&n.nextSibling?e.insertBefore(this.topAggregationContainer,n.nextSibling):e.appendChild(this.topAggregationContainer)}r(this.topAggregationContainer,g,this.visibleColumns,this.sourceRows,this.config.fullWidth)}else this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null);const p=!1!==this.config.showRowCount||this.config.showSelectedCount&&s.selectedRows>0||this.config.showFilteredCount&&s.filteredRows!==s.totalRows||this.config.customPanels&&this.config.customPanels.length>0,h=p&&"top"!==this.config.position,f=d.length>0||h;if(p&&"top"===this.config.position)if(this.infoBarElement){const t=o(this.config,s);this.infoBarElement.replaceWith(t),this.infoBarElement=t}else this.infoBarElement=o(this.config,s),e.insertBefore(this.infoBarElement,e.firstChild);else"top"===this.config.position&&this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null);f?(this.footerWrapper||(this.footerWrapper=document.createElement("div"),this.footerWrapper.className="tbw-footer",e.appendChild(this.footerWrapper)),this.footerWrapper.innerHTML="",d.length>0&&(this.bottomAggregationContainer||(this.bottomAggregationContainer=i("bottom")),this.footerWrapper.appendChild(this.bottomAggregationContainer),r(this.bottomAggregationContainer,d,this.visibleColumns,this.sourceRows,this.config.fullWidth)),h&&(this.infoBarElement=o(this.config,s),this.footerWrapper.appendChild(this.infoBarElement))):this.cleanupFooter()}cleanup(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}cleanupFooter(){this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.infoBarElement&&"top"!==this.config.position&&(this.infoBarElement.remove(),this.infoBarElement=null)}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}getFilterState(){try{return this.grid?.getPluginState?.("filtering")??null}catch{return null}}refresh(){this.requestRender()}getContext(){const t=this.getSelectionState(),e=this.getFilterState();return c(this.rows,this.columns,this.gridElement,t,e)}addPanel(t){this.config.customPanels||(this.config.customPanels=[]),this.config.customPanels.push(t),this.requestRender()}removePanel(t){this.config.customPanels&&(this.config.customPanels=this.config.customPanels.filter(e=>e.id!==t),this.requestRender())}addAggregationRow(t){this.config.aggregationRows||(this.config.aggregationRows=[]),this.config.aggregationRows.push(t),this.requestRender()}removeAggregationRow(t){this.config.aggregationRows&&(this.config.aggregationRows=this.config.aggregationRows.filter(e=>e.id!==t),this.requestRender())}}t.PinnedRowsPlugin=d,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=pinned-rows.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pinned-rows.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/pinned-rows/pinned-rows.ts","../../../../../libs/grid/src/lib/plugins/pinned-rows/PinnedRowsPlugin.ts"],"sourcesContent":["/**\n * Status Bar Rendering Logic\n *\n * Pure functions for creating and updating the status bar UI.\n * Includes both info bar and aggregation row rendering.\n */\n\nimport { getAggregator } from '../../core/internal/aggregators';\nimport type { ColumnConfig } from '../../core/types';\nimport type {\n AggregationRowConfig,\n AggregatorConfig,\n AggregatorDefinition,\n PinnedRowsConfig,\n PinnedRowsContext,\n PinnedRowsPanel,\n} from './types';\n\n/**\n * Check if an aggregator definition is a full config object (with aggFunc and optional formatter).\n */\nfunction isAggregatorConfig(def: AggregatorDefinition): def is AggregatorConfig {\n return typeof def === 'object' && def !== null && 'aggFunc' in def;\n}\n\n/**\n * Creates the info bar DOM element with all configured panels.\n *\n * @param config - The status bar configuration\n * @param context - The current grid context for rendering\n * @returns The complete info bar element\n */\nexport function createInfoBarElement(config: PinnedRowsConfig, context: PinnedRowsContext): HTMLElement {\n const pinnedRows = document.createElement('div');\n pinnedRows.className = 'tbw-pinned-rows';\n pinnedRows.setAttribute('role', 'presentation');\n pinnedRows.setAttribute('aria-live', 'polite');\n\n const left = document.createElement('div');\n left.className = 'tbw-pinned-rows-left';\n\n const center = document.createElement('div');\n center.className = 'tbw-pinned-rows-center';\n\n const right = document.createElement('div');\n right.className = 'tbw-pinned-rows-right';\n\n // Default panels - row count\n if (config.showRowCount !== false) {\n const rowCount = document.createElement('span');\n rowCount.className = 'tbw-status-panel tbw-status-panel-row-count';\n rowCount.textContent = `Total: ${context.totalRows} rows`;\n left.appendChild(rowCount);\n }\n\n // Filtered count panel (only shows when filter is active)\n if (config.showFilteredCount && context.filteredRows !== context.totalRows) {\n const filteredCount = document.createElement('span');\n filteredCount.className = 'tbw-status-panel tbw-status-panel-filtered-count';\n filteredCount.textContent = `Filtered: ${context.filteredRows}`;\n left.appendChild(filteredCount);\n }\n\n // Selected count panel (only shows when rows are selected)\n if (config.showSelectedCount && context.selectedRows > 0) {\n const selectedCount = document.createElement('span');\n selectedCount.className = 'tbw-status-panel tbw-status-panel-selected-count';\n selectedCount.textContent = `Selected: ${context.selectedRows}`;\n right.appendChild(selectedCount);\n }\n\n // Render custom panels\n if (config.customPanels) {\n for (const panel of config.customPanels) {\n const panelEl = renderCustomPanel(panel, context);\n switch (panel.position) {\n case 'left':\n left.appendChild(panelEl);\n break;\n case 'center':\n center.appendChild(panelEl);\n break;\n case 'right':\n right.appendChild(panelEl);\n break;\n }\n }\n }\n\n pinnedRows.appendChild(left);\n pinnedRows.appendChild(center);\n pinnedRows.appendChild(right);\n\n return pinnedRows;\n}\n\n/**\n * Creates a container for aggregation rows at top or bottom.\n *\n * @param position - 'top' or 'bottom'\n * @returns The container element\n */\nexport function createAggregationContainer(position: 'top' | 'bottom'): HTMLElement {\n const container = document.createElement('div');\n container.className = `tbw-aggregation-rows tbw-aggregation-rows-${position}`;\n // Use presentation role since aggregation rows are outside the role=\"grid\" element for layout reasons\n container.setAttribute('role', 'presentation');\n return container;\n}\n\n/**\n * Renders aggregation rows into a container.\n *\n * @param container - The container to render into\n * @param rows - Aggregation row configurations\n * @param columns - Current column configuration\n * @param dataRows - Current row data for aggregation calculations\n * @param globalFullWidth - Global fullWidth default from PinnedRowsConfig (default: false)\n */\nexport function renderAggregationRows(\n container: HTMLElement,\n rows: AggregationRowConfig[],\n columns: ColumnConfig[],\n dataRows: unknown[],\n globalFullWidth = false,\n): void {\n container.innerHTML = '';\n\n for (const rowConfig of rows) {\n const rowEl = document.createElement('div');\n rowEl.className = 'tbw-aggregation-row';\n // Use presentation role since aggregation rows are outside the role=\"grid\" element\n rowEl.setAttribute('role', 'presentation');\n if (rowConfig.id) {\n rowEl.setAttribute('data-aggregation-id', rowConfig.id);\n }\n\n // Per-row fullWidth overrides global default\n const isFullWidth = rowConfig.fullWidth ?? globalFullWidth;\n\n if (isFullWidth) {\n renderFullWidthAggregationRow(rowEl, rowConfig, columns, dataRows);\n } else {\n renderPerColumnAggregationRow(rowEl, rowConfig, columns, dataRows);\n }\n\n container.appendChild(rowEl);\n }\n}\n\n/**\n * Renders a full-width aggregation row: single spanning cell with label and inline aggregated values.\n */\nfunction renderFullWidthAggregationRow(\n rowEl: HTMLElement,\n rowConfig: AggregationRowConfig,\n columns: ColumnConfig[],\n dataRows: unknown[],\n): void {\n const cell = document.createElement('div');\n cell.className = 'tbw-aggregation-cell tbw-aggregation-cell-full';\n cell.style.gridColumn = '1 / -1';\n\n // Label (static string or dynamic function)\n const labelValue = typeof rowConfig.label === 'function' ? rowConfig.label(dataRows, columns) : rowConfig.label;\n if (labelValue) {\n const labelSpan = document.createElement('span');\n labelSpan.className = 'tbw-aggregation-label';\n labelSpan.textContent = labelValue;\n cell.appendChild(labelSpan);\n }\n\n // Inline aggregated values\n const aggregatesContainer = renderInlineAggregates(rowConfig, columns, dataRows);\n if (aggregatesContainer) {\n cell.appendChild(aggregatesContainer);\n }\n\n // If nothing was added (no label, no aggregates), ensure cell is empty but present\n rowEl.appendChild(cell);\n}\n\n/**\n * Renders per-column aggregation cells aligned to the grid template.\n */\nfunction renderPerColumnAggregationRow(\n rowEl: HTMLElement,\n rowConfig: AggregationRowConfig,\n columns: ColumnConfig[],\n dataRows: unknown[],\n): void {\n for (const col of columns) {\n const cell = document.createElement('div');\n cell.className = 'tbw-aggregation-cell';\n cell.setAttribute('data-field', col.field);\n\n const { value, formatter } = resolveAggregatedValue(rowConfig, col, dataRows);\n\n if (value != null) {\n cell.textContent = formatter ? formatter(value, col.field, col) : String(value);\n } else {\n cell.textContent = '';\n }\n rowEl.appendChild(cell);\n }\n\n // Overlay label: positioned at the left edge, independent of column alignment\n const labelValue = typeof rowConfig.label === 'function' ? rowConfig.label(dataRows, columns) : rowConfig.label;\n if (labelValue) {\n const labelEl = document.createElement('span');\n labelEl.className = 'tbw-aggregation-label';\n labelEl.textContent = labelValue;\n rowEl.appendChild(labelEl);\n }\n}\n\n/**\n * Resolves the aggregated value for a single column in an aggregation row.\n * Returns the computed value and an optional formatter function.\n */\nfunction resolveAggregatedValue(\n rowConfig: AggregationRowConfig,\n col: ColumnConfig,\n dataRows: unknown[],\n): { value: unknown; formatter?: (value: unknown, field: string, column?: ColumnConfig) => string } {\n let value: unknown;\n let formatter: ((value: unknown, field: string, column?: ColumnConfig) => string) | undefined;\n\n // Check for aggregator first\n const aggDef = rowConfig.aggregators?.[col.field];\n if (aggDef) {\n if (isAggregatorConfig(aggDef)) {\n const aggFn = getAggregator(aggDef.aggFunc);\n if (aggFn) {\n value = aggFn(dataRows, col.field, col);\n }\n formatter = aggDef.formatter;\n } else {\n const aggFn = getAggregator(aggDef);\n if (aggFn) {\n value = aggFn(dataRows, col.field, col);\n }\n }\n } else if (rowConfig.cells && Object.prototype.hasOwnProperty.call(rowConfig.cells, col.field)) {\n const staticVal = rowConfig.cells[col.field];\n if (typeof staticVal === 'function') {\n value = staticVal(dataRows, col.field, col);\n } else {\n value = staticVal;\n }\n }\n\n return { value, formatter };\n}\n\n/**\n * Renders inline aggregate values for a full-width aggregation row.\n * Returns a container element with aggregate spans, or null if no aggregates are defined.\n */\nfunction renderInlineAggregates(\n rowConfig: AggregationRowConfig,\n columns: ColumnConfig[],\n dataRows: unknown[],\n): HTMLElement | null {\n // Collect fields that have aggregators or cell values\n const hasAggregators = rowConfig.aggregators && Object.keys(rowConfig.aggregators).length > 0;\n const hasCells = rowConfig.cells && Object.keys(rowConfig.cells).length > 0;\n if (!hasAggregators && !hasCells) return null;\n\n const container = document.createElement('span');\n container.className = 'tbw-aggregation-aggregates';\n\n for (const col of columns) {\n const { value, formatter } = resolveAggregatedValue(rowConfig, col, dataRows);\n if (value != null) {\n const span = document.createElement('span');\n span.className = 'tbw-aggregation-aggregate';\n span.setAttribute('data-field', col.field);\n const header = col.header ?? col.field;\n const displayValue = formatter ? formatter(value, col.field, col) : String(value);\n span.textContent = `${header}: ${displayValue}`;\n container.appendChild(span);\n }\n }\n\n return container.children.length > 0 ? container : null;\n}\n\n/**\n * Renders a custom panel element.\n *\n * @param panel - The panel definition\n * @param context - The current grid context\n * @returns The panel DOM element\n */\nfunction renderCustomPanel(panel: PinnedRowsPanel, context: PinnedRowsContext): HTMLElement {\n const panelEl = document.createElement('div');\n panelEl.className = 'tbw-status-panel tbw-status-panel-custom';\n panelEl.id = `status-panel-${panel.id}`;\n\n const content = panel.render(context);\n\n if (typeof content === 'string') {\n panelEl.innerHTML = content;\n } else {\n panelEl.appendChild(content);\n }\n\n return panelEl;\n}\n\n/**\n * Builds the status bar context from grid state and plugin states.\n *\n * @param rows - Current row data\n * @param columns - Current column configuration\n * @param grid - Grid element reference\n * @param selectionState - Optional selection plugin state\n * @param filterState - Optional filtering plugin state\n * @returns The status bar context\n */\nexport function buildContext(\n rows: unknown[],\n columns: unknown[],\n grid: HTMLElement,\n selectionState?: { selected: Set<number> } | null,\n filterState?: { cachedResult: unknown[] | null } | null,\n): PinnedRowsContext {\n return {\n totalRows: rows.length,\n filteredRows: filterState?.cachedResult?.length ?? rows.length,\n selectedRows: selectionState?.selected?.size ?? 0,\n columns: columns as PinnedRowsContext['columns'],\n rows,\n grid,\n };\n}\n\n// Keep old name as alias for backwards compatibility\nexport const createPinnedRowsElement = createInfoBarElement;\n","/**\n * Pinned Rows Plugin (Class-based)\n *\n * Adds info bars and aggregation rows to the grid.\n * - Info bar: Shows row counts, selection info, and custom panels\n * - Aggregation rows: Footer/header rows with computed values (sum, avg, etc.)\n */\n\nimport { BaseGridPlugin } from '../../core/plugin/base-plugin';\nimport type { ColumnConfig } from '../../core/types';\nimport { buildContext, createAggregationContainer, createInfoBarElement, renderAggregationRows } from './pinned-rows';\nimport styles from './pinned-rows.css?inline';\nimport type { AggregationRowConfig, PinnedRowsConfig, PinnedRowsContext, PinnedRowsPanel } from './types';\n\n/**\n * Pinned Rows (Status Bar) Plugin for tbw-grid\n *\n * Creates fixed status bars at the top or bottom of the grid for displaying aggregations,\n * row counts, or custom content. Think of it as the \"totals row\" you'd see in a spreadsheet—\n * always visible regardless of scroll position.\n *\n * ## Installation\n *\n * ```ts\n * import { PinnedRowsPlugin } from '@toolbox-web/grid/plugins/pinned-rows';\n * ```\n *\n * ## Built-in Aggregation Functions\n *\n * | Function | Description |\n * |----------|-------------|\n * | `sum` | Sum of values |\n * | `avg` | Average of values |\n * | `count` | Count of rows |\n * | `min` | Minimum value |\n * | `max` | Maximum value |\n *\n * ## CSS Custom Properties\n *\n * | Property | Default | Description |\n * |----------|---------|-------------|\n * | `--tbw-pinned-rows-bg` | `var(--tbw-color-panel-bg)` | Status bar background |\n * | `--tbw-pinned-rows-border` | `var(--tbw-color-border)` | Status bar border |\n *\n * @example Status Bar with Aggregation\n * ```ts\n * import '@toolbox-web/grid';\n * import { PinnedRowsPlugin } from '@toolbox-web/grid/plugins/pinned-rows';\n *\n * grid.gridConfig = {\n * columns: [\n * { field: 'product', header: 'Product' },\n * { field: 'quantity', header: 'Qty', type: 'number' },\n * { field: 'price', header: 'Price', type: 'currency' },\n * ],\n * plugins: [\n * new PinnedRowsPlugin({\n * position: 'bottom',\n * showRowCount: true,\n * aggregationRows: [\n * {\n * id: 'totals',\n * aggregators: { quantity: 'sum', price: 'sum' },\n * cells: { product: 'Totals:' },\n * },\n * ],\n * }),\n * ],\n * };\n * ```\n *\n * @see {@link PinnedRowsConfig} for all configuration options\n * @see {@link AggregationRowConfig} for aggregation row structure\n *\n * @internal Extends BaseGridPlugin\n */\nexport class PinnedRowsPlugin extends BaseGridPlugin<PinnedRowsConfig> {\n /** @internal */\n readonly name = 'pinnedRows';\n /** @internal */\n override readonly styles = styles;\n\n /** @internal */\n protected override get defaultConfig(): Partial<PinnedRowsConfig> {\n return {\n position: 'bottom',\n showRowCount: true,\n showSelectedCount: true,\n showFilteredCount: true,\n };\n }\n\n // #region Internal State\n private infoBarElement: HTMLElement | null = null;\n private topAggregationContainer: HTMLElement | null = null;\n private bottomAggregationContainer: HTMLElement | null = null;\n private footerWrapper: HTMLElement | null = null;\n // #endregion\n\n // #region Lifecycle\n /** @internal */\n override detach(): void {\n if (this.infoBarElement) {\n this.infoBarElement.remove();\n this.infoBarElement = null;\n }\n if (this.topAggregationContainer) {\n this.topAggregationContainer.remove();\n this.topAggregationContainer = null;\n }\n if (this.bottomAggregationContainer) {\n this.bottomAggregationContainer.remove();\n this.bottomAggregationContainer = null;\n }\n if (this.footerWrapper) {\n this.footerWrapper.remove();\n this.footerWrapper = null;\n }\n }\n // #endregion\n\n // #region Hooks\n /** @internal */\n override afterRender(): void {\n const gridEl = this.gridElement;\n if (!gridEl) return;\n\n // Use .tbw-scroll-area so footer is inside the horizontal scroll area,\n // otherwise fall back to .tbw-grid-content or root container\n const container =\n gridEl.querySelector('.tbw-scroll-area') ??\n gridEl.querySelector('.tbw-grid-content') ??\n gridEl.querySelector('.tbw-grid-root');\n if (!container) return;\n\n // Clear orphaned element references if they were removed from the DOM\n // (e.g., by buildGridDOMIntoShadow calling replaceChildren())\n // We check if the element is still inside the container rather than isConnected,\n // because in unit tests the mock grid may not be attached to document.body\n if (this.footerWrapper && !container.contains(this.footerWrapper)) {\n this.footerWrapper = null;\n this.bottomAggregationContainer = null;\n this.infoBarElement = null;\n }\n if (this.topAggregationContainer && !container.contains(this.topAggregationContainer)) {\n this.topAggregationContainer = null;\n }\n if (this.infoBarElement && !container.contains(this.infoBarElement)) {\n this.infoBarElement = null;\n }\n\n // Build context with plugin states\n const selectionState = this.getSelectionState();\n const filterState = this.getFilterState();\n\n const context = buildContext(\n this.sourceRows as unknown[],\n this.columns as unknown[],\n this.gridElement,\n selectionState,\n filterState,\n );\n\n // #region Handle Aggregation Rows\n const aggregationRows = this.config.aggregationRows || [];\n const topRows = aggregationRows.filter((r) => r.position === 'top');\n const bottomRows = aggregationRows.filter((r) => r.position !== 'top');\n\n // Top aggregation rows\n if (topRows.length > 0) {\n if (!this.topAggregationContainer) {\n this.topAggregationContainer = createAggregationContainer('top');\n const header = gridEl.querySelector('.header');\n if (header && header.nextSibling) {\n container.insertBefore(this.topAggregationContainer, header.nextSibling);\n } else {\n container.appendChild(this.topAggregationContainer);\n }\n }\n renderAggregationRows(\n this.topAggregationContainer,\n topRows,\n this.visibleColumns as ColumnConfig[],\n this.sourceRows as unknown[],\n this.config.fullWidth,\n );\n } else if (this.topAggregationContainer) {\n this.topAggregationContainer.remove();\n this.topAggregationContainer = null;\n }\n\n // Handle footer\n const hasInfoContent =\n this.config.showRowCount !== false ||\n (this.config.showSelectedCount && context.selectedRows > 0) ||\n (this.config.showFilteredCount && context.filteredRows !== context.totalRows) ||\n (this.config.customPanels && this.config.customPanels.length > 0);\n const hasBottomInfoBar = hasInfoContent && this.config.position !== 'top';\n const needsFooter = bottomRows.length > 0 || hasBottomInfoBar;\n\n // Handle top info bar\n if (hasInfoContent && this.config.position === 'top') {\n if (!this.infoBarElement) {\n this.infoBarElement = createInfoBarElement(this.config, context);\n container.insertBefore(this.infoBarElement, container.firstChild);\n } else {\n const newInfoBar = createInfoBarElement(this.config, context);\n this.infoBarElement.replaceWith(newInfoBar);\n this.infoBarElement = newInfoBar;\n }\n } else if (this.config.position === 'top' && this.infoBarElement) {\n this.infoBarElement.remove();\n this.infoBarElement = null;\n }\n\n // Create/manage footer wrapper\n if (needsFooter) {\n if (!this.footerWrapper) {\n this.footerWrapper = document.createElement('div');\n this.footerWrapper.className = 'tbw-footer';\n container.appendChild(this.footerWrapper);\n }\n\n this.footerWrapper.innerHTML = '';\n\n if (bottomRows.length > 0) {\n if (!this.bottomAggregationContainer) {\n this.bottomAggregationContainer = createAggregationContainer('bottom');\n }\n this.footerWrapper.appendChild(this.bottomAggregationContainer);\n renderAggregationRows(\n this.bottomAggregationContainer,\n bottomRows,\n this.visibleColumns as ColumnConfig[],\n this.sourceRows as unknown[],\n this.config.fullWidth,\n );\n }\n\n if (hasBottomInfoBar) {\n this.infoBarElement = createInfoBarElement(this.config, context);\n this.footerWrapper.appendChild(this.infoBarElement);\n }\n } else {\n this.cleanupFooter();\n }\n // #endregion\n }\n // #endregion\n\n // #region Private Methods\n private cleanup(): void {\n if (this.infoBarElement) {\n this.infoBarElement.remove();\n this.infoBarElement = null;\n }\n if (this.topAggregationContainer) {\n this.topAggregationContainer.remove();\n this.topAggregationContainer = null;\n }\n if (this.bottomAggregationContainer) {\n this.bottomAggregationContainer.remove();\n this.bottomAggregationContainer = null;\n }\n if (this.footerWrapper) {\n this.footerWrapper.remove();\n this.footerWrapper = null;\n }\n }\n\n private cleanupFooter(): void {\n if (this.footerWrapper) {\n this.footerWrapper.remove();\n this.footerWrapper = null;\n }\n if (this.bottomAggregationContainer) {\n this.bottomAggregationContainer.remove();\n this.bottomAggregationContainer = null;\n }\n if (this.infoBarElement && this.config.position !== 'top') {\n this.infoBarElement.remove();\n this.infoBarElement = null;\n }\n }\n\n private getSelectionState(): { selected: Set<number> } | null {\n // Try to get selection plugin state\n try {\n return (this.grid?.getPluginState?.('selection') as { selected: Set<number> } | null) ?? null;\n } catch {\n return null;\n }\n }\n\n private getFilterState(): { cachedResult: unknown[] | null } | null {\n try {\n return (this.grid?.getPluginState?.('filtering') as { cachedResult: unknown[] | null } | null) ?? null;\n } catch {\n return null;\n }\n }\n // #endregion\n\n // #region Public API\n /**\n * Refresh the status bar to reflect current grid state.\n */\n refresh(): void {\n this.requestRender();\n }\n\n /**\n * Get the current status bar context.\n * @returns The context with row counts and other info\n */\n getContext(): PinnedRowsContext {\n const selectionState = this.getSelectionState();\n const filterState = this.getFilterState();\n\n return buildContext(\n this.rows as unknown[],\n this.columns as unknown[],\n this.gridElement,\n selectionState,\n filterState,\n );\n }\n\n /**\n * Add a custom panel to the info bar.\n * @param panel - The panel configuration to add\n */\n addPanel(panel: PinnedRowsPanel): void {\n if (!this.config.customPanels) {\n this.config.customPanels = [];\n }\n this.config.customPanels.push(panel);\n this.requestRender();\n }\n\n /**\n * Remove a custom panel by ID.\n * @param id - The panel ID to remove\n */\n removePanel(id: string): void {\n if (this.config.customPanels) {\n this.config.customPanels = this.config.customPanels.filter((p) => p.id !== id);\n this.requestRender();\n }\n }\n\n /**\n * Add an aggregation row.\n * @param row - The aggregation row configuration\n */\n addAggregationRow(row: AggregationRowConfig): void {\n if (!this.config.aggregationRows) {\n this.config.aggregationRows = [];\n }\n this.config.aggregationRows.push(row);\n this.requestRender();\n }\n\n /**\n * Remove an aggregation row by ID.\n * @param id - The aggregation row ID to remove\n */\n removeAggregationRow(id: string): void {\n if (this.config.aggregationRows) {\n this.config.aggregationRows = this.config.aggregationRows.filter((r) => r.id !== id);\n this.requestRender();\n }\n }\n // #endregion\n}\n"],"names":["createInfoBarElement","config","context","pinnedRows","document","createElement","className","setAttribute","left","center","right","showRowCount","rowCount","textContent","totalRows","appendChild","showFilteredCount","filteredRows","filteredCount","showSelectedCount","selectedRows","selectedCount","customPanels","panel","panelEl","renderCustomPanel","position","createAggregationContainer","container","renderAggregationRows","rows","columns","dataRows","globalFullWidth","innerHTML","rowConfig","rowEl","id","fullWidth","renderFullWidthAggregationRow","renderPerColumnAggregationRow","cell","style","gridColumn","labelValue","label","labelSpan","aggregatesContainer","hasAggregators","aggregators","Object","keys","length","hasCells","cells","col","value","formatter","resolveAggregatedValue","span","field","header","displayValue","String","children","renderInlineAggregates","labelEl","aggDef","def","aggFn","getAggregator","aggFunc","prototype","hasOwnProperty","call","staticVal","content","render","buildContext","grid","selectionState","filterState","cachedResult","selected","size","PinnedRowsPlugin","BaseGridPlugin","name","styles","defaultConfig","infoBarElement","topAggregationContainer","bottomAggregationContainer","footerWrapper","detach","this","remove","afterRender","gridEl","gridElement","querySelector","contains","getSelectionState","getFilterState","sourceRows","aggregationRows","topRows","filter","r","bottomRows","nextSibling","insertBefore","visibleColumns","hasInfoContent","hasBottomInfoBar","needsFooter","newInfoBar","replaceWith","firstChild","cleanupFooter","cleanup","getPluginState","refresh","requestRender","getContext","addPanel","push","removePanel","p","addAggregationRow","row","removeAggregationRow"],"mappings":"6aAgCO,SAASA,EAAqBC,EAA0BC,GAC7D,MAAMC,EAAaC,SAASC,cAAc,OAC1CF,EAAWG,UAAY,kBACvBH,EAAWI,aAAa,OAAQ,gBAChCJ,EAAWI,aAAa,YAAa,UAErC,MAAMC,EAAOJ,SAASC,cAAc,OACpCG,EAAKF,UAAY,uBAEjB,MAAMG,EAASL,SAASC,cAAc,OACtCI,EAAOH,UAAY,yBAEnB,MAAMI,EAAQN,SAASC,cAAc,OAIrC,GAHAK,EAAMJ,UAAY,yBAGU,IAAxBL,EAAOU,aAAwB,CACjC,MAAMC,EAAWR,SAASC,cAAc,QACxCO,EAASN,UAAY,8CACrBM,EAASC,YAAc,UAAUX,EAAQY,iBACzCN,EAAKO,YAAYH,EACnB,CAGA,GAAIX,EAAOe,mBAAqBd,EAAQe,eAAiBf,EAAQY,UAAW,CAC1E,MAAMI,EAAgBd,SA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R,KAAKhB,MAAM0C,iBAAiB,cAA8D,IACpG,CAAA,MACE,OAAO,IACT,CACF,CAOA,OAAAC,GACE3B,KAAK4B,eACP,CAMA,UAAAC,GACE,MAAM5C,EAAiBe,KAAKO,oBACtBrB,EAAcc,KAAKQ,iBAEzB,OAAOzB,EACLiB,KAAKjE,KACLiE,KAAKhE,QACLgE,KAAKI,YACLnB,EACAC,EAEJ,CAMA,QAAA4C,CAAStG,GACFwE,KAAK9F,OAAOqB,eACfyE,KAAK9F,OAAOqB,aAAe,IAE7ByE,KAAK9F,OAAOqB,aAAawG,KAAKvG,GAC9BwE,KAAK4B,eACP,CAMA,WAAAI,CAAY1F,GACN0D,KAAK9F,OAAOqB,eACdyE,KAAK9F,OAAOqB,aAAeyE,KAAK9F,OAAOqB,aAAaqF,OAAQqB,GAAMA,EAAE3F,KAAOA,GAC3E0D,KAAK4B,gBAET,CAMA,iBAAAM,CAAkBC,GACXnC,KAAK9F,OAAOwG,kBACfV,KAAK9F,OAAOwG,gBAAkB,IAEhCV,KAAK9F,OAAOwG,gBAAgBqB,KAAKI,GACjCnC,KAAK4B,eACP,CAMA,oBAAAQ,CAAqB9F,GACf0D,KAAK9F,OAAOwG,kBACdV,KAAK9F,OAAOwG,gBAAkBV,KAAK9F,OAAOwG,gBAAgBE,OAAQC,GAAMA,EAAEvE,KAAOA,GACjF0D,KAAK4B,gBAET"}
|
|
1
|
+
{"version":3,"file":"pinned-rows.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/pinned-rows/pinned-rows.ts","../../../../../libs/grid/src/lib/plugins/pinned-rows/PinnedRowsPlugin.ts"],"sourcesContent":["/**\n * Status Bar Rendering Logic\n *\n * Pure functions for creating and updating the status bar UI.\n * Includes both info bar and aggregation row rendering.\n */\n\nimport { aggregatorRegistry } from '../../core/internal/aggregators';\nimport type { ColumnConfig } from '../../core/types';\nimport type {\n AggregationRowConfig,\n AggregatorConfig,\n AggregatorDefinition,\n PinnedRowsConfig,\n PinnedRowsContext,\n PinnedRowsPanel,\n} from './types';\n\n/**\n * Check if an aggregator definition is a full config object (with aggFunc and optional formatter).\n */\nfunction isAggregatorConfig(def: AggregatorDefinition): def is AggregatorConfig {\n return typeof def === 'object' && def !== null && 'aggFunc' in def;\n}\n\n/**\n * Creates the info bar DOM element with all configured panels.\n *\n * @param config - The status bar configuration\n * @param context - The current grid context for rendering\n * @returns The complete info bar element\n */\nexport function createInfoBarElement(config: PinnedRowsConfig, context: PinnedRowsContext): HTMLElement {\n const pinnedRows = document.createElement('div');\n pinnedRows.className = 'tbw-pinned-rows';\n pinnedRows.setAttribute('role', 'presentation');\n pinnedRows.setAttribute('aria-live', 'polite');\n\n const left = document.createElement('div');\n left.className = 'tbw-pinned-rows-left';\n\n const center = document.createElement('div');\n center.className = 'tbw-pinned-rows-center';\n\n const right = document.createElement('div');\n right.className = 'tbw-pinned-rows-right';\n\n // Default panels - row count\n if (config.showRowCount !== false) {\n const rowCount = document.createElement('span');\n rowCount.className = 'tbw-status-panel tbw-status-panel-row-count';\n rowCount.textContent = `Total: ${context.totalRows} rows`;\n left.appendChild(rowCount);\n }\n\n // Filtered count panel (only shows when filter is active)\n if (config.showFilteredCount && context.filteredRows !== context.totalRows) {\n const filteredCount = document.createElement('span');\n filteredCount.className = 'tbw-status-panel tbw-status-panel-filtered-count';\n filteredCount.textContent = `Filtered: ${context.filteredRows}`;\n left.appendChild(filteredCount);\n }\n\n // Selected count panel (only shows when rows are selected)\n if (config.showSelectedCount && context.selectedRows > 0) {\n const selectedCount = document.createElement('span');\n selectedCount.className = 'tbw-status-panel tbw-status-panel-selected-count';\n selectedCount.textContent = `Selected: ${context.selectedRows}`;\n right.appendChild(selectedCount);\n }\n\n // Render custom panels\n if (config.customPanels) {\n for (const panel of config.customPanels) {\n const panelEl = renderCustomPanel(panel, context);\n switch (panel.position) {\n case 'left':\n left.appendChild(panelEl);\n break;\n case 'center':\n center.appendChild(panelEl);\n break;\n case 'right':\n right.appendChild(panelEl);\n break;\n }\n }\n }\n\n pinnedRows.appendChild(left);\n pinnedRows.appendChild(center);\n pinnedRows.appendChild(right);\n\n return pinnedRows;\n}\n\n/**\n * Creates a container for aggregation rows at top or bottom.\n *\n * @param position - 'top' or 'bottom'\n * @returns The container element\n */\nexport function createAggregationContainer(position: 'top' | 'bottom'): HTMLElement {\n const container = document.createElement('div');\n container.className = `tbw-aggregation-rows tbw-aggregation-rows-${position}`;\n // Use presentation role since aggregation rows are outside the role=\"grid\" element for layout reasons\n container.setAttribute('role', 'presentation');\n return container;\n}\n\n/**\n * Renders aggregation rows into a container.\n *\n * @param container - The container to render into\n * @param rows - Aggregation row configurations\n * @param columns - Current column configuration\n * @param dataRows - Current row data for aggregation calculations\n * @param globalFullWidth - Global fullWidth default from PinnedRowsConfig (default: false)\n */\nexport function renderAggregationRows(\n container: HTMLElement,\n rows: AggregationRowConfig[],\n columns: ColumnConfig[],\n dataRows: unknown[],\n globalFullWidth = false,\n): void {\n container.innerHTML = '';\n\n for (const rowConfig of rows) {\n const rowEl = document.createElement('div');\n rowEl.className = 'tbw-aggregation-row';\n // Use presentation role since aggregation rows are outside the role=\"grid\" element\n rowEl.setAttribute('role', 'presentation');\n if (rowConfig.id) {\n rowEl.setAttribute('data-aggregation-id', rowConfig.id);\n }\n\n // Per-row fullWidth overrides global default\n const isFullWidth = rowConfig.fullWidth ?? globalFullWidth;\n\n if (isFullWidth) {\n renderFullWidthAggregationRow(rowEl, rowConfig, columns, dataRows);\n } else {\n renderPerColumnAggregationRow(rowEl, rowConfig, columns, dataRows);\n }\n\n container.appendChild(rowEl);\n }\n}\n\n/**\n * Renders a full-width aggregation row: single spanning cell with label and inline aggregated values.\n */\nfunction renderFullWidthAggregationRow(\n rowEl: HTMLElement,\n rowConfig: AggregationRowConfig,\n columns: ColumnConfig[],\n dataRows: unknown[],\n): void {\n const cell = document.createElement('div');\n cell.className = 'tbw-aggregation-cell tbw-aggregation-cell-full';\n cell.style.gridColumn = '1 / -1';\n\n // Label (static string or dynamic function)\n const labelValue = typeof rowConfig.label === 'function' ? rowConfig.label(dataRows, columns) : rowConfig.label;\n if (labelValue) {\n const labelSpan = document.createElement('span');\n labelSpan.className = 'tbw-aggregation-label';\n labelSpan.textContent = labelValue;\n cell.appendChild(labelSpan);\n }\n\n // Inline aggregated values\n const aggregatesContainer = renderInlineAggregates(rowConfig, columns, dataRows);\n if (aggregatesContainer) {\n cell.appendChild(aggregatesContainer);\n }\n\n // If nothing was added (no label, no aggregates), ensure cell is empty but present\n rowEl.appendChild(cell);\n}\n\n/**\n * Renders per-column aggregation cells aligned to the grid template.\n */\nfunction renderPerColumnAggregationRow(\n rowEl: HTMLElement,\n rowConfig: AggregationRowConfig,\n columns: ColumnConfig[],\n dataRows: unknown[],\n): void {\n for (const col of columns) {\n const cell = document.createElement('div');\n cell.className = 'tbw-aggregation-cell';\n cell.setAttribute('data-field', col.field);\n\n const { value, formatter } = resolveAggregatedValue(rowConfig, col, dataRows);\n\n if (value != null) {\n cell.textContent = formatter ? formatter(value, col.field, col) : String(value);\n } else {\n cell.textContent = '';\n }\n rowEl.appendChild(cell);\n }\n\n // Overlay label: positioned at the left edge, independent of column alignment\n const labelValue = typeof rowConfig.label === 'function' ? rowConfig.label(dataRows, columns) : rowConfig.label;\n if (labelValue) {\n const labelEl = document.createElement('span');\n labelEl.className = 'tbw-aggregation-label';\n labelEl.textContent = labelValue;\n rowEl.appendChild(labelEl);\n }\n}\n\n/**\n * Resolves the aggregated value for a single column in an aggregation row.\n * Returns the computed value and an optional formatter function.\n */\nfunction resolveAggregatedValue(\n rowConfig: AggregationRowConfig,\n col: ColumnConfig,\n dataRows: unknown[],\n): { value: unknown; formatter?: (value: unknown, field: string, column?: ColumnConfig) => string } {\n let value: unknown;\n let formatter: ((value: unknown, field: string, column?: ColumnConfig) => string) | undefined;\n\n // Check for aggregator first\n const aggDef = rowConfig.aggregators?.[col.field];\n if (aggDef) {\n if (isAggregatorConfig(aggDef)) {\n const aggFn = aggregatorRegistry.get(aggDef.aggFunc);\n if (aggFn) {\n value = aggFn(dataRows, col.field, col);\n }\n formatter = aggDef.formatter;\n } else {\n const aggFn = aggregatorRegistry.get(aggDef);\n if (aggFn) {\n value = aggFn(dataRows, col.field, col);\n }\n }\n } else if (rowConfig.cells && Object.prototype.hasOwnProperty.call(rowConfig.cells, col.field)) {\n const staticVal = rowConfig.cells[col.field];\n if (typeof staticVal === 'function') {\n value = staticVal(dataRows, col.field, col);\n } else {\n value = staticVal;\n }\n }\n\n return { value, formatter };\n}\n\n/**\n * Renders inline aggregate values for a full-width aggregation row.\n * Returns a container element with aggregate spans, or null if no aggregates are defined.\n */\nfunction renderInlineAggregates(\n rowConfig: AggregationRowConfig,\n columns: ColumnConfig[],\n dataRows: unknown[],\n): HTMLElement | null {\n // Collect fields that have aggregators or cell values\n const hasAggregators = rowConfig.aggregators && Object.keys(rowConfig.aggregators).length > 0;\n const hasCells = rowConfig.cells && Object.keys(rowConfig.cells).length > 0;\n if (!hasAggregators && !hasCells) return null;\n\n const container = document.createElement('span');\n container.className = 'tbw-aggregation-aggregates';\n\n for (const col of columns) {\n const { value, formatter } = resolveAggregatedValue(rowConfig, col, dataRows);\n if (value != null) {\n const span = document.createElement('span');\n span.className = 'tbw-aggregation-aggregate';\n span.setAttribute('data-field', col.field);\n const header = col.header ?? col.field;\n const displayValue = formatter ? formatter(value, col.field, col) : String(value);\n span.textContent = `${header}: ${displayValue}`;\n container.appendChild(span);\n }\n }\n\n return container.children.length > 0 ? container : null;\n}\n\n/**\n * Renders a custom panel element.\n *\n * @param panel - The panel definition\n * @param context - The current grid context\n * @returns The panel DOM element\n */\nfunction renderCustomPanel(panel: PinnedRowsPanel, context: PinnedRowsContext): HTMLElement {\n const panelEl = document.createElement('div');\n panelEl.className = 'tbw-status-panel tbw-status-panel-custom';\n panelEl.id = `status-panel-${panel.id}`;\n\n const content = panel.render(context);\n\n if (typeof content === 'string') {\n panelEl.innerHTML = content;\n } else {\n panelEl.appendChild(content);\n }\n\n return panelEl;\n}\n\n/**\n * Builds the status bar context from grid state and plugin states.\n *\n * @param rows - Current row data\n * @param columns - Current column configuration\n * @param grid - Grid element reference\n * @param selectionState - Optional selection plugin state\n * @param filterState - Optional filtering plugin state\n * @returns The status bar context\n */\nexport function buildContext(\n rows: unknown[],\n columns: unknown[],\n grid: HTMLElement,\n selectionState?: { selected: Set<number> } | null,\n filterState?: { cachedResult: unknown[] | null } | null,\n): PinnedRowsContext {\n return {\n totalRows: rows.length,\n filteredRows: filterState?.cachedResult?.length ?? rows.length,\n selectedRows: selectionState?.selected?.size ?? 0,\n columns: columns as PinnedRowsContext['columns'],\n rows,\n grid,\n };\n}\n","/**\n * Pinned Rows Plugin (Class-based)\n *\n * Adds info bars and aggregation rows to the grid.\n * - Info bar: Shows row counts, selection info, and custom panels\n * - Aggregation rows: Footer/header rows with computed values (sum, avg, etc.)\n */\n\nimport { BaseGridPlugin } from '../../core/plugin/base-plugin';\nimport type { ColumnConfig } from '../../core/types';\nimport { buildContext, createAggregationContainer, createInfoBarElement, renderAggregationRows } from './pinned-rows';\nimport styles from './pinned-rows.css?inline';\nimport type { AggregationRowConfig, PinnedRowsConfig, PinnedRowsContext, PinnedRowsPanel } from './types';\n\n/**\n * Pinned Rows (Status Bar) Plugin for tbw-grid\n *\n * Creates fixed status bars at the top or bottom of the grid for displaying aggregations,\n * row counts, or custom content. Think of it as the \"totals row\" you'd see in a spreadsheet—\n * always visible regardless of scroll position.\n *\n * ## Installation\n *\n * ```ts\n * import { PinnedRowsPlugin } from '@toolbox-web/grid/plugins/pinned-rows';\n * ```\n *\n * ## Built-in Aggregation Functions\n *\n * | Function | Description |\n * |----------|-------------|\n * | `sum` | Sum of values |\n * | `avg` | Average of values |\n * | `count` | Count of rows |\n * | `min` | Minimum value |\n * | `max` | Maximum value |\n *\n * ## CSS Custom Properties\n *\n * | Property | Default | Description |\n * |----------|---------|-------------|\n * | `--tbw-pinned-rows-bg` | `var(--tbw-color-panel-bg)` | Status bar background |\n * | `--tbw-pinned-rows-border` | `var(--tbw-color-border)` | Status bar border |\n *\n * @example Status Bar with Aggregation\n * ```ts\n * import '@toolbox-web/grid';\n * import { PinnedRowsPlugin } from '@toolbox-web/grid/plugins/pinned-rows';\n *\n * grid.gridConfig = {\n * columns: [\n * { field: 'product', header: 'Product' },\n * { field: 'quantity', header: 'Qty', type: 'number' },\n * { field: 'price', header: 'Price', type: 'currency' },\n * ],\n * plugins: [\n * new PinnedRowsPlugin({\n * position: 'bottom',\n * showRowCount: true,\n * aggregationRows: [\n * {\n * id: 'totals',\n * aggregators: { quantity: 'sum', price: 'sum' },\n * cells: { product: 'Totals:' },\n * },\n * ],\n * }),\n * ],\n * };\n * ```\n *\n * @see {@link PinnedRowsConfig} for all configuration options\n * @see {@link AggregationRowConfig} for aggregation row structure\n *\n * @internal Extends BaseGridPlugin\n */\nexport class PinnedRowsPlugin extends BaseGridPlugin<PinnedRowsConfig> {\n /** @internal */\n readonly name = 'pinnedRows';\n /** @internal */\n override readonly styles = styles;\n\n /** @internal */\n protected override get defaultConfig(): Partial<PinnedRowsConfig> {\n return {\n position: 'bottom',\n showRowCount: true,\n showSelectedCount: true,\n showFilteredCount: true,\n };\n }\n\n // #region Internal State\n private infoBarElement: HTMLElement | null = null;\n private topAggregationContainer: HTMLElement | null = null;\n private bottomAggregationContainer: HTMLElement | null = null;\n private footerWrapper: HTMLElement | null = null;\n // #endregion\n\n // #region Lifecycle\n /** @internal */\n override detach(): void {\n if (this.infoBarElement) {\n this.infoBarElement.remove();\n this.infoBarElement = null;\n }\n if (this.topAggregationContainer) {\n this.topAggregationContainer.remove();\n this.topAggregationContainer = null;\n }\n if (this.bottomAggregationContainer) {\n this.bottomAggregationContainer.remove();\n this.bottomAggregationContainer = null;\n }\n if (this.footerWrapper) {\n this.footerWrapper.remove();\n this.footerWrapper = null;\n }\n }\n // #endregion\n\n // #region Hooks\n /** @internal */\n override afterRender(): void {\n const gridEl = this.gridElement;\n if (!gridEl) return;\n\n // Use .tbw-scroll-area so footer is inside the horizontal scroll area,\n // otherwise fall back to .tbw-grid-content or root container\n const container =\n gridEl.querySelector('.tbw-scroll-area') ??\n gridEl.querySelector('.tbw-grid-content') ??\n gridEl.querySelector('.tbw-grid-root');\n if (!container) return;\n\n // Clear orphaned element references if they were removed from the DOM\n // (e.g., by buildGridDOMIntoShadow calling replaceChildren())\n // We check if the element is still inside the container rather than isConnected,\n // because in unit tests the mock grid may not be attached to document.body\n if (this.footerWrapper && !container.contains(this.footerWrapper)) {\n this.footerWrapper = null;\n this.bottomAggregationContainer = null;\n this.infoBarElement = null;\n }\n if (this.topAggregationContainer && !container.contains(this.topAggregationContainer)) {\n this.topAggregationContainer = null;\n }\n if (this.infoBarElement && !container.contains(this.infoBarElement)) {\n this.infoBarElement = null;\n }\n\n // Build context with plugin states\n const selectionState = this.getSelectionState();\n const filterState = this.getFilterState();\n\n const context = buildContext(\n this.sourceRows as unknown[],\n this.columns as unknown[],\n this.gridElement,\n selectionState,\n filterState,\n );\n\n // #region Handle Aggregation Rows\n const aggregationRows = this.config.aggregationRows || [];\n const topRows = aggregationRows.filter((r) => r.position === 'top');\n const bottomRows = aggregationRows.filter((r) => r.position !== 'top');\n\n // Top aggregation rows\n if (topRows.length > 0) {\n if (!this.topAggregationContainer) {\n this.topAggregationContainer = createAggregationContainer('top');\n const header = gridEl.querySelector('.header');\n if (header && header.nextSibling) {\n container.insertBefore(this.topAggregationContainer, header.nextSibling);\n } else {\n container.appendChild(this.topAggregationContainer);\n }\n }\n renderAggregationRows(\n this.topAggregationContainer,\n topRows,\n this.visibleColumns as ColumnConfig[],\n this.sourceRows as unknown[],\n this.config.fullWidth,\n );\n } else if (this.topAggregationContainer) {\n this.topAggregationContainer.remove();\n this.topAggregationContainer = null;\n }\n\n // Handle footer\n const hasInfoContent =\n this.config.showRowCount !== false ||\n (this.config.showSelectedCount && context.selectedRows > 0) ||\n (this.config.showFilteredCount && context.filteredRows !== context.totalRows) ||\n (this.config.customPanels && this.config.customPanels.length > 0);\n const hasBottomInfoBar = hasInfoContent && this.config.position !== 'top';\n const needsFooter = bottomRows.length > 0 || hasBottomInfoBar;\n\n // Handle top info bar\n if (hasInfoContent && this.config.position === 'top') {\n if (!this.infoBarElement) {\n this.infoBarElement = createInfoBarElement(this.config, context);\n container.insertBefore(this.infoBarElement, container.firstChild);\n } else {\n const newInfoBar = createInfoBarElement(this.config, context);\n this.infoBarElement.replaceWith(newInfoBar);\n this.infoBarElement = newInfoBar;\n }\n } else if (this.config.position === 'top' && this.infoBarElement) {\n this.infoBarElement.remove();\n this.infoBarElement = null;\n }\n\n // Create/manage footer wrapper\n if (needsFooter) {\n if (!this.footerWrapper) {\n this.footerWrapper = document.createElement('div');\n this.footerWrapper.className = 'tbw-footer';\n container.appendChild(this.footerWrapper);\n }\n\n this.footerWrapper.innerHTML = '';\n\n if (bottomRows.length > 0) {\n if (!this.bottomAggregationContainer) {\n this.bottomAggregationContainer = createAggregationContainer('bottom');\n }\n this.footerWrapper.appendChild(this.bottomAggregationContainer);\n renderAggregationRows(\n this.bottomAggregationContainer,\n bottomRows,\n this.visibleColumns as ColumnConfig[],\n this.sourceRows as unknown[],\n this.config.fullWidth,\n );\n }\n\n if (hasBottomInfoBar) {\n this.infoBarElement = createInfoBarElement(this.config, context);\n this.footerWrapper.appendChild(this.infoBarElement);\n }\n } else {\n this.cleanupFooter();\n }\n // #endregion\n }\n // #endregion\n\n // #region Private Methods\n private cleanup(): void {\n if (this.infoBarElement) {\n this.infoBarElement.remove();\n this.infoBarElement = null;\n }\n if (this.topAggregationContainer) {\n this.topAggregationContainer.remove();\n this.topAggregationContainer = null;\n }\n if (this.bottomAggregationContainer) {\n this.bottomAggregationContainer.remove();\n this.bottomAggregationContainer = null;\n }\n if (this.footerWrapper) {\n this.footerWrapper.remove();\n this.footerWrapper = null;\n }\n }\n\n private cleanupFooter(): void {\n if (this.footerWrapper) {\n this.footerWrapper.remove();\n this.footerWrapper = null;\n }\n if (this.bottomAggregationContainer) {\n this.bottomAggregationContainer.remove();\n this.bottomAggregationContainer = null;\n }\n if (this.infoBarElement && this.config.position !== 'top') {\n this.infoBarElement.remove();\n this.infoBarElement = null;\n }\n }\n\n private getSelectionState(): { selected: Set<number> } | null {\n // Try to get selection plugin state\n try {\n return (this.grid?.getPluginState?.('selection') as { selected: Set<number> } | null) ?? null;\n } catch {\n return null;\n }\n }\n\n private getFilterState(): { cachedResult: unknown[] | null } | null {\n try {\n return (this.grid?.getPluginState?.('filtering') as { cachedResult: unknown[] | null } | null) ?? null;\n } catch {\n return null;\n }\n }\n // #endregion\n\n // #region Public API\n /**\n * Refresh the status bar to reflect current grid state.\n */\n refresh(): void {\n this.requestRender();\n }\n\n /**\n * Get the current status bar context.\n * @returns The context with row counts and other info\n */\n getContext(): PinnedRowsContext {\n const selectionState = this.getSelectionState();\n const filterState = this.getFilterState();\n\n return buildContext(\n this.rows as unknown[],\n this.columns as unknown[],\n this.gridElement,\n selectionState,\n filterState,\n );\n }\n\n /**\n * Add a custom panel to the info bar.\n * @param panel - The panel configuration to add\n */\n addPanel(panel: PinnedRowsPanel): void {\n if (!this.config.customPanels) {\n this.config.customPanels = [];\n }\n this.config.customPanels.push(panel);\n this.requestRender();\n }\n\n /**\n * Remove a custom panel by ID.\n * @param id - The panel ID to remove\n */\n removePanel(id: string): void {\n if (this.config.customPanels) {\n this.config.customPanels = this.config.customPanels.filter((p) => p.id !== id);\n this.requestRender();\n }\n }\n\n /**\n * Add an aggregation row.\n * @param row - The aggregation row configuration\n */\n addAggregationRow(row: AggregationRowConfig): void {\n if (!this.config.aggregationRows) {\n this.config.aggregationRows = [];\n }\n this.config.aggregationRows.push(row);\n this.requestRender();\n }\n\n /**\n * Remove an aggregation row by ID.\n * @param id - The aggregation row ID to remove\n */\n removeAggregationRow(id: string): void {\n if (this.config.aggregationRows) {\n this.config.aggregationRows = this.config.aggregationRows.filter((r) => r.id !== id);\n this.requestRender();\n }\n }\n // #endregion\n}\n"],"names":["createInfoBarElement","config","context","pinnedRows","document","createElement","className","setAttribute","left","center","right","showRowCount","rowCount","textContent","totalRows","appendChild","showFilteredCount","filteredRows","filteredCount","showSelectedCount","selectedRows","selectedCount","customPanels","panel","panelEl","renderCustomPanel","position","createAggregationContainer","container","renderAggregationRows","rows","columns","dataRows","globalFullWidth","innerHTML","rowConfig","rowEl","id","fullWidth","renderFullWidthAggregationRow","renderPerColumnAggregationRow","cell","style","gridColumn","labelValue","label","labelSpan","aggregatesContainer","hasAggregators","aggregators","Object","keys","length","hasCells","cells","col","value","formatter","resolveAggregatedValue","span","field","header","displayValue","String","children","renderInlineAggregates","labelEl","aggDef","def","aggFn","aggregatorRegistry","get","aggFunc","prototype","hasOwnProperty","call","staticVal","content","render","buildContext","grid","selectionState","filterState","cachedResult","selected","size","PinnedRowsPlugin","BaseGridPlugin","name","styles","defaultConfig","infoBarElement","topAggregationContainer","bottomAggregationContainer","footerWrapper","detach","this","remove","afterRender","gridEl","gridElement","querySelector","contains","getSelectionState","getFilterState","sourceRows","aggregationRows","topRows","filter","r","bottomRows","nextSibling","insertBefore","visibleColumns","hasInfoContent","hasBottomInfoBar","needsFooter","newInfoBar","replaceWith","firstChild","cleanupFooter","cleanup","getPluginState","refresh","requestRender","getContext","addPanel","push","removePanel","p","addAggregationRow","row","removeAggregationRow"],"mappings":"6aAgCO,SAASA,EAAqBC,EAA0BC,GAC7D,MAAMC,EAAaC,SAASC,cAAc,OAC1CF,EAAWG,UAAY,kBACvBH,EAAWI,aAAa,OAAQ,gBAChCJ,EAAWI,aAAa,YAAa,UAErC,MAAMC,EAAOJ,SAASC,cAAc,OACpCG,EAAKF,UAAY,uBAEjB,MAAMG,EAASL,SAASC,cAAc,OACtCI,EAAOH,UAAY,yBAEnB,MAAMI,EAAQN,SAASC,cAAc,OAIrC,GAHAK,EAAMJ,UAAY,yBAGU,IAAxBL,EAAOU,aAAwB,CACjC,MAAMC,EAAWR,SAASC,cAAc,QACxCO,EAASN,UAAY,8CACrBM,EAASC,YAAc,UAAUX,EAAQ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