@toolbox-web/grid 0.0.4 → 0.0.6
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/README.md +24 -0
- package/all.d.ts +1709 -135
- package/all.js +745 -645
- package/all.js.map +1 -1
- package/index.d.ts +161 -1
- package/index.js +1050 -913
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +110 -52
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +78 -20
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +163 -95
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +93 -35
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +188 -133
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +69 -11
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +111 -55
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +196 -51
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +104 -46
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +74 -16
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +65 -7
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +117 -59
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +103 -45
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +139 -81
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +96 -38
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +108 -47
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +70 -12
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +82 -24
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +31 -31
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -15
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +2 -2
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +3 -3
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +2 -2
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +2 -2
- 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/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +2 -2
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/tree/tree-data.ts","../../../../../libs/grid/src/lib/plugins/tree/tree-detect.ts","../../../../../libs/grid/src/lib/plugins/tree/TreePlugin.ts"],"sourcesContent":["/**\n * Core Tree Data Logic\n *\n * Pure functions for tree flattening, expansion, and traversal.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// The tree plugin intentionally uses `any` for maximum flexibility with user-defined row types.\n\nimport type { FlattenedTreeRow, TreeConfig } from './types';\n\n/**\n * Generates a unique key for a row.\n * Uses row.id if available, otherwise generates from path.\n */\nexport function generateRowKey(row: any, index: number, parentKey: string | null): string {\n if (row.id !== undefined) return String(row.id);\n return parentKey ? `${parentKey}-${index}` : String(index);\n}\n\n/**\n * Flattens a hierarchical tree into a flat array of rows with metadata.\n * Only includes children of expanded nodes.\n */\nexport function flattenTree(\n rows: any[],\n config: TreeConfig,\n expandedKeys: Set<string>,\n parentKey: string | null = null,\n depth = 0\n): FlattenedTreeRow[] {\n const childrenField = config.childrenField ?? 'children';\n const result: FlattenedTreeRow[] = [];\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const key = generateRowKey(row, i, parentKey);\n const children = row[childrenField];\n const hasChildren = Array.isArray(children) && children.length > 0;\n const isExpanded = expandedKeys.has(key);\n\n result.push({\n key,\n data: row,\n depth,\n hasChildren,\n isExpanded,\n parentKey,\n });\n\n // Recursively add children if expanded\n if (hasChildren && isExpanded) {\n const childRows = flattenTree(children, config, expandedKeys, key, depth + 1);\n result.push(...childRows);\n }\n }\n\n return result;\n}\n\n/**\n * Toggles the expansion state of a row.\n * Returns a new Set with the toggled state.\n */\nexport function toggleExpand(expandedKeys: Set<string>, key: string): Set<string> {\n const newExpanded = new Set(expandedKeys);\n if (newExpanded.has(key)) {\n newExpanded.delete(key);\n } else {\n newExpanded.add(key);\n }\n return newExpanded;\n}\n\n/**\n * Expands all nodes in the tree.\n * Returns a Set of all parent row keys.\n */\nexport function expandAll(rows: any[], config: TreeConfig, parentKey: string | null = null, depth = 0): Set<string> {\n const childrenField = config.childrenField ?? 'children';\n const keys = new Set<string>();\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const key = generateRowKey(row, i, parentKey);\n const children = row[childrenField];\n\n if (Array.isArray(children) && children.length > 0) {\n keys.add(key);\n const childKeys = expandAll(children, config, key, depth + 1);\n for (const k of childKeys) keys.add(k);\n }\n }\n\n return keys;\n}\n\n/**\n * Collapses all nodes.\n * Returns an empty Set.\n */\nexport function collapseAll(): Set<string> {\n return new Set();\n}\n\n/**\n * Gets all descendants of a node from the flattened row list.\n * Useful for operations that need to affect an entire subtree.\n */\nexport function getDescendants(flattenedRows: FlattenedTreeRow[], parentKey: string): FlattenedTreeRow[] {\n const descendants: FlattenedTreeRow[] = [];\n let collecting = false;\n let parentDepth = -1;\n\n for (const row of flattenedRows) {\n if (row.key === parentKey) {\n collecting = true;\n parentDepth = row.depth;\n continue;\n }\n\n if (collecting) {\n if (row.depth > parentDepth) {\n descendants.push(row);\n } else {\n break; // No longer a descendant\n }\n }\n }\n\n return descendants;\n}\n\n/**\n * Finds the path from root to a specific row key.\n * Returns an array of keys from root to the target (inclusive).\n */\nexport function getPathToKey(\n rows: any[],\n targetKey: string,\n config: TreeConfig,\n parentKey: string | null = null,\n depth = 0\n): string[] | null {\n const childrenField = config.childrenField ?? 'children';\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const key = generateRowKey(row, i, parentKey);\n\n if (key === targetKey) {\n return [key];\n }\n\n const children = row[childrenField];\n if (Array.isArray(children) && children.length > 0) {\n const childPath = getPathToKey(children, targetKey, config, key, depth + 1);\n if (childPath) {\n return [key, ...childPath];\n }\n }\n }\n\n return null;\n}\n\n/**\n * Expands all ancestors of a specific row to make it visible.\n * Returns a new Set with the required keys added.\n */\nexport function expandToKey(\n rows: any[],\n targetKey: string,\n config: TreeConfig,\n existingExpanded: Set<string>\n): Set<string> {\n const path = getPathToKey(rows, targetKey, config);\n if (!path) return existingExpanded;\n\n const newExpanded = new Set(existingExpanded);\n // Add all keys except the last one (the target itself)\n for (let i = 0; i < path.length - 1; i++) {\n newExpanded.add(path[i]);\n }\n return newExpanded;\n}\n","/**\n * Tree Structure Auto-Detection\n *\n * Utilities for detecting hierarchical tree data structures.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// The tree plugin intentionally uses `any` for maximum flexibility with user-defined row types.\n\n/**\n * Detects if the data has a tree structure by checking for children arrays.\n */\nexport function detectTreeStructure(rows: any[], childrenField = 'children'): boolean {\n if (!Array.isArray(rows) || rows.length === 0) return false;\n\n // Check if any row has a non-empty children array\n for (const row of rows) {\n if (row && Array.isArray(row[childrenField]) && row[childrenField].length > 0) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Attempts to infer the children field name from common patterns.\n * Returns the first field that contains an array with items.\n */\nexport function inferChildrenField(rows: any[]): string | null {\n if (!Array.isArray(rows) || rows.length === 0) return null;\n\n const commonArrayFields = ['children', 'items', 'nodes', 'subRows', 'nested'];\n\n for (const row of rows) {\n if (!row || typeof row !== 'object') continue;\n\n for (const field of commonArrayFields) {\n if (Array.isArray(row[field]) && row[field].length > 0) {\n return field;\n }\n }\n }\n\n return null;\n}\n\n/**\n * Calculates the maximum depth of the tree.\n * Useful for layout calculations and virtualization.\n */\nexport function getMaxDepth(rows: any[], childrenField = 'children', currentDepth = 0): number {\n if (!Array.isArray(rows) || rows.length === 0) return currentDepth;\n\n let maxDepth = currentDepth;\n\n for (const row of rows) {\n if (!row) continue;\n const children = row[childrenField];\n if (Array.isArray(children) && children.length > 0) {\n const childDepth = getMaxDepth(children, childrenField, currentDepth + 1);\n if (childDepth > maxDepth) {\n maxDepth = childDepth;\n }\n }\n }\n\n return maxDepth;\n}\n\n/**\n * Counts total nodes in the tree (including all descendants).\n */\nexport function countNodes(rows: any[], childrenField = 'children'): number {\n if (!Array.isArray(rows)) return 0;\n\n let count = 0;\n for (const row of rows) {\n if (!row) continue;\n count++;\n const children = row[childrenField];\n if (Array.isArray(children)) {\n count += countNodes(children, childrenField);\n }\n }\n\n return count;\n}\n","/**\n * Tree Data Plugin (Class-based)\n *\n * Enables hierarchical tree data with expand/collapse and auto-detection.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// The tree plugin intentionally uses `any` for maximum flexibility with user-defined row types.\n\nimport { BaseGridPlugin, CellClickEvent } from '../../core/plugin/base-plugin';\nimport type { ColumnConfig } from '../../core/types';\nimport { collapseAll, expandAll, expandToKey, flattenTree, toggleExpand } from './tree-data';\nimport { detectTreeStructure, inferChildrenField } from './tree-detect';\nimport type { FlattenedTreeRow, TreeConfig, TreeExpandDetail } from './types';\n\n/**\n * Tree Data Plugin for tbw-grid\n *\n * Provides hierarchical tree data display with expand/collapse functionality.\n *\n * @example\n * ```ts\n * new TreePlugin({ defaultExpanded: true, indentWidth: 24 })\n * ```\n */\nexport class TreePlugin extends BaseGridPlugin<TreeConfig> {\n readonly name = 'tree';\n override readonly version = '1.0.0';\n\n protected override get defaultConfig(): Partial<TreeConfig> {\n return {\n enabled: true,\n childrenField: 'children',\n autoDetect: true,\n defaultExpanded: false,\n indentWidth: 20,\n showExpandIcons: true,\n };\n }\n\n // ===== Internal State =====\n\n /** Set of expanded row keys */\n private expandedKeys = new Set<string>();\n\n /** Whether initial expansion (based on defaultExpanded config) has been applied */\n private initialExpansionDone = false;\n\n /** Flattened tree rows for rendering */\n private flattenedRows: FlattenedTreeRow[] = [];\n\n /** Map from key to flattened row for quick lookup */\n private rowKeyMap = new Map<string, FlattenedTreeRow>();\n\n // ===== Lifecycle =====\n\n override detach(): void {\n this.expandedKeys.clear();\n this.initialExpansionDone = false;\n this.flattenedRows = [];\n this.rowKeyMap.clear();\n }\n\n // ===== Auto-Detection =====\n\n /**\n * Detects if tree functionality should be enabled based on data structure.\n * Called by the grid during plugin initialization.\n */\n detect(rows: readonly unknown[]): boolean {\n if (!this.config.autoDetect) return false;\n const childrenField = this.config.childrenField ?? inferChildrenField(rows as any[]) ?? 'children';\n return detectTreeStructure(rows as any[], childrenField);\n }\n\n // ===== Data Processing =====\n\n override processRows(rows: readonly unknown[]): any[] {\n const childrenField = this.config.childrenField ?? 'children';\n\n // Check if data is actually a tree\n if (!detectTreeStructure(rows as any[], childrenField)) {\n this.flattenedRows = [];\n this.rowKeyMap.clear();\n return [...rows];\n }\n\n // Initialize expansion state if needed (only once per grid lifecycle)\n if (this.config.defaultExpanded && !this.initialExpansionDone) {\n this.expandedKeys = expandAll(rows as any[], this.config);\n this.initialExpansionDone = true;\n }\n\n // Flatten tree\n this.flattenedRows = flattenTree(rows as any[], this.config, this.expandedKeys);\n\n // Build key map\n this.rowKeyMap.clear();\n for (const flatRow of this.flattenedRows) {\n this.rowKeyMap.set(flatRow.key, flatRow);\n }\n\n // Return flattened data for rendering with tree metadata\n return this.flattenedRows.map((fr) => ({\n ...fr.data,\n __treeKey: fr.key,\n __treeDepth: fr.depth,\n __treeHasChildren: fr.hasChildren,\n __treeExpanded: fr.isExpanded,\n }));\n }\n\n override processColumns(columns: readonly ColumnConfig[]): ColumnConfig[] {\n if (this.flattenedRows.length === 0) return [...columns];\n\n const indentWidth = this.config.indentWidth ?? 20;\n const showExpandIcons = this.config.showExpandIcons ?? true;\n\n // Wrap first column's renderer to add tree indentation\n const cols = [...columns] as ColumnConfig[];\n if (cols.length > 0) {\n const firstCol = { ...cols[0] };\n const originalRenderer = firstCol.viewRenderer;\n\n firstCol.viewRenderer = (renderCtx) => {\n const { value, row, column: colConfig } = renderCtx;\n const depth = row.__treeDepth ?? 0;\n const hasChildren = row.__treeHasChildren ?? false;\n const isExpanded = row.__treeExpanded ?? false;\n\n const container = document.createElement('span');\n container.style.display = 'flex';\n container.style.alignItems = 'center';\n container.style.paddingLeft = `${depth * indentWidth}px`;\n\n // Expand/collapse icon\n if (hasChildren && showExpandIcons) {\n const icon = document.createElement('span');\n icon.className = 'tree-toggle';\n icon.textContent = isExpanded ? '▼' : '▶';\n icon.style.cursor = 'pointer';\n icon.style.marginRight = '4px';\n icon.style.fontSize = '10px';\n icon.setAttribute('data-tree-key', row.__treeKey);\n container.appendChild(icon);\n } else if (showExpandIcons) {\n // Spacer for alignment\n const spacer = document.createElement('span');\n spacer.style.width = '14px';\n spacer.style.display = 'inline-block';\n container.appendChild(spacer);\n }\n\n // Cell content\n const content = document.createElement('span');\n if (originalRenderer) {\n const rendered = originalRenderer(renderCtx);\n if (rendered instanceof Node) {\n content.appendChild(rendered);\n } else {\n content.textContent = String(rendered ?? value ?? '');\n }\n } else {\n content.textContent = String(value ?? '');\n }\n container.appendChild(content);\n\n return container;\n };\n\n cols[0] = firstCol;\n }\n\n return cols;\n }\n\n // ===== Event Handlers =====\n\n override onCellClick(event: CellClickEvent): boolean {\n const target = event.originalEvent?.target as HTMLElement;\n if (!target?.classList.contains('tree-toggle')) return false;\n\n const key = target.getAttribute('data-tree-key');\n if (!key) return false;\n\n const flatRow = this.rowKeyMap.get(key);\n if (!flatRow) return false;\n\n this.expandedKeys = toggleExpand(this.expandedKeys, key);\n\n this.emit<TreeExpandDetail>('tree-expand', {\n key,\n row: flatRow.data,\n expanded: this.expandedKeys.has(key),\n depth: flatRow.depth,\n });\n\n this.requestRender();\n return true;\n }\n\n // ===== Public API =====\n\n /**\n * Expand a specific node by key.\n */\n expand(key: string): void {\n this.expandedKeys.add(key);\n this.requestRender();\n }\n\n /**\n * Collapse a specific node by key.\n */\n collapse(key: string): void {\n this.expandedKeys.delete(key);\n this.requestRender();\n }\n\n /**\n * Toggle the expansion state of a node.\n */\n toggle(key: string): void {\n this.expandedKeys = toggleExpand(this.expandedKeys, key);\n this.requestRender();\n }\n\n /**\n * Expand all nodes in the tree.\n */\n expandAll(): void {\n this.expandedKeys = expandAll(this.rows as any[], this.config);\n this.requestRender();\n }\n\n /**\n * Collapse all nodes in the tree.\n */\n collapseAll(): void {\n this.expandedKeys = collapseAll();\n this.requestRender();\n }\n\n /**\n * Check if a node is currently expanded.\n */\n isExpanded(key: string): boolean {\n return this.expandedKeys.has(key);\n }\n\n /**\n * Get all currently expanded keys.\n */\n getExpandedKeys(): string[] {\n return [...this.expandedKeys];\n }\n\n /**\n * Get the flattened tree rows with metadata.\n */\n getFlattenedRows(): FlattenedTreeRow[] {\n return [...this.flattenedRows];\n }\n\n /**\n * Get a row's original data by its key.\n */\n getRowByKey(key: string): any | undefined {\n return this.rowKeyMap.get(key)?.data;\n }\n\n /**\n * Expand all ancestors of a node to make it visible.\n */\n expandToKey(key: string): void {\n this.expandedKeys = expandToKey(this.rows as any[], key, this.config, this.expandedKeys);\n this.requestRender();\n }\n\n // ===== Styles =====\n\n override readonly styles = `\n .tree-toggle {\n cursor: pointer;\n user-select: none;\n transition: transform 0.2s;\n }\n .tree-toggle:hover {\n color: var(--tbw-tree-accent, var(--tbw-color-accent));\n }\n `;\n}\n"],"names":["generateRowKey","row","index","parentKey","flattenTree","rows","config","expandedKeys","depth","childrenField","result","i","key","children","hasChildren","isExpanded","childRows","toggleExpand","newExpanded","expandAll","keys","childKeys","k","collapseAll","getPathToKey","targetKey","childPath","expandToKey","existingExpanded","path","detectTreeStructure","inferChildrenField","commonArrayFields","field","getMaxDepth","currentDepth","maxDepth","childDepth","countNodes","count","TreePlugin","BaseGridPlugin","flatRow","fr","columns","indentWidth","showExpandIcons","cols","firstCol","originalRenderer","renderCtx","value","colConfig","container","icon","spacer","content","rendered","event","target"],"mappings":"gUAeO,SAASA,EAAeC,EAAUC,EAAeC,EAAkC,CACxF,OAAIF,EAAI,KAAO,OAAkB,OAAOA,EAAI,EAAE,EACvCE,EAAY,GAAGA,CAAS,IAAID,CAAK,GAAK,OAAOA,CAAK,CAC3D,CAMO,SAASE,EACdC,EACAC,EACAC,EACAJ,EAA2B,KAC3BK,EAAQ,EACY,CACpB,MAAMC,EAAgBH,EAAO,eAAiB,WACxCI,EAA6B,CAAA,EAEnC,QAASC,EAAI,EAAGA,EAAIN,EAAK,OAAQM,IAAK,CACpC,MAAMV,EAAMI,EAAKM,CAAC,EACZC,EAAMZ,EAAeC,EAAKU,EAAGR,CAAS,EACtCU,EAAWZ,EAAIQ,CAAa,EAC5BK,EAAc,MAAM,QAAQD,CAAQ,GAAKA,EAAS,OAAS,EAC3DE,EAAaR,EAAa,IAAIK,CAAG,EAYvC,GAVAF,EAAO,KAAK,CACV,IAAAE,EACA,KAAMX,EACN,MAAAO,EACA,YAAAM,EACA,WAAAC,EACA,UAAAZ,CAAA,CACD,EAGGW,GAAeC,EAAY,CAC7B,MAAMC,EAAYZ,EAAYS,EAAUP,EAAQC,EAAcK,EAAKJ,EAAQ,CAAC,EAC5EE,EAAO,KAAK,GAAGM,CAAS,CAC1B,CACF,CAEA,OAAON,CACT,CAMO,SAASO,EAAaV,EAA2BK,EAA0B,CAChF,MAAMM,EAAc,IAAI,IAAIX,CAAY,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C1B,MAAO,CAAC,GAAG,KAAK,YAAY,CAC9B,CAKA,kBAAuC,CACrC,MAAO,CAAC,GAAG,KAAK,aAAa,CAC/B,CAKA,YAAYA,EAA8B,CACxC,OAAO,KAAK,UAAU,IAAIA,CAAG,GAAG,IAClC,CAKA,YAAYA,EAAmB,CAC7B,KAAK,aAAee,EAAY,KAAK,KAAef,EAAK,KAAK,OAAQ,KAAK,YAAY,EACvF,KAAK,cAAA,CACP,CAIkB,OAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAU7B"}
|
|
1
|
+
{"version":3,"file":"tree.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/tree/tree-data.ts","../../../../../libs/grid/src/lib/plugins/tree/tree-detect.ts","../../../../../libs/grid/src/lib/plugins/tree/TreePlugin.ts"],"sourcesContent":["/**\n * Core Tree Data Logic\n *\n * Pure functions for tree flattening, expansion, and traversal.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// The tree plugin intentionally uses `any` for maximum flexibility with user-defined row types.\n\nimport type { FlattenedTreeRow, TreeConfig } from './types';\n\n/**\n * Generates a unique key for a row.\n * Uses row.id if available, otherwise generates from path.\n */\nexport function generateRowKey(row: any, index: number, parentKey: string | null): string {\n if (row.id !== undefined) return String(row.id);\n return parentKey ? `${parentKey}-${index}` : String(index);\n}\n\n/**\n * Flattens a hierarchical tree into a flat array of rows with metadata.\n * Only includes children of expanded nodes.\n */\nexport function flattenTree(\n rows: any[],\n config: TreeConfig,\n expandedKeys: Set<string>,\n parentKey: string | null = null,\n depth = 0\n): FlattenedTreeRow[] {\n const childrenField = config.childrenField ?? 'children';\n const result: FlattenedTreeRow[] = [];\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const key = generateRowKey(row, i, parentKey);\n const children = row[childrenField];\n const hasChildren = Array.isArray(children) && children.length > 0;\n const isExpanded = expandedKeys.has(key);\n\n result.push({\n key,\n data: row,\n depth,\n hasChildren,\n isExpanded,\n parentKey,\n });\n\n // Recursively add children if expanded\n if (hasChildren && isExpanded) {\n const childRows = flattenTree(children, config, expandedKeys, key, depth + 1);\n result.push(...childRows);\n }\n }\n\n return result;\n}\n\n/**\n * Toggles the expansion state of a row.\n * Returns a new Set with the toggled state.\n */\nexport function toggleExpand(expandedKeys: Set<string>, key: string): Set<string> {\n const newExpanded = new Set(expandedKeys);\n if (newExpanded.has(key)) {\n newExpanded.delete(key);\n } else {\n newExpanded.add(key);\n }\n return newExpanded;\n}\n\n/**\n * Expands all nodes in the tree.\n * Returns a Set of all parent row keys.\n */\nexport function expandAll(rows: any[], config: TreeConfig, parentKey: string | null = null, depth = 0): Set<string> {\n const childrenField = config.childrenField ?? 'children';\n const keys = new Set<string>();\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const key = generateRowKey(row, i, parentKey);\n const children = row[childrenField];\n\n if (Array.isArray(children) && children.length > 0) {\n keys.add(key);\n const childKeys = expandAll(children, config, key, depth + 1);\n for (const k of childKeys) keys.add(k);\n }\n }\n\n return keys;\n}\n\n/**\n * Collapses all nodes.\n * Returns an empty Set.\n */\nexport function collapseAll(): Set<string> {\n return new Set();\n}\n\n/**\n * Gets all descendants of a node from the flattened row list.\n * Useful for operations that need to affect an entire subtree.\n */\nexport function getDescendants(flattenedRows: FlattenedTreeRow[], parentKey: string): FlattenedTreeRow[] {\n const descendants: FlattenedTreeRow[] = [];\n let collecting = false;\n let parentDepth = -1;\n\n for (const row of flattenedRows) {\n if (row.key === parentKey) {\n collecting = true;\n parentDepth = row.depth;\n continue;\n }\n\n if (collecting) {\n if (row.depth > parentDepth) {\n descendants.push(row);\n } else {\n break; // No longer a descendant\n }\n }\n }\n\n return descendants;\n}\n\n/**\n * Finds the path from root to a specific row key.\n * Returns an array of keys from root to the target (inclusive).\n */\nexport function getPathToKey(\n rows: any[],\n targetKey: string,\n config: TreeConfig,\n parentKey: string | null = null,\n depth = 0\n): string[] | null {\n const childrenField = config.childrenField ?? 'children';\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const key = generateRowKey(row, i, parentKey);\n\n if (key === targetKey) {\n return [key];\n }\n\n const children = row[childrenField];\n if (Array.isArray(children) && children.length > 0) {\n const childPath = getPathToKey(children, targetKey, config, key, depth + 1);\n if (childPath) {\n return [key, ...childPath];\n }\n }\n }\n\n return null;\n}\n\n/**\n * Expands all ancestors of a specific row to make it visible.\n * Returns a new Set with the required keys added.\n */\nexport function expandToKey(\n rows: any[],\n targetKey: string,\n config: TreeConfig,\n existingExpanded: Set<string>\n): Set<string> {\n const path = getPathToKey(rows, targetKey, config);\n if (!path) return existingExpanded;\n\n const newExpanded = new Set(existingExpanded);\n // Add all keys except the last one (the target itself)\n for (let i = 0; i < path.length - 1; i++) {\n newExpanded.add(path[i]);\n }\n return newExpanded;\n}\n","/**\n * Tree Structure Auto-Detection\n *\n * Utilities for detecting hierarchical tree data structures.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// The tree plugin intentionally uses `any` for maximum flexibility with user-defined row types.\n\n/**\n * Detects if the data has a tree structure by checking for children arrays.\n */\nexport function detectTreeStructure(rows: any[], childrenField = 'children'): boolean {\n if (!Array.isArray(rows) || rows.length === 0) return false;\n\n // Check if any row has a non-empty children array\n for (const row of rows) {\n if (row && Array.isArray(row[childrenField]) && row[childrenField].length > 0) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Attempts to infer the children field name from common patterns.\n * Returns the first field that contains an array with items.\n */\nexport function inferChildrenField(rows: any[]): string | null {\n if (!Array.isArray(rows) || rows.length === 0) return null;\n\n const commonArrayFields = ['children', 'items', 'nodes', 'subRows', 'nested'];\n\n for (const row of rows) {\n if (!row || typeof row !== 'object') continue;\n\n for (const field of commonArrayFields) {\n if (Array.isArray(row[field]) && row[field].length > 0) {\n return field;\n }\n }\n }\n\n return null;\n}\n\n/**\n * Calculates the maximum depth of the tree.\n * Useful for layout calculations and virtualization.\n */\nexport function getMaxDepth(rows: any[], childrenField = 'children', currentDepth = 0): number {\n if (!Array.isArray(rows) || rows.length === 0) return currentDepth;\n\n let maxDepth = currentDepth;\n\n for (const row of rows) {\n if (!row) continue;\n const children = row[childrenField];\n if (Array.isArray(children) && children.length > 0) {\n const childDepth = getMaxDepth(children, childrenField, currentDepth + 1);\n if (childDepth > maxDepth) {\n maxDepth = childDepth;\n }\n }\n }\n\n return maxDepth;\n}\n\n/**\n * Counts total nodes in the tree (including all descendants).\n */\nexport function countNodes(rows: any[], childrenField = 'children'): number {\n if (!Array.isArray(rows)) return 0;\n\n let count = 0;\n for (const row of rows) {\n if (!row) continue;\n count++;\n const children = row[childrenField];\n if (Array.isArray(children)) {\n count += countNodes(children, childrenField);\n }\n }\n\n return count;\n}\n","/**\n * Tree Data Plugin (Class-based)\n *\n * Enables hierarchical tree data with expand/collapse and auto-detection.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// The tree plugin intentionally uses `any` for maximum flexibility with user-defined row types.\n\nimport { BaseGridPlugin, CellClickEvent } from '../../core/plugin/base-plugin';\nimport type { ColumnConfig } from '../../core/types';\nimport { collapseAll, expandAll, expandToKey, flattenTree, toggleExpand } from './tree-data';\nimport { detectTreeStructure, inferChildrenField } from './tree-detect';\nimport type { FlattenedTreeRow, TreeConfig, TreeExpandDetail } from './types';\n\n/**\n * Tree Data Plugin for tbw-grid\n *\n * Provides hierarchical tree data display with expand/collapse functionality.\n *\n * @example\n * ```ts\n * new TreePlugin({ defaultExpanded: true, indentWidth: 24 })\n * ```\n */\nexport class TreePlugin extends BaseGridPlugin<TreeConfig> {\n readonly name = 'tree';\n override readonly version = '1.0.0';\n\n protected override get defaultConfig(): Partial<TreeConfig> {\n return {\n enabled: true,\n childrenField: 'children',\n autoDetect: true,\n defaultExpanded: false,\n indentWidth: 20,\n showExpandIcons: true,\n };\n }\n\n // ===== Internal State =====\n\n /** Set of expanded row keys */\n private expandedKeys = new Set<string>();\n\n /** Whether initial expansion (based on defaultExpanded config) has been applied */\n private initialExpansionDone = false;\n\n /** Flattened tree rows for rendering */\n private flattenedRows: FlattenedTreeRow[] = [];\n\n /** Map from key to flattened row for quick lookup */\n private rowKeyMap = new Map<string, FlattenedTreeRow>();\n\n // ===== Lifecycle =====\n\n override detach(): void {\n this.expandedKeys.clear();\n this.initialExpansionDone = false;\n this.flattenedRows = [];\n this.rowKeyMap.clear();\n }\n\n // ===== Auto-Detection =====\n\n /**\n * Detects if tree functionality should be enabled based on data structure.\n * Called by the grid during plugin initialization.\n */\n detect(rows: readonly unknown[]): boolean {\n if (!this.config.autoDetect) return false;\n const childrenField = this.config.childrenField ?? inferChildrenField(rows as any[]) ?? 'children';\n return detectTreeStructure(rows as any[], childrenField);\n }\n\n // ===== Data Processing =====\n\n override processRows(rows: readonly unknown[]): any[] {\n const childrenField = this.config.childrenField ?? 'children';\n\n // Check if data is actually a tree\n if (!detectTreeStructure(rows as any[], childrenField)) {\n this.flattenedRows = [];\n this.rowKeyMap.clear();\n return [...rows];\n }\n\n // Initialize expansion state if needed (only once per grid lifecycle)\n if (this.config.defaultExpanded && !this.initialExpansionDone) {\n this.expandedKeys = expandAll(rows as any[], this.config);\n this.initialExpansionDone = true;\n }\n\n // Flatten tree\n this.flattenedRows = flattenTree(rows as any[], this.config, this.expandedKeys);\n\n // Build key map\n this.rowKeyMap.clear();\n for (const flatRow of this.flattenedRows) {\n this.rowKeyMap.set(flatRow.key, flatRow);\n }\n\n // Return flattened data for rendering with tree metadata\n return this.flattenedRows.map((fr) => ({\n ...fr.data,\n __treeKey: fr.key,\n __treeDepth: fr.depth,\n __treeHasChildren: fr.hasChildren,\n __treeExpanded: fr.isExpanded,\n }));\n }\n\n override processColumns(columns: readonly ColumnConfig[]): ColumnConfig[] {\n if (this.flattenedRows.length === 0) return [...columns];\n\n const indentWidth = this.config.indentWidth ?? 20;\n const showExpandIcons = this.config.showExpandIcons ?? true;\n\n // Wrap first column's renderer to add tree indentation\n const cols = [...columns] as ColumnConfig[];\n if (cols.length > 0) {\n const firstCol = { ...cols[0] };\n const originalRenderer = firstCol.viewRenderer;\n\n // Skip if already wrapped by this plugin (prevents double-wrapping on re-render)\n if ((originalRenderer as any)?.__treeWrapped) {\n return cols;\n }\n\n const wrappedRenderer = (renderCtx: Parameters<NonNullable<typeof originalRenderer>>[0]) => {\n const { value, row, column: colConfig } = renderCtx;\n const depth = row.__treeDepth ?? 0;\n const hasChildren = row.__treeHasChildren ?? false;\n const isExpanded = row.__treeExpanded ?? false;\n\n const container = document.createElement('span');\n container.style.display = 'flex';\n container.style.alignItems = 'center';\n container.style.paddingLeft = `${depth * indentWidth}px`;\n\n // Expand/collapse icon\n if (hasChildren && showExpandIcons) {\n const icon = document.createElement('span');\n icon.className = 'tree-toggle';\n // Use grid-level icons (fall back to defaults)\n this.setIcon(icon, this.resolveIcon(isExpanded ? 'collapse' : 'expand'));\n icon.style.cursor = 'pointer';\n icon.style.marginRight = '4px';\n icon.style.fontSize = '10px';\n icon.setAttribute('data-tree-key', row.__treeKey);\n container.appendChild(icon);\n } else if (showExpandIcons) {\n // Spacer for alignment\n const spacer = document.createElement('span');\n spacer.style.width = '14px';\n spacer.style.display = 'inline-block';\n container.appendChild(spacer);\n }\n\n // Cell content\n const content = document.createElement('span');\n if (originalRenderer) {\n const rendered = originalRenderer(renderCtx);\n if (rendered instanceof Node) {\n content.appendChild(rendered);\n } else {\n content.textContent = String(rendered ?? value ?? '');\n }\n } else {\n content.textContent = String(value ?? '');\n }\n container.appendChild(content);\n\n return container;\n };\n\n // Mark renderer as wrapped to prevent double-wrapping\n (wrappedRenderer as any).__treeWrapped = true;\n firstCol.viewRenderer = wrappedRenderer;\n\n cols[0] = firstCol;\n }\n\n return cols;\n }\n\n // ===== Event Handlers =====\n\n override onCellClick(event: CellClickEvent): boolean {\n const target = event.originalEvent?.target as HTMLElement;\n if (!target?.classList.contains('tree-toggle')) return false;\n\n const key = target.getAttribute('data-tree-key');\n if (!key) return false;\n\n const flatRow = this.rowKeyMap.get(key);\n if (!flatRow) return false;\n\n this.expandedKeys = toggleExpand(this.expandedKeys, key);\n\n this.emit<TreeExpandDetail>('tree-expand', {\n key,\n row: flatRow.data,\n expanded: this.expandedKeys.has(key),\n depth: flatRow.depth,\n });\n\n this.requestRender();\n return true;\n }\n\n // ===== Public API =====\n\n /**\n * Expand a specific node by key.\n */\n expand(key: string): void {\n this.expandedKeys.add(key);\n this.requestRender();\n }\n\n /**\n * Collapse a specific node by key.\n */\n collapse(key: string): void {\n this.expandedKeys.delete(key);\n this.requestRender();\n }\n\n /**\n * Toggle the expansion state of a node.\n */\n toggle(key: string): void {\n this.expandedKeys = toggleExpand(this.expandedKeys, key);\n this.requestRender();\n }\n\n /**\n * Expand all nodes in the tree.\n */\n expandAll(): void {\n this.expandedKeys = expandAll(this.rows as any[], this.config);\n this.requestRender();\n }\n\n /**\n * Collapse all nodes in the tree.\n */\n collapseAll(): void {\n this.expandedKeys = collapseAll();\n this.requestRender();\n }\n\n /**\n * Check if a node is currently expanded.\n */\n isExpanded(key: string): boolean {\n return this.expandedKeys.has(key);\n }\n\n /**\n * Get all currently expanded keys.\n */\n getExpandedKeys(): string[] {\n return [...this.expandedKeys];\n }\n\n /**\n * Get the flattened tree rows with metadata.\n */\n getFlattenedRows(): FlattenedTreeRow[] {\n return [...this.flattenedRows];\n }\n\n /**\n * Get a row's original data by its key.\n */\n getRowByKey(key: string): any | undefined {\n return this.rowKeyMap.get(key)?.data;\n }\n\n /**\n * Expand all ancestors of a node to make it visible.\n */\n expandToKey(key: string): void {\n this.expandedKeys = expandToKey(this.rows as any[], key, this.config, this.expandedKeys);\n this.requestRender();\n }\n\n // ===== Styles =====\n\n override readonly styles = `\n .tree-toggle {\n cursor: pointer;\n user-select: none;\n transition: transform 0.2s;\n }\n .tree-toggle:hover {\n color: var(--tbw-tree-accent, var(--tbw-color-accent));\n }\n `;\n}\n"],"names":["generateRowKey","row","index","parentKey","flattenTree","rows","config","expandedKeys","depth","childrenField","result","i","key","children","hasChildren","isExpanded","childRows","toggleExpand","newExpanded","expandAll","keys","childKeys","k","collapseAll","getPathToKey","targetKey","childPath","expandToKey","existingExpanded","path","detectTreeStructure","inferChildrenField","commonArrayFields","field","getMaxDepth","currentDepth","maxDepth","childDepth","countNodes","count","TreePlugin","BaseGridPlugin","flatRow","fr","columns","indentWidth","showExpandIcons","cols","firstCol","originalRenderer","wrappedRenderer","renderCtx","value","colConfig","container","icon","spacer","content","rendered","event","target"],"mappings":"gUAeO,SAASA,EAAeC,EAAUC,EAAeC,EAAkC,CACxF,OAAIF,EAAI,KAAO,OAAkB,OAAOA,EAAI,EAAE,EACvCE,EAAY,GAAGA,CAAS,IAAID,CAAK,GAAK,OAAOA,CAAK,CAC3D,CAMO,SAASE,EACdC,EACAC,EACAC,EACAJ,EAA2B,KAC3BK,EAAQ,EACY,CACpB,MAAMC,EAAgBH,EAAO,eAAiB,WACxCI,EAA6B,CAAA,EAEnC,QAASC,EAAI,EAAGA,EAAIN,EAAK,OAAQM,IAAK,CACpC,MAAMV,EAAMI,EAAKM,CAAC,EACZC,EAAMZ,EAAeC,EAAKU,EAAGR,CAAS,EACtCU,EAAWZ,EAAIQ,CAAa,EAC5BK,EAAc,MAAM,QAAQD,CAAQ,GAAKA,EAAS,OAAS,EAC3DE,EAAaR,EAAa,IAAIK,CAAG,EAYvC,GAVAF,EAAO,KAAK,CACV,IAAAE,EACA,KAAMX,EACN,MAAAO,EACA,YAAAM,EACA,WAAAC,EACA,UAAAZ,CAAA,CACD,EAGGW,GAAeC,EAAY,CAC7B,MAAMC,EAAYZ,EAAYS,EAAUP,EAAQC,EAAcK,EAAKJ,EAAQ,CAAC,EAC5EE,EAAO,KAAK,GAAGM,CAAS,CAC1B,CACF,CAEA,OAAON,CACT,CAMO,SAASO,EAAaV,EAA2BK,EAA0B,CAChF,MAAMM,EAAc,IAAI,IAAIX,CAAY,EACxC,OAAIW,EAAY,IAAIN,CAAG,EACrBM,EAAY,OAAON,CAAG,EAEtBM,EAAY,IAAIN,CAAG,EAEdM,CACT,C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,iBAA4B,CAC1B,MAAO,CAAC,GAAG,KAAK,YAAY,CAC9B,CAKA,kBAAuC,CACrC,MAAO,CAAC,GAAG,KAAK,aAAa,CAC/B,CAKA,YAAYA,EAA8B,CACxC,OAAO,KAAK,UAAU,IAAIA,CAAG,GAAG,IAClC,CAKA,YAAYA,EAAmB,CAC7B,KAAK,aAAee,EAAY,KAAK,KAAef,EAAK,KAAK,OAAQ,KAAK,YAAY,EACvF,KAAK,cAAA,CACP,CAIkB,OAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAU7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(d,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("../../core/plugin/base-plugin")):typeof define=="function"&&define.amd?define(["exports","../../core/plugin/base-plugin"],b):(d=typeof globalThis<"u"?globalThis:d||self,b(d.TbwGridPlugin_visibility={},d.TbwGrid))})(this,(function(d,b){"use strict";function p(f){const e=f.meta??{};return e.lockPosition!==!0&&e.suppressMovable!==!0}class c extends b.BaseGridPlugin{name="visibility";version="1.0.0";static PANEL_ID="columns";get defaultConfig(){return{enabled:!0,allowHideAll:!1}}columnListElement=null;isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;detach(){this.columnListElement=null,this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null}getToolPanel(){if(this.config.enabled)return{id:c.PANEL_ID,title:"Columns",icon:"☰",tooltip:"Column visibility",order:100,render:e=>this.renderPanelContent(e)}}show(){this.grid.openToolPanel(c.PANEL_ID)}hide(){this.grid.closeToolPanel()}toggle(){this.grid.toggleToolPanel(c.PANEL_ID)}isColumnVisible(e){return this.grid.isColumnVisible(e)}setColumnVisible(e,t){this.grid.setColumnVisible(e,t)}getVisibleColumns(){return this.grid.getAllColumns().filter(t=>t.visible).map(t=>t.field)}getHiddenColumns(){return this.grid.getAllColumns().filter(t=>!t.visible).map(t=>t.field)}showAll(){this.grid.showAllColumns()}toggleColumn(e){this.grid.toggleColumnVisibility(e)}showColumn(e){this.grid.setColumnVisible(e,!0)}hideColumn(e){this.grid.setColumnVisible(e,!1)}getAllColumns(){return this.grid.getAllColumns()}isPanelVisible(){return this.grid.activeToolPanel===c.PANEL_ID}renderPanelContent(e){const t=this.grid,o=document.createElement("div");o.className="tbw-visibility-content";const
|
|
1
|
+
(function(d,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("../../core/plugin/base-plugin")):typeof define=="function"&&define.amd?define(["exports","../../core/plugin/base-plugin"],b):(d=typeof globalThis<"u"?globalThis:d||self,b(d.TbwGridPlugin_visibility={},d.TbwGrid))})(this,(function(d,b){"use strict";function p(f){const e=f.meta??{};return e.lockPosition!==!0&&e.suppressMovable!==!0}class c extends b.BaseGridPlugin{name="visibility";version="1.0.0";static PANEL_ID="columns";get defaultConfig(){return{enabled:!0,allowHideAll:!1}}columnListElement=null;isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;detach(){this.columnListElement=null,this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null}getToolPanel(){if(this.config.enabled)return{id:c.PANEL_ID,title:"Columns",icon:"☰",tooltip:"Column visibility",order:100,render:e=>this.renderPanelContent(e)}}show(){this.grid.openToolPanel(c.PANEL_ID)}hide(){this.grid.closeToolPanel()}toggle(){this.grid.toggleToolPanel(c.PANEL_ID)}isColumnVisible(e){return this.grid.isColumnVisible(e)}setColumnVisible(e,t){this.grid.setColumnVisible(e,t)}getVisibleColumns(){return this.grid.getAllColumns().filter(t=>t.visible).map(t=>t.field)}getHiddenColumns(){return this.grid.getAllColumns().filter(t=>!t.visible).map(t=>t.field)}showAll(){this.grid.showAllColumns()}toggleColumn(e){this.grid.toggleColumnVisibility(e)}showColumn(e){this.grid.setColumnVisible(e,!0)}hideColumn(e){this.grid.setColumnVisible(e,!1)}getAllColumns(){return this.grid.getAllColumns()}isPanelVisible(){return this.grid.activeToolPanel===c.PANEL_ID}renderPanelContent(e){const t=this.grid,o=document.createElement("div");o.className="tbw-visibility-content";const s=document.createElement("div");s.className="tbw-visibility-list",o.appendChild(s);const i=document.createElement("button");return i.className="tbw-visibility-show-all",i.textContent="Show All",i.addEventListener("click",()=>{t.showAllColumns(),this.rebuildToggles(s)}),o.appendChild(i),this.columnListElement=s,this.rebuildToggles(s),e.appendChild(o),()=>{this.columnListElement=null,o.remove()}}hasReorderPlugin(){const e=this.grid?.getPluginByName?.("reorder");return!!(e&&typeof e.moveColumn=="function")}rebuildToggles(e){const t=this.grid,o=this.hasReorderPlugin();e.innerHTML="";const s=t.getAllColumns();for(let i=0;i<s.length;i++){const l=s[i],n=l.header||l.field,r=document.createElement("div");r.className=l.lockVisible?"tbw-visibility-row locked":"tbw-visibility-row",r.setAttribute("data-field",l.field),r.setAttribute("data-index",String(i)),o&&p(l)&&(r.draggable=!0,r.classList.add("reorderable"),this.setupDragListeners(r,l.field,i,e));const a=document.createElement("label");a.className="tbw-visibility-label";const g=document.createElement("input");g.type="checkbox",g.checked=l.visible,g.disabled=l.lockVisible??!1,g.addEventListener("change",()=>{t.toggleColumnVisibility(l.field),setTimeout(()=>this.rebuildToggles(e),0)});const h=document.createElement("span");if(h.textContent=n,a.appendChild(g),a.appendChild(h),o&&p(l)){const u=document.createElement("span");u.className="tbw-visibility-handle",this.setIcon(u,this.resolveIcon("dragHandle")),u.title="Drag to reorder",r.appendChild(u)}r.appendChild(a),e.appendChild(r)}}setupDragListeners(e,t,o,s){e.addEventListener("dragstart",i=>{this.isDragging=!0,this.draggedField=t,this.draggedIndex=o,i.dataTransfer&&(i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",t)),e.classList.add("dragging")}),e.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,s.querySelectorAll(".tbw-visibility-row").forEach(i=>{i.classList.remove("dragging","drop-target","drop-before","drop-after")})}),e.addEventListener("dragover",i=>{if(i.preventDefault(),!this.isDragging||this.draggedField===t)return;const l=e.getBoundingClientRect(),n=l.top+l.height/2;this.dropIndex=i.clientY<n?o:o+1,s.querySelectorAll(".tbw-visibility-row").forEach(r=>{r!==e&&r.classList.remove("drop-target","drop-before","drop-after")}),e.classList.add("drop-target"),e.classList.toggle("drop-before",i.clientY<n),e.classList.toggle("drop-after",i.clientY>=n)}),e.addEventListener("dragleave",()=>{e.classList.remove("drop-target","drop-before","drop-after")}),e.addEventListener("drop",i=>{i.preventDefault();const l=this.draggedField,n=this.draggedIndex,r=this.dropIndex;if(!this.isDragging||l===null||n===null||r===null)return;const a=r>n?r-1:r;if(a!==n){const g={field:l,fromIndex:n,toIndex:a};this.emit("column-reorder-request",g),setTimeout(()=>{this.rebuildToggles(s)},0)}})}styles=`
|
|
2
2
|
.tbw-visibility-content {
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visibility.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/visibility/VisibilityPlugin.ts"],"sourcesContent":["/**\n * Column Visibility Plugin (Class-based)\n *\n * Provides a UI for column visibility control via the shell's tool panel system.\n * Column visibility is a core grid feature - this plugin provides:\n * - A tool panel for column visibility management (registered with the shell)\n * - Backward-compatible API methods that delegate to grid.setColumnVisible(), etc.\n *\n * The grid emits 'column-visibility' events when columns are shown/hidden,\n * allowing consumers to save user preferences.\n *\n * When a reorder plugin is present, column rows become draggable for reordering.\n * Drag-drop emits 'column-reorder-request' events that the ReorderPlugin can listen for.\n */\n\nimport { BaseGridPlugin } from '../../core/plugin/base-plugin';\nimport type { ColumnConfig, ToolPanelDefinition } from '../../core/types';\nimport type { VisibilityConfig } from './types';\n\n/**\n * Detail for column-reorder-request events emitted when users drag-drop in the visibility panel.\n */\nexport interface ColumnReorderRequestDetail {\n /** The field name of the column to move */\n field: string;\n /** The source index (before move) */\n fromIndex: number;\n /** The target index (after move) */\n toIndex: number;\n}\n\n/**\n * Check if a column can be moved (respects lockPosition/suppressMovable).\n * Inlined to avoid importing from reorder plugin.\n */\nfunction canMoveColumn(column: ColumnConfig): boolean {\n const meta = column.meta ?? {};\n return meta.lockPosition !== true && meta.suppressMovable !== true;\n}\n\n/** Extended grid interface with visibility methods */\ninterface GridWithVisibility {\n shadowRoot: ShadowRoot | null;\n getAllColumns(): Array<{ field: string; header: string; visible: boolean; lockVisible?: boolean }>;\n setColumnVisible(field: string, visible: boolean): void;\n toggleColumnVisibility(field: string): void;\n showAllColumns(): void;\n isColumnVisible(field: string): boolean;\n requestRender(): void;\n openToolPanel(id: string): void;\n closeToolPanel(): void;\n toggleToolPanel(id: string): void;\n activeToolPanel: string | undefined;\n}\n\n/**\n * Column Visibility Plugin for tbw-grid\n *\n * @example\n * ```ts\n * new VisibilityPlugin({ enabled: true, allowHideAll: false })\n * ```\n */\nexport class VisibilityPlugin extends BaseGridPlugin<VisibilityConfig> {\n readonly name = 'visibility';\n override readonly version = '1.0.0';\n\n /** Tool panel ID for shell integration */\n static readonly PANEL_ID = 'columns';\n\n protected override get defaultConfig(): Partial<VisibilityConfig> {\n return {\n enabled: true,\n allowHideAll: false,\n };\n }\n\n // ===== Internal State =====\n private columnListElement: HTMLElement | null = null;\n\n // Drag state for reorder integration\n private isDragging = false;\n private draggedField: string | null = null;\n private draggedIndex: number | null = null;\n private dropIndex: number | null = null;\n\n // ===== Lifecycle =====\n\n override detach(): void {\n this.columnListElement = null;\n this.isDragging = false;\n this.draggedField = null;\n this.draggedIndex = null;\n this.dropIndex = null;\n }\n\n // ===== Shell Integration =====\n\n /**\n * Register the column visibility tool panel with the shell.\n */\n override getToolPanel(): ToolPanelDefinition | undefined {\n if (!this.config.enabled) return undefined;\n\n return {\n id: VisibilityPlugin.PANEL_ID,\n title: 'Columns',\n icon: '☰',\n tooltip: 'Column visibility',\n order: 100, // High order so it appears last\n render: (container) => this.renderPanelContent(container),\n };\n }\n\n // ===== Public API =====\n\n /**\n * Show the visibility sidebar panel.\n */\n show(): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.openToolPanel(VisibilityPlugin.PANEL_ID);\n }\n\n /**\n * Hide the visibility sidebar panel.\n */\n hide(): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.closeToolPanel();\n }\n\n /**\n * Toggle the visibility sidebar panel.\n */\n toggle(): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.toggleToolPanel(VisibilityPlugin.PANEL_ID);\n }\n\n /**\n * Check if a specific column is visible.\n * Delegates to grid.isColumnVisible().\n * @param field - The field name to check\n * @returns True if the column is visible\n */\n isColumnVisible(field: string): boolean {\n const grid = this.grid as unknown as GridWithVisibility;\n return grid.isColumnVisible(field);\n }\n\n /**\n * Set visibility for a specific column.\n * Delegates to grid.setColumnVisible().\n * @param field - The field name of the column\n * @param visible - Whether the column should be visible\n */\n setColumnVisible(field: string, visible: boolean): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.setColumnVisible(field, visible);\n }\n\n /**\n * Get list of all visible column fields.\n * @returns Array of visible field names\n */\n getVisibleColumns(): string[] {\n const grid = this.grid as unknown as GridWithVisibility;\n return grid\n .getAllColumns()\n .filter((c) => c.visible)\n .map((c) => c.field);\n }\n\n /**\n * Get list of all hidden column fields.\n * @returns Array of hidden field names\n */\n getHiddenColumns(): string[] {\n const grid = this.grid as unknown as GridWithVisibility;\n return grid\n .getAllColumns()\n .filter((c) => !c.visible)\n .map((c) => c.field);\n }\n\n /**\n * Show all columns.\n * Delegates to grid.showAllColumns().\n */\n showAll(): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.showAllColumns();\n }\n\n /**\n * Toggle visibility for a specific column.\n * Delegates to grid.toggleColumnVisibility().\n * @param field - The field name of the column\n */\n toggleColumn(field: string): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.toggleColumnVisibility(field);\n }\n\n /**\n * Show a specific column.\n * Delegates to grid.setColumnVisible().\n * @param field - The field name of the column to show\n */\n showColumn(field: string): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.setColumnVisible(field, true);\n }\n\n /**\n * Hide a specific column.\n * Delegates to grid.setColumnVisible().\n * @param field - The field name of the column to hide\n */\n hideColumn(field: string): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.setColumnVisible(field, false);\n }\n\n /**\n * Get all columns with their visibility status.\n * Useful for building visibility UI.\n * @returns Array of column info with visibility status\n */\n getAllColumns(): Array<{ field: string; header: string; visible: boolean; lockVisible?: boolean }> {\n const grid = this.grid as unknown as GridWithVisibility;\n return grid.getAllColumns();\n }\n\n /**\n * Check if the sidebar panel is currently open.\n * @returns True if the panel is open\n */\n isPanelVisible(): boolean {\n const grid = this.grid as unknown as GridWithVisibility;\n return grid.activeToolPanel === VisibilityPlugin.PANEL_ID;\n }\n\n // ===== Private Methods =====\n\n /**\n * Render the panel content into the shell's tool panel container.\n * Returns a cleanup function.\n */\n private renderPanelContent(container: HTMLElement): (() => void) | void {\n const grid = this.grid as unknown as GridWithVisibility;\n\n // Create content wrapper\n const wrapper = document.createElement('div');\n wrapper.className = 'tbw-visibility-content';\n\n // Column list container\n const columnList = document.createElement('div');\n columnList.className = 'tbw-visibility-list';\n wrapper.appendChild(columnList);\n\n // Show all button\n const showAllBtn = document.createElement('button');\n showAllBtn.className = 'tbw-visibility-show-all';\n showAllBtn.textContent = 'Show All';\n showAllBtn.addEventListener('click', () => {\n grid.showAllColumns();\n this.rebuildToggles(columnList);\n });\n wrapper.appendChild(showAllBtn);\n\n // Store reference\n this.columnListElement = columnList;\n\n // Build initial toggles\n this.rebuildToggles(columnList);\n\n // Append to container\n container.appendChild(wrapper);\n\n // Return cleanup function\n return () => {\n this.columnListElement = null;\n wrapper.remove();\n };\n }\n\n /**\n * Check if a reorder plugin is present (by name to avoid static import).\n */\n private hasReorderPlugin(): boolean {\n const plugin = this.grid?.getPluginByName?.('reorder');\n // Duck-type check - just verify the plugin exists and has a moveColumn method\n return !!(plugin && typeof (plugin as { moveColumn?: unknown }).moveColumn === 'function');\n }\n\n /**\n * Build the column toggle checkboxes.\n * When a reorder plugin is present, adds drag handles for reordering.\n */\n private rebuildToggles(columnList: HTMLElement): void {\n const grid = this.grid as unknown as GridWithVisibility;\n const reorderEnabled = this.hasReorderPlugin();\n\n columnList.innerHTML = '';\n\n // getAllColumns() now returns columns in their effective display order\n const allColumns = grid.getAllColumns();\n\n for (let i = 0; i < allColumns.length; i++) {\n const col = allColumns[i];\n const label = col.header || col.field;\n\n const row = document.createElement('div');\n row.className = col.lockVisible ? 'tbw-visibility-row locked' : 'tbw-visibility-row';\n row.setAttribute('data-field', col.field);\n row.setAttribute('data-index', String(i));\n\n // Add drag handle if reorder is enabled\n if (reorderEnabled && canMoveColumn(col as unknown as ColumnConfig)) {\n row.draggable = true;\n row.classList.add('reorderable');\n\n this.setupDragListeners(row, col.field, i, columnList);\n }\n\n const labelWrapper = document.createElement('label');\n labelWrapper.className = 'tbw-visibility-label';\n\n const checkbox = document.createElement('input');\n checkbox.type = 'checkbox';\n checkbox.checked = col.visible;\n checkbox.disabled = col.lockVisible ?? false;\n checkbox.addEventListener('change', () => {\n grid.toggleColumnVisibility(col.field);\n // Refresh after toggle (grid may re-render)\n setTimeout(() => this.rebuildToggles(columnList), 0);\n });\n\n const text = document.createElement('span');\n text.textContent = label;\n\n labelWrapper.appendChild(checkbox);\n labelWrapper.appendChild(text);\n\n // Add drag handle icon if reorderable\n if (reorderEnabled && canMoveColumn(col as unknown as ColumnConfig)) {\n const handle = document.createElement('span');\n handle.className = 'tbw-visibility-handle';\n handle.textContent = '⋮⋮';\n handle.title = 'Drag to reorder';\n row.appendChild(handle);\n }\n\n row.appendChild(labelWrapper);\n columnList.appendChild(row);\n }\n }\n\n /**\n * Set up drag-and-drop event listeners for a row.\n * On drop, emits a 'column-reorder-request' event for other plugins to handle.\n */\n private setupDragListeners(row: HTMLElement, field: string, index: number, columnList: HTMLElement): void {\n row.addEventListener('dragstart', (e: DragEvent) => {\n this.isDragging = true;\n this.draggedField = field;\n this.draggedIndex = index;\n\n if (e.dataTransfer) {\n e.dataTransfer.effectAllowed = 'move';\n e.dataTransfer.setData('text/plain', field);\n }\n\n row.classList.add('dragging');\n });\n\n row.addEventListener('dragend', () => {\n this.isDragging = false;\n this.draggedField = null;\n this.draggedIndex = null;\n this.dropIndex = null;\n\n columnList.querySelectorAll('.tbw-visibility-row').forEach((r) => {\n r.classList.remove('dragging', 'drop-target', 'drop-before', 'drop-after');\n });\n });\n\n row.addEventListener('dragover', (e: DragEvent) => {\n e.preventDefault();\n if (!this.isDragging || this.draggedField === field) return;\n\n const rect = row.getBoundingClientRect();\n const midY = rect.top + rect.height / 2;\n\n this.dropIndex = e.clientY < midY ? index : index + 1;\n\n // Clear other row highlights\n columnList.querySelectorAll('.tbw-visibility-row').forEach((r) => {\n if (r !== row) r.classList.remove('drop-target', 'drop-before', 'drop-after');\n });\n\n row.classList.add('drop-target');\n row.classList.toggle('drop-before', e.clientY < midY);\n row.classList.toggle('drop-after', e.clientY >= midY);\n });\n\n row.addEventListener('dragleave', () => {\n row.classList.remove('drop-target', 'drop-before', 'drop-after');\n });\n\n row.addEventListener('drop', (e: DragEvent) => {\n e.preventDefault();\n const draggedField = this.draggedField;\n const draggedIndex = this.draggedIndex;\n const dropIndex = this.dropIndex;\n\n if (!this.isDragging || draggedField === null || draggedIndex === null || dropIndex === null) {\n return;\n }\n\n // Calculate the effective target index\n const effectiveToIndex = dropIndex > draggedIndex ? dropIndex - 1 : dropIndex;\n\n if (effectiveToIndex !== draggedIndex) {\n // Emit a request event - other plugins (like ReorderPlugin) can listen and handle\n const detail: ColumnReorderRequestDetail = {\n field: draggedField,\n fromIndex: draggedIndex,\n toIndex: effectiveToIndex,\n };\n this.emit<ColumnReorderRequestDetail>('column-reorder-request', detail);\n\n // Rebuild the panel after reorder (deferred to allow re-render)\n setTimeout(() => {\n this.rebuildToggles(columnList);\n }, 0);\n }\n });\n }\n\n // ===== Styles =====\n\n override readonly styles = `\n .tbw-visibility-content {\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n\n .tbw-visibility-list {\n flex: 1;\n overflow-y: auto;\n padding: 8px;\n }\n\n .tbw-visibility-row {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 4px;\n cursor: pointer;\n font-size: 13px;\n border-radius: var(--tbw-border-radius, 4px);\n position: relative;\n }\n .tbw-visibility-row:hover {\n background: var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6));\n }\n .tbw-visibility-row input[type=\"checkbox\"] {\n cursor: pointer;\n }\n .tbw-visibility-row.locked span {\n color: var(--tbw-color-fg-muted, #888);\n }\n\n /* Drag handle */\n .tbw-visibility-handle {\n cursor: grab;\n color: var(--tbw-color-fg-muted, #888);\n font-size: 10px;\n letter-spacing: -2px;\n user-select: none;\n flex-shrink: 0;\n }\n .tbw-visibility-row.reorderable:hover .tbw-visibility-handle {\n color: var(--tbw-color-fg, #1f2937);\n }\n\n /* Label wrapper for checkbox and text */\n .tbw-visibility-label {\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n cursor: pointer;\n }\n\n /* Drag states */\n .tbw-visibility-row.dragging {\n opacity: 0.5;\n cursor: grabbing;\n }\n .tbw-visibility-row.drop-before::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n height: 2px;\n background: var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6));\n }\n .tbw-visibility-row.drop-after::after {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n height: 2px;\n background: var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6));\n }\n\n .tbw-visibility-show-all {\n margin: 8px;\n padding: 8px 12px;\n border: 1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));\n border-radius: var(--tbw-border-radius, 4px);\n background: var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));\n color: var(--tbw-color-fg, #1f2937);\n cursor: pointer;\n font-size: 13px;\n }\n .tbw-visibility-show-all:hover {\n background: var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6));\n }\n `;\n}\n"],"names":["canMoveColumn","column","meta","VisibilityPlugin","BaseGridPlugin","container","field","visible","c","grid","wrapper","columnList","showAllBtn","plugin","reorderEnabled","allColumns","col","label","row","labelWrapper","checkbox","text","handle","index","e","r","rect","midY","draggedField","draggedIndex","dropIndex","effectiveToIndex","detail"],"mappings":"sUAmCA,SAASA,EAAcC,EAA+B,CACpD,MAAMC,EAAOD,EAAO,MAAQ,CAAA,EAC5B,OAAOC,EAAK,eAAiB,IAAQA,EAAK,kBAAoB,EAChE,CAyBO,MAAMC,UAAyBC,EAAAA,cAAiC,CAC5D,KAAO,aACE,QAAU,QAG5B,OAAgB,SAAW,UAE3B,IAAuB,eAA2C,CAChE,MAAO,CACL,QAAS,GACT,aAAc,EAAA,CAElB,CAGQ,kBAAwC,KAGxC,WAAa,GACb,aAA8B,KAC9B,aAA8B,KAC9B,UAA2B,KAI1B,QAAe,CACtB,KAAK,kBAAoB,KACzB,KAAK,WAAa,GAClB,KAAK,aAAe,KACpB,KAAK,aAAe,KACpB,KAAK,UAAY,IACnB,CAOS,cAAgD,CACvD,GAAK,KAAK,OAAO,QAEjB,MAAO,CACL,GAAID,EAAiB,SACrB,MAAO,UACP,KAAM,IACN,QAAS,oBACT,MAAO,IACP,OAASE,GAAc,KAAK,mBAAmBA,CAAS,CAAA,CAE5D,CAOA,MAAa,CACE,KAAK,KACb,cAAcF,EAAiB,QAAQ,CAC9C,CAKA,MAAa,CACE,KAAK,KACb,eAAA,CACP,CAKA,QAAe,CACA,KAAK,KACb,gBAAgBA,EAAiB,QAAQ,CAChD,CAQA,gBAAgBG,EAAwB,CAEtC,OADa,KAAK,KACN,gBAAgBA,CAAK,CACnC,CAQA,iBAAiBA,EAAeC,EAAwB,CACzC,KAAK,KACb,iBAAiBD,EAAOC,CAAO,CACtC,CAMA,mBAA8B,CAE5B,OADa,KAAK,KAEf,cAAA,EACA,OAAQC,GAAMA,EAAE,OAAO,EACvB,IAAKA,GAAMA,EAAE,KA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G,EAAqC,CACzC,MAAOJ,EACP,UAAWC,EACX,QAASE,CAAA,EAEX,KAAK,KAAiC,yBAA0BC,CAAM,EAGtE,WAAW,IAAM,CACf,KAAK,eAAerB,CAAU,CAChC,EAAG,CAAC,CACN,CACF,CAAC,CACH,CAIkB,OAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GA6F7B"}
|
|
1
|
+
{"version":3,"file":"visibility.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/visibility/VisibilityPlugin.ts"],"sourcesContent":["/**\n * Column Visibility Plugin (Class-based)\n *\n * Provides a UI for column visibility control via the shell's tool panel system.\n * Column visibility is a core grid feature - this plugin provides:\n * - A tool panel for column visibility management (registered with the shell)\n * - Backward-compatible API methods that delegate to grid.setColumnVisible(), etc.\n *\n * The grid emits 'column-visibility' events when columns are shown/hidden,\n * allowing consumers to save user preferences.\n *\n * When a reorder plugin is present, column rows become draggable for reordering.\n * Drag-drop emits 'column-reorder-request' events that the ReorderPlugin can listen for.\n */\n\nimport { BaseGridPlugin } from '../../core/plugin/base-plugin';\nimport type { ColumnConfig, ToolPanelDefinition } from '../../core/types';\nimport type { VisibilityConfig } from './types';\n\n/**\n * Detail for column-reorder-request events emitted when users drag-drop in the visibility panel.\n */\nexport interface ColumnReorderRequestDetail {\n /** The field name of the column to move */\n field: string;\n /** The source index (before move) */\n fromIndex: number;\n /** The target index (after move) */\n toIndex: number;\n}\n\n/**\n * Check if a column can be moved (respects lockPosition/suppressMovable).\n * Inlined to avoid importing from reorder plugin.\n */\nfunction canMoveColumn(column: ColumnConfig): boolean {\n const meta = column.meta ?? {};\n return meta.lockPosition !== true && meta.suppressMovable !== true;\n}\n\n/** Extended grid interface with visibility methods */\ninterface GridWithVisibility {\n shadowRoot: ShadowRoot | null;\n getAllColumns(): Array<{ field: string; header: string; visible: boolean; lockVisible?: boolean }>;\n setColumnVisible(field: string, visible: boolean): void;\n toggleColumnVisibility(field: string): void;\n showAllColumns(): void;\n isColumnVisible(field: string): boolean;\n requestRender(): void;\n openToolPanel(id: string): void;\n closeToolPanel(): void;\n toggleToolPanel(id: string): void;\n activeToolPanel: string | undefined;\n}\n\n/**\n * Column Visibility Plugin for tbw-grid\n *\n * @example\n * ```ts\n * new VisibilityPlugin({ enabled: true, allowHideAll: false })\n * ```\n */\nexport class VisibilityPlugin extends BaseGridPlugin<VisibilityConfig> {\n readonly name = 'visibility';\n override readonly version = '1.0.0';\n\n /** Tool panel ID for shell integration */\n static readonly PANEL_ID = 'columns';\n\n protected override get defaultConfig(): Partial<VisibilityConfig> {\n return {\n enabled: true,\n allowHideAll: false,\n };\n }\n\n // ===== Internal State =====\n private columnListElement: HTMLElement | null = null;\n\n // Drag state for reorder integration\n private isDragging = false;\n private draggedField: string | null = null;\n private draggedIndex: number | null = null;\n private dropIndex: number | null = null;\n\n // ===== Lifecycle =====\n\n override detach(): void {\n this.columnListElement = null;\n this.isDragging = false;\n this.draggedField = null;\n this.draggedIndex = null;\n this.dropIndex = null;\n }\n\n // ===== Shell Integration =====\n\n /**\n * Register the column visibility tool panel with the shell.\n */\n override getToolPanel(): ToolPanelDefinition | undefined {\n if (!this.config.enabled) return undefined;\n\n return {\n id: VisibilityPlugin.PANEL_ID,\n title: 'Columns',\n icon: '☰',\n tooltip: 'Column visibility',\n order: 100, // High order so it appears last\n render: (container) => this.renderPanelContent(container),\n };\n }\n\n // ===== Public API =====\n\n /**\n * Show the visibility sidebar panel.\n */\n show(): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.openToolPanel(VisibilityPlugin.PANEL_ID);\n }\n\n /**\n * Hide the visibility sidebar panel.\n */\n hide(): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.closeToolPanel();\n }\n\n /**\n * Toggle the visibility sidebar panel.\n */\n toggle(): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.toggleToolPanel(VisibilityPlugin.PANEL_ID);\n }\n\n /**\n * Check if a specific column is visible.\n * Delegates to grid.isColumnVisible().\n * @param field - The field name to check\n * @returns True if the column is visible\n */\n isColumnVisible(field: string): boolean {\n const grid = this.grid as unknown as GridWithVisibility;\n return grid.isColumnVisible(field);\n }\n\n /**\n * Set visibility for a specific column.\n * Delegates to grid.setColumnVisible().\n * @param field - The field name of the column\n * @param visible - Whether the column should be visible\n */\n setColumnVisible(field: string, visible: boolean): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.setColumnVisible(field, visible);\n }\n\n /**\n * Get list of all visible column fields.\n * @returns Array of visible field names\n */\n getVisibleColumns(): string[] {\n const grid = this.grid as unknown as GridWithVisibility;\n return grid\n .getAllColumns()\n .filter((c) => c.visible)\n .map((c) => c.field);\n }\n\n /**\n * Get list of all hidden column fields.\n * @returns Array of hidden field names\n */\n getHiddenColumns(): string[] {\n const grid = this.grid as unknown as GridWithVisibility;\n return grid\n .getAllColumns()\n .filter((c) => !c.visible)\n .map((c) => c.field);\n }\n\n /**\n * Show all columns.\n * Delegates to grid.showAllColumns().\n */\n showAll(): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.showAllColumns();\n }\n\n /**\n * Toggle visibility for a specific column.\n * Delegates to grid.toggleColumnVisibility().\n * @param field - The field name of the column\n */\n toggleColumn(field: string): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.toggleColumnVisibility(field);\n }\n\n /**\n * Show a specific column.\n * Delegates to grid.setColumnVisible().\n * @param field - The field name of the column to show\n */\n showColumn(field: string): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.setColumnVisible(field, true);\n }\n\n /**\n * Hide a specific column.\n * Delegates to grid.setColumnVisible().\n * @param field - The field name of the column to hide\n */\n hideColumn(field: string): void {\n const grid = this.grid as unknown as GridWithVisibility;\n grid.setColumnVisible(field, false);\n }\n\n /**\n * Get all columns with their visibility status.\n * Useful for building visibility UI.\n * @returns Array of column info with visibility status\n */\n getAllColumns(): Array<{ field: string; header: string; visible: boolean; lockVisible?: boolean }> {\n const grid = this.grid as unknown as GridWithVisibility;\n return grid.getAllColumns();\n }\n\n /**\n * Check if the sidebar panel is currently open.\n * @returns True if the panel is open\n */\n isPanelVisible(): boolean {\n const grid = this.grid as unknown as GridWithVisibility;\n return grid.activeToolPanel === VisibilityPlugin.PANEL_ID;\n }\n\n // ===== Private Methods =====\n\n /**\n * Render the panel content into the shell's tool panel container.\n * Returns a cleanup function.\n */\n private renderPanelContent(container: HTMLElement): (() => void) | void {\n const grid = this.grid as unknown as GridWithVisibility;\n\n // Create content wrapper\n const wrapper = document.createElement('div');\n wrapper.className = 'tbw-visibility-content';\n\n // Column list container\n const columnList = document.createElement('div');\n columnList.className = 'tbw-visibility-list';\n wrapper.appendChild(columnList);\n\n // Show all button\n const showAllBtn = document.createElement('button');\n showAllBtn.className = 'tbw-visibility-show-all';\n showAllBtn.textContent = 'Show All';\n showAllBtn.addEventListener('click', () => {\n grid.showAllColumns();\n this.rebuildToggles(columnList);\n });\n wrapper.appendChild(showAllBtn);\n\n // Store reference\n this.columnListElement = columnList;\n\n // Build initial toggles\n this.rebuildToggles(columnList);\n\n // Append to container\n container.appendChild(wrapper);\n\n // Return cleanup function\n return () => {\n this.columnListElement = null;\n wrapper.remove();\n };\n }\n\n /**\n * Check if a reorder plugin is present (by name to avoid static import).\n */\n private hasReorderPlugin(): boolean {\n const plugin = this.grid?.getPluginByName?.('reorder');\n // Duck-type check - just verify the plugin exists and has a moveColumn method\n return !!(plugin && typeof (plugin as { moveColumn?: unknown }).moveColumn === 'function');\n }\n\n /**\n * Build the column toggle checkboxes.\n * When a reorder plugin is present, adds drag handles for reordering.\n */\n private rebuildToggles(columnList: HTMLElement): void {\n const grid = this.grid as unknown as GridWithVisibility;\n const reorderEnabled = this.hasReorderPlugin();\n\n columnList.innerHTML = '';\n\n // getAllColumns() now returns columns in their effective display order\n const allColumns = grid.getAllColumns();\n\n for (let i = 0; i < allColumns.length; i++) {\n const col = allColumns[i];\n const label = col.header || col.field;\n\n const row = document.createElement('div');\n row.className = col.lockVisible ? 'tbw-visibility-row locked' : 'tbw-visibility-row';\n row.setAttribute('data-field', col.field);\n row.setAttribute('data-index', String(i));\n\n // Add drag handle if reorder is enabled\n if (reorderEnabled && canMoveColumn(col as unknown as ColumnConfig)) {\n row.draggable = true;\n row.classList.add('reorderable');\n\n this.setupDragListeners(row, col.field, i, columnList);\n }\n\n const labelWrapper = document.createElement('label');\n labelWrapper.className = 'tbw-visibility-label';\n\n const checkbox = document.createElement('input');\n checkbox.type = 'checkbox';\n checkbox.checked = col.visible;\n checkbox.disabled = col.lockVisible ?? false;\n checkbox.addEventListener('change', () => {\n grid.toggleColumnVisibility(col.field);\n // Refresh after toggle (grid may re-render)\n setTimeout(() => this.rebuildToggles(columnList), 0);\n });\n\n const text = document.createElement('span');\n text.textContent = label;\n\n labelWrapper.appendChild(checkbox);\n labelWrapper.appendChild(text);\n\n // Add drag handle icon if reorderable\n if (reorderEnabled && canMoveColumn(col as unknown as ColumnConfig)) {\n const handle = document.createElement('span');\n handle.className = 'tbw-visibility-handle';\n // Use grid-level icons (fall back to defaults)\n this.setIcon(handle, this.resolveIcon('dragHandle'));\n handle.title = 'Drag to reorder';\n row.appendChild(handle);\n }\n\n row.appendChild(labelWrapper);\n columnList.appendChild(row);\n }\n }\n\n /**\n * Set up drag-and-drop event listeners for a row.\n * On drop, emits a 'column-reorder-request' event for other plugins to handle.\n */\n private setupDragListeners(row: HTMLElement, field: string, index: number, columnList: HTMLElement): void {\n row.addEventListener('dragstart', (e: DragEvent) => {\n this.isDragging = true;\n this.draggedField = field;\n this.draggedIndex = index;\n\n if (e.dataTransfer) {\n e.dataTransfer.effectAllowed = 'move';\n e.dataTransfer.setData('text/plain', field);\n }\n\n row.classList.add('dragging');\n });\n\n row.addEventListener('dragend', () => {\n this.isDragging = false;\n this.draggedField = null;\n this.draggedIndex = null;\n this.dropIndex = null;\n\n columnList.querySelectorAll('.tbw-visibility-row').forEach((r) => {\n r.classList.remove('dragging', 'drop-target', 'drop-before', 'drop-after');\n });\n });\n\n row.addEventListener('dragover', (e: DragEvent) => {\n e.preventDefault();\n if (!this.isDragging || this.draggedField === field) return;\n\n const rect = row.getBoundingClientRect();\n const midY = rect.top + rect.height / 2;\n\n this.dropIndex = e.clientY < midY ? index : index + 1;\n\n // Clear other row highlights\n columnList.querySelectorAll('.tbw-visibility-row').forEach((r) => {\n if (r !== row) r.classList.remove('drop-target', 'drop-before', 'drop-after');\n });\n\n row.classList.add('drop-target');\n row.classList.toggle('drop-before', e.clientY < midY);\n row.classList.toggle('drop-after', e.clientY >= midY);\n });\n\n row.addEventListener('dragleave', () => {\n row.classList.remove('drop-target', 'drop-before', 'drop-after');\n });\n\n row.addEventListener('drop', (e: DragEvent) => {\n e.preventDefault();\n const draggedField = this.draggedField;\n const draggedIndex = this.draggedIndex;\n const dropIndex = this.dropIndex;\n\n if (!this.isDragging || draggedField === null || draggedIndex === null || dropIndex === null) {\n return;\n }\n\n // Calculate the effective target index\n const effectiveToIndex = dropIndex > draggedIndex ? dropIndex - 1 : dropIndex;\n\n if (effectiveToIndex !== draggedIndex) {\n // Emit a request event - other plugins (like ReorderPlugin) can listen and handle\n const detail: ColumnReorderRequestDetail = {\n field: draggedField,\n fromIndex: draggedIndex,\n toIndex: effectiveToIndex,\n };\n this.emit<ColumnReorderRequestDetail>('column-reorder-request', detail);\n\n // Rebuild the panel after reorder (deferred to allow re-render)\n setTimeout(() => {\n this.rebuildToggles(columnList);\n }, 0);\n }\n });\n }\n\n // ===== Styles =====\n\n override readonly styles = `\n .tbw-visibility-content {\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n\n .tbw-visibility-list {\n flex: 1;\n overflow-y: auto;\n padding: 8px;\n }\n\n .tbw-visibility-row {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 4px;\n cursor: pointer;\n font-size: 13px;\n border-radius: var(--tbw-border-radius, 4px);\n position: relative;\n }\n .tbw-visibility-row:hover {\n background: var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6));\n }\n .tbw-visibility-row input[type=\"checkbox\"] {\n cursor: pointer;\n }\n .tbw-visibility-row.locked span {\n color: var(--tbw-color-fg-muted, #888);\n }\n\n /* Drag handle */\n .tbw-visibility-handle {\n cursor: grab;\n color: var(--tbw-color-fg-muted, #888);\n font-size: 10px;\n letter-spacing: -2px;\n user-select: none;\n flex-shrink: 0;\n }\n .tbw-visibility-row.reorderable:hover .tbw-visibility-handle {\n color: var(--tbw-color-fg, #1f2937);\n }\n\n /* Label wrapper for checkbox and text */\n .tbw-visibility-label {\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n cursor: pointer;\n }\n\n /* Drag states */\n .tbw-visibility-row.dragging {\n opacity: 0.5;\n cursor: grabbing;\n }\n .tbw-visibility-row.drop-before::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n height: 2px;\n background: var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6));\n }\n .tbw-visibility-row.drop-after::after {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n height: 2px;\n background: var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6));\n }\n\n .tbw-visibility-show-all {\n margin: 8px;\n padding: 8px 12px;\n border: 1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));\n border-radius: var(--tbw-border-radius, 4px);\n background: var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));\n color: var(--tbw-color-fg, #1f2937);\n cursor: pointer;\n font-size: 13px;\n }\n .tbw-visibility-show-all:hover {\n background: var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6));\n }\n `;\n}\n"],"names":["canMoveColumn","column","meta","VisibilityPlugin","BaseGridPlugin","container","field","visible","c","grid","wrapper","columnList","showAllBtn","plugin","reorderEnabled","allColumns","col","label","row","labelWrapper","checkbox","text","handle","index","e","r","rect","midY","draggedField","draggedIndex","dropIndex","effectiveToIndex","detail"],"mappings":"sUAmCA,SAASA,EAAcC,EAA+B,CACpD,MAAMC,EAAOD,EAAO,MAAQ,CAAA,EAC5B,OAAOC,EAAK,eAAiB,IAAQA,EAAK,kBAAoB,EAChE,CAyBO,MAAMC,UAAyBC,EAAAA,cAAiC,CAC5D,KAAO,aACE,QAAU,QAG5B,OAAgB,SAAW,UAE3B,IAAuB,eAA2C,CAChE,MAAO,CACL,QAAS,GACT,aAAc,EAAA,CAElB,CAGQ,kBAAwC,KAGxC,WAAa,GACb,aAA8B,KAC9B,aAA8B,KAC9B,UAA2B,KAI1B,QAAe,CACtB,KAAK,kBAAoB,KACzB,KAAK,WAAa,GAClB,KAAK,aAAe,KACpB,KAAK,aAAe,KACpB,KAAK,UAAY,IACnB,CAOS,cAAgD,CACvD,GAAK,KAAK,OAAO,QAEjB,MAAO,CACL,GAAID,EAAiB,SACrB,MAAO,UACP,KAAM,IACN,QAAS,oBACT,MAAO,IACP,OAASE,GAAc,KAAK,mBAAmBA,CAAS,CAAA,CAE5D,CAOA,MAAa,CACE,KAAK,KACb,cAAcF,EAAiB,QAAQ,CAC9C,CAKA,MAAa,CACE,KAAK,KACb,eAAA,CACP,CAKA,QAAe,CACA,KAAK,KACb,gBAAgBA,EAAiB,QAAQ,CAChD,CAQ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