@toolbox-web/grid 0.0.3 → 0.0.4

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 (41) hide show
  1. package/all.d.ts +21 -0
  2. package/all.js +405 -402
  3. package/all.js.map +1 -1
  4. package/index.d.ts +26 -0
  5. package/index.js +924 -871
  6. package/index.js.map +1 -1
  7. package/lib/plugins/clipboard/index.js.map +1 -1
  8. package/lib/plugins/column-virtualization/index.js.map +1 -1
  9. package/lib/plugins/context-menu/index.js.map +1 -1
  10. package/lib/plugins/export/index.js.map +1 -1
  11. package/lib/plugins/filtering/index.js.map +1 -1
  12. package/lib/plugins/grouping-columns/index.js.map +1 -1
  13. package/lib/plugins/grouping-rows/index.js.map +1 -1
  14. package/lib/plugins/master-detail/index.js.map +1 -1
  15. package/lib/plugins/multi-sort/index.js.map +1 -1
  16. package/lib/plugins/pinned-columns/index.js.map +1 -1
  17. package/lib/plugins/pinned-rows/index.js.map +1 -1
  18. package/lib/plugins/pivot/index.js.map +1 -1
  19. package/lib/plugins/reorder/index.js +23 -20
  20. package/lib/plugins/reorder/index.js.map +1 -1
  21. package/lib/plugins/selection/index.js +110 -92
  22. package/lib/plugins/selection/index.js.map +1 -1
  23. package/lib/plugins/server-side/index.js.map +1 -1
  24. package/lib/plugins/tree/index.js.map +1 -1
  25. package/lib/plugins/undo-redo/index.js.map +1 -1
  26. package/lib/plugins/visibility/index.js.map +1 -1
  27. package/package.json +4 -1
  28. package/themes/dg-theme-contrast.css +43 -43
  29. package/themes/dg-theme-large.css +54 -54
  30. package/themes/dg-theme-standard.css +19 -19
  31. package/themes/dg-theme-vibrant.css +16 -16
  32. package/umd/grid.all.umd.js +24 -24
  33. package/umd/grid.all.umd.js.map +1 -1
  34. package/umd/grid.umd.js +15 -15
  35. package/umd/grid.umd.js.map +1 -1
  36. package/umd/plugins/multi-sort.umd.js.map +1 -1
  37. package/umd/plugins/reorder.umd.js +1 -1
  38. package/umd/plugins/reorder.umd.js.map +1 -1
  39. package/umd/plugins/selection.umd.js +2 -2
  40. package/umd/plugins/selection.umd.js.map +1 -1
  41. package/umd/plugins/visibility.umd.js.map +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
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-success);--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{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}";
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
2
  function be(o) {
3
3
  const e = /* @__PURE__ */ new Map();
4
4
  return o.sortState && e.set(o.sortState.field, {
@@ -9,58 +9,58 @@ function be(o) {
9
9
  function ae(o, e) {
10
10
  const t = o._columns, n = be(o);
11
11
  return {
12
- columns: t.map((i, s) => {
13
- const r = {
14
- field: i.field,
15
- order: s,
12
+ columns: t.map((s, i) => {
13
+ const l = {
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
- }, l = i;
19
- l.__renderedWidth !== void 0 ? r.width = l.__renderedWidth : i.width !== void 0 && (r.width = typeof i.width == "string" ? parseFloat(i.width) : i.width);
20
- const a = n.get(i.field);
21
- a && (r.sort = a);
22
- for (const h of e)
23
- if (h.getColumnState) {
24
- const u = h.getColumnState(i.field);
25
- u && Object.assign(r, u);
18
+ }, r = s;
19
+ r.__renderedWidth !== void 0 ? l.width = r.__renderedWidth : s.width !== void 0 && (l.width = typeof s.width == "string" ? parseFloat(s.width) : s.width);
20
+ const a = n.get(s.field);
21
+ a && (l.sort = a);
22
+ for (const f of e)
23
+ if (f.getColumnState) {
24
+ const p = f.getColumnState(s.field);
25
+ p && Object.assign(l, p);
26
26
  }
27
- return r;
27
+ return l;
28
28
  })
29
29
  };
30
30
  }
31
31
  function ge(o, e, t, n) {
32
32
  if (!e.columns || e.columns.length === 0) return;
33
- const i = new Map(e.columns.map((l) => [l.field, l])), s = t.map((l) => {
34
- const a = i.get(l.field);
35
- if (!a) return l;
36
- const h = { ...l };
37
- return a.width !== void 0 && (h.width = a.width, h.__renderedWidth = a.width), a.visible !== void 0 && (h.hidden = !a.visible), h;
33
+ const s = new Map(e.columns.map((r) => [r.field, r])), i = t.map((r) => {
34
+ const a = s.get(r.field);
35
+ if (!a) return r;
36
+ const f = { ...r };
37
+ return a.width !== void 0 && (f.width = a.width, f.__renderedWidth = a.width), a.visible !== void 0 && (f.hidden = !a.visible), f;
38
38
  });
39
- s.sort((l, a) => {
40
- const h = i.get(l.field)?.order ?? 1 / 0, u = i.get(a.field)?.order ?? 1 / 0;
41
- return h - u;
42
- }), o._columns = s;
43
- const r = e.columns.filter((l) => l.sort !== void 0).sort((l, a) => (l.sort?.priority ?? 0) - (a.sort?.priority ?? 0));
44
- if (r.length > 0) {
45
- const l = r[0];
46
- l.sort && (o.sortState = {
47
- field: l.field,
48
- direction: l.sort.direction === "asc" ? 1 : -1
39
+ i.sort((r, a) => {
40
+ const f = s.get(r.field)?.order ?? 1 / 0, p = s.get(a.field)?.order ?? 1 / 0;
41
+ return f - p;
42
+ }), o._columns = i;
43
+ const l = e.columns.filter((r) => r.sort !== void 0).sort((r, a) => (r.sort?.priority ?? 0) - (a.sort?.priority ?? 0));
44
+ if (l.length > 0) {
45
+ const r = l[0];
46
+ r.sort && (o.sortState = {
47
+ field: r.field,
48
+ direction: r.sort.direction === "asc" ? 1 : -1
49
49
  });
50
50
  } else
51
51
  o.sortState = null;
52
- for (const l of n)
53
- if (l.applyColumnState)
52
+ for (const r of n)
53
+ if (r.applyColumnState)
54
54
  for (const a of e.columns)
55
- l.applyColumnState(a.field, a);
55
+ r.applyColumnState(a.field, a);
56
56
  }
57
57
  function me(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 = ae(o, e());
63
+ t(s);
64
64
  }, 100);
65
65
  };
66
66
  }
@@ -73,20 +73,20 @@ function ve(o) {
73
73
  }
74
74
  function ce(o, e) {
75
75
  if (e && e.length) {
76
- const s = {};
77
- return e.forEach((r) => {
78
- r.type && (s[r.field] = r.type);
79
- }), { columns: e, typeMap: s };
80
- }
81
- const t = o[0] || {}, n = Object.keys(t).map((s) => {
82
- const r = t[s], l = ve(r);
83
- return { field: s, header: s.charAt(0).toUpperCase() + s.slice(1), type: l };
84
- }), i = {};
85
- return n.forEach((s) => {
86
- i[s.field] = s.type || "string";
87
- }), { columns: n, typeMap: i };
88
- }
89
- const Ce = /{{\s*([^}]+)\s*}}/g, C = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, Ee = /__(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/, Re = /* @__PURE__ */ new Set([
76
+ const i = {};
77
+ return e.forEach((l) => {
78
+ l.type && (i[l.field] = l.type);
79
+ }), { columns: e, typeMap: i };
80
+ }
81
+ const t = o[0] || {}, n = Object.keys(t).map((i) => {
82
+ const l = t[i], r = ve(l);
83
+ return { field: i, header: i.charAt(0).toUpperCase() + i.slice(1), type: r };
84
+ }), s = {};
85
+ return n.forEach((i) => {
86
+ s[i.field] = i.type || "string";
87
+ }), { columns: n, typeMap: s };
88
+ }
89
+ const Ce = /{{\s*([^}]+)\s*}}/g, R = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, Ee = /__(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/, Re = /* @__PURE__ */ new Set([
90
90
  "script",
91
91
  "iframe",
92
92
  "object",
@@ -121,64 +121,64 @@ function N(o) {
121
121
  function Se(o) {
122
122
  const e = [], t = o.querySelectorAll("*");
123
123
  for (const n of t) {
124
- const i = n.tagName.toLowerCase();
125
- if (Re.has(i)) {
124
+ const s = n.tagName.toLowerCase();
125
+ if (Re.has(s)) {
126
126
  e.push(n);
127
127
  continue;
128
128
  }
129
- if ((i === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
130
- (l) => U.test(l.name) || l.name === "href" || l.name === "xlink:href"
129
+ if ((s === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
130
+ (r) => U.test(r.name) || r.name === "href" || r.name === "xlink:href"
131
131
  )) {
132
132
  e.push(n);
133
133
  continue;
134
134
  }
135
- const s = [];
136
- for (const r of n.attributes) {
137
- const l = r.name.toLowerCase();
138
- if (U.test(l)) {
139
- s.push(r.name);
135
+ const i = [];
136
+ for (const l of n.attributes) {
137
+ const r = l.name.toLowerCase();
138
+ if (U.test(r)) {
139
+ i.push(l.name);
140
140
  continue;
141
141
  }
142
- if (_e.has(l) && Ae.test(r.value)) {
143
- s.push(r.name);
142
+ if (_e.has(r) && Ae.test(l.value)) {
143
+ i.push(l.name);
144
144
  continue;
145
145
  }
146
- if (l === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(r.value)) {
147
- s.push(r.name);
146
+ if (r === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(l.value)) {
147
+ i.push(l.name);
148
148
  continue;
149
149
  }
150
150
  }
151
- s.forEach((r) => n.removeAttribute(r));
151
+ i.forEach((l) => n.removeAttribute(l));
152
152
  }
153
153
  e.forEach((n) => n.remove());
154
154
  }
155
155
  function de(o, e) {
156
156
  if (!o || o.indexOf("{{") === -1) return o;
157
- const t = [], n = o.replace(Ce, (l, a) => {
158
- const h = xe(a, e);
159
- return t.push({ expr: a.trim(), result: h }), h;
160
- }), i = Te(n), s = t.length && t.every((l) => l.result === "" || l.result === C);
161
- return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) || s ? "" : i;
157
+ const t = [], n = o.replace(Ce, (r, a) => {
158
+ const f = xe(a, e);
159
+ return t.push({ expr: a.trim(), result: f }), f;
160
+ }), s = Te(n), i = t.length && t.every((r) => r.result === "" || r.result === R);
161
+ return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) || i ? "" : s;
162
162
  }
163
163
  function xe(o, e) {
164
- if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return C;
165
- if (o === "value") return e.value == null ? C : String(e.value);
164
+ if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return R;
165
+ if (o === "value") return e.value == null ? R : String(e.value);
166
166
  if (o.startsWith("row.") && !/[()?]/.test(o) && !o.includes(":")) {
167
- const n = o.slice(4), i = e.row ? e.row[n] : void 0;
168
- return i == null ? C : String(i);
167
+ const n = o.slice(4), s = e.row ? e.row[n] : void 0;
168
+ return s == null ? R : String(s);
169
169
  }
170
- if (o.length > 80 || !ye.test(o) || Ee.test(o)) return C;
170
+ if (o.length > 80 || !ye.test(o) || Ee.test(o)) return R;
171
171
  const t = o.match(/\./g);
172
- if (t && t.length > 1) return C;
172
+ if (t && t.length > 1) return R;
173
173
  try {
174
- const i = new Function("value", "row", `return (${o});`)(e.value, e.row), s = i == null ? "" : String(i);
175
- return /Reflect|Proxy|ownKeys/.test(s) ? C : s || C;
174
+ const s = new Function("value", "row", `return (${o});`)(e.value, e.row), i = s == null ? "" : String(s);
175
+ return /Reflect|Proxy|ownKeys/.test(i) ? R : i || R;
176
176
  } catch {
177
- return C;
177
+ return R;
178
178
  }
179
179
  }
180
180
  function Te(o) {
181
- return o && o.replace(new RegExp(C, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
181
+ return o && o.replace(new RegExp(R, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
182
182
  }
183
183
  function Le(o) {
184
184
  if (/Reflect|Proxy|ownKeys/.test(o.textContent || "")) {
@@ -200,15 +200,15 @@ function ke(o) {
200
200
  return Array.from(o.querySelectorAll("tbw-grid-column")).map((t) => {
201
201
  const n = t.getAttribute("field") || "";
202
202
  if (!n) return null;
203
- const i = t.getAttribute("type") || void 0, r = i && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(i) ? i : void 0, l = t.getAttribute("header") || void 0, a = t.hasAttribute("sortable"), h = t.hasAttribute("editable"), u = { field: n, type: r, header: l, sortable: a, editable: h };
204
- t.hasAttribute("resizable") && (u.resizable = !0), t.hasAttribute("sizable") && (u.resizable = !0);
203
+ const s = t.getAttribute("type") || void 0, l = s && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(s) ? s : void 0, r = t.getAttribute("header") || void 0, a = t.hasAttribute("sortable"), f = t.hasAttribute("editable"), p = { field: n, type: l, header: r, sortable: a, editable: f };
204
+ t.hasAttribute("resizable") && (p.resizable = !0), t.hasAttribute("sizable") && (p.resizable = !0);
205
205
  const w = t.getAttribute("options");
206
- w && (u.options = w.split(",").map((f) => {
207
- const [b, y] = f.includes(":") ? f.split(":") : [f.trim(), f.trim()];
206
+ w && (p.options = w.split(",").map((u) => {
207
+ const [b, y] = u.includes(":") ? u.split(":") : [u.trim(), u.trim()];
208
208
  return { value: b.trim(), label: y?.trim() || b.trim() };
209
209
  }));
210
- const c = t.querySelector("tbw-grid-column-view"), d = t.querySelector("tbw-grid-column-editor"), p = t.querySelector("tbw-grid-column-header");
211
- return c && (u.__viewTemplate = c), d && (u.__editorTemplate = d), p && (u.__headerTemplate = p), u;
210
+ const h = t.querySelector("tbw-grid-column-view"), c = t.querySelector("tbw-grid-column-editor"), d = t.querySelector("tbw-grid-column-header");
211
+ return h && (p.__viewTemplate = h), c && (p.__editorTemplate = c), d && (p.__headerTemplate = d), p;
212
212
  }).filter((t) => !!t);
213
213
  }
214
214
  function Pe(o, e) {
@@ -216,14 +216,14 @@ function Pe(o, e) {
216
216
  if (!o || !o.length) return e || [];
217
217
  if (!e || !e.length) return o;
218
218
  const t = {};
219
- e.forEach((i) => t[i.field] = i);
220
- const n = o.map((i) => {
221
- const s = t[i.field];
222
- if (!s) return i;
223
- const r = { ...i };
224
- 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;
219
+ e.forEach((s) => t[s.field] = s);
220
+ const n = o.map((s) => {
221
+ const i = t[s.field];
222
+ if (!i) return s;
223
+ const l = { ...s };
224
+ return i.header && !l.header && (l.header = i.header), i.type && !l.type && (l.type = i.type), l.sortable = s.sortable || i.sortable, (s.resizable === !0 || i.resizable === !0) && (l.resizable = !0), l.editable = s.editable || i.editable, i.__viewTemplate && (l.__viewTemplate = i.__viewTemplate), i.__editorTemplate && (l.__editorTemplate = i.__editorTemplate), i.__headerTemplate && (l.__headerTemplate = i.__headerTemplate), delete t[s.field], l;
225
225
  });
226
- return Object.keys(t).forEach((i) => n.push(t[i])), n;
226
+ return Object.keys(t).forEach((s) => n.push(t[s])), n;
227
227
  }
228
228
  function B(o, e) {
229
229
  try {
@@ -238,8 +238,8 @@ function Oe(o) {
238
238
  o.querySelectorAll("tbw-grid-column")
239
239
  ), o.__lightDomColumnsCache = o.__originalColumnNodes.length ? ke(o) : []);
240
240
  const e = o.__lightDomColumnsCache, t = Pe(o._columns, e);
241
- t.forEach((i) => {
242
- i.__viewTemplate && !i.__compiledView && (i.__compiledView = X(i.__viewTemplate.innerHTML)), i.__editorTemplate && !i.__compiledEditor && (i.__compiledEditor = X(i.__editorTemplate.innerHTML));
241
+ t.forEach((s) => {
242
+ s.__viewTemplate && !s.__compiledView && (s.__compiledView = X(s.__viewTemplate.innerHTML)), s.__editorTemplate && !s.__compiledEditor && (s.__compiledEditor = X(s.__editorTemplate.innerHTML));
243
243
  });
244
244
  const { columns: n } = ce(o._rows, t);
245
245
  o._columns = n;
@@ -250,18 +250,18 @@ function Me(o) {
250
250
  const t = o.headerRowEl?.children || [];
251
251
  if (!t.length) return;
252
252
  let n = !1;
253
- o.visibleColumns.forEach((i, s) => {
254
- if (i.width) return;
255
- const r = t[s];
256
- let l = r ? r.scrollWidth : 0;
253
+ o.visibleColumns.forEach((s, i) => {
254
+ if (s.width) return;
255
+ const l = t[i];
256
+ let r = l ? l.scrollWidth : 0;
257
257
  for (const a of o.rowPool) {
258
- const h = a.children[s];
259
- if (h) {
260
- const u = h.scrollWidth;
261
- u > l && (l = u);
258
+ const f = a.children[i];
259
+ if (f) {
260
+ const p = f.scrollWidth;
261
+ p > r && (r = p);
262
262
  }
263
263
  }
264
- l > 0 && (i.width = l + 2, i.__autoSized = !0, n = !0);
264
+ r > 0 && (s.width = r + 2, s.__autoSized = !0, n = !0);
265
265
  }), n && he(o), o.__didInitialAutoSize = !0;
266
266
  }
267
267
  function he(o) {
@@ -296,21 +296,21 @@ function De(o) {
296
296
  case "typeahead":
297
297
  return (e) => {
298
298
  const t = document.createElement("select");
299
- e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((s) => {
300
- const r = document.createElement("option");
301
- 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);
299
+ e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((i) => {
300
+ const l = document.createElement("option");
301
+ l.value = String(i.value), l.textContent = i.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(i.value) || !e.column.multi && e.value === i.value) && (l.selected = !0), t.appendChild(l);
302
302
  });
303
- const i = () => {
303
+ const s = () => {
304
304
  if (e.column.multi) {
305
- const s = [];
306
- Array.from(t.selectedOptions).forEach((r) => {
307
- s.push(r.value);
308
- }), e.commit(s);
305
+ const i = [];
306
+ Array.from(t.selectedOptions).forEach((l) => {
307
+ i.push(l.value);
308
+ }), e.commit(i);
309
309
  } else
310
310
  e.commit(t.value);
311
311
  };
312
- return t.addEventListener("change", i), t.addEventListener("blur", i), t.addEventListener("keydown", (s) => {
313
- s.key === "Escape" && e.cancel();
312
+ return t.addEventListener("change", s), t.addEventListener("blur", s), t.addEventListener("keydown", (i) => {
313
+ i.key === "Escape" && e.cancel();
314
314
  }), t.focus(), t;
315
315
  };
316
316
  default:
@@ -325,22 +325,22 @@ function De(o) {
325
325
  function He(o, e) {
326
326
  if (o.dispatchKeyDown?.(e))
327
327
  return;
328
- 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, l = e.composedPath ? e.composedPath() : [], a = l && l.length ? l[0] : e.target, h = (u) => {
329
- if (!u) return !1;
330
- const w = u.tagName;
331
- return !!(w === "INPUT" || w === "SELECT" || w === "TEXTAREA" || u.isContentEditable);
328
+ const t = o._rows.length - 1, n = o.visibleColumns.length - 1, s = o.activeEditRows !== void 0 && o.activeEditRows !== -1, l = o.visibleColumns[o.focusCol]?.type, r = e.composedPath ? e.composedPath() : [], a = r && r.length ? r[0] : e.target, f = (p) => {
329
+ if (!p) return !1;
330
+ const w = p.tagName;
331
+ return !!(w === "INPUT" || w === "SELECT" || w === "TEXTAREA" || p.isContentEditable);
332
332
  };
333
- if (!(h(a) && (e.key === "Home" || e.key === "End")) && !(h(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(i && (r === "select" || r === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
333
+ if (!(f(a) && (e.key === "Home" || e.key === "End")) && !(f(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(s && (l === "select" || l === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
334
334
  switch (e.key) {
335
335
  case "Tab": {
336
336
  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), M(o);
337
337
  return;
338
338
  }
339
339
  case "ArrowDown":
340
- i && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.min(t, o.focusRow + 1), e.preventDefault();
340
+ s && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.min(t, o.focusRow + 1), e.preventDefault();
341
341
  break;
342
342
  case "ArrowUp":
343
- i && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.max(0, o.focusRow - 1), e.preventDefault();
343
+ s && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.max(0, o.focusRow - 1), e.preventDefault();
344
344
  break;
345
345
  case "ArrowRight":
346
346
  o.focusCol = Math.min(n, o.focusCol + 1), e.preventDefault();
@@ -372,29 +372,29 @@ function He(o, e) {
372
372
  }
373
373
  function M(o) {
374
374
  if (o.virtualization?.enabled) {
375
- const { rowHeight: i } = o.virtualization, s = o, r = o.focusRow * i;
376
- r < s.scrollTop ? s.scrollTop = r : r + i > s.scrollTop + s.clientHeight && (s.scrollTop = r - s.clientHeight + i);
375
+ const { rowHeight: s } = o.virtualization, i = o, l = o.focusRow * s;
376
+ l < i.scrollTop ? i.scrollTop = l : l + s > i.scrollTop + i.clientHeight && (i.scrollTop = l - i.clientHeight + s);
377
377
  }
378
- 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) => {
379
- i.setAttribute("aria-selected", "false");
378
+ 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) => {
379
+ s.setAttribute("aria-selected", "false");
380
380
  });
381
381
  const e = o.focusRow, t = o.virtualization.start ?? 0, n = o.virtualization.end ?? o._rows.length;
382
382
  if (e >= t && e < n) {
383
- const s = o.bodyEl.querySelectorAll(".data-grid-row")[e - t]?.children[o.focusCol];
384
- if (s) {
385
- if (s.classList.add("cell-focus"), s.setAttribute("aria-selected", "true"), o.activeEditRows !== void 0 && o.activeEditRows !== -1 && s.classList.contains("editing")) {
386
- const r = s.querySelector(
383
+ const i = o.bodyEl.querySelectorAll(".data-grid-row")[e - t]?.children[o.focusCol];
384
+ if (i) {
385
+ if (i.classList.add("cell-focus"), i.setAttribute("aria-selected", "true"), o.activeEditRows !== void 0 && o.activeEditRows !== -1 && i.classList.contains("editing")) {
386
+ const l = i.querySelector(
387
387
  'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
388
388
  );
389
- if (r && document.activeElement !== r)
389
+ if (l && document.activeElement !== l)
390
390
  try {
391
- r.focus();
391
+ l.focus();
392
392
  } catch {
393
393
  }
394
- } else if (!s.contains(document.activeElement)) {
395
- s.hasAttribute("tabindex") || s.setAttribute("tabindex", "-1");
394
+ } else if (!i.contains(document.activeElement)) {
395
+ i.hasAttribute("tabindex") || i.setAttribute("tabindex", "-1");
396
396
  try {
397
- s.focus({ preventScroll: !0 });
397
+ i.focus({ preventScroll: !0 });
398
398
  } catch {
399
399
  }
400
400
  }
@@ -405,131 +405,135 @@ const ze = "__cellDisplayCache", Ne = "__cellCacheEpoch";
405
405
  function j(o) {
406
406
  o[ze] = void 0, o[Ne] = void 0, o.__hasSpecialColumns = void 0;
407
407
  }
408
- function qe(o, e, t, n, i) {
409
- const s = Math.max(0, t - e), r = o.bodyEl, l = o.visibleColumns, a = l.length;
410
- let h = o.__cachedHeaderRowCount;
411
- for (h === void 0 && (h = o.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, o.__cachedHeaderRowCount = h); o.rowPool.length < s; ) {
408
+ function qe(o, e, t, n, s) {
409
+ const i = Math.max(0, t - e), l = o.bodyEl, r = o.visibleColumns, a = r.length;
410
+ let f = o.__cachedHeaderRowCount;
411
+ for (f === void 0 && (f = o.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, o.__cachedHeaderRowCount = f); o.rowPool.length < i; ) {
412
412
  const w = document.createElement("div");
413
- w.className = "data-grid-row", w.setAttribute("role", "row"), w.addEventListener("click", (c) => Z(o, c, w, !1)), w.addEventListener("dblclick", (c) => Z(o, c, w, !0)), o.rowPool.push(w);
413
+ w.className = "data-grid-row", w.setAttribute("role", "row"), w.addEventListener("click", (h) => Z(o, h, w, !1)), w.addEventListener("dblclick", (h) => Z(o, h, w, !0)), o.rowPool.push(w);
414
414
  }
415
- if (o.rowPool.length > s) {
416
- for (let w = s; w < o.rowPool.length; w++) {
417
- const c = o.rowPool[w];
418
- c.parentNode === r && c.remove();
415
+ if (o.rowPool.length > i) {
416
+ for (let w = i; w < o.rowPool.length; w++) {
417
+ const h = o.rowPool[w];
418
+ h.parentNode === l && h.remove();
419
419
  }
420
- o.rowPool.length = s;
420
+ o.rowPool.length = i;
421
421
  }
422
- const u = i && o.__hasRenderRowPlugins !== !1;
423
- for (let w = 0; w < s; w++) {
424
- const c = e + w, d = o._rows[c], p = o.rowPool[w];
425
- if (p.setAttribute("aria-rowindex", String(c + h + 1)), u && i(d, p, c)) {
426
- p.__epoch = n, p.__rowDataRef = d, p.parentNode !== r && r.appendChild(p);
422
+ const p = s && o.__hasRenderRowPlugins !== !1;
423
+ for (let w = 0; w < i; w++) {
424
+ const h = e + w, c = o._rows[h], d = o.rowPool[w];
425
+ if (d.setAttribute("aria-rowindex", String(h + f + 1)), p && s(c, d, h)) {
426
+ d.__epoch = n, d.__rowDataRef = c, d.parentNode !== l && l.appendChild(d);
427
427
  continue;
428
428
  }
429
- const f = p.__epoch, b = p.__rowDataRef, y = p.children.length, T = f === n && y === a, L = b !== d;
430
- let _ = !1;
431
- if (T && L) {
432
- for (let E = 0; E < a; E++)
433
- if (l[E].externalView && !p.querySelector(`.cell[data-col="${E}"] [data-external-view]`)) {
434
- _ = !0;
429
+ const u = d.__epoch, b = d.__rowDataRef, y = d.children.length, E = u === n && y === a, _ = b !== c;
430
+ let x = !1;
431
+ if (E && _) {
432
+ for (let A = 0; A < a; A++)
433
+ if (r[A].externalView && !d.querySelector(`.cell[data-col="${A}"] [data-external-view]`)) {
434
+ x = !0;
435
435
  break;
436
436
  }
437
437
  }
438
- !T || _ ? (p.__isCustomRow && (p.className = "data-grid-row", p.setAttribute("role", "row"), p.__isCustomRow = !1), F(o, p, d, c), p.__epoch = n, p.__rowDataRef = d) : L ? (Y(o, p, d, c), p.__rowDataRef = d) : Y(o, p, d, c);
439
- const g = o._changedRowIndices.has(c), m = p.classList.contains("changed");
440
- g !== m && p.classList.toggle("changed", g), p.parentNode !== r && r.appendChild(p);
438
+ !E || x ? (d.__isCustomRow && (d.className = "data-grid-row", d.setAttribute("role", "row"), d.__isCustomRow = !1), F(o, d, c, h), d.__epoch = n, d.__rowDataRef = c) : _ ? (Y(o, d, c, h), d.__rowDataRef = c) : Y(o, d, c, h);
439
+ const g = o._changedRowIndices.has(h), m = d.classList.contains("changed");
440
+ g !== m && d.classList.toggle("changed", g), d.parentNode !== l && l.appendChild(d);
441
441
  }
442
442
  }
443
443
  function Y(o, e, t, n) {
444
- const i = e.children, s = o.visibleColumns, r = s.length, l = i.length, a = r < l ? r : l;
445
- let h = o.__hasSpecialColumns;
446
- if (h === void 0) {
447
- h = !1;
448
- for (let w = 0; w < r; w++) {
449
- const c = s[w];
450
- if (c.__viewTemplate || c.__compiledView || c.viewRenderer || c.externalView || c.format || c.type === "date" || c.type === "boolean") {
451
- h = !0;
444
+ const s = e.children, i = o.visibleColumns, l = i.length, r = s.length, a = l < r ? l : r, f = o.focusRow, p = o.focusCol;
445
+ let w = o.__hasSpecialColumns;
446
+ if (w === void 0) {
447
+ w = !1;
448
+ for (let c = 0; c < l; c++) {
449
+ const d = i[c];
450
+ if (d.__viewTemplate || d.__compiledView || d.viewRenderer || d.externalView || d.format || d.type === "date" || d.type === "boolean") {
451
+ w = !0;
452
452
  break;
453
453
  }
454
454
  }
455
- o.__hasSpecialColumns = h;
455
+ o.__hasSpecialColumns = w;
456
456
  }
457
- const u = String(n);
458
- if (!h) {
459
- for (let w = 0; w < a; w++) {
460
- const c = i[w], d = t[s[w].field];
461
- c.textContent = d == null ? "" : String(d), c.getAttribute("data-row") !== u && c.setAttribute("data-row", u);
457
+ const h = String(n);
458
+ if (!w) {
459
+ for (let c = 0; c < a; c++) {
460
+ const d = s[c], u = t[i[c].field];
461
+ d.textContent = u == null ? "" : String(u), d.getAttribute("data-row") !== h && d.setAttribute("data-row", h);
462
+ const b = f === n && p === c, y = d.classList.contains("cell-focus");
463
+ b !== y && (d.classList.toggle("cell-focus", b), d.setAttribute("aria-selected", String(b)));
462
464
  }
463
465
  return;
464
466
  }
465
- for (let w = 0; w < a; w++)
466
- if (s[w].externalView && !i[w].querySelector("[data-external-view]")) {
467
+ for (let c = 0; c < a; c++)
468
+ if (i[c].externalView && !s[c].querySelector("[data-external-view]")) {
467
469
  F(o, e, t, n);
468
470
  return;
469
471
  }
470
- for (let w = 0; w < a; w++) {
471
- const c = s[w], d = i[w];
472
- if (d.getAttribute("data-row") !== u && d.setAttribute("data-row", u), d.classList.contains("editing") || c.__viewTemplate || c.__compiledView || c.viewRenderer || c.externalView)
472
+ for (let c = 0; c < a; c++) {
473
+ const d = i[c], u = s[c];
474
+ u.getAttribute("data-row") !== h && u.setAttribute("data-row", h);
475
+ const b = f === n && p === c, y = u.classList.contains("cell-focus");
476
+ if (b !== y && (u.classList.toggle("cell-focus", b), u.setAttribute("aria-selected", String(b))), u.classList.contains("editing") || d.__viewTemplate || d.__compiledView || d.viewRenderer || d.externalView)
473
477
  continue;
474
- const p = t[c.field];
475
- let f;
476
- if (c.format)
478
+ const v = t[d.field];
479
+ let E;
480
+ if (d.format)
477
481
  try {
478
- const b = c.format(p, t);
479
- f = b == null ? "" : String(b);
482
+ const _ = d.format(v, t);
483
+ E = _ == null ? "" : String(_);
480
484
  } catch {
481
- f = p == null ? "" : String(p);
485
+ E = v == null ? "" : String(v);
482
486
  }
483
- else if (c.type === "date")
484
- if (p == null || p === "")
485
- f = "";
486
- else if (p instanceof Date)
487
- f = isNaN(p.getTime()) ? "" : p.toLocaleDateString();
487
+ else if (d.type === "date")
488
+ if (v == null || v === "")
489
+ E = "";
490
+ else if (v instanceof Date)
491
+ E = isNaN(v.getTime()) ? "" : v.toLocaleDateString();
488
492
  else {
489
- const b = new Date(p);
490
- f = isNaN(b.getTime()) ? "" : b.toLocaleDateString();
493
+ const _ = new Date(v);
494
+ E = isNaN(_.getTime()) ? "" : _.toLocaleDateString();
491
495
  }
492
- else c.type === "boolean" ? (f = p ? "🗹" : "☐", d.setAttribute("aria-checked", String(!!p))) : f = p == null ? "" : String(p);
493
- d.textContent = f;
496
+ else d.type === "boolean" ? (E = v ? "🗹" : "☐", u.setAttribute("aria-checked", String(!!v))) : E = v == null ? "" : String(v);
497
+ u.textContent = E;
494
498
  }
495
499
  }
496
500
  function F(o, e, t, n) {
497
501
  e.innerHTML = "";
498
- const i = o.visibleColumns, s = i.length, r = o.focusRow, l = o.focusCol, a = o.effectiveConfig?.editOn || o.editOn, h = o, u = document.createDocumentFragment();
499
- for (let w = 0; w < s; w++) {
500
- const c = i[w], d = document.createElement("div");
501
- d.className = "cell", B(d, "cell"), c.type !== "boolean" && d.setAttribute("role", "gridcell"), d.setAttribute("data-col", String(w)), d.setAttribute("data-row", String(n)), d.setAttribute("aria-colindex", String(w + 1)), c.type && d.setAttribute("data-type", c.type);
502
- const p = c.sticky;
503
- p === "left" ? d.classList.add("sticky-left") : p === "right" && d.classList.add("sticky-right");
504
- let f = t[c.field];
505
- const b = c.format;
502
+ const s = o.visibleColumns, i = s.length, l = o.focusRow, r = o.focusCol, a = o.effectiveConfig?.editOn || o.editOn, f = o, p = document.createDocumentFragment();
503
+ for (let w = 0; w < i; w++) {
504
+ const h = s[w], c = document.createElement("div");
505
+ c.className = "cell", B(c, "cell"), h.type !== "boolean" && c.setAttribute("role", "gridcell"), c.setAttribute("data-col", String(w)), c.setAttribute("data-row", String(n)), c.setAttribute("aria-colindex", String(w + 1)), h.type && c.setAttribute("data-type", h.type);
506
+ const d = h.sticky;
507
+ d === "left" ? c.classList.add("sticky-left") : d === "right" && c.classList.add("sticky-right");
508
+ let u = t[h.field];
509
+ const b = h.format;
506
510
  if (b)
507
511
  try {
508
- f = b(f, t);
512
+ u = b(u, t);
509
513
  } catch {
510
514
  }
511
- const y = c.__compiledView, S = c.__viewTemplate, T = c.viewRenderer, L = c.externalView;
512
- let _ = !1;
513
- if (T) {
514
- const g = T({ row: t, value: f, field: c.field, column: c });
515
- typeof g == "string" ? (d.innerHTML = N(g), _ = !0) : g ? d.appendChild(g) : d.textContent = f == null ? "" : String(f);
516
- } else if (L) {
517
- const g = L, m = document.createElement("div");
518
- m.setAttribute("data-external-view", ""), m.setAttribute("data-field", c.field), d.appendChild(m);
519
- const E = { row: t, value: f, field: c.field, column: c };
515
+ const y = h.__compiledView, v = h.__viewTemplate, E = h.viewRenderer, _ = h.externalView;
516
+ let x = !1;
517
+ if (E) {
518
+ const g = E({ row: t, value: u, field: h.field, column: h });
519
+ typeof g == "string" ? (c.innerHTML = N(g), x = !0) : g ? c.appendChild(g) : c.textContent = u == null ? "" : String(u);
520
+ } else if (_) {
521
+ const g = _, m = document.createElement("div");
522
+ m.setAttribute("data-external-view", ""), m.setAttribute("data-field", h.field), c.appendChild(m);
523
+ const A = { row: t, value: u, field: h.field, column: h };
520
524
  if (g.mount)
521
525
  try {
522
- g.mount({ placeholder: m, context: E, spec: g });
526
+ g.mount({ placeholder: m, context: A, spec: g });
523
527
  } catch {
524
528
  }
525
529
  else
526
530
  queueMicrotask(() => {
527
531
  try {
528
- h.dispatchEvent(
532
+ f.dispatchEvent(
529
533
  new CustomEvent("mount-external-view", {
530
534
  bubbles: !0,
531
535
  composed: !0,
532
- detail: { placeholder: m, spec: g, context: E }
536
+ detail: { placeholder: m, spec: g, context: A }
533
537
  })
534
538
  );
535
539
  } catch {
@@ -537,51 +541,51 @@ function F(o, e, t, n) {
537
541
  });
538
542
  m.setAttribute("data-mounted", "");
539
543
  } else if (y) {
540
- const g = y({ row: t, value: f, field: c.field, column: c }), m = y.__blocked;
541
- d.innerHTML = m ? "" : N(g), _ = !0, m && (d.textContent = "", d.setAttribute("data-blocked-template", ""));
542
- } else if (S) {
543
- const g = S.innerHTML;
544
- /Reflect\.|\bProxy\b|ownKeys\(/.test(g) ? (d.textContent = "", d.setAttribute("data-blocked-template", "")) : (d.innerHTML = N(de(g, { row: t, value: f })), _ = !0);
545
- } else if (c.type === "date")
546
- if (f == null || f === "")
547
- d.textContent = "";
544
+ const g = y({ row: t, value: u, field: h.field, column: h }), m = y.__blocked;
545
+ c.innerHTML = m ? "" : N(g), x = !0, m && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
546
+ } else if (v) {
547
+ const g = v.innerHTML;
548
+ /Reflect\.|\bProxy\b|ownKeys\(/.test(g) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = N(de(g, { row: t, value: u })), x = !0);
549
+ } else if (h.type === "date")
550
+ if (u == null || u === "")
551
+ c.textContent = "";
548
552
  else {
549
553
  let g = null;
550
- if (f instanceof Date) g = f;
551
- else if (typeof f == "number" || typeof f == "string") {
552
- const m = new Date(f);
554
+ if (u instanceof Date) g = u;
555
+ else if (typeof u == "number" || typeof u == "string") {
556
+ const m = new Date(u);
553
557
  isNaN(m.getTime()) || (g = m);
554
558
  }
555
- d.textContent = g ? g.toLocaleDateString() : "";
559
+ c.textContent = g ? g.toLocaleDateString() : "";
556
560
  }
557
- else if (c.type === "boolean") {
558
- const g = !!f;
559
- d.innerHTML = g ? "&#x1F5F9;" : "&#9744;", d.setAttribute("role", "checkbox"), d.setAttribute("aria-checked", String(g)), d.setAttribute("aria-label", String(g));
561
+ else if (h.type === "boolean") {
562
+ const g = !!u;
563
+ c.innerHTML = g ? "&#x1F5F9;" : "&#9744;", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(g)), c.setAttribute("aria-label", String(g));
560
564
  } else
561
- d.textContent = f == null ? "" : String(f);
562
- if (_) {
563
- Le(d);
564
- const g = d.textContent || "";
565
- /Proxy|Reflect\.ownKeys/.test(g) && (d.textContent = g.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(d.textContent || "") && (d.textContent = ""));
565
+ c.textContent = u == null ? "" : String(u);
566
+ if (x) {
567
+ Le(c);
568
+ const g = c.textContent || "";
569
+ /Proxy|Reflect\.ownKeys/.test(g) && (c.textContent = g.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(c.textContent || "") && (c.textContent = ""));
566
570
  }
567
- d.hasAttribute("data-blocked-template") && (d.textContent || "").trim().length && (d.textContent = ""), c.editable ? (d.tabIndex = 0, d.addEventListener("mousedown", () => {
571
+ c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""), h.editable ? (c.tabIndex = 0, c.addEventListener("mousedown", () => {
568
572
  o.focusRow = n, o.focusCol = w, M(o);
569
- }), a === "click" ? d.addEventListener("click", (g) => {
570
- d.classList.contains("editing") || (g.stopPropagation(), o.focusRow = n, o.focusCol = w, x(o, t, n, c, d));
571
- }) : d.addEventListener("dblclick", (g) => {
572
- g.stopPropagation(), A(o, n, t);
573
+ }), a === "click" ? c.addEventListener("click", (g) => {
574
+ c.classList.contains("editing") || (g.stopPropagation(), o.focusRow = n, o.focusCol = w, L(o, t, n, h, c));
575
+ }) : c.addEventListener("dblclick", (g) => {
576
+ g.stopPropagation(), T(o, n, t);
573
577
  const m = o.findRenderedRowElement?.(n);
574
578
  if (m) {
575
- const E = m.children;
576
- for (let k = 0; k < E.length; k++) {
579
+ const A = m.children;
580
+ for (let k = 0; k < A.length; k++) {
577
581
  const D = o.visibleColumns[k];
578
- D && D.editable && x(o, t, n, D, E[k]);
582
+ D && D.editable && L(o, t, n, D, A[k]);
579
583
  }
580
584
  }
581
- }), d.addEventListener("keydown", (g) => {
582
- if ((c.type === "select" || c.type === "typeahead") && !d.classList.contains("editing") && g.key === "Enter") {
583
- g.preventDefault(), o.activeEditRows !== n && A(o, n, t), x(o, t, n, c, d), setTimeout(() => {
584
- const m = d.querySelector("select");
585
+ }), c.addEventListener("keydown", (g) => {
586
+ if ((h.type === "select" || h.type === "typeahead") && !c.classList.contains("editing") && g.key === "Enter") {
587
+ g.preventDefault(), o.activeEditRows !== n && T(o, n, t), L(o, t, n, h, c), setTimeout(() => {
588
+ const m = c.querySelector("select");
585
589
  try {
586
590
  m?.showPicker?.();
587
591
  } catch {
@@ -590,87 +594,87 @@ function F(o, e, t, n) {
590
594
  }, 0);
591
595
  return;
592
596
  }
593
- if (c.type === "boolean" && g.key === " " && !d.classList.contains("editing")) {
594
- g.preventDefault(), o.activeEditRows !== n && A(o, n, t);
595
- const m = !t[c.field];
596
- $(o, n, c, m, t), d.innerHTML = m ? "&#x1F5F9;" : "&#9744;", d.setAttribute("aria-label", String(!!m));
597
+ if (h.type === "boolean" && g.key === " " && !c.classList.contains("editing")) {
598
+ g.preventDefault(), o.activeEditRows !== n && T(o, n, t);
599
+ const m = !t[h.field];
600
+ $(o, n, h, m, t), c.innerHTML = m ? "&#x1F5F9;" : "&#9744;", c.setAttribute("aria-label", String(!!m));
597
601
  return;
598
602
  }
599
- if (g.key === "Enter" && !d.classList.contains("editing")) {
600
- g.preventDefault(), o.focusRow = n, o.focusCol = w, typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(n) : x(o, t, n, c, d);
603
+ if (g.key === "Enter" && !c.classList.contains("editing")) {
604
+ g.preventDefault(), o.focusRow = n, o.focusCol = w, typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(n) : L(o, t, n, h, c);
601
605
  return;
602
606
  }
603
- if (g.key === "F2" && !d.classList.contains("editing")) {
604
- g.preventDefault(), x(o, t, n, c, d);
607
+ if (g.key === "F2" && !c.classList.contains("editing")) {
608
+ g.preventDefault(), L(o, t, n, h, c);
605
609
  return;
606
610
  }
607
- })) : c.type === "boolean" && (d.hasAttribute("tabindex") || (d.tabIndex = 0), d.addEventListener("keydown", (g) => {
611
+ })) : h.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0), c.addEventListener("keydown", (g) => {
608
612
  if (g.key === " ") {
609
613
  g.preventDefault();
610
- const m = !t[c.field];
611
- o.activeEditRows !== n && A(o, n, t), $(o, n, c, m, t), d.innerHTML = m ? "&#x1F5F9;" : "&#9744;", d.setAttribute("role", "checkbox"), d.setAttribute("aria-checked", String(!!m)), d.setAttribute("aria-label", String(!!m));
614
+ const m = !t[h.field];
615
+ o.activeEditRows !== n && T(o, n, t), $(o, n, h, m, t), c.innerHTML = m ? "&#x1F5F9;" : "&#9744;", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(!!m)), c.setAttribute("aria-label", String(!!m));
612
616
  }
613
- })), r === n && l === w ? d.setAttribute("aria-selected", "true") : d.setAttribute("aria-selected", "false"), u.appendChild(d);
617
+ })), l === n && r === w ? c.setAttribute("aria-selected", "true") : c.setAttribute("aria-selected", "false"), p.appendChild(c);
614
618
  }
615
- e.appendChild(u);
619
+ e.appendChild(p);
616
620
  }
617
621
  function Z(o, e, t, n) {
618
622
  if (e.target?.closest(".resize-handle")) return;
619
- const i = t.querySelector(".cell[data-row]");
620
- if (!i) return;
621
- const s = Number(i.getAttribute("data-row"));
622
- if (isNaN(s)) return;
623
- const r = o._rows[s];
624
- if (!r) return;
625
- const l = e.target?.closest(".cell[data-col]");
626
- if (l) {
627
- const h = Number(l.getAttribute("data-col"));
628
- if (!isNaN(h)) {
629
- if (o.dispatchCellClick?.(e, s, h, l))
623
+ const s = t.querySelector(".cell[data-row]");
624
+ if (!s) return;
625
+ const i = Number(s.getAttribute("data-row"));
626
+ if (isNaN(i)) return;
627
+ const l = o._rows[i];
628
+ if (!l) return;
629
+ const r = e.target?.closest(".cell[data-col]");
630
+ if (r) {
631
+ const f = Number(r.getAttribute("data-col"));
632
+ if (!isNaN(f)) {
633
+ if (o.dispatchCellClick?.(e, i, f, r))
630
634
  return;
631
- o.focusRow = s, o.focusCol = h, M(o);
635
+ o.focusRow = i, o.focusCol = f, M(o);
632
636
  }
633
637
  }
634
638
  if (t.querySelector(".cell.editing")) {
635
- const h = t.querySelectorAll(".cell.editing");
639
+ const f = t.querySelectorAll(".cell.editing");
636
640
  if (!n) return;
637
- h.forEach((u) => u.classList.remove("editing"));
641
+ f.forEach((p) => p.classList.remove("editing"));
638
642
  }
639
643
  const a = o.effectiveConfig?.editOn || o.editOn || "doubleClick";
640
- if (a === "click" || a === "doubleClick" && n) A(o, s, r);
644
+ if (a === "click" || a === "doubleClick" && n) T(o, i, l);
641
645
  else return;
642
- Array.from(t.children).forEach((h, u) => {
643
- const w = o.visibleColumns[u];
644
- w && w.editable && x(o, r, s, w, h);
645
- }), l && queueMicrotask(() => {
646
- const h = t.querySelector(`.cell[data-col="${o.focusCol}"]`);
647
- if (h?.classList.contains("editing")) {
648
- const u = h.querySelector(
646
+ Array.from(t.children).forEach((f, p) => {
647
+ const w = o.visibleColumns[p];
648
+ w && w.editable && L(o, l, i, w, f);
649
+ }), r && queueMicrotask(() => {
650
+ const f = t.querySelector(`.cell[data-col="${o.focusCol}"]`);
651
+ if (f?.classList.contains("editing")) {
652
+ const p = f.querySelector(
649
653
  'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
650
654
  );
651
655
  try {
652
- u?.focus();
656
+ p?.focus();
653
657
  } catch {
654
658
  }
655
659
  }
656
660
  });
657
661
  }
658
- function A(o, e, t) {
662
+ function T(o, e, t) {
659
663
  o.activeEditRows !== e && (o.rowEditSnapshots.set(e, { ...t }), o.activeEditRows = e);
660
664
  }
661
665
  function Ie(o, e, t) {
662
666
  if (o.activeEditRows !== e) return;
663
- const n = o.rowEditSnapshots.get(e), i = o._rows[e];
664
- if (t && n && i)
665
- Object.keys(n).forEach((r) => i[r] = n[r]), o._changedRowIndices.delete(e);
667
+ const n = o.rowEditSnapshots.get(e), s = o._rows[e];
668
+ if (t && n && s)
669
+ Object.keys(n).forEach((l) => s[l] = n[l]), o._changedRowIndices.delete(e);
666
670
  else if (!t) {
667
- const r = o._changedRowIndices.has(e);
671
+ const l = o._changedRowIndices.has(e);
668
672
  o.dispatchEvent(
669
673
  new CustomEvent("row-commit", {
670
674
  detail: {
671
675
  rowIndex: e,
672
- row: i,
673
- changed: r,
676
+ row: s,
677
+ changed: l,
674
678
  changedRows: o.changedRows,
675
679
  changedRowIndices: o.changedRowIndices
676
680
  }
@@ -678,100 +682,100 @@ function Ie(o, e, t) {
678
682
  );
679
683
  }
680
684
  o.rowEditSnapshots.delete(e), o.activeEditRows = -1;
681
- const s = o.findRenderedRowElement?.(e);
682
- s && (F(o, s, o._rows[e], e), o._changedRowIndices.has(e) ? s.classList.add("changed") : s.classList.remove("changed")), t && queueMicrotask(() => {
685
+ const i = o.findRenderedRowElement?.(e);
686
+ i && (F(o, i, o._rows[e], e), o._changedRowIndices.has(e) ? i.classList.add("changed") : i.classList.remove("changed")), t && queueMicrotask(() => {
683
687
  try {
684
688
  o.focus();
685
- const r = o.focusRow, l = o.focusCol, a = o.findRenderedRowElement?.(r);
689
+ const l = o.focusRow, r = o.focusCol, a = o.findRenderedRowElement?.(l);
686
690
  if (a) {
687
691
  Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach(
688
- (u) => u.classList.remove("cell-focus")
692
+ (p) => p.classList.remove("cell-focus")
689
693
  );
690
- const h = a.querySelector(`.cell[data-row="${r}"][data-col="${l}"]`);
691
- h && h.classList.add("cell-focus");
694
+ const f = a.querySelector(`.cell[data-row="${l}"][data-col="${r}"]`);
695
+ f && f.classList.add("cell-focus");
692
696
  }
693
697
  } catch {
694
698
  }
695
699
  });
696
700
  }
697
- function $(o, e, t, n, i) {
698
- const s = t.field;
699
- if (i[s] === n) return;
700
- i[s] = n;
701
- const l = !o._changedRowIndices.has(e);
701
+ function $(o, e, t, n, s) {
702
+ const i = t.field;
703
+ if (s[i] === n) return;
704
+ s[i] = n;
705
+ const r = !o._changedRowIndices.has(e);
702
706
  o._changedRowIndices.add(e);
703
707
  const a = o.findRenderedRowElement?.(e);
704
708
  a && a.classList.add("changed"), o.dispatchEvent(
705
709
  new CustomEvent("cell-commit", {
706
710
  detail: {
707
- row: i,
708
- field: s,
711
+ row: s,
712
+ field: i,
709
713
  value: n,
710
714
  rowIndex: e,
711
715
  changedRows: o.changedRows,
712
716
  changedRowIndices: o.changedRowIndices,
713
- firstTimeForRow: l
717
+ firstTimeForRow: r
714
718
  }
715
719
  })
716
720
  );
717
721
  }
718
- function x(o, e, t, n, i) {
719
- if (!n.editable || (o.activeEditRows !== t && A(o, t, e), i.classList.contains("editing"))) return;
720
- const s = e[n.field];
721
- i.classList.add("editing");
722
- const r = (c) => {
723
- $(o, t, n, c, e);
724
- }, l = () => {
725
- e[n.field] = s;
726
- const c = i.querySelector("input,textarea,select");
727
- c && (typeof HTMLInputElement < "u" && c instanceof HTMLInputElement && c.type === "checkbox" ? c.checked = !!s : "value" in c && (c.value = s ?? ""));
722
+ function L(o, e, t, n, s) {
723
+ if (!n.editable || (o.activeEditRows !== t && T(o, t, e), s.classList.contains("editing"))) return;
724
+ const i = e[n.field];
725
+ s.classList.add("editing");
726
+ const l = (h) => {
727
+ $(o, t, n, h, e);
728
+ }, r = () => {
729
+ e[n.field] = i;
730
+ const h = s.querySelector("input,textarea,select");
731
+ h && (typeof HTMLInputElement < "u" && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!i : "value" in h && (h.value = i ?? ""));
728
732
  }, a = document.createElement("div");
729
- a.style.display = "contents", i.innerHTML = "", i.appendChild(a);
730
- const h = n.__editorTemplate, u = n.editor || (h ? "template" : De(n)), w = s;
731
- if (u === "template" && h) {
732
- const c = h.cloneNode(!0), d = n.__compiledEditor;
733
- d ? c.innerHTML = d({ row: e, value: s, field: n.field, column: n }) : c.querySelectorAll("*").forEach((f) => {
734
- f.childNodes.length === 1 && f.firstChild?.nodeType === Node.TEXT_NODE && (f.textContent = f.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (b, y) => {
735
- const S = e[y];
736
- return S == null ? "" : String(S);
733
+ a.style.display = "contents", s.innerHTML = "", s.appendChild(a);
734
+ const f = n.__editorTemplate, p = n.editor || (f ? "template" : De(n)), w = i;
735
+ if (p === "template" && f) {
736
+ const h = f.cloneNode(!0), c = n.__compiledEditor;
737
+ c ? h.innerHTML = c({ row: e, value: i, field: n.field, column: n }) : h.querySelectorAll("*").forEach((u) => {
738
+ u.childNodes.length === 1 && u.firstChild?.nodeType === Node.TEXT_NODE && (u.textContent = u.textContent?.replace(/{{\s*value\s*}}/g, i == null ? "" : String(i)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (b, y) => {
739
+ const v = e[y];
740
+ return v == null ? "" : String(v);
737
741
  }) || "");
738
742
  });
739
- const p = c.querySelector("input,textarea,select");
740
- if (p) {
741
- const f = typeof HTMLInputElement < "u";
742
- f && p instanceof HTMLInputElement && p.type === "checkbox" ? p.checked = !!s : "value" in p && (p.value = s ?? ""), p.addEventListener("blur", () => {
743
- const b = f && p instanceof HTMLInputElement && p.type === "checkbox" ? p.checked : p.value;
744
- r(b);
745
- }), p.addEventListener("keydown", (b) => {
743
+ const d = h.querySelector("input,textarea,select");
744
+ if (d) {
745
+ const u = typeof HTMLInputElement < "u";
746
+ u && d instanceof HTMLInputElement && d.type === "checkbox" ? d.checked = !!i : "value" in d && (d.value = i ?? ""), d.addEventListener("blur", () => {
747
+ const b = u && d instanceof HTMLInputElement && d.type === "checkbox" ? d.checked : d.value;
748
+ l(b);
749
+ }), d.addEventListener("keydown", (b) => {
746
750
  if (b.key === "Enter") {
747
- const y = f && p instanceof HTMLInputElement && p.type === "checkbox" ? p.checked : p.value;
748
- r(y);
751
+ const y = u && d instanceof HTMLInputElement && d.type === "checkbox" ? d.checked : d.value;
752
+ l(y);
749
753
  }
750
- b.key === "Escape" && l();
751
- }), f && p instanceof HTMLInputElement && p.type === "checkbox" && p.addEventListener("change", () => {
752
- const b = p.checked;
753
- r(b);
754
- }), setTimeout(() => p.focus(), 0);
755
- }
756
- a.appendChild(c);
757
- } else if (typeof u == "string") {
758
- const c = document.createElement(u);
759
- c.value = w, c.addEventListener("change", () => r(c.value)), a.appendChild(c);
760
- } else if (typeof u == "function") {
761
- const c = u({ row: e, value: w, field: n.field, column: n, commit: r, cancel: l });
762
- typeof c == "string" ? a.innerHTML = c : a.appendChild(c);
763
- } else if (u && typeof u == "object") {
764
- const c = document.createElement("div");
765
- c.setAttribute("data-external-editor", ""), c.setAttribute("data-field", n.field), a.appendChild(c);
766
- const d = { row: e, value: w, field: n.field, column: n, commit: r, cancel: l };
767
- if (u.mount)
754
+ b.key === "Escape" && r();
755
+ }), u && d instanceof HTMLInputElement && d.type === "checkbox" && d.addEventListener("change", () => {
756
+ const b = d.checked;
757
+ l(b);
758
+ }), setTimeout(() => d.focus(), 0);
759
+ }
760
+ a.appendChild(h);
761
+ } else if (typeof p == "string") {
762
+ const h = document.createElement(p);
763
+ h.value = w, h.addEventListener("change", () => l(h.value)), a.appendChild(h);
764
+ } else if (typeof p == "function") {
765
+ const h = p({ row: e, value: w, field: n.field, column: n, commit: l, cancel: r });
766
+ typeof h == "string" ? a.innerHTML = h : a.appendChild(h);
767
+ } else if (p && typeof p == "object") {
768
+ const h = document.createElement("div");
769
+ h.setAttribute("data-external-editor", ""), h.setAttribute("data-field", n.field), a.appendChild(h);
770
+ const c = { row: e, value: w, field: n.field, column: n, commit: l, cancel: r };
771
+ if (p.mount)
768
772
  try {
769
- u.mount({ placeholder: c, context: d, spec: u });
773
+ p.mount({ placeholder: h, context: c, spec: p });
770
774
  } catch {
771
775
  }
772
776
  else
773
777
  o.dispatchEvent(
774
- new CustomEvent("mount-external-editor", { detail: { placeholder: c, spec: u, context: d } })
778
+ new CustomEvent("mount-external-editor", { detail: { placeholder: h, spec: p, context: c } })
775
779
  );
776
780
  }
777
781
  }
@@ -784,8 +788,8 @@ function J(o, e) {
784
788
  }
785
789
  function Q(o, e, t) {
786
790
  o.sortState = { field: e.field, direction: t };
787
- const n = e.sortComparator || ((i, s) => i == null && s == null ? 0 : i == null ? -1 : s == null || i > s ? 1 : i < s ? -1 : 0);
788
- 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(
791
+ const n = e.sortComparator || ((s, i) => s == null && i == null ? 0 : s == null ? -1 : i == null || s > i ? 1 : s < i ? -1 : 0);
792
+ o._rows.sort((s, i) => n(s[e.field], i[e.field], s, i) * t), o.__rowRenderEpoch++, o.rowPool.forEach((s) => s.__epoch = -1), V(o), o.refreshVirtualWindow(!0), o.dispatchEvent(
789
793
  new CustomEvent("sort-change", { detail: { field: e.field, direction: t } })
790
794
  ), o.requestStateChange?.();
791
795
  }
@@ -793,41 +797,41 @@ function V(o) {
793
797
  o.headerRowEl = o.findHeaderRow();
794
798
  const e = o.headerRowEl;
795
799
  e.innerHTML = "", e.setAttribute("role", "row"), e.setAttribute("aria-rowindex", "1"), o.visibleColumns.forEach((t, n) => {
796
- const i = document.createElement("div");
797
- 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");
798
- const s = t.__headerTemplate;
799
- if (s) Array.from(s.childNodes).forEach((r) => i.appendChild(r.cloneNode(!0)));
800
+ const s = document.createElement("div");
801
+ s.className = "cell", B(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");
802
+ const i = t.__headerTemplate;
803
+ if (i) Array.from(i.childNodes).forEach((l) => s.appendChild(l.cloneNode(!0)));
800
804
  else {
801
- const r = t.header || t.field, l = document.createElement("span");
802
- l.textContent = r, i.appendChild(l);
805
+ const l = t.header || t.field, r = document.createElement("span");
806
+ r.textContent = l, s.appendChild(r);
803
807
  }
804
808
  if (t.sortable) {
805
- i.classList.add("sortable"), i.tabIndex = 0;
806
- const r = document.createElement("span");
807
- B(r, "sort-indicator"), r.style.opacity = "0.6";
808
- const l = o.sortState?.field === t.field ? o.sortState.direction : 0;
809
- r.textContent = l === 1 ? "▲" : l === -1 ? "▼" : "⇅", i.appendChild(r), i.setAttribute("aria-sort", l === 0 ? "none" : l === 1 ? "ascending" : "descending"), i.addEventListener("click", (a) => {
810
- o.resizeController?.isResizing || o.dispatchHeaderClick?.(a, n, i) || J(o, t);
811
- }), i.addEventListener("keydown", (a) => {
809
+ s.classList.add("sortable"), s.tabIndex = 0;
810
+ const l = document.createElement("span");
811
+ B(l, "sort-indicator"), l.style.opacity = "0.6";
812
+ const r = o.sortState?.field === t.field ? o.sortState.direction : 0;
813
+ l.textContent = r === 1 ? "▲" : r === -1 ? "▼" : "⇅", s.appendChild(l), s.setAttribute("aria-sort", r === 0 ? "none" : r === 1 ? "ascending" : "descending"), s.addEventListener("click", (a) => {
814
+ o.resizeController?.isResizing || o.dispatchHeaderClick?.(a, n, s) || J(o, t);
815
+ }), s.addEventListener("keydown", (a) => {
812
816
  if (a.key === "Enter" || a.key === " ") {
813
- if (a.preventDefault(), o.dispatchHeaderClick?.(a, n, i)) return;
817
+ if (a.preventDefault(), o.dispatchHeaderClick?.(a, n, s)) return;
814
818
  J(o, t);
815
819
  }
816
820
  });
817
821
  }
818
822
  if (t.resizable) {
819
- t.sticky || (i.style.position = "relative");
820
- const r = document.createElement("div");
821
- r.className = "resize-handle", r.setAttribute("aria-hidden", "true"), r.addEventListener("mousedown", (l) => {
822
- l.stopPropagation(), l.preventDefault(), o.resizeController.start(l, n, i);
823
- }), i.appendChild(r);
823
+ t.sticky || (s.style.position = "relative");
824
+ const l = document.createElement("div");
825
+ l.className = "resize-handle", l.setAttribute("aria-hidden", "true"), l.addEventListener("mousedown", (r) => {
826
+ r.stopPropagation(), r.preventDefault(), o.resizeController.start(r, n, s);
827
+ }), s.appendChild(l);
824
828
  }
825
- e.appendChild(i);
829
+ e.appendChild(s);
826
830
  });
827
831
  try {
828
832
  const t = o.shadowRoot;
829
- t && t.querySelectorAll(".header-group-row .cell").forEach((i) => {
830
- i.getAttribute("data-group") && i.classList.add("grouped");
833
+ t && t.querySelectorAll(".header-group-row .cell").forEach((s) => {
834
+ s.getAttribute("data-group") && s.classList.add("grouped");
831
835
  });
832
836
  } catch {
833
837
  }
@@ -836,34 +840,34 @@ function V(o) {
836
840
  });
837
841
  }
838
842
  function Be(o) {
839
- let e = null, t = null, n = null, i = null;
840
- const s = (a) => {
843
+ let e = null, t = null, n = null, s = null;
844
+ const i = (a) => {
841
845
  if (!e) return;
842
- const h = a.clientX - e.startX, u = Math.max(40, e.startWidth + h), w = o.visibleColumns[e.colIndex];
843
- w.width = u, w.__userResized = !0, w.__renderedWidth = u, t == null && (t = requestAnimationFrame(() => {
846
+ const f = a.clientX - e.startX, p = Math.max(40, e.startWidth + f), w = o.visibleColumns[e.colIndex];
847
+ w.width = p, w.__userResized = !0, w.__renderedWidth = p, t == null && (t = requestAnimationFrame(() => {
844
848
  t = null, o.updateTemplate?.();
845
849
  })), o.dispatchEvent(
846
- new CustomEvent("column-resize", { detail: { field: w.field, width: u } })
850
+ new CustomEvent("column-resize", { detail: { field: w.field, width: p } })
847
851
  );
848
852
  };
849
- let r = !1;
850
- const l = () => {
853
+ let l = !1;
854
+ const r = () => {
851
855
  const a = e !== null;
852
- a && (r = !0, requestAnimationFrame(() => {
853
- r = !1;
854
- })), window.removeEventListener("mousemove", s), window.removeEventListener("mouseup", l), n !== null && (document.documentElement.style.cursor = n, n = null), i !== null && (document.body.style.userSelect = i, i = null), e = null, a && o.requestStateChange && o.requestStateChange();
856
+ a && (l = !0, requestAnimationFrame(() => {
857
+ l = !1;
858
+ })), window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", r), n !== null && (document.documentElement.style.cursor = n, n = null), s !== null && (document.body.style.userSelect = s, s = null), e = null, a && o.requestStateChange && o.requestStateChange();
855
859
  };
856
860
  return {
857
861
  get isResizing() {
858
- return e !== null || r;
862
+ return e !== null || l;
859
863
  },
860
- start(a, h, u) {
864
+ start(a, f, p) {
861
865
  a.preventDefault();
862
- const w = u.getBoundingClientRect();
863
- e = { startX: a.clientX, colIndex: h, startWidth: w.width }, window.addEventListener("mousemove", s), window.addEventListener("mouseup", l), 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";
866
+ const w = p.getBoundingClientRect();
867
+ e = { startX: a.clientX, colIndex: f, startWidth: w.width }, window.addEventListener("mousemove", i), window.addEventListener("mouseup", r), 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";
864
868
  },
865
869
  dispose() {
866
- l();
870
+ r();
867
871
  }
868
872
  };
869
873
  }
@@ -884,20 +888,20 @@ function Ke(o, e) {
884
888
  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);
885
889
  }
886
890
  function We(o, e) {
887
- const t = o?.header?.title ?? "", n = !!t, i = o?.header?.toolbarButtons ?? [], s = i.length > 0, r = e.toolbarButtons.size > 0, l = e.lightDomButtons.length > 0, a = e.toolPanels.size > 0, u = (s || r || l) && a, w = [...i].sort((f, b) => (f.order ?? 100) - (b.order ?? 100)), c = [...e.toolbarButtons.values()].sort((f, b) => (f.order ?? 100) - (b.order ?? 100)), d = [...e.toolPanels.values()].sort((f, b) => (f.order ?? 100) - (b.order ?? 100));
888
- let p = "";
889
- for (const f of w)
890
- f.icon && f.action && (p += `<button class="tbw-toolbar-btn" data-btn="${f.id}" title="${f.label}" aria-label="${f.label}"${f.disabled ? " disabled" : ""}>${f.icon}</button>`);
891
- for (const f of c)
892
- f.icon && f.action && (p += `<button class="tbw-toolbar-btn" data-btn="${f.id}" title="${f.label}" aria-label="${f.label}"${f.disabled ? " disabled" : ""}>${f.icon}</button>`);
893
- for (const f of w)
894
- (f.element || f.render) && (p += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${f.id}"></div>`);
895
- for (const f of c)
896
- (f.element || f.render) && (p += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${f.id}"></div>`);
897
- l && (p += '<slot name="toolbar"></slot>'), u && (p += '<div class="tbw-toolbar-separator"></div>');
898
- for (const f of d) {
899
- const b = e.activePanel === f.id;
900
- p += `<button class="tbw-toolbar-btn${b ? " active" : ""}" data-panel="${f.id}" title="${f.tooltip ?? f.title}" aria-label="${f.tooltip ?? f.title}" aria-pressed="${b}" aria-controls="tbw-panel-${f.id}">${f.icon}</button>`;
891
+ const t = o?.header?.title ?? "", n = !!t, s = o?.header?.toolbarButtons ?? [], i = s.length > 0, l = e.toolbarButtons.size > 0, r = e.lightDomButtons.length > 0, a = e.toolPanels.size > 0, p = (i || l || r) && a, w = [...s].sort((u, b) => (u.order ?? 100) - (b.order ?? 100)), h = [...e.toolbarButtons.values()].sort((u, b) => (u.order ?? 100) - (b.order ?? 100)), c = [...e.toolPanels.values()].sort((u, b) => (u.order ?? 100) - (b.order ?? 100));
892
+ let d = "";
893
+ for (const u of w)
894
+ u.icon && u.action && (d += `<button class="tbw-toolbar-btn" data-btn="${u.id}" title="${u.label}" aria-label="${u.label}"${u.disabled ? " disabled" : ""}>${u.icon}</button>`);
895
+ for (const u of h)
896
+ u.icon && u.action && (d += `<button class="tbw-toolbar-btn" data-btn="${u.id}" title="${u.label}" aria-label="${u.label}"${u.disabled ? " disabled" : ""}>${u.icon}</button>`);
897
+ for (const u of w)
898
+ (u.element || u.render) && (d += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${u.id}"></div>`);
899
+ for (const u of h)
900
+ (u.element || u.render) && (d += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${u.id}"></div>`);
901
+ r && (d += '<slot name="toolbar"></slot>'), p && (d += '<div class="tbw-toolbar-separator"></div>');
902
+ for (const u of c) {
903
+ const b = e.activePanel === u.id;
904
+ d += `<button class="tbw-toolbar-btn${b ? " active" : ""}" data-panel="${u.id}" title="${u.tooltip ?? u.title}" aria-label="${u.tooltip ?? u.title}" aria-pressed="${b}" aria-controls="tbw-panel-${u.id}">${u.icon}</button>`;
901
905
  }
902
906
  return `
903
907
  <div class="tbw-shell-header" part="shell-header" role="banner">
@@ -906,16 +910,16 @@ function We(o, e) {
906
910
  <slot name="header-content"></slot>
907
911
  </div>
908
912
  <div class="tbw-shell-toolbar" part="shell-toolbar" role="toolbar" aria-label="Grid tools">
909
- ${p}
913
+ ${d}
910
914
  </div>
911
915
  </div>
912
916
  `;
913
917
  }
914
918
  function Fe(o, e, t) {
915
- const n = o?.toolPanel?.position ?? "right", i = e.toolPanels.size > 0, s = e.activePanel !== null, r = e.activePanel ? e.toolPanels.get(e.activePanel) : null, l = i ? `
916
- <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"}">
919
+ const n = o?.toolPanel?.position ?? "right", s = e.toolPanels.size > 0, i = e.activePanel !== null, l = e.activePanel ? e.toolPanels.get(e.activePanel) : null, r = s ? `
920
+ <aside class="tbw-tool-panel${i ? " open" : ""}" part="tool-panel" data-position="${n}" role="complementary" aria-label="${l?.title ?? "Tool panel"}" id="tbw-panel-${e.activePanel ?? "closed"}">
917
921
  <div class="tbw-tool-panel-header">
918
- <span class="tbw-tool-panel-title">${r?.title ?? ""}</span>
922
+ <span class="tbw-tool-panel-title">${l?.title ?? ""}</span>
919
923
  <button class="tbw-tool-panel-close" aria-label="Close panel">✕</button>
920
924
  </div>
921
925
  <div class="tbw-tool-panel-content" role="region"></div>
@@ -923,7 +927,7 @@ function Fe(o, e, t) {
923
927
  ` : "";
924
928
  return n === "left" ? `
925
929
  <div class="tbw-shell-body">
926
- ${l}
930
+ ${r}
927
931
  <div class="tbw-grid-content">
928
932
  ${t}
929
933
  </div>
@@ -933,7 +937,7 @@ function Fe(o, e, t) {
933
937
  <div class="tbw-grid-content">
934
938
  ${t}
935
939
  </div>
936
- ${l}
940
+ ${r}
937
941
  </div>
938
942
  `;
939
943
  }
@@ -942,62 +946,62 @@ function ee(o, e) {
942
946
  if (!t) return;
943
947
  t.style.display = "none";
944
948
  const n = t.querySelectorAll("tbw-grid-header-content");
945
- e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((s, r) => {
946
- s.setAttribute("slot", "header-content");
949
+ e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((i, l) => {
950
+ i.setAttribute("slot", "header-content");
947
951
  });
948
- const i = t.querySelectorAll("tbw-grid-tool-button");
949
- e.lightDomButtons = Array.from(i), e.lightDomButtons.sort((s, r) => {
950
- const l = parseInt(s.getAttribute("order") ?? "100", 10), a = parseInt(r.getAttribute("order") ?? "100", 10);
951
- return l - a;
952
- }), e.lightDomButtons.forEach((s) => {
953
- s.setAttribute("slot", "toolbar");
952
+ const s = t.querySelectorAll("tbw-grid-tool-button");
953
+ e.lightDomButtons = Array.from(s), e.lightDomButtons.sort((i, l) => {
954
+ const r = parseInt(i.getAttribute("order") ?? "100", 10), a = parseInt(l.getAttribute("order") ?? "100", 10);
955
+ return r - a;
956
+ }), e.lightDomButtons.forEach((i) => {
957
+ i.setAttribute("slot", "toolbar");
954
958
  });
955
959
  }
956
960
  function Ve(o, e, t, n) {
957
- const i = o.querySelector(".tbw-shell-toolbar");
958
- i && i.addEventListener("click", (r) => {
959
- const l = r.target, a = l.closest("[data-panel]");
961
+ const s = o.querySelector(".tbw-shell-toolbar");
962
+ s && s.addEventListener("click", (l) => {
963
+ const r = l.target, a = r.closest("[data-panel]");
960
964
  if (a) {
961
- const u = a.getAttribute("data-panel");
962
- u && n.onPanelToggle(u);
965
+ const p = a.getAttribute("data-panel");
966
+ p && n.onPanelToggle(p);
963
967
  return;
964
968
  }
965
- const h = l.closest("[data-btn]");
966
- if (h) {
967
- const u = h.getAttribute("data-btn");
968
- u && n.onToolbarButtonClick(u);
969
+ const f = r.closest("[data-btn]");
970
+ if (f) {
971
+ const p = f.getAttribute("data-btn");
972
+ p && n.onToolbarButtonClick(p);
969
973
  }
970
974
  });
971
- const s = o.querySelector(".tbw-tool-panel-close");
972
- s && s.addEventListener("click", () => {
975
+ const i = o.querySelector(".tbw-tool-panel-close");
976
+ i && i.addEventListener("click", () => {
973
977
  n.onPanelClose();
974
978
  });
975
979
  }
976
980
  function Ge(o, e, t) {
977
981
  const n = [...e?.header?.toolbarButtons ?? [], ...t.toolbarButtons.values()];
978
- for (const i of n) {
979
- const s = o.querySelector(`[data-btn-slot="${i.id}"]`);
980
- if (!s) continue;
981
- const r = t.toolbarButtonCleanups.get(i.id);
982
- if (r && (r(), t.toolbarButtonCleanups.delete(i.id)), i.element)
983
- s.appendChild(i.element);
984
- else if (i.render) {
985
- const l = i.render(s);
986
- l && t.toolbarButtonCleanups.set(i.id, l);
982
+ for (const s of n) {
983
+ const i = o.querySelector(`[data-btn-slot="${s.id}"]`);
984
+ if (!i) continue;
985
+ const l = t.toolbarButtonCleanups.get(s.id);
986
+ if (l && (l(), t.toolbarButtonCleanups.delete(s.id)), s.element)
987
+ i.appendChild(s.element);
988
+ else if (s.render) {
989
+ const r = s.render(i);
990
+ r && t.toolbarButtonCleanups.set(s.id, r);
987
991
  }
988
992
  }
989
993
  }
990
994
  function te(o, e) {
991
995
  const t = o.querySelector(".tbw-shell-content");
992
996
  if (!t) return;
993
- const n = [...e.headerContents.values()].sort((s, r) => (s.order ?? 100) - (r.order ?? 100)), i = t.querySelector('slot[name="header-content"]');
994
- for (const s of n) {
995
- const r = e.headerContentCleanups.get(s.id);
996
- r && (r(), e.headerContentCleanups.delete(s.id));
997
- let l = t.querySelector(`[data-header-content="${s.id}"]`);
998
- l || (l = document.createElement("div"), l.setAttribute("data-header-content", s.id), i ? t.insertBefore(l, i) : t.appendChild(l));
999
- const a = s.render(l);
1000
- a && e.headerContentCleanups.set(s.id, a);
997
+ const n = [...e.headerContents.values()].sort((i, l) => (i.order ?? 100) - (l.order ?? 100)), s = t.querySelector('slot[name="header-content"]');
998
+ for (const i of n) {
999
+ const l = e.headerContentCleanups.get(i.id);
1000
+ l && (l(), e.headerContentCleanups.delete(i.id));
1001
+ let r = t.querySelector(`[data-header-content="${i.id}"]`);
1002
+ r || (r = document.createElement("div"), r.setAttribute("data-header-content", i.id), s ? t.insertBefore(r, s) : t.appendChild(r));
1003
+ const a = i.render(r);
1004
+ a && e.headerContentCleanups.set(i.id, a);
1001
1005
  }
1002
1006
  }
1003
1007
  function Ue(o, e) {
@@ -1007,13 +1011,13 @@ function Ue(o, e) {
1007
1011
  const n = o.querySelector(".tbw-tool-panel-content");
1008
1012
  if (!n) return;
1009
1013
  e.activePanelCleanup && (e.activePanelCleanup(), e.activePanelCleanup = null), n.innerHTML = "";
1010
- const i = t.render(n);
1011
- i && (e.activePanelCleanup = i);
1014
+ const s = t.render(n);
1015
+ s && (e.activePanelCleanup = s);
1012
1016
  }
1013
1017
  function oe(o, e) {
1014
1018
  o.querySelectorAll("[data-panel]").forEach((n) => {
1015
- const s = n.getAttribute("data-panel") === e.activePanel;
1016
- n.classList.toggle("active", s), n.setAttribute("aria-pressed", String(s));
1019
+ const i = n.getAttribute("data-panel") === e.activePanel;
1020
+ n.classList.toggle("active", i), n.setAttribute("aria-pressed", String(i));
1017
1021
  });
1018
1022
  }
1019
1023
  function ne(o, e) {
@@ -1021,8 +1025,8 @@ function ne(o, e) {
1021
1025
  if (!t) return;
1022
1026
  const n = e.activePanel !== null;
1023
1027
  if (t.classList.toggle("open", n), n && e.activePanel) {
1024
- const i = e.toolPanels.get(e.activePanel), s = t.querySelector(".tbw-tool-panel-title");
1025
- s && (s.textContent = i?.title ?? ""), t.setAttribute("aria-label", `${i?.title ?? "Tool"} panel`), t.id = `tbw-panel-${e.activePanel}`;
1028
+ const s = e.toolPanels.get(e.activePanel), i = t.querySelector(".tbw-tool-panel-title");
1029
+ i && (i.textContent = s?.title ?? ""), t.setAttribute("aria-label", `${s?.title ?? "Tool"} panel`), t.id = `tbw-panel-${e.activePanel}`;
1026
1030
  }
1027
1031
  }
1028
1032
  function Xe(o, e) {
@@ -1042,11 +1046,11 @@ function Xe(o, e) {
1042
1046
  source: "config"
1043
1047
  });
1044
1048
  for (let n = 0; n < e.lightDomButtons.length; n++) {
1045
- const s = e.lightDomButtons[n].querySelector("button");
1049
+ const i = e.lightDomButtons[n].querySelector("button");
1046
1050
  t.push({
1047
1051
  id: `light-dom-${n}`,
1048
- label: s?.getAttribute("title") ?? s?.getAttribute("aria-label") ?? "",
1049
- disabled: s?.disabled ?? !1,
1052
+ label: i?.getAttribute("title") ?? i?.getAttribute("aria-label") ?? "",
1053
+ disabled: i?.disabled ?? !1,
1050
1054
  source: "light-dom"
1051
1055
  });
1052
1056
  }
@@ -1194,13 +1198,21 @@ class Ye {
1194
1198
  for (const e of this.plugins)
1195
1199
  e.afterRender?.();
1196
1200
  }
1201
+ /**
1202
+ * Execute onScrollRender hook on all plugins.
1203
+ * Called after scroll-triggered row rendering for lightweight visual state updates.
1204
+ */
1205
+ onScrollRender() {
1206
+ for (const e of this.plugins)
1207
+ e.onScrollRender?.();
1208
+ }
1197
1209
  /**
1198
1210
  * Execute renderRow hook on all plugins.
1199
1211
  * Returns true if any plugin handled the row.
1200
1212
  */
1201
1213
  renderRow(e, t, n) {
1202
- for (const i of this.plugins)
1203
- if (i.renderRow?.(e, t, n))
1214
+ for (const s of this.plugins)
1215
+ if (s.renderRow?.(e, t, n))
1204
1216
  return !0;
1205
1217
  return !1;
1206
1218
  }
@@ -1287,8 +1299,8 @@ class Ye {
1287
1299
  getContextMenuItems(e) {
1288
1300
  const t = [];
1289
1301
  for (const n of this.plugins) {
1290
- const i = n.getContextMenuItems?.(e);
1291
- i && t.push(...i);
1302
+ const s = n.getContextMenuItems?.(e);
1303
+ s && t.push(...s);
1292
1304
  }
1293
1305
  return t;
1294
1306
  }
@@ -1321,44 +1333,46 @@ class Ye {
1321
1333
  class q extends HTMLElement {
1322
1334
  // TODO: Rename to 'data-grid' when migration is complete
1323
1335
  static tagName = "tbw-grid";
1324
- #t;
1325
- #S = !1;
1336
+ #n;
1337
+ #i = !1;
1326
1338
  // ---------------- Ready Promise ----------------
1327
- #D;
1328
- #H;
1339
+ #z;
1340
+ #N;
1329
1341
  // ================== INPUT PROPERTIES ==================
1330
1342
  // These backing fields store raw user input. They are merged into
1331
1343
  // #effectiveConfig by #mergeEffectiveConfig(). Never read directly
1332
1344
  // for rendering logic - always use effectiveConfig or derived state.
1333
- #s = [];
1345
+ #l = [];
1334
1346
  #r;
1335
- #b;
1336
- #v;
1347
+ #g;
1337
1348
  #C;
1349
+ #y;
1338
1350
  // ================== SINGLE SOURCE OF TRUTH ==================
1339
1351
  // All input sources converge here. This is the canonical config
1340
1352
  // that all rendering and logic should read from.
1341
- #n = {};
1342
- #h = !1;
1343
- #x = 0;
1344
- #y = null;
1345
- #E = !1;
1353
+ #o = {};
1354
+ #u = !1;
1355
+ #L = 0;
1356
+ #E = null;
1357
+ #R = !1;
1346
1358
  // Cached flag for plugin scroll handlers
1347
- #T;
1359
+ #k;
1348
1360
  // Cached hook to avoid closures
1349
- #u;
1350
1361
  #f;
1351
- #R = !1;
1352
1362
  #p;
1363
+ #_ = !1;
1353
1364
  #w;
1365
+ #b;
1366
+ #A = null;
1367
+ #S = null;
1354
1368
  // ---------------- Plugin System ----------------
1355
- #o;
1369
+ #t;
1356
1370
  // ---------------- Column State ----------------
1357
- #L;
1358
- #c;
1371
+ #P;
1372
+ #d;
1359
1373
  // ---------------- Shell State ----------------
1360
1374
  #e = $e();
1361
- #l = !1;
1375
+ #a = !1;
1362
1376
  // ================== DERIVED STATE ==================
1363
1377
  // _rows: result of applying plugin processRows hooks
1364
1378
  _rows = [];
@@ -1366,10 +1380,10 @@ class q extends HTMLElement {
1366
1380
  // This ensures effectiveConfig.columns is the single source of truth for columns
1367
1381
  // _columns always contains ALL columns (including hidden)
1368
1382
  get _columns() {
1369
- return this.#n.columns ?? [];
1383
+ return this.#o.columns ?? [];
1370
1384
  }
1371
1385
  set _columns(e) {
1372
- this.#n.columns = e;
1386
+ this.#o.columns = e;
1373
1387
  }
1374
1388
  // visibleColumns returns only visible columns for rendering
1375
1389
  // This is what header/row rendering should use
@@ -1418,56 +1432,56 @@ class q extends HTMLElement {
1418
1432
  return this._rows;
1419
1433
  }
1420
1434
  set rows(e) {
1421
- const t = this.#s;
1422
- this.#s = e, t !== e && this.#j();
1435
+ const t = this.#l;
1436
+ this.#l = e, t !== e && this.#Z();
1423
1437
  }
1424
1438
  /**
1425
1439
  * Get the original unfiltered/unprocessed rows.
1426
1440
  * Use this when you need access to all source data regardless of active filters.
1427
1441
  */
1428
1442
  get sourceRows() {
1429
- return this.#s;
1443
+ return this.#l;
1430
1444
  }
1431
1445
  get columns() {
1432
1446
  return [...this._columns];
1433
1447
  }
1434
1448
  set columns(e) {
1435
1449
  const t = this.#r;
1436
- this.#r = e, t !== e && this.#Y();
1450
+ this.#r = e, t !== e && this.#J();
1437
1451
  }
1438
1452
  get gridConfig() {
1439
- return this.#n;
1453
+ return this.#o;
1440
1454
  }
1441
1455
  set gridConfig(e) {
1442
- const t = this.#b;
1443
- this.#b = e, t !== e && this.#Z();
1456
+ const t = this.#g;
1457
+ this.#g = e, t !== e && this.#Q();
1444
1458
  }
1445
1459
  get fitMode() {
1446
- return this.#n.fitMode ?? "stretch";
1460
+ return this.#o.fitMode ?? "stretch";
1447
1461
  }
1448
1462
  set fitMode(e) {
1449
- const t = this.#v;
1450
- this.#v = e, t !== e && this.#U();
1463
+ const t = this.#C;
1464
+ this.#C = e, t !== e && this.#j();
1451
1465
  }
1452
1466
  get editOn() {
1453
- return this.#n.editOn;
1467
+ return this.#o.editOn;
1454
1468
  }
1455
1469
  set editOn(e) {
1456
- const t = this.#C;
1457
- this.#C = e, t !== e && this.#X();
1470
+ const t = this.#y;
1471
+ this.#y = e, t !== e && this.#Y();
1458
1472
  }
1459
1473
  // Effective config accessor for internal modules and plugins
1460
1474
  // Returns the merged config (single source of truth) before plugin processing
1461
1475
  // Use this when you need the raw merged config (e.g., for column definitions including hidden)
1462
1476
  get effectiveConfig() {
1463
- return this.#n;
1477
+ return this.#o;
1464
1478
  }
1465
1479
  constructor() {
1466
- super(), this.#t = this.attachShadow({ mode: "open" }), this.#W(), this.#D = new Promise((e) => this.#H = e);
1480
+ super(), this.#n = this.attachShadow({ mode: "open" }), this.#V(), this.#z = new Promise((e) => this.#N = e);
1467
1481
  }
1468
- #W() {
1482
+ #V() {
1469
1483
  const e = new CSSStyleSheet();
1470
- e.replaceSync(we), this.#t.adoptedStyleSheets = [e];
1484
+ e.replaceSync(we), this.#n.adoptedStyleSheets = [e];
1471
1485
  }
1472
1486
  // ---------------- Plugin System ----------------
1473
1487
  /**
@@ -1475,14 +1489,14 @@ class q extends HTMLElement {
1475
1489
  * Used by plugins for inter-plugin communication.
1476
1490
  */
1477
1491
  getPlugin(e) {
1478
- return this.#o?.getPlugin(e);
1492
+ return this.#t?.getPlugin(e);
1479
1493
  }
1480
1494
  /**
1481
1495
  * Get a plugin instance by its name.
1482
1496
  * Used for loose coupling between plugins (avoids static imports).
1483
1497
  */
1484
1498
  getPluginByName(e) {
1485
- return this.#o?.getPluginByName(e);
1499
+ return this.#t?.getPluginByName(e);
1486
1500
  }
1487
1501
  /**
1488
1502
  * Request a full re-render of the grid.
@@ -1490,7 +1504,7 @@ class q extends HTMLElement {
1490
1504
  * Note: This does NOT reset plugin state - just re-processes rows/columns and renders.
1491
1505
  */
1492
1506
  requestRender() {
1493
- this.#A(), this.#k(), this.#_(), this.updateTemplate(), this.refreshVirtualWindow(!0);
1507
+ this.#T(), this.#O(), this.#x(), this.updateTemplate(), this.refreshVirtualWindow(!0);
1494
1508
  }
1495
1509
  /**
1496
1510
  * Request a lightweight style update without rebuilding DOM.
@@ -1498,186 +1512,207 @@ class q extends HTMLElement {
1498
1512
  * This runs all plugin afterRender hooks without rebuilding row/column DOM.
1499
1513
  */
1500
1514
  requestAfterRender() {
1501
- this.#g();
1515
+ this.#m();
1502
1516
  }
1503
1517
  /**
1504
1518
  * Initialize plugin system with instances from config.
1505
1519
  * Plugins are class instances passed in gridConfig.plugins[].
1506
1520
  */
1507
- #z() {
1508
- this.#o = new Ye(this);
1509
- const e = this.#n?.plugins, t = Array.isArray(e) ? e : [];
1510
- this.#o.attachAll(t);
1521
+ #q() {
1522
+ this.#t = new Ye(this);
1523
+ const e = this.#o?.plugins, t = Array.isArray(e) ? e : [];
1524
+ this.#t.attachAll(t);
1511
1525
  }
1512
1526
  /**
1513
1527
  * Inject all plugin styles into the shadow DOM.
1514
1528
  * Must be called after #render() since innerHTML wipes existing content.
1515
1529
  */
1516
- #N() {
1517
- const e = this.#o?.getAllStyles() ?? "";
1530
+ #I() {
1531
+ const e = this.#t?.getAllStyles() ?? "";
1518
1532
  if (e) {
1519
1533
  const t = document.createElement("style");
1520
- t.setAttribute("data-plugin", "all"), t.textContent = e, this.#t.appendChild(t);
1534
+ t.setAttribute("data-plugin", "all"), t.textContent = e, this.#n.appendChild(t);
1521
1535
  }
1522
1536
  }
1523
1537
  /**
1524
1538
  * Update plugins when grid config changes.
1525
1539
  * With class-based plugins, we need to detach old and attach new.
1526
1540
  */
1527
- #q() {
1528
- this.#o && this.#o.detachAll(), this.#z(), this.#N(), this.#E = this.#o?.getAll().some((e) => e.onScroll) ?? !1;
1541
+ #B() {
1542
+ this.#t && this.#t.detachAll(), this.#q(), this.#I(), this.#R = this.#t?.getAll().some((e) => e.onScroll) ?? !1;
1529
1543
  }
1530
1544
  /**
1531
1545
  * Clean up plugin states when grid disconnects.
1532
1546
  */
1533
- #F() {
1534
- this.#o?.detachAll();
1547
+ #G() {
1548
+ this.#t?.detachAll();
1535
1549
  }
1536
1550
  /**
1537
1551
  * Collect tool panels and header content from all plugins.
1538
1552
  * Called after plugins are attached but before render.
1539
1553
  */
1540
- #V() {
1541
- if (!this.#o) return;
1542
- const e = this.#o.getToolPanels();
1554
+ #U() {
1555
+ if (!this.#t) return;
1556
+ const e = this.#t.getToolPanels();
1543
1557
  for (const { panel: n } of e)
1544
1558
  this.#e.toolPanels.has(n.id) || this.#e.toolPanels.set(n.id, n);
1545
- const t = this.#o.getHeaderContents();
1559
+ const t = this.#t.getHeaderContents();
1546
1560
  for (const { content: n } of t)
1547
1561
  this.#e.headerContents.has(n.id) || this.#e.headerContents.set(n.id, n);
1548
1562
  }
1549
1563
  // ---------------- Lifecycle ----------------
1550
1564
  connectedCallback() {
1551
- this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#s) ? [...this.#s] : [], this.#d(), this.#z(), this.#V(), this.#S || (this.#K(), this.#N(), this.#S = !0), this.#I();
1565
+ this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#h(), this.#q(), this.#U(), this.#i || (this.#F(), this.#I(), this.#i = !0), this.#$();
1552
1566
  }
1553
1567
  disconnectedCallback() {
1554
- this.#F(), je(this.#e), this.#l = !1, this.#u && (document.removeEventListener("keydown", this.#u, !0), this.#u = void 0), this.#f && (document.removeEventListener("mousedown", this.#f, !1), this.#f = void 0), this.#p && (document.removeEventListener("mousemove", this.#p), this.#p = void 0), this.#w && (document.removeEventListener("mouseup", this.#w), this.#w = void 0), this.resizeController && this.resizeController.dispose(), this.#h = !1;
1555
- }
1556
- #I() {
1557
- const t = this.#t.querySelector(".tbw-grid-content") ?? this.#t.querySelector(".tbw-grid-root");
1558
- 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.#l) {
1559
- te(this.#t, this.#e), Ge(this.#t, this.#n?.shell, this.#e);
1560
- const s = this.#n?.shell?.toolPanel?.defaultOpen;
1561
- s && this.#e.toolPanels.has(s) && this.openToolPanel(s);
1562
- }
1563
- this.setAttribute("data-upgraded", ""), this.hasAttribute("role") || this.setAttribute("role", "grid"), this.#h = !0, this.#a(), this.addEventListener("keydown", (s) => He(this, s)), this.#u || (this.#u = (s) => {
1564
- s.key === "Escape" && this.activeEditRows !== -1 && this.#O(this.activeEditRows, !0);
1565
- }, document.addEventListener("keydown", this.#u, !0)), this.#f || (this.#f = (s) => {
1568
+ this.#G(), je(this.#e), this.#a = !1, this.#f && (document.removeEventListener("keydown", this.#f, !0), this.#f = void 0), this.#p && (document.removeEventListener("mousedown", this.#p, !1), this.#p = void 0), this.#w && (document.removeEventListener("mousemove", this.#w), this.#w = void 0), this.#b && (document.removeEventListener("mouseup", this.#b), this.#b = void 0), this.resizeController && this.resizeController.dispose(), this.#u = !1;
1569
+ }
1570
+ #$() {
1571
+ const t = this.#n.querySelector(".tbw-grid-content") ?? this.#n.querySelector(".tbw-grid-root");
1572
+ 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.#a) {
1573
+ te(this.#n, this.#e), Ge(this.#n, this.#o?.shell, this.#e);
1574
+ const i = this.#o?.shell?.toolPanel?.defaultOpen;
1575
+ i && this.#e.toolPanels.has(i) && this.openToolPanel(i);
1576
+ }
1577
+ this.setAttribute("data-upgraded", ""), this.hasAttribute("role") || this.setAttribute("role", "grid"), this.#u = !0, this.#c(), this.addEventListener("keydown", (i) => He(this, i)), this.#f || (this.#f = (i) => {
1578
+ i.key === "Escape" && this.activeEditRows !== -1 && this.#D(this.activeEditRows, !0);
1579
+ }, document.addEventListener("keydown", this.#f, !0)), this.#p || (this.#p = (i) => {
1566
1580
  if (this.activeEditRows === -1) return;
1567
- const r = this.findRenderedRowElement(this.activeEditRows);
1568
- !r || (s.composedPath && s.composedPath() || []).includes(r) || this.#O(this.activeEditRows, !1);
1569
- }, document.addEventListener("mousedown", this.#f, !1));
1570
- const n = t?.querySelector(".faux-vscroll"), i = t?.querySelector(".rows");
1571
- if (this.virtualization.container = n ?? this, this.#E = this.#o?.getAll().some((s) => s.onScroll) ?? !1, n && i) {
1581
+ const l = this.findRenderedRowElement(this.activeEditRows);
1582
+ !l || (i.composedPath && i.composedPath() || []).includes(l) || this.#D(this.activeEditRows, !1);
1583
+ }, document.addEventListener("mousedown", this.#p, !1));
1584
+ const n = t?.querySelector(".faux-vscroll"), s = t?.querySelector(".rows");
1585
+ if (this.virtualization.container = n ?? this, this.#R = this.#t?.getAll().some((i) => i.onScroll) ?? !1, n && s) {
1572
1586
  n.addEventListener(
1573
1587
  "scroll",
1574
1588
  () => {
1575
- if (!this.virtualization.enabled && !this.#E) return;
1576
- const r = n.scrollTop, l = this.virtualization.rowHeight, a = -(r % l);
1577
- i.style.transform = `translateY(${a}px)`, this.#y = r, this.#x || (this.#x = requestAnimationFrame(() => {
1578
- this.#x = 0, this.#y !== null && (this.#te(this.#y), this.#y = null);
1589
+ if (!this.virtualization.enabled && !this.#R) return;
1590
+ const l = n.scrollTop, r = this.virtualization.rowHeight, a = -(l % r);
1591
+ s.style.transform = `translateY(${a}px)`, this.#E = l, this.#L || (this.#L = requestAnimationFrame(() => {
1592
+ this.#L = 0, this.#E !== null && (this.#ne(this.#E), this.#E = null);
1579
1593
  }));
1580
1594
  },
1581
1595
  { passive: !0 }
1582
1596
  );
1583
- const s = t?.querySelector(".rows-body");
1584
- s && s.addEventListener(
1597
+ const i = t?.querySelector(".rows-body");
1598
+ i && (i.addEventListener(
1585
1599
  "wheel",
1586
- (r) => {
1587
- r.preventDefault(), n.scrollTop += r.deltaY;
1600
+ (l) => {
1601
+ l.preventDefault(), n.scrollTop += l.deltaY;
1588
1602
  },
1589
1603
  { passive: !1 }
1590
- );
1604
+ ), i.addEventListener(
1605
+ "touchstart",
1606
+ (l) => {
1607
+ l.touches.length === 1 && (this.#A = l.touches[0].clientY, this.#S = n.scrollTop);
1608
+ },
1609
+ { passive: !0 }
1610
+ ), i.addEventListener(
1611
+ "touchmove",
1612
+ (l) => {
1613
+ if (l.touches.length === 1 && this.#A !== null && this.#S !== null) {
1614
+ const r = this.#A - l.touches[0].clientY;
1615
+ n.scrollTop = this.#S + r, l.preventDefault();
1616
+ }
1617
+ },
1618
+ { passive: !1 }
1619
+ ), i.addEventListener(
1620
+ "touchend",
1621
+ () => {
1622
+ this.#A = null, this.#S = null;
1623
+ },
1624
+ { passive: !0 }
1625
+ ));
1591
1626
  }
1592
- this.resizeController = Be(this), this.#t.addEventListener("mousedown", (s) => this.#oe(s)), this.#p || (this.#p = (s) => this.#ne(s), document.addEventListener("mousemove", this.#p)), this.#w || (this.#w = (s) => this.#ie(s), document.addEventListener("mouseup", this.#w)), this.virtualization.enabled && requestAnimationFrame(() => this.refreshVirtualWindow(!0)), requestAnimationFrame(() => {
1593
- const s = this.bodyEl.querySelector(".data-grid-row");
1594
- if (s) {
1595
- const r = s.getBoundingClientRect().height;
1596
- r && Math.abs(r - this.virtualization.rowHeight) > 0.1 && (this.virtualization.rowHeight = r, this.refreshVirtualWindow(!0));
1627
+ this.resizeController = Be(this), this.#n.addEventListener("mousedown", (i) => this.#ie(i)), this.#w || (this.#w = (i) => this.#se(i), document.addEventListener("mousemove", this.#w)), this.#b || (this.#b = (i) => this.#le(i), document.addEventListener("mouseup", this.#b)), this.virtualization.enabled && requestAnimationFrame(() => this.refreshVirtualWindow(!0)), requestAnimationFrame(() => {
1628
+ const i = this.bodyEl.querySelector(".data-grid-row");
1629
+ if (i) {
1630
+ const l = i.getBoundingClientRect().height;
1631
+ l && Math.abs(l - this.virtualization.rowHeight) > 0.1 && (this.virtualization.rowHeight = l, this.refreshVirtualWindow(!0));
1597
1632
  }
1598
- }), queueMicrotask(() => this.#G()), requestAnimationFrame(() => requestAnimationFrame(() => this.#H?.()));
1633
+ }), queueMicrotask(() => this.#X()), requestAnimationFrame(() => requestAnimationFrame(() => this.#N?.()));
1599
1634
  }
1600
1635
  // ---------------- Event Emitters ----------------
1601
- #i(e, t) {
1636
+ #s(e, t) {
1602
1637
  this.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
1603
1638
  }
1604
1639
  emitCellCommit(e) {
1605
- this.#i("cell-commit", e);
1640
+ this.#s("cell-commit", e);
1606
1641
  }
1607
1642
  emitRowCommit(e) {
1608
- this.#i("row-commit", e);
1643
+ this.#s("row-commit", e);
1609
1644
  }
1610
1645
  emitSortChange(e) {
1611
- this.#i("sort-change", e);
1646
+ this.#s("sort-change", e);
1612
1647
  }
1613
1648
  emitColumnResize(e) {
1614
- this.#i("column-resize", e);
1649
+ this.#s("column-resize", e);
1615
1650
  }
1616
1651
  emitActivateCell(e) {
1617
- this.#i("activate-cell", e);
1652
+ this.#s("activate-cell", e);
1618
1653
  }
1619
1654
  /** Update ARIA selection attributes on rendered rows/cells */
1620
- #G() {
1655
+ #X() {
1621
1656
  this.bodyEl?.querySelectorAll(".data-grid-row")?.forEach((t, n) => {
1622
- const i = n === this.focusRow;
1623
- t.setAttribute("aria-selected", String(i)), t.querySelectorAll(".cell").forEach((s, r) => {
1624
- s.setAttribute("aria-selected", String(i && r === this.focusCol));
1657
+ const s = n === this.focusRow;
1658
+ t.setAttribute("aria-selected", String(s)), t.querySelectorAll(".cell").forEach((i, l) => {
1659
+ i.setAttribute("aria-selected", String(s && l === this.focusCol));
1625
1660
  });
1626
1661
  });
1627
1662
  }
1628
1663
  // ---------------- Watch Handlers ----------------
1629
- #U() {
1630
- if (!this.#h) return;
1631
- this.#d(), this.#n.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, this.#B()) : (this._columns.forEach((t) => {
1664
+ #j() {
1665
+ if (!this.#u) return;
1666
+ this.#h(), this.#o.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, this.#K()) : (this._columns.forEach((t) => {
1632
1667
  !t.__userResized && t.__autoSized && delete t.width;
1633
1668
  }), this.updateTemplate());
1634
1669
  }
1635
- #X() {
1636
- this.#h && (this.#d(), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
1637
- }
1638
- #j() {
1639
- this._rows = Array.isArray(this.#s) ? [...this.#s] : [], this.#A(), !this.#r || Array.isArray(this.#r) && this.#r.length === 0 ? this.#a() : this.refreshVirtualWindow(!0);
1640
- }
1641
1670
  #Y() {
1642
- j(this), this.#h && (this.#d(), this.#a());
1671
+ this.#u && (this.#h(), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
1643
1672
  }
1644
1673
  #Z() {
1645
- this.#h && (this.#d(), this.#q(), this.#A(), this.#k(), this.#_(), this.updateTemplate(), this.refreshVirtualWindow(!0));
1674
+ this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#T(), !this.#r || Array.isArray(this.#r) && this.#r.length === 0 ? this.#c() : this.refreshVirtualWindow(!0);
1646
1675
  }
1647
- // ---------------- Helper Wrappers ----------------
1648
1676
  #J() {
1677
+ j(this), this.#u && (this.#h(), this.#c());
1678
+ }
1679
+ #Q() {
1680
+ this.#u && (this.#h(), this.#B(), this.#T(), this.#O(), this.#x(), this.updateTemplate(), this.refreshVirtualWindow(!0));
1681
+ }
1682
+ // ---------------- Helper Wrappers ----------------
1683
+ #ee() {
1649
1684
  Oe(this);
1650
1685
  }
1651
- #_() {
1686
+ #x() {
1652
1687
  V(this);
1653
1688
  }
1654
1689
  updateTemplate() {
1655
1690
  he(this);
1656
1691
  }
1657
- #B() {
1692
+ #K() {
1658
1693
  Me(this);
1659
1694
  }
1660
- #k() {
1661
- if (this.#o) {
1662
- const e = this._columns.filter((n) => !n.hidden), t = this.#o.processColumns([...e]);
1695
+ #O() {
1696
+ if (this.#t) {
1697
+ const e = this._columns.filter((n) => !n.hidden), t = this.#t.processColumns([...e]);
1663
1698
  if (t !== e) {
1664
- const n = new Map(t.map((s, r) => [s.field, { col: s, order: r }])), i = this._columns.map((s) => {
1665
- if (s.hidden) return s;
1666
- const r = n.get(s.field);
1667
- return r ? r.col : s;
1699
+ const n = new Map(t.map((i, l) => [i.field, { col: i, order: l }])), s = this._columns.map((i) => {
1700
+ if (i.hidden) return i;
1701
+ const l = n.get(i.field);
1702
+ return l ? l.col : i;
1668
1703
  });
1669
- this._columns = i;
1704
+ this._columns = s;
1670
1705
  }
1671
1706
  }
1672
1707
  }
1673
1708
  /** Execute all plugin afterRender hooks */
1674
- #g() {
1675
- this.#o?.afterRender();
1709
+ #m() {
1710
+ this.#t?.afterRender();
1676
1711
  }
1677
1712
  /** Recompute row model via plugin hooks (grouping, tree, filtering, etc.). */
1678
- #A() {
1713
+ #T() {
1679
1714
  j(this);
1680
- const e = Array.isArray(this.#s) ? [...this.#s] : [], t = this.#o?.processRows(e) ?? e;
1715
+ const e = Array.isArray(this.#l) ? [...this.#l] : [], t = this.#t?.processRows(e) ?? e;
1681
1716
  this._rows = t;
1682
1717
  }
1683
1718
  /**
@@ -1698,75 +1733,75 @@ class q extends HTMLElement {
1698
1733
  * - `_columns` is NOT set here (done by #getColumnConfiguration + #processColumns)
1699
1734
  * - Plugins receive config via their attach() method
1700
1735
  */
1701
- #d() {
1702
- const e = this.#b ? { ...this.#b } : {};
1736
+ #h() {
1737
+ const e = this.#g ? { ...this.#g } : {};
1703
1738
  let t = Array.isArray(e.columns) ? [...e.columns] : [];
1704
- const n = (this.__lightDomColumnsCache || []).map((i) => ({
1705
- ...i
1739
+ const n = (this.__lightDomColumnsCache || []).map((s) => ({
1740
+ ...s
1706
1741
  }));
1707
1742
  if (n.length) {
1708
- const i = {};
1709
- t.forEach((s) => i[s.field] = s), n.forEach((s) => {
1710
- const r = i[s.field];
1711
- 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);
1743
+ const s = {};
1744
+ t.forEach((i) => s[i.field] = i), n.forEach((i) => {
1745
+ const l = s[i.field];
1746
+ l ? (i.header && !l.header && (l.header = i.header), i.type && !l.type && (l.type = i.type), l.sortable = l.sortable || i.sortable, i.resizable && (l.resizable = !0), i.editable && (l.editable = !0)) : (t.push(i), s[i.field] = i);
1712
1747
  });
1713
1748
  }
1714
1749
  if (this.#r && this.#r.length && (t = [...this.#r]), (!t || t.length === 0) && this._rows.length && (t = ce(this._rows).columns), t.length) {
1715
- t.forEach((r) => {
1716
- r.sortable === void 0 && (r.sortable = !0), r.resizable === void 0 && (r.resizable = !0);
1750
+ t.forEach((l) => {
1751
+ l.sortable === void 0 && (l.sortable = !0), l.resizable === void 0 && (l.resizable = !0);
1717
1752
  });
1718
- const i = this.#n.columns;
1719
- i?.some((r) => r.__compiledView || r.__compiledEditor) ? e.columns = i : e.columns = t;
1753
+ const s = this.#o.columns;
1754
+ s?.some((l) => l.__compiledView || l.__compiledEditor) ? e.columns = s : e.columns = t;
1720
1755
  } else {
1721
- const i = this.#n.columns;
1722
- i?.some((s) => s.__compiledView || s.__compiledEditor) && (e.columns = i);
1756
+ const s = this.#o.columns;
1757
+ s?.some((i) => i.__compiledView || i.__compiledEditor) && (e.columns = s);
1723
1758
  }
1724
- this.#v && (e.fitMode = this.#v), e.fitMode || (e.fitMode = "stretch"), this.#C && (e.editOn = this.#C), e.columnState && !this.#c && (this.#c = e.columnState), this.#n = e, e.fitMode === "fixed" && this._columns.forEach((i) => {
1725
- i.width == null && (i.width = 80);
1759
+ this.#C && (e.fitMode = this.#C), e.fitMode || (e.fitMode = "stretch"), this.#y && (e.editOn = this.#y), e.columnState && !this.#d && (this.#d = e.columnState), this.#o = e, e.fitMode === "fixed" && this._columns.forEach((s) => {
1760
+ s.width == null && (s.width = 80);
1726
1761
  });
1727
1762
  }
1728
1763
  // ---------------- Delegate Wrappers ----------------
1729
- #P(e, t, n = this.__rowRenderEpoch) {
1730
- this.#T || (this.#T = (i, s, r) => this.#o?.renderRow(i, s, r) ?? !1), qe(this, e, t, n, this.#T);
1764
+ #M(e, t, n = this.__rowRenderEpoch) {
1765
+ this.#k || (this.#k = (s, i, l) => this.#t?.renderRow(s, i, l) ?? !1), qe(this, e, t, n, this.#k);
1731
1766
  }
1732
- #Q(e, t) {
1733
- A(this, e, t);
1767
+ #te(e, t) {
1768
+ T(this, e, t);
1734
1769
  }
1735
- #O(e, t) {
1770
+ #D(e, t) {
1736
1771
  Ie(this, e, t);
1737
1772
  }
1738
1773
  // ---------------- Core Helpers ----------------
1739
- #a() {
1774
+ #c() {
1740
1775
  if (!this.isConnected || !this.headerRowEl || !this.bodyEl)
1741
1776
  return;
1742
- const e = this.#b?.columns || this.#r || [];
1777
+ const e = this.#g?.columns || this.#r || [];
1743
1778
  if (e.length) {
1744
- const n = new Map(this._columns.filter((s) => s.hidden).map((s) => [s.field, !0])), i = e.map((s) => ({
1745
- ...s,
1746
- hidden: n.get(s.field) ?? s.hidden
1779
+ const n = new Map(this._columns.filter((i) => i.hidden).map((i) => [i.field, !0])), s = e.map((i) => ({
1780
+ ...i,
1781
+ hidden: n.get(i.field) ?? i.hidden
1747
1782
  }));
1748
- this._columns = i;
1783
+ this._columns = s;
1749
1784
  }
1750
- if (this.#J(), this.#d(), this.#q(), this.#A(), this.#k(), this.#c) {
1751
- const n = this.#c;
1752
- this.#c = void 0, this.#$(n);
1785
+ if (this.#ee(), this.#h(), this.#B(), this.#T(), this.#O(), this.#d) {
1786
+ const n = this.#d;
1787
+ this.#d = void 0, this.#W(n);
1753
1788
  }
1754
- this.#_(), this.updateTemplate(), this.refreshVirtualWindow(!0), this.#n.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => this.#B()), this.bodyEl && (this.bodyEl.style.display = "", this.bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#g());
1789
+ this.#x(), this.updateTemplate(), this.refreshVirtualWindow(!0), this.#o.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => this.#K()), this.bodyEl && (this.bodyEl.style.display = "", this.bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#m());
1755
1790
  }
1756
1791
  /** Internal method to apply column state without triggering setup loop */
1757
- #$(e) {
1758
- const t = this.#n.columns ?? [], n = this.#o?.getAll() ?? [];
1792
+ #W(e) {
1793
+ const t = this.#o.columns ?? [], n = this.#t?.getAll() ?? [];
1759
1794
  ge(this, e, t, n);
1760
- for (const i of e.columns) {
1761
- const s = t.find((r) => r.field === i.field);
1762
- s && (s.hidden = !i.visible);
1795
+ for (const s of e.columns) {
1796
+ const i = t.find((l) => l.field === s.field);
1797
+ i && (i.hidden = !s.visible);
1763
1798
  }
1764
1799
  }
1765
- #ee() {
1800
+ #oe() {
1766
1801
  return this._rows.length <= this.virtualization.bypassThreshold;
1767
1802
  }
1768
- #te(e) {
1769
- if (this.refreshVirtualWindow(!1), this.#E) {
1803
+ #ne(e) {
1804
+ if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#R) {
1770
1805
  const t = this.virtualization.container, n = {
1771
1806
  scrollTop: e,
1772
1807
  scrollLeft: t?.scrollLeft ?? 0,
@@ -1776,11 +1811,11 @@ class q extends HTMLElement {
1776
1811
  clientWidth: t?.clientWidth ?? 0,
1777
1812
  originalEvent: new Event("scroll")
1778
1813
  };
1779
- this.#o?.onScroll(n);
1814
+ this.#t?.onScroll(n);
1780
1815
  }
1781
1816
  }
1782
1817
  findHeaderRow() {
1783
- return this.#t.querySelector(".header-row");
1818
+ return this.#n.querySelector(".header-row");
1784
1819
  }
1785
1820
  findRenderedRowElement(e) {
1786
1821
  return Array.from(this.bodyEl.querySelectorAll(".data-grid-row")).find((t) => {
@@ -1792,93 +1827,93 @@ class q extends HTMLElement {
1792
1827
  * Dispatch a cell click event to the plugin system.
1793
1828
  * Returns true if any plugin handled the event.
1794
1829
  */
1795
- dispatchCellClick(e, t, n, i) {
1796
- const s = this._rows[t], r = this._columns[n];
1797
- if (!s || !r) return !1;
1798
- const l = {
1799
- row: s,
1830
+ dispatchCellClick(e, t, n, s) {
1831
+ const i = this._rows[t], l = this._columns[n];
1832
+ if (!i || !l) return !1;
1833
+ const r = {
1834
+ row: i,
1800
1835
  rowIndex: t,
1801
1836
  colIndex: n,
1802
- field: r.field,
1803
- value: s[r.field],
1804
- cellEl: i,
1837
+ field: l.field,
1838
+ value: i[l.field],
1839
+ cellEl: s,
1805
1840
  originalEvent: e
1806
1841
  };
1807
- return this.#o?.onCellClick(l) ?? !1;
1842
+ return this.#t?.onCellClick(r) ?? !1;
1808
1843
  }
1809
1844
  /**
1810
1845
  * Dispatch a header click event to the plugin system.
1811
1846
  * Returns true if any plugin handled the event.
1812
1847
  */
1813
1848
  dispatchHeaderClick(e, t, n) {
1814
- const i = this._columns[t];
1815
- if (!i) return !1;
1816
- const s = {
1849
+ const s = this._columns[t];
1850
+ if (!s) return !1;
1851
+ const i = {
1817
1852
  colIndex: t,
1818
- field: i.field,
1819
- column: i,
1853
+ field: s.field,
1854
+ column: s,
1820
1855
  headerEl: n,
1821
1856
  originalEvent: e
1822
1857
  };
1823
- return this.#o?.onHeaderClick(s) ?? !1;
1858
+ return this.#t?.onHeaderClick(i) ?? !1;
1824
1859
  }
1825
1860
  /**
1826
1861
  * Dispatch a keyboard event to the plugin system.
1827
1862
  * Returns true if any plugin handled the event.
1828
1863
  */
1829
1864
  dispatchKeyDown(e) {
1830
- return this.#o?.onKeyDown(e) ?? !1;
1865
+ return this.#t?.onKeyDown(e) ?? !1;
1831
1866
  }
1832
1867
  /**
1833
1868
  * Build a CellMouseEvent from a native MouseEvent.
1834
1869
  * Extracts cell/row information from the event target.
1835
1870
  */
1836
- #M(e, t) {
1871
+ #H(e, t) {
1837
1872
  let n = null;
1838
- const i = e.composedPath?.();
1839
- if (i && i.length > 0 ? n = i[0] : n = e.target, n && !this.#t.contains(n)) {
1840
- const p = this.#t.elementFromPoint(e.clientX, e.clientY);
1841
- p && (n = p);
1842
- }
1843
- const s = n?.closest?.("[data-col]"), r = n?.closest?.(".data-grid-row"), l = n?.closest?.(".header-row");
1844
- let a, h, u, w, c, d;
1845
- return s && (a = parseInt(s.getAttribute("data-row") ?? "-1", 10), h = parseInt(s.getAttribute("data-col") ?? "-1", 10), a >= 0 && h >= 0 && (u = this._rows[a], d = this._columns[h], w = d?.field, c = u && w ? u[w] : void 0)), {
1873
+ const s = e.composedPath?.();
1874
+ if (s && s.length > 0 ? n = s[0] : n = e.target, n && !this.#n.contains(n)) {
1875
+ const d = this.#n.elementFromPoint(e.clientX, e.clientY);
1876
+ d && (n = d);
1877
+ }
1878
+ const i = n?.closest?.("[data-col]"), l = n?.closest?.(".data-grid-row"), r = n?.closest?.(".header-row");
1879
+ let a, f, p, w, h, c;
1880
+ return i && (a = parseInt(i.getAttribute("data-row") ?? "-1", 10), f = parseInt(i.getAttribute("data-col") ?? "-1", 10), a >= 0 && f >= 0 && (p = this._rows[a], c = this._columns[f], w = c?.field, h = p && w ? p[w] : void 0)), {
1846
1881
  type: t,
1847
- row: u,
1882
+ row: p,
1848
1883
  rowIndex: a !== void 0 && a >= 0 ? a : void 0,
1849
- colIndex: h !== void 0 && h >= 0 ? h : void 0,
1884
+ colIndex: f !== void 0 && f >= 0 ? f : void 0,
1850
1885
  field: w,
1851
- value: c,
1852
- column: d,
1886
+ value: h,
1887
+ column: c,
1853
1888
  originalEvent: e,
1854
- cellElement: s ?? void 0,
1855
- rowElement: r ?? void 0,
1856
- isHeader: !!l,
1857
- cell: a !== void 0 && h !== void 0 && a >= 0 && h >= 0 ? { row: a, col: h } : void 0
1889
+ cellElement: i ?? void 0,
1890
+ rowElement: l ?? void 0,
1891
+ isHeader: !!r,
1892
+ cell: a !== void 0 && f !== void 0 && a >= 0 && f >= 0 ? { row: a, col: f } : void 0
1858
1893
  };
1859
1894
  }
1860
1895
  /**
1861
1896
  * Handle mousedown events and dispatch to plugin system.
1862
1897
  */
1863
- #oe(e) {
1864
- const t = this.#M(e, "mousedown");
1865
- (this.#o?.onCellMouseDown(t) ?? !1) && (this.#R = !0);
1898
+ #ie(e) {
1899
+ const t = this.#H(e, "mousedown");
1900
+ (this.#t?.onCellMouseDown(t) ?? !1) && (this.#_ = !0);
1866
1901
  }
1867
1902
  /**
1868
1903
  * Handle mousemove events (only when dragging).
1869
1904
  */
1870
- #ne(e) {
1871
- if (!this.#R) return;
1872
- const t = this.#M(e, "mousemove");
1873
- this.#o?.onCellMouseMove(t);
1905
+ #se(e) {
1906
+ if (!this.#_) return;
1907
+ const t = this.#H(e, "mousemove");
1908
+ this.#t?.onCellMouseMove(t);
1874
1909
  }
1875
1910
  /**
1876
1911
  * Handle mouseup events.
1877
1912
  */
1878
- #ie(e) {
1879
- if (!this.#R) return;
1880
- const t = this.#M(e, "mouseup");
1881
- this.#o?.onCellMouseUp(t), this.#R = !1;
1913
+ #le(e) {
1914
+ if (!this.#_) return;
1915
+ const t = this.#H(e, "mouseup");
1916
+ this.#t?.onCellMouseUp(t), this.#_ = !1;
1882
1917
  }
1883
1918
  // API consumed by internal utils (rows.ts)
1884
1919
  get changedRows() {
@@ -1888,23 +1923,23 @@ class q extends HTMLElement {
1888
1923
  return Array.from(this._changedRowIndices);
1889
1924
  }
1890
1925
  async resetChangedRows(e) {
1891
- this._changedRowIndices.clear(), e || this.#i("changed-rows-reset", { rows: this.changedRows, indices: this.changedRowIndices }), this.rowPool.forEach((t) => t.classList.remove("changed"));
1926
+ this._changedRowIndices.clear(), e || this.#s("changed-rows-reset", { rows: this.changedRows, indices: this.changedRowIndices }), this.rowPool.forEach((t) => t.classList.remove("changed"));
1892
1927
  }
1893
1928
  async beginBulkEdit(e) {
1894
- this.#Q(e, this._rows[e]);
1929
+ this.#te(e, this._rows[e]);
1895
1930
  }
1896
1931
  async commitActiveRowEdit() {
1897
- this.activeEditRows !== -1 && this.#O(this.activeEditRows, !1);
1932
+ this.activeEditRows !== -1 && this.#D(this.activeEditRows, !1);
1898
1933
  }
1899
1934
  async ready() {
1900
- return this.#D;
1935
+ return this.#z;
1901
1936
  }
1902
1937
  async forceLayout() {
1903
- this.#a(), await new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(e)));
1938
+ this.#c(), await new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(e)));
1904
1939
  }
1905
1940
  /** Public method: returns a frozen snapshot of the merged effective configuration */
1906
1941
  async getConfig() {
1907
- return Object.freeze({ ...this.#n || {} });
1942
+ return Object.freeze({ ...this.#o || {} });
1908
1943
  }
1909
1944
  // ---------------- Column Visibility API ----------------
1910
1945
  /**
@@ -1914,15 +1949,15 @@ class q extends HTMLElement {
1914
1949
  * @returns True if visibility was changed, false if column not found or locked
1915
1950
  */
1916
1951
  setColumnVisible(e, t) {
1917
- const n = this.#n.columns, i = n?.find((l) => l.field === e);
1918
- if (!i || !t && i.lockVisible || !t && (n ?? []).filter((a) => !a.hidden && a.field !== e).length === 0)
1952
+ const n = this.#o.columns, s = n?.find((r) => r.field === e);
1953
+ if (!s || !t && s.lockVisible || !t && (n ?? []).filter((a) => !a.hidden && a.field !== e).length === 0)
1919
1954
  return !1;
1920
- const s = !!i.hidden, r = !t;
1921
- return s !== r ? (i.hidden = r, this.#i("column-visibility", {
1955
+ const i = !!s.hidden, l = !t;
1956
+ return i !== l ? (s.hidden = l, this.#s("column-visibility", {
1922
1957
  field: e,
1923
1958
  visible: t,
1924
- visibleColumns: (n ?? []).filter((l) => !l.hidden).map((l) => l.field)
1925
- }), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#a(), this.requestStateChange(), !0) : !1;
1959
+ visibleColumns: (n ?? []).filter((r) => !r.hidden).map((r) => r.field)
1960
+ }), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#c(), this.requestStateChange(), !0) : !1;
1926
1961
  }
1927
1962
  /**
1928
1963
  * Toggle the visibility of a column.
@@ -1930,8 +1965,8 @@ class q extends HTMLElement {
1930
1965
  * @returns True if visibility was toggled, false if column not found or locked
1931
1966
  */
1932
1967
  toggleColumnVisibility(e) {
1933
- const i = !!this.#n.columns?.find((s) => s.field === e)?.hidden;
1934
- return this.setColumnVisible(e, i);
1968
+ const s = !!this.#o.columns?.find((i) => i.field === e)?.hidden;
1969
+ return this.setColumnVisible(e, s);
1935
1970
  }
1936
1971
  /**
1937
1972
  * Check if a column is currently visible.
@@ -1939,19 +1974,19 @@ class q extends HTMLElement {
1939
1974
  * @returns True if visible, false if hidden or not found
1940
1975
  */
1941
1976
  isColumnVisible(e) {
1942
- const n = this.#n.columns?.find((i) => i.field === e);
1977
+ const n = this.#o.columns?.find((s) => s.field === e);
1943
1978
  return n ? !n.hidden : !1;
1944
1979
  }
1945
1980
  /**
1946
1981
  * Show all columns.
1947
1982
  */
1948
1983
  showAllColumns() {
1949
- const e = this.#n.columns;
1984
+ const e = this.#o.columns;
1950
1985
  e?.some((n) => n.hidden) && (e?.forEach((n) => {
1951
1986
  n.hidden = !1;
1952
- }), this.#i("column-visibility", {
1987
+ }), this.#s("column-visibility", {
1953
1988
  visibleColumns: (e ?? []).map((n) => n.field)
1954
- }), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#a(), this.requestStateChange());
1989
+ }), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#c(), this.requestStateChange());
1955
1990
  }
1956
1991
  /**
1957
1992
  * Get list of all column fields (including hidden).
@@ -1960,7 +1995,7 @@ class q extends HTMLElement {
1960
1995
  * @returns Array of all field names with their visibility status
1961
1996
  */
1962
1997
  getAllColumns() {
1963
- return (this.#n.columns ?? []).map((t) => ({
1998
+ return (this.#o.columns ?? []).map((t) => ({
1964
1999
  field: t.field,
1965
2000
  header: t.header || t.field,
1966
2001
  visible: !t.hidden,
@@ -1974,14 +2009,14 @@ class q extends HTMLElement {
1974
2009
  */
1975
2010
  setColumnOrder(e) {
1976
2011
  if (!e.length) return;
1977
- const t = new Map(this._columns.map((i) => [i.field, i])), n = [];
1978
- for (const i of e) {
1979
- const s = t.get(i);
1980
- s && (n.push(s), t.delete(i));
2012
+ const t = new Map(this._columns.map((s) => [s.field, s])), n = [];
2013
+ for (const s of e) {
2014
+ const i = t.get(s);
2015
+ i && (n.push(i), t.delete(s));
1981
2016
  }
1982
- for (const i of t.values())
1983
- n.push(i);
1984
- this._columns = n, this.#_(), this.updateTemplate(), this.refreshVirtualWindow(!0);
2017
+ for (const s of t.values())
2018
+ n.push(s);
2019
+ this._columns = n, this.#x(), this.updateTemplate(), this.refreshVirtualWindow(!0);
1985
2020
  }
1986
2021
  /**
1987
2022
  * Get the current column order as an array of field names.
@@ -1996,7 +2031,7 @@ class q extends HTMLElement {
1996
2031
  * Returns a serializable object suitable for localStorage or database storage.
1997
2032
  */
1998
2033
  getColumnState() {
1999
- const e = this.#o?.getAll() ?? [];
2034
+ const e = this.#t?.getAll() ?? [];
2000
2035
  return ae(this, e);
2001
2036
  }
2002
2037
  /**
@@ -2004,7 +2039,7 @@ class q extends HTMLElement {
2004
2039
  * Use this to restore previously saved column state.
2005
2040
  */
2006
2041
  set columnState(e) {
2007
- e && (this.#c = e, this.#S && this.#se(e));
2042
+ e && (this.#d = e, this.#i && this.#re(e));
2008
2043
  }
2009
2044
  /**
2010
2045
  * Get the current column state.
@@ -2015,10 +2050,10 @@ class q extends HTMLElement {
2015
2050
  /**
2016
2051
  * Apply column state internally.
2017
2052
  */
2018
- #se(e) {
2019
- (this.#n.columns ?? []).forEach((n) => {
2053
+ #re(e) {
2054
+ (this.#o.columns ?? []).forEach((n) => {
2020
2055
  n.hidden = !1;
2021
- }), this.#$(e), this.#a();
2056
+ }), this.#W(e), this.#c();
2022
2057
  }
2023
2058
  /**
2024
2059
  * Request a state change event to be emitted.
@@ -2027,26 +2062,26 @@ class q extends HTMLElement {
2027
2062
  * The event is debounced to avoid excessive events during drag operations.
2028
2063
  */
2029
2064
  requestStateChange() {
2030
- this.#L || (this.#L = me(
2065
+ this.#P || (this.#P = me(
2031
2066
  this,
2032
- () => this.#o?.getAll() ?? [],
2033
- (e) => this.#i("column-state-change", e)
2034
- )), this.#L();
2067
+ () => this.#t?.getAll() ?? [],
2068
+ (e) => this.#s("column-state-change", e)
2069
+ )), this.#P();
2035
2070
  }
2036
2071
  /**
2037
2072
  * Reset column state to initial configuration.
2038
2073
  * Clears all user modifications (order, width, visibility, sort).
2039
2074
  */
2040
2075
  resetColumnState() {
2041
- this.#c = void 0, (this.#n.columns ?? []).forEach((n) => {
2076
+ this.#d = void 0, (this.#o.columns ?? []).forEach((n) => {
2042
2077
  n.hidden = !1;
2043
- }), this.sortState = null, this.__originalOrder = [], this.#d(), this.#a();
2044
- const t = this.#o?.getAll() ?? [];
2078
+ }), this.sortState = null, this.__originalOrder = [], this.#h(), this.#c();
2079
+ const t = this.#t?.getAll() ?? [];
2045
2080
  for (const n of t)
2046
2081
  if (n.applyColumnState)
2047
- for (const i of this._columns)
2048
- n.applyColumnState(i.field, {
2049
- field: i.field,
2082
+ for (const s of this._columns)
2083
+ n.applyColumnState(s.field, {
2084
+ field: s.field,
2050
2085
  order: 0,
2051
2086
  visible: !0
2052
2087
  });
@@ -2068,7 +2103,7 @@ class q extends HTMLElement {
2068
2103
  console.warn(`[tbw-grid] Tool panel "${e}" not found`);
2069
2104
  return;
2070
2105
  }
2071
- this.#e.activePanel && this.#e.activePanel !== e && this.closeToolPanel(), this.#e.activePanel = e, oe(this.#t, this.#e), ne(this.#t, this.#e), Ue(this.#t, this.#e), this.#i("tool-panel-open", { id: e });
2106
+ this.#e.activePanel && this.#e.activePanel !== e && this.closeToolPanel(), this.#e.activePanel = e, oe(this.#n, this.#e), ne(this.#n, this.#e), Ue(this.#n, this.#e), this.#s("tool-panel-open", { id: e });
2072
2107
  }
2073
2108
  /**
2074
2109
  * Close the currently open tool panel.
@@ -2076,7 +2111,7 @@ class q extends HTMLElement {
2076
2111
  closeToolPanel() {
2077
2112
  if (!this.#e.activePanel) return;
2078
2113
  const e = this.#e.activePanel, t = this.#e.toolPanels.get(e);
2079
- this.#e.activePanelCleanup && (this.#e.activePanelCleanup(), this.#e.activePanelCleanup = null), t?.onClose?.(), this.#e.activePanel = null, oe(this.#t, this.#e), ne(this.#t, this.#e), this.#i("tool-panel-close", { id: e });
2114
+ this.#e.activePanelCleanup && (this.#e.activePanelCleanup(), this.#e.activePanelCleanup = null), t?.onClose?.(), this.#e.activePanel = null, oe(this.#n, this.#e), ne(this.#n, this.#e), this.#s("tool-panel-close", { id: e });
2080
2115
  }
2081
2116
  /**
2082
2117
  * Toggle a tool panel open/closed.
@@ -2098,13 +2133,13 @@ class q extends HTMLElement {
2098
2133
  console.warn(`[tbw-grid] Tool panel "${e.id}" already registered`);
2099
2134
  return;
2100
2135
  }
2101
- this.#e.toolPanels.set(e.id, e), this.#l && this.#m();
2136
+ this.#e.toolPanels.set(e.id, e), this.#a && this.#v();
2102
2137
  }
2103
2138
  /**
2104
2139
  * Unregister a custom tool panel.
2105
2140
  */
2106
2141
  unregisterToolPanel(e) {
2107
- this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#l && this.#m();
2142
+ this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#a && this.#v();
2108
2143
  }
2109
2144
  /**
2110
2145
  * Get registered header content definitions.
@@ -2120,20 +2155,20 @@ class q extends HTMLElement {
2120
2155
  console.warn(`[tbw-grid] Header content "${e.id}" already registered`);
2121
2156
  return;
2122
2157
  }
2123
- this.#e.headerContents.set(e.id, e), this.#l && te(this.#t, this.#e);
2158
+ this.#e.headerContents.set(e.id, e), this.#a && te(this.#n, this.#e);
2124
2159
  }
2125
2160
  /**
2126
2161
  * Unregister custom header content.
2127
2162
  */
2128
2163
  unregisterHeaderContent(e) {
2129
2164
  const t = this.#e.headerContentCleanups.get(e);
2130
- t && (t(), this.#e.headerContentCleanups.delete(e)), this.#e.headerContents.get(e)?.onDestroy?.(), this.#e.headerContents.delete(e), this.#t.querySelector(`[data-header-content="${e}"]`)?.remove();
2165
+ 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();
2131
2166
  }
2132
2167
  /**
2133
2168
  * Get all registered toolbar buttons.
2134
2169
  */
2135
2170
  getToolbarButtons() {
2136
- return Xe(this.#n?.shell, this.#e);
2171
+ return Xe(this.#o?.shell, this.#e);
2137
2172
  }
2138
2173
  /**
2139
2174
  * Register a custom toolbar button programmatically.
@@ -2143,14 +2178,14 @@ class q extends HTMLElement {
2143
2178
  console.warn(`[tbw-grid] Toolbar button "${e.id}" already registered`);
2144
2179
  return;
2145
2180
  }
2146
- this.#e.toolbarButtons.set(e.id, e), this.#l && this.#m();
2181
+ this.#e.toolbarButtons.set(e.id, e), this.#a && this.#v();
2147
2182
  }
2148
2183
  /**
2149
2184
  * Unregister a custom toolbar button.
2150
2185
  */
2151
2186
  unregisterToolbarButton(e) {
2152
2187
  const t = this.#e.toolbarButtonCleanups.get(e);
2153
- t && (t(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#l && this.#m();
2188
+ t && (t(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#a && this.#v();
2154
2189
  }
2155
2190
  /**
2156
2191
  * Enable/disable a toolbar button by ID.
@@ -2158,21 +2193,21 @@ class q extends HTMLElement {
2158
2193
  setToolbarButtonDisabled(e, t) {
2159
2194
  const n = this.#e.toolbarButtons.get(e);
2160
2195
  n && (n.disabled = t);
2161
- const i = this.#t.querySelector(`[data-btn="${e}"]`);
2162
- i && (i.disabled = t);
2196
+ const s = this.#n.querySelector(`[data-btn="${e}"]`);
2197
+ s && (s.disabled = t);
2163
2198
  }
2164
2199
  /**
2165
2200
  * Re-parse light DOM shell elements and refresh shell header.
2166
2201
  * Call this after dynamically modifying <tbw-grid-header> children.
2167
2202
  */
2168
2203
  refreshShellHeader() {
2169
- this.#m();
2204
+ this.#v();
2170
2205
  }
2171
2206
  /**
2172
2207
  * Internal shell header refresh.
2173
2208
  */
2174
- #m() {
2175
- ee(this, this.#e), this.#K(), this.#I();
2209
+ #v() {
2210
+ ee(this, this.#e), this.#F(), this.#$();
2176
2211
  }
2177
2212
  // ---------------- Virtual Window ----------------
2178
2213
  /**
@@ -2183,26 +2218,26 @@ class q extends HTMLElement {
2183
2218
  if (!this.bodyEl) return;
2184
2219
  const t = this._rows.length;
2185
2220
  if (!this.virtualization.enabled) {
2186
- this.#P(0, t), this.#g();
2221
+ this.#M(0, t), this.#m();
2187
2222
  return;
2188
2223
  }
2189
- if (this.#ee()) {
2190
- this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#P(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.#g();
2224
+ if (this.#oe()) {
2225
+ this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#M(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.#m();
2191
2226
  return;
2192
2227
  }
2193
- const n = this.virtualization.container ?? this, s = (this.virtualization.viewportEl ?? n).clientHeight, r = this.virtualization.rowHeight, l = n.scrollTop;
2194
- let a = Math.floor(l / r);
2228
+ const n = this.virtualization.container ?? this, i = (this.virtualization.viewportEl ?? n).clientHeight, l = this.virtualization.rowHeight, r = n.scrollTop;
2229
+ let a = Math.floor(r / l);
2195
2230
  a < 0 && (a = 0);
2196
- const h = Math.ceil(s / r) + 2;
2197
- let u = a + h;
2198
- u > t && (u = t), this.virtualization.start = a, this.virtualization.end = u, this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * r}px`);
2199
- const w = -(l % r);
2200
- this.bodyEl.style.transform = `translateY(${w}px)`, this.#P(a, u, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#g();
2231
+ const f = Math.ceil(i / l) + 2;
2232
+ let p = a + f;
2233
+ p > t && (p = t), this.virtualization.start = a, this.virtualization.end = p, this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * l}px`);
2234
+ const w = -(r % l);
2235
+ this.bodyEl.style.transform = `translateY(${w}px)`, this.#M(a, p, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#m();
2201
2236
  }
2202
2237
  // ---------------- Render ----------------
2203
- #K() {
2238
+ #F() {
2204
2239
  ee(this, this.#e);
2205
- const e = this.#n?.shell, t = Ke(e, this.#e), n = `
2240
+ const e = this.#o?.shell, t = Ke(e, this.#e), n = `
2206
2241
  <div class="tbw-scroll-area">
2207
2242
  <div class="rows-body-wrapper">
2208
2243
  <div class="rows-body">
@@ -2222,15 +2257,15 @@ class q extends HTMLElement {
2222
2257
  </div>
2223
2258
  `;
2224
2259
  if (t) {
2225
- const i = We(e, this.#e), s = Fe(e, this.#e, n);
2226
- this.#t.innerHTML = `
2260
+ const s = We(e, this.#e), i = Fe(e, this.#e, n);
2261
+ this.#n.innerHTML = `
2227
2262
  <div class="tbw-grid-root has-shell">
2228
- ${i}
2229
2263
  ${s}
2264
+ ${i}
2230
2265
  </div>
2231
- `, this.#re(), this.#l = !0;
2266
+ `, this.#ae(), this.#a = !0;
2232
2267
  } else
2233
- this.#t.innerHTML = `
2268
+ this.#n.innerHTML = `
2234
2269
  <div class="tbw-grid-root">
2235
2270
  <div class="tbw-grid-content">
2236
2271
  ${n}
@@ -2241,24 +2276,24 @@ class q extends HTMLElement {
2241
2276
  /**
2242
2277
  * Set up shell event listeners after render.
2243
2278
  */
2244
- #re() {
2245
- Ve(this.#t, this.#n?.shell, this.#e, {
2279
+ #ae() {
2280
+ Ve(this.#n, this.#o?.shell, this.#e, {
2246
2281
  onPanelToggle: (e) => this.toggleToolPanel(e),
2247
2282
  onPanelClose: () => this.closeToolPanel(),
2248
- onToolbarButtonClick: (e) => this.#le(e)
2283
+ onToolbarButtonClick: (e) => this.#ce(e)
2249
2284
  });
2250
2285
  }
2251
2286
  /**
2252
2287
  * Handle toolbar button click (for config buttons with action).
2253
2288
  */
2254
- #le(e) {
2255
- const n = (this.#n?.shell?.header?.toolbarButtons ?? []).find((s) => s.id === e);
2289
+ #ce(e) {
2290
+ const n = (this.#o?.shell?.header?.toolbarButtons ?? []).find((i) => i.id === e);
2256
2291
  if (n?.action) {
2257
2292
  n.action();
2258
2293
  return;
2259
2294
  }
2260
- const i = this.#e.toolbarButtons.get(e);
2261
- i?.action && i.action();
2295
+ const s = this.#e.toolbarButtons.get(e);
2296
+ s?.action && s.action();
2262
2297
  }
2263
2298
  }
2264
2299
  customElements.get(q.tagName) || customElements.define(q.tagName, q);
@@ -2396,8 +2431,8 @@ function ie(o, e, t) {
2396
2431
  function Qe(o) {
2397
2432
  const e = [], t = z(o);
2398
2433
  for (let n = t.startRow; n <= t.endRow; n++)
2399
- for (let i = t.startCol; i <= t.endCol; i++)
2400
- e.push({ row: n, col: i });
2434
+ for (let s = t.startCol; s <= t.endCol; s++)
2435
+ e.push({ row: n, col: s });
2401
2436
  return e;
2402
2437
  }
2403
2438
  function et(o) {
@@ -2427,9 +2462,9 @@ function tt(o, e, t) {
2427
2462
  ]
2428
2463
  };
2429
2464
  if (o === "row" && e.selected.size > 0) {
2430
- const n = [...e.selected].map((i) => ({
2431
- from: { row: i, col: 0 },
2432
- to: { row: i, col: t - 1 }
2465
+ const n = [...e.selected].map((s) => ({
2466
+ from: { row: s, col: 0 },
2467
+ to: { row: s, col: t - 1 }
2433
2468
  }));
2434
2469
  return { mode: o, ranges: n };
2435
2470
  }
@@ -2461,17 +2496,17 @@ class st extends ue {
2461
2496
  }
2462
2497
  // ===== Event Handlers =====
2463
2498
  onCellClick(e) {
2464
- const { rowIndex: t, colIndex: n, originalEvent: i } = e, { mode: s } = this.config;
2465
- if (s === "cell")
2466
- return this.selectedCell = { row: t, col: n }, this.emit("selection-change", this.#t()), this.requestAfterRender(), !1;
2467
- if (s === "row")
2468
- return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#t()), this.requestAfterRender(), !1;
2469
- if (s === "range") {
2470
- const r = i.shiftKey, l = i.ctrlKey || i.metaKey;
2471
- if (r && this.cellAnchor) {
2499
+ const { rowIndex: t, colIndex: n, originalEvent: s } = e, { mode: i } = this.config;
2500
+ if (i === "cell")
2501
+ return this.selectedCell = { row: t, col: n }, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
2502
+ if (i === "row")
2503
+ return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
2504
+ if (i === "range") {
2505
+ const l = s.shiftKey, r = s.ctrlKey || s.metaKey;
2506
+ if (l && this.cellAnchor) {
2472
2507
  const a = se(this.cellAnchor, { row: t, col: n });
2473
- l ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = a : this.ranges.push(a) : this.ranges = [a], this.activeRange = a;
2474
- } else if (l) {
2508
+ r ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = a : this.ranges.push(a) : this.ranges = [a], this.activeRange = a;
2509
+ } else if (r) {
2475
2510
  const a = {
2476
2511
  startRow: t,
2477
2512
  startCol: n,
@@ -2488,24 +2523,24 @@ class st extends ue {
2488
2523
  };
2489
2524
  this.ranges = [a], this.activeRange = a, this.cellAnchor = { row: t, col: n };
2490
2525
  }
2491
- return this.emit("selection-change", this.#t()), this.requestAfterRender(), !1;
2526
+ return this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
2492
2527
  }
2493
2528
  return !1;
2494
2529
  }
2495
2530
  onKeyDown(e) {
2496
2531
  const { mode: t } = this.config;
2497
2532
  if (e.key === "Escape")
2498
- 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.#t()), this.requestAfterRender(), !0;
2533
+ 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;
2499
2534
  if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
2500
- const n = this.rows.length, i = this.columns.length;
2501
- if (n > 0 && i > 0) {
2502
- const s = {
2535
+ const n = this.rows.length, s = this.columns.length;
2536
+ if (n > 0 && s > 0) {
2537
+ const i = {
2503
2538
  startRow: 0,
2504
2539
  startCol: 0,
2505
2540
  endRow: n - 1,
2506
- endCol: i - 1
2541
+ endCol: s - 1
2507
2542
  };
2508
- return this.ranges = [s], this.activeRange = s, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0;
2543
+ return this.ranges = [i], this.activeRange = i, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
2509
2544
  }
2510
2545
  }
2511
2546
  return !1;
@@ -2516,43 +2551,61 @@ class st extends ue {
2516
2551
  this.isDragging = !0;
2517
2552
  const t = e.rowIndex, n = e.colIndex;
2518
2553
  this.cellAnchor = { row: t, col: n }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
2519
- const s = {
2554
+ const i = {
2520
2555
  startRow: t,
2521
2556
  startCol: n,
2522
2557
  endRow: t,
2523
2558
  endCol: n
2524
2559
  };
2525
- return this.ranges.push(s), this.activeRange = s, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0;
2560
+ return this.ranges.push(i), this.activeRange = i, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
2526
2561
  }
2527
2562
  onCellMouseMove(e) {
2528
2563
  if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
2529
2564
  const t = se(this.cellAnchor, { row: e.rowIndex, col: e.colIndex });
2530
- return this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = t : this.ranges.push(t), this.activeRange = t, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0;
2565
+ 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;
2531
2566
  }
2532
2567
  onCellMouseUp(e) {
2533
2568
  if (this.config.mode === "range" && this.isDragging)
2534
2569
  return this.isDragging = !1, !0;
2535
2570
  }
2536
- afterRender() {
2571
+ /**
2572
+ * Apply selection classes to visible cells/rows.
2573
+ * Shared by afterRender and onScrollRender.
2574
+ */
2575
+ #n() {
2537
2576
  const e = this.shadowRoot;
2538
2577
  if (!e) return;
2539
- const t = e.children[0], { mode: n } = this.config;
2540
- this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), e.querySelectorAll(".cell").forEach((r) => {
2541
- r.classList.remove("selected", "top", "bottom", "first", "last");
2578
+ const { mode: t } = this.config;
2579
+ e.querySelectorAll(".cell").forEach((i) => {
2580
+ i.classList.remove("selected", "top", "bottom", "first", "last");
2542
2581
  });
2543
2582
  const s = e.querySelectorAll(".data-grid-row");
2544
- if (s.forEach((r) => {
2545
- r.classList.remove("selected");
2546
- }), n === "row" && (s.forEach((r) => r.classList.remove("row-focus")), s.forEach((r) => {
2547
- const l = r.querySelector(".cell[data-row]"), a = parseInt(l?.getAttribute("data-row") ?? "-1", 10);
2548
- a >= 0 && this.selected.has(a) && r.classList.add("selected", "row-focus");
2549
- })), n === "range" && this.ranges.length > 0) {
2550
- const r = this.activeRange ? z(this.activeRange) : null;
2551
- e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
2552
- const h = parseInt(a.getAttribute("data-row") ?? "-1", 10), u = parseInt(a.getAttribute("data-col") ?? "-1", 10);
2553
- h >= 0 && u >= 0 && ie(h, u, this.ranges) && (a.classList.add("selected"), r && (h === r.startRow && a.classList.add("top"), h === r.endRow && a.classList.add("bottom"), u === r.startCol && a.classList.add("first"), u === r.endCol && a.classList.add("last")));
2583
+ if (s.forEach((i) => {
2584
+ i.classList.remove("selected", "row-focus");
2585
+ }), t === "row" && s.forEach((i) => {
2586
+ const l = i.querySelector(".cell[data-row]"), r = parseInt(l?.getAttribute("data-row") ?? "-1", 10);
2587
+ r >= 0 && this.selected.has(r) && (i.classList.add("selected", "row-focus"), i.querySelectorAll(".cell-focus").forEach((a) => a.classList.remove("cell-focus")));
2588
+ }), t === "range" && this.ranges.length > 0) {
2589
+ const i = this.activeRange ? z(this.activeRange) : null;
2590
+ e.querySelectorAll(".cell[data-row][data-col]").forEach((r) => {
2591
+ const a = parseInt(r.getAttribute("data-row") ?? "-1", 10), f = parseInt(r.getAttribute("data-col") ?? "-1", 10);
2592
+ a >= 0 && f >= 0 && ie(a, f, this.ranges) && (r.classList.add("selected"), r.classList.remove("cell-focus"), i && (a === i.startRow && r.classList.add("top"), a === i.endRow && r.classList.add("bottom"), f === i.startCol && r.classList.add("first"), f === i.endCol && r.classList.add("last")));
2554
2593
  });
2555
2594
  }
2595
+ t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((i) => i.classList.remove("cell-focus"));
2596
+ }
2597
+ afterRender() {
2598
+ const e = this.shadowRoot;
2599
+ if (!e) return;
2600
+ const t = e.children[0], { mode: n } = this.config;
2601
+ this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), this.#n();
2602
+ }
2603
+ /**
2604
+ * Called after scroll-triggered row rendering.
2605
+ * Reapplies selection classes to recycled DOM elements.
2606
+ */
2607
+ onScrollRender() {
2608
+ this.#n();
2556
2609
  }
2557
2610
  // ===== Public API =====
2558
2611
  /**
@@ -2606,7 +2659,7 @@ class st extends ue {
2606
2659
  }), this.requestAfterRender();
2607
2660
  }
2608
2661
  // ===== Private Helpers =====
2609
- #t() {
2662
+ #i() {
2610
2663
  return tt(
2611
2664
  this.config.mode,
2612
2665
  {
@@ -2655,67 +2708,67 @@ class st extends ue {
2655
2708
  function G(o, e, t) {
2656
2709
  return o.id !== void 0 ? String(o.id) : t ? `${t}-${e}` : String(e);
2657
2710
  }
2658
- function fe(o, e, t, n = null, i = 0) {
2659
- const s = e.childrenField ?? "children", r = [];
2660
- for (let l = 0; l < o.length; l++) {
2661
- const a = o[l], h = G(a, l, n), u = a[s], w = Array.isArray(u) && u.length > 0, c = t.has(h);
2662
- if (r.push({
2663
- key: h,
2711
+ function fe(o, e, t, n = null, s = 0) {
2712
+ const i = e.childrenField ?? "children", l = [];
2713
+ for (let r = 0; r < o.length; r++) {
2714
+ const a = o[r], f = G(a, r, n), p = a[i], w = Array.isArray(p) && p.length > 0, h = t.has(f);
2715
+ if (l.push({
2716
+ key: f,
2664
2717
  data: a,
2665
- depth: i,
2718
+ depth: s,
2666
2719
  hasChildren: w,
2667
- isExpanded: c,
2720
+ isExpanded: h,
2668
2721
  parentKey: n
2669
- }), w && c) {
2670
- const d = fe(u, e, t, h, i + 1);
2671
- r.push(...d);
2722
+ }), w && h) {
2723
+ const c = fe(p, e, t, f, s + 1);
2724
+ l.push(...c);
2672
2725
  }
2673
2726
  }
2674
- return r;
2727
+ return l;
2675
2728
  }
2676
- function re(o, e) {
2729
+ function le(o, e) {
2677
2730
  const t = new Set(o);
2678
2731
  return t.has(e) ? t.delete(e) : t.add(e), t;
2679
2732
  }
2680
2733
  function W(o, e, t = null, n = 0) {
2681
- const i = e.childrenField ?? "children", s = /* @__PURE__ */ new Set();
2682
- for (let r = 0; r < o.length; r++) {
2683
- const l = o[r], a = G(l, r, t), h = l[i];
2684
- if (Array.isArray(h) && h.length > 0) {
2685
- s.add(a);
2686
- const u = W(h, e, a, n + 1);
2687
- for (const w of u) s.add(w);
2734
+ const s = e.childrenField ?? "children", i = /* @__PURE__ */ new Set();
2735
+ for (let l = 0; l < o.length; l++) {
2736
+ const r = o[l], a = G(r, l, t), f = r[s];
2737
+ if (Array.isArray(f) && f.length > 0) {
2738
+ i.add(a);
2739
+ const p = W(f, e, a, n + 1);
2740
+ for (const w of p) i.add(w);
2688
2741
  }
2689
2742
  }
2690
- return s;
2743
+ return i;
2691
2744
  }
2692
2745
  function ot() {
2693
2746
  return /* @__PURE__ */ new Set();
2694
2747
  }
2695
- function pe(o, e, t, n = null, i = 0) {
2696
- const s = t.childrenField ?? "children";
2697
- for (let r = 0; r < o.length; r++) {
2698
- const l = o[r], a = G(l, r, n);
2748
+ function pe(o, e, t, n = null, s = 0) {
2749
+ const i = t.childrenField ?? "children";
2750
+ for (let l = 0; l < o.length; l++) {
2751
+ const r = o[l], a = G(r, l, n);
2699
2752
  if (a === e)
2700
2753
  return [a];
2701
- const h = l[s];
2702
- if (Array.isArray(h) && h.length > 0) {
2703
- const u = pe(h, e, t, a, i + 1);
2704
- if (u)
2705
- return [a, ...u];
2754
+ const f = r[i];
2755
+ if (Array.isArray(f) && f.length > 0) {
2756
+ const p = pe(f, e, t, a, s + 1);
2757
+ if (p)
2758
+ return [a, ...p];
2706
2759
  }
2707
2760
  }
2708
2761
  return null;
2709
2762
  }
2710
2763
  function nt(o, e, t, n) {
2711
- const i = pe(o, e, t);
2712
- if (!i) return n;
2713
- const s = new Set(n);
2714
- for (let r = 0; r < i.length - 1; r++)
2715
- s.add(i[r]);
2716
- return s;
2717
- }
2718
- function le(o, e = "children") {
2764
+ const s = pe(o, e, t);
2765
+ if (!s) return n;
2766
+ const i = new Set(n);
2767
+ for (let l = 0; l < s.length - 1; l++)
2768
+ i.add(s[l]);
2769
+ return i;
2770
+ }
2771
+ function re(o, e = "children") {
2719
2772
  if (!Array.isArray(o) || o.length === 0) return !1;
2720
2773
  for (const t of o)
2721
2774
  if (t && Array.isArray(t[e]) && t[e].length > 0)
@@ -2733,7 +2786,7 @@ function it(o) {
2733
2786
  }
2734
2787
  return null;
2735
2788
  }
2736
- class rt extends ue {
2789
+ class lt extends ue {
2737
2790
  name = "tree";
2738
2791
  version = "1.0.0";
2739
2792
  get defaultConfig() {
@@ -2767,12 +2820,12 @@ class rt extends ue {
2767
2820
  detect(e) {
2768
2821
  if (!this.config.autoDetect) return !1;
2769
2822
  const t = this.config.childrenField ?? it(e) ?? "children";
2770
- return le(e, t);
2823
+ return re(e, t);
2771
2824
  }
2772
2825
  // ===== Data Processing =====
2773
2826
  processRows(e) {
2774
2827
  const t = this.config.childrenField ?? "children";
2775
- if (!le(e, t))
2828
+ if (!re(e, t))
2776
2829
  return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
2777
2830
  this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = W(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = fe(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
2778
2831
  for (const n of this.flattenedRows)
@@ -2787,28 +2840,28 @@ class rt extends ue {
2787
2840
  }
2788
2841
  processColumns(e) {
2789
2842
  if (this.flattenedRows.length === 0) return [...e];
2790
- const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, i = [...e];
2791
- if (i.length > 0) {
2792
- const s = { ...i[0] }, r = s.viewRenderer;
2793
- s.viewRenderer = (l) => {
2794
- const { value: a, row: h, column: u } = l, w = h.__treeDepth ?? 0, c = h.__treeHasChildren ?? !1, d = h.__treeExpanded ?? !1, p = document.createElement("span");
2795
- if (p.style.display = "flex", p.style.alignItems = "center", p.style.paddingLeft = `${w * t}px`, c && n) {
2843
+ const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, s = [...e];
2844
+ if (s.length > 0) {
2845
+ const i = { ...s[0] }, l = i.viewRenderer;
2846
+ i.viewRenderer = (r) => {
2847
+ const { value: a, row: f, column: p } = r, w = f.__treeDepth ?? 0, h = f.__treeHasChildren ?? !1, c = f.__treeExpanded ?? !1, d = document.createElement("span");
2848
+ if (d.style.display = "flex", d.style.alignItems = "center", d.style.paddingLeft = `${w * t}px`, h && n) {
2796
2849
  const b = document.createElement("span");
2797
- b.className = "tree-toggle", b.textContent = d ? "▼" : "▶", b.style.cursor = "pointer", b.style.marginRight = "4px", b.style.fontSize = "10px", b.setAttribute("data-tree-key", h.__treeKey), p.appendChild(b);
2850
+ b.className = "tree-toggle", b.textContent = c ? "▼" : "▶", b.style.cursor = "pointer", b.style.marginRight = "4px", b.style.fontSize = "10px", b.setAttribute("data-tree-key", f.__treeKey), d.appendChild(b);
2798
2851
  } else if (n) {
2799
2852
  const b = document.createElement("span");
2800
- b.style.width = "14px", b.style.display = "inline-block", p.appendChild(b);
2853
+ b.style.width = "14px", b.style.display = "inline-block", d.appendChild(b);
2801
2854
  }
2802
- const f = document.createElement("span");
2803
- if (r) {
2804
- const b = r(l);
2805
- b instanceof Node ? f.appendChild(b) : f.textContent = String(b ?? a ?? "");
2855
+ const u = document.createElement("span");
2856
+ if (l) {
2857
+ const b = l(r);
2858
+ b instanceof Node ? u.appendChild(b) : u.textContent = String(b ?? a ?? "");
2806
2859
  } else
2807
- f.textContent = String(a ?? "");
2808
- return p.appendChild(f), p;
2809
- }, i[0] = s;
2860
+ u.textContent = String(a ?? "");
2861
+ return d.appendChild(u), d;
2862
+ }, s[0] = i;
2810
2863
  }
2811
- return i;
2864
+ return s;
2812
2865
  }
2813
2866
  // ===== Event Handlers =====
2814
2867
  onCellClick(e) {
@@ -2816,12 +2869,12 @@ class rt extends ue {
2816
2869
  if (!t?.classList.contains("tree-toggle")) return !1;
2817
2870
  const n = t.getAttribute("data-tree-key");
2818
2871
  if (!n) return !1;
2819
- const i = this.rowKeyMap.get(n);
2820
- return i ? (this.expandedKeys = re(this.expandedKeys, n), this.emit("tree-expand", {
2872
+ const s = this.rowKeyMap.get(n);
2873
+ return s ? (this.expandedKeys = le(this.expandedKeys, n), this.emit("tree-expand", {
2821
2874
  key: n,
2822
- row: i.data,
2875
+ row: s.data,
2823
2876
  expanded: this.expandedKeys.has(n),
2824
- depth: i.depth
2877
+ depth: s.depth
2825
2878
  }), this.requestRender(), !0) : !1;
2826
2879
  }
2827
2880
  // ===== Public API =====
@@ -2841,7 +2894,7 @@ class rt extends ue {
2841
2894
  * Toggle the expansion state of a node.
2842
2895
  */
2843
2896
  toggle(e) {
2844
- this.expandedKeys = re(this.expandedKeys, e), this.requestRender();
2897
+ this.expandedKeys = le(this.expandedKeys, e), this.requestRender();
2845
2898
  }
2846
2899
  /**
2847
2900
  * Expand all nodes in the tree.
@@ -2897,7 +2950,7 @@ class rt extends ue {
2897
2950
  }
2898
2951
  `;
2899
2952
  }
2900
- const v = {
2953
+ const C = {
2901
2954
  // Root structure
2902
2955
  ROOT: "tbw-grid-root",
2903
2956
  HEADER: "header",
@@ -2949,23 +3002,23 @@ const v = {
2949
3002
  GROUP_KEY: "data-group-key",
2950
3003
  TREE_LEVEL: "data-tree-level",
2951
3004
  STICKY: "data-sticky"
2952
- }, lt = {
2953
- ROOT: `.${v.ROOT}`,
2954
- HEADER: `.${v.HEADER}`,
2955
- HEADER_ROW: `.${v.HEADER_ROW}`,
2956
- HEADER_CELL: `.${v.HEADER_CELL}`,
2957
- ROWS_VIEWPORT: `.${v.ROWS_VIEWPORT}`,
2958
- ROWS_CONTAINER: `.${v.ROWS_CONTAINER}`,
2959
- DATA_ROW: `.${v.DATA_ROW}`,
2960
- DATA_CELL: `.${v.DATA_CELL}`,
2961
- GROUP_ROW: `.${v.GROUP_ROW}`,
3005
+ }, rt = {
3006
+ ROOT: `.${C.ROOT}`,
3007
+ HEADER: `.${C.HEADER}`,
3008
+ HEADER_ROW: `.${C.HEADER_ROW}`,
3009
+ HEADER_CELL: `.${C.HEADER_CELL}`,
3010
+ ROWS_VIEWPORT: `.${C.ROWS_VIEWPORT}`,
3011
+ ROWS_CONTAINER: `.${C.ROWS_CONTAINER}`,
3012
+ DATA_ROW: `.${C.DATA_ROW}`,
3013
+ DATA_CELL: `.${C.DATA_CELL}`,
3014
+ GROUP_ROW: `.${C.GROUP_ROW}`,
2962
3015
  // By data attribute
2963
- ROW_BY_INDEX: (o) => `.${v.DATA_ROW}[${H.ROW_INDEX}="${o}"]`,
2964
- CELL_BY_FIELD: (o) => `.${v.DATA_CELL}[${H.FIELD}="${o}"]`,
2965
- CELL_AT: (o, e) => `.${v.DATA_ROW}[${H.ROW_INDEX}="${o}"] .${v.DATA_CELL}[${H.COL_INDEX}="${e}"]`,
3016
+ ROW_BY_INDEX: (o) => `.${C.DATA_ROW}[${H.ROW_INDEX}="${o}"]`,
3017
+ CELL_BY_FIELD: (o) => `.${C.DATA_CELL}[${H.FIELD}="${o}"]`,
3018
+ CELL_AT: (o, e) => `.${C.DATA_ROW}[${H.ROW_INDEX}="${o}"] .${C.DATA_CELL}[${H.COL_INDEX}="${e}"]`,
2966
3019
  // State selectors
2967
- SELECTED_ROWS: `.${v.DATA_ROW}.${v.SELECTED}`,
2968
- EDITING_CELL: `.${v.DATA_CELL}.${v.EDITING}`
3020
+ SELECTED_ROWS: `.${C.DATA_ROW}.${C.SELECTED}`,
3021
+ EDITING_CELL: `.${C.DATA_CELL}.${C.EDITING}`
2969
3022
  }, at = {
2970
3023
  // Colors
2971
3024
  COLOR_BG: "--tbw-color-bg",
@@ -3033,7 +3086,7 @@ const v = {
3033
3086
  }, I = {
3034
3087
  sum: (o, e) => o.reduce((t, n) => t + (Number(n[e]) || 0), 0),
3035
3088
  avg: (o, e) => {
3036
- const t = o.reduce((n, i) => n + (Number(i[e]) || 0), 0);
3089
+ const t = o.reduce((n, s) => n + (Number(s[e]) || 0), 0);
3037
3090
  return o.length ? t / o.length : 0;
3038
3091
  },
3039
3092
  count: (o) => o.length,
@@ -3041,7 +3094,7 @@ const v = {
3041
3094
  max: (o, e) => Math.max(...o.map((t) => Number(t[e]) || -1 / 0)),
3042
3095
  first: (o, e) => o[0]?.[e],
3043
3096
  last: (o, e) => o[o.length - 1]?.[e]
3044
- }, P = /* @__PURE__ */ new Map(), R = {
3097
+ }, P = /* @__PURE__ */ new Map(), S = {
3045
3098
  /**
3046
3099
  * Register a custom aggregator function.
3047
3100
  */
@@ -3065,8 +3118,8 @@ const v = {
3065
3118
  * Run an aggregator on a set of rows.
3066
3119
  */
3067
3120
  run(o, e, t, n) {
3068
- const i = this.get(o);
3069
- return i ? i(e, t, n) : void 0;
3121
+ const s = this.get(o);
3122
+ return s ? s(e, t, n) : void 0;
3070
3123
  },
3071
3124
  /**
3072
3125
  * Check if an aggregator exists.
@@ -3080,22 +3133,22 @@ const v = {
3080
3133
  list() {
3081
3134
  return [...Object.keys(I), ...P.keys()];
3082
3135
  }
3083
- }, ht = R.register.bind(R), ut = R.unregister.bind(R), ft = R.get.bind(R), pt = R.run.bind(R), wt = R.list.bind(R);
3136
+ }, ht = S.register.bind(S), ut = S.unregister.bind(S), ft = S.get.bind(S), pt = S.run.bind(S), wt = S.list.bind(S);
3084
3137
  export {
3085
3138
  ue as BaseGridPlugin,
3086
3139
  ct as DGEvents,
3087
3140
  q as DataGridElement,
3088
3141
  O as FitModeEnum,
3089
3142
  at as GridCSSVars,
3090
- v as GridClasses,
3143
+ C as GridClasses,
3091
3144
  H as GridDataAttrs,
3092
3145
  q as GridElement,
3093
- lt as GridSelectors,
3146
+ rt as GridSelectors,
3094
3147
  dt as PluginEvents,
3095
3148
  Ye as PluginManager,
3096
3149
  st as SelectionPlugin,
3097
- rt as TreePlugin,
3098
- R as aggregatorRegistry,
3150
+ lt as TreePlugin,
3151
+ S as aggregatorRegistry,
3099
3152
  ft as getAggregator,
3100
3153
  wt as listAggregators,
3101
3154
  ht as registerAggregator,