@toolbox-web/grid 0.0.7 → 0.1.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.
Files changed (86) hide show
  1. package/all.d.ts +151 -95
  2. package/all.js +1554 -1452
  3. package/all.js.map +1 -1
  4. package/custom-elements.json +89 -7
  5. package/index.d.ts +68 -23
  6. package/index.js +1066 -948
  7. package/index.js.map +1 -1
  8. package/lib/plugins/clipboard/index.js +48 -49
  9. package/lib/plugins/clipboard/index.js.map +1 -1
  10. package/lib/plugins/column-virtualization/index.js +6 -6
  11. package/lib/plugins/column-virtualization/index.js.map +1 -1
  12. package/lib/plugins/context-menu/index.js +32 -34
  13. package/lib/plugins/context-menu/index.js.map +1 -1
  14. package/lib/plugins/export/index.js +7 -7
  15. package/lib/plugins/export/index.js.map +1 -1
  16. package/lib/plugins/filtering/index.js +5 -38
  17. package/lib/plugins/filtering/index.js.map +1 -1
  18. package/lib/plugins/grouping-columns/index.js +4 -32
  19. package/lib/plugins/grouping-columns/index.js.map +1 -1
  20. package/lib/plugins/grouping-rows/index.js +8 -45
  21. package/lib/plugins/grouping-rows/index.js.map +1 -1
  22. package/lib/plugins/master-detail/index.js +6 -30
  23. package/lib/plugins/master-detail/index.js.map +1 -1
  24. package/lib/plugins/multi-sort/index.js +19 -42
  25. package/lib/plugins/multi-sort/index.js.map +1 -1
  26. package/lib/plugins/pinned-columns/index.js +5 -6
  27. package/lib/plugins/pinned-columns/index.js.map +1 -1
  28. package/lib/plugins/pinned-rows/index.js +6 -80
  29. package/lib/plugins/pinned-rows/index.js.map +1 -1
  30. package/lib/plugins/pivot/index.js +673 -145
  31. package/lib/plugins/pivot/index.js.map +1 -1
  32. package/lib/plugins/reorder/index.js +22 -51
  33. package/lib/plugins/reorder/index.js.map +1 -1
  34. package/lib/plugins/selection/index.js +53 -83
  35. package/lib/plugins/selection/index.js.map +1 -1
  36. package/lib/plugins/server-side/index.js +2 -2
  37. package/lib/plugins/server-side/index.js.map +1 -1
  38. package/lib/plugins/tree/index.js +6 -14
  39. package/lib/plugins/tree/index.js.map +1 -1
  40. package/lib/plugins/undo-redo/index.js +2 -3
  41. package/lib/plugins/undo-redo/index.js.map +1 -1
  42. package/lib/plugins/visibility/index.js +13 -105
  43. package/lib/plugins/visibility/index.js.map +1 -1
  44. package/package.json +1 -1
  45. package/themes/dg-theme-bootstrap.css +73 -0
  46. package/themes/dg-theme-material.css +71 -0
  47. package/umd/grid.all.umd.js +40 -415
  48. package/umd/grid.all.umd.js.map +1 -1
  49. package/umd/grid.umd.js +29 -60
  50. package/umd/grid.umd.js.map +1 -1
  51. package/umd/plugins/clipboard.umd.js +4 -4
  52. package/umd/plugins/clipboard.umd.js.map +1 -1
  53. package/umd/plugins/column-virtualization.umd.js +1 -1
  54. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  55. package/umd/plugins/context-menu.umd.js +2 -2
  56. package/umd/plugins/context-menu.umd.js.map +1 -1
  57. package/umd/plugins/export.umd.js +1 -1
  58. package/umd/plugins/export.umd.js.map +1 -1
  59. package/umd/plugins/filtering.umd.js +2 -34
  60. package/umd/plugins/filtering.umd.js.map +1 -1
  61. package/umd/plugins/grouping-columns.umd.js +1 -28
  62. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  63. package/umd/plugins/grouping-rows.umd.js +1 -39
  64. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  65. package/umd/plugins/master-detail.umd.js +1 -26
  66. package/umd/plugins/master-detail.umd.js.map +1 -1
  67. package/umd/plugins/multi-sort.umd.js +1 -25
  68. package/umd/plugins/multi-sort.umd.js.map +1 -1
  69. package/umd/plugins/pinned-columns.umd.js +1 -1
  70. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  71. package/umd/plugins/pinned-rows.umd.js +1 -72
  72. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  73. package/umd/plugins/pivot.umd.js +1 -7
  74. package/umd/plugins/pivot.umd.js.map +1 -1
  75. package/umd/plugins/reorder.umd.js +1 -30
  76. package/umd/plugins/reorder.umd.js.map +1 -1
  77. package/umd/plugins/selection.umd.js +1 -33
  78. package/umd/plugins/selection.umd.js.map +1 -1
  79. package/umd/plugins/server-side.umd.js +1 -1
  80. package/umd/plugins/server-side.umd.js.map +1 -1
  81. package/umd/plugins/tree.umd.js +1 -10
  82. package/umd/plugins/tree.umd.js.map +1 -1
  83. package/umd/plugins/undo-redo.umd.js +1 -1
  84. package/umd/plugins/undo-redo.umd.js.map +1 -1
  85. package/umd/plugins/visibility.umd.js +1 -93
  86. package/umd/plugins/visibility.umd.js.map +1 -1
package/index.js CHANGED
@@ -1,45 +1,45 @@
1
- const we = ":root{color-scheme:light dark}:host{--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #adacac);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: 2px 8px;--tbw-cell-padding: 2px 8px;--tbw-cell-padding-input: 2px 6px;--tbw-row-height: 28px;--tbw-header-height: 30px;--tbw-border-radius: 4px;--tbw-border-input: 1px solid var(--tbw-color-border-strong);--tbw-border-header: 1px solid var(--tbw-color-border-header);--tbw-row-divider: 1px solid var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline: 2px solid var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: 4px;--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-scrollbar-thumb: var(--tbw-color-border-strong);--tbw-scrollbar-track: var(--tbw-color-bg);--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-checkbox-size: 16px;--tbw-density-scale: 1}:host{position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none}:host,:host *{box-sizing:border-box}:host .header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}:host .header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}:host .header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start))}:host .header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30)}:host .header-row>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}:host .header-row>.cell>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .header-row>.cell>span[part~=sort-indicator]{flex-shrink:0}:host .header-row>.cell:last-child{border-right:0}:host .header-group-cell,:host .header-row>.cell.grouped.group-end{border-right:2px solid var(--tbw-color-border)}:host .tbw-grid-root{display:flex;flex-direction:column;height:100%}:host .rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}:host .rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}:host .rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}:host .rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip}:host .faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30)}:host .faux-vscroll-spacer{width:1px}:host .rows-viewport .rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}:host .data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style}:host .data-grid-row:has(.editing){background:var(--tbw-editing-bg)}:host .selecting .data-grid-row>.cell{user-select:none}:host .data-grid-row>.cell:focus-visible{outline:none}:host .data-grid-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}:host .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .data-grid-row>.cell:last-child{border-right:0}:host .data-grid-row>.cell[data-type=boolean]{justify-content:center}:host .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size)}:host .data-grid-row>.cell.editing{overflow:hidden;padding:0}:host .data-grid-row>.cell.editing input:not([type=checkbox]),:host .data-grid-row>.cell.editing select,:host .data-grid-row>.cell.editing textarea{width:100%;height:100%;max-width:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}:host .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}:host .data-grid-row:hover{background:var(--tbw-color-row-hover)}:host .sortable{cursor:pointer;user-select:none}:host .resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}:host .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}:host .cell-focus,:host .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-row-alt);font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}:host .group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px)}:host .group-row .group-toggle{background:none;border:0;cursor:pointer;padding:0 4px 0 0;font:inherit}:host .group-row .group-count{margin-left:4px;opacity:.7}:host .sticky-left,:host .sticky-right{position:sticky;z-index:25}:host .header-row>.cell.sticky-left,:host .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}:host .data-grid-row>.cell.sticky-left,:host .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}:host .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}:host .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}.grid-container{position:relative;width:100%;height:100%}.grid-placeholder{padding:2rem;text-align:center;color:var(--tbw-color-fg);opacity:.6}:host{--tbw-shell-header-height: 44px;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: 14px;--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 280px;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 40px;--tbw-tool-panel-transition: .2s ease-out;--tbw-toolbar-button-size: 32px;--tbw-toolbar-button-gap: 4px}:host .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}:host .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}:host .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}:host .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}:host .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}:host .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}:host .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}:host .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}:host .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}:host .tbw-shell-body{display:flex;flex:1;min-height:0;overflow:visible}:host .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}:host .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden}:host .tbw-tool-panel{width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;flex-shrink:0}:host .tbw-tool-panel[data-position=left]{border-left:none;border-right:1px solid var(--tbw-tool-panel-border);order:-1}:host .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}:host .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}:host .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}:host .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}:host .tbw-tool-panel-content{flex:1;overflow:auto;padding:12px}:host .tbw-quick-filter-input{flex:1;max-width:300px;height:28px;padding:0 8px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:13px}:host .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}:host .tbw-selection-summary{font-size:13px;color:var(--tbw-color-fg-muted);white-space:nowrap}";
2
- function be(o) {
1
+ const me = ":root{color-scheme:light dark}:host{--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #adacac);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: 2px 8px;--tbw-cell-padding: 2px 8px;--tbw-cell-padding-input: 2px 6px;--tbw-row-height: 28px;--tbw-header-height: 30px;--tbw-border-radius: 4px;--tbw-border-input: 1px solid var(--tbw-color-border-strong);--tbw-border-header: 1px solid var(--tbw-color-border-header);--tbw-row-divider: 1px solid var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline: 2px solid var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: 4px;--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-scrollbar-thumb: var(--tbw-color-border-strong);--tbw-scrollbar-track: var(--tbw-color-bg);--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-checkbox-size: 16px;--tbw-density-scale: 1}:host{position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none}:host,:host *{box-sizing:border-box}:host .header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}:host .header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}:host .header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start))}:host .header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30)}:host .header-row>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}:host .header-row>.cell>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .header-row>.cell>span[part~=sort-indicator]{flex-shrink:0}:host .header-row>.cell:last-child{border-right:0}:host .header-group-cell,:host .header-row>.cell.grouped.group-end{border-right:2px solid var(--tbw-color-border)}:host .tbw-grid-root{display:flex;flex-direction:column;height:100%}:host .rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}:host .rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}:host .rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}:host .rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip}:host .faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30)}:host .faux-vscroll-spacer{width:1px}:host .rows-viewport .rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}:host .data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style}:host .data-grid-row:has(.editing){background:var(--tbw-editing-bg)}:host .selecting .data-grid-row>.cell{user-select:none}:host .data-grid-row>.cell:focus-visible{outline:none}:host .data-grid-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}:host .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .data-grid-row>.cell:last-child{border-right:0}:host .data-grid-row>.cell[data-type=boolean]{justify-content:center}:host .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size)}:host .data-grid-row>.cell.editing{overflow:hidden;padding:0}:host .data-grid-row>.cell.editing input:not([type=checkbox]),:host .data-grid-row>.cell.editing select,:host .data-grid-row>.cell.editing textarea{width:100%;height:100%;max-width:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}:host .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}:host .data-grid-row:hover{background:var(--tbw-color-row-hover)}:host .sortable{cursor:pointer;user-select:none}:host .resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}:host .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}:host .cell-focus,:host .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-row-alt);font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}:host .group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px)}:host .group-row .group-toggle{background:none;border:0;cursor:pointer;padding:0 4px 0 0;font:inherit}:host .group-row .group-count{margin-left:4px;opacity:.7}:host .sticky-left,:host .sticky-right{position:sticky;z-index:25}:host .header-row>.cell.sticky-left,:host .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}:host .data-grid-row>.cell.sticky-left,:host .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}:host .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}:host .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}.grid-container{position:relative;width:100%;height:100%}.grid-placeholder{padding:2rem;text-align:center;color:var(--tbw-color-fg);opacity:.6}:host{--tbw-shell-header-height: 44px;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: 14px;--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 280px;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 40px;--tbw-tool-panel-transition: .2s ease-out;--tbw-toolbar-button-size: 32px;--tbw-toolbar-button-gap: 4px}:host .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}:host .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}:host .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}:host .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}:host .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}:host .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}:host .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}:host .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}:host .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}:host .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}:host .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}:host .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden}:host .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}:host .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background .15s ease}:host .tbw-tool-panel-resize[data-handle-position=left]{left:0}:host .tbw-tool-panel-resize[data-handle-position=right]{right:0}:host .tbw-tool-panel-resize:hover,:host .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}:host .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}:host .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}:host .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}:host .tbw-tool-panel-content{flex:1;overflow:auto}:host .tbw-accordion{display:flex;flex-direction:column;gap:0}:host .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}:host .tbw-accordion-section:last-child{border-bottom:none}:host .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:left;cursor:pointer;user-select:none}:host .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}:host .tbw-accordion-section.single .tbw-accordion-header{cursor:default}:host .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}:host .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}:host .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}:host .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}:host .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .tbw-accordion-content{display:none}:host .tbw-accordion-section.expanded .tbw-accordion-content{display:block}:host .tbw-quick-filter-input{flex:1;max-width:300px;height:28px;padding:0 8px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:13px}:host .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}:host .tbw-selection-summary{font-size:13px;color:var(--tbw-color-fg-muted);white-space:nowrap}";
2
+ function ve(o) {
3
3
  const e = /* @__PURE__ */ new Map();
4
4
  return o.sortState && e.set(o.sortState.field, {
5
5
  direction: o.sortState.direction === 1 ? "asc" : "desc",
6
6
  priority: 0
7
7
  }), e;
8
8
  }
9
- function ae(o, e) {
10
- const t = o._columns, n = be(o);
9
+ function he(o, e) {
10
+ const t = o._columns, n = ve(o);
11
11
  return {
12
- columns: t.map((i, s) => {
12
+ columns: t.map((s, i) => {
13
13
  const r = {
14
- field: i.field,
15
- order: s,
14
+ field: s.field,
15
+ order: i,
16
16
  visible: !0
17
17
  // If it's in _columns, it's visible (hidden columns are filtered out)
18
- }, a = i;
19
- a.__renderedWidth !== void 0 ? r.width = a.__renderedWidth : i.width !== void 0 && (r.width = typeof i.width == "string" ? parseFloat(i.width) : i.width);
20
- const l = n.get(i.field);
18
+ }, a = s;
19
+ a.__renderedWidth !== void 0 ? r.width = a.__renderedWidth : s.width !== void 0 && (r.width = typeof s.width == "string" ? parseFloat(s.width) : s.width);
20
+ const l = n.get(s.field);
21
21
  l && (r.sort = l);
22
- for (const f of e)
23
- if (f.getColumnState) {
24
- const p = f.getColumnState(i.field);
25
- p && Object.assign(r, p);
22
+ for (const d of e)
23
+ if (d.getColumnState) {
24
+ const u = d.getColumnState(s.field);
25
+ u && Object.assign(r, u);
26
26
  }
27
27
  return r;
28
28
  })
29
29
  };
30
30
  }
31
- function me(o, e, t, n) {
31
+ function ye(o, e, t, n) {
32
32
  if (!e.columns || e.columns.length === 0) return;
33
- const i = new Map(e.columns.map((a) => [a.field, a])), s = t.map((a) => {
34
- const l = i.get(a.field);
33
+ const s = new Map(e.columns.map((a) => [a.field, a])), i = t.map((a) => {
34
+ const l = s.get(a.field);
35
35
  if (!l) return a;
36
- const f = { ...a };
37
- return l.width !== void 0 && (f.width = l.width, f.__renderedWidth = l.width), l.visible !== void 0 && (f.hidden = !l.visible), f;
36
+ const d = { ...a };
37
+ return l.width !== void 0 && (d.width = l.width, d.__renderedWidth = l.width), l.visible !== void 0 && (d.hidden = !l.visible), d;
38
38
  });
39
- s.sort((a, l) => {
40
- const f = i.get(a.field)?.order ?? 1 / 0, p = i.get(l.field)?.order ?? 1 / 0;
41
- return f - p;
42
- }), o._columns = s;
39
+ i.sort((a, l) => {
40
+ const d = s.get(a.field)?.order ?? 1 / 0, u = s.get(l.field)?.order ?? 1 / 0;
41
+ return d - u;
42
+ }), o._columns = i;
43
43
  const r = e.columns.filter((a) => a.sort !== void 0).sort((a, l) => (a.sort?.priority ?? 0) - (l.sort?.priority ?? 0));
44
44
  if (r.length > 0) {
45
45
  const a = r[0];
@@ -54,47 +54,48 @@ function me(o, e, t, n) {
54
54
  for (const l of e.columns)
55
55
  a.applyColumnState(l.field, l);
56
56
  }
57
- function ve(o, e, t) {
57
+ function Ce(o, e, t) {
58
58
  let n = null;
59
59
  return () => {
60
60
  n !== null && clearTimeout(n), n = setTimeout(() => {
61
61
  n = null;
62
- const i = ae(o, e());
63
- t(i);
62
+ const s = he(o, e());
63
+ t(s);
64
64
  }, 100);
65
65
  };
66
66
  }
67
- const M = {
67
+ const O = {
68
68
  STRETCH: "stretch",
69
69
  FIXED: "fixed"
70
- }, ce = {
70
+ }, S = {
71
71
  expand: "▶",
72
72
  collapse: "▼",
73
73
  sortAsc: "▲",
74
74
  sortDesc: "▼",
75
75
  sortNone: "⇅",
76
76
  submenuArrow: "▶",
77
- dragHandle: "⋮⋮"
77
+ dragHandle: "⋮⋮",
78
+ toolPanel: "☰"
78
79
  };
79
- function Ce(o) {
80
+ function Ee(o) {
80
81
  return o == null ? "string" : typeof o == "number" ? "number" : typeof o == "boolean" ? "boolean" : o instanceof Date || typeof o == "string" && /\d{4}-\d{2}-\d{2}/.test(o) && !isNaN(Date.parse(o)) ? "date" : "string";
81
82
  }
82
- function de(o, e) {
83
+ function ue(o, e) {
83
84
  if (e && e.length) {
84
- const s = {};
85
+ const i = {};
85
86
  return e.forEach((r) => {
86
- r.type && (s[r.field] = r.type);
87
- }), { columns: e, typeMap: s };
88
- }
89
- const t = o[0] || {}, n = Object.keys(t).map((s) => {
90
- const r = t[s], a = Ce(r);
91
- return { field: s, header: s.charAt(0).toUpperCase() + s.slice(1), type: a };
92
- }), i = {};
93
- return n.forEach((s) => {
94
- i[s.field] = s.type || "string";
95
- }), { columns: n, typeMap: i };
96
- }
97
- const Ee = /{{\s*([^}]+)\s*}}/g, A = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, Re = /__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/, _e = /* @__PURE__ */ new Set([
87
+ r.type && (i[r.field] = r.type);
88
+ }), { columns: e, typeMap: i };
89
+ }
90
+ const t = o[0] || {}, n = Object.keys(t).map((i) => {
91
+ const r = t[i], a = Ee(r);
92
+ return { field: i, header: i.charAt(0).toUpperCase() + i.slice(1), type: a };
93
+ }), s = {};
94
+ return n.forEach((i) => {
95
+ s[i.field] = i.type || "string";
96
+ }), { columns: n, typeMap: s };
97
+ }
98
+ const Re = /{{\s*([^}]+)\s*}}/g, x = "__DG_EMPTY__", _e = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, xe = /__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/, Se = /* @__PURE__ */ new Set([
98
99
  "script",
99
100
  "iframe",
100
101
  "object",
@@ -119,76 +120,76 @@ const Ee = /{{\s*([^}]+)\s*}}/g, A = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>
119
120
  "plaintext",
120
121
  "xmp",
121
122
  "listing"
122
- ]), U = /^on\w+$/i, Ae = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), Se = /^\s*(javascript|vbscript|data|blob):/i;
123
- function z(o) {
123
+ ]), j = /^on\w+$/i, Ae = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), Te = /^\s*(javascript|vbscript|data|blob):/i;
124
+ function q(o) {
124
125
  if (!o || typeof o != "string") return "";
125
126
  if (o.indexOf("<") === -1) return o;
126
127
  const e = document.createElement("template");
127
- return e.innerHTML = o, xe(e.content), e.innerHTML;
128
+ return e.innerHTML = o, Le(e.content), e.innerHTML;
128
129
  }
129
- function xe(o) {
130
+ function Le(o) {
130
131
  const e = [], t = o.querySelectorAll("*");
131
132
  for (const n of t) {
132
- const i = n.tagName.toLowerCase();
133
- if (_e.has(i)) {
133
+ const s = n.tagName.toLowerCase();
134
+ if (Se.has(s)) {
134
135
  e.push(n);
135
136
  continue;
136
137
  }
137
- if ((i === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
138
- (a) => U.test(a.name) || a.name === "href" || a.name === "xlink:href"
138
+ if ((s === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
139
+ (a) => j.test(a.name) || a.name === "href" || a.name === "xlink:href"
139
140
  )) {
140
141
  e.push(n);
141
142
  continue;
142
143
  }
143
- const s = [];
144
+ const i = [];
144
145
  for (const r of n.attributes) {
145
146
  const a = r.name.toLowerCase();
146
- if (U.test(a)) {
147
- s.push(r.name);
147
+ if (j.test(a)) {
148
+ i.push(r.name);
148
149
  continue;
149
150
  }
150
- if (Ae.has(a) && Se.test(r.value)) {
151
- s.push(r.name);
151
+ if (Ae.has(a) && Te.test(r.value)) {
152
+ i.push(r.name);
152
153
  continue;
153
154
  }
154
155
  if (a === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(r.value)) {
155
- s.push(r.name);
156
+ i.push(r.name);
156
157
  continue;
157
158
  }
158
159
  }
159
- s.forEach((r) => n.removeAttribute(r));
160
+ i.forEach((r) => n.removeAttribute(r));
160
161
  }
161
162
  e.forEach((n) => n.remove());
162
163
  }
163
- function he(o, e) {
164
+ function fe(o, e) {
164
165
  if (!o || o.indexOf("{{") === -1) return o;
165
- const t = [], n = o.replace(Ee, (a, l) => {
166
- const f = Te(l, e);
167
- return t.push({ expr: l.trim(), result: f }), f;
168
- }), i = Le(n), s = t.length && t.every((a) => a.result === "" || a.result === A);
169
- return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) || s ? "" : i;
170
- }
171
- function Te(o, e) {
172
- if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return A;
173
- if (o === "value") return e.value == null ? A : String(e.value);
166
+ const t = [], n = o.replace(Re, (a, l) => {
167
+ const d = ke(l, e);
168
+ return t.push({ expr: l.trim(), result: d }), d;
169
+ }), s = Pe(n), i = t.length && t.every((a) => a.result === "" || a.result === x);
170
+ return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) || i ? "" : s;
171
+ }
172
+ function ke(o, e) {
173
+ if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return x;
174
+ if (o === "value") return e.value == null ? x : String(e.value);
174
175
  if (o.startsWith("row.") && !/[()?]/.test(o) && !o.includes(":")) {
175
- const n = o.slice(4), i = e.row ? e.row[n] : void 0;
176
- return i == null ? A : String(i);
176
+ const n = o.slice(4), s = e.row ? e.row[n] : void 0;
177
+ return s == null ? x : String(s);
177
178
  }
178
- if (o.length > 80 || !ye.test(o) || Re.test(o)) return A;
179
+ if (o.length > 80 || !_e.test(o) || xe.test(o)) return x;
179
180
  const t = o.match(/\./g);
180
- if (t && t.length > 1) return A;
181
+ if (t && t.length > 1) return x;
181
182
  try {
182
- const i = new Function("value", "row", `return (${o});`)(e.value, e.row), s = i == null ? "" : String(i);
183
- return /Reflect|Proxy|ownKeys/.test(s) ? A : s || A;
183
+ const s = new Function("value", "row", `return (${o});`)(e.value, e.row), i = s == null ? "" : String(s);
184
+ return /Reflect|Proxy|ownKeys/.test(i) ? x : i || x;
184
185
  } catch {
185
- return A;
186
+ return x;
186
187
  }
187
188
  }
188
- function Le(o) {
189
- return o && o.replace(new RegExp(A, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
189
+ function Pe(o) {
190
+ return o && o.replace(new RegExp(x, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
190
191
  }
191
- function ke(o) {
192
+ function Me(o) {
192
193
  if (/Reflect|Proxy|ownKeys/.test(o.textContent || "")) {
193
194
  if (Array.from(o.childNodes).forEach((e) => {
194
195
  e.nodeType === Node.TEXT_NODE && /Reflect|Proxy|ownKeys/.test(e.textContent || "") && (e.textContent = "");
@@ -200,40 +201,40 @@ function ke(o) {
200
201
  (o.textContent || "").trim().length === 0 && (o.textContent = "");
201
202
  }
202
203
  }
203
- function X(o) {
204
- const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(o), t = (n) => e ? "" : he(o, n);
204
+ function Y(o) {
205
+ const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(o), t = (n) => e ? "" : fe(o, n);
205
206
  return t.__blocked = e, t;
206
207
  }
207
- function Pe(o) {
208
+ function Oe(o) {
208
209
  return Array.from(o.querySelectorAll("tbw-grid-column")).map((t) => {
209
210
  const n = t.getAttribute("field") || "";
210
211
  if (!n) return null;
211
- const i = t.getAttribute("type") || void 0, r = i && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(i) ? i : void 0, a = t.getAttribute("header") || void 0, l = t.hasAttribute("sortable"), f = t.hasAttribute("editable"), p = { field: n, type: r, header: a, sortable: l, editable: f };
212
- t.hasAttribute("resizable") && (p.resizable = !0), t.hasAttribute("sizable") && (p.resizable = !0);
212
+ const s = t.getAttribute("type") || void 0, r = s && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(s) ? s : void 0, a = t.getAttribute("header") || void 0, l = t.hasAttribute("sortable"), d = t.hasAttribute("editable"), u = { field: n, type: r, header: a, sortable: l, editable: d };
213
+ t.hasAttribute("resizable") && (u.resizable = !0), t.hasAttribute("sizable") && (u.resizable = !0);
213
214
  const g = t.getAttribute("options");
214
- g && (p.options = g.split(",").map((d) => {
215
- const [b, m] = d.includes(":") ? d.split(":") : [d.trim(), d.trim()];
216
- return { value: b.trim(), label: m?.trim() || b.trim() };
215
+ g && (u.options = g.split(",").map((p) => {
216
+ const [w, m] = p.includes(":") ? p.split(":") : [p.trim(), p.trim()];
217
+ return { value: w.trim(), label: m?.trim() || w.trim() };
217
218
  }));
218
- const h = t.querySelector("tbw-grid-column-view"), c = t.querySelector("tbw-grid-column-editor"), u = t.querySelector("tbw-grid-column-header");
219
- return h && (p.__viewTemplate = h), c && (p.__editorTemplate = c), u && (p.__headerTemplate = u), p;
219
+ const h = t.querySelector("tbw-grid-column-view"), c = t.querySelector("tbw-grid-column-editor"), f = t.querySelector("tbw-grid-column-header");
220
+ return h && (u.__viewTemplate = h), c && (u.__editorTemplate = c), f && (u.__headerTemplate = f), u;
220
221
  }).filter((t) => !!t);
221
222
  }
222
- function Me(o, e) {
223
+ function He(o, e) {
223
224
  if ((!o || !o.length) && (!e || !e.length)) return [];
224
225
  if (!o || !o.length) return e || [];
225
226
  if (!e || !e.length) return o;
226
227
  const t = {};
227
- e.forEach((i) => t[i.field] = i);
228
- const n = o.map((i) => {
229
- const s = t[i.field];
230
- if (!s) return i;
231
- const r = { ...i };
232
- return s.header && !r.header && (r.header = s.header), s.type && !r.type && (r.type = s.type), r.sortable = i.sortable || s.sortable, (i.resizable === !0 || s.resizable === !0) && (r.resizable = !0), r.editable = i.editable || s.editable, s.__viewTemplate && (r.__viewTemplate = s.__viewTemplate), s.__editorTemplate && (r.__editorTemplate = s.__editorTemplate), s.__headerTemplate && (r.__headerTemplate = s.__headerTemplate), delete t[i.field], r;
228
+ e.forEach((s) => t[s.field] = s);
229
+ const n = o.map((s) => {
230
+ const i = t[s.field];
231
+ if (!i) return s;
232
+ const r = { ...s };
233
+ return i.header && !r.header && (r.header = i.header), i.type && !r.type && (r.type = i.type), r.sortable = s.sortable || i.sortable, (s.resizable === !0 || i.resizable === !0) && (r.resizable = !0), r.editable = s.editable || i.editable, i.__viewTemplate && (r.__viewTemplate = i.__viewTemplate), i.__editorTemplate && (r.__editorTemplate = i.__editorTemplate), i.__headerTemplate && (r.__headerTemplate = i.__headerTemplate), delete t[s.field], r;
233
234
  });
234
- return Object.keys(t).forEach((i) => n.push(t[i])), n;
235
+ return Object.keys(t).forEach((s) => n.push(t[s])), n;
235
236
  }
236
- function B(o, e) {
237
+ function W(o, e) {
237
238
  try {
238
239
  o.part?.add?.(e);
239
240
  } catch {
@@ -241,45 +242,45 @@ function B(o, e) {
241
242
  const t = o.getAttribute("part");
242
243
  t ? t.split(/\s+/).includes(e) || o.setAttribute("part", t + " " + e) : o.setAttribute("part", e);
243
244
  }
244
- function He(o) {
245
+ function ze(o) {
245
246
  o.__lightDomColumnsCache || (o.__originalColumnNodes = Array.from(
246
247
  o.querySelectorAll("tbw-grid-column")
247
- ), o.__lightDomColumnsCache = o.__originalColumnNodes.length ? Pe(o) : []);
248
- const e = o.__lightDomColumnsCache, t = Me(o._columns, e);
249
- t.forEach((i) => {
250
- i.__viewTemplate && !i.__compiledView && (i.__compiledView = X(i.__viewTemplate.innerHTML)), i.__editorTemplate && !i.__compiledEditor && (i.__compiledEditor = X(i.__editorTemplate.innerHTML));
248
+ ), o.__lightDomColumnsCache = o.__originalColumnNodes.length ? Oe(o) : []);
249
+ const e = o.__lightDomColumnsCache, t = He(o._columns, e);
250
+ t.forEach((s) => {
251
+ s.__viewTemplate && !s.__compiledView && (s.__compiledView = Y(s.__viewTemplate.innerHTML)), s.__editorTemplate && !s.__compiledEditor && (s.__compiledEditor = Y(s.__editorTemplate.innerHTML));
251
252
  });
252
- const { columns: n } = de(o._rows, t);
253
+ const { columns: n } = ue(o._rows, t);
253
254
  o._columns = n;
254
255
  }
255
- function Oe(o) {
256
- const e = o.effectiveConfig?.fitMode || o.fitMode || M.STRETCH;
257
- if (e !== M.STRETCH && e !== M.FIXED || o.__didInitialAutoSize || !o.isConnected) return;
256
+ function De(o) {
257
+ const e = o.effectiveConfig?.fitMode || o.fitMode || O.STRETCH;
258
+ if (e !== O.STRETCH && e !== O.FIXED || o.__didInitialAutoSize || !o.isConnected) return;
258
259
  const t = o.headerRowEl?.children || [];
259
260
  if (!t.length) return;
260
261
  let n = !1;
261
- o.visibleColumns.forEach((i, s) => {
262
- if (i.width) return;
263
- const r = t[s];
262
+ o.visibleColumns.forEach((s, i) => {
263
+ if (s.width) return;
264
+ const r = t[i];
264
265
  let a = r ? r.scrollWidth : 0;
265
266
  for (const l of o.rowPool) {
266
- const f = l.children[s];
267
- if (f) {
268
- const p = f.scrollWidth;
269
- p > a && (a = p);
267
+ const d = l.children[i];
268
+ if (d) {
269
+ const u = d.scrollWidth;
270
+ u > a && (a = u);
270
271
  }
271
272
  }
272
- a > 0 && (i.width = a + 2, i.__autoSized = !0, n = !0);
273
- }), n && ue(o), o.__didInitialAutoSize = !0;
273
+ a > 0 && (s.width = a + 2, s.__autoSized = !0, n = !0);
274
+ }), n && pe(o), o.__didInitialAutoSize = !0;
274
275
  }
275
- function ue(o) {
276
- (o.effectiveConfig?.fitMode || o.fitMode || M.STRETCH) === M.STRETCH ? o.gridTemplate = o.visibleColumns.map((t) => {
276
+ function pe(o) {
277
+ (o.effectiveConfig?.fitMode || o.fitMode || O.STRETCH) === O.STRETCH ? o.gridTemplate = o.visibleColumns.map((t) => {
277
278
  if (t.width) return `${t.width}px`;
278
279
  const n = t.minWidth;
279
280
  return n != null ? `minmax(${n}px, 1fr)` : "1fr";
280
281
  }).join(" ").trim() : o.gridTemplate = o.visibleColumns.map((t) => t.width ? `${t.width}px` : "max-content").join(" "), o.style.setProperty("--tbw-column-template", o.gridTemplate);
281
282
  }
282
- function De(o) {
283
+ function Ne(o) {
283
284
  switch (o.type) {
284
285
  case "number":
285
286
  return (e) => {
@@ -304,21 +305,21 @@ function De(o) {
304
305
  case "typeahead":
305
306
  return (e) => {
306
307
  const t = document.createElement("select");
307
- e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((s) => {
308
+ e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((i) => {
308
309
  const r = document.createElement("option");
309
- r.value = String(s.value), r.textContent = s.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(s.value) || !e.column.multi && e.value === s.value) && (r.selected = !0), t.appendChild(r);
310
+ r.value = String(i.value), r.textContent = i.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(i.value) || !e.column.multi && e.value === i.value) && (r.selected = !0), t.appendChild(r);
310
311
  });
311
- const i = () => {
312
+ const s = () => {
312
313
  if (e.column.multi) {
313
- const s = [];
314
+ const i = [];
314
315
  Array.from(t.selectedOptions).forEach((r) => {
315
- s.push(r.value);
316
- }), e.commit(s);
316
+ i.push(r.value);
317
+ }), e.commit(i);
317
318
  } else
318
319
  e.commit(t.value);
319
320
  };
320
- return t.addEventListener("change", i), t.addEventListener("blur", i), t.addEventListener("keydown", (s) => {
321
- s.key === "Escape" && e.cancel();
321
+ return t.addEventListener("change", s), t.addEventListener("blur", s), t.addEventListener("keydown", (i) => {
322
+ i.key === "Escape" && e.cancel();
322
323
  }), t.focus(), t;
323
324
  };
324
325
  default:
@@ -330,25 +331,25 @@ function De(o) {
330
331
  };
331
332
  }
332
333
  }
333
- function ze(o, e) {
334
+ function qe(o, e) {
334
335
  if (o.dispatchKeyDown?.(e))
335
336
  return;
336
- const t = o._rows.length - 1, n = o.visibleColumns.length - 1, i = o.activeEditRows !== void 0 && o.activeEditRows !== -1, r = o.visibleColumns[o.focusCol]?.type, a = e.composedPath ? e.composedPath() : [], l = a && a.length ? a[0] : e.target, f = (p) => {
337
- if (!p) return !1;
338
- const g = p.tagName;
339
- return !!(g === "INPUT" || g === "SELECT" || g === "TEXTAREA" || p.isContentEditable);
337
+ const t = o._rows.length - 1, n = o.visibleColumns.length - 1, s = o.activeEditRows !== void 0 && o.activeEditRows !== -1, r = o.visibleColumns[o.focusCol]?.type, a = e.composedPath ? e.composedPath() : [], l = a && a.length ? a[0] : e.target, d = (u) => {
338
+ if (!u) return !1;
339
+ const g = u.tagName;
340
+ return !!(g === "INPUT" || g === "SELECT" || g === "TEXTAREA" || u.isContentEditable);
340
341
  };
341
- if (!(f(l) && (e.key === "Home" || e.key === "End")) && !(f(l) && (e.key === "ArrowUp" || e.key === "ArrowDown") && l.tagName === "INPUT" && l.type === "number") && !(i && (r === "select" || r === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
342
+ if (!(d(l) && (e.key === "Home" || e.key === "End")) && !(d(l) && (e.key === "ArrowUp" || e.key === "ArrowDown") && l.tagName === "INPUT" && l.type === "number") && !(s && (r === "select" || r === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
342
343
  switch (e.key) {
343
344
  case "Tab": {
344
345
  e.preventDefault(), !e.shiftKey ? o.focusCol < n ? o.focusCol += 1 : (typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow < t && (o.focusRow += 1, o.focusCol = 0)) : o.focusCol > 0 ? o.focusCol -= 1 : o.focusRow > 0 && (typeof o.commitActiveRowEdit == "function" && o.activeEditRows === o.focusRow && o.commitActiveRowEdit(), o.focusRow -= 1, o.focusCol = n), H(o);
345
346
  return;
346
347
  }
347
348
  case "ArrowDown":
348
- i && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.min(t, o.focusRow + 1), e.preventDefault();
349
+ s && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.min(t, o.focusRow + 1), e.preventDefault();
349
350
  break;
350
351
  case "ArrowUp":
351
- i && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.max(0, o.focusRow - 1), e.preventDefault();
352
+ s && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.max(0, o.focusRow - 1), e.preventDefault();
352
353
  break;
353
354
  case "ArrowRight":
354
355
  o.focusCol = Math.min(n, o.focusCol + 1), e.preventDefault();
@@ -380,18 +381,18 @@ function ze(o, e) {
380
381
  }
381
382
  function H(o) {
382
383
  if (o.virtualization?.enabled) {
383
- const { rowHeight: i } = o.virtualization, s = o, r = o.focusRow * i;
384
- r < s.scrollTop ? s.scrollTop = r : r + i > s.scrollTop + s.clientHeight && (s.scrollTop = r - s.clientHeight + i);
384
+ const { rowHeight: s } = o.virtualization, i = o, r = o.focusRow * s;
385
+ r < i.scrollTop ? i.scrollTop = r : r + s > i.scrollTop + i.clientHeight && (i.scrollTop = r - i.clientHeight + s);
385
386
  }
386
- o.refreshVirtualWindow(!1), Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach((i) => i.classList.remove("cell-focus")), Array.from(o.bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((i) => {
387
- i.setAttribute("aria-selected", "false");
387
+ o.refreshVirtualWindow(!1), Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach((s) => s.classList.remove("cell-focus")), Array.from(o.bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((s) => {
388
+ s.setAttribute("aria-selected", "false");
388
389
  });
389
390
  const e = o.focusRow, t = o.virtualization.start ?? 0, n = o.virtualization.end ?? o._rows.length;
390
391
  if (e >= t && e < n) {
391
- const s = o.bodyEl.querySelectorAll(".data-grid-row")[e - t]?.children[o.focusCol];
392
- if (s) {
393
- if (s.classList.add("cell-focus"), s.setAttribute("aria-selected", "true"), o.activeEditRows !== void 0 && o.activeEditRows !== -1 && s.classList.contains("editing")) {
394
- const r = s.querySelector(
392
+ const i = o.bodyEl.querySelectorAll(".data-grid-row")[e - t]?.children[o.focusCol];
393
+ if (i) {
394
+ if (i.classList.add("cell-focus"), i.setAttribute("aria-selected", "true"), o.activeEditRows !== void 0 && o.activeEditRows !== -1 && i.classList.contains("editing")) {
395
+ const r = i.querySelector(
395
396
  'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
396
397
  );
397
398
  if (r && document.activeElement !== r)
@@ -399,63 +400,63 @@ function H(o) {
399
400
  r.focus();
400
401
  } catch {
401
402
  }
402
- } else if (!s.contains(document.activeElement)) {
403
- s.hasAttribute("tabindex") || s.setAttribute("tabindex", "-1");
403
+ } else if (!i.contains(document.activeElement)) {
404
+ i.hasAttribute("tabindex") || i.setAttribute("tabindex", "-1");
404
405
  try {
405
- s.focus({ preventScroll: !0 });
406
+ i.focus({ preventScroll: !0 });
406
407
  } catch {
407
408
  }
408
409
  }
409
410
  }
410
411
  }
411
412
  }
412
- const Ne = "__cellDisplayCache", Ie = "__cellCacheEpoch";
413
- function j(o) {
414
- o[Ne] = void 0, o[Ie] = void 0, o.__hasSpecialColumns = void 0;
413
+ const Ie = "__cellDisplayCache", $e = "__cellCacheEpoch";
414
+ function Z(o) {
415
+ o[Ie] = void 0, o[$e] = void 0, o.__hasSpecialColumns = void 0;
415
416
  }
416
- function qe(o, e, t, n, i) {
417
- const s = Math.max(0, t - e), r = o.bodyEl, a = o.visibleColumns, l = a.length;
418
- let f = o.__cachedHeaderRowCount;
419
- for (f === void 0 && (f = o.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, o.__cachedHeaderRowCount = f); o.rowPool.length < s; ) {
417
+ function Be(o, e, t, n, s) {
418
+ const i = Math.max(0, t - e), r = o.bodyEl, a = o.visibleColumns, l = a.length;
419
+ let d = o.__cachedHeaderRowCount;
420
+ for (d === void 0 && (d = o.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, o.__cachedHeaderRowCount = d); o.rowPool.length < i; ) {
420
421
  const g = document.createElement("div");
421
- g.className = "data-grid-row", g.setAttribute("role", "row"), g.addEventListener("click", (h) => Z(o, h, g, !1)), g.addEventListener("dblclick", (h) => Z(o, h, g, !0)), o.rowPool.push(g);
422
+ g.className = "data-grid-row", g.setAttribute("role", "row"), g.addEventListener("click", (h) => Q(o, h, g, !1)), g.addEventListener("dblclick", (h) => Q(o, h, g, !0)), o.rowPool.push(g);
422
423
  }
423
- if (o.rowPool.length > s) {
424
- for (let g = s; g < o.rowPool.length; g++) {
424
+ if (o.rowPool.length > i) {
425
+ for (let g = i; g < o.rowPool.length; g++) {
425
426
  const h = o.rowPool[g];
426
427
  h.parentNode === r && h.remove();
427
428
  }
428
- o.rowPool.length = s;
429
+ o.rowPool.length = i;
429
430
  }
430
- const p = i && o.__hasRenderRowPlugins !== !1;
431
- for (let g = 0; g < s; g++) {
432
- const h = e + g, c = o._rows[h], u = o.rowPool[g];
433
- if (u.setAttribute("aria-rowindex", String(h + f + 1)), p && i(c, u, h)) {
434
- u.__epoch = n, u.__rowDataRef = c, u.parentNode !== r && r.appendChild(u);
431
+ const u = s && o.__hasRenderRowPlugins !== !1;
432
+ for (let g = 0; g < i; g++) {
433
+ const h = e + g, c = o._rows[h], f = o.rowPool[g];
434
+ if (f.setAttribute("aria-rowindex", String(h + d + 1)), u && s(c, f, h)) {
435
+ f.__epoch = n, f.__rowDataRef = c, f.parentNode !== r && r.appendChild(f);
435
436
  continue;
436
437
  }
437
- const d = u.__epoch, b = u.__rowDataRef, m = u.children.length, R = d === n && m === l, E = b !== c;
438
+ const p = f.__epoch, w = f.__rowDataRef, m = f.children.length, R = p === n && m === l, C = w !== c;
438
439
  let _ = !1;
439
- if (R && E) {
440
- for (let S = 0; S < l; S++)
441
- if (a[S].externalView && !u.querySelector(`.cell[data-col="${S}"] [data-external-view]`)) {
440
+ if (R && C) {
441
+ for (let A = 0; A < l; A++)
442
+ if (a[A].externalView && !f.querySelector(`.cell[data-col="${A}"] [data-external-view]`)) {
442
443
  _ = !0;
443
444
  break;
444
445
  }
445
446
  }
446
- !R || _ ? (u.__isCustomRow && (u.className = "data-grid-row", u.setAttribute("role", "row"), u.__isCustomRow = !1), F(o, u, c, h), u.__epoch = n, u.__rowDataRef = c) : E ? (Y(o, u, c, h), u.__rowDataRef = c) : Y(o, u, c, h);
447
- const w = o._changedRowIndices.has(h), v = u.classList.contains("changed");
448
- w !== v && u.classList.toggle("changed", w), u.parentNode !== r && r.appendChild(u);
447
+ !R || _ ? (f.__isCustomRow && (f.className = "data-grid-row", f.setAttribute("role", "row"), f.__isCustomRow = !1), G(o, f, c, h), f.__epoch = n, f.__rowDataRef = c) : C ? (J(o, f, c, h), f.__rowDataRef = c) : J(o, f, c, h);
448
+ const b = o._changedRowIndices.has(h), v = f.classList.contains("changed");
449
+ b !== v && f.classList.toggle("changed", b), f.parentNode !== r && r.appendChild(f);
449
450
  }
450
451
  }
451
- function Y(o, e, t, n) {
452
- const i = e.children, s = o.visibleColumns, r = s.length, a = i.length, l = r < a ? r : a, f = o.focusRow, p = o.focusCol;
452
+ function J(o, e, t, n) {
453
+ const s = e.children, i = o.visibleColumns, r = i.length, a = s.length, l = r < a ? r : a, d = o.focusRow, u = o.focusCol;
453
454
  let g = o.__hasSpecialColumns;
454
455
  if (g === void 0) {
455
456
  g = !1;
456
457
  for (let c = 0; c < r; c++) {
457
- const u = s[c];
458
- if (u.__viewTemplate || u.__compiledView || u.viewRenderer || u.externalView || u.format || u.type === "date" || u.type === "boolean") {
458
+ const f = i[c];
459
+ if (f.__viewTemplate || f.__compiledView || f.viewRenderer || f.externalView || f.format || f.type === "date" || f.type === "boolean") {
459
460
  g = !0;
460
461
  break;
461
462
  }
@@ -465,89 +466,89 @@ function Y(o, e, t, n) {
465
466
  const h = String(n);
466
467
  if (!g) {
467
468
  for (let c = 0; c < l; c++) {
468
- const u = i[c], d = t[s[c].field];
469
- u.textContent = d == null ? "" : String(d), u.getAttribute("data-row") !== h && u.setAttribute("data-row", h);
470
- const b = f === n && p === c, m = u.classList.contains("cell-focus");
471
- b !== m && (u.classList.toggle("cell-focus", b), u.setAttribute("aria-selected", String(b)));
469
+ const f = s[c], p = t[i[c].field];
470
+ f.textContent = p == null ? "" : String(p), f.getAttribute("data-row") !== h && f.setAttribute("data-row", h);
471
+ const w = d === n && u === c, m = f.classList.contains("cell-focus");
472
+ w !== m && (f.classList.toggle("cell-focus", w), f.setAttribute("aria-selected", String(w)));
472
473
  }
473
474
  return;
474
475
  }
475
476
  for (let c = 0; c < l; c++)
476
- if (s[c].externalView && !i[c].querySelector("[data-external-view]")) {
477
- F(o, e, t, n);
477
+ if (i[c].externalView && !s[c].querySelector("[data-external-view]")) {
478
+ G(o, e, t, n);
478
479
  return;
479
480
  }
480
481
  for (let c = 0; c < l; c++) {
481
- const u = s[c], d = i[c];
482
- d.getAttribute("data-row") !== h && d.setAttribute("data-row", h);
483
- const b = f === n && p === c, m = d.classList.contains("cell-focus");
484
- if (b !== m && (d.classList.toggle("cell-focus", b), d.setAttribute("aria-selected", String(b))), d.classList.contains("editing")) continue;
485
- if (u.viewRenderer) {
486
- const E = t[u.field], _ = u.viewRenderer({ row: t, value: E, field: u.field, column: u });
487
- typeof _ == "string" ? d.innerHTML = z(_) : _ ? (d.innerHTML = "", d.appendChild(_)) : d.textContent = E == null ? "" : String(E);
482
+ const f = i[c], p = s[c];
483
+ p.getAttribute("data-row") !== h && p.setAttribute("data-row", h);
484
+ const w = d === n && u === c, m = p.classList.contains("cell-focus");
485
+ if (w !== m && (p.classList.toggle("cell-focus", w), p.setAttribute("aria-selected", String(w))), p.classList.contains("editing")) continue;
486
+ if (f.viewRenderer) {
487
+ const C = t[f.field], _ = f.viewRenderer({ row: t, value: C, field: f.field, column: f });
488
+ typeof _ == "string" ? p.innerHTML = q(_) : _ ? (p.innerHTML = "", p.appendChild(_)) : p.textContent = C == null ? "" : String(C);
488
489
  continue;
489
490
  }
490
- if (u.__viewTemplate || u.__compiledView || u.externalView)
491
+ if (f.__viewTemplate || f.__compiledView || f.externalView)
491
492
  continue;
492
- const C = t[u.field];
493
+ const y = t[f.field];
493
494
  let R;
494
- if (u.format)
495
+ if (f.format)
495
496
  try {
496
- const E = u.format(C, t);
497
- R = E == null ? "" : String(E);
498
- } catch {
497
+ const C = f.format(y, t);
499
498
  R = C == null ? "" : String(C);
499
+ } catch {
500
+ R = y == null ? "" : String(y);
500
501
  }
501
- else if (u.type === "date")
502
- if (C == null || C === "")
502
+ else if (f.type === "date")
503
+ if (y == null || y === "")
503
504
  R = "";
504
- else if (C instanceof Date)
505
- R = isNaN(C.getTime()) ? "" : C.toLocaleDateString();
505
+ else if (y instanceof Date)
506
+ R = isNaN(y.getTime()) ? "" : y.toLocaleDateString();
506
507
  else {
507
- const E = new Date(C);
508
- R = isNaN(E.getTime()) ? "" : E.toLocaleDateString();
508
+ const C = new Date(y);
509
+ R = isNaN(C.getTime()) ? "" : C.toLocaleDateString();
509
510
  }
510
- else u.type === "boolean" ? (R = C ? "🗹" : "☐", d.setAttribute("aria-checked", String(!!C))) : R = C == null ? "" : String(C);
511
- d.textContent = R;
511
+ else f.type === "boolean" ? (R = y ? "🗹" : "☐", p.setAttribute("aria-checked", String(!!y))) : R = y == null ? "" : String(y);
512
+ p.textContent = R;
512
513
  }
513
514
  }
514
- function F(o, e, t, n) {
515
+ function G(o, e, t, n) {
515
516
  e.innerHTML = "";
516
- const i = o.visibleColumns, s = i.length, r = o.focusRow, a = o.focusCol, l = o.effectiveConfig?.editOn || o.editOn, f = o, p = document.createDocumentFragment();
517
- for (let g = 0; g < s; g++) {
518
- const h = i[g], c = document.createElement("div");
519
- c.className = "cell", B(c, "cell"), h.type !== "boolean" && c.setAttribute("role", "gridcell"), c.setAttribute("data-col", String(g)), c.setAttribute("data-row", String(n)), c.setAttribute("aria-colindex", String(g + 1)), h.type && c.setAttribute("data-type", h.type);
520
- const u = h.sticky;
521
- u === "left" ? c.classList.add("sticky-left") : u === "right" && c.classList.add("sticky-right");
522
- let d = t[h.field];
523
- const b = h.format;
524
- if (b)
517
+ const s = o.visibleColumns, i = s.length, r = o.focusRow, a = o.focusCol, l = o.effectiveConfig?.editOn || o.editOn, d = o, u = document.createDocumentFragment();
518
+ for (let g = 0; g < i; g++) {
519
+ const h = s[g], c = document.createElement("div");
520
+ c.className = "cell", W(c, "cell"), h.type !== "boolean" && c.setAttribute("role", "gridcell"), c.setAttribute("data-col", String(g)), c.setAttribute("data-row", String(n)), c.setAttribute("aria-colindex", String(g + 1)), h.type && c.setAttribute("data-type", h.type);
521
+ const f = h.sticky;
522
+ f === "left" ? c.classList.add("sticky-left") : f === "right" && c.classList.add("sticky-right");
523
+ let p = t[h.field];
524
+ const w = h.format;
525
+ if (w)
525
526
  try {
526
- d = b(d, t);
527
+ p = w(p, t);
527
528
  } catch {
528
529
  }
529
- const m = h.__compiledView, C = h.__viewTemplate, R = h.viewRenderer, E = h.externalView;
530
+ const m = h.__compiledView, y = h.__viewTemplate, R = h.viewRenderer, C = h.externalView;
530
531
  let _ = !1;
531
532
  if (R) {
532
- const w = R({ row: t, value: d, field: h.field, column: h });
533
- typeof w == "string" ? (c.innerHTML = z(w), _ = !0) : w ? c.appendChild(w) : c.textContent = d == null ? "" : String(d);
534
- } else if (E) {
535
- const w = E, v = document.createElement("div");
533
+ const b = R({ row: t, value: p, field: h.field, column: h });
534
+ typeof b == "string" ? (c.innerHTML = q(b), _ = !0) : b ? c.appendChild(b) : c.textContent = p == null ? "" : String(p);
535
+ } else if (C) {
536
+ const b = C, v = document.createElement("div");
536
537
  v.setAttribute("data-external-view", ""), v.setAttribute("data-field", h.field), c.appendChild(v);
537
- const S = { row: t, value: d, field: h.field, column: h };
538
- if (w.mount)
538
+ const A = { row: t, value: p, field: h.field, column: h };
539
+ if (b.mount)
539
540
  try {
540
- w.mount({ placeholder: v, context: S, spec: w });
541
+ b.mount({ placeholder: v, context: A, spec: b });
541
542
  } catch {
542
543
  }
543
544
  else
544
545
  queueMicrotask(() => {
545
546
  try {
546
- f.dispatchEvent(
547
+ d.dispatchEvent(
547
548
  new CustomEvent("mount-external-view", {
548
549
  bubbles: !0,
549
550
  composed: !0,
550
- detail: { placeholder: v, spec: w, context: S }
551
+ detail: { placeholder: v, spec: b, context: A }
551
552
  })
552
553
  );
553
554
  } catch {
@@ -555,50 +556,50 @@ function F(o, e, t, n) {
555
556
  });
556
557
  v.setAttribute("data-mounted", "");
557
558
  } else if (m) {
558
- const w = m({ row: t, value: d, field: h.field, column: h }), v = m.__blocked;
559
- c.innerHTML = v ? "" : z(w), _ = !0, v && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
560
- } else if (C) {
561
- const w = C.innerHTML;
562
- /Reflect\.|\bProxy\b|ownKeys\(/.test(w) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = z(he(w, { row: t, value: d })), _ = !0);
559
+ const b = m({ row: t, value: p, field: h.field, column: h }), v = m.__blocked;
560
+ c.innerHTML = v ? "" : q(b), _ = !0, v && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
561
+ } else if (y) {
562
+ const b = y.innerHTML;
563
+ /Reflect\.|\bProxy\b|ownKeys\(/.test(b) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = q(fe(b, { row: t, value: p })), _ = !0);
563
564
  } else if (h.type === "date")
564
- if (d == null || d === "")
565
+ if (p == null || p === "")
565
566
  c.textContent = "";
566
567
  else {
567
- let w = null;
568
- if (d instanceof Date) w = d;
569
- else if (typeof d == "number" || typeof d == "string") {
570
- const v = new Date(d);
571
- isNaN(v.getTime()) || (w = v);
568
+ let b = null;
569
+ if (p instanceof Date) b = p;
570
+ else if (typeof p == "number" || typeof p == "string") {
571
+ const v = new Date(p);
572
+ isNaN(v.getTime()) || (b = v);
572
573
  }
573
- c.textContent = w ? w.toLocaleDateString() : "";
574
+ c.textContent = b ? b.toLocaleDateString() : "";
574
575
  }
575
576
  else if (h.type === "boolean") {
576
- const w = !!d;
577
- c.innerHTML = w ? "&#x1F5F9;" : "&#9744;", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(w)), c.setAttribute("aria-label", String(w));
577
+ const b = !!p;
578
+ c.innerHTML = b ? "&#x1F5F9;" : "&#9744;", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(b)), c.setAttribute("aria-label", String(b));
578
579
  } else
579
- c.textContent = d == null ? "" : String(d);
580
+ c.textContent = p == null ? "" : String(p);
580
581
  if (_) {
581
- ke(c);
582
- const w = c.textContent || "";
583
- /Proxy|Reflect\.ownKeys/.test(w) && (c.textContent = w.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(c.textContent || "") && (c.textContent = ""));
582
+ Me(c);
583
+ const b = c.textContent || "";
584
+ /Proxy|Reflect\.ownKeys/.test(b) && (c.textContent = b.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(c.textContent || "") && (c.textContent = ""));
584
585
  }
585
586
  c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""), h.editable ? (c.tabIndex = 0, c.addEventListener("mousedown", () => {
586
587
  o.focusRow = n, o.focusCol = g, H(o);
587
- }), l === "click" ? c.addEventListener("click", (w) => {
588
- c.classList.contains("editing") || (w.stopPropagation(), o.focusRow = n, o.focusCol = g, L(o, t, n, h, c));
589
- }) : c.addEventListener("dblclick", (w) => {
590
- w.stopPropagation(), T(o, n, t);
588
+ }), l === "click" ? c.addEventListener("click", (b) => {
589
+ c.classList.contains("editing") || (b.stopPropagation(), o.focusRow = n, o.focusCol = g, k(o, t, n, h, c));
590
+ }) : c.addEventListener("dblclick", (b) => {
591
+ b.stopPropagation(), L(o, n, t);
591
592
  const v = o.findRenderedRowElement?.(n);
592
593
  if (v) {
593
- const S = v.children;
594
- for (let k = 0; k < S.length; k++) {
595
- const O = o.visibleColumns[k];
596
- O && O.editable && L(o, t, n, O, S[k]);
594
+ const A = v.children;
595
+ for (let P = 0; P < A.length; P++) {
596
+ const D = o.visibleColumns[P];
597
+ D && D.editable && k(o, t, n, D, A[P]);
597
598
  }
598
599
  }
599
- }), c.addEventListener("keydown", (w) => {
600
- if ((h.type === "select" || h.type === "typeahead") && !c.classList.contains("editing") && w.key === "Enter") {
601
- w.preventDefault(), o.activeEditRows !== n && T(o, n, t), L(o, t, n, h, c), setTimeout(() => {
600
+ }), c.addEventListener("keydown", (b) => {
601
+ if ((h.type === "select" || h.type === "typeahead") && !c.classList.contains("editing") && b.key === "Enter") {
602
+ b.preventDefault(), o.activeEditRows !== n && L(o, n, t), k(o, t, n, h, c), setTimeout(() => {
602
603
  const v = c.querySelector("select");
603
604
  try {
604
605
  v?.showPicker?.();
@@ -608,86 +609,86 @@ function F(o, e, t, n) {
608
609
  }, 0);
609
610
  return;
610
611
  }
611
- if (h.type === "boolean" && w.key === " " && !c.classList.contains("editing")) {
612
- w.preventDefault(), o.activeEditRows !== n && T(o, n, t);
612
+ if (h.type === "boolean" && b.key === " " && !c.classList.contains("editing")) {
613
+ b.preventDefault(), o.activeEditRows !== n && L(o, n, t);
613
614
  const v = !t[h.field];
614
- $(o, n, h, v, t), c.innerHTML = v ? "&#x1F5F9;" : "&#9744;", c.setAttribute("aria-label", String(!!v));
615
+ K(o, n, h, v, t), c.innerHTML = v ? "&#x1F5F9;" : "&#9744;", c.setAttribute("aria-label", String(!!v));
615
616
  return;
616
617
  }
617
- if (w.key === "Enter" && !c.classList.contains("editing")) {
618
- w.preventDefault(), o.focusRow = n, o.focusCol = g, typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(n) : L(o, t, n, h, c);
618
+ if (b.key === "Enter" && !c.classList.contains("editing")) {
619
+ b.preventDefault(), o.focusRow = n, o.focusCol = g, typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(n) : k(o, t, n, h, c);
619
620
  return;
620
621
  }
621
- if (w.key === "F2" && !c.classList.contains("editing")) {
622
- w.preventDefault(), L(o, t, n, h, c);
622
+ if (b.key === "F2" && !c.classList.contains("editing")) {
623
+ b.preventDefault(), k(o, t, n, h, c);
623
624
  return;
624
625
  }
625
- })) : h.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0), c.addEventListener("keydown", (w) => {
626
- if (w.key === " ") {
627
- w.preventDefault();
626
+ })) : h.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0), c.addEventListener("keydown", (b) => {
627
+ if (b.key === " ") {
628
+ b.preventDefault();
628
629
  const v = !t[h.field];
629
- o.activeEditRows !== n && T(o, n, t), $(o, n, h, v, t), c.innerHTML = v ? "&#x1F5F9;" : "&#9744;", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(!!v)), c.setAttribute("aria-label", String(!!v));
630
+ o.activeEditRows !== n && L(o, n, t), K(o, n, h, v, t), c.innerHTML = v ? "&#x1F5F9;" : "&#9744;", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(!!v)), c.setAttribute("aria-label", String(!!v));
630
631
  }
631
- })), r === n && a === g ? c.setAttribute("aria-selected", "true") : c.setAttribute("aria-selected", "false"), p.appendChild(c);
632
+ })), r === n && a === g ? c.setAttribute("aria-selected", "true") : c.setAttribute("aria-selected", "false"), u.appendChild(c);
632
633
  }
633
- e.appendChild(p);
634
+ e.appendChild(u);
634
635
  }
635
- function Z(o, e, t, n) {
636
+ function Q(o, e, t, n) {
636
637
  if (e.target?.closest(".resize-handle")) return;
637
- const i = t.querySelector(".cell[data-row]");
638
- if (!i) return;
639
- const s = Number(i.getAttribute("data-row"));
640
- if (isNaN(s)) return;
641
- const r = o._rows[s];
638
+ const s = t.querySelector(".cell[data-row]");
639
+ if (!s) return;
640
+ const i = Number(s.getAttribute("data-row"));
641
+ if (isNaN(i)) return;
642
+ const r = o._rows[i];
642
643
  if (!r) return;
643
644
  const a = e.target?.closest(".cell[data-col]");
644
645
  if (a) {
645
- const f = Number(a.getAttribute("data-col"));
646
- if (!isNaN(f)) {
647
- if (o.dispatchCellClick?.(e, s, f, a))
646
+ const d = Number(a.getAttribute("data-col"));
647
+ if (!isNaN(d)) {
648
+ if (o.dispatchCellClick?.(e, i, d, a))
648
649
  return;
649
- o.focusRow = s, o.focusCol = f, H(o);
650
+ o.focusRow = i, o.focusCol = d, H(o);
650
651
  }
651
652
  }
652
653
  if (t.querySelector(".cell.editing")) {
653
- const f = t.querySelectorAll(".cell.editing");
654
+ const d = t.querySelectorAll(".cell.editing");
654
655
  if (!n) return;
655
- f.forEach((p) => p.classList.remove("editing"));
656
+ d.forEach((u) => u.classList.remove("editing"));
656
657
  }
657
658
  const l = o.effectiveConfig?.editOn || o.editOn || "doubleClick";
658
- if (l === "click" || l === "doubleClick" && n) T(o, s, r);
659
+ if (l === "click" || l === "doubleClick" && n) L(o, i, r);
659
660
  else return;
660
- Array.from(t.children).forEach((f, p) => {
661
- const g = o.visibleColumns[p];
662
- g && g.editable && L(o, r, s, g, f);
661
+ Array.from(t.children).forEach((d, u) => {
662
+ const g = o.visibleColumns[u];
663
+ g && g.editable && k(o, r, i, g, d);
663
664
  }), a && queueMicrotask(() => {
664
- const f = t.querySelector(`.cell[data-col="${o.focusCol}"]`);
665
- if (f?.classList.contains("editing")) {
666
- const p = f.querySelector(
665
+ const d = t.querySelector(`.cell[data-col="${o.focusCol}"]`);
666
+ if (d?.classList.contains("editing")) {
667
+ const u = d.querySelector(
667
668
  'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
668
669
  );
669
670
  try {
670
- p?.focus();
671
+ u?.focus();
671
672
  } catch {
672
673
  }
673
674
  }
674
675
  });
675
676
  }
676
- function T(o, e, t) {
677
+ function L(o, e, t) {
677
678
  o.activeEditRows !== e && (o.rowEditSnapshots.set(e, { ...t }), o.activeEditRows = e);
678
679
  }
679
- function Be(o, e, t) {
680
+ function We(o, e, t) {
680
681
  if (o.activeEditRows !== e) return;
681
- const n = o.rowEditSnapshots.get(e), i = o._rows[e];
682
- if (t && n && i)
683
- Object.keys(n).forEach((r) => i[r] = n[r]), o._changedRowIndices.delete(e);
682
+ const n = o.rowEditSnapshots.get(e), s = o._rows[e];
683
+ if (t && n && s)
684
+ Object.keys(n).forEach((r) => s[r] = n[r]), o._changedRowIndices.delete(e);
684
685
  else if (!t) {
685
686
  const r = o._changedRowIndices.has(e);
686
687
  o.dispatchEvent(
687
688
  new CustomEvent("row-commit", {
688
689
  detail: {
689
690
  rowIndex: e,
690
- row: i,
691
+ row: s,
691
692
  changed: r,
692
693
  changedRows: o.changedRows,
693
694
  changedRowIndices: o.changedRowIndices
@@ -696,34 +697,34 @@ function Be(o, e, t) {
696
697
  );
697
698
  }
698
699
  o.rowEditSnapshots.delete(e), o.activeEditRows = -1;
699
- const s = o.findRenderedRowElement?.(e);
700
- s && (F(o, s, o._rows[e], e), o._changedRowIndices.has(e) ? s.classList.add("changed") : s.classList.remove("changed")), t && queueMicrotask(() => {
700
+ const i = o.findRenderedRowElement?.(e);
701
+ i && (G(o, i, o._rows[e], e), o._changedRowIndices.has(e) ? i.classList.add("changed") : i.classList.remove("changed")), t && queueMicrotask(() => {
701
702
  try {
702
703
  o.focus();
703
704
  const r = o.focusRow, a = o.focusCol, l = o.findRenderedRowElement?.(r);
704
705
  if (l) {
705
706
  Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach(
706
- (p) => p.classList.remove("cell-focus")
707
+ (u) => u.classList.remove("cell-focus")
707
708
  );
708
- const f = l.querySelector(`.cell[data-row="${r}"][data-col="${a}"]`);
709
- f && f.classList.add("cell-focus");
709
+ const d = l.querySelector(`.cell[data-row="${r}"][data-col="${a}"]`);
710
+ d && d.classList.add("cell-focus");
710
711
  }
711
712
  } catch {
712
713
  }
713
714
  });
714
715
  }
715
- function $(o, e, t, n, i) {
716
- const s = t.field;
717
- if (i[s] === n) return;
718
- i[s] = n;
716
+ function K(o, e, t, n, s) {
717
+ const i = t.field;
718
+ if (s[i] === n) return;
719
+ s[i] = n;
719
720
  const a = !o._changedRowIndices.has(e);
720
721
  o._changedRowIndices.add(e);
721
722
  const l = o.findRenderedRowElement?.(e);
722
723
  l && l.classList.add("changed"), o.dispatchEvent(
723
724
  new CustomEvent("cell-commit", {
724
725
  detail: {
725
- row: i,
726
- field: s,
726
+ row: s,
727
+ field: i,
727
728
  value: n,
728
729
  rowIndex: e,
729
730
  changedRows: o.changedRows,
@@ -733,122 +734,122 @@ function $(o, e, t, n, i) {
733
734
  })
734
735
  );
735
736
  }
736
- function L(o, e, t, n, i) {
737
- if (!n.editable || (o.activeEditRows !== t && T(o, t, e), i.classList.contains("editing"))) return;
738
- const s = e[n.field];
739
- i.classList.add("editing");
737
+ function k(o, e, t, n, s) {
738
+ if (!n.editable || (o.activeEditRows !== t && L(o, t, e), s.classList.contains("editing"))) return;
739
+ const i = e[n.field];
740
+ s.classList.add("editing");
740
741
  const r = (h) => {
741
- $(o, t, n, h, e);
742
+ K(o, t, n, h, e);
742
743
  }, a = () => {
743
- e[n.field] = s;
744
- const h = i.querySelector("input,textarea,select");
745
- h && (typeof HTMLInputElement < "u" && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!s : "value" in h && (h.value = s ?? ""));
744
+ e[n.field] = i;
745
+ const h = s.querySelector("input,textarea,select");
746
+ h && (typeof HTMLInputElement < "u" && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!i : "value" in h && (h.value = i ?? ""));
746
747
  }, l = document.createElement("div");
747
- l.style.display = "contents", i.innerHTML = "", i.appendChild(l);
748
- const f = n.__editorTemplate, p = n.editor || (f ? "template" : De(n)), g = s;
749
- if (p === "template" && f) {
750
- const h = f.cloneNode(!0), c = n.__compiledEditor;
751
- c ? h.innerHTML = c({ row: e, value: s, field: n.field, column: n }) : h.querySelectorAll("*").forEach((d) => {
752
- d.childNodes.length === 1 && d.firstChild?.nodeType === Node.TEXT_NODE && (d.textContent = d.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (b, m) => {
753
- const C = e[m];
754
- return C == null ? "" : String(C);
748
+ l.style.display = "contents", s.innerHTML = "", s.appendChild(l);
749
+ const d = n.__editorTemplate, u = n.editor || (d ? "template" : Ne(n)), g = i;
750
+ if (u === "template" && d) {
751
+ const h = d.cloneNode(!0), c = n.__compiledEditor;
752
+ c ? h.innerHTML = c({ row: e, value: i, field: n.field, column: n }) : h.querySelectorAll("*").forEach((p) => {
753
+ p.childNodes.length === 1 && p.firstChild?.nodeType === Node.TEXT_NODE && (p.textContent = p.textContent?.replace(/{{\s*value\s*}}/g, i == null ? "" : String(i)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (w, m) => {
754
+ const y = e[m];
755
+ return y == null ? "" : String(y);
755
756
  }) || "");
756
757
  });
757
- const u = h.querySelector("input,textarea,select");
758
- if (u) {
759
- const d = typeof HTMLInputElement < "u";
760
- d && u instanceof HTMLInputElement && u.type === "checkbox" ? u.checked = !!s : "value" in u && (u.value = s ?? ""), u.addEventListener("blur", () => {
761
- const b = d && u instanceof HTMLInputElement && u.type === "checkbox" ? u.checked : u.value;
762
- r(b);
763
- }), u.addEventListener("keydown", (b) => {
764
- if (b.key === "Enter") {
765
- const m = d && u instanceof HTMLInputElement && u.type === "checkbox" ? u.checked : u.value;
758
+ const f = h.querySelector("input,textarea,select");
759
+ if (f) {
760
+ const p = typeof HTMLInputElement < "u";
761
+ p && f instanceof HTMLInputElement && f.type === "checkbox" ? f.checked = !!i : "value" in f && (f.value = i ?? ""), f.addEventListener("blur", () => {
762
+ const w = p && f instanceof HTMLInputElement && f.type === "checkbox" ? f.checked : f.value;
763
+ r(w);
764
+ }), f.addEventListener("keydown", (w) => {
765
+ if (w.key === "Enter") {
766
+ const m = p && f instanceof HTMLInputElement && f.type === "checkbox" ? f.checked : f.value;
766
767
  r(m);
767
768
  }
768
- b.key === "Escape" && a();
769
- }), d && u instanceof HTMLInputElement && u.type === "checkbox" && u.addEventListener("change", () => {
770
- const b = u.checked;
771
- r(b);
772
- }), setTimeout(() => u.focus(), 0);
769
+ w.key === "Escape" && a();
770
+ }), p && f instanceof HTMLInputElement && f.type === "checkbox" && f.addEventListener("change", () => {
771
+ const w = f.checked;
772
+ r(w);
773
+ }), setTimeout(() => f.focus(), 0);
773
774
  }
774
775
  l.appendChild(h);
775
- } else if (typeof p == "string") {
776
- const h = document.createElement(p);
776
+ } else if (typeof u == "string") {
777
+ const h = document.createElement(u);
777
778
  h.value = g, h.addEventListener("change", () => r(h.value)), l.appendChild(h);
778
- } else if (typeof p == "function") {
779
- const h = p({ row: e, value: g, field: n.field, column: n, commit: r, cancel: a });
779
+ } else if (typeof u == "function") {
780
+ const h = u({ row: e, value: g, field: n.field, column: n, commit: r, cancel: a });
780
781
  typeof h == "string" ? l.innerHTML = h : l.appendChild(h);
781
- } else if (p && typeof p == "object") {
782
+ } else if (u && typeof u == "object") {
782
783
  const h = document.createElement("div");
783
784
  h.setAttribute("data-external-editor", ""), h.setAttribute("data-field", n.field), l.appendChild(h);
784
785
  const c = { row: e, value: g, field: n.field, column: n, commit: r, cancel: a };
785
- if (p.mount)
786
+ if (u.mount)
786
787
  try {
787
- p.mount({ placeholder: h, context: c, spec: p });
788
+ u.mount({ placeholder: h, context: c, spec: u });
788
789
  } catch {
789
790
  }
790
791
  else
791
792
  o.dispatchEvent(
792
- new CustomEvent("mount-external-editor", { detail: { placeholder: h, spec: p, context: c } })
793
+ new CustomEvent("mount-external-editor", { detail: { placeholder: h, spec: u, context: c } })
793
794
  );
794
795
  }
795
796
  }
796
- function J(o, e) {
797
- !o.sortState || o.sortState.field !== e.field ? (o.sortState || (o.__originalOrder = o._rows.slice()), Q(o, e, 1)) : o.sortState.direction === 1 ? Q(o, e, -1) : (o.sortState = null, o.__rowRenderEpoch++, o.rowPool.forEach((n) => n.__epoch = -1), o._rows = o.__originalOrder.slice(), V(o), o.headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach((n) => {
797
+ function ee(o, e) {
798
+ !o.sortState || o.sortState.field !== e.field ? (o.sortState || (o.__originalOrder = o._rows.slice()), te(o, e, 1)) : o.sortState.direction === 1 ? te(o, e, -1) : (o.sortState = null, o.__rowRenderEpoch++, o.rowPool.forEach((n) => n.__epoch = -1), o._rows = o.__originalOrder.slice(), U(o), o.headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach((n) => {
798
799
  n.getAttribute("aria-sort") ? (n.getAttribute("aria-sort") === "ascending" || n.getAttribute("aria-sort") === "descending") && (o.sortState || n.setAttribute("aria-sort", "none")) : n.setAttribute("aria-sort", "none");
799
800
  }), o.refreshVirtualWindow(!0), o.dispatchEvent(
800
801
  new CustomEvent("sort-change", { detail: { field: e.field, direction: 0 } })
801
802
  ), o.requestStateChange?.());
802
803
  }
803
- function Q(o, e, t) {
804
+ function te(o, e, t) {
804
805
  o.sortState = { field: e.field, direction: t };
805
- const n = e.sortComparator || ((i, s) => i == null && s == null ? 0 : i == null ? -1 : s == null || i > s ? 1 : i < s ? -1 : 0);
806
- o._rows.sort((i, s) => n(i[e.field], s[e.field], i, s) * t), o.__rowRenderEpoch++, o.rowPool.forEach((i) => i.__epoch = -1), V(o), o.refreshVirtualWindow(!0), o.dispatchEvent(
806
+ const n = e.sortComparator || ((s, i) => s == null && i == null ? 0 : s == null ? -1 : i == null || s > i ? 1 : s < i ? -1 : 0);
807
+ o._rows.sort((s, i) => n(s[e.field], i[e.field], s, i) * t), o.__rowRenderEpoch++, o.rowPool.forEach((s) => s.__epoch = -1), U(o), o.refreshVirtualWindow(!0), o.dispatchEvent(
807
808
  new CustomEvent("sort-change", { detail: { field: e.field, direction: t } })
808
809
  ), o.requestStateChange?.();
809
810
  }
810
- function $e(o, e) {
811
+ function Ke(o, e) {
811
812
  typeof e == "string" ? o.textContent = e : e instanceof HTMLElement && (o.innerHTML = "", o.appendChild(e.cloneNode(!0)));
812
813
  }
813
- function V(o) {
814
+ function U(o) {
814
815
  o.headerRowEl = o.findHeaderRow();
815
816
  const e = o.headerRowEl;
816
817
  e.innerHTML = "", e.setAttribute("role", "row"), e.setAttribute("aria-rowindex", "1"), o.visibleColumns.forEach((t, n) => {
817
- const i = document.createElement("div");
818
- i.className = "cell", B(i, "header-cell"), i.setAttribute("role", "columnheader"), i.setAttribute("aria-colindex", String(n + 1)), i.setAttribute("data-field", t.field), i.setAttribute("data-col", String(n)), t.sticky === "left" ? i.classList.add("sticky-left") : t.sticky === "right" && i.classList.add("sticky-right");
819
- const s = t.__headerTemplate;
820
- if (s) Array.from(s.childNodes).forEach((r) => i.appendChild(r.cloneNode(!0)));
818
+ const s = document.createElement("div");
819
+ s.className = "cell", W(s, "header-cell"), s.setAttribute("role", "columnheader"), s.setAttribute("aria-colindex", String(n + 1)), s.setAttribute("data-field", t.field), s.setAttribute("data-col", String(n)), t.sticky === "left" ? s.classList.add("sticky-left") : t.sticky === "right" && s.classList.add("sticky-right");
820
+ const i = t.__headerTemplate;
821
+ if (i) Array.from(i.childNodes).forEach((r) => s.appendChild(r.cloneNode(!0)));
821
822
  else {
822
823
  const r = t.header || t.field, a = document.createElement("span");
823
- a.textContent = r, i.appendChild(a);
824
+ a.textContent = r, s.appendChild(a);
824
825
  }
825
826
  if (t.sortable) {
826
- i.classList.add("sortable"), i.tabIndex = 0;
827
+ s.classList.add("sortable"), s.tabIndex = 0;
827
828
  const r = document.createElement("span");
828
- B(r, "sort-indicator"), r.style.opacity = "0.6";
829
- const a = o.sortState?.field === t.field ? o.sortState.direction : 0, l = { ...ce, ...o.icons }, f = a === 1 ? l.sortAsc : a === -1 ? l.sortDesc : l.sortNone;
830
- $e(r, f), i.appendChild(r), i.setAttribute("aria-sort", a === 0 ? "none" : a === 1 ? "ascending" : "descending"), i.addEventListener("click", (p) => {
831
- o.resizeController?.isResizing || o.dispatchHeaderClick?.(p, n, i) || J(o, t);
832
- }), i.addEventListener("keydown", (p) => {
833
- if (p.key === "Enter" || p.key === " ") {
834
- if (p.preventDefault(), o.dispatchHeaderClick?.(p, n, i)) return;
835
- J(o, t);
829
+ W(r, "sort-indicator"), r.style.opacity = "0.6";
830
+ const a = o.sortState?.field === t.field ? o.sortState.direction : 0, l = { ...S, ...o.icons }, d = a === 1 ? l.sortAsc : a === -1 ? l.sortDesc : l.sortNone;
831
+ Ke(r, d), s.appendChild(r), s.setAttribute("aria-sort", a === 0 ? "none" : a === 1 ? "ascending" : "descending"), s.addEventListener("click", (u) => {
832
+ o.resizeController?.isResizing || o.dispatchHeaderClick?.(u, n, s) || ee(o, t);
833
+ }), s.addEventListener("keydown", (u) => {
834
+ if (u.key === "Enter" || u.key === " ") {
835
+ if (u.preventDefault(), o.dispatchHeaderClick?.(u, n, s)) return;
836
+ ee(o, t);
836
837
  }
837
838
  });
838
839
  }
839
840
  if (t.resizable) {
840
- t.sticky || (i.style.position = "relative");
841
+ t.sticky || (s.style.position = "relative");
841
842
  const r = document.createElement("div");
842
843
  r.className = "resize-handle", r.setAttribute("aria-hidden", "true"), r.addEventListener("mousedown", (a) => {
843
- a.stopPropagation(), a.preventDefault(), o.resizeController.start(a, n, i);
844
- }), i.appendChild(r);
844
+ a.stopPropagation(), a.preventDefault(), o.resizeController.start(a, n, s);
845
+ }), s.appendChild(r);
845
846
  }
846
- e.appendChild(i);
847
+ e.appendChild(s);
847
848
  });
848
849
  try {
849
850
  const t = o.shadowRoot;
850
- t && t.querySelectorAll(".header-group-row .cell").forEach((i) => {
851
- i.getAttribute("data-group") && i.classList.add("grouped");
851
+ t && t.querySelectorAll(".header-group-row .cell").forEach((s) => {
852
+ s.getAttribute("data-group") && s.classList.add("grouped");
852
853
  });
853
854
  } catch {
854
855
  }
@@ -856,15 +857,15 @@ function V(o) {
856
857
  t.getAttribute("aria-sort") || t.setAttribute("aria-sort", "none");
857
858
  });
858
859
  }
859
- function Ke(o) {
860
- let e = null, t = null, n = null, i = null;
861
- const s = (l) => {
860
+ function Ve(o) {
861
+ let e = null, t = null, n = null, s = null;
862
+ const i = (l) => {
862
863
  if (!e) return;
863
- const f = l.clientX - e.startX, p = Math.max(40, e.startWidth + f), g = o.visibleColumns[e.colIndex];
864
- g.width = p, g.__userResized = !0, g.__renderedWidth = p, t == null && (t = requestAnimationFrame(() => {
864
+ const d = l.clientX - e.startX, u = Math.max(40, e.startWidth + d), g = o.visibleColumns[e.colIndex];
865
+ g.width = u, g.__userResized = !0, g.__renderedWidth = u, t == null && (t = requestAnimationFrame(() => {
865
866
  t = null, o.updateTemplate?.();
866
867
  })), o.dispatchEvent(
867
- new CustomEvent("column-resize", { detail: { field: g.field, width: p } })
868
+ new CustomEvent("column-resize", { detail: { field: g.field, width: u } })
868
869
  );
869
870
  };
870
871
  let r = !1;
@@ -872,79 +873,101 @@ function Ke(o) {
872
873
  const l = e !== null;
873
874
  l && (r = !0, requestAnimationFrame(() => {
874
875
  r = !1;
875
- })), window.removeEventListener("mousemove", s), window.removeEventListener("mouseup", a), n !== null && (document.documentElement.style.cursor = n, n = null), i !== null && (document.body.style.userSelect = i, i = null), e = null, l && o.requestStateChange && o.requestStateChange();
876
+ })), window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", a), n !== null && (document.documentElement.style.cursor = n, n = null), s !== null && (document.body.style.userSelect = s, s = null), e = null, l && o.requestStateChange && o.requestStateChange();
876
877
  };
877
878
  return {
878
879
  get isResizing() {
879
880
  return e !== null || r;
880
881
  },
881
- start(l, f, p) {
882
+ start(l, d, u) {
882
883
  l.preventDefault();
883
- const g = p.getBoundingClientRect();
884
- e = { startX: l.clientX, colIndex: f, startWidth: g.width }, window.addEventListener("mousemove", s), window.addEventListener("mouseup", a), n === null && (n = document.documentElement.style.cursor), document.documentElement.style.cursor = "e-resize", i === null && (i = document.body.style.userSelect), document.body.style.userSelect = "none";
884
+ const g = u.getBoundingClientRect();
885
+ e = { startX: l.clientX, colIndex: d, startWidth: g.width }, window.addEventListener("mousemove", i), window.addEventListener("mouseup", a), n === null && (n = document.documentElement.style.cursor), document.documentElement.style.cursor = "e-resize", s === null && (s = document.body.style.userSelect), document.body.style.userSelect = "none";
885
886
  },
886
887
  dispose() {
887
888
  a();
888
889
  }
889
890
  };
890
891
  }
891
- function We() {
892
+ function z(o) {
893
+ return o ? typeof o == "string" ? o : o.outerHTML : "";
894
+ }
895
+ function Fe() {
892
896
  return {
893
897
  toolPanels: /* @__PURE__ */ new Map(),
894
898
  headerContents: /* @__PURE__ */ new Map(),
895
899
  toolbarButtons: /* @__PURE__ */ new Map(),
896
900
  lightDomButtons: [],
897
901
  lightDomHeaderContent: [],
898
- activePanel: null,
902
+ isPanelOpen: !1,
903
+ expandedSections: /* @__PURE__ */ new Set(),
899
904
  headerContentCleanups: /* @__PURE__ */ new Map(),
900
- activePanelCleanup: null,
901
- toolbarButtonCleanups: /* @__PURE__ */ new Map()
905
+ panelCleanups: /* @__PURE__ */ new Map(),
906
+ toolbarButtonCleanups: /* @__PURE__ */ new Map(),
907
+ // Deprecated - kept for backward compatibility
908
+ activePanel: null,
909
+ activePanelCleanup: null
902
910
  };
903
911
  }
904
- function Fe(o, e) {
912
+ function Ge(o, e) {
905
913
  return !!(o?.header?.title || o?.header?.toolbarButtons?.length || e.toolPanels.size > 0 || e.headerContents.size > 0 || e.toolbarButtons.size > 0 || e.lightDomButtons.length > 0 || e.lightDomHeaderContent.length > 0);
906
914
  }
907
- function Ve(o, e) {
908
- const t = o?.header?.title ?? "", n = !!t, i = o?.header?.toolbarButtons ?? [], s = i.length > 0, r = e.toolbarButtons.size > 0, a = e.lightDomButtons.length > 0, l = e.toolPanels.size > 0, p = (s || r || a) && l, g = [...i].sort((d, b) => (d.order ?? 100) - (b.order ?? 100)), h = [...e.toolbarButtons.values()].sort((d, b) => (d.order ?? 100) - (b.order ?? 100)), c = [...e.toolPanels.values()].sort((d, b) => (d.order ?? 100) - (b.order ?? 100));
909
- let u = "";
910
- for (const d of g)
911
- d.icon && d.action && (u += `<button class="tbw-toolbar-btn" data-btn="${d.id}" title="${d.label}" aria-label="${d.label}"${d.disabled ? " disabled" : ""}>${d.icon}</button>`);
912
- for (const d of h)
913
- d.icon && d.action && (u += `<button class="tbw-toolbar-btn" data-btn="${d.id}" title="${d.label}" aria-label="${d.label}"${d.disabled ? " disabled" : ""}>${d.icon}</button>`);
914
- for (const d of g)
915
- (d.element || d.render) && (u += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${d.id}"></div>`);
916
- for (const d of h)
917
- (d.element || d.render) && (u += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${d.id}"></div>`);
918
- a && (u += '<slot name="toolbar"></slot>'), p && (u += '<div class="tbw-toolbar-separator"></div>');
919
- for (const d of c) {
920
- const b = e.activePanel === d.id;
921
- u += `<button class="tbw-toolbar-btn${b ? " active" : ""}" data-panel="${d.id}" title="${d.tooltip ?? d.title}" aria-label="${d.tooltip ?? d.title}" aria-pressed="${b}" aria-controls="tbw-panel-${d.id}">${d.icon}</button>`;
915
+ function Ue(o, e, t = "☰") {
916
+ const n = o?.header?.title ?? "", s = !!n, i = z(t), r = o?.header?.toolbarButtons ?? [], a = r.length > 0, l = e.toolbarButtons.size > 0, d = e.lightDomButtons.length > 0, u = e.toolPanels.size > 0, h = (a || l || d) && u, c = [...r].sort((w, m) => (w.order ?? 100) - (m.order ?? 100)), f = [...e.toolbarButtons.values()].sort((w, m) => (w.order ?? 100) - (m.order ?? 100));
917
+ let p = "";
918
+ for (const w of c)
919
+ w.icon && w.action && (p += `<button class="tbw-toolbar-btn" data-btn="${w.id}" title="${w.label}" aria-label="${w.label}"${w.disabled ? " disabled" : ""}>${w.icon}</button>`);
920
+ for (const w of f)
921
+ w.icon && w.action && (p += `<button class="tbw-toolbar-btn" data-btn="${w.id}" title="${w.label}" aria-label="${w.label}"${w.disabled ? " disabled" : ""}>${w.icon}</button>`);
922
+ for (const w of c)
923
+ (w.element || w.render) && (p += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${w.id}"></div>`);
924
+ for (const w of f)
925
+ (w.element || w.render) && (p += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${w.id}"></div>`);
926
+ if (d && (p += '<slot name="toolbar"></slot>'), h && (p += '<div class="tbw-toolbar-separator"></div>'), u) {
927
+ const w = e.isPanelOpen;
928
+ p += `<button class="tbw-toolbar-btn${w ? " active" : ""}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${w}" aria-controls="tbw-tool-panel">${i}</button>`;
922
929
  }
923
930
  return `
924
931
  <div class="tbw-shell-header" part="shell-header" role="banner">
925
- ${n ? `<div class="tbw-shell-title">${t}</div>` : ""}
932
+ ${s ? `<div class="tbw-shell-title">${n}</div>` : ""}
926
933
  <div class="tbw-shell-content" part="shell-content" role="region" aria-label="Grid information">
927
934
  <slot name="header-content"></slot>
928
935
  </div>
929
936
  <div class="tbw-shell-toolbar" part="shell-toolbar" role="toolbar" aria-label="Grid tools">
930
- ${u}
937
+ ${p}
931
938
  </div>
932
939
  </div>
933
940
  `;
934
941
  }
935
- function Ge(o, e, t) {
936
- const n = o?.toolPanel?.position ?? "right", i = e.toolPanels.size > 0, s = e.activePanel !== null, r = e.activePanel ? e.toolPanels.get(e.activePanel) : null, a = i ? `
937
- <aside class="tbw-tool-panel${s ? " open" : ""}" part="tool-panel" data-position="${n}" role="complementary" aria-label="${r?.title ?? "Tool panel"}" id="tbw-panel-${e.activePanel ?? "closed"}">
938
- <div class="tbw-tool-panel-header">
939
- <span class="tbw-tool-panel-title">${r?.title ?? ""}</span>
940
- <button class="tbw-tool-panel-close" aria-label="Close panel">✕</button>
942
+ function Xe(o, e, t, n) {
943
+ const s = o?.toolPanel?.position ?? "right", i = e.toolPanels.size > 0, r = e.isPanelOpen, a = z(n?.expand ?? S.expand), l = z(n?.collapse ?? S.collapse), d = [...e.toolPanels.values()].sort((f, p) => (f.order ?? 100) - (p.order ?? 100)), u = d.length === 1;
944
+ let g = "";
945
+ for (const f of d) {
946
+ const p = e.expandedSections.has(f.id), w = f.icon ? `<span class="tbw-accordion-icon">${f.icon}</span>` : "", m = u ? "" : `<span class="tbw-accordion-chevron">${p ? l : a}</span>`;
947
+ g += `
948
+ <div class="${`tbw-accordion-section${p ? " expanded" : ""}${u ? " single" : ""}`}" data-section="${f.id}">
949
+ <button class="tbw-accordion-header" aria-expanded="${p}" aria-controls="tbw-section-${f.id}"${u ? ' aria-disabled="true"' : ""}>
950
+ ${w}
951
+ <span class="tbw-accordion-title">${f.title}</span>
952
+ ${m}
953
+ </button>
954
+ <div class="tbw-accordion-content" id="tbw-section-${f.id}" role="region" aria-labelledby="tbw-section-header-${f.id}"></div>
955
+ </div>
956
+ `;
957
+ }
958
+ const c = i ? `
959
+ <aside class="tbw-tool-panel${r ? " open" : ""}" part="tool-panel" data-position="${s}" role="complementary" aria-label="Tool panel" id="tbw-tool-panel">
960
+ <div class="tbw-tool-panel-resize" data-resize-handle data-handle-position="${s === "left" ? "right" : "left"}" aria-hidden="true"></div>
961
+ <div class="tbw-tool-panel-content" role="region">
962
+ <div class="tbw-accordion">
963
+ ${g}
964
+ </div>
941
965
  </div>
942
- <div class="tbw-tool-panel-content" role="region"></div>
943
966
  </aside>
944
967
  ` : "";
945
- return n === "left" ? `
968
+ return s === "left" ? `
946
969
  <div class="tbw-shell-body">
947
- ${a}
970
+ ${c}
948
971
  <div class="tbw-grid-content">
949
972
  ${t}
950
973
  </div>
@@ -954,99 +977,130 @@ function Ge(o, e, t) {
954
977
  <div class="tbw-grid-content">
955
978
  ${t}
956
979
  </div>
957
- ${a}
980
+ ${c}
958
981
  </div>
959
982
  `;
960
983
  }
961
- function ee(o, e) {
984
+ function oe(o, e) {
962
985
  const t = o.querySelector("tbw-grid-header");
963
986
  if (!t) return;
964
987
  t.style.display = "none";
965
988
  const n = t.querySelectorAll("tbw-grid-header-content");
966
- e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((s, r) => {
967
- s.setAttribute("slot", "header-content");
989
+ e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((i) => {
990
+ i.setAttribute("slot", "header-content");
968
991
  });
969
- const i = t.querySelectorAll("tbw-grid-tool-button");
970
- e.lightDomButtons = Array.from(i), e.lightDomButtons.sort((s, r) => {
971
- const a = parseInt(s.getAttribute("order") ?? "100", 10), l = parseInt(r.getAttribute("order") ?? "100", 10);
992
+ const s = t.querySelectorAll("tbw-grid-tool-button");
993
+ e.lightDomButtons = Array.from(s), e.lightDomButtons.sort((i, r) => {
994
+ const a = parseInt(i.getAttribute("order") ?? "100", 10), l = parseInt(r.getAttribute("order") ?? "100", 10);
972
995
  return a - l;
973
- }), e.lightDomButtons.forEach((s) => {
974
- s.setAttribute("slot", "toolbar");
996
+ }), e.lightDomButtons.forEach((i) => {
997
+ i.setAttribute("slot", "toolbar");
975
998
  });
976
999
  }
977
- function Ue(o, e, t, n) {
978
- const i = o.querySelector(".tbw-shell-toolbar");
979
- i && i.addEventListener("click", (r) => {
980
- const a = r.target, l = a.closest("[data-panel]");
981
- if (l) {
982
- const p = l.getAttribute("data-panel");
983
- p && n.onPanelToggle(p);
1000
+ function je(o, e, t, n) {
1001
+ const s = o.querySelector(".tbw-shell-toolbar");
1002
+ s && s.addEventListener("click", (r) => {
1003
+ const a = r.target;
1004
+ if (a.closest("[data-panel-toggle]")) {
1005
+ n.onPanelToggle();
984
1006
  return;
985
1007
  }
986
- const f = a.closest("[data-btn]");
987
- if (f) {
988
- const p = f.getAttribute("data-btn");
989
- p && n.onToolbarButtonClick(p);
1008
+ const d = a.closest("[data-btn]");
1009
+ if (d) {
1010
+ const u = d.getAttribute("data-btn");
1011
+ u && n.onToolbarButtonClick(u);
990
1012
  }
991
1013
  });
992
- const s = o.querySelector(".tbw-tool-panel-close");
993
- s && s.addEventListener("click", () => {
994
- n.onPanelClose();
1014
+ const i = o.querySelector(".tbw-accordion");
1015
+ i && i.addEventListener("click", (r) => {
1016
+ const l = r.target.closest(".tbw-accordion-header");
1017
+ if (l) {
1018
+ const u = l.closest("[data-section]")?.getAttribute("data-section");
1019
+ u && n.onSectionToggle(u);
1020
+ }
995
1021
  });
996
1022
  }
997
- function Xe(o, e, t) {
1023
+ function Ye(o, e, t) {
1024
+ const n = o.querySelector(".tbw-tool-panel"), s = o.querySelector("[data-resize-handle]"), i = o.querySelector(".tbw-shell-body");
1025
+ if (!n || !s || !i)
1026
+ return () => {
1027
+ };
1028
+ const r = e?.toolPanel?.position ?? "right", a = 200;
1029
+ let l = 0, d = 0, u = 0, g = !1;
1030
+ const h = (p) => {
1031
+ if (!g) return;
1032
+ p.preventDefault();
1033
+ const w = r === "left" ? p.clientX - l : l - p.clientX, m = Math.min(u, Math.max(a, d + w));
1034
+ n.style.width = `${m}px`;
1035
+ }, c = () => {
1036
+ if (!g) return;
1037
+ g = !1, s.classList.remove("resizing"), n.style.transition = "", document.body.style.cursor = "", document.body.style.userSelect = "";
1038
+ const p = n.getBoundingClientRect().width;
1039
+ t(p), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", c);
1040
+ }, f = (p) => {
1041
+ p.preventDefault(), g = !0, l = p.clientX, d = n.getBoundingClientRect().width, u = i.getBoundingClientRect().width - 20, s.classList.add("resizing"), n.style.transition = "none", document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", h), document.addEventListener("mouseup", c);
1042
+ };
1043
+ return s.addEventListener("mousedown", f), () => {
1044
+ s.removeEventListener("mousedown", f), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", c);
1045
+ };
1046
+ }
1047
+ function Ze(o, e, t) {
998
1048
  const n = [...e?.header?.toolbarButtons ?? [], ...t.toolbarButtons.values()];
999
- for (const i of n) {
1000
- const s = o.querySelector(`[data-btn-slot="${i.id}"]`);
1001
- if (!s) continue;
1002
- const r = t.toolbarButtonCleanups.get(i.id);
1003
- if (r && (r(), t.toolbarButtonCleanups.delete(i.id)), i.element)
1004
- s.appendChild(i.element);
1005
- else if (i.render) {
1006
- const a = i.render(s);
1007
- a && t.toolbarButtonCleanups.set(i.id, a);
1049
+ for (const s of n) {
1050
+ const i = o.querySelector(`[data-btn-slot="${s.id}"]`);
1051
+ if (!i) continue;
1052
+ const r = t.toolbarButtonCleanups.get(s.id);
1053
+ if (r && (r(), t.toolbarButtonCleanups.delete(s.id)), s.element)
1054
+ i.appendChild(s.element);
1055
+ else if (s.render) {
1056
+ const a = s.render(i);
1057
+ a && t.toolbarButtonCleanups.set(s.id, a);
1008
1058
  }
1009
1059
  }
1010
1060
  }
1011
- function te(o, e) {
1061
+ function ne(o, e) {
1012
1062
  const t = o.querySelector(".tbw-shell-content");
1013
1063
  if (!t) return;
1014
- const n = [...e.headerContents.values()].sort((s, r) => (s.order ?? 100) - (r.order ?? 100)), i = t.querySelector('slot[name="header-content"]');
1015
- for (const s of n) {
1016
- const r = e.headerContentCleanups.get(s.id);
1017
- r && (r(), e.headerContentCleanups.delete(s.id));
1018
- let a = t.querySelector(`[data-header-content="${s.id}"]`);
1019
- a || (a = document.createElement("div"), a.setAttribute("data-header-content", s.id), i ? t.insertBefore(a, i) : t.appendChild(a));
1020
- const l = s.render(a);
1021
- l && e.headerContentCleanups.set(s.id, l);
1064
+ const n = [...e.headerContents.values()].sort((i, r) => (i.order ?? 100) - (r.order ?? 100)), s = t.querySelector('slot[name="header-content"]');
1065
+ for (const i of n) {
1066
+ const r = e.headerContentCleanups.get(i.id);
1067
+ r && (r(), e.headerContentCleanups.delete(i.id));
1068
+ let a = t.querySelector(`[data-header-content="${i.id}"]`);
1069
+ a || (a = document.createElement("div"), a.setAttribute("data-header-content", i.id), s ? t.insertBefore(a, s) : t.appendChild(a));
1070
+ const l = i.render(a);
1071
+ l && e.headerContentCleanups.set(i.id, l);
1072
+ }
1073
+ }
1074
+ function Je(o, e, t) {
1075
+ if (!e.isPanelOpen) return;
1076
+ const n = z(t?.expand ?? S.expand), s = z(t?.collapse ?? S.collapse);
1077
+ for (const [i, r] of e.toolPanels) {
1078
+ const a = e.expandedSections.has(i), l = o.querySelector(`[data-section="${i}"]`), d = l?.querySelector(".tbw-accordion-content");
1079
+ if (!l || !d) continue;
1080
+ l.classList.toggle("expanded", a);
1081
+ const u = l.querySelector(".tbw-accordion-header");
1082
+ u && u.setAttribute("aria-expanded", String(a));
1083
+ const g = l.querySelector(".tbw-accordion-chevron");
1084
+ if (g && (g.innerHTML = a ? s : n), a) {
1085
+ if (d.children.length === 0) {
1086
+ const h = r.render(d);
1087
+ h && e.panelCleanups.set(i, h);
1088
+ }
1089
+ } else {
1090
+ const h = e.panelCleanups.get(i);
1091
+ h && (h(), e.panelCleanups.delete(i)), d.innerHTML = "";
1092
+ }
1022
1093
  }
1023
1094
  }
1024
- function je(o, e) {
1025
- if (!e.activePanel) return;
1026
- const t = e.toolPanels.get(e.activePanel);
1027
- if (!t) return;
1028
- const n = o.querySelector(".tbw-tool-panel-content");
1029
- if (!n) return;
1030
- e.activePanelCleanup && (e.activePanelCleanup(), e.activePanelCleanup = null), n.innerHTML = "";
1031
- const i = t.render(n);
1032
- i && (e.activePanelCleanup = i);
1033
- }
1034
- function oe(o, e) {
1035
- o.querySelectorAll("[data-panel]").forEach((n) => {
1036
- const s = n.getAttribute("data-panel") === e.activePanel;
1037
- n.classList.toggle("active", s), n.setAttribute("aria-pressed", String(s));
1038
- });
1095
+ function se(o, e) {
1096
+ const t = o.querySelector("[data-panel-toggle]");
1097
+ t && (t.classList.toggle("active", e.isPanelOpen), t.setAttribute("aria-pressed", String(e.isPanelOpen)));
1039
1098
  }
1040
- function ne(o, e) {
1099
+ function ie(o, e) {
1041
1100
  const t = o.querySelector(".tbw-tool-panel");
1042
- if (!t) return;
1043
- const n = e.activePanel !== null;
1044
- if (t.classList.toggle("open", n), n && e.activePanel) {
1045
- const i = e.toolPanels.get(e.activePanel), s = t.querySelector(".tbw-tool-panel-title");
1046
- s && (s.textContent = i?.title ?? ""), t.setAttribute("aria-label", `${i?.title ?? "Tool"} panel`), t.id = `tbw-panel-${e.activePanel}`;
1047
- }
1101
+ t && (t.classList.toggle("open", e.isPanelOpen), e.isPanelOpen || (t.style.width = ""));
1048
1102
  }
1049
- function Ye(o, e) {
1103
+ function Qe(o, e) {
1050
1104
  const t = [];
1051
1105
  for (const n of o?.header?.toolbarButtons ?? [])
1052
1106
  t.push({
@@ -1063,11 +1117,11 @@ function Ye(o, e) {
1063
1117
  source: "config"
1064
1118
  });
1065
1119
  for (let n = 0; n < e.lightDomButtons.length; n++) {
1066
- const s = e.lightDomButtons[n].querySelector("button");
1120
+ const i = e.lightDomButtons[n].querySelector("button");
1067
1121
  t.push({
1068
1122
  id: `light-dom-${n}`,
1069
- label: s?.getAttribute("title") ?? s?.getAttribute("aria-label") ?? "",
1070
- disabled: s?.disabled ?? !1,
1123
+ label: i?.getAttribute("title") ?? i?.getAttribute("aria-label") ?? "",
1124
+ disabled: i?.disabled ?? !1,
1071
1125
  source: "light-dom"
1072
1126
  });
1073
1127
  }
@@ -1081,7 +1135,7 @@ function Ye(o, e) {
1081
1135
  });
1082
1136
  return t;
1083
1137
  }
1084
- function Ze(o) {
1138
+ function et(o) {
1085
1139
  for (const e of o.headerContentCleanups.values())
1086
1140
  e();
1087
1141
  o.headerContentCleanups.clear(), o.activePanelCleanup && (o.activePanelCleanup(), o.activePanelCleanup = null);
@@ -1089,7 +1143,7 @@ function Ze(o) {
1089
1143
  e();
1090
1144
  o.toolbarButtonCleanups.clear(), o.activePanel && o.toolPanels.get(o.activePanel)?.onClose?.(), o.toolPanels.clear(), o.headerContents.clear(), o.toolbarButtons.clear(), o.lightDomButtons = [], o.lightDomHeaderContent = [], o.activePanel = null;
1091
1145
  }
1092
- class Je {
1146
+ class tt {
1093
1147
  constructor(e) {
1094
1148
  this.grid = e;
1095
1149
  }
@@ -1248,21 +1302,21 @@ class Je {
1248
1302
  * Returns the minimum start index from all plugins.
1249
1303
  */
1250
1304
  adjustVirtualStart(e, t, n) {
1251
- let i = e;
1252
- for (const s of this.plugins)
1253
- if (typeof s.adjustVirtualStart == "function") {
1254
- const r = s.adjustVirtualStart(e, t, n);
1255
- r < i && (i = r);
1305
+ let s = e;
1306
+ for (const i of this.plugins)
1307
+ if (typeof i.adjustVirtualStart == "function") {
1308
+ const r = i.adjustVirtualStart(e, t, n);
1309
+ r < s && (s = r);
1256
1310
  }
1257
- return i;
1311
+ return s;
1258
1312
  }
1259
1313
  /**
1260
1314
  * Execute renderRow hook on all plugins.
1261
1315
  * Returns true if any plugin handled the row.
1262
1316
  */
1263
1317
  renderRow(e, t, n) {
1264
- for (const i of this.plugins)
1265
- if (i.renderRow?.(e, t, n))
1318
+ for (const s of this.plugins)
1319
+ if (s.renderRow?.(e, t, n))
1266
1320
  return !0;
1267
1321
  return !1;
1268
1322
  }
@@ -1349,8 +1403,8 @@ class Je {
1349
1403
  getContextMenuItems(e) {
1350
1404
  const t = [];
1351
1405
  for (const n of this.plugins) {
1352
- const i = n.getContextMenuItems?.(e);
1353
- i && t.push(...i);
1406
+ const s = n.getContextMenuItems?.(e);
1407
+ s && t.push(...s);
1354
1408
  }
1355
1409
  return t;
1356
1410
  }
@@ -1380,14 +1434,14 @@ class Je {
1380
1434
  return e.sort((t, n) => (t.content.order ?? 0) - (n.content.order ?? 0));
1381
1435
  }
1382
1436
  }
1383
- class I extends HTMLElement {
1437
+ class $ extends HTMLElement {
1384
1438
  // TODO: Rename to 'data-grid' when migration is complete
1385
1439
  static tagName = "tbw-grid";
1386
- #o;
1440
+ #n;
1387
1441
  #i = !1;
1388
1442
  // ---------------- Ready Promise ----------------
1389
- #z;
1390
- #N;
1443
+ #I;
1444
+ #$;
1391
1445
  // ================== INPUT PROPERTIES ==================
1392
1446
  // These backing fields store raw user input. They are merged into
1393
1447
  // #effectiveConfig by #mergeEffectiveConfig(). Never read directly
@@ -1396,44 +1450,48 @@ class I extends HTMLElement {
1396
1450
  #l;
1397
1451
  #g;
1398
1452
  #v;
1399
- #C;
1453
+ #y;
1400
1454
  // ================== SINGLE SOURCE OF TRUTH ==================
1401
1455
  // All input sources converge here. This is the canonical config
1402
1456
  // that all rendering and logic should read from.
1403
- #n = {};
1457
+ #o = {};
1404
1458
  #f = !1;
1405
1459
  #p = 0;
1406
- #E = null;
1407
- #y = !1;
1460
+ #C = null;
1461
+ #E = !1;
1408
1462
  // Cached flag for plugin scroll handlers
1409
- #k;
1463
+ #P;
1410
1464
  // Cached hook to avoid closures
1411
1465
  #R = !1;
1412
1466
  #_ = null;
1413
- #A = null;
1414
- #S = null;
1415
1467
  #x = null;
1468
+ #S = null;
1469
+ #A = null;
1416
1470
  #a;
1417
1471
  #w;
1418
1472
  // ---------------- Plugin System ----------------
1419
1473
  #t;
1420
1474
  // ---------------- Column State ----------------
1421
- #P;
1475
+ #M;
1422
1476
  #h;
1423
1477
  // ---------------- Shell State ----------------
1424
- #e = We();
1478
+ #e = Fe();
1425
1479
  #c = !1;
1480
+ #T;
1426
1481
  // ================== DERIVED STATE ==================
1427
1482
  // _rows: result of applying plugin processRows hooks
1428
1483
  _rows = [];
1484
+ // _baseColumns: columns before plugin transformation (analogous to #rows for row processing)
1485
+ // This is the source of truth for processColumns - plugins transform these
1486
+ #O = [];
1429
1487
  // _columns is a getter/setter that operates on effectiveConfig.columns
1430
1488
  // This ensures effectiveConfig.columns is the single source of truth for columns
1431
1489
  // _columns always contains ALL columns (including hidden)
1432
1490
  get _columns() {
1433
- return this.#n.columns ?? [];
1491
+ return this.#o.columns ?? [];
1434
1492
  }
1435
1493
  set _columns(e) {
1436
- this.#n.columns = e;
1494
+ this.#o.columns = e;
1437
1495
  }
1438
1496
  // visibleColumns returns only visible columns for rendering
1439
1497
  // This is what header/row rendering should use
@@ -1483,7 +1541,7 @@ class I extends HTMLElement {
1483
1541
  }
1484
1542
  set rows(e) {
1485
1543
  const t = this.#r;
1486
- this.#r = e, t !== e && this.#Z();
1544
+ this.#r = e, t !== e && this.#ee();
1487
1545
  }
1488
1546
  /**
1489
1547
  * Get the original unfiltered/unprocessed rows.
@@ -1497,34 +1555,34 @@ class I extends HTMLElement {
1497
1555
  }
1498
1556
  set columns(e) {
1499
1557
  const t = this.#l;
1500
- this.#l = e, t !== e && this.#J();
1558
+ this.#l = e, t !== e && this.#te();
1501
1559
  }
1502
1560
  get gridConfig() {
1503
- return this.#n;
1561
+ return this.#o;
1504
1562
  }
1505
1563
  set gridConfig(e) {
1506
1564
  const t = this.#g;
1507
- this.#g = e, t !== e && this.#Q();
1565
+ this.#g = e, t !== e && this.#oe();
1508
1566
  }
1509
1567
  get fitMode() {
1510
- return this.#n.fitMode ?? "stretch";
1568
+ return this.#o.fitMode ?? "stretch";
1511
1569
  }
1512
1570
  set fitMode(e) {
1513
1571
  const t = this.#v;
1514
- this.#v = e, t !== e && this.#j();
1572
+ this.#v = e, t !== e && this.#J();
1515
1573
  }
1516
1574
  get editOn() {
1517
- return this.#n.editOn;
1575
+ return this.#o.editOn;
1518
1576
  }
1519
1577
  set editOn(e) {
1520
- const t = this.#C;
1521
- this.#C = e, t !== e && this.#Y();
1578
+ const t = this.#y;
1579
+ this.#y = e, t !== e && this.#Q();
1522
1580
  }
1523
1581
  // Effective config accessor for internal modules and plugins
1524
1582
  // Returns the merged config (single source of truth) before plugin processing
1525
1583
  // Use this when you need the raw merged config (e.g., for column definitions including hidden)
1526
1584
  get effectiveConfig() {
1527
- return this.#n;
1585
+ return this.#o;
1528
1586
  }
1529
1587
  /**
1530
1588
  * Get the disconnect signal for event listener cleanup.
@@ -1537,11 +1595,11 @@ class I extends HTMLElement {
1537
1595
  return this.#a || (this.#a = new AbortController()), this.#a.signal;
1538
1596
  }
1539
1597
  constructor() {
1540
- super(), this.#o = this.attachShadow({ mode: "open" }), this.#V(), this.#z = new Promise((e) => this.#N = e);
1598
+ super(), this.#n = this.attachShadow({ mode: "open" }), this.#X(), this.#I = new Promise((e) => this.#$ = e);
1541
1599
  }
1542
- #V() {
1600
+ #X() {
1543
1601
  const e = new CSSStyleSheet();
1544
- e.replaceSync(we), this.#o.adoptedStyleSheets = [e];
1602
+ e.replaceSync(me), this.#n.adoptedStyleSheets = [e];
1545
1603
  }
1546
1604
  // ---------------- Plugin System ----------------
1547
1605
  /**
@@ -1564,7 +1622,7 @@ class I extends HTMLElement {
1564
1622
  * Note: This does NOT reset plugin state - just re-processes rows/columns and renders.
1565
1623
  */
1566
1624
  requestRender() {
1567
- this.#L(), this.#M(), this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0);
1625
+ this.#k(), this.#H(), this.#L(), this.updateTemplate(), this.refreshVirtualWindow(!0);
1568
1626
  }
1569
1627
  /**
1570
1628
  * Request a lightweight style update without rebuilding DOM.
@@ -1578,40 +1636,40 @@ class I extends HTMLElement {
1578
1636
  * Initialize plugin system with instances from config.
1579
1637
  * Plugins are class instances passed in gridConfig.plugins[].
1580
1638
  */
1581
- #I() {
1582
- this.#t = new Je(this);
1583
- const e = this.#n?.plugins, t = Array.isArray(e) ? e : [];
1639
+ #B() {
1640
+ this.#t = new tt(this);
1641
+ const e = this.#o?.plugins, t = Array.isArray(e) ? e : [];
1584
1642
  this.#t.attachAll(t);
1585
1643
  }
1586
1644
  /**
1587
1645
  * Inject all plugin styles into the shadow DOM.
1588
1646
  * Must be called after #render() since innerHTML wipes existing content.
1589
1647
  */
1590
- #q() {
1648
+ #W() {
1591
1649
  const e = this.#t?.getAllStyles() ?? "";
1592
1650
  if (e) {
1593
1651
  const t = document.createElement("style");
1594
- t.setAttribute("data-plugin", "all"), t.textContent = e, this.#o.appendChild(t);
1652
+ t.setAttribute("data-plugin", "all"), t.textContent = e, this.#n.appendChild(t);
1595
1653
  }
1596
1654
  }
1597
1655
  /**
1598
1656
  * Update plugins when grid config changes.
1599
1657
  * With class-based plugins, we need to detach old and attach new.
1600
1658
  */
1601
- #B() {
1602
- this.#t && this.#t.detachAll(), this.#I(), this.#q(), this.#y = this.#t?.getAll().some((e) => e.onScroll) ?? !1;
1659
+ #K() {
1660
+ this.#t && this.#t.detachAll(), this.#B(), this.#W(), this.#E = this.#t?.getAll().some((e) => e.onScroll) ?? !1;
1603
1661
  }
1604
1662
  /**
1605
1663
  * Clean up plugin states when grid disconnects.
1606
1664
  */
1607
- #G() {
1665
+ #j() {
1608
1666
  this.#t?.detachAll();
1609
1667
  }
1610
1668
  /**
1611
1669
  * Collect tool panels and header content from all plugins.
1612
1670
  * Called after plugins are attached but before render.
1613
1671
  */
1614
- #U() {
1672
+ #Y() {
1615
1673
  if (!this.#t) return;
1616
1674
  const e = this.#t.getToolPanels();
1617
1675
  for (const { panel: n } of e)
@@ -1622,24 +1680,24 @@ class I extends HTMLElement {
1622
1680
  }
1623
1681
  // ---------------- Lifecycle ----------------
1624
1682
  connectedCallback() {
1625
- this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#a?.abort(), this.#a = new AbortController(), this.#u(), this.#I(), this.#U(), this.#i || (this.#F(), this.#q(), this.#i = !0), this.#$();
1683
+ this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#a?.abort(), this.#a = new AbortController(), this.#u(), this.#B(), this.#Y(), this.#i || (this.#U(), this.#W(), this.#i = !0), this.#V();
1626
1684
  }
1627
1685
  disconnectedCallback() {
1628
- this.#G(), Ze(this.#e), this.#c = !1, this.#a && (this.#a.abort(), this.#a = void 0), this.resizeController && this.resizeController.dispose(), this.#w && (this.#w.disconnect(), this.#w = void 0), this.#f = !1;
1686
+ this.#j(), et(this.#e), this.#c = !1, this.#T?.(), this.#T = void 0, this.#a && (this.#a.abort(), this.#a = void 0), this.resizeController && this.resizeController.dispose(), this.#w && (this.#w.disconnect(), this.#w = void 0), this.#f = !1;
1629
1687
  }
1630
- #$() {
1631
- const t = this.#o.querySelector(".tbw-grid-content") ?? this.#o.querySelector(".tbw-grid-root");
1688
+ #V() {
1689
+ const t = this.#n.querySelector(".tbw-grid-content") ?? this.#n.querySelector(".tbw-grid-root");
1632
1690
  if (this.headerRowEl = t?.querySelector(".header-row"), this.virtualization.totalHeightEl = t?.querySelector(".faux-vscroll-spacer"), this.virtualization.viewportEl = t?.querySelector(".rows-viewport"), this.bodyEl = t?.querySelector(".rows"), this.#c) {
1633
- te(this.#o, this.#e), Xe(this.#o, this.#n?.shell, this.#e);
1634
- const r = this.#n?.shell?.toolPanel?.defaultOpen;
1635
- r && this.#e.toolPanels.has(r) && this.openToolPanel(r);
1691
+ ne(this.#n, this.#e), Ze(this.#n, this.#o?.shell, this.#e);
1692
+ const r = this.#o?.shell?.toolPanel?.defaultOpen;
1693
+ r && this.#e.toolPanels.has(r) && (this.openToolPanel(), this.#e.expandedSections.add(r));
1636
1694
  }
1637
1695
  this.setAttribute("data-upgraded", ""), this.hasAttribute("role") || this.setAttribute("role", "grid"), this.#f = !0;
1638
1696
  const n = this.disconnectSignal;
1639
- this.#d(), this.addEventListener("keydown", (r) => ze(this, r), { signal: n }), document.addEventListener(
1697
+ this.#d(), this.addEventListener("keydown", (r) => qe(this, r), { signal: n }), document.addEventListener(
1640
1698
  "keydown",
1641
1699
  (r) => {
1642
- r.key === "Escape" && this.activeEditRows !== -1 && this.#O(this.activeEditRows, !0);
1700
+ r.key === "Escape" && this.activeEditRows !== -1 && this.#D(this.activeEditRows, !0);
1643
1701
  },
1644
1702
  { capture: !0, signal: n }
1645
1703
  ), document.addEventListener(
@@ -1647,54 +1705,54 @@ class I extends HTMLElement {
1647
1705
  (r) => {
1648
1706
  if (this.activeEditRows === -1) return;
1649
1707
  const a = this.findRenderedRowElement(this.activeEditRows);
1650
- !a || (r.composedPath && r.composedPath() || []).includes(a) || this.#O(this.activeEditRows, !1);
1708
+ !a || (r.composedPath && r.composedPath() || []).includes(a) || this.#D(this.activeEditRows, !1);
1651
1709
  },
1652
1710
  { signal: n }
1653
1711
  );
1654
- const i = t?.querySelector(".faux-vscroll"), s = t?.querySelector(".rows");
1655
- if (this.virtualization.container = i ?? this, this.#y = this.#t?.getAll().some((r) => r.onScroll) ?? !1, i && s) {
1656
- i.addEventListener(
1712
+ const s = t?.querySelector(".faux-vscroll"), i = t?.querySelector(".rows");
1713
+ if (this.virtualization.container = s ?? this, this.#E = this.#t?.getAll().some((r) => r.onScroll) ?? !1, s && i) {
1714
+ s.addEventListener(
1657
1715
  "scroll",
1658
1716
  () => {
1659
- if (!this.virtualization.enabled && !this.#y) return;
1660
- const l = i.scrollTop, f = this.virtualization.rowHeight, p = Math.floor(l / f), g = p - p % 2, h = -(l - g * f);
1661
- s.style.transform = `translateY(${h}px)`, this.#E = l, this.#p || (this.#p = requestAnimationFrame(() => {
1662
- this.#p = 0, this.#E !== null && (this.#ne(this.#E), this.#E = null);
1717
+ if (!this.virtualization.enabled && !this.#E) return;
1718
+ const l = s.scrollTop, d = this.virtualization.rowHeight, u = Math.floor(l / d), g = u - u % 2, h = -(l - g * d);
1719
+ i.style.transform = `translateY(${h}px)`, this.#C = l, this.#p || (this.#p = requestAnimationFrame(() => {
1720
+ this.#p = 0, this.#C !== null && (this.#re(this.#C), this.#C = null);
1663
1721
  }));
1664
1722
  },
1665
1723
  { passive: !0, signal: n }
1666
1724
  );
1667
- const r = this.#o.querySelector(".tbw-grid-content"), a = this.#o.querySelector(".tbw-scroll-area");
1725
+ const r = this.#n.querySelector(".tbw-grid-content"), a = this.#n.querySelector(".tbw-scroll-area");
1668
1726
  r && (r.addEventListener(
1669
1727
  "wheel",
1670
1728
  (l) => {
1671
- l.preventDefault(), l.shiftKey || Math.abs(l.deltaX) > Math.abs(l.deltaY) ? a && (a.scrollLeft += l.shiftKey ? l.deltaY : l.deltaX) : i.scrollTop += l.deltaY;
1729
+ l.preventDefault(), l.shiftKey || Math.abs(l.deltaX) > Math.abs(l.deltaY) ? a && (a.scrollLeft += l.shiftKey ? l.deltaY : l.deltaX) : s.scrollTop += l.deltaY;
1672
1730
  },
1673
1731
  { passive: !1, signal: n }
1674
1732
  ), r.addEventListener(
1675
1733
  "touchstart",
1676
1734
  (l) => {
1677
- l.touches.length === 1 && (this.#_ = l.touches[0].clientY, this.#A = l.touches[0].clientX, this.#S = i.scrollTop, this.#x = a?.scrollLeft ?? 0);
1735
+ l.touches.length === 1 && (this.#_ = l.touches[0].clientY, this.#x = l.touches[0].clientX, this.#S = s.scrollTop, this.#A = a?.scrollLeft ?? 0);
1678
1736
  },
1679
1737
  { passive: !0, signal: n }
1680
1738
  ), r.addEventListener(
1681
1739
  "touchmove",
1682
1740
  (l) => {
1683
- if (l.touches.length === 1 && this.#_ !== null && this.#A !== null && this.#S !== null && this.#x !== null) {
1684
- const f = this.#_ - l.touches[0].clientY, p = this.#A - l.touches[0].clientX;
1685
- i.scrollTop = this.#S + f, a && (a.scrollLeft = this.#x + p), l.preventDefault();
1741
+ if (l.touches.length === 1 && this.#_ !== null && this.#x !== null && this.#S !== null && this.#A !== null) {
1742
+ const d = this.#_ - l.touches[0].clientY, u = this.#x - l.touches[0].clientX;
1743
+ s.scrollTop = this.#S + d, a && (a.scrollLeft = this.#A + u), l.preventDefault();
1686
1744
  }
1687
1745
  },
1688
1746
  { passive: !1, signal: n }
1689
1747
  ), r.addEventListener(
1690
1748
  "touchend",
1691
1749
  () => {
1692
- this.#_ = null, this.#A = null, this.#S = null, this.#x = null;
1750
+ this.#_ = null, this.#x = null, this.#S = null, this.#A = null;
1693
1751
  },
1694
1752
  { passive: !0, signal: n }
1695
1753
  ));
1696
1754
  }
1697
- this.resizeController = Ke(this), this.#o.addEventListener("mousedown", (r) => this.#ie(r), { signal: n }), document.addEventListener("mousemove", (r) => this.#se(r), { signal: n }), document.addEventListener("mouseup", (r) => this.#re(r), { signal: n }), this.virtualization.enabled && requestAnimationFrame(() => this.refreshVirtualWindow(!0)), requestAnimationFrame(() => {
1755
+ this.resizeController = Ve(this), this.#n.addEventListener("mousedown", (r) => this.#le(r), { signal: n }), document.addEventListener("mousemove", (r) => this.#ae(r), { signal: n }), document.addEventListener("mouseup", (r) => this.#ce(r), { signal: n }), this.virtualization.enabled && requestAnimationFrame(() => this.refreshVirtualWindow(!0)), requestAnimationFrame(() => {
1698
1756
  const r = this.bodyEl.querySelector(".data-grid-row");
1699
1757
  if (r) {
1700
1758
  const a = r.getBoundingClientRect().height;
@@ -1704,7 +1762,7 @@ class I extends HTMLElement {
1704
1762
  this.#p || (this.#p = requestAnimationFrame(() => {
1705
1763
  this.#p = 0, this.refreshVirtualWindow(!0);
1706
1764
  }));
1707
- }), this.#w.observe(this.virtualization.viewportEl)), queueMicrotask(() => this.#X()), requestAnimationFrame(() => requestAnimationFrame(() => this.#N?.()));
1765
+ }), this.#w.observe(this.virtualization.viewportEl)), queueMicrotask(() => this.#Z()), requestAnimationFrame(() => requestAnimationFrame(() => this.#$?.()));
1708
1766
  }
1709
1767
  // ---------------- Event Emitters ----------------
1710
1768
  #s(e, t) {
@@ -1726,57 +1784,63 @@ class I extends HTMLElement {
1726
1784
  this.#s("activate-cell", e);
1727
1785
  }
1728
1786
  /** Update ARIA selection attributes on rendered rows/cells */
1729
- #X() {
1787
+ #Z() {
1730
1788
  this.bodyEl?.querySelectorAll(".data-grid-row")?.forEach((t, n) => {
1731
- const i = n === this.focusRow;
1732
- t.setAttribute("aria-selected", String(i)), t.querySelectorAll(".cell").forEach((s, r) => {
1733
- s.setAttribute("aria-selected", String(i && r === this.focusCol));
1789
+ const s = n === this.focusRow;
1790
+ t.setAttribute("aria-selected", String(s)), t.querySelectorAll(".cell").forEach((i, r) => {
1791
+ i.setAttribute("aria-selected", String(s && r === this.focusCol));
1734
1792
  });
1735
1793
  });
1736
1794
  }
1737
1795
  // ---------------- Watch Handlers ----------------
1738
- #j() {
1796
+ #J() {
1739
1797
  if (!this.#f) return;
1740
- this.#u(), this.#n.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, this.#K()) : (this._columns.forEach((t) => {
1798
+ this.#u(), this.#o.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, this.#F()) : (this._columns.forEach((t) => {
1741
1799
  !t.__userResized && t.__autoSized && delete t.width;
1742
1800
  }), this.updateTemplate());
1743
1801
  }
1744
- #Y() {
1802
+ #Q() {
1745
1803
  this.#f && (this.#u(), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
1746
1804
  }
1747
- #Z() {
1748
- this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#L(), !this.#l || Array.isArray(this.#l) && this.#l.length === 0 ? this.#d() : this.refreshVirtualWindow(!0);
1805
+ #ee() {
1806
+ this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#k(), !this.#l || Array.isArray(this.#l) && this.#l.length === 0 ? this.#d() : this.refreshVirtualWindow(!0);
1749
1807
  }
1750
- #J() {
1751
- j(this), this.#f && (this.#u(), this.#d());
1808
+ #te() {
1809
+ Z(this), this.#f && (this.#u(), this.#d());
1752
1810
  }
1753
- #Q() {
1754
- this.#f && (this.#u(), this.#B(), this.#L(), this.#M(), this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0));
1811
+ #oe() {
1812
+ this.#f && (this.#u(), this.#K(), this.#k(), this.#H(), this.#L(), this.updateTemplate(), this.refreshVirtualWindow(!0));
1755
1813
  }
1756
1814
  // ---------------- Helper Wrappers ----------------
1757
- #ee() {
1758
- He(this);
1815
+ #ne() {
1816
+ ze(this);
1759
1817
  }
1760
- #T() {
1761
- V(this);
1818
+ #L() {
1819
+ U(this);
1762
1820
  }
1763
1821
  updateTemplate() {
1764
- ue(this);
1822
+ pe(this);
1765
1823
  }
1766
- #K() {
1767
- Oe(this);
1824
+ #F() {
1825
+ De(this);
1768
1826
  }
1769
- #M() {
1827
+ #H() {
1770
1828
  if (this.#t) {
1771
- const e = this._columns.filter((n) => !n.hidden), t = this.#t.processColumns([...e]);
1772
- if (t !== e) {
1773
- const n = new Map(t.map((s, r) => [s.field, { col: s, order: r }])), i = this._columns.map((s) => {
1774
- if (s.hidden) return s;
1775
- const r = n.get(s.field);
1776
- return r ? r.col : s;
1777
- });
1778
- this._columns = i;
1779
- }
1829
+ const e = this.#O.length > 0 ? this.#O : this._columns, t = e.filter((i) => !i.hidden), n = e.filter((i) => i.hidden), s = this.#t.processColumns([...t]);
1830
+ if (s !== t) {
1831
+ const i = new Map(s.map((a, l) => [a.field, { col: a, order: l }]));
1832
+ if (!t.some((a) => i.has(a.field)) && s.length > 0)
1833
+ this._columns = [...s, ...n];
1834
+ else {
1835
+ const a = e.map((l) => {
1836
+ if (l.hidden) return l;
1837
+ const d = i.get(l.field);
1838
+ return d ? d.col : l;
1839
+ });
1840
+ this._columns = a;
1841
+ }
1842
+ } else
1843
+ this._columns = [...e];
1780
1844
  }
1781
1845
  }
1782
1846
  /** Execute all plugin afterRender hooks */
@@ -1784,8 +1848,8 @@ class I extends HTMLElement {
1784
1848
  this.#t?.afterRender();
1785
1849
  }
1786
1850
  /** Recompute row model via plugin hooks (grouping, tree, filtering, etc.). */
1787
- #L() {
1788
- j(this);
1851
+ #k() {
1852
+ Z(this);
1789
1853
  const e = Array.isArray(this.#r) ? [...this.#r] : [], t = this.#t?.processRows(e) ?? e;
1790
1854
  this._rows = t;
1791
1855
  }
@@ -1810,39 +1874,39 @@ class I extends HTMLElement {
1810
1874
  #u() {
1811
1875
  const e = this.#g ? { ...this.#g } : {};
1812
1876
  let t = Array.isArray(e.columns) ? [...e.columns] : [];
1813
- const n = (this.__lightDomColumnsCache || []).map((i) => ({
1814
- ...i
1877
+ const n = (this.__lightDomColumnsCache || []).map((s) => ({
1878
+ ...s
1815
1879
  }));
1816
1880
  if (n.length) {
1817
- const i = {};
1818
- t.forEach((s) => i[s.field] = s), n.forEach((s) => {
1819
- const r = i[s.field];
1820
- r ? (s.header && !r.header && (r.header = s.header), s.type && !r.type && (r.type = s.type), r.sortable = r.sortable || s.sortable, s.resizable && (r.resizable = !0), s.editable && (r.editable = !0)) : (t.push(s), i[s.field] = s);
1881
+ const s = {};
1882
+ t.forEach((i) => s[i.field] = i), n.forEach((i) => {
1883
+ const r = s[i.field];
1884
+ r ? (i.header && !r.header && (r.header = i.header), i.type && !r.type && (r.type = i.type), r.sortable = r.sortable || i.sortable, i.resizable && (r.resizable = !0), i.editable && (r.editable = !0)) : (t.push(i), s[i.field] = i);
1821
1885
  });
1822
1886
  }
1823
- if (this.#l && this.#l.length && (t = [...this.#l]), (!t || t.length === 0) && this._rows.length && (t = de(this._rows).columns), t.length) {
1887
+ if (this.#l && this.#l.length && (t = [...this.#l]), (!t || t.length === 0) && this._rows.length && (t = ue(this._rows).columns), t.length) {
1824
1888
  t.forEach((r) => {
1825
1889
  r.sortable === void 0 && (r.sortable = !0), r.resizable === void 0 && (r.resizable = !0);
1826
1890
  });
1827
- const i = this.#n.columns;
1828
- i?.some((r) => r.__compiledView || r.__compiledEditor) ? e.columns = i : e.columns = t;
1891
+ const s = this.#o.columns;
1892
+ s?.some((r) => r.__compiledView || r.__compiledEditor) ? e.columns = s : e.columns = t;
1829
1893
  } else {
1830
- const i = this.#n.columns;
1831
- i?.some((s) => s.__compiledView || s.__compiledEditor) && (e.columns = i);
1894
+ const s = this.#o.columns;
1895
+ s?.some((i) => i.__compiledView || i.__compiledEditor) && (e.columns = s);
1832
1896
  }
1833
- this.#v && (e.fitMode = this.#v), e.fitMode || (e.fitMode = "stretch"), this.#C && (e.editOn = this.#C), e.columnState && !this.#h && (this.#h = e.columnState), this.#n = e, e.fitMode === "fixed" && this._columns.forEach((i) => {
1834
- i.width == null && (i.width = 80);
1897
+ this.#v && (e.fitMode = this.#v), e.fitMode || (e.fitMode = "stretch"), this.#y && (e.editOn = this.#y), e.columnState && !this.#h && (this.#h = e.columnState), this.#o = e, e.fitMode === "fixed" && this._columns.forEach((s) => {
1898
+ s.width == null && (s.width = 80);
1835
1899
  });
1836
1900
  }
1837
1901
  // ---------------- Delegate Wrappers ----------------
1838
- #H(e, t, n = this.__rowRenderEpoch) {
1839
- this.#k || (this.#k = (i, s, r) => this.#t?.renderRow(i, s, r) ?? !1), qe(this, e, t, n, this.#k);
1902
+ #z(e, t, n = this.__rowRenderEpoch) {
1903
+ this.#P || (this.#P = (s, i, r) => this.#t?.renderRow(s, i, r) ?? !1), Be(this, e, t, n, this.#P);
1840
1904
  }
1841
- #te(e, t) {
1842
- T(this, e, t);
1905
+ #se(e, t) {
1906
+ L(this, e, t);
1843
1907
  }
1844
- #O(e, t) {
1845
- Be(this, e, t);
1908
+ #D(e, t) {
1909
+ We(this, e, t);
1846
1910
  }
1847
1911
  // ---------------- Core Helpers ----------------
1848
1912
  #d() {
@@ -1850,32 +1914,32 @@ class I extends HTMLElement {
1850
1914
  return;
1851
1915
  const e = this.#g?.columns || this.#l || [];
1852
1916
  if (e.length) {
1853
- const n = new Map(this._columns.filter((s) => s.hidden).map((s) => [s.field, !0])), i = e.map((s) => ({
1854
- ...s,
1855
- hidden: n.get(s.field) ?? s.hidden
1917
+ const n = new Map(this._columns.filter((i) => i.hidden).map((i) => [i.field, !0])), s = e.map((i) => ({
1918
+ ...i,
1919
+ hidden: n.get(i.field) ?? i.hidden
1856
1920
  }));
1857
- this._columns = i;
1921
+ this._columns = s;
1858
1922
  }
1859
- if (this.#ee(), this.#u(), this.#B(), this.#L(), this.#M(), this.#h) {
1923
+ if (this.#ne(), this.#u(), this.#K(), this.#O = [...this._columns], this.#k(), this.#H(), this.#h) {
1860
1924
  const n = this.#h;
1861
- this.#h = void 0, this.#W(n);
1925
+ this.#h = void 0, this.#G(n);
1862
1926
  }
1863
- this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0), this.#n.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => this.#K()), this.bodyEl && (this.bodyEl.style.display = "", this.bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#b());
1927
+ this.#L(), this.updateTemplate(), this.refreshVirtualWindow(!0), this.#o.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => this.#F()), this.bodyEl && (this.bodyEl.style.display = "", this.bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#b());
1864
1928
  }
1865
1929
  /** Internal method to apply column state without triggering setup loop */
1866
- #W(e) {
1867
- const t = this.#n.columns ?? [], n = this.#t?.getAll() ?? [];
1868
- me(this, e, t, n);
1869
- for (const i of e.columns) {
1870
- const s = t.find((r) => r.field === i.field);
1871
- s && (s.hidden = !i.visible);
1930
+ #G(e) {
1931
+ const t = this.#o.columns ?? [], n = this.#t?.getAll() ?? [];
1932
+ ye(this, e, t, n);
1933
+ for (const s of e.columns) {
1934
+ const i = t.find((r) => r.field === s.field);
1935
+ i && (i.hidden = !s.visible);
1872
1936
  }
1873
1937
  }
1874
- #oe() {
1938
+ #ie() {
1875
1939
  return this._rows.length <= this.virtualization.bypassThreshold;
1876
1940
  }
1877
- #ne(e) {
1878
- if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#y) {
1941
+ #re(e) {
1942
+ if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#E) {
1879
1943
  const t = this.virtualization.container, n = {
1880
1944
  scrollTop: e,
1881
1945
  scrollLeft: t?.scrollLeft ?? 0,
@@ -1889,7 +1953,7 @@ class I extends HTMLElement {
1889
1953
  }
1890
1954
  }
1891
1955
  findHeaderRow() {
1892
- return this.#o.querySelector(".header-row");
1956
+ return this.#n.querySelector(".header-row");
1893
1957
  }
1894
1958
  findRenderedRowElement(e) {
1895
1959
  return Array.from(this.bodyEl.querySelectorAll(".data-grid-row")).find((t) => {
@@ -1901,16 +1965,16 @@ class I extends HTMLElement {
1901
1965
  * Dispatch a cell click event to the plugin system.
1902
1966
  * Returns true if any plugin handled the event.
1903
1967
  */
1904
- dispatchCellClick(e, t, n, i) {
1905
- const s = this._rows[t], r = this._columns[n];
1906
- if (!s || !r) return !1;
1968
+ dispatchCellClick(e, t, n, s) {
1969
+ const i = this._rows[t], r = this._columns[n];
1970
+ if (!i || !r) return !1;
1907
1971
  const a = {
1908
- row: s,
1972
+ row: i,
1909
1973
  rowIndex: t,
1910
1974
  colIndex: n,
1911
1975
  field: r.field,
1912
- value: s[r.field],
1913
- cellEl: i,
1976
+ value: i[r.field],
1977
+ cellEl: s,
1914
1978
  originalEvent: e
1915
1979
  };
1916
1980
  return this.#t?.onCellClick(a) ?? !1;
@@ -1920,16 +1984,16 @@ class I extends HTMLElement {
1920
1984
  * Returns true if any plugin handled the event.
1921
1985
  */
1922
1986
  dispatchHeaderClick(e, t, n) {
1923
- const i = this._columns[t];
1924
- if (!i) return !1;
1925
- const s = {
1987
+ const s = this._columns[t];
1988
+ if (!s) return !1;
1989
+ const i = {
1926
1990
  colIndex: t,
1927
- field: i.field,
1928
- column: i,
1991
+ field: s.field,
1992
+ column: s,
1929
1993
  headerEl: n,
1930
1994
  originalEvent: e
1931
1995
  };
1932
- return this.#t?.onHeaderClick(s) ?? !1;
1996
+ return this.#t?.onHeaderClick(i) ?? !1;
1933
1997
  }
1934
1998
  /**
1935
1999
  * Dispatch a keyboard event to the plugin system.
@@ -1942,51 +2006,51 @@ class I extends HTMLElement {
1942
2006
  * Build a CellMouseEvent from a native MouseEvent.
1943
2007
  * Extracts cell/row information from the event target.
1944
2008
  */
1945
- #D(e, t) {
2009
+ #N(e, t) {
1946
2010
  let n = null;
1947
- const i = e.composedPath?.();
1948
- if (i && i.length > 0 ? n = i[0] : n = e.target, n && !this.#o.contains(n)) {
1949
- const u = this.#o.elementFromPoint(e.clientX, e.clientY);
1950
- u && (n = u);
1951
- }
1952
- const s = n?.closest?.("[data-col]"), r = n?.closest?.(".data-grid-row"), a = n?.closest?.(".header-row");
1953
- let l, f, p, g, h, c;
1954
- return s && (l = parseInt(s.getAttribute("data-row") ?? "-1", 10), f = parseInt(s.getAttribute("data-col") ?? "-1", 10), l >= 0 && f >= 0 && (p = this._rows[l], c = this._columns[f], g = c?.field, h = p && g ? p[g] : void 0)), {
2011
+ const s = e.composedPath?.();
2012
+ if (s && s.length > 0 ? n = s[0] : n = e.target, n && !this.#n.contains(n)) {
2013
+ const f = this.#n.elementFromPoint(e.clientX, e.clientY);
2014
+ f && (n = f);
2015
+ }
2016
+ const i = n?.closest?.("[data-col]"), r = n?.closest?.(".data-grid-row"), a = n?.closest?.(".header-row");
2017
+ let l, d, u, g, h, c;
2018
+ return i && (l = parseInt(i.getAttribute("data-row") ?? "-1", 10), d = parseInt(i.getAttribute("data-col") ?? "-1", 10), l >= 0 && d >= 0 && (u = this._rows[l], c = this._columns[d], g = c?.field, h = u && g ? u[g] : void 0)), {
1955
2019
  type: t,
1956
- row: p,
2020
+ row: u,
1957
2021
  rowIndex: l !== void 0 && l >= 0 ? l : void 0,
1958
- colIndex: f !== void 0 && f >= 0 ? f : void 0,
2022
+ colIndex: d !== void 0 && d >= 0 ? d : void 0,
1959
2023
  field: g,
1960
2024
  value: h,
1961
2025
  column: c,
1962
2026
  originalEvent: e,
1963
- cellElement: s ?? void 0,
2027
+ cellElement: i ?? void 0,
1964
2028
  rowElement: r ?? void 0,
1965
2029
  isHeader: !!a,
1966
- cell: l !== void 0 && f !== void 0 && l >= 0 && f >= 0 ? { row: l, col: f } : void 0
2030
+ cell: l !== void 0 && d !== void 0 && l >= 0 && d >= 0 ? { row: l, col: d } : void 0
1967
2031
  };
1968
2032
  }
1969
2033
  /**
1970
2034
  * Handle mousedown events and dispatch to plugin system.
1971
2035
  */
1972
- #ie(e) {
1973
- const t = this.#D(e, "mousedown");
2036
+ #le(e) {
2037
+ const t = this.#N(e, "mousedown");
1974
2038
  (this.#t?.onCellMouseDown(t) ?? !1) && (this.#R = !0);
1975
2039
  }
1976
2040
  /**
1977
2041
  * Handle mousemove events (only when dragging).
1978
2042
  */
1979
- #se(e) {
2043
+ #ae(e) {
1980
2044
  if (!this.#R) return;
1981
- const t = this.#D(e, "mousemove");
2045
+ const t = this.#N(e, "mousemove");
1982
2046
  this.#t?.onCellMouseMove(t);
1983
2047
  }
1984
2048
  /**
1985
2049
  * Handle mouseup events.
1986
2050
  */
1987
- #re(e) {
2051
+ #ce(e) {
1988
2052
  if (!this.#R) return;
1989
- const t = this.#D(e, "mouseup");
2053
+ const t = this.#N(e, "mouseup");
1990
2054
  this.#t?.onCellMouseUp(t), this.#R = !1;
1991
2055
  }
1992
2056
  // API consumed by internal utils (rows.ts)
@@ -2000,20 +2064,20 @@ class I extends HTMLElement {
2000
2064
  this._changedRowIndices.clear(), e || this.#s("changed-rows-reset", { rows: this.changedRows, indices: this.changedRowIndices }), this.rowPool.forEach((t) => t.classList.remove("changed"));
2001
2065
  }
2002
2066
  async beginBulkEdit(e) {
2003
- this.#te(e, this._rows[e]);
2067
+ this.#se(e, this._rows[e]);
2004
2068
  }
2005
2069
  async commitActiveRowEdit() {
2006
- this.activeEditRows !== -1 && this.#O(this.activeEditRows, !1);
2070
+ this.activeEditRows !== -1 && this.#D(this.activeEditRows, !1);
2007
2071
  }
2008
2072
  async ready() {
2009
- return this.#z;
2073
+ return this.#I;
2010
2074
  }
2011
2075
  async forceLayout() {
2012
2076
  this.#d(), await new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(e)));
2013
2077
  }
2014
2078
  /** Public method: returns a frozen snapshot of the merged effective configuration */
2015
2079
  async getConfig() {
2016
- return Object.freeze({ ...this.#n || {} });
2080
+ return Object.freeze({ ...this.#o || {} });
2017
2081
  }
2018
2082
  // ---------------- Column Visibility API ----------------
2019
2083
  /**
@@ -2023,11 +2087,11 @@ class I extends HTMLElement {
2023
2087
  * @returns True if visibility was changed, false if column not found or locked
2024
2088
  */
2025
2089
  setColumnVisible(e, t) {
2026
- const n = this.#n.columns, i = n?.find((a) => a.field === e);
2027
- if (!i || !t && i.lockVisible || !t && (n ?? []).filter((l) => !l.hidden && l.field !== e).length === 0)
2090
+ const n = this.#o.columns, s = n?.find((a) => a.field === e);
2091
+ if (!s || !t && s.lockVisible || !t && (n ?? []).filter((l) => !l.hidden && l.field !== e).length === 0)
2028
2092
  return !1;
2029
- const s = !!i.hidden, r = !t;
2030
- return s !== r ? (i.hidden = r, this.#s("column-visibility", {
2093
+ const i = !!s.hidden, r = !t;
2094
+ return i !== r ? (s.hidden = r, this.#s("column-visibility", {
2031
2095
  field: e,
2032
2096
  visible: t,
2033
2097
  visibleColumns: (n ?? []).filter((a) => !a.hidden).map((a) => a.field)
@@ -2039,8 +2103,8 @@ class I extends HTMLElement {
2039
2103
  * @returns True if visibility was toggled, false if column not found or locked
2040
2104
  */
2041
2105
  toggleColumnVisibility(e) {
2042
- const i = !!this.#n.columns?.find((s) => s.field === e)?.hidden;
2043
- return this.setColumnVisible(e, i);
2106
+ const s = !!this.#o.columns?.find((i) => i.field === e)?.hidden;
2107
+ return this.setColumnVisible(e, s);
2044
2108
  }
2045
2109
  /**
2046
2110
  * Check if a column is currently visible.
@@ -2048,14 +2112,14 @@ class I extends HTMLElement {
2048
2112
  * @returns True if visible, false if hidden or not found
2049
2113
  */
2050
2114
  isColumnVisible(e) {
2051
- const n = this.#n.columns?.find((i) => i.field === e);
2115
+ const n = this.#o.columns?.find((s) => s.field === e);
2052
2116
  return n ? !n.hidden : !1;
2053
2117
  }
2054
2118
  /**
2055
2119
  * Show all columns.
2056
2120
  */
2057
2121
  showAllColumns() {
2058
- const e = this.#n.columns;
2122
+ const e = this.#o.columns;
2059
2123
  e?.some((n) => n.hidden) && (e?.forEach((n) => {
2060
2124
  n.hidden = !1;
2061
2125
  }), this.#s("column-visibility", {
@@ -2069,7 +2133,7 @@ class I extends HTMLElement {
2069
2133
  * @returns Array of all field names with their visibility status
2070
2134
  */
2071
2135
  getAllColumns() {
2072
- return (this.#n.columns ?? []).map((t) => ({
2136
+ return (this.#o.columns ?? []).map((t) => ({
2073
2137
  field: t.field,
2074
2138
  header: t.header || t.field,
2075
2139
  visible: !t.hidden,
@@ -2083,14 +2147,14 @@ class I extends HTMLElement {
2083
2147
  */
2084
2148
  setColumnOrder(e) {
2085
2149
  if (!e.length) return;
2086
- const t = new Map(this._columns.map((i) => [i.field, i])), n = [];
2087
- for (const i of e) {
2088
- const s = t.get(i);
2089
- s && (n.push(s), t.delete(i));
2150
+ const t = new Map(this._columns.map((s) => [s.field, s])), n = [];
2151
+ for (const s of e) {
2152
+ const i = t.get(s);
2153
+ i && (n.push(i), t.delete(s));
2090
2154
  }
2091
- for (const i of t.values())
2092
- n.push(i);
2093
- this._columns = n, this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0);
2155
+ for (const s of t.values())
2156
+ n.push(s);
2157
+ this._columns = n, this.#L(), this.updateTemplate(), this.refreshVirtualWindow(!0);
2094
2158
  }
2095
2159
  /**
2096
2160
  * Get the current column order as an array of field names.
@@ -2106,14 +2170,14 @@ class I extends HTMLElement {
2106
2170
  */
2107
2171
  getColumnState() {
2108
2172
  const e = this.#t?.getAll() ?? [];
2109
- return ae(this, e);
2173
+ return he(this, e);
2110
2174
  }
2111
2175
  /**
2112
2176
  * Set the column state, restoring order, width, visibility, sort, and plugin state.
2113
2177
  * Use this to restore previously saved column state.
2114
2178
  */
2115
2179
  set columnState(e) {
2116
- e && (this.#h = e, this.#i && this.#le(e));
2180
+ e && (this.#h = e, this.#i && this.#de(e));
2117
2181
  }
2118
2182
  /**
2119
2183
  * Get the current column state.
@@ -2124,10 +2188,10 @@ class I extends HTMLElement {
2124
2188
  /**
2125
2189
  * Apply column state internally.
2126
2190
  */
2127
- #le(e) {
2128
- (this.#n.columns ?? []).forEach((n) => {
2191
+ #de(e) {
2192
+ (this.#o.columns ?? []).forEach((n) => {
2129
2193
  n.hidden = !1;
2130
- }), this.#W(e), this.#d();
2194
+ }), this.#G(e), this.#d();
2131
2195
  }
2132
2196
  /**
2133
2197
  * Request a state change event to be emitted.
@@ -2136,62 +2200,134 @@ class I extends HTMLElement {
2136
2200
  * The event is debounced to avoid excessive events during drag operations.
2137
2201
  */
2138
2202
  requestStateChange() {
2139
- this.#P || (this.#P = ve(
2203
+ this.#M || (this.#M = Ce(
2140
2204
  this,
2141
2205
  () => this.#t?.getAll() ?? [],
2142
2206
  (e) => this.#s("column-state-change", e)
2143
- )), this.#P();
2207
+ )), this.#M();
2144
2208
  }
2145
2209
  /**
2146
2210
  * Reset column state to initial configuration.
2147
2211
  * Clears all user modifications (order, width, visibility, sort).
2148
2212
  */
2149
2213
  resetColumnState() {
2150
- this.#h = void 0, (this.#n.columns ?? []).forEach((n) => {
2214
+ this.#h = void 0, (this.#o.columns ?? []).forEach((n) => {
2151
2215
  n.hidden = !1;
2152
2216
  }), this.sortState = null, this.__originalOrder = [], this.#u(), this.#d();
2153
2217
  const t = this.#t?.getAll() ?? [];
2154
2218
  for (const n of t)
2155
2219
  if (n.applyColumnState)
2156
- for (const i of this._columns)
2157
- n.applyColumnState(i.field, {
2158
- field: i.field,
2220
+ for (const s of this._columns)
2221
+ n.applyColumnState(s.field, {
2222
+ field: s.field,
2159
2223
  order: 0,
2160
2224
  visible: !0
2161
2225
  });
2162
2226
  this.requestStateChange();
2163
2227
  }
2164
2228
  // ---------------- Shell / Tool Panel API ----------------
2229
+ /**
2230
+ * Check if the tool panel is currently open.
2231
+ */
2232
+ get isToolPanelOpen() {
2233
+ return this.#e.isPanelOpen;
2234
+ }
2165
2235
  /**
2166
2236
  * Get the currently active tool panel ID, or null if none is open.
2237
+ * @deprecated Use isToolPanelOpen and expandedToolPanelSections instead.
2167
2238
  */
2168
2239
  get activeToolPanel() {
2169
2240
  return this.#e.activePanel;
2170
2241
  }
2171
2242
  /**
2172
- * Open a tool panel by ID.
2173
- * Closes any currently open panel first.
2243
+ * Get the IDs of expanded accordion sections.
2174
2244
  */
2175
- openToolPanel(e) {
2176
- if (!this.#e.toolPanels.get(e)) {
2177
- console.warn(`[tbw-grid] Tool panel "${e}" not found`);
2178
- return;
2245
+ get expandedToolPanelSections() {
2246
+ return [...this.#e.expandedSections];
2247
+ }
2248
+ /**
2249
+ * Open the tool panel (accordion view with all registered panels).
2250
+ */
2251
+ openToolPanel() {
2252
+ if (this.#e.isPanelOpen) return;
2253
+ if (this.#e.isPanelOpen = !0, this.#e.expandedSections.size === 0 && this.#e.toolPanels.size > 0) {
2254
+ const n = [...this.#e.toolPanels.values()].sort(
2255
+ (s, i) => (s.order ?? 100) - (i.order ?? 100)
2256
+ )[0];
2257
+ n && this.#e.expandedSections.add(n.id);
2179
2258
  }
2180
- this.#e.activePanel && this.#e.activePanel !== e && this.closeToolPanel(), this.#e.activePanel = e, oe(this.#o, this.#e), ne(this.#o, this.#e), je(this.#o, this.#e), this.#s("tool-panel-open", { id: e });
2259
+ se(this.#n, this.#e), ie(this.#n, this.#e);
2260
+ const e = {
2261
+ expand: this.#o?.icons?.expand ?? S.expand,
2262
+ collapse: this.#o?.icons?.collapse ?? S.collapse
2263
+ };
2264
+ Je(this.#n, this.#e, e), this.#s("tool-panel-open", { sections: this.expandedToolPanelSections });
2181
2265
  }
2182
2266
  /**
2183
- * Close the currently open tool panel.
2267
+ * Close the tool panel.
2184
2268
  */
2185
2269
  closeToolPanel() {
2186
- if (!this.#e.activePanel) return;
2187
- const e = this.#e.activePanel, t = this.#e.toolPanels.get(e);
2188
- this.#e.activePanelCleanup && (this.#e.activePanelCleanup(), this.#e.activePanelCleanup = null), t?.onClose?.(), this.#e.activePanel = null, oe(this.#o, this.#e), ne(this.#o, this.#e), this.#s("tool-panel-close", { id: e });
2270
+ if (this.#e.isPanelOpen) {
2271
+ for (const e of this.#e.panelCleanups.values())
2272
+ e();
2273
+ this.#e.panelCleanups.clear(), this.#e.activePanelCleanup && (this.#e.activePanelCleanup(), this.#e.activePanelCleanup = null);
2274
+ for (const e of this.#e.toolPanels.values())
2275
+ e.onClose?.();
2276
+ this.#e.isPanelOpen = !1, se(this.#n, this.#e), ie(this.#n, this.#e), this.#s("tool-panel-close", {});
2277
+ }
2278
+ }
2279
+ /**
2280
+ * Toggle the tool panel open/closed.
2281
+ */
2282
+ toggleToolPanel() {
2283
+ this.#e.isPanelOpen ? this.closeToolPanel() : this.openToolPanel();
2189
2284
  }
2190
2285
  /**
2191
- * Toggle a tool panel open/closed.
2286
+ * Toggle an accordion section expanded/collapsed.
2287
+ * Only one section can be expanded at a time (exclusive accordion).
2288
+ * When there's only one panel, toggling is disabled (always expanded).
2192
2289
  */
2193
- toggleToolPanel(e) {
2194
- this.#e.activePanel === e ? this.closeToolPanel() : this.openToolPanel(e);
2290
+ toggleToolPanelSection(e) {
2291
+ const t = this.#e.toolPanels.get(e);
2292
+ if (!t) {
2293
+ console.warn(`[tbw-grid] Tool panel section "${e}" not found`);
2294
+ return;
2295
+ }
2296
+ if (this.#e.toolPanels.size === 1)
2297
+ return;
2298
+ const n = this.#e.expandedSections.has(e);
2299
+ if (n) {
2300
+ const s = this.#e.panelCleanups.get(e);
2301
+ s && (s(), this.#e.panelCleanups.delete(e)), t.onClose?.(), this.#e.expandedSections.delete(e), this.#q(e, !1);
2302
+ } else {
2303
+ for (const [s, i] of this.#e.toolPanels)
2304
+ if (s !== e && this.#e.expandedSections.has(s)) {
2305
+ const r = this.#e.panelCleanups.get(s);
2306
+ r && (r(), this.#e.panelCleanups.delete(s)), i.onClose?.(), this.#e.expandedSections.delete(s), this.#q(s, !1);
2307
+ const a = this.#n.querySelector(`[data-section="${s}"] .tbw-accordion-content`);
2308
+ a && (a.innerHTML = "");
2309
+ }
2310
+ this.#e.expandedSections.add(e), this.#q(e, !0), this.#he(e);
2311
+ }
2312
+ this.#s("tool-panel-section-toggle", { id: e, expanded: !n });
2313
+ }
2314
+ /**
2315
+ * Update accordion section visual state.
2316
+ */
2317
+ #q(e, t) {
2318
+ const n = this.#n.querySelector(`[data-section="${e}"]`);
2319
+ n && n.classList.toggle("expanded", t);
2320
+ }
2321
+ /**
2322
+ * Render content for a single accordion section.
2323
+ */
2324
+ #he(e) {
2325
+ const t = this.#e.toolPanels.get(e);
2326
+ if (!t?.render) return;
2327
+ const n = this.#n.querySelector(`[data-section="${e}"] .tbw-accordion-content`);
2328
+ if (!n) return;
2329
+ const s = t.render(n);
2330
+ s && this.#e.panelCleanups.set(e, s);
2195
2331
  }
2196
2332
  /**
2197
2333
  * Get registered tool panel definitions.
@@ -2229,20 +2365,20 @@ class I extends HTMLElement {
2229
2365
  console.warn(`[tbw-grid] Header content "${e.id}" already registered`);
2230
2366
  return;
2231
2367
  }
2232
- this.#e.headerContents.set(e.id, e), this.#c && te(this.#o, this.#e);
2368
+ this.#e.headerContents.set(e.id, e), this.#c && ne(this.#n, this.#e);
2233
2369
  }
2234
2370
  /**
2235
2371
  * Unregister custom header content.
2236
2372
  */
2237
2373
  unregisterHeaderContent(e) {
2238
2374
  const t = this.#e.headerContentCleanups.get(e);
2239
- t && (t(), this.#e.headerContentCleanups.delete(e)), this.#e.headerContents.get(e)?.onDestroy?.(), this.#e.headerContents.delete(e), this.#o.querySelector(`[data-header-content="${e}"]`)?.remove();
2375
+ t && (t(), this.#e.headerContentCleanups.delete(e)), this.#e.headerContents.get(e)?.onDestroy?.(), this.#e.headerContents.delete(e), this.#n.querySelector(`[data-header-content="${e}"]`)?.remove();
2240
2376
  }
2241
2377
  /**
2242
2378
  * Get all registered toolbar buttons.
2243
2379
  */
2244
2380
  getToolbarButtons() {
2245
- return Ye(this.#n?.shell, this.#e);
2381
+ return Qe(this.#o?.shell, this.#e);
2246
2382
  }
2247
2383
  /**
2248
2384
  * Register a custom toolbar button programmatically.
@@ -2267,8 +2403,8 @@ class I extends HTMLElement {
2267
2403
  setToolbarButtonDisabled(e, t) {
2268
2404
  const n = this.#e.toolbarButtons.get(e);
2269
2405
  n && (n.disabled = t);
2270
- const i = this.#o.querySelector(`[data-btn="${e}"]`);
2271
- i && (i.disabled = t);
2406
+ const s = this.#n.querySelector(`[data-btn="${e}"]`);
2407
+ s && (s.disabled = t);
2272
2408
  }
2273
2409
  /**
2274
2410
  * Re-parse light DOM shell elements and refresh shell header.
@@ -2281,7 +2417,7 @@ class I extends HTMLElement {
2281
2417
  * Internal shell header refresh.
2282
2418
  */
2283
2419
  #m() {
2284
- ee(this, this.#e), this.#F(), this.#$();
2420
+ oe(this, this.#e), this.#U(), this.#V();
2285
2421
  }
2286
2422
  // ---------------- Virtual Window ----------------
2287
2423
  /**
@@ -2292,36 +2428,36 @@ class I extends HTMLElement {
2292
2428
  if (!this.bodyEl) return;
2293
2429
  const t = this._rows.length;
2294
2430
  if (!this.virtualization.enabled) {
2295
- this.#H(0, t), this.#b();
2431
+ this.#z(0, t), this.#b();
2296
2432
  return;
2297
2433
  }
2298
- if (this.#oe()) {
2299
- this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#H(0, t, this.__rowRenderEpoch), this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * this.virtualization.rowHeight}px`), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), this.#b();
2434
+ if (this.#ie()) {
2435
+ this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#z(0, t, this.__rowRenderEpoch), this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * this.virtualization.rowHeight}px`), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), this.#b();
2300
2436
  return;
2301
2437
  }
2302
- const n = this.virtualization.container ?? this, s = (this.virtualization.viewportEl ?? n).clientHeight, r = this.virtualization.rowHeight, a = n.scrollTop;
2303
- let l = Math.floor(a / r), f = 0;
2304
- const p = 10;
2305
- for (; f < p; ) {
2306
- const R = this.#t?.getExtraHeightBefore?.(l) ?? 0, E = Math.floor((a - R) / r);
2307
- if (E >= l || E < 0) break;
2308
- l = E, f++;
2438
+ const n = this.virtualization.container ?? this, i = (this.virtualization.viewportEl ?? n).clientHeight, r = this.virtualization.rowHeight, a = n.scrollTop;
2439
+ let l = Math.floor(a / r), d = 0;
2440
+ const u = 10;
2441
+ for (; d < u; ) {
2442
+ const R = this.#t?.getExtraHeightBefore?.(l) ?? 0, C = Math.floor((a - R) / r);
2443
+ if (C >= l || C < 0) break;
2444
+ l = C, d++;
2309
2445
  }
2310
2446
  l = l - l % 2, l < 0 && (l = 0);
2311
2447
  const g = this.#t?.adjustVirtualStart(l, a, r);
2312
2448
  g !== void 0 && g < l && (l = g, l = l - l % 2, l < 0 && (l = 0));
2313
- const h = Math.ceil(s / r) + 3;
2449
+ const h = Math.ceil(i / r) + 3;
2314
2450
  let c = l + h;
2315
2451
  c > t && (c = t), this.virtualization.start = l, this.virtualization.end = c;
2316
- const d = this.#o.querySelector(".tbw-footer")?.offsetHeight ?? 0, b = this.#t?.getExtraHeight() ?? 0;
2317
- this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * r + r + d + b}px`);
2318
- const m = this.#t?.getExtraHeightBefore?.(l) ?? 0, C = -(a - l * r - m);
2319
- this.bodyEl.style.transform = `translateY(${C}px)`, this.#H(l, c, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#b();
2452
+ const p = this.#n.querySelector(".tbw-footer")?.offsetHeight ?? 0, w = this.#t?.getExtraHeight() ?? 0;
2453
+ this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * r + r + p + w}px`);
2454
+ const m = this.#t?.getExtraHeightBefore?.(l) ?? 0, y = -(a - l * r - m);
2455
+ this.bodyEl.style.transform = `translateY(${y}px)`, this.#z(l, c, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#b();
2320
2456
  }
2321
2457
  // ---------------- Render ----------------
2322
- #F() {
2323
- ee(this, this.#e);
2324
- const e = this.#n?.shell, t = Fe(e, this.#e), n = `
2458
+ #U() {
2459
+ oe(this, this.#e);
2460
+ const e = this.#o?.shell, t = Ge(e, this.#e), n = `
2325
2461
  <div class="tbw-scroll-area">
2326
2462
  <div class="rows-body-wrapper">
2327
2463
  <div class="rows-body">
@@ -2341,15 +2477,18 @@ class I extends HTMLElement {
2341
2477
  </div>
2342
2478
  `;
2343
2479
  if (t) {
2344
- const i = Ve(e, this.#e), s = Ge(e, this.#e, n);
2345
- this.#o.innerHTML = `
2480
+ const s = this.#o?.icons?.toolPanel ?? S.toolPanel, i = {
2481
+ expand: this.#o?.icons?.expand ?? S.expand,
2482
+ collapse: this.#o?.icons?.collapse ?? S.collapse
2483
+ }, r = Ue(e, this.#e, s), a = Xe(e, this.#e, n, i);
2484
+ this.#n.innerHTML = `
2346
2485
  <div class="tbw-grid-root has-shell">
2347
- ${i}
2348
- ${s}
2486
+ ${r}
2487
+ ${a}
2349
2488
  </div>
2350
- `, this.#ae(), this.#c = !0;
2489
+ `, this.#ue(), this.#c = !0;
2351
2490
  } else
2352
- this.#o.innerHTML = `
2491
+ this.#n.innerHTML = `
2353
2492
  <div class="tbw-grid-root">
2354
2493
  <div class="tbw-grid-content">
2355
2494
  ${n}
@@ -2360,28 +2499,30 @@ class I extends HTMLElement {
2360
2499
  /**
2361
2500
  * Set up shell event listeners after render.
2362
2501
  */
2363
- #ae() {
2364
- Ue(this.#o, this.#n?.shell, this.#e, {
2365
- onPanelToggle: (e) => this.toggleToolPanel(e),
2366
- onPanelClose: () => this.closeToolPanel(),
2367
- onToolbarButtonClick: (e) => this.#ce(e)
2502
+ #ue() {
2503
+ je(this.#n, this.#o?.shell, this.#e, {
2504
+ onPanelToggle: () => this.toggleToolPanel(),
2505
+ onSectionToggle: (e) => this.toggleToolPanelSection(e),
2506
+ onToolbarButtonClick: (e) => this.#fe(e)
2507
+ }), this.#T?.(), this.#T = Ye(this.#n, this.#o?.shell, (e) => {
2508
+ this.style.setProperty("--tbw-tool-panel-width", `${e}px`);
2368
2509
  });
2369
2510
  }
2370
2511
  /**
2371
2512
  * Handle toolbar button click (for config buttons with action).
2372
2513
  */
2373
- #ce(e) {
2374
- const n = (this.#n?.shell?.header?.toolbarButtons ?? []).find((s) => s.id === e);
2514
+ #fe(e) {
2515
+ const n = (this.#o?.shell?.header?.toolbarButtons ?? []).find((i) => i.id === e);
2375
2516
  if (n?.action) {
2376
2517
  n.action();
2377
2518
  return;
2378
2519
  }
2379
- const i = this.#e.toolbarButtons.get(e);
2380
- i?.action && i.action();
2520
+ const s = this.#e.toolbarButtons.get(e);
2521
+ s?.action && s.action();
2381
2522
  }
2382
2523
  }
2383
- customElements.get(I.tagName) || customElements.define(I.tagName, I);
2384
- class fe {
2524
+ customElements.get($.tagName) || customElements.define($.tagName, $);
2525
+ class ge {
2385
2526
  /** Plugin version - override in subclass if needed */
2386
2527
  version = "1.0.0";
2387
2528
  /** CSS styles to inject into the grid's shadow DOM */
@@ -2506,7 +2647,7 @@ class fe {
2506
2647
  */
2507
2648
  get gridIcons() {
2508
2649
  const e = this.grid?.gridConfig?.icons ?? {};
2509
- return { ...ce, ...e };
2650
+ return { ...S, ...e };
2510
2651
  }
2511
2652
  /**
2512
2653
  * Resolve an icon value to string or HTMLElement.
@@ -2536,7 +2677,7 @@ class fe {
2536
2677
  console.warn(`[tbw-grid:${this.name}] ${e}`);
2537
2678
  }
2538
2679
  }
2539
- function N(o) {
2680
+ function I(o) {
2540
2681
  return {
2541
2682
  startRow: Math.min(o.startRow, o.endRow),
2542
2683
  startCol: Math.min(o.startCol, o.endCol),
@@ -2544,38 +2685,38 @@ function N(o) {
2544
2685
  endCol: Math.max(o.startCol, o.endCol)
2545
2686
  };
2546
2687
  }
2547
- function Qe(o) {
2548
- const e = N(o);
2688
+ function ot(o) {
2689
+ const e = I(o);
2549
2690
  return {
2550
2691
  from: { row: e.startRow, col: e.startCol },
2551
2692
  to: { row: e.endRow, col: e.endCol }
2552
2693
  };
2553
2694
  }
2554
- function K(o) {
2555
- return o.map(Qe);
2695
+ function V(o) {
2696
+ return o.map(ot);
2556
2697
  }
2557
- function et(o, e, t) {
2558
- const n = N(t);
2698
+ function nt(o, e, t) {
2699
+ const n = I(t);
2559
2700
  return o >= n.startRow && o <= n.endRow && e >= n.startCol && e <= n.endCol;
2560
2701
  }
2561
- function ie(o, e, t) {
2562
- return t.some((n) => et(o, e, n));
2702
+ function re(o, e, t) {
2703
+ return t.some((n) => nt(o, e, n));
2563
2704
  }
2564
- function tt(o) {
2565
- const e = [], t = N(o);
2705
+ function st(o) {
2706
+ const e = [], t = I(o);
2566
2707
  for (let n = t.startRow; n <= t.endRow; n++)
2567
- for (let i = t.startCol; i <= t.endCol; i++)
2568
- e.push({ row: n, col: i });
2708
+ for (let s = t.startCol; s <= t.endCol; s++)
2709
+ e.push({ row: n, col: s });
2569
2710
  return e;
2570
2711
  }
2571
- function ot(o) {
2712
+ function it(o) {
2572
2713
  const e = /* @__PURE__ */ new Map();
2573
2714
  for (const t of o)
2574
- for (const n of tt(t))
2715
+ for (const n of st(t))
2575
2716
  e.set(`${n.row},${n.col}`, n);
2576
2717
  return [...e.values()];
2577
2718
  }
2578
- function se(o, e) {
2719
+ function le(o, e) {
2579
2720
  return {
2580
2721
  startRow: o.row,
2581
2722
  startCol: o.col,
@@ -2583,7 +2724,8 @@ function se(o, e) {
2583
2724
  endCol: e.col
2584
2725
  };
2585
2726
  }
2586
- function nt(o, e, t) {
2727
+ const rt = ':host .selecting .data-grid-row>.cell{user-select:none}:host .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}:host([data-selection-mode="row"]) .cell-focus{outline:none}:host .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}:host .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}';
2728
+ function lt(o, e, t) {
2587
2729
  if (o === "cell" && e.selectedCell)
2588
2730
  return {
2589
2731
  mode: o,
@@ -2595,15 +2737,15 @@ function nt(o, e, t) {
2595
2737
  ]
2596
2738
  };
2597
2739
  if (o === "row" && e.selected.size > 0) {
2598
- const n = [...e.selected].map((i) => ({
2599
- from: { row: i, col: 0 },
2600
- to: { row: i, col: t - 1 }
2740
+ const n = [...e.selected].map((s) => ({
2741
+ from: { row: s, col: 0 },
2742
+ to: { row: s, col: t - 1 }
2601
2743
  }));
2602
2744
  return { mode: o, ranges: n };
2603
2745
  }
2604
- return o === "range" && e.ranges.length > 0 ? { mode: o, ranges: K(e.ranges) } : { mode: o, ranges: [] };
2746
+ return o === "range" && e.ranges.length > 0 ? { mode: o, ranges: V(e.ranges) } : { mode: o, ranges: [] };
2605
2747
  }
2606
- class lt extends fe {
2748
+ class ft extends ge {
2607
2749
  name = "selection";
2608
2750
  version = "1.0.0";
2609
2751
  get defaultConfig() {
@@ -2629,15 +2771,15 @@ class lt extends fe {
2629
2771
  }
2630
2772
  // ===== Event Handlers =====
2631
2773
  onCellClick(e) {
2632
- const { rowIndex: t, colIndex: n, originalEvent: i } = e, { mode: s } = this.config;
2633
- if (s === "cell")
2774
+ const { rowIndex: t, colIndex: n, originalEvent: s } = e, { mode: i } = this.config;
2775
+ if (i === "cell")
2634
2776
  return this.selectedCell = { row: t, col: n }, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
2635
- if (s === "row")
2777
+ if (i === "row")
2636
2778
  return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
2637
- if (s === "range") {
2638
- const r = i.shiftKey, a = i.ctrlKey || i.metaKey;
2779
+ if (i === "range") {
2780
+ const r = s.shiftKey, a = s.ctrlKey || s.metaKey;
2639
2781
  if (r && this.cellAnchor) {
2640
- const l = se(this.cellAnchor, { row: t, col: n });
2782
+ const l = le(this.cellAnchor, { row: t, col: n });
2641
2783
  a ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = l : this.ranges.push(l) : this.ranges = [l], this.activeRange = l;
2642
2784
  } else if (a) {
2643
2785
  const l = {
@@ -2665,15 +2807,15 @@ class lt extends fe {
2665
2807
  if (e.key === "Escape")
2666
2808
  return t === "cell" ? this.selectedCell = null : t === "row" ? (this.selected.clear(), this.anchor = null) : t === "range" && (this.ranges = [], this.activeRange = null, this.cellAnchor = null), this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
2667
2809
  if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
2668
- const n = this.rows.length, i = this.columns.length;
2669
- if (n > 0 && i > 0) {
2670
- const s = {
2810
+ const n = this.rows.length, s = this.columns.length;
2811
+ if (n > 0 && s > 0) {
2812
+ const i = {
2671
2813
  startRow: 0,
2672
2814
  startCol: 0,
2673
2815
  endRow: n - 1,
2674
- endCol: i - 1
2816
+ endCol: s - 1
2675
2817
  };
2676
- return this.ranges = [s], this.activeRange = s, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
2818
+ return this.ranges = [i], this.activeRange = i, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
2677
2819
  }
2678
2820
  }
2679
2821
  return !1;
@@ -2684,17 +2826,17 @@ class lt extends fe {
2684
2826
  this.isDragging = !0;
2685
2827
  const t = e.rowIndex, n = e.colIndex;
2686
2828
  this.cellAnchor = { row: t, col: n }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
2687
- const s = {
2829
+ const i = {
2688
2830
  startRow: t,
2689
2831
  startCol: n,
2690
2832
  endRow: t,
2691
2833
  endCol: n
2692
2834
  };
2693
- return this.ranges.push(s), this.activeRange = s, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
2835
+ return this.ranges.push(i), this.activeRange = i, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
2694
2836
  }
2695
2837
  onCellMouseMove(e) {
2696
2838
  if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
2697
- const t = se(this.cellAnchor, { row: e.rowIndex, col: e.colIndex });
2839
+ const t = le(this.cellAnchor, { row: e.rowIndex, col: e.colIndex });
2698
2840
  return this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = t : this.ranges.push(t), this.activeRange = t, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
2699
2841
  }
2700
2842
  onCellMouseUp(e) {
@@ -2705,40 +2847,40 @@ class lt extends fe {
2705
2847
  * Apply selection classes to visible cells/rows.
2706
2848
  * Shared by afterRender and onScrollRender.
2707
2849
  */
2708
- #o() {
2850
+ #n() {
2709
2851
  const e = this.shadowRoot;
2710
2852
  if (!e) return;
2711
2853
  const { mode: t } = this.config;
2712
- e.querySelectorAll(".cell").forEach((s) => {
2713
- s.classList.remove("selected", "top", "bottom", "first", "last");
2854
+ e.querySelectorAll(".cell").forEach((i) => {
2855
+ i.classList.remove("selected", "top", "bottom", "first", "last");
2714
2856
  });
2715
- const i = e.querySelectorAll(".data-grid-row");
2716
- if (i.forEach((s) => {
2717
- s.classList.remove("selected", "row-focus");
2718
- }), t === "row" && i.forEach((s) => {
2719
- const r = s.querySelector(".cell[data-row]"), a = parseInt(r?.getAttribute("data-row") ?? "-1", 10);
2720
- a >= 0 && this.selected.has(a) && (s.classList.add("selected", "row-focus"), s.querySelectorAll(".cell-focus").forEach((l) => l.classList.remove("cell-focus")));
2857
+ const s = e.querySelectorAll(".data-grid-row");
2858
+ if (s.forEach((i) => {
2859
+ i.classList.remove("selected", "row-focus");
2860
+ }), t === "row" && s.forEach((i) => {
2861
+ const r = i.querySelector(".cell[data-row]"), a = parseInt(r?.getAttribute("data-row") ?? "-1", 10);
2862
+ a >= 0 && this.selected.has(a) && (i.classList.add("selected", "row-focus"), i.querySelectorAll(".cell-focus").forEach((l) => l.classList.remove("cell-focus")));
2721
2863
  }), t === "range" && this.ranges.length > 0) {
2722
- const s = this.activeRange ? N(this.activeRange) : null;
2864
+ const i = this.activeRange ? I(this.activeRange) : null;
2723
2865
  e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
2724
- const l = parseInt(a.getAttribute("data-row") ?? "-1", 10), f = parseInt(a.getAttribute("data-col") ?? "-1", 10);
2725
- l >= 0 && f >= 0 && ie(l, f, this.ranges) && (a.classList.add("selected"), a.classList.remove("cell-focus"), s && (l === s.startRow && a.classList.add("top"), l === s.endRow && a.classList.add("bottom"), f === s.startCol && a.classList.add("first"), f === s.endCol && a.classList.add("last")));
2866
+ const l = parseInt(a.getAttribute("data-row") ?? "-1", 10), d = parseInt(a.getAttribute("data-col") ?? "-1", 10);
2867
+ l >= 0 && d >= 0 && re(l, d, this.ranges) && (a.classList.add("selected"), a.classList.remove("cell-focus"), i && (l === i.startRow && a.classList.add("top"), l === i.endRow && a.classList.add("bottom"), d === i.startCol && a.classList.add("first"), d === i.endCol && a.classList.add("last")));
2726
2868
  });
2727
2869
  }
2728
- t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((s) => s.classList.remove("cell-focus"));
2870
+ t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((i) => i.classList.remove("cell-focus"));
2729
2871
  }
2730
2872
  afterRender() {
2731
2873
  const e = this.shadowRoot;
2732
2874
  if (!e) return;
2733
2875
  const t = e.children[0], { mode: n } = this.config;
2734
- this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), this.#o();
2876
+ this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), this.#n();
2735
2877
  }
2736
2878
  /**
2737
2879
  * Called after scroll-triggered row rendering.
2738
2880
  * Reapplies selection classes to recycled DOM elements.
2739
2881
  */
2740
2882
  onScrollRender() {
2741
- this.#o();
2883
+ this.#n();
2742
2884
  }
2743
2885
  // ===== Public API =====
2744
2886
  /**
@@ -2757,19 +2899,19 @@ class lt extends fe {
2757
2899
  * Get all selected cell ranges in public format.
2758
2900
  */
2759
2901
  getRanges() {
2760
- return K(this.ranges);
2902
+ return V(this.ranges);
2761
2903
  }
2762
2904
  /**
2763
2905
  * Get all selected cells across all ranges.
2764
2906
  */
2765
2907
  getSelectedCells() {
2766
- return ot(this.ranges);
2908
+ return it(this.ranges);
2767
2909
  }
2768
2910
  /**
2769
2911
  * Check if a specific cell is in range selection.
2770
2912
  */
2771
2913
  isCellSelected(e, t) {
2772
- return ie(e, t, this.ranges);
2914
+ return re(e, t, this.ranges);
2773
2915
  }
2774
2916
  /**
2775
2917
  * Clear all selection.
@@ -2788,12 +2930,12 @@ class lt extends fe {
2788
2930
  endCol: t.to.col
2789
2931
  })), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
2790
2932
  mode: this.config.mode,
2791
- ranges: K(this.ranges)
2933
+ ranges: V(this.ranges)
2792
2934
  }), this.requestAfterRender();
2793
2935
  }
2794
2936
  // ===== Private Helpers =====
2795
2937
  #i() {
2796
- return nt(
2938
+ return lt(
2797
2939
  this.config.mode,
2798
2940
  {
2799
2941
  selectedCell: this.selectedCell,
@@ -2804,111 +2946,79 @@ class lt extends fe {
2804
2946
  );
2805
2947
  }
2806
2948
  // ===== Styles =====
2807
- styles = `
2808
- /* Prevent text selection during range drag */
2809
- :host .selecting .data-grid-row > .cell {
2810
- user-select: none;
2811
- }
2812
-
2813
- /* Row selection - use accent color for row focus */
2814
- :host .data-grid-row.row-focus {
2815
- background-color: var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%));
2816
- }
2817
-
2818
- /* Disable cell-focus outline in row mode - row is the focus unit */
2819
- :host([data-selection-mode="row"]) .cell-focus {
2820
- outline: none;
2821
- }
2822
-
2823
- /* Selection cell styles - for range mode */
2824
- :host .data-grid-row > .cell.selected {
2825
- background-color: var(--tbw-range-selection-bg);
2826
- }
2827
- :host .data-grid-row > .cell.selected.top {
2828
- border-top: 2px solid var(--tbw-range-border-color);
2829
- }
2830
- :host .data-grid-row > .cell.selected.bottom {
2831
- border-bottom: 2px solid var(--tbw-range-border-color);
2832
- }
2833
- :host .data-grid-row > .cell.selected.first {
2834
- border-left: 2px solid var(--tbw-range-border-color);
2835
- }
2836
- :host .data-grid-row > .cell.selected.last {
2837
- border-right: 2px solid var(--tbw-range-border-color);
2838
- }
2839
- `;
2949
+ styles = rt;
2840
2950
  }
2841
- function G(o, e, t) {
2951
+ function X(o, e, t) {
2842
2952
  return o.id !== void 0 ? String(o.id) : t ? `${t}-${e}` : String(e);
2843
2953
  }
2844
- function pe(o, e, t, n = null, i = 0) {
2845
- const s = e.childrenField ?? "children", r = [];
2954
+ function we(o, e, t, n = null, s = 0) {
2955
+ const i = e.childrenField ?? "children", r = [];
2846
2956
  for (let a = 0; a < o.length; a++) {
2847
- const l = o[a], f = G(l, a, n), p = l[s], g = Array.isArray(p) && p.length > 0, h = t.has(f);
2957
+ const l = o[a], d = X(l, a, n), u = l[i], g = Array.isArray(u) && u.length > 0, h = t.has(d);
2848
2958
  if (r.push({
2849
- key: f,
2959
+ key: d,
2850
2960
  data: l,
2851
- depth: i,
2961
+ depth: s,
2852
2962
  hasChildren: g,
2853
2963
  isExpanded: h,
2854
2964
  parentKey: n
2855
2965
  }), g && h) {
2856
- const c = pe(p, e, t, f, i + 1);
2966
+ const c = we(u, e, t, d, s + 1);
2857
2967
  r.push(...c);
2858
2968
  }
2859
2969
  }
2860
2970
  return r;
2861
2971
  }
2862
- function re(o, e) {
2972
+ function ae(o, e) {
2863
2973
  const t = new Set(o);
2864
2974
  return t.has(e) ? t.delete(e) : t.add(e), t;
2865
2975
  }
2866
- function W(o, e, t = null, n = 0) {
2867
- const i = e.childrenField ?? "children", s = /* @__PURE__ */ new Set();
2976
+ function F(o, e, t = null, n = 0) {
2977
+ const s = e.childrenField ?? "children", i = /* @__PURE__ */ new Set();
2868
2978
  for (let r = 0; r < o.length; r++) {
2869
- const a = o[r], l = G(a, r, t), f = a[i];
2870
- if (Array.isArray(f) && f.length > 0) {
2871
- s.add(l);
2872
- const p = W(f, e, l, n + 1);
2873
- for (const g of p) s.add(g);
2979
+ const a = o[r], l = X(a, r, t), d = a[s];
2980
+ if (Array.isArray(d) && d.length > 0) {
2981
+ i.add(l);
2982
+ const u = F(d, e, l, n + 1);
2983
+ for (const g of u) i.add(g);
2874
2984
  }
2875
2985
  }
2876
- return s;
2986
+ return i;
2877
2987
  }
2878
- function it() {
2988
+ function at() {
2879
2989
  return /* @__PURE__ */ new Set();
2880
2990
  }
2881
- function ge(o, e, t, n = null, i = 0) {
2882
- const s = t.childrenField ?? "children";
2991
+ function be(o, e, t, n = null, s = 0) {
2992
+ const i = t.childrenField ?? "children";
2883
2993
  for (let r = 0; r < o.length; r++) {
2884
- const a = o[r], l = G(a, r, n);
2994
+ const a = o[r], l = X(a, r, n);
2885
2995
  if (l === e)
2886
2996
  return [l];
2887
- const f = a[s];
2888
- if (Array.isArray(f) && f.length > 0) {
2889
- const p = ge(f, e, t, l, i + 1);
2890
- if (p)
2891
- return [l, ...p];
2997
+ const d = a[i];
2998
+ if (Array.isArray(d) && d.length > 0) {
2999
+ const u = be(d, e, t, l, s + 1);
3000
+ if (u)
3001
+ return [l, ...u];
2892
3002
  }
2893
3003
  }
2894
3004
  return null;
2895
3005
  }
2896
- function st(o, e, t, n) {
2897
- const i = ge(o, e, t);
2898
- if (!i) return n;
2899
- const s = new Set(n);
2900
- for (let r = 0; r < i.length - 1; r++)
2901
- s.add(i[r]);
2902
- return s;
3006
+ function ct(o, e, t, n) {
3007
+ const s = be(o, e, t);
3008
+ if (!s) return n;
3009
+ const i = new Set(n);
3010
+ for (let r = 0; r < s.length - 1; r++)
3011
+ i.add(s[r]);
3012
+ return i;
2903
3013
  }
2904
- function le(o, e = "children") {
3014
+ function ce(o, e = "children") {
2905
3015
  if (!Array.isArray(o) || o.length === 0) return !1;
2906
3016
  for (const t of o)
2907
3017
  if (t && Array.isArray(t[e]) && t[e].length > 0)
2908
3018
  return !0;
2909
3019
  return !1;
2910
3020
  }
2911
- function rt(o) {
3021
+ function dt(o) {
2912
3022
  if (!Array.isArray(o) || o.length === 0) return null;
2913
3023
  const e = ["children", "items", "nodes", "subRows", "nested"];
2914
3024
  for (const t of o)
@@ -2919,12 +3029,12 @@ function rt(o) {
2919
3029
  }
2920
3030
  return null;
2921
3031
  }
2922
- class at extends fe {
3032
+ const ht = ".tree-toggle{cursor:pointer;user-select:none;transition:transform .2s}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}";
3033
+ class pt extends ge {
2923
3034
  name = "tree";
2924
3035
  version = "1.0.0";
2925
3036
  get defaultConfig() {
2926
3037
  return {
2927
- enabled: !0,
2928
3038
  childrenField: "children",
2929
3039
  autoDetect: !0,
2930
3040
  defaultExpanded: !1,
@@ -2952,15 +3062,15 @@ class at extends fe {
2952
3062
  */
2953
3063
  detect(e) {
2954
3064
  if (!this.config.autoDetect) return !1;
2955
- const t = this.config.childrenField ?? rt(e) ?? "children";
2956
- return le(e, t);
3065
+ const t = this.config.childrenField ?? dt(e) ?? "children";
3066
+ return ce(e, t);
2957
3067
  }
2958
3068
  // ===== Data Processing =====
2959
3069
  processRows(e) {
2960
3070
  const t = this.config.childrenField ?? "children";
2961
- if (!le(e, t))
3071
+ if (!ce(e, t))
2962
3072
  return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
2963
- this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = W(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = pe(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
3073
+ this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = F(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = we(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
2964
3074
  for (const n of this.flattenedRows)
2965
3075
  this.rowKeyMap.set(n.key, n);
2966
3076
  return this.flattenedRows.map((n) => ({
@@ -2973,31 +3083,31 @@ class at extends fe {
2973
3083
  }
2974
3084
  processColumns(e) {
2975
3085
  if (this.flattenedRows.length === 0) return [...e];
2976
- const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, i = [...e];
2977
- if (i.length > 0) {
2978
- const s = { ...i[0] }, r = s.viewRenderer;
3086
+ const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, s = [...e];
3087
+ if (s.length > 0) {
3088
+ const i = { ...s[0] }, r = i.viewRenderer;
2979
3089
  if (r?.__treeWrapped)
2980
- return i;
3090
+ return s;
2981
3091
  const a = (l) => {
2982
- const { value: f, row: p, column: g } = l, h = p.__treeDepth ?? 0, c = p.__treeHasChildren ?? !1, u = p.__treeExpanded ?? !1, d = document.createElement("span");
2983
- if (d.style.display = "flex", d.style.alignItems = "center", d.style.paddingLeft = `${h * t}px`, c && n) {
3092
+ const { value: d, row: u, column: g } = l, h = u.__treeDepth ?? 0, c = u.__treeHasChildren ?? !1, f = u.__treeExpanded ?? !1, p = document.createElement("span");
3093
+ if (p.style.display = "flex", p.style.alignItems = "center", p.style.paddingLeft = `${h * t}px`, c && n) {
2984
3094
  const m = document.createElement("span");
2985
- m.className = "tree-toggle", this.setIcon(m, this.resolveIcon(u ? "collapse" : "expand")), m.style.cursor = "pointer", m.style.marginRight = "4px", m.style.fontSize = "10px", m.setAttribute("data-tree-key", p.__treeKey), d.appendChild(m);
3095
+ m.className = "tree-toggle", this.setIcon(m, this.resolveIcon(f ? "collapse" : "expand")), m.style.cursor = "pointer", m.style.marginRight = "4px", m.style.fontSize = "10px", m.setAttribute("data-tree-key", u.__treeKey), p.appendChild(m);
2986
3096
  } else if (n) {
2987
3097
  const m = document.createElement("span");
2988
- m.style.width = "14px", m.style.display = "inline-block", d.appendChild(m);
3098
+ m.style.width = "14px", m.style.display = "inline-block", p.appendChild(m);
2989
3099
  }
2990
- const b = document.createElement("span");
3100
+ const w = document.createElement("span");
2991
3101
  if (r) {
2992
3102
  const m = r(l);
2993
- m instanceof Node ? b.appendChild(m) : b.textContent = String(m ?? f ?? "");
3103
+ m instanceof Node ? w.appendChild(m) : w.textContent = String(m ?? d ?? "");
2994
3104
  } else
2995
- b.textContent = String(f ?? "");
2996
- return d.appendChild(b), d;
3105
+ w.textContent = String(d ?? "");
3106
+ return p.appendChild(w), p;
2997
3107
  };
2998
- a.__treeWrapped = !0, s.viewRenderer = a, i[0] = s;
3108
+ a.__treeWrapped = !0, i.viewRenderer = a, s[0] = i;
2999
3109
  }
3000
- return i;
3110
+ return s;
3001
3111
  }
3002
3112
  // ===== Event Handlers =====
3003
3113
  onCellClick(e) {
@@ -3005,12 +3115,12 @@ class at extends fe {
3005
3115
  if (!t?.classList.contains("tree-toggle")) return !1;
3006
3116
  const n = t.getAttribute("data-tree-key");
3007
3117
  if (!n) return !1;
3008
- const i = this.rowKeyMap.get(n);
3009
- return i ? (this.expandedKeys = re(this.expandedKeys, n), this.emit("tree-expand", {
3118
+ const s = this.rowKeyMap.get(n);
3119
+ return s ? (this.expandedKeys = ae(this.expandedKeys, n), this.emit("tree-expand", {
3010
3120
  key: n,
3011
- row: i.data,
3121
+ row: s.data,
3012
3122
  expanded: this.expandedKeys.has(n),
3013
- depth: i.depth
3123
+ depth: s.depth
3014
3124
  }), this.requestRender(), !0) : !1;
3015
3125
  }
3016
3126
  // ===== Public API =====
@@ -3030,19 +3140,19 @@ class at extends fe {
3030
3140
  * Toggle the expansion state of a node.
3031
3141
  */
3032
3142
  toggle(e) {
3033
- this.expandedKeys = re(this.expandedKeys, e), this.requestRender();
3143
+ this.expandedKeys = ae(this.expandedKeys, e), this.requestRender();
3034
3144
  }
3035
3145
  /**
3036
3146
  * Expand all nodes in the tree.
3037
3147
  */
3038
3148
  expandAll() {
3039
- this.expandedKeys = W(this.rows, this.config), this.requestRender();
3149
+ this.expandedKeys = F(this.rows, this.config), this.requestRender();
3040
3150
  }
3041
3151
  /**
3042
3152
  * Collapse all nodes in the tree.
3043
3153
  */
3044
3154
  collapseAll() {
3045
- this.expandedKeys = it(), this.requestRender();
3155
+ this.expandedKeys = at(), this.requestRender();
3046
3156
  }
3047
3157
  /**
3048
3158
  * Check if a node is currently expanded.
@@ -3072,21 +3182,12 @@ class at extends fe {
3072
3182
  * Expand all ancestors of a node to make it visible.
3073
3183
  */
3074
3184
  expandToKey(e) {
3075
- this.expandedKeys = st(this.rows, e, this.config, this.expandedKeys), this.requestRender();
3185
+ this.expandedKeys = ct(this.rows, e, this.config, this.expandedKeys), this.requestRender();
3076
3186
  }
3077
3187
  // ===== Styles =====
3078
- styles = `
3079
- .tree-toggle {
3080
- cursor: pointer;
3081
- user-select: none;
3082
- transition: transform 0.2s;
3083
- }
3084
- .tree-toggle:hover {
3085
- color: var(--tbw-tree-accent, var(--tbw-color-accent));
3086
- }
3087
- `;
3188
+ styles = ht;
3088
3189
  }
3089
- const y = {
3190
+ const E = {
3090
3191
  // Root structure
3091
3192
  ROOT: "tbw-grid-root",
3092
3193
  HEADER: "header",
@@ -3131,31 +3232,31 @@ const y = {
3131
3232
  // Selection
3132
3233
  RANGE_SELECTION: "range-selection",
3133
3234
  SELECTION_OVERLAY: "selection-overlay"
3134
- }, D = {
3235
+ }, N = {
3135
3236
  ROW_INDEX: "data-row-index",
3136
3237
  COL_INDEX: "data-col-index",
3137
3238
  FIELD: "data-field",
3138
3239
  GROUP_KEY: "data-group-key",
3139
3240
  TREE_LEVEL: "data-tree-level",
3140
3241
  STICKY: "data-sticky"
3141
- }, ct = {
3142
- ROOT: `.${y.ROOT}`,
3143
- HEADER: `.${y.HEADER}`,
3144
- HEADER_ROW: `.${y.HEADER_ROW}`,
3145
- HEADER_CELL: `.${y.HEADER_CELL}`,
3146
- ROWS_VIEWPORT: `.${y.ROWS_VIEWPORT}`,
3147
- ROWS_CONTAINER: `.${y.ROWS_CONTAINER}`,
3148
- DATA_ROW: `.${y.DATA_ROW}`,
3149
- DATA_CELL: `.${y.DATA_CELL}`,
3150
- GROUP_ROW: `.${y.GROUP_ROW}`,
3242
+ }, gt = {
3243
+ ROOT: `.${E.ROOT}`,
3244
+ HEADER: `.${E.HEADER}`,
3245
+ HEADER_ROW: `.${E.HEADER_ROW}`,
3246
+ HEADER_CELL: `.${E.HEADER_CELL}`,
3247
+ ROWS_VIEWPORT: `.${E.ROWS_VIEWPORT}`,
3248
+ ROWS_CONTAINER: `.${E.ROWS_CONTAINER}`,
3249
+ DATA_ROW: `.${E.DATA_ROW}`,
3250
+ DATA_CELL: `.${E.DATA_CELL}`,
3251
+ GROUP_ROW: `.${E.GROUP_ROW}`,
3151
3252
  // By data attribute
3152
- ROW_BY_INDEX: (o) => `.${y.DATA_ROW}[${D.ROW_INDEX}="${o}"]`,
3153
- CELL_BY_FIELD: (o) => `.${y.DATA_CELL}[${D.FIELD}="${o}"]`,
3154
- CELL_AT: (o, e) => `.${y.DATA_ROW}[${D.ROW_INDEX}="${o}"] .${y.DATA_CELL}[${D.COL_INDEX}="${e}"]`,
3253
+ ROW_BY_INDEX: (o) => `.${E.DATA_ROW}[${N.ROW_INDEX}="${o}"]`,
3254
+ CELL_BY_FIELD: (o) => `.${E.DATA_CELL}[${N.FIELD}="${o}"]`,
3255
+ CELL_AT: (o, e) => `.${E.DATA_ROW}[${N.ROW_INDEX}="${o}"] .${E.DATA_CELL}[${N.COL_INDEX}="${e}"]`,
3155
3256
  // State selectors
3156
- SELECTED_ROWS: `.${y.DATA_ROW}.${y.SELECTED}`,
3157
- EDITING_CELL: `.${y.DATA_CELL}.${y.EDITING}`
3158
- }, dt = {
3257
+ SELECTED_ROWS: `.${E.DATA_ROW}.${E.SELECTED}`,
3258
+ EDITING_CELL: `.${E.DATA_CELL}.${E.EDITING}`
3259
+ }, wt = {
3159
3260
  // Colors
3160
3261
  COLOR_BG: "--tbw-color-bg",
3161
3262
  COLOR_FG: "--tbw-color-fg",
@@ -3177,7 +3278,7 @@ const y = {
3177
3278
  // Borders
3178
3279
  BORDER_RADIUS: "--tbw-border-radius",
3179
3280
  FOCUS_OUTLINE: "--tbw-focus-outline"
3180
- }, ht = {
3281
+ }, bt = {
3181
3282
  CELL_COMMIT: "cell-commit",
3182
3283
  ROW_COMMIT: "row-commit",
3183
3284
  CHANGED_ROWS_RESET: "changed-rows-reset",
@@ -3188,7 +3289,7 @@ const y = {
3188
3289
  ACTIVATE_CELL: "activate-cell",
3189
3290
  GROUP_TOGGLE: "group-toggle",
3190
3291
  COLUMN_STATE_CHANGE: "column-state-change"
3191
- }, ut = {
3292
+ }, mt = {
3192
3293
  // Selection plugin
3193
3294
  SELECTION_CHANGE: "selection-change",
3194
3295
  // Tree plugin
@@ -3219,10 +3320,10 @@ const y = {
3219
3320
  DETAIL_EXPAND: "detail-expand",
3220
3321
  // Grouping rows plugin
3221
3322
  GROUP_EXPAND: "group-expand"
3222
- }, q = {
3323
+ }, B = {
3223
3324
  sum: (o, e) => o.reduce((t, n) => t + (Number(n[e]) || 0), 0),
3224
3325
  avg: (o, e) => {
3225
- const t = o.reduce((n, i) => n + (Number(i[e]) || 0), 0);
3326
+ const t = o.reduce((n, s) => n + (Number(s[e]) || 0), 0);
3226
3327
  return o.length ? t / o.length : 0;
3227
3328
  },
3228
3329
  count: (o) => o.length,
@@ -3230,66 +3331,83 @@ const y = {
3230
3331
  max: (o, e) => Math.max(...o.map((t) => Number(t[e]) || -1 / 0)),
3231
3332
  first: (o, e) => o[0]?.[e],
3232
3333
  last: (o, e) => o[o.length - 1]?.[e]
3233
- }, P = /* @__PURE__ */ new Map(), x = {
3334
+ }, M = /* @__PURE__ */ new Map(), T = {
3234
3335
  /**
3235
3336
  * Register a custom aggregator function.
3236
3337
  */
3237
3338
  register(o, e) {
3238
- P.set(o, e);
3339
+ M.set(o, e);
3239
3340
  },
3240
3341
  /**
3241
3342
  * Unregister a custom aggregator function.
3242
3343
  */
3243
3344
  unregister(o) {
3244
- P.delete(o);
3345
+ M.delete(o);
3245
3346
  },
3246
3347
  /**
3247
3348
  * Get an aggregator function by reference.
3248
3349
  */
3249
3350
  get(o) {
3250
3351
  if (o !== void 0)
3251
- return typeof o == "function" ? o : P.get(o) ?? q[o];
3352
+ return typeof o == "function" ? o : M.get(o) ?? B[o];
3252
3353
  },
3253
3354
  /**
3254
3355
  * Run an aggregator on a set of rows.
3255
3356
  */
3256
3357
  run(o, e, t, n) {
3257
- const i = this.get(o);
3258
- return i ? i(e, t, n) : void 0;
3358
+ const s = this.get(o);
3359
+ return s ? s(e, t, n) : void 0;
3259
3360
  },
3260
3361
  /**
3261
3362
  * Check if an aggregator exists.
3262
3363
  */
3263
3364
  has(o) {
3264
- return P.has(o) || o in q;
3365
+ return M.has(o) || o in B;
3265
3366
  },
3266
3367
  /**
3267
3368
  * List all available aggregator names.
3268
3369
  */
3269
3370
  list() {
3270
- return [...Object.keys(q), ...P.keys()];
3371
+ return [...Object.keys(B), ...M.keys()];
3271
3372
  }
3272
- }, ft = x.register.bind(x), pt = x.unregister.bind(x), gt = x.get.bind(x), wt = x.run.bind(x), bt = x.list.bind(x);
3373
+ }, de = {
3374
+ sum: (o) => o.reduce((e, t) => e + t, 0),
3375
+ avg: (o) => o.length ? o.reduce((e, t) => e + t, 0) / o.length : 0,
3376
+ count: (o) => o.length,
3377
+ min: (o) => o.length ? Math.min(...o) : 0,
3378
+ max: (o) => o.length ? Math.max(...o) : 0,
3379
+ first: (o) => o[0] ?? 0,
3380
+ last: (o) => o[o.length - 1] ?? 0
3381
+ };
3382
+ function ut(o) {
3383
+ return de[o] ?? de.sum;
3384
+ }
3385
+ function vt(o, e) {
3386
+ return ut(o)(e);
3387
+ }
3388
+ const yt = T.register.bind(T), Ct = T.unregister.bind(T), Et = T.get.bind(T), Rt = T.run.bind(T), _t = T.list.bind(T);
3273
3389
  export {
3274
- fe as BaseGridPlugin,
3275
- ce as DEFAULT_GRID_ICONS,
3276
- ht as DGEvents,
3277
- I as DataGridElement,
3278
- M as FitModeEnum,
3279
- dt as GridCSSVars,
3280
- y as GridClasses,
3281
- D as GridDataAttrs,
3282
- I as GridElement,
3283
- ct as GridSelectors,
3284
- ut as PluginEvents,
3285
- Je as PluginManager,
3286
- lt as SelectionPlugin,
3287
- at as TreePlugin,
3288
- x as aggregatorRegistry,
3289
- gt as getAggregator,
3290
- bt as listAggregators,
3291
- ft as registerAggregator,
3292
- wt as runAggregator,
3293
- pt as unregisterAggregator
3390
+ ge as BaseGridPlugin,
3391
+ S as DEFAULT_GRID_ICONS,
3392
+ bt as DGEvents,
3393
+ $ as DataGridElement,
3394
+ O as FitModeEnum,
3395
+ wt as GridCSSVars,
3396
+ E as GridClasses,
3397
+ N as GridDataAttrs,
3398
+ $ as GridElement,
3399
+ gt as GridSelectors,
3400
+ mt as PluginEvents,
3401
+ tt as PluginManager,
3402
+ ft as SelectionPlugin,
3403
+ pt as TreePlugin,
3404
+ T as aggregatorRegistry,
3405
+ Et as getAggregator,
3406
+ ut as getValueAggregator,
3407
+ _t as listAggregators,
3408
+ yt as registerAggregator,
3409
+ Rt as runAggregator,
3410
+ vt as runValueAggregator,
3411
+ Ct as unregisterAggregator
3294
3412
  };
3295
3413
  //# sourceMappingURL=index.js.map