@toolbox-web/grid 1.28.2 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +2 -2
- package/all.js.map +1 -1
- package/custom-elements.json +43 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/core/constants.d.ts +1 -7
- package/lib/core/grid.d.ts +47 -3
- package/lib/core/internal/render-scheduler.d.ts +3 -1
- package/lib/core/plugin/base-plugin.d.ts +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +2 -0
- package/lib/core/types.d.ts +55 -0
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +0 -21
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +0 -16
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/index.js +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/ExportPlugin.d.ts +0 -18
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +0 -21
- package/lib/plugins/filtering/filter-model.d.ts +8 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +0 -16
- package/lib/plugins/grouping-columns/grouping-columns.d.ts +23 -3
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +0 -23
- package/lib/plugins/grouping-rows/index.js +2 -2
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +0 -22
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +0 -18
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/multi-sort/multi-sort.d.ts +7 -0
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +18 -4
- 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.d.ts +38 -2
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +0 -11
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/PivotPlugin.d.ts +0 -24
- package/lib/plugins/pivot/index.js +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/PrintPlugin.d.ts +2 -21
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder-columns/ReorderPlugin.d.ts +0 -7
- package/lib/plugins/reorder-columns/index.js +1 -1
- package/lib/plugins/reorder-columns/index.js.map +1 -1
- package/lib/plugins/reorder-rows/RowReorderPlugin.d.ts +1 -13
- package/lib/plugins/reorder-rows/index.js +1 -1
- package/lib/plugins/reorder-rows/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/ServerSidePlugin.d.ts +0 -16
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tooltip/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +0 -22
- package/lib/plugins/tree/index.js +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +0 -19
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +0 -16
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/themes/dg-theme-material.css +5 -0
- package/umd/grid.all.umd.js +1 -1
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -1
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/export.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-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.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.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.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/print.umd.js.map +1 -1
- package/umd/plugins/reorder-columns.umd.js +1 -1
- package/umd/plugins/reorder-columns.umd.js.map +1 -1
- package/umd/plugins/reorder-rows.umd.js +1 -1
- package/umd/plugins/reorder-rows.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-sort.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/multi-sort/multi-sort.ts","../../../../../libs/grid/src/lib/plugins/multi-sort/MultiSortPlugin.ts"],"sourcesContent":["/**\n * Multi-Sort Core Logic\n *\n * Pure functions for multi-column sorting operations.\n */\n\nimport type { ColumnConfig } from '../../core/types';\nimport type { SortModel } from './types';\n\n/**\n * Apply multiple sort columns to a row array.\n * Sorts are applied in order - first sort has highest priority.\n *\n * @param rows - Array of row objects to sort\n * @param sorts - Ordered array of sort configurations\n * @param columns - Column configurations (for custom comparators)\n * @returns New sorted array (does not mutate original)\n */\nexport function applySorts<TRow = unknown>(rows: TRow[], sorts: SortModel[], columns: ColumnConfig<TRow>[]): TRow[] {\n if (!sorts.length) return [...rows];\n\n return [...rows].sort((a, b) => {\n for (const sort of sorts) {\n const col = columns.find((c) => c.field === sort.field);\n const comparator = col?.sortComparator ?? defaultComparator;\n const aVal = (a as Record<string, unknown>)[sort.field];\n const bVal = (b as Record<string, unknown>)[sort.field];\n const result = comparator(aVal, bVal, a, b);\n if (result !== 0) {\n return sort.direction === 'asc' ? result : -result;\n }\n }\n return 0;\n });\n}\n\n/**\n * Default comparator for sorting values.\n * Handles nulls, numbers, dates, and strings.\n *\n * @param a - First value\n * @param b - Second value\n * @returns Comparison result (-1, 0, 1)\n */\nexport function defaultComparator(a: unknown, b: unknown): number {\n // Handle nulls/undefined - push to end\n if (a == null && b == null) return 0;\n if (a == null) return 1;\n if (b == null) return -1;\n\n // Type-aware comparison\n if (typeof a === 'number' && typeof b === 'number') {\n return a - b;\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() - b.getTime();\n }\n\n // Boolean comparison\n if (typeof a === 'boolean' && typeof b === 'boolean') {\n return a === b ? 0 : a ? -1 : 1;\n }\n\n // String comparison (fallback)\n return String(a).localeCompare(String(b));\n}\n\n/**\n * Toggle sort state for a field.\n * With shift key: adds/toggles in multi-sort list\n * Without shift key: replaces entire sort with single column\n *\n * @param current - Current sort model\n * @param field - Field to toggle\n * @param shiftKey - Whether shift key is held (multi-sort mode)\n * @param maxColumns - Maximum columns allowed in sort\n * @returns New sort model\n */\nexport function toggleSort(current: SortModel[], field: string, shiftKey: boolean, maxColumns: number): SortModel[] {\n const existing = current.find((s) => s.field === field);\n\n if (shiftKey) {\n // Multi-sort: add/toggle in list\n if (existing) {\n if (existing.direction === 'asc') {\n // Flip to descending\n return current.map((s) => (s.field === field ? { ...s, direction: 'desc' as const } : s));\n } else {\n // Remove from sort\n return current.filter((s) => s.field !== field);\n }\n } else if (current.length < maxColumns) {\n // Add new sort column\n return [...current, { field, direction: 'asc' as const }];\n }\n // Max columns reached, return unchanged\n return current;\n } else {\n // Single sort: replace all\n if (existing?.direction === 'asc') {\n return [{ field, direction: 'desc' }];\n } else if (existing?.direction === 'desc') {\n return [];\n }\n return [{ field, direction: 'asc' }];\n }\n}\n\n/**\n * Get the sort index (1-based) for a field in the sort model.\n * Returns undefined if the field is not in the sort model.\n *\n * @param sortModel - Current sort model\n * @param field - Field to check\n * @returns 1-based index or undefined\n */\nexport function getSortIndex(sortModel: SortModel[], field: string): number | undefined {\n const index = sortModel.findIndex((s) => s.field === field);\n return index >= 0 ? index + 1 : undefined;\n}\n\n/**\n * Get the sort direction for a field in the sort model.\n *\n * @param sortModel - Current sort model\n * @param field - Field to check\n * @returns Sort direction or undefined if not sorted\n */\nexport function getSortDirection(sortModel: SortModel[], field: string): 'asc' | 'desc' | undefined {\n return sortModel.find((s) => s.field === field)?.direction;\n}\n","/**\n * Multi-Sort Plugin (Class-based)\n *\n * Provides multi-column sorting capabilities for tbw-grid.\n * Supports shift+click for adding secondary sort columns.\n */\n\nimport { announce } from '../../core/internal/aria';\nimport { BaseGridPlugin, HeaderClickEvent } from '../../core/plugin/base-plugin';\nimport type { ColumnState, GridHost } from '../../core/types';\nimport { applySorts, getSortDirection, getSortIndex, toggleSort } from './multi-sort';\nimport styles from './multi-sort.css?inline';\nimport type { MultiSortConfig, SortModel } from './types';\n\n/**\n * Multi-Sort Plugin for tbw-grid\n *\n * Enables sorting by multiple columns at once—hold Shift and click additional column\n * headers to build up a sort stack. Priority badges show the sort order, so users\n * always know which column takes precedence.\n *\n * ## Installation\n *\n * ```ts\n * import { MultiSortPlugin } from '@toolbox-web/grid/plugins/multi-sort';\n * ```\n *\n * ## Configuration Options\n *\n * | Option | Type | Default | Description |\n * |--------|------|---------|-------------|\n * | `maxSortColumns` | `number` | `3` | Maximum columns to sort by |\n * | `showSortIndex` | `boolean` | `true` | Show sort priority badges |\n * | `initialSort` | `SortModel[]` | - | Pre-configured sort order on load |\n *\n * ## Keyboard Shortcuts\n *\n * | Shortcut | Action |\n * |----------|--------|\n * | `Click header` | Sort by column (clears other sorts) |\n * | `Shift + Click` | Add column to multi-sort stack |\n * | `Ctrl + Click` | Toggle sort direction |\n *\n * ## Events\n *\n * | Event | Detail | Description |\n * |-------|--------|-------------|\n * | `sort-change` | `{ sortModel: SortModel[] }` | Fired when sort changes |\n *\n * ## Programmatic API\n *\n * | Method | Signature | Description |\n * |--------|-----------|-------------|\n * | `setSort` | `(sortModel: SortModel[]) => void` | Set sort programmatically |\n * | `getSortModel` | `() => SortModel[]` | Get current sort model |\n * | `clearSort` | `() => void` | Clear all sorting |\n * | `addSort` | `(field, direction) => void` | Add a column to sort |\n * | `removeSort` | `(field) => void` | Remove a column from sort |\n *\n * @example Basic Multi-Column Sorting\n * ```ts\n * import { queryGrid } from '@toolbox-web/grid';\n * import { MultiSortPlugin } from '@toolbox-web/grid/plugins/multi-sort';\n *\n * const grid = queryGrid('tbw-grid');\n * grid.gridConfig = {\n * columns: [\n * { field: 'name', header: 'Name', sortable: true },\n * { field: 'department', header: 'Department', sortable: true },\n * { field: 'salary', header: 'Salary', type: 'number', sortable: true },\n * ],\n * plugins: [new MultiSortPlugin({ maxSortColumns: 3, showSortIndex: true })],\n * };\n *\n * grid.on('sort-change', ({ sortModel }) => {\n * console.log('Active sorts:', sortModel);\n * });\n * ```\n *\n * @example Initial Sort Configuration\n * ```ts\n * new MultiSortPlugin({\n * initialSort: [\n * { field: 'department', direction: 'asc' },\n * { field: 'salary', direction: 'desc' },\n * ],\n * })\n * ```\n *\n * @see {@link MultiSortConfig} for all configuration options\n * @see {@link SortModel} for the sort model structure\n *\n * @internal Extends BaseGridPlugin\n */\nexport class MultiSortPlugin extends BaseGridPlugin<MultiSortConfig> {\n /** @internal */\n readonly name = 'multiSort';\n /** @internal */\n override readonly styles = styles;\n\n /** @internal */\n protected override get defaultConfig(): Partial<MultiSortConfig> {\n return {\n maxSortColumns: 3,\n showSortIndex: true,\n };\n }\n\n // #region Internal State\n private sortModel: SortModel[] = [];\n /** Cached sort result — returned as-is while a row edit is active to prevent\n * the edited row from jumping to a new sorted position mid-edit. Row data\n * mutations are still visible because the array holds shared object refs. */\n private cachedSortResult: unknown[] | null = null;\n\n /** Typed internal grid accessor. */\n get #internalGrid(): GridHost {\n return this.grid as unknown as GridHost;\n }\n\n /**\n * Clear the core `_sortState` so that only this plugin's `processRows`\n * sorting applies. `ConfigManager.applyState()` always sets the core sort\n * state when restoring from storage, even when a plugin handles sorting.\n * Without this, the stale core state leaks into `collectState()` and\n * `reapplyCoreSort()` after the plugin clears its own model.\n */\n private clearCoreSortState(): void {\n this.#internalGrid._sortState = null;\n }\n // #endregion\n\n // #region Lifecycle\n\n /** @internal */\n override detach(): void {\n this.sortModel = [];\n this.cachedSortResult = null;\n }\n // #endregion\n\n // #region Hooks\n\n /** @internal */\n override processRows(rows: readonly unknown[]): unknown[] {\n if (this.sortModel.length === 0) {\n this.cachedSortResult = null;\n return [...rows];\n }\n\n // Freeze sort order while a row is actively being edited (row mode only).\n // Re-sorting mid-edit would move the edited row to a new index while the\n // editors remain at the old position, causing data/UI mismatch.\n // In grid mode (_isGridEditMode) sorting is safe — afterCellRender\n // re-injects editors into the re-sorted cells.\n // We return the cached previous sort result (same object references, so\n // in-place value mutations are already visible) instead of unsorted input.\n const grid = this.#internalGrid;\n if (!grid._isGridEditMode && typeof grid._activeEditRows === 'number' && grid._activeEditRows !== -1) {\n if (this.cachedSortResult && this.cachedSortResult.length === rows.length) {\n return [...this.cachedSortResult];\n }\n }\n\n const sorted = applySorts([...rows], this.sortModel, [...this.columns]);\n this.cachedSortResult = sorted;\n return sorted;\n }\n\n /** @internal */\n override onHeaderClick(event: HeaderClickEvent): boolean {\n const column = this.columns.find((c) => c.field === event.field);\n if (!column?.sortable) return false;\n\n const shiftKey = event.originalEvent.shiftKey;\n const maxColumns = this.config.maxSortColumns ?? 3;\n\n this.sortModel = toggleSort(this.sortModel, event.field, shiftKey, maxColumns);\n this.clearCoreSortState();\n\n this.emit('sort-change', { sortModel: [...this.sortModel] });\n this.requestRender();\n this.grid?.requestStateChange?.();\n\n // Announce for screen readers\n if (this.sortModel.length > 0) {\n const labels = this.sortModel.map((s) => {\n const col = this.columns.find((c) => c.field === s.field);\n return `${col?.header ?? s.field} ${s.direction === 'asc' ? 'ascending' : 'descending'}`;\n });\n announce(this.gridElement!, `Sorted by ${labels.join(', then ')}`);\n } else {\n announce(this.gridElement!, 'Sort cleared');\n }\n\n return true;\n }\n\n /** @internal */\n override afterRender(): void {\n const gridEl = this.gridElement;\n if (!gridEl) return;\n\n const showIndex = this.config.showSortIndex !== false;\n\n // Update all sortable header cells with sort indicators\n const headerCells = gridEl.querySelectorAll('.header-row .cell[data-field]');\n headerCells.forEach((cell) => {\n const field = cell.getAttribute('data-field');\n if (!field) return;\n\n const sortIndex = getSortIndex(this.sortModel, field);\n const sortDir = getSortDirection(this.sortModel, field);\n\n // Remove existing sort index badge (always clean up)\n const existingBadge = cell.querySelector('.sort-index');\n existingBadge?.remove();\n\n if (sortDir) {\n // Column is sorted - remove base indicator and add our own\n const existingIndicator = cell.querySelector('[part~=\"sort-indicator\"], .sort-indicator');\n existingIndicator?.remove();\n\n cell.setAttribute('data-sort', sortDir);\n\n // Add sort arrow indicator - insert BEFORE filter button and resize handle\n // to maintain consistent order: [label, sort-indicator, sort-index, filter-btn, resize-handle]\n const indicator = document.createElement('span');\n indicator.className = 'sort-indicator';\n // Use grid-level icons (fall back to defaults)\n this.setIcon(indicator, this.resolveIcon(sortDir === 'asc' ? 'sortAsc' : 'sortDesc'));\n\n // Find insertion point: before filter button or resize handle\n const filterBtn = cell.querySelector('.tbw-filter-btn');\n const resizeHandle = cell.querySelector('.resize-handle');\n const insertBefore = filterBtn ?? resizeHandle;\n if (insertBefore) {\n cell.insertBefore(indicator, insertBefore);\n } else {\n cell.appendChild(indicator);\n }\n\n // Add sort index badge if multiple columns sorted and showSortIndex is enabled\n if (showIndex && this.sortModel.length > 1 && sortIndex !== undefined) {\n const badge = document.createElement('span');\n badge.className = 'sort-index';\n badge.textContent = String(sortIndex);\n // Insert badge right after the indicator\n if (indicator.nextSibling) {\n cell.insertBefore(badge, indicator.nextSibling);\n } else {\n cell.appendChild(badge);\n }\n }\n } else {\n cell.removeAttribute('data-sort');\n // Remove any stale sort indicators left by a previous afterRender cycle\n // Base indicators use part=\"sort-indicator\", plugin indicators use class=\"sort-indicator\"\n const staleIndicator = cell.querySelector('[part~=\"sort-indicator\"], .sort-indicator');\n staleIndicator?.remove();\n }\n });\n }\n // #endregion\n\n // #region Public API\n\n /**\n * Get the current sort model.\n * @returns Copy of the current sort model\n */\n getSortModel(): SortModel[] {\n return [...this.sortModel];\n }\n\n /**\n * Set the sort model programmatically.\n * @param model - New sort model to apply\n */\n setSortModel(model: SortModel[]): void {\n this.sortModel = [...model];\n this.clearCoreSortState();\n this.emit('sort-change', { sortModel: [...model] });\n this.requestRender();\n this.grid?.requestStateChange?.();\n if (model.length > 0) {\n const labels = model.map((s) => {\n const col = this.columns.find((c) => c.field === s.field);\n return `${col?.header ?? s.field} ${s.direction === 'asc' ? 'ascending' : 'descending'}`;\n });\n announce(this.gridElement!, `Sorted by ${labels.join(', then ')}`);\n }\n }\n\n /**\n * Clear all sorting.\n */\n clearSort(): void {\n this.sortModel = [];\n this.clearCoreSortState();\n this.emit('sort-change', { sortModel: [] });\n this.requestRender();\n this.grid?.requestStateChange?.();\n announce(this.gridElement!, 'Sort cleared');\n }\n\n /**\n * Get the sort index (1-based) for a specific field.\n * @param field - Field to check\n * @returns 1-based index or undefined if not sorted\n */\n getSortIndex(field: string): number | undefined {\n return getSortIndex(this.sortModel, field);\n }\n\n /**\n * Get the sort direction for a specific field.\n * @param field - Field to check\n * @returns Sort direction or undefined if not sorted\n */\n getSortDirection(field: string): 'asc' | 'desc' | undefined {\n return getSortDirection(this.sortModel, field);\n }\n // #endregion\n\n // #region Column State Hooks\n\n /**\n * Return sort state for a column if it's in the sort model.\n * @internal\n */\n override getColumnState(field: string): Partial<ColumnState> | undefined {\n const index = this.sortModel.findIndex((s) => s.field === field);\n if (index === -1) return undefined;\n\n const sortEntry = this.sortModel[index];\n return {\n sort: {\n direction: sortEntry.direction,\n priority: index,\n },\n };\n }\n\n /**\n * Apply sort state from column state.\n * Rebuilds the sort model from all column states.\n * @internal\n */\n override applyColumnState(field: string, state: ColumnState): void {\n // Only process if the column has sort state\n if (!state.sort) {\n // Remove this field from sortModel if it exists\n this.sortModel = this.sortModel.filter((s) => s.field !== field);\n return;\n }\n\n // Find existing entry or add new one\n const existingIndex = this.sortModel.findIndex((s) => s.field === field);\n const newEntry: SortModel = {\n field,\n direction: state.sort.direction,\n };\n\n if (existingIndex !== -1) {\n // Update existing entry\n this.sortModel[existingIndex] = newEntry;\n } else {\n // Add at the correct priority position\n this.sortModel.splice(state.sort.priority, 0, newEntry);\n }\n\n // Clear core sort state — this plugin exclusively handles sorting via\n // processRows. The core _sortState is set by ConfigManager.applyState()\n // before plugins run; null it so reapplyCoreSort() is a no-op.\n this.clearCoreSortState();\n }\n // #endregion\n}\n"],"names":["defaultComparator","a","b","Date","getTime","String","localeCompare","getSortIndex","sortModel","field","index","findIndex","s","getSortDirection","find","direction","MultiSortPlugin","BaseGridPlugin","name","styles","defaultConfig","maxSortColumns","showSortIndex","cachedSortResult","internalGrid","this","grid","clearCoreSortState","_sortState","detach","processRows","rows","length","_isGridEditMode","_activeEditRows","sorted","sorts","columns","sort","col","c","result","sortComparator","applySorts","onHeaderClick","event","column","sortable","shiftKey","originalEvent","maxColumns","config","current","existing","map","filter","toggleSort","emit","requestRender","requestStateChange","labels","header","announce","gridElement","join","afterRender","gridEl","showIndex","querySelectorAll","forEach","cell","getAttribute","sortIndex","sortDir","existingBadge","querySelector","remove","existingIndicator","setAttribute","indicator","document","createElement","className","setIcon","resolveIcon","filterBtn","resizeHandle","insertBefore","appendChild","badge","textContent","nextSibling","removeAttribute","staleIndicator","getSortModel","setSortModel","model","clearSort","getColumnState","priority","applyColumnState","state","existingIndex","newEntry","splice"],"mappings":"8ZA4CO,SAASA,EAAkBC,EAAYC,GAE5C,OAAS,MAALD,GAAkB,MAALC,EAAkB,EAC1B,MAALD,EAAkB,EACb,MAALC,GAAkB,EAGL,iBAAND,GAA+B,iBAANC,EAC3BD,EAAIC,EAGTD,aAAaE,MAAQD,aAAaC,KAC7BF,EAAEG,UAAYF,EAAEE,UAIR,kBAANH,GAAgC,kBAANC,EAC5BD,IAAMC,EAAI,EAAID,GAAI,EAAK,EAIzBI,OAAOJ,GAAGK,cAAcD,OAAOH,GACxC,CAmDO,SAASK,EAAaC,EAAwBC,GACnD,MAAMC,EAAQF,EAAUG,UAAWC,GAAMA,EAAEH,QAAUA,GACrD,OAAOC,GAAS,EAAIA,EAAQ,OAAI,CAClC,CASO,SAASG,EAAiBL,EAAwBC,GACvD,OAAOD,EAAUM,KAAMF,GAAMA,EAAEH,QAAUA,IAAQM,SACnD,CCrCO,MAAMC,UAAwBC,EAAAA,eAE1BC,KAAO,YAEEC,isBAGlB,iBAAuBC,GACrB,MAAO,CACLC,eAAgB,EAChBC,eAAe,EAEnB,CAGQd,UAAyB,GAIzBe,iBAAqC,KAG7C,KAAIC,GACF,OAAOC,KAAKC,IACd,CASQ,kBAAAC,GACNF,MAAKD,EAAcI,WAAa,IAClC,CAMS,MAAAC,GACPJ,KAAKjB,UAAY,GACjBiB,KAAKF,iBAAmB,IAC1B,CAMS,WAAAO,CAAYC,GACnB,GAA8B,IAA1BN,KAAKjB,UAAUwB,OAEjB,OADAP,KAAK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CAOA,YAAAxD,CAAaE,GACX,OAAOF,EAAakB,KAAKjB,UAAWC,EACtC,CAOA,gBAAAI,CAAiBJ,GACf,OAAOI,EAAiBY,KAAKjB,UAAWC,EAC1C,CASS,cAAAyF,CAAezF,GACtB,MAAMC,EAAQe,KAAKjB,UAAUG,UAAWC,GAAMA,EAAEH,QAAUA,GAC1D,QAAIC,EAAc,OAGlB,MAAO,CACL4B,KAAM,CACJvB,UAHcU,KAAKjB,UAAUE,GAGRK,UACrBoF,SAAUzF,GAGhB,CAOS,gBAAA0F,CAAiB3F,EAAe4F,GAEvC,IAAKA,EAAM/D,KAGT,YADAb,KAAKjB,UAAYiB,KAAKjB,UAAU+C,OAAQ3C,GAAMA,EAAEH,QAAUA,IAK5D,MAAM6F,EAAgB7E,KAAKjB,UAAUG,UAAWC,GAAMA,EAAEH,QAAUA,GAC5D8F,EAAsB,CAC1B9F,QACAM,UAAWsF,EAAM/D,KAAKvB,YAGF,IAAlBuF,EAEF7E,KAAKjB,UAAU8F,GAAiBC,EAGhC9E,KAAKjB,UAAUgG,OAAOH,EAAM/D,KAAK6D,SAAU,EAAGI,GAMhD9E,KAAKE,oBACP"}
|
|
1
|
+
{"version":3,"file":"multi-sort.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/multi-sort/multi-sort.ts","../../../../../libs/grid/src/lib/plugins/multi-sort/MultiSortPlugin.ts"],"sourcesContent":["/**\n * Multi-Sort Core Logic\n *\n * Pure functions for multi-column sorting operations.\n */\n\nimport type { ColumnConfig } from '../../core/types';\nimport type { SortModel } from './types';\n\n/**\n * Apply multiple sort columns to a row array.\n * Sorts are applied in order - first sort has highest priority.\n *\n * @param rows - Array of row objects to sort\n * @param sorts - Ordered array of sort configurations\n * @param columns - Column configurations (for custom comparators)\n * @returns New sorted array (does not mutate original)\n */\nexport function applySorts<TRow = unknown>(rows: TRow[], sorts: SortModel[], columns: ColumnConfig<TRow>[]): TRow[] {\n if (!sorts.length) return [...rows];\n\n const copy = [...rows];\n sortRowsInPlace(copy, sorts, columns);\n return copy;\n}\n\n/**\n * Sort an array in-place using multiple sort columns.\n * Pre-resolves column comparators to avoid O(n·log·n·m) column lookups\n * inside the comparator.\n * @internal\n */\nexport function sortRowsInPlace<TRow = unknown>(rows: TRow[], sorts: SortModel[], columns: ColumnConfig<TRow>[]): void {\n if (!sorts.length) return;\n\n // Pre-resolve comparator chain — avoids columns.find() on every pair comparison\n const chain = sorts.map((sort) => {\n const col = columns.find((c) => c.field === sort.field);\n return {\n field: sort.field,\n asc: sort.direction === 'asc',\n comparator: col?.sortComparator ?? defaultComparator,\n };\n });\n\n if (chain.length === 1) {\n // Single-sort fast path — avoid loop overhead\n const { field, asc, comparator } = chain[0];\n rows.sort((a: any, b: any) => {\n const result = comparator(a[field], b[field], a, b);\n return asc ? result : -result;\n });\n } else {\n rows.sort((a: any, b: any) => {\n for (let i = 0; i < chain.length; i++) {\n const { field, asc, comparator } = chain[i];\n const result = comparator(a[field], b[field], a, b);\n if (result !== 0) return asc ? result : -result;\n }\n return 0;\n });\n }\n}\n\n/**\n * Default comparator for sorting values.\n * Handles nulls, numbers, dates, and strings.\n *\n * @param a - First value\n * @param b - Second value\n * @returns Comparison result (-1, 0, 1)\n */\nexport function defaultComparator(a: unknown, b: unknown): number {\n // Handle nulls/undefined - push to end\n if (a == null && b == null) return 0;\n if (a == null) return 1;\n if (b == null) return -1;\n\n // Type-aware comparison\n if (typeof a === 'number' && typeof b === 'number') {\n return a - b;\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() - b.getTime();\n }\n\n // Boolean comparison\n if (typeof a === 'boolean' && typeof b === 'boolean') {\n return a === b ? 0 : a ? -1 : 1;\n }\n\n // String comparison (fallback)\n return String(a).localeCompare(String(b));\n}\n\n/**\n * Toggle sort state for a field.\n * With shift key: adds/toggles in multi-sort list\n * Without shift key: replaces entire sort with single column\n *\n * @param current - Current sort model\n * @param field - Field to toggle\n * @param shiftKey - Whether shift key is held (multi-sort mode)\n * @param maxColumns - Maximum columns allowed in sort\n * @returns New sort model\n */\nexport function toggleSort(current: SortModel[], field: string, shiftKey: boolean, maxColumns: number): SortModel[] {\n const existing = current.find((s) => s.field === field);\n\n if (shiftKey) {\n // Multi-sort: add/toggle in list\n if (existing) {\n if (existing.direction === 'asc') {\n // Flip to descending\n return current.map((s) => (s.field === field ? { ...s, direction: 'desc' as const } : s));\n } else {\n // Remove from sort\n return current.filter((s) => s.field !== field);\n }\n } else if (current.length < maxColumns) {\n // Add new sort column\n return [...current, { field, direction: 'asc' as const }];\n }\n // Max columns reached, return unchanged\n return current;\n } else {\n // Single sort: replace all\n if (existing?.direction === 'asc') {\n return [{ field, direction: 'desc' }];\n } else if (existing?.direction === 'desc') {\n return [];\n }\n return [{ field, direction: 'asc' }];\n }\n}\n\n/**\n * Get the sort index (1-based) for a field in the sort model.\n * Returns undefined if the field is not in the sort model.\n *\n * @param sortModel - Current sort model\n * @param field - Field to check\n * @returns 1-based index or undefined\n */\nexport function getSortIndex(sortModel: SortModel[], field: string): number | undefined {\n const index = sortModel.findIndex((s) => s.field === field);\n return index >= 0 ? index + 1 : undefined;\n}\n\n/**\n * Get the sort direction for a field in the sort model.\n *\n * @param sortModel - Current sort model\n * @param field - Field to check\n * @returns Sort direction or undefined if not sorted\n */\nexport function getSortDirection(sortModel: SortModel[], field: string): 'asc' | 'desc' | undefined {\n return sortModel.find((s) => s.field === field)?.direction;\n}\n","/**\n * Multi-Sort Plugin (Class-based)\n *\n * Provides multi-column sorting capabilities for tbw-grid.\n * Supports shift+click for adding secondary sort columns.\n */\n\nimport { announce } from '../../core/internal/aria';\nimport { BaseGridPlugin, HeaderClickEvent } from '../../core/plugin/base-plugin';\nimport type { ColumnState, GridHost } from '../../core/types';\nimport { getSortDirection, getSortIndex, sortRowsInPlace, toggleSort } from './multi-sort';\nimport styles from './multi-sort.css?inline';\nimport type { MultiSortConfig, SortModel } from './types';\n\n/**\n * Multi-Sort Plugin for tbw-grid\n *\n * Enables sorting by multiple columns at once—hold Shift and click additional column\n * headers to build up a sort stack. Priority badges show the sort order, so users\n * always know which column takes precedence.\n *\n * ## Installation\n *\n * ```ts\n * import { MultiSortPlugin } from '@toolbox-web/grid/plugins/multi-sort';\n * ```\n *\n * ## Keyboard Shortcuts\n *\n * | Shortcut | Action |\n * |----------|--------|\n * | `Click header` | Sort by column (clears other sorts) |\n * | `Shift + Click` | Add column to multi-sort stack |\n * | `Ctrl + Click` | Toggle sort direction |\n *\n * ## Events\n *\n * | Event | Detail | Description |\n * |-------|--------|-------------|\n * | `sort-change` | `{ sortModel: SortModel[] }` | Fired when sort changes |\n *\n * @example Basic Multi-Column Sorting\n * ```ts\n * import { queryGrid } from '@toolbox-web/grid';\n * import { MultiSortPlugin } from '@toolbox-web/grid/plugins/multi-sort';\n *\n * const grid = queryGrid('tbw-grid');\n * grid.gridConfig = {\n * columns: [\n * { field: 'name', header: 'Name', sortable: true },\n * { field: 'department', header: 'Department', sortable: true },\n * { field: 'salary', header: 'Salary', type: 'number', sortable: true },\n * ],\n * plugins: [new MultiSortPlugin({ maxSortColumns: 3, showSortIndex: true })],\n * };\n *\n * grid.on('sort-change', ({ sortModel }) => {\n * console.log('Active sorts:', sortModel);\n * });\n * ```\n *\n * @example Initial Sort Configuration\n * ```ts\n * new MultiSortPlugin({\n * initialSort: [\n * { field: 'department', direction: 'asc' },\n * { field: 'salary', direction: 'desc' },\n * ],\n * })\n * ```\n *\n * @see {@link MultiSortConfig} for all configuration options\n * @see {@link SortModel} for the sort model structure\n *\n * @internal Extends BaseGridPlugin\n */\nexport class MultiSortPlugin extends BaseGridPlugin<MultiSortConfig> {\n /** @internal */\n readonly name = 'multiSort';\n /** @internal */\n override readonly styles = styles;\n\n /** @internal */\n protected override get defaultConfig(): Partial<MultiSortConfig> {\n return {\n maxSortColumns: 3,\n showSortIndex: true,\n };\n }\n\n // #region Internal State\n private sortModel: SortModel[] = [];\n /** Cached sort result — returned as-is while a row edit is active to prevent\n * the edited row from jumping to a new sorted position mid-edit. Row data\n * mutations are still visible because the array holds shared object refs. */\n private cachedSortResult: unknown[] | null = null;\n\n /** Typed internal grid accessor. */\n get #internalGrid(): GridHost {\n return this.grid as unknown as GridHost;\n }\n\n /**\n * Clear the core `_sortState` so that only this plugin's `processRows`\n * sorting applies. `ConfigManager.applyState()` always sets the core sort\n * state when restoring from storage, even when a plugin handles sorting.\n * Without this, the stale core state leaks into `collectState()` and\n * `reapplyCoreSort()` after the plugin clears its own model.\n */\n private clearCoreSortState(): void {\n this.#internalGrid._sortState = null;\n }\n // #endregion\n\n // #region Lifecycle\n\n /** @internal */\n override detach(): void {\n this.sortModel = [];\n this.cachedSortResult = null;\n }\n // #endregion\n\n // #region Hooks\n\n /** @internal */\n override processRows(rows: readonly unknown[]): unknown[] {\n if (this.sortModel.length === 0) {\n this.cachedSortResult = null;\n return [...rows];\n }\n\n // Freeze sort order while a row is actively being edited (row mode only).\n // Re-sorting mid-edit would move the edited row to a new index while the\n // editors remain at the old position, causing data/UI mismatch.\n // In grid mode (_isGridEditMode) sorting is safe — afterCellRender\n // re-injects editors into the re-sorted cells.\n // We return the cached previous sort result (same object references, so\n // in-place value mutations are already visible) instead of unsorted input.\n const grid = this.#internalGrid;\n if (!grid._isGridEditMode && typeof grid._activeEditRows === 'number' && grid._activeEditRows !== -1) {\n if (this.cachedSortResult && this.cachedSortResult.length === rows.length) {\n return [...this.cachedSortResult];\n }\n }\n\n // Sort in-place — the input array is already a mutable copy from plugin-manager.\n // Pre-resolved comparator chain avoids column lookup on every pair comparison.\n const mutableRows = rows as unknown[];\n sortRowsInPlace(mutableRows, this.sortModel, this.columns);\n this.cachedSortResult = mutableRows;\n return mutableRows;\n }\n\n /** @internal */\n override onHeaderClick(event: HeaderClickEvent): boolean {\n const column = this.columns.find((c) => c.field === event.field);\n if (!column?.sortable) return false;\n\n const shiftKey = event.originalEvent.shiftKey;\n const maxColumns = this.config.maxSortColumns ?? 3;\n\n this.sortModel = toggleSort(this.sortModel, event.field, shiftKey, maxColumns);\n this.clearCoreSortState();\n\n this.emit('sort-change', { sortModel: [...this.sortModel] });\n this.requestRender();\n this.grid?.requestStateChange?.();\n\n // Announce for screen readers\n if (this.sortModel.length > 0) {\n const labels = this.sortModel.map((s) => {\n const col = this.columns.find((c) => c.field === s.field);\n return `${col?.header ?? s.field} ${s.direction === 'asc' ? 'ascending' : 'descending'}`;\n });\n announce(this.gridElement!, `Sorted by ${labels.join(', then ')}`);\n } else {\n announce(this.gridElement!, 'Sort cleared');\n }\n\n return true;\n }\n\n /** @internal */\n override afterRender(): void {\n const gridEl = this.gridElement;\n if (!gridEl) return;\n\n const showIndex = this.config.showSortIndex !== false;\n\n // Update all sortable header cells with sort indicators\n const headerCells = gridEl.querySelectorAll('.header-row .cell[data-field]');\n headerCells.forEach((cell) => {\n const field = cell.getAttribute('data-field');\n if (!field) return;\n\n const sortIndex = getSortIndex(this.sortModel, field);\n const sortDir = getSortDirection(this.sortModel, field);\n\n // Remove existing sort index badge (always clean up)\n const existingBadge = cell.querySelector('.sort-index');\n existingBadge?.remove();\n\n if (sortDir) {\n // Column is sorted - remove base indicator and add our own\n const existingIndicator = cell.querySelector('[part~=\"sort-indicator\"], .sort-indicator');\n existingIndicator?.remove();\n\n cell.setAttribute('data-sort', sortDir);\n\n // Add sort arrow indicator - insert BEFORE filter button and resize handle\n // to maintain consistent order: [label, sort-indicator, sort-index, filter-btn, resize-handle]\n const indicator = document.createElement('span');\n indicator.className = 'sort-indicator';\n // Use grid-level icons (fall back to defaults)\n this.setIcon(indicator, this.resolveIcon(sortDir === 'asc' ? 'sortAsc' : 'sortDesc'));\n\n // Find insertion point: before filter button or resize handle\n const filterBtn = cell.querySelector('.tbw-filter-btn');\n const resizeHandle = cell.querySelector('.resize-handle');\n const insertBefore = filterBtn ?? resizeHandle;\n if (insertBefore) {\n cell.insertBefore(indicator, insertBefore);\n } else {\n cell.appendChild(indicator);\n }\n\n // Add sort index badge if multiple columns sorted and showSortIndex is enabled\n if (showIndex && this.sortModel.length > 1 && sortIndex !== undefined) {\n const badge = document.createElement('span');\n badge.className = 'sort-index';\n badge.textContent = String(sortIndex);\n // Insert badge right after the indicator\n if (indicator.nextSibling) {\n cell.insertBefore(badge, indicator.nextSibling);\n } else {\n cell.appendChild(badge);\n }\n }\n } else {\n cell.removeAttribute('data-sort');\n // Remove any stale sort indicators left by a previous afterRender cycle\n // Base indicators use part=\"sort-indicator\", plugin indicators use class=\"sort-indicator\"\n const staleIndicator = cell.querySelector('[part~=\"sort-indicator\"], .sort-indicator');\n staleIndicator?.remove();\n }\n });\n }\n // #endregion\n\n // #region Public API\n\n /**\n * Get the current sort model.\n * @returns Copy of the current sort model\n */\n getSortModel(): SortModel[] {\n return [...this.sortModel];\n }\n\n /**\n * Set the sort model programmatically.\n * @param model - New sort model to apply\n */\n setSortModel(model: SortModel[]): void {\n this.sortModel = [...model];\n this.clearCoreSortState();\n this.emit('sort-change', { sortModel: [...model] });\n this.requestRender();\n this.grid?.requestStateChange?.();\n if (model.length > 0) {\n const labels = model.map((s) => {\n const col = this.columns.find((c) => c.field === s.field);\n return `${col?.header ?? s.field} ${s.direction === 'asc' ? 'ascending' : 'descending'}`;\n });\n announce(this.gridElement!, `Sorted by ${labels.join(', then ')}`);\n }\n }\n\n /**\n * Clear all sorting.\n */\n clearSort(): void {\n this.sortModel = [];\n this.clearCoreSortState();\n this.emit('sort-change', { sortModel: [] });\n this.requestRender();\n this.grid?.requestStateChange?.();\n announce(this.gridElement!, 'Sort cleared');\n }\n\n /**\n * Get the sort index (1-based) for a specific field.\n * @param field - Field to check\n * @returns 1-based index or undefined if not sorted\n */\n getSortIndex(field: string): number | undefined {\n return getSortIndex(this.sortModel, field);\n }\n\n /**\n * Get the sort direction for a specific field.\n * @param field - Field to check\n * @returns Sort direction or undefined if not sorted\n */\n getSortDirection(field: string): 'asc' | 'desc' | undefined {\n return getSortDirection(this.sortModel, field);\n }\n // #endregion\n\n // #region Column State Hooks\n\n /**\n * Return sort state for a column if it's in the sort model.\n * @internal\n */\n override getColumnState(field: string): Partial<ColumnState> | undefined {\n const index = this.sortModel.findIndex((s) => s.field === field);\n if (index === -1) return undefined;\n\n const sortEntry = this.sortModel[index];\n return {\n sort: {\n direction: sortEntry.direction,\n priority: index,\n },\n };\n }\n\n /**\n * Apply sort state from column state.\n * Rebuilds the sort model from all column states.\n * @internal\n */\n override applyColumnState(field: string, state: ColumnState): void {\n // Only process if the column has sort state\n if (!state.sort) {\n // Remove this field from sortModel if it exists\n this.sortModel = this.sortModel.filter((s) => s.field !== field);\n return;\n }\n\n // Find existing entry or add new one\n const existingIndex = this.sortModel.findIndex((s) => s.field === field);\n const newEntry: SortModel = {\n field,\n direction: state.sort.direction,\n };\n\n if (existingIndex !== -1) {\n // Update existing entry\n this.sortModel[existingIndex] = newEntry;\n } else {\n // Add at the correct priority position\n this.sortModel.splice(state.sort.priority, 0, newEntry);\n }\n\n // Clear core sort state — this plugin exclusively handles sorting via\n // processRows. The core _sortState is set by ConfigManager.applyState()\n // before plugins run; null it so reapplyCoreSort() is a no-op.\n this.clearCoreSortState();\n }\n // #endregion\n}\n"],"names":["defaultComparator","a","b","Date","getTime","String","localeCompare","getSortIndex","sortModel","field","index","findIndex","s","getSortDirection","find","direction","MultiSortPlugin","BaseGridPlugin","name","styles","defaultConfig","maxSortColumns","showSortIndex","cachedSortResult","internalGrid","this","grid","clearCoreSortState","_sortState","detach","processRows","rows","length","_isGridEditMode","_activeEditRows","mutableRows","sorts","columns","chain","map","sort","col","c","asc","comparator","sortComparator","result","i","sortRowsInPlace","onHeaderClick","event","column","sortable","shiftKey","originalEvent","maxColumns","config","current","existing","filter","toggleSort","emit","requestRender","requestStateChange","labels","header","announce","gridElement","join","afterRender","gridEl","showIndex","querySelectorAll","forEach","cell","getAttribute","sortIndex","sortDir","existingBadge","querySelector","remove","existingIndicator","setAttribute","indicator","document","createElement","className","setIcon","resolveIcon","filterBtn","resizeHandle","insertBefore","appendChild","badge","textContent","nextSibling","removeAttribute","staleIndicator","getSortModel","setSortModel","model","clearSort","getColumnState","priority","applyColumnState","state","existingIndex","newEntry","splice"],"mappings":"8ZAwEO,SAASA,EAAkBC,EAAYC,GAE5C,OAAS,MAALD,GAAkB,MAALC,EAAkB,EAC1B,MAALD,EAAkB,EACb,MAALC,GAAkB,EAGL,iBAAND,GAA+B,iBAANC,EAC3BD,EAAIC,EAGTD,aAAaE,MAAQD,aAAaC,KAC7BF,EAAEG,UAAYF,EAAEE,UAIR,kBAANH,GAAgC,kBAANC,EAC5BD,IAAMC,EAAI,EAAID,GAAI,EAAK,EAIzBI,OAAOJ,GAAGK,cAAcD,OAAOH,GACxC,CAmDO,SAASK,EAAaC,EAAwBC,GACnD,MAAMC,EAAQF,EAAUG,UAAWC,GAAMA,EAAEH,QAAUA,GACrD,OAAOC,GAAS,EAAIA,EAAQ,OAAI,CAClC,CASO,SAASG,EAAiBL,EAAwBC,GACvD,OAAOD,EAAUM,KAAMF,GAAMA,EAAEH,QAAUA,IAAQM,SACnD,CCnFO,MAAMC,UAAwBC,EAAAA,eAE1BC,KAAO,YAEEC,isBAGlB,iBAAuBC,GACrB,MAAO,CACLC,eAAgB,EAChBC,eAAe,EAEnB,CAGQd,UAAyB,GAIzBe,iBAAqC,KAG7C,KAAIC,GACF,OAAOC,KAAKC,IACd,CASQ,kBAAAC,GACNF,MAAKD,EAAcI,WAAa,IAClC,CAMS,MAAAC,GACPJ,KAAKjB,UAAY,GACjBiB,KAAKF,iBAAmB,IAC1B,CAMS,WAAAO,CAAYC,GACnB,GAA8B,IAA1BN,KAAKjB,UAAUwB,OAEjB,OADAP,KAAKF,iBAAmB,KACjB,IAAIQ,GAUb,MAAML,EAAOD,MAAKD,EAClB,IAAKE,EAAKO,iBAAmD,iBAAzBP,EAAKQ,kBAAyD,IAAzBR,EAAKQ,iBACxET,KAAKF,kBAAoBE,KAAKF,iBAAiBS,SAAWD,EAAKC,OACjE,MAAO,IAAIP,KAAKF,kBAMpB,MAAMY,EAAcJ,EAGpB,ODvHG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C,GACE5E,KAAKjB,UAAY,GACjBiB,KAAKE,qBACLF,KAAKoC,KAAK,cAAe,CAAErD,UAAW,KACtCiB,KAAKqC,gBACLrC,KAAKC,MAAMqC,uBACXG,WAASzC,KAAK0C,YAAc,eAC9B,CAOA,YAAA5D,CAAaE,GACX,OAAOF,EAAakB,KAAKjB,UAAWC,EACtC,CAOA,gBAAAI,CAAiBJ,GACf,OAAOI,EAAiBY,KAAKjB,UAAWC,EAC1C,CASS,cAAA6F,CAAe7F,GACtB,MAAMC,EAAQe,KAAKjB,UAAUG,UAAWC,GAAMA,EAAEH,QAAUA,GAC1D,QAAIC,EAAc,OAGlB,MAAO,CACL8B,KAAM,CACJzB,UAHcU,KAAKjB,UAAUE,GAGRK,UACrBwF,SAAU7F,GAGhB,CAOS,gBAAA8F,CAAiB/F,EAAegG,GAEvC,IAAKA,EAAMjE,KAGT,YADAf,KAAKjB,UAAYiB,KAAKjB,UAAUmD,OAAQ/C,GAAMA,EAAEH,QAAUA,IAK5D,MAAMiG,EAAgBjF,KAAKjB,UAAUG,UAAWC,GAAMA,EAAEH,QAAUA,GAC5DkG,EAAsB,CAC1BlG,QACAM,UAAW0F,EAAMjE,KAAKzB,YAGF,IAAlB2F,EAEFjF,KAAKjB,UAAUkG,GAAiBC,EAGhClF,KAAKjB,UAAUoG,OAAOH,EAAMjE,KAAK+D,SAAU,EAAGI,GAMhDlF,KAAKE,oBACP"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("../../core/internal/utils"),require("../../core/plugin/base-plugin")):"function"==typeof define&&define.amd?define(["exports","../../core/internal/utils","../../core/plugin/base-plugin"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TbwGridPlugin_pinnedColumns={},t.TbwGrid,t.TbwGrid)}(this,function(t,e,i){"use strict";function n(t){return t.pinned??t.sticky??t.meta?.pinned??t.meta?.sticky}function s(t,i){return e.resolveInlinePosition(t,i)}function r(t,e){const i=n(t);return!!i&&"left"===s(i,e)}function o(t,e){const i=n(t);return!!i&&"right"===s(i,e)}function l(t){return t.some(t=>null!=n(t))}function d(t,i){const n={addGroupEnd:new Set,removeGroupEnd:new Set},s=Array.from(t.querySelectorAll(".header-row .cell"));if(!s.length)return n;const l=e.getDirection(t);let d=0;for(const e of i)if(r(e,l)){const i=s.find(t=>t.getAttribute("data-field")===e.field);i&&(i.classList.add("sticky-left"),i.style.position="sticky",i.style.left=d+"px",t.querySelectorAll(`.data-grid-row .cell[data-field="${e.field}"]`).forEach(t=>{t.classList.add("sticky-left"),t.style.position="sticky",t.style.left=d+"px"}),d+=i.offsetWidth)}let c=0;for(const e of[...i].reverse())if(o(e,l)){const i=s.find(t=>t.getAttribute("data-field")===e.field);i&&(i.classList.add("sticky-right"),i.style.position="sticky",i.style.right=c+"px",t.querySelectorAll(`.data-grid-row .cell[data-field="${e.field}"]`).forEach(t=>{t.classList.add("sticky-right"),t.style.position="sticky",t.style.right=c+"px"}),c+=i.offsetWidth)}const u=function(t,e,i,n){const s={addGroupEnd:new Set,removeGroupEnd:new Set},l=Array.from(t.querySelectorAll(".header-group-row .header-group-cell"));if(!l.length)return s;for(const d of l){const t=d.style.gridColumn;if(!t)continue;const l=t.match(/^(\d+)\s*\/\s*span\s+(\d+)$/);if(!l)continue;const c=parseInt(l[1],10)-1,u=c+parseInt(l[2],10)-1,a=e.slice(c,u+1);if(!a.length)continue;const p=a.every(t=>r(t,n)),h=a.every(t=>o(t,n));if(p){const t=a[0].field,e=i.find(e=>e.getAttribute("data-field")===t);e&&(d.classList.add("sticky-left"),d.style.position="sticky",d.style.left=e.style.left)}else if(h){const t=a[a.length-1].field,e=i.find(e=>e.getAttribute("data-field")===t);e&&(d.classList.add("sticky-right"),d.style.position="sticky",d.style.right=e.style.right)}else d.classList.contains("implicit-group")&&f(d,a,c,i,n,s)}return s}(t,i,s,l);if(u.addGroupEnd.size>0||u.removeGroupEnd.size>0){for(const e of u.addGroupEnd){const i=s.find(t=>t.getAttribute("data-field")===e);i&&i.classList.add("group-end"),t.querySelectorAll(`.data-grid-row .cell[data-field="${e}"]`).forEach(t=>{t.classList.add("group-end")})}for(const e of u.removeGroupEnd){const i=s.find(t=>t.getAttribute("data-field")===e);i&&i.classList.remove("group-end"),t.querySelectorAll(`.data-grid-row .cell[data-field="${e}"]`).forEach(t=>{t.classList.remove("group-end")})}}return u}function c(t,e){return r(t,e)?"left":o(t,e)?"right":"none"}function f(t,e,i,n,s,r){const o=[];for(let f=0;f<e.length;f++){const t=c(e[f],s),n=o[o.length-1];n&&n.state===t?n.cols.push(e[f]):o.push({state:t,cols:[e[f]],colStart:i+f})}if(o.length<=1)return;const l=t.parentElement;if(!l)return;const d=t.nextSibling;l.removeChild(t);for(const c of o){const e=document.createElement("div");if(e.className=t.className,e.setAttribute("data-group",t.getAttribute("data-group")||""),e.style.gridColumn=`${c.colStart+1} / span ${c.cols.length}`,"left"===c.state){const t=c.cols[0].field,i=n.find(e=>e.getAttribute("data-field")===t);i&&(e.classList.add("sticky-left"),e.style.position="sticky",e.style.left=i.style.left)}else if("right"===c.state){const t=c.cols[c.cols.length-1].field,i=n.find(e=>e.getAttribute("data-field")===t);i&&(e.classList.add("sticky-right"),e.style.position="sticky",e.style.right=i.style.right)}else if("none"===c.state){c.cols.every(t=>String(t.field||"").startsWith("__tbw_"))&&(e.style.borderRightStyle="none")}d?l.insertBefore(e,d):l.appendChild(e)}for(let c=0;c<o.length;c++){const t=o[c],e=o[c+1];if("none"!==t.state&&e&&"none"===e.state){const e=t.cols[t.cols.length-1].field;e&&r.addGroupEnd.add(e)}if("none"===t.state){if(t.cols.every(t=>String(t.field||"").startsWith("__tbw_"))){const e=t.cols[t.cols.length-1].field;e&&r.removeGroupEnd.add(e)}}}}function u(t){t.querySelectorAll(".sticky-left, .sticky-right").forEach(t=>{t.classList.remove("sticky-left","sticky-right"),t.style.position="",t.style.left="",t.style.right=""})}const a="canMoveColumn";class p extends i.BaseGridPlugin{static manifest={ownedProperties:[{property:"pinned",level:"column",description:'the "pinned" column property',isUsed:t=>"left"===t||"right"===t||"start"===t||"end"===t},{property:"sticky",level:"column",description:'the "sticky" column property (deprecated, use "pinned")',isUsed:t=>"left"===t||"right"===t||"start"===t||"end"===t}],queries:[{type:a,description:"Prevents pinned (sticky) columns from being moved/reordered"},{type:"getStickyOffsets",description:"Returns the sticky offsets for left/right pinned columns"},{type:"getContextMenuItems",description:"Contributes pin/unpin items to the header context menu"}]};name="pinnedColumns";get defaultConfig(){return{}}isApplied=!1;leftOffsets=new Map;rightOffsets=new Map;#t={addGroupEnd:new Set,removeGroupEnd:new Set};#e=[];detach(){this.leftOffsets.clear(),this.rightOffsets.clear(),this.isApplied=!1,this.#t={addGroupEnd:new Set,removeGroupEnd:new Set},this.#e=[]}static detect(t,e){const i=e?.columns;return!!Array.isArray(i)&&l(i)}processColumns(t){const i=[...t];if(this.isApplied=l(i),!this.isApplied)return i;const r=this.gridElement;return function(t,e="ltr"){const i=[],r=[],o=[];for(const l of t){const t=n(l);t?"left"===s(t,e)?i.push(l):o.push(l):r.push(l)}return[...i,...r,...o]}(i,r?e.getDirection(r):"ltr")}afterRender(){if(!this.isApplied)return;const t=this.gridElement,e=[...this.columns];if(!l(e))return u(t),void(this.isApplied=!1);queueMicrotask(()=>{this.#t=d(t,e)})}afterCellRender(t){if(!this.isApplied)return;const e=t.column.field;this.#t.addGroupEnd.has(e)?t.cellElement.classList.add("group-end"):this.#t.removeGroupEnd.has(e)&&t.cellElement.classList.remove("group-end")}handleQuery(t){switch(t.type){case a:return null==n(t.context)&&void 0;case"getStickyOffsets":return{left:Object.fromEntries(this.leftOffsets),right:Object.fromEntries(this.rightOffsets)};case"getContextMenuItems":{const e=t.context;if(!e.isHeader)return;const i=e.column;if(!i?.field)return;if(i.meta?.lockPinning)return;const s=[];return null!=n(i)?s.push({id:"pinned/unpin",label:"Unpin Column",icon:"📌",order:40,action:()=>this.setPinPosition(i.field,void 0)}):(s.push({id:"pinned/pin-left",label:"Pin Left",icon:"⬅",order:40,action:()=>this.setPinPosition(i.field,"left")}),s.push({id:"pinned/pin-right",label:"Pin Right",icon:"➡",order:41,action:()=>this.setPinPosition(i.field,"right")})),s}default:return}}setPinPosition(t,e){const i=this.columns;if(!i?.length)return;const s=i.findIndex(e=>e.field===t);if(-1===s)return;const r=this.gridElement;if(e){0===this.#e.length&&(this.#e=i.map(t=>t.field));const n=i.map(i=>{if(i.field!==t)return i;const n={...i};return n.pinned=e,delete n.sticky,n});r.columns=n}else{const e={...i[s]};delete e.pinned,delete e.sticky;const o=[...i];o.splice(s,1);const l=this.#e.indexOf(t);if(l>=0){let t=o.length;for(let e=0;e<o.length;e++){if(n(o[e]))continue;if(this.#e.indexOf(o[e].field)>l){t=e;break}}o.splice(t,0,e)}else o.splice(Math.min(s,o.length),0,e);o.some(t=>null!=n(t))||(this.#e=[]),r.columns=o}}refreshStickyOffsets(){const t=[...this.columns];d(this.gridElement,t)}getLeftPinnedColumns(){return function(t,e="ltr"){return t.filter(t=>r(t,e))}([...this.columns],e.getDirection(this.gridElement))}getRightPinnedColumns(){return function(t,e="ltr"){return t.filter(t=>o(t,e))}([...this.columns],e.getDirection(this.gridElement))}clearStickyPositions(){u(this.gridElement)}getHorizontalScrollOffsets(t,e){if(!this.isApplied)return;let i=0,n=0;if(t){const e=t.querySelectorAll(".sticky-left"),s=t.querySelectorAll(".sticky-right");e.forEach(t=>{i+=t.offsetWidth}),s.forEach(t=>{n+=t.offsetWidth})}else{this.gridElement.querySelectorAll(".header-row .cell").forEach(t=>{t.classList.contains("sticky-left")?i+=t.offsetWidth:t.classList.contains("sticky-right")&&(n+=t.offsetWidth)})}const s=e?.classList.contains("sticky-left")||e?.classList.contains("sticky-right");return{left:i,right:n,skipScroll:s}}}t.PinnedColumnsPlugin=p,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("../../core/constants"),require("../../core/internal/utils"),require("../../core/plugin/base-plugin")):"function"==typeof define&&define.amd?define(["exports","../../core/constants","../../core/internal/utils","../../core/plugin/base-plugin"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TbwGridPlugin_pinnedColumns={},e.TbwGrid,e.TbwGrid,e.TbwGrid)}(this,function(e,t,s,i){"use strict";function n(e){return e.pinned??e.sticky??e.meta?.pinned??e.meta?.sticky}function l(e,t){return s.resolveInlinePosition(e,t)}function r(e,t){const s=n(e);return!!s&&"left"===l(s,t)}function o(e,t){const s=n(e);return!!s&&"right"===l(s,t)}function d(e){return e.some(e=>null!=n(e))}function a(e,i){const n={groupEndAdjustments:{addGroupEnd:new Set,removeGroupEnd:new Set},leftOffsets:new Map,rightOffsets:new Map,splitGroups:[]},l=Array.from(e.querySelectorAll(".header-row .cell"));if(!l.length)return n;const d=s.getDirection(e),a=new Map,f=new Map;let p=0;for(const s of i)if(r(s,d)){const i=l.find(e=>e.getAttribute("data-field")===s.field);i&&(a.set(s.field,p),i.classList.add(t.GridClasses.STICKY_LEFT),i.style.position="sticky",i.style.left=p+"px",e.querySelectorAll(`.data-grid-row .cell[data-field="${s.field}"]`).forEach(e=>{e.classList.add(t.GridClasses.STICKY_LEFT),e.style.position="sticky",e.style.left=p+"px"}),p+=i.offsetWidth)}let g=0;for(const s of[...i].reverse())if(o(s,d)){const i=l.find(e=>e.getAttribute("data-field")===s.field);i&&(f.set(s.field,g),i.classList.add(t.GridClasses.STICKY_RIGHT),i.style.position="sticky",i.style.right=g+"px",e.querySelectorAll(`.data-grid-row .cell[data-field="${s.field}"]`).forEach(e=>{e.classList.add(t.GridClasses.STICKY_RIGHT),e.style.position="sticky",e.style.right=g+"px"}),g+=i.offsetWidth)}const h=[],m=function(e,s,i,n,l){const d={addGroupEnd:new Set,removeGroupEnd:new Set},a=Array.from(e.querySelectorAll(".header-group-row .header-group-cell"));if(!a.length)return d;for(const f of a){const e=f.style.gridColumn;if(!e)continue;const a=e.match(/^(\d+)\s*\/\s*span\s+(\d+)$/);if(!a)continue;const p=parseInt(a[1],10)-1,g=p+parseInt(a[2],10)-1,h=s.slice(p,g+1);if(!h.length)continue;const m=h.every(e=>r(e,n)),y=h.every(e=>o(e,n));if(m){const e=h[0].field,s=i.find(t=>t.getAttribute("data-field")===e);s&&(f.classList.add(t.GridClasses.STICKY_LEFT),f.style.position="sticky",f.style.left=s.style.left)}else if(y){const e=h[h.length-1].field,s=i.find(t=>t.getAttribute("data-field")===e);s&&(f.classList.add(t.GridClasses.STICKY_RIGHT),f.style.position="sticky",f.style.right=s.style.right)}else if(f.classList.contains("implicit-group"))c(f,h,p,i,n,d);else{const e=h.some(e=>r(e,n)),t=h.some(e=>o(e,n));(e||t)&&u(f,h,p,i,n,d,l)}}return d}(e,i,l,d,h);if(m.addGroupEnd.size>0||m.removeGroupEnd.size>0){for(const t of m.addGroupEnd){const s=l.find(e=>e.getAttribute("data-field")===t);s&&s.classList.add("group-end"),e.querySelectorAll(`.data-grid-row .cell[data-field="${t}"]`).forEach(e=>{e.classList.add("group-end")})}for(const t of m.removeGroupEnd){const s=l.find(e=>e.getAttribute("data-field")===t);s&&s.classList.remove("group-end"),e.querySelectorAll(`.data-grid-row .cell[data-field="${t}"]`).forEach(e=>{e.classList.remove("group-end")})}}return{groupEndAdjustments:m,leftOffsets:a,rightOffsets:f,splitGroups:h}}function f(e,t){return r(e,t)?"left":o(e,t)?"right":"none"}function c(e,s,i,n,l,r){const o=[];for(let t=0;t<s.length;t++){const e=f(s[t],l),n=o[o.length-1];n&&n.state===e?n.cols.push(s[t]):o.push({state:e,cols:[s[t]],colStart:i+t})}if(o.length<=1)return;const d=e.parentElement;if(!d)return;const a=e.nextSibling;d.removeChild(e);for(const f of o){const s=document.createElement("div");if(s.className=e.className,s.setAttribute("data-group",e.getAttribute("data-group")||""),s.style.gridColumn=`${f.colStart+1} / span ${f.cols.length}`,"left"===f.state){const e=f.cols[0].field,i=n.find(t=>t.getAttribute("data-field")===e);i&&(s.classList.add(t.GridClasses.STICKY_LEFT),s.style.position="sticky",s.style.left=i.style.left)}else if("right"===f.state){const e=f.cols[f.cols.length-1].field,i=n.find(t=>t.getAttribute("data-field")===e);i&&(s.classList.add(t.GridClasses.STICKY_RIGHT),s.style.position="sticky",s.style.right=i.style.right)}else if("none"===f.state){f.cols.every(e=>String(e.field||"").startsWith("__tbw_"))&&(s.style.borderRightStyle="none")}a?d.insertBefore(s,a):d.appendChild(s)}for(let t=0;t<o.length;t++){const e=o[t],s=o[t+1];if("none"!==e.state&&s&&"none"===s.state){const t=e.cols[e.cols.length-1].field;t&&r.addGroupEnd.add(t)}if("none"===e.state){if(e.cols.every(e=>String(e.field||"").startsWith("__tbw_"))){const t=e.cols[e.cols.length-1].field;t&&r.removeGroupEnd.add(t)}}}}function u(e,s,i,n,l,r,o){const d=[];for(let t=0;t<s.length;t++){const e=f(s[t],l),n=d[d.length-1];n&&n.state===e?n.cols.push(s[t]):d.push({state:e,cols:[s[t]],colStart:i+t})}if(d.length<=1)return;const a=e.parentElement;if(!a)return;const c=e.textContent||"",u=e.getAttribute("data-group")||"",p=e.nextSibling;a.removeChild(e);const g=d.findIndex(e=>"left"===e.state);let h=-1;for(let t=d.length-1;t>=0;t--)if("right"===d[t].state){h=t;break}const m=g>=0?g:h,y=g>=0&&g+1<d.length?g+1:h>=0&&h-1>=0?h-1:-1;let C,S,G,E="";for(let f=0;f<d.length;f++){const s=d[f],i=document.createElement("div");if(i.className=e.className,i.setAttribute("data-group",u),i.style.gridColumn=`${s.colStart+1} / span ${s.cols.length}`,"left"===s.state){const e=s.cols[0].field,l=n.find(t=>t.getAttribute("data-field")===e);l&&(i.classList.add(t.GridClasses.STICKY_LEFT),i.style.position="sticky",i.style.left=l.style.left,l.style.left),f===m&&(i.style.borderRightStyle="none",C=i,E=s.cols[s.cols.length-1].field)}else if("right"===s.state){const e=s.cols[s.cols.length-1].field,l=n.find(t=>t.getAttribute("data-field")===e);l&&(i.classList.add(t.GridClasses.STICKY_RIGHT),i.style.position="sticky",i.style.right=l.style.right),f===m&&(i.style.borderLeftStyle="none",C=i,E=s.cols[0].field)}if(f===y){i.style.overflow="visible";const e=document.createElement("span");e.textContent=c,e.style.position="relative",e.style.zIndex="36",e.style.display="block",e.style.overflow="hidden",e.style.textOverflow="ellipsis",e.style.whiteSpace="nowrap",i.appendChild(e),S=i,G=e}p?a.insertBefore(i,p):a.appendChild(i)}C&&S&&G&&E&&o.push({groupId:u,label:c,pinnedFragment:C,scrollableFragment:S,floatLabel:G,pinnedField:E,isTransferred:!1,floatOffset:0})}function p(e){e.querySelectorAll(`.${t.GridClasses.STICKY_LEFT}, .${t.GridClasses.STICKY_RIGHT}`).forEach(e=>{e.classList.remove(t.GridClasses.STICKY_LEFT,t.GridClasses.STICKY_RIGHT),e.style.position="",e.style.left="",e.style.right=""})}const g="canMoveColumn";class h extends i.BaseGridPlugin{static manifest={ownedProperties:[{property:"pinned",level:"column",description:'the "pinned" column property',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e},{property:"sticky",level:"column",description:'the "sticky" column property (deprecated, use "pinned")',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e}],queries:[{type:g,description:"Prevents pinned (sticky) columns from being moved/reordered"},{type:"getStickyOffsets",description:"Returns the sticky offsets for left/right pinned columns"},{type:"getContextMenuItems",description:"Contributes pin/unpin items to the header context menu"}]};name="pinnedColumns";get defaultConfig(){return{}}isApplied=!1;leftOffsets=new Map;rightOffsets=new Map;#e={addGroupEnd:new Set,removeGroupEnd:new Set};#t=[];#s=[];detach(){this.leftOffsets.clear(),this.rightOffsets.clear(),this.isApplied=!1,this.#e={addGroupEnd:new Set,removeGroupEnd:new Set},this.#t=[],this.#s=[]}static detect(e,t){const s=t?.columns;return!!Array.isArray(s)&&d(s)}processColumns(e){const t=[...e];if(this.isApplied=d(t),!this.isApplied)return t;const i=this.gridElement;return function(e,t="ltr"){const s=[],i=[],r=[];for(const o of e){const e=n(o);e?"left"===l(e,t)?s.push(o):r.push(o):i.push(o)}return[...s,...i,...r]}(t,i?s.getDirection(i):"ltr")}afterRender(){if(!this.isApplied)return;const e=this.gridElement,t=[...this.columns];if(!d(t))return p(e),void(this.isApplied=!1);queueMicrotask(()=>{const s=a(e,t);this.#e=s.groupEndAdjustments,this.leftOffsets=s.leftOffsets,this.rightOffsets=s.rightOffsets,this.#t=s.splitGroups,this.#i()})}afterCellRender(e){if(!this.isApplied)return;const s=e.column.field,i=e.cellElement,n=this.leftOffsets.get(s);if(void 0!==n)i.classList.contains(t.GridClasses.STICKY_LEFT)||i.classList.add(t.GridClasses.STICKY_LEFT),i.style.position="sticky",i.style.left=n+"px";else{const e=this.rightOffsets.get(s);void 0!==e&&(i.classList.contains(t.GridClasses.STICKY_RIGHT)||i.classList.add(t.GridClasses.STICKY_RIGHT),i.style.position="sticky",i.style.right=e+"px")}this.#e.addGroupEnd.has(s)?e.cellElement.classList.add("group-end"):this.#e.removeGroupEnd.has(s)&&e.cellElement.classList.remove("group-end")}onScroll(e){this.#i()}#i(){if(!this.isApplied||0===this.#t.length)return;const e=this.gridElement;for(const t of this.#t){const s=t.pinnedFragment.getBoundingClientRect(),i=t.scrollableFragment.getBoundingClientRect().right<=s.right;if(i&&!t.isTransferred?(t.pinnedFragment.textContent=t.label,t.pinnedFragment.style.overflow="hidden",t.pinnedFragment.style.textOverflow="ellipsis",t.pinnedFragment.style.whiteSpace="nowrap",t.pinnedFragment.style.borderRightStyle="",t.floatLabel.style.visibility="hidden",t.floatLabel.style.transform="",t.floatOffset=0,this.#e.addGroupEnd.add(t.pinnedField),e.querySelectorAll(`.header-row .cell[data-field="${t.pinnedField}"], .data-grid-row .cell[data-field="${t.pinnedField}"]`).forEach(e=>e.classList.add("group-end")),t.isTransferred=!0):!i&&t.isTransferred&&(t.pinnedFragment.textContent="",t.pinnedFragment.style.overflow="",t.pinnedFragment.style.textOverflow="",t.pinnedFragment.style.whiteSpace="",t.pinnedFragment.style.borderRightStyle="none",t.floatLabel.style.visibility="",t.floatLabel.style.transform="",t.floatOffset=0,this.#e.addGroupEnd.delete(t.pinnedField),e.querySelectorAll(`.header-row .cell[data-field="${t.pinnedField}"], .data-grid-row .cell[data-field="${t.pinnedField}"]`).forEach(e=>e.classList.remove("group-end")),t.isTransferred=!1),!t.isTransferred){const e=t.floatLabel.getBoundingClientRect().left-t.floatOffset,i=s.left;e<i?(t.floatOffset=i-e,t.floatLabel.style.transform=`translateX(${t.floatOffset}px)`):(t.floatOffset=0,t.floatLabel.style.transform="")}}}handleQuery(e){switch(e.type){case g:return null==n(e.context)&&void 0;case"getStickyOffsets":return{left:Object.fromEntries(this.leftOffsets),right:Object.fromEntries(this.rightOffsets)};case"getContextMenuItems":{const t=e.context;if(!t.isHeader)return;const s=t.column;if(!s?.field)return;if(s.meta?.lockPinning)return;const i=[];return null!=n(s)?i.push({id:"pinned/unpin",label:"Unpin Column",icon:"📌",order:40,action:()=>this.setPinPosition(s.field,void 0)}):(i.push({id:"pinned/pin-left",label:"Pin Left",icon:"⬅",order:40,action:()=>this.setPinPosition(s.field,"left")}),i.push({id:"pinned/pin-right",label:"Pin Right",icon:"➡",order:41,action:()=>this.setPinPosition(s.field,"right")})),i}default:return}}setPinPosition(e,t){const s=this.columns;if(!s?.length)return;const i=s.findIndex(t=>t.field===e);if(-1===i)return;const l=this.gridElement;if(t){0===this.#s.length&&(this.#s=s.map(e=>e.field));const i=s.map(s=>{if(s.field!==e)return s;const i={...s};return i.pinned=t,delete i.sticky,i});l.columns=i}else{const t={...s[i]};delete t.pinned,delete t.sticky;const r=[...s];r.splice(i,1);const o=this.#s.indexOf(e);if(o>=0){let e=r.length;for(let t=0;t<r.length;t++){if(n(r[t]))continue;if(this.#s.indexOf(r[t].field)>o){e=t;break}}r.splice(e,0,t)}else r.splice(Math.min(i,r.length),0,t);r.some(e=>null!=n(e))||(this.#s=[]),l.columns=r}}refreshStickyOffsets(){const e=[...this.columns],t=a(this.gridElement,e);this.#e=t.groupEndAdjustments,this.leftOffsets=t.leftOffsets,this.rightOffsets=t.rightOffsets,this.#t=t.splitGroups}getLeftPinnedColumns(){return function(e,t="ltr"){return e.filter(e=>r(e,t))}([...this.columns],s.getDirection(this.gridElement))}getRightPinnedColumns(){return function(e,t="ltr"){return e.filter(e=>o(e,t))}([...this.columns],s.getDirection(this.gridElement))}clearStickyPositions(){p(this.gridElement)}getHorizontalScrollOffsets(e,s){if(!this.isApplied)return;let i=0,n=0;if(e){const s=e.querySelectorAll(`.${t.GridClasses.STICKY_LEFT}`),l=e.querySelectorAll(`.${t.GridClasses.STICKY_RIGHT}`);s.forEach(e=>{i+=e.offsetWidth}),l.forEach(e=>{n+=e.offsetWidth})}else{this.gridElement.querySelectorAll(".header-row .cell").forEach(e=>{e.classList.contains(t.GridClasses.STICKY_LEFT)?i+=e.offsetWidth:e.classList.contains(t.GridClasses.STICKY_RIGHT)&&(n+=e.offsetWidth)})}const l=s?.classList.contains(t.GridClasses.STICKY_LEFT)||s?.classList.contains(t.GridClasses.STICKY_RIGHT);return{left:i,right:n,skipScroll:l}}}e.PinnedColumnsPlugin=h,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=pinned-columns.umd.js.map
|
|
@@ -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 { 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 * 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 Group-end adjustments for `afterCellRender` hooks to maintain during scroll\n */\nexport function applyStickyOffsets(host: HTMLElement, columns: any[]): GroupEndAdjustments {\n const empty: GroupEndAdjustments = { addGroupEnd: new Set(), removeGroupEnd: new Set() };\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 empty;\n\n // Detect text direction from the host element\n const direction = getDirection(host);\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 cell.classList.add('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('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 cell.classList.add('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('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 adjustments = applyGroupHeaderStickyOffsets(host, columns, headerCells, direction);\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 adjustments;\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): 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('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('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 }\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('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('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 * 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('.sticky-left, .sticky-right');\n cells.forEach((cell) => {\n cell.classList.remove('sticky-left', '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 { getDirection } from '../../core/internal/utils';\nimport type { AfterCellRenderContext, PluginManifest, PluginQuery } 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} 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 /**\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.#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 this.#groupEndAdjustments = applyStickyOffsets(host, columns);\n });\n }\n\n /**\n * Maintain group-end adjustments on cells rendered during scroll.\n * Runs after GroupingColumnsPlugin.afterCellRender (which sets group-end\n * based on group boundaries), overriding it at pin boundaries.\n * @internal\n */\n override afterCellRender(context: AfterCellRenderContext): void {\n if (!this.isApplied) return;\n const field = context.column.field;\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 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 applyStickyOffsets(this.gridElement, columns);\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('.sticky-left');\n const stickyRightCells = rowEl.querySelectorAll('.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('sticky-left')) {\n left += (cell as HTMLElement).offsetWidth;\n } else if (cell.classList.contains('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('sticky-left') || focusedCell?.classList.contains('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","empty","addGroupEnd","Set","removeGroupEnd","headerCells","Array","from","querySelectorAll","length","getDirection","left","cell","find","c","getAttribute","field","classList","add","style","forEach","el","offsetWidth","right","reverse","adjustments","groupCells","groupCell","gridCol","gridColumn","match","startIdx","parseInt","endIdx","spannedColumns","slice","allLeft","every","allRight","firstField","firstCell","lastField","lastCell","contains","splitMixedPinImplicitGroup","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","clearStickyOffsets","QUERY_CAN_MOVE_COLUMN","PinnedColumnsPlugin","BaseGridPlugin","static","ownedProperties","property","level","description","isUsed","v","queries","type","name","defaultConfig","isApplied","leftOffsets","Map","rightOffsets","groupEndAdjustments","originalColumnOrder","detach","this","clear","detect","rows","config","isArray","processColumns","gridElement","middle","reorderColumnsForPinning","afterRender","queueMicrotask","afterCellRender","context","column","has","cellElement","handleQuery","query","Object","fromEntries","params","isHeader","lockPinning","items","id","label","icon","order","action","setPinPosition","currentColumns","currentIndex","findIndex","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":"oaAqBO,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,CAsFO,SAASa,EAAmBC,EAAmBH,GACpD,MAAMI,EAA6B,CAAEC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,EAAmBH,EAAM7I,iBAAiB,iBAChD+I,EAAgBnI,QAASC,IACvBV,GAASU,EAAmBC,cAE9BkI,EAAiBpI,QAASC,IACxBE,GAAUF,EAAmBC,aAEjC,KAAO,CAEQ0E,KAAKO,YACO/F,iBAAiB,qBAC9BY,QAASR,IACfA,EAAKK,UAAU0B,SAAS,eAC1BhC,GAASC,EAAqBU,YACrBV,EAAKK,UAAU0B,SAAS,kBACjCpB,GAAUX,EAAqBU,cAGrC,CAGA,MAAMmI,EACJH,GAAarI,UAAU0B,SAAS,gBAAkB2G,GAAarI,UAAU0B,SAAS,gBAEpF,MAAO,CAAEhC,OAAMY,QAAOkI,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// 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,E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