@toolbox-web/grid 0.3.0 → 0.3.2

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 (44) hide show
  1. package/index.js +1265 -1247
  2. package/index.js.map +1 -1
  3. package/lib/core/grid.d.ts +2 -8
  4. package/lib/core/grid.d.ts.map +1 -1
  5. package/lib/core/internal/columns.d.ts +2 -69
  6. package/lib/core/internal/columns.d.ts.map +1 -1
  7. package/lib/core/internal/dom-builder.d.ts +7 -11
  8. package/lib/core/internal/dom-builder.d.ts.map +1 -1
  9. package/lib/core/internal/editing.d.ts.map +1 -1
  10. package/lib/core/internal/idle-scheduler.d.ts +0 -8
  11. package/lib/core/internal/idle-scheduler.d.ts.map +1 -1
  12. package/lib/core/internal/rows.d.ts +0 -5
  13. package/lib/core/internal/rows.d.ts.map +1 -1
  14. package/lib/core/internal/shell.d.ts +34 -18
  15. package/lib/core/internal/shell.d.ts.map +1 -1
  16. package/lib/core/internal/utils.d.ts +0 -7
  17. package/lib/core/internal/utils.d.ts.map +1 -1
  18. package/lib/core/types.d.ts +42 -15
  19. package/lib/core/types.d.ts.map +1 -1
  20. package/lib/plugins/clipboard/index.js.map +1 -1
  21. package/lib/plugins/column-virtualization/index.js.map +1 -1
  22. package/lib/plugins/context-menu/index.js.map +1 -1
  23. package/lib/plugins/export/index.js.map +1 -1
  24. package/lib/plugins/filtering/index.js.map +1 -1
  25. package/lib/plugins/grouping-columns/index.js.map +1 -1
  26. package/lib/plugins/grouping-rows/index.js.map +1 -1
  27. package/lib/plugins/master-detail/index.js.map +1 -1
  28. package/lib/plugins/multi-sort/index.js.map +1 -1
  29. package/lib/plugins/pinned-columns/index.js.map +1 -1
  30. package/lib/plugins/pinned-rows/index.js.map +1 -1
  31. package/lib/plugins/pivot/index.js.map +1 -1
  32. package/lib/plugins/reorder/index.js.map +1 -1
  33. package/lib/plugins/selection/index.js.map +1 -1
  34. package/lib/plugins/server-side/index.js.map +1 -1
  35. package/lib/plugins/tree/index.js.map +1 -1
  36. package/lib/plugins/undo-redo/index.js.map +1 -1
  37. package/lib/plugins/visibility/index.js.map +1 -1
  38. package/package.json +1 -1
  39. package/public.d.ts +6 -0
  40. package/public.d.ts.map +1 -1
  41. package/umd/grid.all.umd.js +20 -20
  42. package/umd/grid.all.umd.js.map +1 -1
  43. package/umd/grid.umd.js +10 -10
  44. package/umd/grid.umd.js.map +1 -1
package/index.js CHANGED
@@ -1,92 +1,92 @@
1
- const de = ':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-cell-white-space: nowrap;--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: 6px;--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-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--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;opacity:.6}:host .header-row>.cell:last-child{border-right:0}:host .header-group-cell:not(:last-child),:host .header-row>.cell.grouped.group-end:not(:last-child){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.selected:focus-visible,:host .data-grid-row>.cell:focus-visible:not(.cell-focus){outline:none}:host .data-grid-row>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);line-height:calc(var(--tbw-row-height) - 5px);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis}:host .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}:host .data-grid-row>.cell:last-child{border-right:0}:host .data-grid-row>.cell[data-type=boolean]{text-align:center}:host .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}:host .data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px)}: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%;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 .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: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 32px;--tbw-toolbar-button-gap: 4px}:host .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}:host .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}:host .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}:host .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}:host .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}:host .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}:host .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}:host .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}:host .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}:host .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}:host .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}:host .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}:host .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}:host .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}:host .tbw-tool-panel-resize[data-handle-position=left]{left:0}:host .tbw-tool-panel-resize[data-handle-position=right]{right:0}:host .tbw-tool-panel-resize:hover,:host .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}:host .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}:host .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}:host .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}:host .tbw-tool-panel-content{flex:1;overflow:auto}:host .tbw-accordion{display:flex;flex-direction:column;gap:0}:host .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}:host .tbw-accordion-section:last-child{border-bottom:none}:host .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:left;cursor:pointer;user-select:none}:host .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}:host .tbw-accordion-section.single .tbw-accordion-header{cursor:default}:host .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}:host .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}:host .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}:host .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}:host .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .tbw-accordion-content{display:none}:host .tbw-accordion-section.expanded .tbw-accordion-content{display:block}@media(prefers-reduced-motion:reduce){:host([data-animation-mode="reduced-motion"]){--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}}:host([data-animation-mode="off"]){--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}:host .tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}:host .tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}:host .tbw-fade-in{animation:tbw-fade-in var(--tbw-animation-duration) var(--tbw-animation-easing) forwards}:host .tbw-fade-out{animation:tbw-fade-out var(--tbw-animation-duration) var(--tbw-animation-easing) forwards}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}@keyframes tbw-fade-out{0%{opacity:1}to{opacity:0}}:host .tbw-flip-animating{will-change:transform;z-index:1}:host .tbw-toggle-icon{display:inline-flex;align-items:center;justify-content:center;transition:transform var(--tbw-animation-duration) var(--tbw-animation-easing)}:host .tbw-toggle-icon.tbw-expanded{transform:rotate(90deg)}';
2
- function Ve(t) {
1
+ const de = ':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-cell-white-space: nowrap;--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: 6px;--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-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--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-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px;--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;opacity:.6}:host .header-row>.cell:last-child{border-right:0}:host .header-group-cell:not(:last-child),:host .header-row>.cell.grouped.group-end:not(:last-child){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;content-visibility:auto;contain-intrinsic-size:auto var(--tbw-row-height)}:host .data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}:host .selecting .data-grid-row>.cell{user-select:none}:host .data-grid-row>.cell.selected:focus-visible,:host .data-grid-row>.cell:focus-visible:not(.cell-focus){outline:none}:host .data-grid-row>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);line-height:calc(var(--tbw-row-height) - 5px);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis}:host .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}:host .data-grid-row>.cell:last-child{border-right:0}:host .data-grid-row>.cell[data-type=boolean]{text-align:center}:host .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}:host .data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px)}: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%;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 .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: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 32px;--tbw-toolbar-button-gap: 4px}:host .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}:host .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}:host .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}:host .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}:host .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}:host .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}:host .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}:host .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}:host .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}:host .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}:host .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}:host .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}:host .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}:host .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}:host .tbw-tool-panel-resize[data-handle-position=left]{left:0}:host .tbw-tool-panel-resize[data-handle-position=right]{right:0}:host .tbw-tool-panel-resize:hover,:host .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}:host .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}:host .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}:host .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}:host .tbw-tool-panel-content{flex:1;overflow:auto}:host .tbw-accordion{display:flex;flex-direction:column;gap:0}:host .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}:host .tbw-accordion-section:last-child{border-bottom:none}:host .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:left;cursor:pointer;user-select:none}:host .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}:host .tbw-accordion-section.single .tbw-accordion-header{cursor:default}:host .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}:host .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}:host .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}:host .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}:host .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .tbw-accordion-content{display:none}:host .tbw-accordion-section.expanded .tbw-accordion-content{display:block}@media(forced-colors:active){:host{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight}:host .cell:focus,:host .cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}:host .data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}@media(prefers-reduced-motion:reduce){:host([data-animation-mode="reduced-motion"]){--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}}:host([data-animation-mode="off"]){--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}:host .tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}:host .tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}:host .tbw-fade-in{animation:tbw-fade-in var(--tbw-animation-duration) var(--tbw-animation-easing) forwards}:host .tbw-fade-out{animation:tbw-fade-out var(--tbw-animation-duration) var(--tbw-animation-easing) forwards}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}@keyframes tbw-fade-out{0%{opacity:1}to{opacity:0}}:host .tbw-flip-animating{will-change:transform;z-index:1}:host .tbw-toggle-icon{display:inline-flex;align-items:center;justify-content:center;transition:transform var(--tbw-animation-duration) var(--tbw-animation-easing)}:host .tbw-toggle-icon.tbw-expanded{transform:rotate(90deg)}';
2
+ function Fe(t) {
3
3
  const e = /* @__PURE__ */ new Map();
4
4
  return t._sortState && e.set(t._sortState.field, {
5
5
  direction: t._sortState.direction === 1 ? "asc" : "desc",
6
6
  priority: 0
7
7
  }), e;
8
8
  }
9
- function Te(t, e) {
10
- const o = t._columns, n = Ve(t);
9
+ function xe(t, e) {
10
+ const o = t._columns, n = Fe(t);
11
11
  return {
12
- columns: o.map((i, l) => {
13
- const r = {
12
+ columns: o.map((i, r) => {
13
+ const s = {
14
14
  field: i.field,
15
- order: l,
15
+ order: r,
16
16
  visible: !0
17
17
  // If it's in _columns, it's visible (hidden columns are filtered out)
18
- }, s = i;
19
- s.__renderedWidth !== void 0 ? r.width = s.__renderedWidth : i.width !== void 0 && (r.width = typeof i.width == "string" ? parseFloat(i.width) : i.width);
18
+ }, l = i;
19
+ l.__renderedWidth !== void 0 ? s.width = l.__renderedWidth : i.width !== void 0 && (s.width = typeof i.width == "string" ? parseFloat(i.width) : i.width);
20
20
  const a = n.get(i.field);
21
- a && (r.sort = a);
21
+ a && (s.sort = a);
22
22
  for (const c of e)
23
23
  if (c.getColumnState) {
24
- const h = c.getColumnState(i.field);
25
- h && Object.assign(r, h);
24
+ const f = c.getColumnState(i.field);
25
+ f && Object.assign(s, f);
26
26
  }
27
- return r;
27
+ return s;
28
28
  })
29
29
  };
30
30
  }
31
- function Fe(t, e, o, n) {
31
+ function Ge(t, e, o, n) {
32
32
  if (!e.columns || e.columns.length === 0) return;
33
- const i = new Map(e.columns.map((s) => [s.field, s])), l = o.map((s) => {
34
- const a = i.get(s.field);
35
- if (!a) return s;
36
- const c = { ...s };
33
+ const i = new Map(e.columns.map((l) => [l.field, l])), r = o.map((l) => {
34
+ const a = i.get(l.field);
35
+ if (!a) return l;
36
+ const c = { ...l };
37
37
  return a.width !== void 0 && (c.width = a.width, c.__renderedWidth = a.width), a.visible !== void 0 && (c.hidden = !a.visible), c;
38
38
  });
39
- l.sort((s, a) => {
40
- const c = i.get(s.field)?.order ?? 1 / 0, h = i.get(a.field)?.order ?? 1 / 0;
41
- return c - h;
42
- }), t._columns = l;
43
- const r = e.columns.filter((s) => s.sort !== void 0).sort((s, a) => (s.sort?.priority ?? 0) - (a.sort?.priority ?? 0));
44
- if (r.length > 0) {
45
- const s = r[0];
46
- s.sort && (t._sortState = {
47
- field: s.field,
48
- direction: s.sort.direction === "asc" ? 1 : -1
39
+ r.sort((l, a) => {
40
+ const c = i.get(l.field)?.order ?? 1 / 0, f = i.get(a.field)?.order ?? 1 / 0;
41
+ return c - f;
42
+ }), t._columns = r;
43
+ const s = e.columns.filter((l) => l.sort !== void 0).sort((l, a) => (l.sort?.priority ?? 0) - (a.sort?.priority ?? 0));
44
+ if (s.length > 0) {
45
+ const l = s[0];
46
+ l.sort && (t._sortState = {
47
+ field: l.field,
48
+ direction: l.sort.direction === "asc" ? 1 : -1
49
49
  });
50
50
  } else
51
51
  t._sortState = null;
52
- for (const s of n)
53
- if (s.applyColumnState)
52
+ for (const l of n)
53
+ if (l.applyColumnState)
54
54
  for (const a of e.columns)
55
- s.applyColumnState(a.field, a);
55
+ l.applyColumnState(a.field, a);
56
56
  }
57
- function Ge(t, e, o) {
57
+ function Ue(t, e, o) {
58
58
  let n = null;
59
59
  return () => {
60
60
  n !== null && clearTimeout(n), n = setTimeout(() => {
61
61
  n = null;
62
- const i = Te(t, e());
62
+ const i = xe(t, e());
63
63
  o(i);
64
64
  }, 100);
65
65
  };
66
66
  }
67
- function xe(t, e, o, n) {
68
- const i = t.effectiveConfig?.columns ?? [], l = i.find((s) => s.field === e);
69
- return !l || !o && l.lockVisible || !o && i.filter((a) => !a.hidden && a.field !== e).length === 0 || !!l.hidden === !o ? !1 : (l.hidden = !o, n.emit("column-visibility", {
67
+ function Ae(t, e, o, n) {
68
+ const i = t.effectiveConfig?.columns ?? [], r = i.find((l) => l.field === e);
69
+ return !r || !o && r.lockVisible || !o && i.filter((a) => !a.hidden && a.field !== e).length === 0 || !!r.hidden === !o ? !1 : (r.hidden = !o, n.emit("column-visibility", {
70
70
  field: e,
71
71
  visible: o,
72
- visibleColumns: i.filter((s) => !s.hidden).map((s) => s.field)
72
+ visibleColumns: i.filter((l) => !l.hidden).map((l) => l.field)
73
73
  }), n.clearRowPool(), n.setup(), n.requestStateChange(), !0);
74
74
  }
75
- function Ue(t, e, o) {
76
- const i = (t.effectiveConfig?.columns ?? []).find((l) => l.field === e);
77
- return i ? xe(t, e, !!i.hidden, o) : !1;
75
+ function Xe(t, e, o) {
76
+ const i = (t.effectiveConfig?.columns ?? []).find((r) => r.field === e);
77
+ return i ? Ae(t, e, !!i.hidden, o) : !1;
78
78
  }
79
- function Xe(t, e) {
79
+ function Ye(t, e) {
80
80
  const n = (t.effectiveConfig?.columns ?? []).find((i) => i.field === e);
81
81
  return n ? !n.hidden : !1;
82
82
  }
83
- function Ye(t, e) {
83
+ function je(t, e) {
84
84
  const o = t.effectiveConfig?.columns ?? [];
85
85
  o.some((n) => n.hidden) && (o.forEach((n) => n.hidden = !1), e.emit("column-visibility", {
86
86
  visibleColumns: o.map((n) => n.field)
87
87
  }), e.clearRowPool(), e.setup(), e.requestStateChange());
88
88
  }
89
- function je(t) {
89
+ function Ke(t) {
90
90
  return (t.effectiveConfig?.columns ?? []).map((o) => ({
91
91
  field: o.field,
92
92
  header: o.header || o.field,
@@ -94,24 +94,24 @@ function je(t) {
94
94
  lockVisible: o.lockVisible
95
95
  }));
96
96
  }
97
- function Ke(t) {
97
+ function Ze(t) {
98
98
  return t._columns.map((e) => e.field);
99
99
  }
100
- function Ze(t, e, o) {
100
+ function Je(t, e, o) {
101
101
  if (!e.length) return;
102
- const n = new Map(t._columns.map((l) => [l.field, l])), i = [];
103
- for (const l of e) {
104
- const r = n.get(l);
105
- r && (i.push(r), n.delete(l));
102
+ const n = new Map(t._columns.map((r) => [r.field, r])), i = [];
103
+ for (const r of e) {
104
+ const s = n.get(r);
105
+ s && (i.push(s), n.delete(r));
106
106
  }
107
- for (const l of n.values())
108
- i.push(l);
107
+ for (const r of n.values())
108
+ i.push(r);
109
109
  t._columns = i, o.renderHeader(), o.updateTemplate(), o.refreshVirtualWindow();
110
110
  }
111
- const X = {
111
+ const j = {
112
112
  STRETCH: "stretch",
113
113
  FIXED: "fixed"
114
- }, Je = {
114
+ }, Qe = {
115
115
  mode: "reduced-motion",
116
116
  duration: 200,
117
117
  easing: "ease-out"
@@ -125,25 +125,25 @@ const X = {
125
125
  dragHandle: "⋮⋮",
126
126
  toolPanel: "☰"
127
127
  };
128
- function Qe(t) {
128
+ function et(t) {
129
129
  return t == null ? "string" : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t instanceof Date || typeof t == "string" && /\d{4}-\d{2}-\d{2}/.test(t) && !isNaN(Date.parse(t)) ? "date" : "string";
130
130
  }
131
131
  function Le(t, e) {
132
132
  if (e && e.length) {
133
- const l = {};
134
- return e.forEach((r) => {
135
- r.type && (l[r.field] = r.type);
136
- }), { columns: e, typeMap: l };
137
- }
138
- const o = t[0] || {}, n = Object.keys(o).map((l) => {
139
- const r = o[l], s = Qe(r);
140
- return { field: l, header: l.charAt(0).toUpperCase() + l.slice(1), type: s };
133
+ const r = {};
134
+ return e.forEach((s) => {
135
+ s.type && (r[s.field] = s.type);
136
+ }), { columns: e, typeMap: r };
137
+ }
138
+ const o = t[0] || {}, n = Object.keys(o).map((r) => {
139
+ const s = o[r], l = et(s);
140
+ return { field: r, header: r.charAt(0).toUpperCase() + r.slice(1), type: l };
141
141
  }), i = {};
142
- return n.forEach((l) => {
143
- i[l.field] = l.type || "string";
142
+ return n.forEach((r) => {
143
+ i[r.field] = r.type || "string";
144
144
  }), { columns: n, typeMap: i };
145
145
  }
146
- const et = /{{\s*([^}]+)\s*}}/g, A = "__DG_EMPTY__", tt = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, ot = /__(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/, nt = /* @__PURE__ */ new Set([
146
+ const tt = /{{\s*([^}]+)\s*}}/g, L = "__DG_EMPTY__", ot = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, nt = /__(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/, it = /* @__PURE__ */ new Set([
147
147
  "script",
148
148
  "iframe",
149
149
  "object",
@@ -168,76 +168,76 @@ const et = /{{\s*([^}]+)\s*}}/g, A = "__DG_EMPTY__", tt = /^[\w$. '?+\-*/%:()!<>
168
168
  "plaintext",
169
169
  "xmp",
170
170
  "listing"
171
- ]), ue = /^on\w+$/i, it = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), lt = /^\s*(javascript|vbscript|data|blob):/i;
172
- function K(t) {
171
+ ]), ue = /^on\w+$/i, rt = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), st = /^\s*(javascript|vbscript|data|blob):/i;
172
+ function Q(t) {
173
173
  if (!t || typeof t != "string") return "";
174
174
  if (t.indexOf("<") === -1) return t;
175
175
  const e = document.createElement("template");
176
- return e.innerHTML = t, rt(e.content), e.innerHTML;
176
+ return e.innerHTML = t, lt(e.content), e.innerHTML;
177
177
  }
178
- function rt(t) {
178
+ function lt(t) {
179
179
  const e = [], o = t.querySelectorAll("*");
180
180
  for (const n of o) {
181
181
  const i = n.tagName.toLowerCase();
182
- if (nt.has(i)) {
182
+ if (it.has(i)) {
183
183
  e.push(n);
184
184
  continue;
185
185
  }
186
186
  if ((i === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
187
- (s) => ue.test(s.name) || s.name === "href" || s.name === "xlink:href"
187
+ (l) => ue.test(l.name) || l.name === "href" || l.name === "xlink:href"
188
188
  )) {
189
189
  e.push(n);
190
190
  continue;
191
191
  }
192
- const l = [];
193
- for (const r of n.attributes) {
194
- const s = r.name.toLowerCase();
195
- if (ue.test(s)) {
196
- l.push(r.name);
192
+ const r = [];
193
+ for (const s of n.attributes) {
194
+ const l = s.name.toLowerCase();
195
+ if (ue.test(l)) {
196
+ r.push(s.name);
197
197
  continue;
198
198
  }
199
- if (it.has(s) && lt.test(r.value)) {
200
- l.push(r.name);
199
+ if (rt.has(l) && st.test(s.value)) {
200
+ r.push(s.name);
201
201
  continue;
202
202
  }
203
- if (s === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(r.value)) {
204
- l.push(r.name);
203
+ if (l === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(s.value)) {
204
+ r.push(s.name);
205
205
  continue;
206
206
  }
207
207
  }
208
- l.forEach((r) => n.removeAttribute(r));
208
+ r.forEach((s) => n.removeAttribute(s));
209
209
  }
210
210
  e.forEach((n) => n.remove());
211
211
  }
212
212
  function Pe(t, e) {
213
213
  if (!t || t.indexOf("{{") === -1) return t;
214
- const o = [], n = t.replace(et, (s, a) => {
215
- const c = st(a, e);
214
+ const o = [], n = t.replace(tt, (l, a) => {
215
+ const c = at(a, e);
216
216
  return o.push({ expr: a.trim(), result: c }), c;
217
- }), i = at(n), l = o.length && o.every((s) => s.result === "" || s.result === A);
218
- return /Reflect\.|\bProxy\b|ownKeys\(/.test(t) || l ? "" : i;
217
+ }), i = ct(n), r = o.length && o.every((l) => l.result === "" || l.result === L);
218
+ return /Reflect\.|\bProxy\b|ownKeys\(/.test(t) || r ? "" : i;
219
219
  }
220
- function st(t, e) {
221
- if (t = (t || "").trim(), !t || /\b(Reflect|Proxy|ownKeys)\b/.test(t)) return A;
222
- if (t === "value") return e.value == null ? A : String(e.value);
220
+ function at(t, e) {
221
+ if (t = (t || "").trim(), !t || /\b(Reflect|Proxy|ownKeys)\b/.test(t)) return L;
222
+ if (t === "value") return e.value == null ? L : String(e.value);
223
223
  if (t.startsWith("row.") && !/[()?]/.test(t) && !t.includes(":")) {
224
224
  const n = t.slice(4), i = e.row ? e.row[n] : void 0;
225
- return i == null ? A : String(i);
225
+ return i == null ? L : String(i);
226
226
  }
227
- if (t.length > 80 || !tt.test(t) || ot.test(t)) return A;
227
+ if (t.length > 80 || !ot.test(t) || nt.test(t)) return L;
228
228
  const o = t.match(/\./g);
229
- if (o && o.length > 1) return A;
229
+ if (o && o.length > 1) return L;
230
230
  try {
231
- const i = new Function("value", "row", `return (${t});`)(e.value, e.row), l = i == null ? "" : String(i);
232
- return /Reflect|Proxy|ownKeys/.test(l) ? A : l || A;
231
+ const i = new Function("value", "row", `return (${t});`)(e.value, e.row), r = i == null ? "" : String(i);
232
+ return /Reflect|Proxy|ownKeys/.test(r) ? L : r || L;
233
233
  } catch {
234
- return A;
234
+ return L;
235
235
  }
236
236
  }
237
- function at(t) {
238
- return t && t.replace(new RegExp(A, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
239
- }
240
237
  function ct(t) {
238
+ return t && t.replace(new RegExp(L, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
239
+ }
240
+ function dt(t) {
241
241
  if (/Reflect|Proxy|ownKeys/.test(t.textContent || "")) {
242
242
  if (Array.from(t.childNodes).forEach((e) => {
243
243
  e.nodeType === Node.TEXT_NODE && /Reflect|Proxy|ownKeys/.test(e.textContent || "") && (e.textContent = "");
@@ -253,51 +253,64 @@ function he(t) {
253
253
  const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(t), o = (n) => e ? "" : Pe(t, n);
254
254
  return o.__blocked = e, o;
255
255
  }
256
- function dt(t) {
256
+ function ut(t) {
257
257
  return Array.from(t.querySelectorAll("tbw-grid-column")).map((o) => {
258
258
  const n = o.getAttribute("field") || "";
259
259
  if (!n) return null;
260
- const i = o.getAttribute("type") || void 0, r = i && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(i) ? i : void 0, s = o.getAttribute("header") || void 0, a = o.hasAttribute("sortable"), c = o.hasAttribute("editable"), h = { field: n, type: r, header: s, sortable: a, editable: c }, d = o.getAttribute("width");
260
+ const i = o.getAttribute("type") || void 0, s = i && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(i) ? i : void 0, l = o.getAttribute("header") || void 0, a = o.hasAttribute("sortable"), c = o.hasAttribute("editable"), f = { field: n, type: s, header: l, sortable: a, editable: c }, d = o.getAttribute("width");
261
261
  if (d) {
262
- const m = parseFloat(d);
263
- !isNaN(m) && /^\d+(\.\d+)?$/.test(d.trim()) ? h.width = m : h.width = d;
262
+ const C = parseFloat(d);
263
+ !isNaN(C) && /^\d+(\.\d+)?$/.test(d.trim()) ? f.width = C : f.width = d;
264
264
  }
265
265
  const u = o.getAttribute("minWidth") || o.getAttribute("min-width");
266
266
  if (u) {
267
- const m = parseFloat(u);
268
- isNaN(m) || (h.minWidth = m);
269
- }
270
- o.hasAttribute("resizable") && (h.resizable = !0), o.hasAttribute("sizable") && (h.resizable = !0);
271
- const p = o.getAttribute("editor"), f = o.getAttribute("renderer");
272
- p && (h.__editorName = p), f && (h.__rendererName = f);
273
- const b = o.getAttribute("options");
274
- b && (h.options = b.split(",").map((m) => {
275
- const [v, C] = m.includes(":") ? m.split(":") : [m.trim(), m.trim()];
276
- return { value: v.trim(), label: C?.trim() || v.trim() };
267
+ const C = parseFloat(u);
268
+ isNaN(C) || (f.minWidth = C);
269
+ }
270
+ o.hasAttribute("resizable") && (f.resizable = !0), o.hasAttribute("sizable") && (f.resizable = !0);
271
+ const w = o.getAttribute("editor"), h = o.getAttribute("renderer");
272
+ w && (f.__editorName = w), h && (f.__rendererName = h);
273
+ const p = o.getAttribute("options");
274
+ p && (f.options = p.split(",").map((C) => {
275
+ const [A, R] = C.includes(":") ? C.split(":") : [C.trim(), C.trim()];
276
+ return { value: A.trim(), label: R?.trim() || A.trim() };
277
277
  }));
278
- const g = o.querySelector("tbw-grid-column-view"), w = o.querySelector("tbw-grid-column-editor"), _ = o.querySelector("tbw-grid-column-header");
279
- if (g && (h.__viewTemplate = g), w && (h.__editorTemplate = w), _ && (h.__headerTemplate = _), g) {
280
- const v = (globalThis.DataGridElement?.getAdapters?.() ?? []).find((C) => C.canHandle(g));
281
- v && (h.viewRenderer = v.createRenderer(g));
282
- }
283
- if (w) {
284
- const v = (globalThis.DataGridElement?.getAdapters?.() ?? []).find((C) => C.canHandle(w));
285
- v && (h.editor = v.createEditor(w));
286
- }
287
- return h;
278
+ const g = o.querySelector("tbw-grid-column-view"), b = o.querySelector("tbw-grid-column-editor"), _ = o.querySelector("tbw-grid-column-header");
279
+ g && (f.__viewTemplate = g), b && (f.__editorTemplate = b), _ && (f.__headerTemplate = _);
280
+ const m = globalThis.DataGridElement?.getAdapters?.() ?? [], E = g ?? o, x = m.find((C) => C.canHandle(E));
281
+ if (x) {
282
+ const C = x.createRenderer(E);
283
+ C && (f.viewRenderer = C);
284
+ }
285
+ const K = b ?? o, S = m.find((C) => C.canHandle(K));
286
+ if (S) {
287
+ const C = S.createEditor(K);
288
+ C && (f.editor = C);
289
+ }
290
+ return f;
288
291
  }).filter((o) => !!o);
289
292
  }
290
- function ut(t, e) {
293
+ function ht(t, e) {
291
294
  if ((!t || !t.length) && (!e || !e.length)) return [];
292
295
  if (!t || !t.length) return e || [];
293
296
  if (!e || !e.length) return t;
294
297
  const o = {};
295
- e.forEach((i) => o[i.field] = i);
298
+ e.forEach((i) => {
299
+ const r = o[i.field];
300
+ if (r) {
301
+ i.header && !r.header && (r.header = i.header), i.type && !r.type && (r.type = i.type), i.sortable && (r.sortable = !0), i.editable && (r.editable = !0), i.resizable && (r.resizable = !0), i.width != null && r.width == null && (r.width = i.width), i.minWidth != null && r.minWidth == null && (r.minWidth = i.minWidth), i.__viewTemplate && (r.__viewTemplate = i.__viewTemplate), i.__editorTemplate && (r.__editorTemplate = i.__editorTemplate), i.__headerTemplate && (r.__headerTemplate = i.__headerTemplate);
302
+ const s = i.renderer || i.viewRenderer, l = r.renderer || r.viewRenderer;
303
+ s && !l && (r.viewRenderer = s, i.renderer && (r.renderer = s)), i.editor && !r.editor && (r.editor = i.editor);
304
+ } else
305
+ o[i.field] = { ...i };
306
+ });
296
307
  const n = t.map((i) => {
297
- const l = o[i.field];
298
- if (!l) return i;
299
- const r = { ...i };
300
- return l.header && !r.header && (r.header = l.header), l.type && !r.type && (r.type = l.type), r.sortable = i.sortable || l.sortable, (i.resizable === !0 || l.resizable === !0) && (r.resizable = !0), r.editable = i.editable || l.editable, l.width != null && r.width == null && (r.width = l.width), l.minWidth != null && r.minWidth == null && (r.minWidth = l.minWidth), l.__viewTemplate && (r.__viewTemplate = l.__viewTemplate), l.__editorTemplate && (r.__editorTemplate = l.__editorTemplate), l.__headerTemplate && (r.__headerTemplate = l.__headerTemplate), l.viewRenderer && !r.viewRenderer && (r.viewRenderer = l.viewRenderer), l.editor && !r.editor && (r.editor = l.editor), delete o[i.field], r;
308
+ const r = o[i.field];
309
+ if (!r) return i;
310
+ const s = { ...i };
311
+ r.header && !s.header && (s.header = r.header), r.type && !s.type && (s.type = r.type), s.sortable = i.sortable || r.sortable, (i.resizable === !0 || r.resizable === !0) && (s.resizable = !0), s.editable = i.editable || r.editable, r.width != null && s.width == null && (s.width = r.width), r.minWidth != null && s.minWidth == null && (s.minWidth = r.minWidth), r.__viewTemplate && (s.__viewTemplate = r.__viewTemplate), r.__editorTemplate && (s.__editorTemplate = r.__editorTemplate), r.__headerTemplate && (s.__headerTemplate = r.__headerTemplate);
312
+ const l = r.renderer || r.viewRenderer, a = s.renderer || s.viewRenderer;
313
+ return l && !a && (s.viewRenderer = l, r.renderer && (s.renderer = l)), r.editor && !s.editor && (s.editor = r.editor), delete o[i.field], s;
301
314
  });
302
315
  return Object.keys(o).forEach((i) => n.push(o[i])), n;
303
316
  }
@@ -312,42 +325,42 @@ function fe(t, e) {
312
325
  function pe(t) {
313
326
  t.__lightDomColumnsCache || (t.__originalColumnNodes = Array.from(
314
327
  t.querySelectorAll("tbw-grid-column")
315
- ), t.__lightDomColumnsCache = t.__originalColumnNodes.length ? dt(t) : []);
316
- const e = t.__lightDomColumnsCache, o = ut(t._columns, e);
328
+ ), t.__lightDomColumnsCache = t.__originalColumnNodes.length ? ut(t) : []);
329
+ const e = t.__lightDomColumnsCache, o = ht(t._columns, e);
317
330
  o.forEach((i) => {
318
331
  i.__viewTemplate && !i.__compiledView && (i.__compiledView = he(i.__viewTemplate.innerHTML)), i.__editorTemplate && !i.__compiledEditor && (i.__compiledEditor = he(i.__editorTemplate.innerHTML));
319
332
  });
320
333
  const { columns: n } = Le(t._rows, o);
321
334
  t._columns = n;
322
335
  }
323
- function be(t) {
324
- const e = t.effectiveConfig?.fitMode || t.fitMode || X.STRETCH;
325
- if (e !== X.STRETCH && e !== X.FIXED || t.__didInitialAutoSize || !t.isConnected) return;
336
+ function we(t) {
337
+ const e = t.effectiveConfig?.fitMode || t.fitMode || j.STRETCH;
338
+ if (e !== j.STRETCH && e !== j.FIXED || t.__didInitialAutoSize || !t.isConnected) return;
326
339
  const o = t._headerRowEl?.children || [];
327
340
  if (!o.length) return;
328
341
  let n = !1;
329
- t._visibleColumns.forEach((i, l) => {
342
+ t._visibleColumns.forEach((i, r) => {
330
343
  if (i.width) return;
331
- const r = o[l];
332
- let s = r ? r.scrollWidth : 0;
344
+ const s = o[r];
345
+ let l = s ? s.scrollWidth : 0;
333
346
  for (const a of t._rowPool) {
334
- const c = a.children[l];
347
+ const c = a.children[r];
335
348
  if (c) {
336
- const h = c.scrollWidth;
337
- h > s && (s = h);
349
+ const f = c.scrollWidth;
350
+ f > l && (l = f);
338
351
  }
339
352
  }
340
- s > 0 && (i.width = s + 2, i.__autoSized = !0, n = !0);
353
+ l > 0 && (i.width = l + 2, i.__autoSized = !0, n = !0);
341
354
  }), n && z(t), t.__didInitialAutoSize = !0;
342
355
  }
343
356
  function z(t) {
344
- (t.effectiveConfig?.fitMode || t.fitMode || X.STRETCH) === X.STRETCH ? t._gridTemplate = t._visibleColumns.map((o) => {
357
+ (t.effectiveConfig?.fitMode || t.fitMode || j.STRETCH) === j.STRETCH ? t._gridTemplate = t._visibleColumns.map((o) => {
345
358
  if (o.width) return `${o.width}px`;
346
359
  const n = o.minWidth;
347
360
  return n != null ? `minmax(${n}px, 1fr)` : "1fr";
348
361
  }).join(" ").trim() : t._gridTemplate = t._visibleColumns.map((o) => o.width ? `${o.width}px` : "max-content").join(" "), t.style.setProperty("--tbw-column-template", t._gridTemplate);
349
362
  }
350
- function ht(t) {
363
+ function ft(t) {
351
364
  switch (t.type) {
352
365
  case "number":
353
366
  return (e) => {
@@ -372,21 +385,21 @@ function ht(t) {
372
385
  case "typeahead":
373
386
  return (e) => {
374
387
  const o = document.createElement("select");
375
- e.column.multi && (o.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((l) => {
376
- const r = document.createElement("option");
377
- r.value = String(l.value), r.textContent = l.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(l.value) || !e.column.multi && e.value === l.value) && (r.selected = !0), o.appendChild(r);
388
+ e.column.multi && (o.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((r) => {
389
+ const s = document.createElement("option");
390
+ s.value = String(r.value), s.textContent = r.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(r.value) || !e.column.multi && e.value === r.value) && (s.selected = !0), o.appendChild(s);
378
391
  });
379
392
  const i = () => {
380
393
  if (e.column.multi) {
381
- const l = [];
382
- Array.from(o.selectedOptions).forEach((r) => {
383
- l.push(r.value);
384
- }), e.commit(l);
394
+ const r = [];
395
+ Array.from(o.selectedOptions).forEach((s) => {
396
+ r.push(s.value);
397
+ }), e.commit(r);
385
398
  } else
386
399
  e.commit(o.value);
387
400
  };
388
- return o.addEventListener("change", i), o.addEventListener("blur", i), o.addEventListener("keydown", (l) => {
389
- l.key === "Escape" && e.cancel();
401
+ return o.addEventListener("change", i), o.addEventListener("blur", i), o.addEventListener("keydown", (r) => {
402
+ r.key === "Escape" && e.cancel();
390
403
  }), o;
391
404
  };
392
405
  default:
@@ -416,23 +429,23 @@ function Me(t) {
416
429
  const e = t.getAttribute("data-row");
417
430
  return e ? parseInt(e, 10) : -1;
418
431
  }
419
- function U(t) {
432
+ function X(t) {
420
433
  if (!t) return -1;
421
434
  const e = t.getAttribute("data-col");
422
435
  return e ? parseInt(e, 10) : -1;
423
436
  }
424
- function le(t) {
437
+ function se(t) {
425
438
  t && t.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
426
439
  }
427
- function ft(t, e) {
440
+ function pt(t, e) {
428
441
  if (t._dispatchKeyDown?.(e))
429
442
  return;
430
- const o = t._rows.length - 1, n = t._visibleColumns.length - 1, i = t._activeEditRows !== void 0 && t._activeEditRows !== -1, r = t._visibleColumns[t._focusCol]?.type, s = e.composedPath ? e.composedPath() : [], a = s && s.length ? s[0] : e.target, c = (h) => {
431
- if (!h) return !1;
432
- const d = h.tagName;
433
- return !!(d === "INPUT" || d === "SELECT" || d === "TEXTAREA" || h.isContentEditable);
443
+ const o = t._rows.length - 1, n = t._visibleColumns.length - 1, i = t._activeEditRows !== void 0 && t._activeEditRows !== -1, s = t._visibleColumns[t._focusCol]?.type, l = e.composedPath ? e.composedPath() : [], a = l && l.length ? l[0] : e.target, c = (f) => {
444
+ if (!f) return !1;
445
+ const d = f.tagName;
446
+ return !!(d === "INPUT" || d === "SELECT" || d === "TEXTAREA" || f.isContentEditable);
434
447
  };
435
- if (!(c(a) && (e.key === "Home" || e.key === "End")) && !(c(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(c(a) && (e.key === "ArrowLeft" || e.key === "ArrowRight")) && !(c(a) && (e.key === "Enter" || e.key === "Escape")) && !(i && (r === "select" || r === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
448
+ if (!(c(a) && (e.key === "Home" || e.key === "End")) && !(c(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(c(a) && (e.key === "ArrowLeft" || e.key === "ArrowRight")) && !(c(a) && (e.key === "Enter" || e.key === "Escape")) && !(i && (s === "select" || s === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
436
449
  switch (e.key) {
437
450
  case "Tab": {
438
451
  e.preventDefault(), !e.shiftKey ? t._focusCol < n ? t._focusCol += 1 : (typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t._focusRow < o && (t._focusRow += 1, t._focusCol = 0)) : t._focusCol > 0 ? t._focusCol -= 1 : t._focusRow > 0 && (typeof t.commitActiveRowEdit == "function" && t._activeEditRows === t._focusRow && t.commitActiveRowEdit(), t._focusRow -= 1, t._focusCol = n), k(t);
@@ -479,45 +492,45 @@ function ft(t, e) {
479
492
  }
480
493
  function k(t, e) {
481
494
  if (t._virtualization?.enabled) {
482
- const { rowHeight: r, container: s, viewportEl: a } = t._virtualization, c = s, h = a?.clientHeight ?? c?.clientHeight ?? 0;
483
- if (c && h > 0) {
484
- const d = t._focusRow * r;
485
- d < c.scrollTop ? c.scrollTop = d : d + r > c.scrollTop + h && (c.scrollTop = d - h + r);
495
+ const { rowHeight: s, container: l, viewportEl: a } = t._virtualization, c = l, f = a?.clientHeight ?? c?.clientHeight ?? 0;
496
+ if (c && f > 0) {
497
+ const d = t._focusRow * s;
498
+ d < c.scrollTop ? c.scrollTop = d : d + s > c.scrollTop + f && (c.scrollTop = d - f + s);
486
499
  }
487
500
  }
488
501
  const o = t._activeEditRows !== void 0 && t._activeEditRows !== -1;
489
- o || t.refreshVirtualWindow(!1), le(t._bodyEl), Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((r) => {
490
- r.setAttribute("aria-selected", "false");
502
+ o || t.refreshVirtualWindow(!1), se(t._bodyEl), Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((s) => {
503
+ s.setAttribute("aria-selected", "false");
491
504
  });
492
- const n = t._focusRow, i = t._virtualization.start ?? 0, l = t._virtualization.end ?? t._rows.length;
493
- if (n >= i && n < l) {
494
- const r = t._bodyEl.querySelectorAll(".data-grid-row")[n - i], s = r?.children[t._focusCol];
495
- if (s) {
496
- s.classList.add("cell-focus"), s.setAttribute("aria-selected", "true");
505
+ const n = t._focusRow, i = t._virtualization.start ?? 0, r = t._virtualization.end ?? t._rows.length;
506
+ if (n >= i && n < r) {
507
+ const s = t._bodyEl.querySelectorAll(".data-grid-row")[n - i], l = s?.children[t._focusCol];
508
+ if (l) {
509
+ l.classList.add("cell-focus"), l.setAttribute("aria-selected", "true");
497
510
  const a = t.shadowRoot?.querySelector(".tbw-scroll-area");
498
- if (a && s && !o)
511
+ if (a && l && !o)
499
512
  if (e?.forceScrollLeft)
500
513
  a.scrollLeft = 0;
501
514
  else if (e?.forceScrollRight)
502
515
  a.scrollLeft = a.scrollWidth - a.clientWidth;
503
516
  else {
504
- const c = t._getHorizontalScrollOffsets?.(r ?? void 0, s) ?? { left: 0, right: 0 };
517
+ const c = t._getHorizontalScrollOffsets?.(s ?? void 0, l) ?? { left: 0, right: 0 };
505
518
  if (!c.skipScroll) {
506
- const h = s.getBoundingClientRect(), d = a.getBoundingClientRect(), u = h.left - d.left + a.scrollLeft, p = u + h.width, f = a.scrollLeft + c.left, b = a.scrollLeft + a.clientWidth - c.right;
507
- u < f ? a.scrollLeft = u - c.left : p > b && (a.scrollLeft = p - a.clientWidth + c.right);
519
+ const f = l.getBoundingClientRect(), d = a.getBoundingClientRect(), u = f.left - d.left + a.scrollLeft, w = u + f.width, h = a.scrollLeft + c.left, p = a.scrollLeft + a.clientWidth - c.right;
520
+ u < h ? a.scrollLeft = u - c.left : w > p && (a.scrollLeft = w - a.clientWidth + c.right);
508
521
  }
509
522
  }
510
- if (t._activeEditRows !== void 0 && t._activeEditRows !== -1 && s.classList.contains("editing")) {
511
- const c = s.querySelector(B);
523
+ if (t._activeEditRows !== void 0 && t._activeEditRows !== -1 && l.classList.contains("editing")) {
524
+ const c = l.querySelector(B);
512
525
  if (c && document.activeElement !== c)
513
526
  try {
514
527
  c.focus({ preventScroll: !0 });
515
528
  } catch {
516
529
  }
517
- } else if (!s.contains(document.activeElement)) {
518
- s.hasAttribute("tabindex") || s.setAttribute("tabindex", "-1");
530
+ } else if (!l.contains(document.activeElement)) {
531
+ l.hasAttribute("tabindex") || l.setAttribute("tabindex", "-1");
519
532
  try {
520
- s.focus({ preventScroll: !0 });
533
+ l.focus({ preventScroll: !0 });
521
534
  } catch {
522
535
  }
523
536
  }
@@ -528,94 +541,94 @@ const Oe = document.createElement("template");
528
541
  Oe.innerHTML = '<div class="cell" role="gridcell" part="cell"></div>';
529
542
  const ke = document.createElement("template");
530
543
  ke.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
531
- function pt() {
544
+ function wt() {
532
545
  return Oe.content.firstElementChild.cloneNode(!0);
533
546
  }
534
547
  function bt() {
535
548
  return ke.content.firstElementChild.cloneNode(!0);
536
549
  }
537
- const wt = "__cellDisplayCache", gt = "__cellCacheEpoch";
538
- function Z(t) {
539
- t[wt] = void 0, t[gt] = void 0, t.__hasSpecialColumns = void 0;
550
+ const gt = "__cellDisplayCache", mt = "__cellCacheEpoch";
551
+ function Y(t) {
552
+ t[gt] = void 0, t[mt] = void 0, t.__hasSpecialColumns = void 0;
540
553
  }
541
- function mt(t, e, o, n, i) {
542
- const l = Math.max(0, o - e), r = t._bodyEl, s = t._visibleColumns, a = s.length;
554
+ function vt(t, e, o, n, i) {
555
+ const r = Math.max(0, o - e), s = t._bodyEl, l = t._visibleColumns, a = l.length;
543
556
  let c = t.__cachedHeaderRowCount;
544
- for (c === void 0 && (c = t.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, t.__cachedHeaderRowCount = c); t._rowPool.length < l; ) {
557
+ for (c === void 0 && (c = t.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, t.__cachedHeaderRowCount = c); t._rowPool.length < r; ) {
545
558
  const d = bt();
546
- d.addEventListener("click", (u) => we(t, u, d, !1)), d.addEventListener("dblclick", (u) => we(t, u, d, !0)), t._rowPool.push(d);
559
+ d.addEventListener("click", (u) => be(t, u, d, !1)), d.addEventListener("dblclick", (u) => be(t, u, d, !0)), t._rowPool.push(d);
547
560
  }
548
- if (t._rowPool.length > l) {
549
- for (let d = l; d < t._rowPool.length; d++) {
561
+ if (t._rowPool.length > r) {
562
+ for (let d = r; d < t._rowPool.length; d++) {
550
563
  const u = t._rowPool[d];
551
- u.parentNode === r && u.remove();
564
+ u.parentNode === s && u.remove();
552
565
  }
553
- t._rowPool.length = l;
566
+ t._rowPool.length = r;
554
567
  }
555
- const h = i && t.__hasRenderRowPlugins !== !1;
556
- for (let d = 0; d < l; d++) {
557
- const u = e + d, p = t._rows[u], f = t._rowPool[d];
558
- if (f.setAttribute("aria-rowindex", String(u + c + 1)), h && i(p, f, u)) {
559
- f.__epoch = n, f.__rowDataRef = p, f.parentNode !== r && r.appendChild(f);
568
+ const f = i && t.__hasRenderRowPlugins !== !1;
569
+ for (let d = 0; d < r; d++) {
570
+ const u = e + d, w = t._rows[u], h = t._rowPool[d];
571
+ if (h.setAttribute("aria-rowindex", String(u + c + 1)), f && i(w, h, u)) {
572
+ h.__epoch = n, h.__rowDataRef = w, h.parentNode !== s && s.appendChild(h);
560
573
  continue;
561
574
  }
562
- const b = f.__epoch, g = f.__rowDataRef, w = f.children.length, m = b === n && w === a, v = g !== p;
563
- let C = !1;
564
- if (m && v) {
565
- for (let R = 0; R < a; R++)
566
- if (s[R].externalView && !f.querySelector(`.cell[data-col="${R}"] [data-external-view]`)) {
567
- C = !0;
575
+ const p = h.__epoch, g = h.__rowDataRef, b = h.children.length, v = p === n && b === a, m = g !== w;
576
+ let E = !1;
577
+ if (v && m) {
578
+ for (let S = 0; S < a; S++)
579
+ if (l[S].externalView && !h.querySelector(`.cell[data-col="${S}"] [data-external-view]`)) {
580
+ E = !0;
568
581
  break;
569
582
  }
570
583
  }
571
- if (!m || C) {
572
- const R = J(f), x = t._activeEditRows === u;
573
- if (R && !x)
574
- f.__isCustomRow && (f.className = "data-grid-row", f.setAttribute("role", "row"), f.__isCustomRow = !1), Q(f), I(t, f, p, u), f.__epoch = n, f.__rowDataRef = p;
575
- else if (R && x)
576
- oe(t, f, p, u), f.__rowDataRef = p;
577
- else if (f.__isCustomRow && (f.className = "data-grid-row", f.setAttribute("role", "row"), f.__isCustomRow = !1), I(t, f, p, u), f.__epoch = n, f.__rowDataRef = p, x) {
578
- const H = f.children;
579
- for (let S = 0; S < H.length; S++) {
580
- const T = t._visibleColumns[S];
581
- T && T.editable && L(t, p, u, T, H[S], !0);
584
+ if (!v || E) {
585
+ const S = ee(h), C = t._activeEditRows === u;
586
+ if (S && !C)
587
+ h.__isCustomRow && (h.className = "data-grid-row", h.setAttribute("role", "row"), h.__isCustomRow = !1), te(h), $(t, h, w, u), h.__epoch = n, h.__rowDataRef = w;
588
+ else if (S && C)
589
+ ne(t, h, w, u), h.__rowDataRef = w;
590
+ else if (h.__isCustomRow && (h.className = "data-grid-row", h.setAttribute("role", "row"), h.__isCustomRow = !1), $(t, h, w, u), h.__epoch = n, h.__rowDataRef = w, C) {
591
+ const A = h.children;
592
+ for (let R = 0; R < A.length; R++) {
593
+ const P = t._visibleColumns[R];
594
+ P && P.editable && H(t, w, u, P, A[R], !0);
582
595
  }
583
596
  }
584
- } else if (v) {
585
- const R = J(f), x = t._activeEditRows === u;
586
- if (R && !x)
587
- Q(f), I(t, f, p, u), f.__epoch = n, f.__rowDataRef = p;
588
- else if (oe(t, f, p, u), f.__rowDataRef = p, x && !R) {
589
- const H = f.children;
590
- for (let S = 0; S < H.length; S++) {
591
- const T = t._visibleColumns[S];
592
- T && T.editable && L(t, p, u, T, H[S], !0);
597
+ } else if (m) {
598
+ const S = ee(h), C = t._activeEditRows === u;
599
+ if (S && !C)
600
+ te(h), $(t, h, w, u), h.__epoch = n, h.__rowDataRef = w;
601
+ else if (ne(t, h, w, u), h.__rowDataRef = w, C && !S) {
602
+ const A = h.children;
603
+ for (let R = 0; R < A.length; R++) {
604
+ const P = t._visibleColumns[R];
605
+ P && P.editable && H(t, w, u, P, A[R], !0);
593
606
  }
594
607
  }
595
608
  } else {
596
- const R = J(f), x = t._activeEditRows === u;
597
- if (R && !x)
598
- Q(f), I(t, f, p, u), f.__epoch = n, f.__rowDataRef = p;
599
- else if (oe(t, f, p, u), x && !R) {
600
- const H = f.children;
601
- for (let S = 0; S < H.length; S++) {
602
- const T = t._visibleColumns[S];
603
- T && T.editable && L(t, p, u, T, H[S], !0);
609
+ const S = ee(h), C = t._activeEditRows === u;
610
+ if (S && !C)
611
+ te(h), $(t, h, w, u), h.__epoch = n, h.__rowDataRef = w;
612
+ else if (ne(t, h, w, u), C && !S) {
613
+ const A = h.children;
614
+ for (let R = 0; R < A.length; R++) {
615
+ const P = t._visibleColumns[R];
616
+ P && P.editable && H(t, w, u, P, A[R], !0);
604
617
  }
605
618
  }
606
619
  }
607
- const $ = t._changedRowIndices.has(u), $e = f.classList.contains("changed");
608
- $ !== $e && f.classList.toggle("changed", $), f.parentNode !== r && r.appendChild(f);
620
+ const x = t._changedRowIndices.has(u), K = h.classList.contains("changed");
621
+ x !== K && h.classList.toggle("changed", x), h.parentNode !== s && s.appendChild(h);
609
622
  }
610
623
  }
611
- function oe(t, e, o, n) {
612
- const i = e.children, l = t._visibleColumns, r = l.length, s = i.length, a = r < s ? r : s, c = t._focusRow, h = t._focusCol;
624
+ function ne(t, e, o, n) {
625
+ const i = e.children, r = t._visibleColumns, s = r.length, l = i.length, a = s < l ? s : l, c = t._focusRow, f = t._focusCol;
613
626
  let d = t.__hasSpecialColumns;
614
627
  if (d === void 0) {
615
628
  d = !1;
616
- for (let p = 0; p < r; p++) {
617
- const f = l[p];
618
- if (f.__viewTemplate || f.__compiledView || f.viewRenderer || f.externalView || f.format || f.type === "date" || f.type === "boolean") {
629
+ for (let w = 0; w < s; w++) {
630
+ const h = r[w];
631
+ if (h.__viewTemplate || h.__compiledView || h.renderer || h.viewRenderer || h.externalView || h.format || h.type === "date" || h.type === "boolean") {
619
632
  d = !0;
620
633
  break;
621
634
  }
@@ -624,70 +637,71 @@ function oe(t, e, o, n) {
624
637
  }
625
638
  const u = String(n);
626
639
  if (!d) {
627
- for (let p = 0; p < a; p++) {
628
- const f = i[p], b = o[l[p].field];
629
- f.textContent = b == null ? "" : String(b), f.getAttribute("data-row") !== u && f.setAttribute("data-row", u);
630
- const g = c === n && h === p, w = f.classList.contains("cell-focus");
631
- g !== w && (f.classList.toggle("cell-focus", g), f.setAttribute("aria-selected", String(g)));
640
+ for (let w = 0; w < a; w++) {
641
+ const h = i[w], p = o[r[w].field];
642
+ h.textContent = p == null ? "" : String(p), h.getAttribute("data-row") !== u && h.setAttribute("data-row", u);
643
+ const g = c === n && f === w, b = h.classList.contains("cell-focus");
644
+ g !== b && (h.classList.toggle("cell-focus", g), h.setAttribute("aria-selected", String(g)));
632
645
  }
633
646
  return;
634
647
  }
635
- for (let p = 0; p < a; p++)
636
- if (l[p].externalView && !i[p].querySelector("[data-external-view]")) {
637
- I(t, e, o, n);
648
+ for (let w = 0; w < a; w++)
649
+ if (r[w].externalView && !i[w].querySelector("[data-external-view]")) {
650
+ $(t, e, o, n);
638
651
  return;
639
652
  }
640
- for (let p = 0; p < a; p++) {
641
- const f = l[p], b = i[p];
642
- b.getAttribute("data-row") !== u && b.setAttribute("data-row", u);
643
- const g = c === n && h === p, w = b.classList.contains("cell-focus");
644
- if (g !== w && (b.classList.toggle("cell-focus", g), b.setAttribute("aria-selected", String(g))), b.classList.contains("editing")) continue;
645
- if (f.viewRenderer) {
646
- const v = o[f.field], C = f.viewRenderer({ row: o, value: v, field: f.field, column: f });
647
- typeof C == "string" ? b.innerHTML = K(C) : C ? (b.innerHTML = "", b.appendChild(C)) : b.textContent = v == null ? "" : String(v);
653
+ for (let w = 0; w < a; w++) {
654
+ const h = r[w], p = i[w];
655
+ p.getAttribute("data-row") !== u && p.setAttribute("data-row", u);
656
+ const g = c === n && f === w, b = p.classList.contains("cell-focus");
657
+ if (g !== b && (p.classList.toggle("cell-focus", g), p.setAttribute("aria-selected", String(g))), p.classList.contains("editing")) continue;
658
+ const _ = h.renderer || h.viewRenderer;
659
+ if (_) {
660
+ const E = o[h.field], x = _({ row: o, value: E, field: h.field, column: h, cellEl: p });
661
+ typeof x == "string" ? p.innerHTML = Q(x) : x ? x.parentElement !== p && (p.innerHTML = "", p.appendChild(x)) : p.textContent = E == null ? "" : String(E);
648
662
  continue;
649
663
  }
650
- if (f.__viewTemplate || f.__compiledView || f.externalView)
664
+ if (h.__viewTemplate || h.__compiledView || h.externalView)
651
665
  continue;
652
- const _ = o[f.field];
666
+ const v = o[h.field];
653
667
  let m;
654
- if (f.format)
668
+ if (h.format)
655
669
  try {
656
- const v = f.format(_, o);
657
- m = v == null ? "" : String(v);
670
+ const E = h.format(v, o);
671
+ m = E == null ? "" : String(E);
658
672
  } catch {
659
- m = _ == null ? "" : String(_);
673
+ m = v == null ? "" : String(v);
660
674
  }
661
- else f.type === "date" ? (m = He(_), b.textContent = m) : f.type === "boolean" ? b.innerHTML = ae(!!_) : (m = _ == null ? "" : String(_), b.textContent = m);
675
+ else h.type === "date" ? (m = He(v), p.textContent = m) : h.type === "boolean" ? p.innerHTML = ae(!!v) : (m = v == null ? "" : String(v), p.textContent = m);
662
676
  }
663
677
  }
664
- function I(t, e, o, n) {
678
+ function $(t, e, o, n) {
665
679
  e.innerHTML = "";
666
- const i = t._visibleColumns, l = i.length, r = t._focusRow, s = t._focusCol;
680
+ const i = t._visibleColumns, r = i.length, s = t._focusRow, l = t._focusCol;
667
681
  t.effectiveConfig?.editOn || t.editOn;
668
682
  const a = t, c = document.createDocumentFragment();
669
- for (let h = 0; h < l; h++) {
670
- const d = i[h], u = pt();
671
- u.setAttribute("aria-colindex", String(h + 1)), u.setAttribute("data-col", String(h)), u.setAttribute("data-row", String(n)), u.setAttribute("data-field", d.field), d.type, d.type && u.setAttribute("data-type", d.type);
672
- let p = o[d.field];
673
- const f = d.format;
674
- if (f)
683
+ for (let f = 0; f < r; f++) {
684
+ const d = i[f], u = wt();
685
+ u.setAttribute("aria-colindex", String(f + 1)), u.setAttribute("data-col", String(f)), u.setAttribute("data-row", String(n)), u.setAttribute("data-field", d.field), d.type, d.type && u.setAttribute("data-type", d.type);
686
+ let w = o[d.field];
687
+ const h = d.format;
688
+ if (h)
675
689
  try {
676
- p = f(p, o);
690
+ w = h(w, o);
677
691
  } catch {
678
692
  }
679
- const b = d.__compiledView, g = d.__viewTemplate, w = d.viewRenderer, _ = d.externalView;
680
- let m = !1;
681
- if (w) {
682
- const v = w({ row: o, value: p, field: d.field, column: d });
683
- typeof v == "string" ? (u.innerHTML = K(v), m = !0) : v ? u.appendChild(v) : u.textContent = p == null ? "" : String(p);
693
+ const p = d.__compiledView, g = d.__viewTemplate, b = d.renderer || d.viewRenderer, _ = d.externalView;
694
+ let v = !1;
695
+ if (b) {
696
+ const m = b({ row: o, value: w, field: d.field, column: d, cellEl: u });
697
+ typeof m == "string" ? (u.innerHTML = Q(m), v = !0) : m ? m.parentElement !== u && (u.textContent = "", u.appendChild(m)) : u.textContent = w == null ? "" : String(w);
684
698
  } else if (_) {
685
- const v = _, C = document.createElement("div");
686
- C.setAttribute("data-external-view", ""), C.setAttribute("data-field", d.field), u.appendChild(C);
687
- const $ = { row: o, value: p, field: d.field, column: d };
688
- if (v.mount)
699
+ const m = _, E = document.createElement("div");
700
+ E.setAttribute("data-external-view", ""), E.setAttribute("data-field", d.field), u.appendChild(E);
701
+ const x = { row: o, value: w, field: d.field, column: d };
702
+ if (m.mount)
689
703
  try {
690
- v.mount({ placeholder: C, context: $, spec: v });
704
+ m.mount({ placeholder: E, context: x, spec: m });
691
705
  } catch {
692
706
  }
693
707
  else
@@ -697,85 +711,85 @@ function I(t, e, o, n) {
697
711
  new CustomEvent("mount-external-view", {
698
712
  bubbles: !0,
699
713
  composed: !0,
700
- detail: { placeholder: C, spec: v, context: $ }
714
+ detail: { placeholder: E, spec: m, context: x }
701
715
  })
702
716
  );
703
717
  } catch {
704
718
  }
705
719
  });
706
- C.setAttribute("data-mounted", "");
707
- } else if (b) {
708
- const v = b({ row: o, value: p, field: d.field, column: d }), C = b.__blocked;
709
- u.innerHTML = C ? "" : K(v), m = !0, C && (u.textContent = "", u.setAttribute("data-blocked-template", ""));
720
+ E.setAttribute("data-mounted", "");
721
+ } else if (p) {
722
+ const m = p({ row: o, value: w, field: d.field, column: d }), E = p.__blocked;
723
+ u.innerHTML = E ? "" : Q(m), v = !0, E && (u.textContent = "", u.setAttribute("data-blocked-template", ""));
710
724
  } else if (g) {
711
- const v = g.innerHTML;
712
- /Reflect\.|\bProxy\b|ownKeys\(/.test(v) ? (u.textContent = "", u.setAttribute("data-blocked-template", "")) : (u.innerHTML = K(Pe(v, { row: o, value: p })), m = !0);
725
+ const m = g.innerHTML;
726
+ /Reflect\.|\bProxy\b|ownKeys\(/.test(m) ? (u.textContent = "", u.setAttribute("data-blocked-template", "")) : (u.innerHTML = Q(Pe(m, { row: o, value: w })), v = !0);
713
727
  } else
714
- d.type === "date" ? u.textContent = He(p) : d.type === "boolean" ? u.innerHTML = ae(!!p) : u.textContent = p == null ? "" : String(p);
715
- if (m) {
716
- ct(u);
717
- const v = u.textContent || "";
718
- /Proxy|Reflect\.ownKeys/.test(v) && (u.textContent = v.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(u.textContent || "") && (u.textContent = ""));
728
+ d.type === "date" ? u.textContent = He(w) : d.type === "boolean" ? u.innerHTML = ae(!!w) : u.textContent = w == null ? "" : String(w);
729
+ if (v) {
730
+ dt(u);
731
+ const m = u.textContent || "";
732
+ /Proxy|Reflect\.ownKeys/.test(m) && (u.textContent = m.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(u.textContent || "") && (u.textContent = ""));
719
733
  }
720
- u.hasAttribute("data-blocked-template") && (u.textContent || "").trim().length && (u.textContent = ""), d.editable ? u.tabIndex = 0 : d.type === "boolean" && (u.hasAttribute("tabindex") || (u.tabIndex = 0)), r === n && s === h ? (u.classList.add("cell-focus"), u.setAttribute("aria-selected", "true")) : u.setAttribute("aria-selected", "false"), c.appendChild(u);
734
+ u.hasAttribute("data-blocked-template") && (u.textContent || "").trim().length && (u.textContent = ""), d.editable ? u.tabIndex = 0 : d.type === "boolean" && (u.hasAttribute("tabindex") || (u.tabIndex = 0)), s === n && l === f ? (u.classList.add("cell-focus"), u.setAttribute("aria-selected", "true")) : u.setAttribute("aria-selected", "false"), c.appendChild(u);
721
735
  }
722
736
  e.appendChild(c);
723
737
  }
724
- function we(t, e, o, n) {
738
+ function be(t, e, o, n) {
725
739
  if (e.target?.closest(".resize-handle")) return;
726
- const i = o.querySelector(".cell[data-row]"), l = Me(i);
727
- if (l < 0) return;
728
- const r = t._rows[l];
729
- if (!r || t._dispatchRowClick?.(e, l, r, o))
740
+ const i = o.querySelector(".cell[data-row]"), r = Me(i);
741
+ if (r < 0) return;
742
+ const s = t._rows[r];
743
+ if (!s || t._dispatchRowClick?.(e, r, s, o))
730
744
  return;
731
- const s = e.target?.closest(".cell[data-col]");
732
- if (s) {
733
- const d = Number(s.getAttribute("data-col"));
745
+ const l = e.target?.closest(".cell[data-col]");
746
+ if (l) {
747
+ const d = Number(l.getAttribute("data-col"));
734
748
  if (!isNaN(d)) {
735
- if (t._dispatchCellClick?.(e, l, d, s))
749
+ if (t._dispatchCellClick?.(e, r, d, l))
736
750
  return;
737
- const u = t._focusRow !== l || t._focusCol !== d;
738
- if (t._focusRow = l, t._focusCol = d, s.classList.contains("editing")) {
739
- u && (le(t.shadowRoot ?? t._bodyEl), s.classList.add("cell-focus"));
751
+ const u = t._focusRow !== r || t._focusCol !== d;
752
+ if (t._focusRow = r, t._focusCol = d, l.classList.contains("editing")) {
753
+ u && (se(t.shadowRoot ?? t._bodyEl), l.classList.add("cell-focus"));
740
754
  return;
741
755
  }
742
756
  k(t);
743
757
  }
744
758
  }
745
- if (t._activeEditRows === l) {
746
- s && (le(t.shadowRoot ?? t._bodyEl), s.classList.add("cell-focus"), queueMicrotask(() => {
747
- const d = Number(s.getAttribute("data-col")), u = t._visibleColumns[d];
748
- if (u && u.editable && s.classList.contains("editing")) {
749
- const p = s.querySelector(B);
759
+ if (t._activeEditRows === r) {
760
+ l && (se(t.shadowRoot ?? t._bodyEl), l.classList.add("cell-focus"), queueMicrotask(() => {
761
+ const d = Number(l.getAttribute("data-col")), u = t._visibleColumns[d];
762
+ if (u && u.editable && l.classList.contains("editing")) {
763
+ const w = l.querySelector(B);
750
764
  try {
751
- p?.focus({ preventScroll: !0 });
765
+ w?.focus({ preventScroll: !0 });
752
766
  } catch {
753
767
  }
754
768
  }
755
769
  }));
756
770
  return;
757
771
  }
758
- if (J(o)) {
772
+ if (ee(o)) {
759
773
  if (!n) return;
760
774
  const d = o.children;
761
775
  for (let u = 0; u < d.length; u++)
762
776
  d[u].classList.remove("editing");
763
- Q(o);
777
+ te(o);
764
778
  }
765
779
  const c = t.effectiveConfig?.editOn ?? t.editOn ?? "dblClick";
766
780
  if (c === !1) return;
767
- const h = c === "dblclick" ? "dblClick" : c;
768
- if (h === "click" || h === "dblClick" && n) {
781
+ const f = c === "dblclick" ? "dblClick" : c;
782
+ if (f === "click" || f === "dblClick" && n) {
769
783
  if (typeof t.beginBulkEdit == "function") {
770
- t.beginBulkEdit(l);
784
+ t.beginBulkEdit(r);
771
785
  return;
772
786
  }
773
- W(t, l, r);
787
+ G(t, r, s);
774
788
  } else return;
775
789
  Array.from(o.children).forEach((d, u) => {
776
- const p = t._visibleColumns[u];
777
- p && p.editable && L(t, r, l, p, d, !0);
778
- }), s && queueMicrotask(() => {
790
+ const w = t._visibleColumns[u];
791
+ w && w.editable && H(t, s, r, w, d, !0);
792
+ }), l && queueMicrotask(() => {
779
793
  const d = o.querySelector(`.cell[data-col="${t._focusCol}"]`);
780
794
  if (d?.classList.contains("editing")) {
781
795
  const u = d.querySelector(B);
@@ -787,59 +801,74 @@ function we(t, e, o, n) {
787
801
  });
788
802
  }
789
803
  const B = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';
790
- function re(t) {
804
+ function le(t) {
791
805
  return !(t === "__proto__" || t === "constructor" || t === "prototype");
792
806
  }
793
- function J(t) {
807
+ function ee(t) {
794
808
  return (t.__editingCellCount ?? 0) > 0;
795
809
  }
796
- function vt(t) {
810
+ function _t(t) {
797
811
  const e = (t.__editingCellCount ?? 0) + 1;
798
812
  t.__editingCellCount = e, t.setAttribute("data-has-editing", "");
799
813
  }
800
- function Q(t) {
814
+ function te(t) {
801
815
  t.__editingCellCount = 0, t.removeAttribute("data-has-editing");
802
816
  }
803
- function W(t, e, o) {
817
+ function Ct(t, e, o, n, i) {
818
+ const r = t.querySelector("input,textarea,select");
819
+ if (!r) return;
820
+ const s = () => {
821
+ if (r instanceof HTMLInputElement) {
822
+ if (r.type === "checkbox") return r.checked;
823
+ if (r.type === "number") return r.value === "" ? null : Number(r.value);
824
+ if (r.type === "date") return r.valueAsDate;
825
+ }
826
+ return e.type === "number" && r.value !== "" ? Number(r.value) : r.value;
827
+ };
828
+ r.addEventListener("blur", () => {
829
+ o(s());
830
+ }), r instanceof HTMLInputElement && r.type === "checkbox" ? r.addEventListener("change", () => o(r.checked)) : r instanceof HTMLSelectElement && r.addEventListener("change", () => o(s()));
831
+ }
832
+ function G(t, e, o) {
804
833
  t._activeEditRows !== e && (t._rowEditSnapshots.set(e, { ...o }), t._activeEditRows = e);
805
834
  }
806
835
  function D(t, e, o) {
807
836
  if (t._activeEditRows !== e) return;
808
- const n = t._rowEditSnapshots.get(e), i = t._rows[e], l = t.findRenderedRowElement?.(e);
809
- if (!o && l && i && l.querySelectorAll(".cell.editing").forEach((s) => {
810
- const a = Number(s.getAttribute("data-col"));
837
+ const n = t._rowEditSnapshots.get(e), i = t._rows[e], r = t.findRenderedRowElement?.(e);
838
+ if (!o && r && i && r.querySelectorAll(".cell.editing").forEach((l) => {
839
+ const a = Number(l.getAttribute("data-col"));
811
840
  if (isNaN(a)) return;
812
841
  const c = t._visibleColumns[a];
813
842
  if (!c) return;
814
- const h = s.querySelector("input,textarea,select");
815
- if (h) {
843
+ const f = l.querySelector("input,textarea,select");
844
+ if (f) {
816
845
  let d;
817
- h instanceof HTMLInputElement && h.type === "checkbox" ? d = h.checked : (d = h.value, c.type === "number" && d !== "" && (d = Number(d))), i[c.field] !== d && ce(t, e, c, d, i);
846
+ f instanceof HTMLInputElement && f.type === "checkbox" ? d = f.checked : (d = f.value, c.type === "number" && d !== "" && (d = Number(d))), i[c.field] !== d && ce(t, e, c, d, i);
818
847
  }
819
848
  }), o && n && i)
820
- Object.keys(n).forEach((r) => i[r] = n[r]), t._changedRowIndices.delete(e), Z(t);
849
+ Object.keys(n).forEach((s) => i[s] = n[s]), t._changedRowIndices.delete(e), Y(t);
821
850
  else if (!o) {
822
- const r = t._changedRowIndices.has(e);
851
+ const s = t._changedRowIndices.has(e);
823
852
  t.dispatchEvent(
824
853
  new CustomEvent("row-commit", {
825
854
  detail: {
826
855
  rowIndex: e,
827
856
  row: i,
828
- changed: r,
857
+ changed: s,
829
858
  changedRows: t.changedRows,
830
859
  changedRowIndices: t.changedRowIndices
831
860
  }
832
861
  })
833
862
  );
834
863
  }
835
- t._rowEditSnapshots.delete(e), t._activeEditRows = -1, l && (I(t, l, t._rows[e], e), t._changedRowIndices.has(e) ? l.classList.add("changed") : l.classList.remove("changed")), queueMicrotask(() => {
864
+ t._rowEditSnapshots.delete(e), t._activeEditRows = -1, r && ($(t, r, t._rows[e], e), t._changedRowIndices.has(e) ? r.classList.add("changed") : r.classList.remove("changed")), queueMicrotask(() => {
836
865
  try {
837
- const r = t._focusRow, s = t._focusCol, a = t.findRenderedRowElement?.(r);
866
+ const s = t._focusRow, l = t._focusCol, a = t.findRenderedRowElement?.(s);
838
867
  if (a) {
839
868
  Array.from(t._bodyEl.querySelectorAll(".cell-focus")).forEach(
840
- (h) => h.classList.remove("cell-focus")
869
+ (f) => f.classList.remove("cell-focus")
841
870
  );
842
- const c = a.querySelector(`.cell[data-row="${r}"][data-col="${s}"]`);
871
+ const c = a.querySelector(`.cell[data-row="${s}"][data-col="${l}"]`);
843
872
  c && (c.classList.add("cell-focus"), c.setAttribute("aria-selected", "true"), c.hasAttribute("tabindex") || c.setAttribute("tabindex", "-1"), c.focus({ preventScroll: !0 }));
844
873
  }
845
874
  } catch {
@@ -847,97 +876,97 @@ function D(t, e, o) {
847
876
  });
848
877
  }
849
878
  function ce(t, e, o, n, i) {
850
- const l = o.field;
851
- if (!re(l) || i[l] === n) return;
852
- i[l] = n;
853
- const s = !t._changedRowIndices.has(e);
879
+ const r = o.field;
880
+ if (!le(r) || i[r] === n) return;
881
+ i[r] = n;
882
+ const l = !t._changedRowIndices.has(e);
854
883
  t._changedRowIndices.add(e);
855
884
  const a = t.findRenderedRowElement?.(e);
856
885
  a && a.classList.add("changed"), t.dispatchEvent(
857
886
  new CustomEvent("cell-commit", {
858
887
  detail: {
859
888
  row: i,
860
- field: l,
889
+ field: r,
861
890
  value: n,
862
891
  rowIndex: e,
863
892
  changedRows: t.changedRows,
864
893
  changedRowIndices: t.changedRowIndices,
865
- firstTimeForRow: s
894
+ firstTimeForRow: l
866
895
  }
867
896
  })
868
897
  );
869
898
  }
870
- function L(t, e, o, n, i, l = !1) {
871
- if (!n.editable || (t._activeEditRows !== o && W(t, o, e), i.classList.contains("editing"))) return;
872
- const r = re(n.field) ? e[n.field] : void 0;
899
+ function H(t, e, o, n, i, r = !1) {
900
+ if (!n.editable || (t._activeEditRows !== o && G(t, o, e), i.classList.contains("editing"))) return;
901
+ const s = le(n.field) ? e[n.field] : void 0;
873
902
  i.classList.add("editing");
874
- const s = i.parentElement;
875
- s && vt(s);
903
+ const l = i.parentElement;
904
+ l && _t(l);
876
905
  let a = !1;
877
- const c = (b) => {
878
- a || t._activeEditRows === -1 || ce(t, o, n, b, e);
879
- }, h = () => {
880
- a = !0, e[n.field] = re(n.field) ? r : void 0;
881
- const b = i.querySelector("input,textarea,select");
882
- b && (typeof HTMLInputElement < "u" && b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked = !!r : "value" in b && (b.value = r ?? ""));
906
+ const c = (p) => {
907
+ a || t._activeEditRows === -1 || ce(t, o, n, p, e);
908
+ }, f = () => {
909
+ a = !0, e[n.field] = le(n.field) ? s : void 0;
910
+ const p = i.querySelector("input,textarea,select");
911
+ p && (typeof HTMLInputElement < "u" && p instanceof HTMLInputElement && p.type === "checkbox" ? p.checked = !!s : "value" in p && (p.value = s ?? ""));
883
912
  }, d = document.createElement("div");
884
- d.style.display = "contents", i.innerHTML = "", i.appendChild(d), d.addEventListener("keydown", (b) => {
885
- b.key === "Enter" && (b.stopPropagation(), b.preventDefault(), a = !0, D(t, o, !1)), b.key === "Escape" && (b.stopPropagation(), b.preventDefault(), h(), D(t, o, !0));
913
+ d.style.display = "contents", i.innerHTML = "", i.appendChild(d), d.addEventListener("keydown", (p) => {
914
+ p.key === "Enter" && (p.stopPropagation(), p.preventDefault(), a = !0, D(t, o, !1)), p.key === "Escape" && (p.stopPropagation(), p.preventDefault(), f(), D(t, o, !0));
886
915
  });
887
- const u = n.__editorTemplate, p = n.editor || (u ? "template" : ht(n)), f = r;
888
- if (p === "template" && u) {
889
- const b = u.cloneNode(!0), g = n.__compiledEditor;
890
- g ? b.innerHTML = g({ row: e, value: r, field: n.field, column: n }) : b.querySelectorAll("*").forEach((_) => {
891
- _.childNodes.length === 1 && _.firstChild?.nodeType === Node.TEXT_NODE && (_.textContent = _.textContent?.replace(/{{\s*value\s*}}/g, r == null ? "" : String(r)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (m, v) => {
892
- const C = e[v];
893
- return C == null ? "" : String(C);
916
+ const u = n.__editorTemplate, w = n.editor || (u ? "template" : ft(n)), h = s;
917
+ if (w === "template" && u) {
918
+ const p = u.cloneNode(!0), g = n.__compiledEditor;
919
+ g ? p.innerHTML = g({ row: e, value: s, field: n.field, column: n }) : p.querySelectorAll("*").forEach((_) => {
920
+ _.childNodes.length === 1 && _.firstChild?.nodeType === Node.TEXT_NODE && (_.textContent = _.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (v, m) => {
921
+ const E = e[m];
922
+ return E == null ? "" : String(E);
894
923
  }) || "");
895
924
  });
896
- const w = b.querySelector("input,textarea,select");
897
- if (w) {
925
+ const b = p.querySelector("input,textarea,select");
926
+ if (b) {
898
927
  const _ = typeof HTMLInputElement < "u";
899
- _ && w instanceof HTMLInputElement && w.type === "checkbox" ? w.checked = !!r : "value" in w && (w.value = r ?? ""), w.addEventListener("blur", () => {
900
- const m = _ && w instanceof HTMLInputElement && w.type === "checkbox" ? w.checked : w.value;
901
- c(m);
902
- }), w.addEventListener("keydown", (m) => {
903
- if (m.key === "Enter") {
904
- m.stopPropagation(), m.preventDefault(), a = !0;
905
- const v = _ && w instanceof HTMLInputElement && w.type === "checkbox" ? w.checked : w.value;
906
- c(v), D(t, o, !1);
928
+ _ && b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked = !!s : "value" in b && (b.value = s ?? ""), b.addEventListener("blur", () => {
929
+ const v = _ && b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked : b.value;
930
+ c(v);
931
+ }), b.addEventListener("keydown", (v) => {
932
+ if (v.key === "Enter") {
933
+ v.stopPropagation(), v.preventDefault(), a = !0;
934
+ const m = _ && b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked : b.value;
935
+ c(m), D(t, o, !1);
907
936
  }
908
- m.key === "Escape" && (m.stopPropagation(), m.preventDefault(), h(), D(t, o, !0));
909
- }), _ && w instanceof HTMLInputElement && w.type === "checkbox" && w.addEventListener("change", () => {
910
- const m = w.checked;
911
- c(m);
912
- }), l || setTimeout(() => w.focus({ preventScroll: !0 }), 0);
913
- }
914
- d.appendChild(b);
915
- } else if (typeof p == "string") {
916
- const b = document.createElement(p);
917
- b.value = f, b.addEventListener("change", () => c(b.value)), d.appendChild(b), l || queueMicrotask(() => {
937
+ v.key === "Escape" && (v.stopPropagation(), v.preventDefault(), f(), D(t, o, !0));
938
+ }), _ && b instanceof HTMLInputElement && b.type === "checkbox" && b.addEventListener("change", () => {
939
+ const v = b.checked;
940
+ c(v);
941
+ }), r || setTimeout(() => b.focus({ preventScroll: !0 }), 0);
942
+ }
943
+ d.appendChild(p);
944
+ } else if (typeof w == "string") {
945
+ const p = document.createElement(w);
946
+ p.value = h, p.addEventListener("change", () => c(p.value)), d.appendChild(p), r || queueMicrotask(() => {
918
947
  d.querySelector(B)?.focus({ preventScroll: !0 });
919
948
  });
920
- } else if (typeof p == "function") {
921
- const b = p({ row: e, value: f, field: n.field, column: n, commit: c, cancel: h });
922
- typeof b == "string" ? d.innerHTML = b : d.appendChild(b), l || queueMicrotask(() => {
949
+ } else if (typeof w == "function") {
950
+ const p = w({ row: e, value: h, field: n.field, column: n, commit: c, cancel: f });
951
+ typeof p == "string" ? (d.innerHTML = p, Ct(d, n, c)) : d.appendChild(p), r || queueMicrotask(() => {
923
952
  d.querySelector(B)?.focus({ preventScroll: !0 });
924
953
  });
925
- } else if (p && typeof p == "object") {
926
- const b = document.createElement("div");
927
- b.setAttribute("data-external-editor", ""), b.setAttribute("data-field", n.field), d.appendChild(b);
928
- const g = { row: e, value: f, field: n.field, column: n, commit: c, cancel: h };
929
- if (p.mount)
954
+ } else if (w && typeof w == "object") {
955
+ const p = document.createElement("div");
956
+ p.setAttribute("data-external-editor", ""), p.setAttribute("data-field", n.field), d.appendChild(p);
957
+ const g = { row: e, value: h, field: n.field, column: n, commit: c, cancel: f };
958
+ if (w.mount)
930
959
  try {
931
- p.mount({ placeholder: b, context: g, spec: p });
960
+ w.mount({ placeholder: p, context: g, spec: w });
932
961
  } catch {
933
962
  }
934
963
  else
935
964
  t.dispatchEvent(
936
- new CustomEvent("mount-external-editor", { detail: { placeholder: b, spec: p, context: g } })
965
+ new CustomEvent("mount-external-editor", { detail: { placeholder: p, spec: w, context: g } })
937
966
  );
938
967
  }
939
968
  }
940
- function _t(t, e, o) {
969
+ function Et(t, e, o) {
941
970
  t.dispatchEvent(new CustomEvent(e, { detail: o, bubbles: !0 }));
942
971
  }
943
972
  function De(t) {
@@ -946,90 +975,90 @@ function De(t) {
946
975
  function ze(t) {
947
976
  return Array.from(t._changedRowIndices);
948
977
  }
949
- function Ct(t, e) {
950
- t._changedRowIndices.clear(), e || _t(t, "changed-rows-reset", {
978
+ function yt(t, e) {
979
+ t._changedRowIndices.clear(), e || Et(t, "changed-rows-reset", {
951
980
  rows: De(t),
952
981
  indices: ze(t)
953
982
  }), t._rowPool.forEach((o) => o.classList.remove("changed"));
954
983
  }
955
- function Et(t, e, o) {
956
- if (t.effectiveConfig?.editOn === !1 || !t._columns.some((r) => r.editable)) return;
984
+ function St(t, e, o) {
985
+ if (t.effectiveConfig?.editOn === !1 || !t._columns.some((s) => s.editable)) return;
957
986
  const i = t._rows[e];
958
- W(t, e, i);
959
- const l = o.findRenderedRowElement(e);
960
- l && (Array.from(l.children).forEach((r, s) => {
961
- const a = t._visibleColumns[s];
987
+ G(t, e, i);
988
+ const r = o.findRenderedRowElement(e);
989
+ r && (Array.from(r.children).forEach((s, l) => {
990
+ const a = t._visibleColumns[l];
962
991
  if (a?.editable) {
963
- const c = r;
964
- c.classList.contains("editing") || L(t, i, e, a, c, !0);
992
+ const c = s;
993
+ c.classList.contains("editing") || H(t, i, e, a, c, !0);
965
994
  }
966
995
  }), setTimeout(() => {
967
- let r = l.querySelector(`.cell[data-col="${t._focusCol}"]`);
968
- if (r?.classList.contains("editing") || (r = l.querySelector(".cell.editing")), r?.classList.contains("editing")) {
969
- const s = r.querySelector(B);
996
+ let s = r.querySelector(`.cell[data-col="${t._focusCol}"]`);
997
+ if (s?.classList.contains("editing") || (s = r.querySelector(".cell.editing")), s?.classList.contains("editing")) {
998
+ const l = s.querySelector(B);
970
999
  try {
971
- s?.focus({ preventScroll: !0 });
1000
+ l?.focus({ preventScroll: !0 });
972
1001
  } catch {
973
1002
  }
974
1003
  }
975
1004
  }, 0));
976
1005
  }
977
- function yt(t) {
1006
+ function Rt(t) {
978
1007
  t._activeEditRows !== -1 && D(t, t._activeEditRows, !1);
979
1008
  }
980
- function St(t) {
1009
+ function Tt(t) {
981
1010
  t._activeEditRows !== -1 && D(t, t._activeEditRows, !0);
982
1011
  }
983
- function te(t, e) {
984
- const o = Me(e), n = U(e);
1012
+ function oe(t, e) {
1013
+ const o = Me(e), n = X(e);
985
1014
  if (o < 0 || n < 0) return null;
986
- const i = t._rows[o], l = t._visibleColumns[n];
987
- return !i || !l ? null : { rowIndex: o, colIndex: n, rowData: i, col: l };
1015
+ const i = t._rows[o], r = t._visibleColumns[n];
1016
+ return !i || !r ? null : { rowIndex: o, colIndex: n, rowData: i, col: r };
988
1017
  }
989
- function Rt(t, e) {
1018
+ function xt(t, e) {
990
1019
  if (e.classList.contains("editing")) return;
991
- const o = te(t, e);
1020
+ const o = oe(t, e);
992
1021
  o && (t._focusRow = o.rowIndex, t._focusCol = o.colIndex, k(t));
993
1022
  }
994
1023
  function At(t, e, o) {
995
1024
  if (e.classList.contains("editing")) return;
996
- const n = te(t, e);
997
- n && (o.stopPropagation(), t._focusRow = n.rowIndex, t._focusCol = n.colIndex, L(t, n.rowData, n.rowIndex, n.col, e));
1025
+ const n = oe(t, e);
1026
+ n && (o.stopPropagation(), t._focusRow = n.rowIndex, t._focusCol = n.colIndex, H(t, n.rowData, n.rowIndex, n.col, e));
998
1027
  }
999
- function Tt(t, e, o) {
1028
+ function Lt(t, e, o) {
1000
1029
  o.stopPropagation();
1001
- const n = te(t, e);
1030
+ const n = oe(t, e);
1002
1031
  if (!n) return;
1003
1032
  if (typeof t.beginBulkEdit == "function") {
1004
1033
  t._focusRow = n.rowIndex, t._focusCol = n.colIndex, t.beginBulkEdit(n.rowIndex);
1005
1034
  return;
1006
1035
  }
1007
- W(t, n.rowIndex, n.rowData);
1036
+ G(t, n.rowIndex, n.rowData);
1008
1037
  const i = t.findRenderedRowElement?.(n.rowIndex);
1009
1038
  if (i) {
1010
- const l = i.children;
1011
- for (let r = 0; r < l.length; r++) {
1012
- const s = t._visibleColumns[r];
1013
- s && s.editable && L(t, n.rowData, n.rowIndex, s, l[r], !0);
1039
+ const r = i.children;
1040
+ for (let s = 0; s < r.length; s++) {
1041
+ const l = t._visibleColumns[s];
1042
+ l && l.editable && H(t, n.rowData, n.rowIndex, l, r[s], !0);
1014
1043
  }
1015
1044
  queueMicrotask(() => {
1016
- const r = i.querySelector(`.cell[data-col="${t._focusCol}"]`);
1017
- if (r?.classList.contains("editing")) {
1018
- const s = r.querySelector(B);
1045
+ const s = i.querySelector(`.cell[data-col="${t._focusCol}"]`);
1046
+ if (s?.classList.contains("editing")) {
1047
+ const l = s.querySelector(B);
1019
1048
  try {
1020
- s?.focus({ preventScroll: !0 });
1049
+ l?.focus({ preventScroll: !0 });
1021
1050
  } catch {
1022
1051
  }
1023
1052
  }
1024
1053
  });
1025
1054
  }
1026
1055
  }
1027
- function xt(t, e, o) {
1028
- const n = te(t, e);
1056
+ function Pt(t, e, o) {
1057
+ const n = oe(t, e);
1029
1058
  if (!n) return;
1030
- const { rowIndex: i, colIndex: l, rowData: r, col: s } = n, a = e.classList.contains("editing");
1031
- if ((s.type === "select" || s.type === "typeahead") && !a && o.key === "Enter") {
1032
- o.preventDefault(), t._activeEditRows !== i && W(t, i, r), L(t, r, i, s, e), setTimeout(() => {
1059
+ const { rowIndex: i, colIndex: r, rowData: s, col: l } = n, a = e.classList.contains("editing");
1060
+ if ((l.type === "select" || l.type === "typeahead") && !a && o.key === "Enter") {
1061
+ o.preventDefault(), t._activeEditRows !== i && G(t, i, s), H(t, s, i, l, e), setTimeout(() => {
1033
1062
  const c = e.querySelector("select");
1034
1063
  try {
1035
1064
  c?.showPicker?.();
@@ -1039,86 +1068,86 @@ function xt(t, e, o) {
1039
1068
  }, 0);
1040
1069
  return;
1041
1070
  }
1042
- if (s.type === "boolean" && o.key === " " && !a) {
1043
- o.preventDefault(), t._activeEditRows !== i && W(t, i, r);
1044
- const c = !r[s.field];
1045
- ce(t, i, s, c, r), e.innerHTML = ae(!!c);
1071
+ if (l.type === "boolean" && o.key === " " && !a) {
1072
+ o.preventDefault(), t._activeEditRows !== i && G(t, i, s);
1073
+ const c = !s[l.field];
1074
+ ce(t, i, l, c, s), e.innerHTML = ae(!!c);
1046
1075
  return;
1047
1076
  }
1048
1077
  if (o.key === "Enter" && !a) {
1049
- o.preventDefault(), o.stopPropagation(), t._focusRow = i, t._focusCol = l, typeof t.beginBulkEdit == "function" ? t.beginBulkEdit(i) : L(t, r, i, s, e);
1078
+ o.preventDefault(), o.stopPropagation(), t._focusRow = i, t._focusCol = r, typeof t.beginBulkEdit == "function" ? t.beginBulkEdit(i) : H(t, s, i, l, e);
1050
1079
  return;
1051
1080
  }
1052
1081
  if (o.key === "F2" && !a) {
1053
- o.preventDefault(), L(t, r, i, s, e);
1082
+ o.preventDefault(), H(t, s, i, l, e);
1054
1083
  return;
1055
1084
  }
1056
1085
  }
1057
- function Lt(t, e, o) {
1086
+ function Ht(t, e, o) {
1058
1087
  const n = () => t.effectiveConfig?.editOn || t.editOn;
1059
1088
  e.addEventListener(
1060
1089
  "mousedown",
1061
1090
  (i) => {
1062
- const l = i.target.closest(".cell[data-col]");
1063
- if (!l) return;
1064
- const r = U(l);
1065
- if (r < 0) return;
1066
- const s = t._visibleColumns[r];
1067
- s && s.editable && Rt(t, l);
1091
+ const r = i.target.closest(".cell[data-col]");
1092
+ if (!r) return;
1093
+ const s = X(r);
1094
+ if (s < 0) return;
1095
+ const l = t._visibleColumns[s];
1096
+ l && l.editable && xt(t, r);
1068
1097
  },
1069
1098
  { signal: o }
1070
1099
  ), e.addEventListener(
1071
1100
  "click",
1072
1101
  (i) => {
1073
1102
  if (n() !== "click") return;
1074
- const r = i.target.closest(".cell[data-col]");
1075
- if (!r) return;
1076
- const s = U(r);
1077
- if (s < 0) return;
1078
- const a = t._visibleColumns[s];
1079
- a && a.editable && At(t, r, i);
1103
+ const s = i.target.closest(".cell[data-col]");
1104
+ if (!s) return;
1105
+ const l = X(s);
1106
+ if (l < 0) return;
1107
+ const a = t._visibleColumns[l];
1108
+ a && a.editable && At(t, s, i);
1080
1109
  },
1081
1110
  { signal: o }
1082
1111
  ), e.addEventListener(
1083
1112
  "dblclick",
1084
1113
  (i) => {
1085
- const l = n();
1086
- if ((l === "dblclick" ? "dblClick" : l) === "click" || l === !1) return;
1087
- const s = i.target.closest(".cell[data-col]");
1088
- if (!s) return;
1089
- const a = U(s);
1114
+ const r = n();
1115
+ if ((r === "dblclick" ? "dblClick" : r) === "click" || r === !1) return;
1116
+ const l = i.target.closest(".cell[data-col]");
1117
+ if (!l) return;
1118
+ const a = X(l);
1090
1119
  if (a < 0) return;
1091
1120
  const c = t._visibleColumns[a];
1092
- c && c.editable && Tt(t, s, i);
1121
+ c && c.editable && Lt(t, l, i);
1093
1122
  },
1094
1123
  { signal: o }
1095
1124
  ), e.addEventListener(
1096
1125
  "keydown",
1097
1126
  (i) => {
1098
- const l = i.target.closest(".cell[data-col]");
1099
- if (!l) return;
1100
- const r = U(l);
1101
- if (r < 0) return;
1102
- const s = t._visibleColumns[r];
1103
- s && s.editable && xt(t, l, i);
1127
+ const r = i.target.closest(".cell[data-col]");
1128
+ if (!r) return;
1129
+ const s = X(r);
1130
+ if (s < 0) return;
1131
+ const l = t._visibleColumns[s];
1132
+ l && l.editable && Pt(t, r, i);
1104
1133
  },
1105
1134
  { signal: o }
1106
1135
  );
1107
1136
  }
1108
- function Pt(t, e) {
1137
+ function Mt(t, e) {
1109
1138
  return t == null && e == null ? 0 : t == null ? -1 : e == null || t > e ? 1 : t < e ? -1 : 0;
1110
1139
  }
1111
- function Ht(t, e, o) {
1112
- const i = o.find((s) => s.field === e.field)?.sortComparator ?? Pt, { field: l, direction: r } = e;
1113
- return [...t].sort((s, a) => i(s[l], a[l], s, a) * r);
1140
+ function Ot(t, e, o) {
1141
+ const i = o.find((l) => l.field === e.field)?.sortComparator ?? Mt, { field: r, direction: s } = e;
1142
+ return [...t].sort((l, a) => i(l[r], a[r], l, a) * s);
1114
1143
  }
1115
1144
  function ge(t, e, o, n) {
1116
- t._rows = e, t.__rowRenderEpoch++, t._rowPool.forEach((i) => i.__epoch = -1), q(t), t.refreshVirtualWindow(!0), t.dispatchEvent(
1145
+ t._rows = e, t.__rowRenderEpoch++, t._rowPool.forEach((i) => i.__epoch = -1), F(t), t.refreshVirtualWindow(!0), t.dispatchEvent(
1117
1146
  new CustomEvent("sort-change", { detail: { field: o.field, direction: n } })
1118
1147
  ), t.requestStateChange?.();
1119
1148
  }
1120
1149
  function me(t, e) {
1121
- !t._sortState || t._sortState.field !== e.field ? (t._sortState || (t.__originalOrder = t._rows.slice()), ve(t, e, 1)) : t._sortState.direction === 1 ? ve(t, e, -1) : (t._sortState = null, t.__rowRenderEpoch++, t._rowPool.forEach((n) => n.__epoch = -1), t._rows = t.__originalOrder.slice(), q(t), t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach((n) => {
1150
+ !t._sortState || t._sortState.field !== e.field ? (t._sortState || (t.__originalOrder = t._rows.slice()), ve(t, e, 1)) : t._sortState.direction === 1 ? ve(t, e, -1) : (t._sortState = null, t.__rowRenderEpoch++, t._rowPool.forEach((n) => n.__epoch = -1), t._rows = t.__originalOrder.slice(), F(t), t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach((n) => {
1122
1151
  n.getAttribute("aria-sort") ? (n.getAttribute("aria-sort") === "ascending" || n.getAttribute("aria-sort") === "descending") && (t._sortState || n.setAttribute("aria-sort", "none")) : n.setAttribute("aria-sort", "none");
1123
1152
  }), t.refreshVirtualWindow(!0), t.dispatchEvent(
1124
1153
  new CustomEvent("sort-change", { detail: { field: e.field, direction: 0 } })
@@ -1126,48 +1155,48 @@ function me(t, e) {
1126
1155
  }
1127
1156
  function ve(t, e, o) {
1128
1157
  t._sortState = { field: e.field, direction: o };
1129
- const n = { field: e.field, direction: o }, i = t._columns, r = (t.effectiveConfig?.sortHandler ?? Ht)(t._rows, n, i);
1130
- r && typeof r.then == "function" ? r.then((s) => {
1131
- ge(t, s, e, o);
1132
- }) : ge(t, r, e, o);
1158
+ const n = { field: e.field, direction: o }, i = t._columns, s = (t.effectiveConfig?.sortHandler ?? Ot)(t._rows, n, i);
1159
+ s && typeof s.then == "function" ? s.then((l) => {
1160
+ ge(t, l, e, o);
1161
+ }) : ge(t, s, e, o);
1133
1162
  }
1134
- function Mt(t, e) {
1163
+ function kt(t, e) {
1135
1164
  typeof e == "string" ? t.textContent = e : e instanceof HTMLElement && (t.innerHTML = "", t.appendChild(e.cloneNode(!0)));
1136
1165
  }
1137
- function q(t) {
1166
+ function F(t) {
1138
1167
  t._headerRowEl = t.findHeaderRow();
1139
1168
  const e = t._headerRowEl;
1140
1169
  e.innerHTML = "", t._visibleColumns.forEach((o, n) => {
1141
1170
  const i = document.createElement("div");
1142
1171
  i.className = "cell", fe(i, "header-cell"), i.setAttribute("role", "columnheader"), i.setAttribute("aria-colindex", String(n + 1)), i.setAttribute("data-field", o.field), i.setAttribute("data-col", String(n));
1143
- const l = o.__headerTemplate;
1144
- if (l) Array.from(l.childNodes).forEach((r) => i.appendChild(r.cloneNode(!0)));
1172
+ const r = o.__headerTemplate;
1173
+ if (r) Array.from(r.childNodes).forEach((s) => i.appendChild(s.cloneNode(!0)));
1145
1174
  else {
1146
- const r = o.header || o.field, s = document.createElement("span");
1147
- s.textContent = r, i.appendChild(s);
1175
+ const s = o.header || o.field, l = document.createElement("span");
1176
+ l.textContent = s, i.appendChild(l);
1148
1177
  }
1149
1178
  if (o.sortable) {
1150
1179
  i.classList.add("sortable"), i.tabIndex = 0;
1151
- const r = document.createElement("span");
1152
- fe(r, "sort-indicator");
1153
- const s = t._sortState?.field === o.field ? t._sortState.direction : 0, a = { ...O, ...t.icons }, c = s === 1 ? a.sortAsc : s === -1 ? a.sortDesc : a.sortNone;
1154
- Mt(r, c), i.appendChild(r), i.setAttribute("aria-sort", s === 0 ? "none" : s === 1 ? "ascending" : "descending"), i.addEventListener("click", (h) => {
1155
- t._resizeController?.isResizing || t._dispatchHeaderClick?.(h, n, i) || me(t, o);
1156
- }), i.addEventListener("keydown", (h) => {
1157
- if (h.key === "Enter" || h.key === " ") {
1158
- if (h.preventDefault(), t._dispatchHeaderClick?.(h, n, i)) return;
1180
+ const s = document.createElement("span");
1181
+ fe(s, "sort-indicator");
1182
+ const l = t._sortState?.field === o.field ? t._sortState.direction : 0, a = { ...O, ...t.icons }, c = l === 1 ? a.sortAsc : l === -1 ? a.sortDesc : a.sortNone;
1183
+ kt(s, c), i.appendChild(s), i.setAttribute("aria-sort", l === 0 ? "none" : l === 1 ? "ascending" : "descending"), i.addEventListener("click", (f) => {
1184
+ t._resizeController?.isResizing || t._dispatchHeaderClick?.(f, n, i) || me(t, o);
1185
+ }), i.addEventListener("keydown", (f) => {
1186
+ if (f.key === "Enter" || f.key === " ") {
1187
+ if (f.preventDefault(), t._dispatchHeaderClick?.(f, n, i)) return;
1159
1188
  me(t, o);
1160
1189
  }
1161
1190
  });
1162
1191
  }
1163
1192
  if (o.resizable) {
1164
1193
  i.style.position = "relative";
1165
- const r = document.createElement("div");
1166
- r.className = "resize-handle", r.setAttribute("aria-hidden", "true"), r.addEventListener("mousedown", (s) => {
1167
- s.stopPropagation(), s.preventDefault(), t._resizeController.start(s, n, i);
1168
- }), r.addEventListener("dblclick", (s) => {
1169
- s.stopPropagation(), s.preventDefault(), t._resizeController.resetColumn(n);
1170
- }), i.appendChild(r);
1194
+ const s = document.createElement("div");
1195
+ s.className = "resize-handle", s.setAttribute("aria-hidden", "true"), s.addEventListener("mousedown", (l) => {
1196
+ l.stopPropagation(), l.preventDefault(), t._resizeController.start(l, n, i);
1197
+ }), s.addEventListener("dblclick", (l) => {
1198
+ l.stopPropagation(), l.preventDefault(), t._resizeController.resetColumn(n);
1199
+ }), i.appendChild(s);
1171
1200
  }
1172
1201
  e.appendChild(i);
1173
1202
  }), e.querySelectorAll(".cell.sortable").forEach((o) => {
@@ -1175,7 +1204,7 @@ function q(t) {
1175
1204
  }), e.children.length > 0 ? (e.setAttribute("role", "row"), e.setAttribute("aria-rowindex", "1")) : (e.removeAttribute("role"), e.removeAttribute("aria-rowindex"));
1176
1205
  }
1177
1206
  const Ne = typeof requestIdleCallback == "function";
1178
- function Ot(t, e) {
1207
+ function Dt(t, e) {
1179
1208
  return Ne ? requestIdleCallback(t, e) : window.setTimeout(() => {
1180
1209
  const o = Date.now();
1181
1210
  t({
@@ -1187,32 +1216,32 @@ function Ot(t, e) {
1187
1216
  function _e(t) {
1188
1217
  Ne ? cancelIdleCallback(t) : clearTimeout(t);
1189
1218
  }
1190
- function kt(t) {
1219
+ function zt(t) {
1191
1220
  let e = null, o = null, n = null, i = null;
1192
- const l = (a) => {
1221
+ const r = (a) => {
1193
1222
  if (!e) return;
1194
- const c = a.clientX - e.startX, h = Math.max(40, e.startWidth + c), d = t._visibleColumns[e.colIndex];
1195
- d.width = h, d.__userResized = !0, d.__renderedWidth = h, o == null && (o = requestAnimationFrame(() => {
1223
+ const c = a.clientX - e.startX, f = Math.max(40, e.startWidth + c), d = t._visibleColumns[e.colIndex];
1224
+ d.width = f, d.__userResized = !0, d.__renderedWidth = f, o == null && (o = requestAnimationFrame(() => {
1196
1225
  o = null, t.updateTemplate?.();
1197
1226
  })), t.dispatchEvent(
1198
- new CustomEvent("column-resize", { detail: { field: d.field, width: h } })
1227
+ new CustomEvent("column-resize", { detail: { field: d.field, width: f } })
1199
1228
  );
1200
1229
  };
1201
- let r = !1;
1202
- const s = () => {
1230
+ let s = !1;
1231
+ const l = () => {
1203
1232
  const a = e !== null;
1204
- a && (r = !0, requestAnimationFrame(() => {
1205
- r = !1;
1206
- })), window.removeEventListener("mousemove", l), window.removeEventListener("mouseup", s), n !== null && (document.documentElement.style.cursor = n, n = null), i !== null && (document.body.style.userSelect = i, i = null), e = null, a && t.requestStateChange && t.requestStateChange();
1233
+ a && (s = !0, requestAnimationFrame(() => {
1234
+ s = !1;
1235
+ })), window.removeEventListener("mousemove", r), 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 && t.requestStateChange && t.requestStateChange();
1207
1236
  };
1208
1237
  return {
1209
1238
  get isResizing() {
1210
- return e !== null || r;
1239
+ return e !== null || s;
1211
1240
  },
1212
- start(a, c, h) {
1241
+ start(a, c, f) {
1213
1242
  a.preventDefault();
1214
- const d = h.getBoundingClientRect();
1215
- e = { startX: a.clientX, colIndex: c, startWidth: d.width }, window.addEventListener("mousemove", l), window.addEventListener("mouseup", s), 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";
1243
+ const d = f.getBoundingClientRect();
1244
+ e = { startX: a.clientX, colIndex: c, startWidth: d.width }, window.addEventListener("mousemove", r), 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";
1216
1245
  },
1217
1246
  resetColumn(a) {
1218
1247
  const c = t._visibleColumns[a];
@@ -1221,20 +1250,20 @@ function kt(t) {
1221
1250
  ));
1222
1251
  },
1223
1252
  dispose() {
1224
- s();
1253
+ l();
1225
1254
  }
1226
1255
  };
1227
1256
  }
1228
- function Y(t, e, o) {
1257
+ function Z(t, e, o) {
1229
1258
  const n = document.createElement(t);
1230
1259
  if (e)
1231
1260
  for (const i in e) {
1232
- const l = e[i];
1233
- l != null && n.setAttribute(i, l);
1261
+ const r = e[i];
1262
+ r != null && n.setAttribute(i, r);
1234
1263
  }
1235
1264
  return n;
1236
1265
  }
1237
- function y(t, e) {
1266
+ function T(t, e) {
1238
1267
  const o = document.createElement("div");
1239
1268
  if (t && (o.className = t), e)
1240
1269
  for (const n in e) {
@@ -1243,12 +1272,12 @@ function y(t, e) {
1243
1272
  }
1244
1273
  return o;
1245
1274
  }
1246
- function ee(t, e, o) {
1275
+ function Ie(t, e, o) {
1247
1276
  const n = document.createElement("button");
1248
1277
  if (t && (n.className = t), e)
1249
1278
  for (const i in e) {
1250
- const l = e[i];
1251
- l != null && n.setAttribute(i, l);
1279
+ const r = e[i];
1280
+ r != null && n.setAttribute(i, r);
1252
1281
  }
1253
1282
  return n;
1254
1283
  }
@@ -1261,11 +1290,11 @@ Be.innerHTML = `
1261
1290
  <div class="tbw-scroll-area">
1262
1291
  <div class="rows-body-wrapper">
1263
1292
  <div class="rows-body" role="grid">
1264
- <div class="header">
1265
- <div class="header-row" part="header-row"></div>
1293
+ <div class="header" role="rowgroup">
1294
+ <div class="header-row" role="row" part="header-row"></div>
1266
1295
  </div>
1267
- <div class="rows-container">
1268
- <div class="rows-viewport">
1296
+ <div class="rows-container" role="presentation">
1297
+ <div class="rows-viewport" role="presentation">
1269
1298
  <div class="rows"></div>
1270
1299
  </div>
1271
1300
  </div>
@@ -1276,147 +1305,123 @@ Be.innerHTML = `
1276
1305
  <div class="faux-vscroll-spacer"></div>
1277
1306
  </div>
1278
1307
  `;
1279
- function Ie() {
1308
+ function qe() {
1280
1309
  return Be.content.cloneNode(!0);
1281
1310
  }
1282
1311
  function Ee(t) {
1283
- const e = document.createDocumentFragment(), o = y(t.hasShell ? "tbw-grid-root has-shell" : "tbw-grid-root");
1312
+ const e = document.createDocumentFragment(), o = T(t.hasShell ? "tbw-grid-root has-shell" : "tbw-grid-root");
1284
1313
  if (t.hasShell && t.shellHeader && t.shellBody)
1285
1314
  o.appendChild(t.shellHeader), o.appendChild(t.shellBody);
1286
1315
  else {
1287
- const n = y("tbw-grid-content");
1288
- n.appendChild(Ie()), o.appendChild(n);
1316
+ const n = T("tbw-grid-content");
1317
+ n.appendChild(qe()), o.appendChild(n);
1289
1318
  }
1290
1319
  return e.appendChild(o), e;
1291
1320
  }
1292
- function Dt(t) {
1293
- const e = y("tbw-shell-header", { part: "shell-header", role: "presentation" });
1321
+ function Nt(t) {
1322
+ const e = T("tbw-shell-header", { part: "shell-header", role: "presentation" });
1294
1323
  if (t.title) {
1295
- const l = y("tbw-shell-title");
1296
- l.textContent = t.title, e.appendChild(l);
1324
+ const r = T("tbw-shell-title");
1325
+ r.textContent = t.title, e.appendChild(r);
1297
1326
  }
1298
- const o = y("tbw-shell-content", { part: "shell-content", role: "presentation" });
1327
+ const o = T("tbw-shell-content", { part: "shell-content", role: "presentation" });
1299
1328
  o.appendChild(Ce("header-content")), e.appendChild(o);
1300
- const n = y("tbw-shell-toolbar", { part: "shell-toolbar", role: "presentation" });
1301
- for (const l of t.configButtons)
1302
- if (l.icon && l.action) {
1303
- const r = ee("tbw-toolbar-btn", {
1304
- "data-btn": l.id,
1305
- title: l.label,
1306
- "aria-label": l.label
1307
- });
1308
- l.disabled && (r.disabled = !0), r.innerHTML = l.icon, n.appendChild(r);
1309
- }
1310
- for (const l of t.apiButtons)
1311
- if (l.icon && l.action) {
1312
- const r = ee("tbw-toolbar-btn", {
1313
- "data-btn": l.id,
1314
- title: l.label,
1315
- "aria-label": l.label
1316
- });
1317
- l.disabled && (r.disabled = !0), r.innerHTML = l.icon, n.appendChild(r);
1318
- }
1319
- for (const l of t.configButtons)
1320
- (l.hasElement || l.hasRender) && n.appendChild(y("tbw-toolbar-btn-slot", { "data-btn-slot": l.id }));
1321
- for (const l of t.apiButtons)
1322
- (l.hasElement || l.hasRender) && n.appendChild(y("tbw-toolbar-btn-slot", { "data-btn-slot": l.id }));
1323
- if (t.hasLightDomButtons && n.appendChild(Ce("toolbar")), (t.configButtons.length > 0 || t.apiButtons.length > 0 || t.hasLightDomButtons) && t.hasPanels && n.appendChild(y("tbw-toolbar-separator")), t.hasPanels) {
1324
- const l = ee(t.isPanelOpen ? "tbw-toolbar-btn active" : "tbw-toolbar-btn", {
1329
+ const n = T("tbw-shell-toolbar", { part: "shell-toolbar", role: "presentation" });
1330
+ for (const r of t.configButtons)
1331
+ (r.hasElement || r.hasRender) && n.appendChild(T("tbw-toolbar-btn-slot", { "data-btn-slot": r.id }));
1332
+ for (const r of t.apiButtons)
1333
+ (r.hasElement || r.hasRender) && n.appendChild(T("tbw-toolbar-btn-slot", { "data-btn-slot": r.id }));
1334
+ if (n.appendChild(Ce("toolbar")), (t.configButtons.some((r) => r.hasElement || r.hasRender) || t.apiButtons.some((r) => r.hasElement || r.hasRender)) && t.hasPanels && n.appendChild(T("tbw-toolbar-separator")), t.hasPanels) {
1335
+ const r = Ie(t.isPanelOpen ? "tbw-toolbar-btn active" : "tbw-toolbar-btn", {
1325
1336
  "data-panel-toggle": "",
1326
1337
  title: "Settings",
1327
1338
  "aria-label": "Toggle settings panel",
1328
1339
  "aria-pressed": String(t.isPanelOpen),
1329
1340
  "aria-controls": "tbw-tool-panel"
1330
1341
  });
1331
- l.innerHTML = t.toolPanelIcon, n.appendChild(l);
1342
+ r.innerHTML = t.toolPanelIcon, n.appendChild(r);
1332
1343
  }
1333
1344
  return e.appendChild(n), e;
1334
1345
  }
1335
- function zt(t) {
1336
- const e = y("tbw-shell-body"), o = t.panels.length > 0, n = t.panels.length === 1, i = y("tbw-grid-content");
1337
- i.appendChild(Ie());
1338
- let l = null;
1346
+ function It(t) {
1347
+ const e = T("tbw-shell-body"), o = t.panels.length > 0, n = t.panels.length === 1, i = T("tbw-grid-content");
1348
+ i.appendChild(qe());
1349
+ let r = null;
1339
1350
  if (o) {
1340
- l = Y("aside", {
1351
+ r = Z("aside", {
1341
1352
  class: t.isPanelOpen ? "tbw-tool-panel open" : "tbw-tool-panel",
1342
1353
  part: "tool-panel",
1343
1354
  "data-position": t.position,
1344
1355
  role: "presentation",
1345
1356
  id: "tbw-tool-panel"
1346
1357
  });
1347
- const r = t.position === "left" ? "right" : "left";
1348
- l.appendChild(
1349
- y("tbw-tool-panel-resize", {
1358
+ const s = t.position === "left" ? "right" : "left";
1359
+ r.appendChild(
1360
+ T("tbw-tool-panel-resize", {
1350
1361
  "data-resize-handle": "",
1351
- "data-handle-position": r,
1362
+ "data-handle-position": s,
1352
1363
  "aria-hidden": "true"
1353
1364
  })
1354
1365
  );
1355
- const s = y("tbw-tool-panel-content", { role: "presentation" }), a = y("tbw-accordion");
1366
+ const l = T("tbw-tool-panel-content", { role: "presentation" }), a = T("tbw-accordion");
1356
1367
  for (const c of t.panels) {
1357
- const h = `tbw-accordion-section${c.isExpanded ? " expanded" : ""}${n ? " single" : ""}`, d = y(h, { "data-section": c.id }), u = ee("tbw-accordion-header", {
1368
+ const f = `tbw-accordion-section${c.isExpanded ? " expanded" : ""}${n ? " single" : ""}`, d = T(f, { "data-section": c.id }), u = Ie("tbw-accordion-header", {
1358
1369
  "aria-expanded": String(c.isExpanded),
1359
1370
  "aria-controls": `tbw-section-${c.id}`
1360
1371
  });
1361
1372
  if (n && u.setAttribute("aria-disabled", "true"), c.icon) {
1362
- const f = Y("span", { class: "tbw-accordion-icon" });
1363
- f.innerHTML = c.icon, u.appendChild(f);
1373
+ const h = Z("span", { class: "tbw-accordion-icon" });
1374
+ h.innerHTML = c.icon, u.appendChild(h);
1364
1375
  }
1365
- const p = Y("span", { class: "tbw-accordion-title" });
1366
- if (p.textContent = c.title, u.appendChild(p), !n) {
1367
- const f = Y("span", { class: "tbw-accordion-chevron" });
1368
- f.innerHTML = c.isExpanded ? t.collapseIcon : t.expandIcon, u.appendChild(f);
1376
+ const w = Z("span", { class: "tbw-accordion-title" });
1377
+ if (w.textContent = c.title, u.appendChild(w), !n) {
1378
+ const h = Z("span", { class: "tbw-accordion-chevron" });
1379
+ h.innerHTML = c.isExpanded ? t.collapseIcon : t.expandIcon, u.appendChild(h);
1369
1380
  }
1370
1381
  d.appendChild(u), d.appendChild(
1371
- y("tbw-accordion-content", {
1382
+ T("tbw-accordion-content", {
1372
1383
  id: `tbw-section-${c.id}`,
1373
1384
  role: "presentation"
1374
1385
  })
1375
1386
  ), a.appendChild(d);
1376
1387
  }
1377
- s.appendChild(a), l.appendChild(s);
1388
+ l.appendChild(a), r.appendChild(l);
1378
1389
  }
1379
- return t.position === "left" && l ? (e.appendChild(l), e.appendChild(i)) : (e.appendChild(i), l && e.appendChild(l)), e;
1390
+ return t.position === "left" && r ? (e.appendChild(r), e.appendChild(i)) : (e.appendChild(i), r && e.appendChild(r)), e;
1380
1391
  }
1381
- function M(t) {
1392
+ function N(t) {
1382
1393
  return t ? typeof t == "string" ? t : t.outerHTML : "";
1383
1394
  }
1384
- function Nt() {
1395
+ function Bt() {
1385
1396
  return {
1386
1397
  toolPanels: /* @__PURE__ */ new Map(),
1387
1398
  headerContents: /* @__PURE__ */ new Map(),
1388
1399
  toolbarButtons: /* @__PURE__ */ new Map(),
1389
- lightDomButtons: [],
1400
+ hasToolButtonsContainer: !1,
1390
1401
  lightDomHeaderContent: [],
1391
1402
  lightDomTitle: null,
1392
1403
  lightDomToolPanelIds: /* @__PURE__ */ new Set(),
1404
+ apiToolPanelIds: /* @__PURE__ */ new Set(),
1393
1405
  isPanelOpen: !1,
1394
1406
  expandedSections: /* @__PURE__ */ new Set(),
1395
1407
  headerContentCleanups: /* @__PURE__ */ new Map(),
1396
1408
  panelCleanups: /* @__PURE__ */ new Map(),
1397
- toolbarButtonCleanups: /* @__PURE__ */ new Map(),
1398
- // Deprecated - kept for backward compatibility
1399
- activePanel: null,
1400
- activePanelCleanup: null
1409
+ toolbarButtonCleanups: /* @__PURE__ */ new Map()
1401
1410
  };
1402
1411
  }
1403
- function se(t, e) {
1404
- return !!(t?.header?.title || e.lightDomTitle || t?.header?.toolbarButtons?.length || e.toolPanels.size > 0 || e.headerContents.size > 0 || e.toolbarButtons.size > 0 || e.lightDomButtons.length > 0 || e.lightDomHeaderContent.length > 0);
1412
+ function We(t, e) {
1413
+ return !!(t?.header?.title || e.lightDomTitle || t?.header?.toolbarButtons?.length || e.toolPanels.size > 0 || e.headerContents.size > 0 || e.toolbarButtons.size > 0 || e.lightDomHeaderContent.length > 0 || e.hasToolButtonsContainer);
1405
1414
  }
1406
1415
  function ye(t, e, o = "☰") {
1407
- const n = t?.header?.title ?? "", i = !!n, l = M(o), r = t?.header?.toolbarButtons ?? [], s = r.length > 0, a = e.toolbarButtons.size > 0, c = e.lightDomButtons.length > 0, h = e.toolPanels.size > 0, u = (s || a || c) && h, p = [...r].sort((g, w) => (g.order ?? 100) - (w.order ?? 100)), f = [...e.toolbarButtons.values()].sort((g, w) => (g.order ?? 100) - (w.order ?? 100));
1408
- let b = "";
1409
- for (const g of p)
1410
- g.icon && g.action && (b += `<button class="tbw-toolbar-btn" data-btn="${g.id}" title="${g.label}" aria-label="${g.label}"${g.disabled ? " disabled" : ""}>${g.icon}</button>`);
1411
- for (const g of f)
1412
- g.icon && g.action && (b += `<button class="tbw-toolbar-btn" data-btn="${g.id}" title="${g.label}" aria-label="${g.label}"${g.disabled ? " disabled" : ""}>${g.icon}</button>`);
1413
- for (const g of p)
1414
- (g.element || g.render) && (b += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${g.id}"></div>`);
1415
- for (const g of f)
1416
- (g.element || g.render) && (b += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${g.id}"></div>`);
1417
- if (c && (b += '<slot name="toolbar"></slot>'), u && (b += '<div class="tbw-toolbar-separator"></div>'), h) {
1418
- const g = e.isPanelOpen;
1419
- b += `<button class="tbw-toolbar-btn${g ? " active" : ""}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${g}" aria-controls="tbw-tool-panel">${l}</button>`;
1416
+ const n = t?.header?.title ?? e.lightDomTitle ?? "", i = !!n, r = N(o), s = t?.header?.toolbarButtons ?? [], l = s.some((p) => p.element || p.render), a = [...e.toolbarButtons.values()].some((p) => p.element || p.render), c = e.toolPanels.size > 0, d = (l || a) && c, u = [...s].sort((p, g) => (p.order ?? 100) - (g.order ?? 100)), w = [...e.toolbarButtons.values()].sort((p, g) => (p.order ?? 100) - (g.order ?? 100));
1417
+ let h = "";
1418
+ for (const p of u)
1419
+ (p.element || p.render) && (h += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${p.id}"></div>`);
1420
+ for (const p of w)
1421
+ (p.element || p.render) && (h += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${p.id}"></div>`);
1422
+ if (h += '<slot name="toolbar"></slot>', d && (h += '<div class="tbw-toolbar-separator"></div>'), c) {
1423
+ const p = e.isPanelOpen;
1424
+ h += `<button class="${p ? "tbw-toolbar-btn active" : "tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${p}" aria-controls="tbw-tool-panel">${r}</button>`;
1420
1425
  }
1421
1426
  return `
1422
1427
  <div class="tbw-shell-header" part="shell-header" role="presentation">
@@ -1425,171 +1430,160 @@ function ye(t, e, o = "☰") {
1425
1430
  <slot name="header-content"></slot>
1426
1431
  </div>
1427
1432
  <div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">
1428
- ${b}
1433
+ ${h}
1429
1434
  </div>
1430
1435
  </div>
1431
1436
  `;
1432
1437
  }
1433
- function V(t, e) {
1438
+ function q(t, e) {
1434
1439
  const o = t.querySelector("tbw-grid-header");
1435
1440
  if (!o) return;
1436
1441
  if (!e.lightDomTitle) {
1437
- const r = o.getAttribute("title");
1438
- r && (e.lightDomTitle = r);
1442
+ const i = o.getAttribute("title");
1443
+ i && (e.lightDomTitle = i);
1439
1444
  }
1440
1445
  const n = o.querySelectorAll("tbw-grid-header-content");
1441
- n.length > 0 && e.lightDomHeaderContent.length === 0 && (e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((r) => {
1442
- r.setAttribute("slot", "header-content");
1443
- }));
1444
- const i = o.querySelectorAll("tbw-grid-tool-button"), l = o.querySelectorAll('button.tbw-toolbar-btn[slot="toolbar"]');
1445
- i.length > 0 && e.lightDomButtons.length === 0 ? (e.lightDomButtons = Array.from(i).map((r) => {
1446
- const s = document.createElement("button");
1447
- s.className = "tbw-toolbar-btn";
1448
- const a = r.getAttribute("id") ?? "", c = r.getAttribute("label") ?? "", h = r.getAttribute("icon") ?? "", d = r.getAttribute("order") ?? "100";
1449
- return s.setAttribute("data-btn", a), s.setAttribute("title", c), s.setAttribute("aria-label", c), s.setAttribute("data-order", d), s.textContent = h, s.setAttribute("slot", "toolbar"), r.replaceWith(s), s;
1450
- }), e.lightDomButtons.sort((r, s) => {
1451
- const a = parseInt(r.getAttribute("data-order") ?? "100", 10), c = parseInt(s.getAttribute("data-order") ?? "100", 10);
1452
- return a - c;
1453
- })) : l.length > 0 && e.lightDomButtons.length === 0 && (e.lightDomButtons = Array.from(l), e.lightDomButtons.sort((r, s) => {
1454
- const a = parseInt(r.getAttribute("data-order") ?? "100", 10), c = parseInt(s.getAttribute("data-order") ?? "100", 10);
1455
- return a - c;
1456
- })), e.lightDomButtons.forEach((r) => {
1457
- r.parentElement === o && t.appendChild(r);
1458
- }), o.style.display = "none";
1459
- }
1460
- function F(t, e, o) {
1446
+ n.length > 0 && e.lightDomHeaderContent.length === 0 && (e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((i) => {
1447
+ i.setAttribute("slot", "header-content");
1448
+ })), o.style.display = "none";
1449
+ }
1450
+ function W(t, e) {
1451
+ const o = t.querySelector(":scope > tbw-grid-tool-buttons");
1452
+ o && (e.hasToolButtonsContainer = !0, o.setAttribute("slot", "toolbar"));
1453
+ }
1454
+ function V(t, e, o) {
1461
1455
  t.querySelectorAll(":scope > tbw-grid-tool-panel").forEach((i) => {
1462
- const l = i, r = l.getAttribute("id"), s = l.getAttribute("title");
1463
- if (!r || !s) {
1456
+ const r = i, s = r.getAttribute("id"), l = r.getAttribute("title");
1457
+ if (!s || !l) {
1464
1458
  console.warn(
1465
- `[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${r ?? ""}", title="${s ?? ""}"`
1459
+ `[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${s ?? ""}", title="${l ?? ""}"`
1466
1460
  );
1467
1461
  return;
1468
1462
  }
1469
- const a = l.getAttribute("icon") ?? void 0, c = l.getAttribute("tooltip") ?? void 0, h = parseInt(l.getAttribute("order") ?? "100", 10);
1463
+ const a = r.getAttribute("icon") ?? void 0, c = r.getAttribute("tooltip") ?? void 0, f = parseInt(r.getAttribute("order") ?? "100", 10);
1470
1464
  let d;
1471
- const u = o?.(l);
1465
+ const u = o?.(r);
1472
1466
  if (u)
1473
1467
  d = u;
1474
1468
  else {
1475
- const b = l.innerHTML.trim();
1469
+ const p = r.innerHTML.trim();
1476
1470
  d = (g) => {
1477
- const w = document.createElement("div");
1478
- return w.innerHTML = b, g.appendChild(w), () => w.remove();
1471
+ const b = document.createElement("div");
1472
+ return b.innerHTML = p, g.appendChild(b), () => b.remove();
1479
1473
  };
1480
1474
  }
1481
- const p = e.toolPanels.get(r);
1482
- if (p) {
1475
+ const w = e.toolPanels.get(s);
1476
+ if (w) {
1483
1477
  if (u) {
1484
- p.render = d, p.order = h, p.icon = a, p.tooltip = c;
1485
- const b = e.panelCleanups.get(r);
1486
- b && (b(), e.panelCleanups.delete(r));
1478
+ w.render = d, w.order = f, w.icon = a, w.tooltip = c;
1479
+ const p = e.panelCleanups.get(s);
1480
+ p && (p(), e.panelCleanups.delete(s));
1487
1481
  }
1488
1482
  return;
1489
1483
  }
1490
- const f = {
1491
- id: r,
1492
- title: s,
1484
+ const h = {
1485
+ id: s,
1486
+ title: l,
1493
1487
  icon: a,
1494
1488
  tooltip: c,
1495
- order: h,
1489
+ order: f,
1496
1490
  render: d
1497
1491
  };
1498
- e.toolPanels.set(r, f), e.lightDomToolPanelIds.add(r), l.style.display = "none";
1492
+ e.toolPanels.set(s, h), e.lightDomToolPanelIds.add(s), r.style.display = "none";
1499
1493
  });
1500
1494
  }
1501
- function Bt(t, e, o, n) {
1495
+ function qt(t, e, o, n) {
1502
1496
  const i = t.querySelector(".tbw-shell-toolbar");
1503
- i && i.addEventListener("click", (r) => {
1504
- const s = r.target;
1505
- if (s.closest("[data-panel-toggle]")) {
1497
+ i && i.addEventListener("click", (s) => {
1498
+ const l = s.target;
1499
+ if (l.closest("[data-panel-toggle]")) {
1506
1500
  n.onPanelToggle();
1507
1501
  return;
1508
1502
  }
1509
- const c = s.closest("[data-btn]");
1503
+ const c = l.closest("[data-btn]");
1510
1504
  if (c) {
1511
- const h = c.getAttribute("data-btn");
1512
- h && n.onToolbarButtonClick(h);
1505
+ const f = c.getAttribute("data-btn");
1506
+ f && n.onToolbarButtonClick(f);
1513
1507
  }
1514
1508
  });
1515
- const l = t.querySelector(".tbw-accordion");
1516
- l && l.addEventListener("click", (r) => {
1517
- const a = r.target.closest(".tbw-accordion-header");
1509
+ const r = t.querySelector(".tbw-accordion");
1510
+ r && r.addEventListener("click", (s) => {
1511
+ const a = s.target.closest(".tbw-accordion-header");
1518
1512
  if (a) {
1519
- const h = a.closest("[data-section]")?.getAttribute("data-section");
1520
- h && n.onSectionToggle(h);
1513
+ const f = a.closest("[data-section]")?.getAttribute("data-section");
1514
+ f && n.onSectionToggle(f);
1521
1515
  }
1522
1516
  });
1523
1517
  }
1524
- function It(t, e, o) {
1525
- const n = t.querySelector(".tbw-tool-panel"), i = t.querySelector("[data-resize-handle]"), l = t.querySelector(".tbw-shell-body");
1526
- if (!n || !i || !l)
1518
+ function Wt(t, e, o) {
1519
+ const n = t.querySelector(".tbw-tool-panel"), i = t.querySelector("[data-resize-handle]"), r = t.querySelector(".tbw-shell-body");
1520
+ if (!n || !i || !r)
1527
1521
  return () => {
1528
1522
  };
1529
- const r = e?.toolPanel?.position ?? "right", s = 200;
1530
- let a = 0, c = 0, h = 0, d = !1;
1531
- const u = (b) => {
1523
+ const s = e?.toolPanel?.position ?? "right", l = 200;
1524
+ let a = 0, c = 0, f = 0, d = !1;
1525
+ const u = (p) => {
1532
1526
  if (!d) return;
1533
- b.preventDefault();
1534
- const g = r === "left" ? b.clientX - a : a - b.clientX, w = Math.min(h, Math.max(s, c + g));
1535
- n.style.width = `${w}px`;
1536
- }, p = () => {
1527
+ p.preventDefault();
1528
+ const g = s === "left" ? p.clientX - a : a - p.clientX, b = Math.min(f, Math.max(l, c + g));
1529
+ n.style.width = `${b}px`;
1530
+ }, w = () => {
1537
1531
  if (!d) return;
1538
1532
  d = !1, i.classList.remove("resizing"), n.style.transition = "", document.body.style.cursor = "", document.body.style.userSelect = "";
1539
- const b = n.getBoundingClientRect().width;
1540
- o(b), document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", p);
1541
- }, f = (b) => {
1542
- b.preventDefault(), d = !0, a = b.clientX, c = n.getBoundingClientRect().width, h = l.getBoundingClientRect().width - 20, i.classList.add("resizing"), n.style.transition = "none", document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", u), document.addEventListener("mouseup", p);
1533
+ const p = n.getBoundingClientRect().width;
1534
+ o(p), document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", w);
1535
+ }, h = (p) => {
1536
+ p.preventDefault(), d = !0, a = p.clientX, c = n.getBoundingClientRect().width, f = r.getBoundingClientRect().width - 20, i.classList.add("resizing"), n.style.transition = "none", document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", u), document.addEventListener("mouseup", w);
1543
1537
  };
1544
- return i.addEventListener("mousedown", f), () => {
1545
- i.removeEventListener("mousedown", f), document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", p);
1538
+ return i.addEventListener("mousedown", h), () => {
1539
+ i.removeEventListener("mousedown", h), document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", w);
1546
1540
  };
1547
1541
  }
1548
- function qt(t, e, o) {
1542
+ function Vt(t, e, o) {
1549
1543
  const n = [...e?.header?.toolbarButtons ?? [], ...o.toolbarButtons.values()];
1550
1544
  for (const i of n) {
1551
- const l = t.querySelector(`[data-btn-slot="${i.id}"]`);
1552
- if (!l) continue;
1553
- const r = o.toolbarButtonCleanups.get(i.id);
1554
- if (r && (r(), o.toolbarButtonCleanups.delete(i.id)), i.element)
1555
- l.appendChild(i.element);
1545
+ const r = t.querySelector(`[data-btn-slot="${i.id}"]`);
1546
+ if (!r) continue;
1547
+ const s = o.toolbarButtonCleanups.get(i.id);
1548
+ if (s && (s(), o.toolbarButtonCleanups.delete(i.id)), i.element)
1549
+ r.appendChild(i.element);
1556
1550
  else if (i.render) {
1557
- const s = i.render(l);
1558
- s && o.toolbarButtonCleanups.set(i.id, s);
1551
+ const l = i.render(r);
1552
+ l && o.toolbarButtonCleanups.set(i.id, l);
1559
1553
  }
1560
1554
  }
1561
1555
  }
1562
- function qe(t, e) {
1556
+ function Ve(t, e) {
1563
1557
  const o = t.querySelector(".tbw-shell-content");
1564
1558
  if (!o) return;
1565
- const n = [...e.headerContents.values()].sort((l, r) => (l.order ?? 100) - (r.order ?? 100)), i = o.querySelector('slot[name="header-content"]');
1566
- for (const l of n) {
1567
- const r = e.headerContentCleanups.get(l.id);
1568
- r && (r(), e.headerContentCleanups.delete(l.id));
1569
- let s = o.querySelector(`[data-header-content="${l.id}"]`);
1570
- s || (s = document.createElement("div"), s.setAttribute("data-header-content", l.id), i ? o.insertBefore(s, i) : o.appendChild(s));
1571
- const a = l.render(s);
1572
- a && e.headerContentCleanups.set(l.id, a);
1559
+ const n = [...e.headerContents.values()].sort((r, s) => (r.order ?? 100) - (s.order ?? 100)), i = o.querySelector('slot[name="header-content"]');
1560
+ for (const r of n) {
1561
+ const s = e.headerContentCleanups.get(r.id);
1562
+ s && (s(), e.headerContentCleanups.delete(r.id));
1563
+ let l = o.querySelector(`[data-header-content="${r.id}"]`);
1564
+ l || (l = document.createElement("div"), l.setAttribute("data-header-content", r.id), i ? o.insertBefore(l, i) : o.appendChild(l));
1565
+ const a = r.render(l);
1566
+ a && e.headerContentCleanups.set(r.id, a);
1573
1567
  }
1574
1568
  }
1575
- function Wt(t, e, o) {
1569
+ function $t(t, e, o) {
1576
1570
  if (!e.isPanelOpen) return;
1577
- const n = M(o?.expand ?? O.expand), i = M(o?.collapse ?? O.collapse);
1578
- for (const [l, r] of e.toolPanels) {
1579
- const s = e.expandedSections.has(l), a = t.querySelector(`[data-section="${l}"]`), c = a?.querySelector(".tbw-accordion-content");
1571
+ const n = N(o?.expand ?? O.expand), i = N(o?.collapse ?? O.collapse);
1572
+ for (const [r, s] of e.toolPanels) {
1573
+ const l = e.expandedSections.has(r), a = t.querySelector(`[data-section="${r}"]`), c = a?.querySelector(".tbw-accordion-content");
1580
1574
  if (!a || !c) continue;
1581
- a.classList.toggle("expanded", s);
1582
- const h = a.querySelector(".tbw-accordion-header");
1583
- h && h.setAttribute("aria-expanded", String(s));
1575
+ a.classList.toggle("expanded", l);
1576
+ const f = a.querySelector(".tbw-accordion-header");
1577
+ f && f.setAttribute("aria-expanded", String(l));
1584
1578
  const d = a.querySelector(".tbw-accordion-chevron");
1585
- if (d && (d.innerHTML = s ? i : n), s) {
1579
+ if (d && (d.innerHTML = l ? i : n), l) {
1586
1580
  if (c.children.length === 0) {
1587
- const u = r.render(c);
1588
- u && e.panelCleanups.set(l, u);
1581
+ const u = s.render(c);
1582
+ u && e.panelCleanups.set(r, u);
1589
1583
  }
1590
1584
  } else {
1591
- const u = e.panelCleanups.get(l);
1592
- u && (u(), e.panelCleanups.delete(l)), c.innerHTML = "";
1585
+ const u = e.panelCleanups.get(r);
1586
+ u && (u(), e.panelCleanups.delete(r)), c.innerHTML = "";
1593
1587
  }
1594
1588
  }
1595
1589
  }
@@ -1601,50 +1595,44 @@ function Re(t, e) {
1601
1595
  const o = t.querySelector(".tbw-tool-panel");
1602
1596
  o && (o.classList.toggle("open", e.isPanelOpen), e.isPanelOpen || (o.style.width = ""));
1603
1597
  }
1604
- function $t(t, e) {
1598
+ function Ft(t, e) {
1605
1599
  const o = [];
1606
1600
  for (const n of t?.header?.toolbarButtons ?? [])
1607
1601
  o.push({
1608
1602
  id: n.id,
1609
- label: n.label,
1610
- disabled: n.disabled ?? !1,
1603
+ label: n.label ?? "",
1611
1604
  source: "config"
1612
1605
  });
1613
1606
  for (const n of e.toolbarButtons.values())
1614
1607
  o.push({
1615
1608
  id: n.id,
1616
- label: n.label,
1617
- disabled: n.disabled ?? !1,
1609
+ label: n.label ?? "",
1618
1610
  source: "config"
1619
1611
  });
1620
- for (let n = 0; n < e.lightDomButtons.length; n++) {
1621
- const l = e.lightDomButtons[n].querySelector("button");
1622
- o.push({
1623
- id: `light-dom-${n}`,
1624
- label: l?.getAttribute("title") ?? l?.getAttribute("aria-label") ?? "",
1625
- disabled: l?.disabled ?? !1,
1626
- source: "light-dom"
1627
- });
1628
- }
1629
1612
  for (const n of e.toolPanels.values())
1630
1613
  o.push({
1631
1614
  id: `panel-toggle-${n.id}`,
1632
1615
  label: n.tooltip ?? n.title,
1633
- disabled: !1,
1634
1616
  source: "panel-toggle",
1635
1617
  panelId: n.id
1636
1618
  });
1637
1619
  return o;
1638
1620
  }
1639
- function Vt(t) {
1621
+ function Gt(t) {
1640
1622
  for (const e of t.headerContentCleanups.values())
1641
1623
  e();
1642
- t.headerContentCleanups.clear(), t.activePanelCleanup && (t.activePanelCleanup(), t.activePanelCleanup = null);
1624
+ t.headerContentCleanups.clear();
1625
+ for (const e of t.panelCleanups.values())
1626
+ e();
1627
+ t.panelCleanups.clear();
1643
1628
  for (const e of t.toolbarButtonCleanups.values())
1644
1629
  e();
1645
- t.toolbarButtonCleanups.clear(), t.activePanel && t.toolPanels.get(t.activePanel)?.onClose?.(), t.toolPanels.clear(), t.headerContents.clear(), t.toolbarButtons.clear(), t.lightDomButtons = [], t.lightDomHeaderContent = [], t.activePanel = null;
1630
+ if (t.toolbarButtonCleanups.clear(), t.isPanelOpen)
1631
+ for (const e of t.expandedSections)
1632
+ t.toolPanels.get(e)?.onClose?.();
1633
+ t.isPanelOpen = !1, t.expandedSections.clear(), t.toolPanels.clear(), t.headerContents.clear(), t.toolbarButtons.clear(), t.lightDomHeaderContent = [];
1646
1634
  }
1647
- function Ft(t, e) {
1635
+ function Ut(t, e) {
1648
1636
  let o = !1;
1649
1637
  const n = {
1650
1638
  get isInitialized() {
@@ -1669,19 +1657,19 @@ function Ft(t, e) {
1669
1657
  return;
1670
1658
  }
1671
1659
  if (t.isPanelOpen = !0, t.expandedSections.size === 0 && t.toolPanels.size > 0) {
1672
- const r = [...t.toolPanels.values()].sort((s, a) => (s.order ?? 100) - (a.order ?? 100))[0];
1673
- r && t.expandedSections.add(r.id);
1660
+ const s = [...t.toolPanels.values()].sort((l, a) => (l.order ?? 100) - (a.order ?? 100))[0];
1661
+ s && t.expandedSections.add(s.id);
1674
1662
  }
1675
1663
  const i = e.getShadow();
1676
- Se(i, t), Re(i, t), Wt(i, t, e.getAccordionIcons()), e.emit("tool-panel-open", { sections: n.expandedSections });
1664
+ Se(i, t), Re(i, t), $t(i, t, e.getAccordionIcons()), e.emit("tool-panel-open", { sections: n.expandedSections });
1677
1665
  },
1678
1666
  closeToolPanel() {
1679
1667
  if (!t.isPanelOpen) return;
1680
- for (const l of t.panelCleanups.values())
1681
- l();
1682
- t.panelCleanups.clear(), t.activePanelCleanup && (t.activePanelCleanup(), t.activePanelCleanup = null);
1683
- for (const l of t.toolPanels.values())
1684
- l.onClose?.();
1668
+ for (const r of t.panelCleanups.values())
1669
+ r();
1670
+ t.panelCleanups.clear();
1671
+ for (const r of t.toolPanels.values())
1672
+ r.onClose?.();
1685
1673
  t.isPanelOpen = !1;
1686
1674
  const i = e.getShadow();
1687
1675
  Se(i, t), Re(i, t), e.emit("tool-panel-close", {});
@@ -1690,28 +1678,28 @@ function Ft(t, e) {
1690
1678
  t.isPanelOpen ? n.closeToolPanel() : n.openToolPanel();
1691
1679
  },
1692
1680
  toggleToolPanelSection(i) {
1693
- const l = t.toolPanels.get(i);
1694
- if (!l) {
1681
+ const r = t.toolPanels.get(i);
1682
+ if (!r) {
1695
1683
  console.warn(`[tbw-grid] Tool panel section "${i}" not found`);
1696
1684
  return;
1697
1685
  }
1698
1686
  if (t.toolPanels.size === 1)
1699
1687
  return;
1700
- const r = e.getShadow(), s = t.expandedSections.has(i);
1701
- if (s) {
1688
+ const s = e.getShadow(), l = t.expandedSections.has(i);
1689
+ if (l) {
1702
1690
  const a = t.panelCleanups.get(i);
1703
- a && (a(), t.panelCleanups.delete(i)), l.onClose?.(), t.expandedSections.delete(i), ne(r, i, !1);
1691
+ a && (a(), t.panelCleanups.delete(i)), r.onClose?.(), t.expandedSections.delete(i), ie(s, i, !1);
1704
1692
  } else {
1705
1693
  for (const [a, c] of t.toolPanels)
1706
1694
  if (a !== i && t.expandedSections.has(a)) {
1707
- const h = t.panelCleanups.get(a);
1708
- h && (h(), t.panelCleanups.delete(a)), c.onClose?.(), t.expandedSections.delete(a), ne(r, a, !1);
1709
- const d = r.querySelector(`[data-section="${a}"] .tbw-accordion-content`);
1695
+ const f = t.panelCleanups.get(a);
1696
+ f && (f(), t.panelCleanups.delete(a)), c.onClose?.(), t.expandedSections.delete(a), ie(s, a, !1);
1697
+ const d = s.querySelector(`[data-section="${a}"] .tbw-accordion-content`);
1710
1698
  d && (d.innerHTML = "");
1711
1699
  }
1712
- t.expandedSections.add(i), ne(r, i, !0), Gt(r, t, i);
1700
+ t.expandedSections.add(i), ie(s, i, !0), Xt(s, t, i);
1713
1701
  }
1714
- e.emit("tool-panel-section-toggle", { id: i, expanded: !s });
1702
+ e.emit("tool-panel-section-toggle", { id: i, expanded: !l });
1715
1703
  },
1716
1704
  getToolPanels() {
1717
1705
  return [...t.toolPanels.values()];
@@ -1725,8 +1713,8 @@ function Ft(t, e) {
1725
1713
  },
1726
1714
  unregisterToolPanel(i) {
1727
1715
  if (t.expandedSections.has(i)) {
1728
- const l = t.panelCleanups.get(i);
1729
- l && (l(), t.panelCleanups.delete(i)), t.expandedSections.delete(i);
1716
+ const r = t.panelCleanups.get(i);
1717
+ r && (r(), t.panelCleanups.delete(i)), t.expandedSections.delete(i);
1730
1718
  }
1731
1719
  t.toolPanels.delete(i), o && e.refreshShellHeader();
1732
1720
  },
@@ -1738,14 +1726,14 @@ function Ft(t, e) {
1738
1726
  console.warn(`[tbw-grid] Header content "${i.id}" already registered`);
1739
1727
  return;
1740
1728
  }
1741
- t.headerContents.set(i.id, i), o && qe(e.getShadow(), t);
1729
+ t.headerContents.set(i.id, i), o && Ve(e.getShadow(), t);
1742
1730
  },
1743
1731
  unregisterHeaderContent(i) {
1744
- const l = t.headerContentCleanups.get(i);
1745
- l && (l(), t.headerContentCleanups.delete(i)), t.headerContents.get(i)?.onDestroy?.(), t.headerContents.delete(i), e.getShadow().querySelector(`[data-header-content="${i}"]`)?.remove();
1732
+ const r = t.headerContentCleanups.get(i);
1733
+ r && (r(), t.headerContentCleanups.delete(i)), t.headerContents.get(i)?.onDestroy?.(), t.headerContents.delete(i), e.getShadow().querySelector(`[data-header-content="${i}"]`)?.remove();
1746
1734
  },
1747
1735
  getToolbarButtons() {
1748
- return $t(e.getShellConfig(), t);
1736
+ return Ft(e.getShellConfig(), t);
1749
1737
  },
1750
1738
  registerToolbarButton(i) {
1751
1739
  if (t.toolbarButtons.has(i.id)) {
@@ -1755,81 +1743,74 @@ function Ft(t, e) {
1755
1743
  t.toolbarButtons.set(i.id, i), o && e.refreshShellHeader();
1756
1744
  },
1757
1745
  unregisterToolbarButton(i) {
1758
- const l = t.toolbarButtonCleanups.get(i);
1759
- l && (l(), t.toolbarButtonCleanups.delete(i)), t.toolbarButtons.delete(i), o && e.refreshShellHeader();
1746
+ const r = t.toolbarButtonCleanups.get(i);
1747
+ r && (r(), t.toolbarButtonCleanups.delete(i)), t.toolbarButtons.delete(i), o && e.refreshShellHeader();
1760
1748
  },
1761
- setToolbarButtonDisabled(i, l) {
1762
- const r = t.toolbarButtons.get(i);
1763
- r && (r.disabled = l);
1764
- const s = e.getShadow().querySelector(`[data-btn="${i}"]`);
1765
- s && (s.disabled = l);
1749
+ /**
1750
+ * Note: Toolbar button disabled state is now managed by the user.
1751
+ * This method is kept for backward compatibility but is a no-op.
1752
+ * Users should control their button's disabled state directly in their HTML.
1753
+ */
1754
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1755
+ setToolbarButtonDisabled(i, r) {
1766
1756
  }
1767
1757
  };
1768
1758
  return n;
1769
1759
  }
1770
- function ne(t, e, o) {
1760
+ function ie(t, e, o) {
1771
1761
  const n = t.querySelector(`[data-section="${e}"]`);
1772
1762
  n && n.classList.toggle("expanded", o);
1773
1763
  }
1774
- function Gt(t, e, o) {
1764
+ function Xt(t, e, o) {
1775
1765
  const n = e.toolPanels.get(o);
1776
1766
  if (!n?.render) return;
1777
1767
  const i = t.querySelector(`[data-section="${o}"] .tbw-accordion-content`);
1778
1768
  if (!i) return;
1779
- const l = n.render(i);
1780
- l && e.panelCleanups.set(o, l);
1769
+ const r = n.render(i);
1770
+ r && e.panelCleanups.set(o, r);
1781
1771
  }
1782
- function Ut(t, e, o, n) {
1783
- const i = se(e, o);
1772
+ function Yt(t, e, o, n) {
1773
+ const i = We(e, o);
1784
1774
  if (t.replaceChildren(), i) {
1785
- const l = M(n?.toolPanel ?? O.toolPanel), r = M(n?.expand ?? O.expand), s = M(n?.collapse ?? O.collapse), c = [...e?.header?.toolbarButtons ?? []].sort((w, _) => (w.order ?? 100) - (_.order ?? 100)), h = [...o.toolbarButtons.values()].sort((w, _) => (w.order ?? 100) - (_.order ?? 100)), d = {
1775
+ const r = N(n?.toolPanel ?? O.toolPanel), s = N(n?.expand ?? O.expand), l = N(n?.collapse ?? O.collapse), c = [...e?.header?.toolbarButtons ?? []].sort((b, _) => (b.order ?? 100) - (_.order ?? 100)), f = [...o.toolbarButtons.values()].sort((b, _) => (b.order ?? 100) - (_.order ?? 100)), d = {
1786
1776
  title: e?.header?.title ?? o.lightDomTitle ?? void 0,
1787
- hasLightDomButtons: o.lightDomButtons.length > 0,
1788
1777
  hasPanels: o.toolPanels.size > 0,
1789
1778
  isPanelOpen: o.isPanelOpen,
1790
- toolPanelIcon: l,
1791
- configButtons: c.map((w) => ({
1792
- id: w.id,
1793
- label: w.label,
1794
- icon: M(w.icon),
1795
- disabled: w.disabled,
1796
- hasElement: !!w.element,
1797
- hasRender: !!w.render,
1798
- action: w.action
1779
+ toolPanelIcon: r,
1780
+ configButtons: c.map((b) => ({
1781
+ id: b.id,
1782
+ hasElement: !!b.element,
1783
+ hasRender: !!b.render
1799
1784
  })),
1800
- apiButtons: h.map((w) => ({
1801
- id: w.id,
1802
- label: w.label,
1803
- icon: M(w.icon),
1804
- disabled: w.disabled,
1805
- hasElement: !!w.element,
1806
- hasRender: !!w.render,
1807
- action: w.action
1785
+ apiButtons: f.map((b) => ({
1786
+ id: b.id,
1787
+ hasElement: !!b.element,
1788
+ hasRender: !!b.render
1808
1789
  }))
1809
- }, u = [...o.toolPanels.values()].sort((w, _) => (w.order ?? 100) - (_.order ?? 100)), p = {
1790
+ }, u = [...o.toolPanels.values()].sort((b, _) => (b.order ?? 100) - (_.order ?? 100)), w = {
1810
1791
  position: e?.toolPanel?.position ?? "right",
1811
1792
  isPanelOpen: o.isPanelOpen,
1812
- expandIcon: r,
1813
- collapseIcon: s,
1814
- panels: u.map((w) => ({
1815
- id: w.id,
1816
- title: w.title,
1817
- icon: M(w.icon),
1818
- isExpanded: o.expandedSections.has(w.id)
1793
+ expandIcon: s,
1794
+ collapseIcon: l,
1795
+ panels: u.map((b) => ({
1796
+ id: b.id,
1797
+ title: b.title,
1798
+ icon: N(b.icon),
1799
+ isExpanded: o.expandedSections.has(b.id)
1819
1800
  }))
1820
- }, f = Dt(d), b = zt(p), g = Ee({
1801
+ }, h = Nt(d), p = It(w), g = Ee({
1821
1802
  hasShell: !0,
1822
- shellHeader: f,
1823
- shellBody: b
1803
+ shellHeader: h,
1804
+ shellBody: p
1824
1805
  });
1825
1806
  t.appendChild(g);
1826
1807
  } else {
1827
- const l = Ee({ hasShell: !1 });
1828
- t.appendChild(l);
1808
+ const r = Ee({ hasShell: !1 });
1809
+ t.appendChild(r);
1829
1810
  }
1830
1811
  return i;
1831
1812
  }
1832
- function Xt() {
1813
+ function jt() {
1833
1814
  return {
1834
1815
  startY: null,
1835
1816
  startX: null,
@@ -1843,59 +1824,59 @@ function Xt() {
1843
1824
  momentumRaf: 0
1844
1825
  };
1845
1826
  }
1846
- function Yt(t) {
1827
+ function Kt(t) {
1847
1828
  t.startY = null, t.startX = null, t.scrollTop = null, t.scrollLeft = null, t.lastY = null, t.lastX = null, t.lastTime = null;
1848
1829
  }
1849
- function We(t) {
1830
+ function $e(t) {
1850
1831
  t.momentumRaf && (cancelAnimationFrame(t.momentumRaf), t.momentumRaf = 0);
1851
1832
  }
1852
- function jt(t, e, o) {
1833
+ function Zt(t, e, o) {
1853
1834
  if (t.touches.length !== 1) return;
1854
- We(e);
1835
+ $e(e);
1855
1836
  const n = t.touches[0];
1856
1837
  e.startY = n.clientY, e.startX = n.clientX, e.lastY = n.clientY, e.lastX = n.clientX, e.lastTime = performance.now(), e.scrollTop = o.fauxScrollbar.scrollTop, e.scrollLeft = o.scrollArea?.scrollLeft ?? 0, e.velocityY = 0, e.velocityX = 0;
1857
1838
  }
1858
- function Kt(t, e, o) {
1839
+ function Jt(t, e, o) {
1859
1840
  if (t.touches.length !== 1 || e.startY === null || e.startX === null || e.scrollTop === null || e.scrollLeft === null)
1860
1841
  return !1;
1861
- const n = t.touches[0], i = n.clientY, l = n.clientX, r = performance.now(), s = e.startY - i, a = e.startX - l;
1842
+ const n = t.touches[0], i = n.clientY, r = n.clientX, s = performance.now(), l = e.startY - i, a = e.startX - r;
1862
1843
  if (e.lastTime !== null && e.lastY !== null && e.lastX !== null) {
1863
- const b = r - e.lastTime;
1864
- b > 0 && (e.velocityY = (e.lastY - i) / b, e.velocityX = (e.lastX - l) / b);
1844
+ const p = s - e.lastTime;
1845
+ p > 0 && (e.velocityY = (e.lastY - i) / p, e.velocityX = (e.lastX - r) / p);
1865
1846
  }
1866
- e.lastY = i, e.lastX = l, e.lastTime = r;
1867
- const { scrollTop: c, scrollHeight: h, clientHeight: d } = o.fauxScrollbar, u = h - d, p = s > 0 && c < u || s < 0 && c > 0;
1868
- let f = !1;
1847
+ e.lastY = i, e.lastX = r, e.lastTime = s;
1848
+ const { scrollTop: c, scrollHeight: f, clientHeight: d } = o.fauxScrollbar, u = f - d, w = l > 0 && c < u || l < 0 && c > 0;
1849
+ let h = !1;
1869
1850
  if (o.scrollArea) {
1870
- const { scrollLeft: b, scrollWidth: g, clientWidth: w } = o.scrollArea, _ = g - w;
1871
- f = a > 0 && b < _ || a < 0 && b > 0;
1851
+ const { scrollLeft: p, scrollWidth: g, clientWidth: b } = o.scrollArea, _ = g - b;
1852
+ h = a > 0 && p < _ || a < 0 && p > 0;
1872
1853
  }
1873
- return p && (o.fauxScrollbar.scrollTop = e.scrollTop + s), f && o.scrollArea && (o.scrollArea.scrollLeft = e.scrollLeft + a), p || f;
1854
+ return w && (o.fauxScrollbar.scrollTop = e.scrollTop + l), h && o.scrollArea && (o.scrollArea.scrollLeft = e.scrollLeft + a), w || h;
1874
1855
  }
1875
- function Zt(t, e) {
1876
- (Math.abs(t.velocityY) > 0.1 || Math.abs(t.velocityX) > 0.1) && Jt(t, e), Yt(t);
1856
+ function Qt(t, e) {
1857
+ (Math.abs(t.velocityY) > 0.1 || Math.abs(t.velocityX) > 0.1) && eo(t, e), Kt(t);
1877
1858
  }
1878
- function Jt(t, e) {
1859
+ function eo(t, e) {
1879
1860
  const i = () => {
1880
1861
  t.velocityY *= 0.95, t.velocityX *= 0.95;
1881
- const l = t.velocityY * 16, r = t.velocityX * 16;
1882
- Math.abs(t.velocityY) > 0.01 && (e.fauxScrollbar.scrollTop += l), Math.abs(t.velocityX) > 0.01 && e.scrollArea && (e.scrollArea.scrollLeft += r), Math.abs(t.velocityY) > 0.01 || Math.abs(t.velocityX) > 0.01 ? t.momentumRaf = requestAnimationFrame(i) : t.momentumRaf = 0;
1862
+ const r = t.velocityY * 16, s = t.velocityX * 16;
1863
+ Math.abs(t.velocityY) > 0.01 && (e.fauxScrollbar.scrollTop += r), Math.abs(t.velocityX) > 0.01 && e.scrollArea && (e.scrollArea.scrollLeft += s), Math.abs(t.velocityY) > 0.01 || Math.abs(t.velocityX) > 0.01 ? t.momentumRaf = requestAnimationFrame(i) : t.momentumRaf = 0;
1883
1864
  };
1884
1865
  t.momentumRaf = requestAnimationFrame(i);
1885
1866
  }
1886
- function Qt(t, e, o, n) {
1887
- t.addEventListener("touchstart", (i) => jt(i, e, o), {
1867
+ function to(t, e, o, n) {
1868
+ t.addEventListener("touchstart", (i) => Zt(i, e, o), {
1888
1869
  passive: !0,
1889
1870
  signal: n
1890
1871
  }), t.addEventListener(
1891
1872
  "touchmove",
1892
1873
  (i) => {
1893
- Kt(i, e, o) && i.preventDefault();
1874
+ Jt(i, e, o) && i.preventDefault();
1894
1875
  },
1895
1876
  { passive: !1, signal: n }
1896
- ), t.addEventListener("touchend", () => Zt(e, o), { passive: !0, signal: n });
1877
+ ), t.addEventListener("touchend", () => Qt(e, o), { passive: !0, signal: n });
1897
1878
  }
1898
- class eo {
1879
+ class oo {
1899
1880
  constructor(e) {
1900
1881
  this.grid = e;
1901
1882
  }
@@ -2055,10 +2036,10 @@ class eo {
2055
2036
  */
2056
2037
  adjustVirtualStart(e, o, n) {
2057
2038
  let i = e;
2058
- for (const l of this.plugins)
2059
- if (typeof l.adjustVirtualStart == "function") {
2060
- const r = l.adjustVirtualStart(e, o, n);
2061
- r < i && (i = r);
2039
+ for (const r of this.plugins)
2040
+ if (typeof r.adjustVirtualStart == "function") {
2041
+ const s = r.adjustVirtualStart(e, o, n);
2042
+ s < i && (i = s);
2062
2043
  }
2063
2044
  return i;
2064
2045
  }
@@ -2177,12 +2158,12 @@ class eo {
2177
2158
  * @returns Combined left and right pixel offsets, plus skipScroll if any plugin requests it
2178
2159
  */
2179
2160
  getHorizontalScrollOffsets(e, o) {
2180
- let n = 0, i = 0, l = !1;
2181
- for (const r of this.plugins) {
2182
- const s = r.getHorizontalScrollOffsets?.(e, o);
2183
- s && (n += s.left, i += s.right, s.skipScroll && (l = !0));
2161
+ let n = 0, i = 0, r = !1;
2162
+ for (const s of this.plugins) {
2163
+ const l = s.getHorizontalScrollOffsets?.(e, o);
2164
+ l && (n += l.left, i += l.right, l.skipScroll && (r = !0));
2184
2165
  }
2185
- return { left: n, right: i, skipScroll: l };
2166
+ return { left: n, right: i, skipScroll: r };
2186
2167
  }
2187
2168
  // #endregion
2188
2169
  // #region Shell Integration Hooks
@@ -2212,10 +2193,10 @@ class eo {
2212
2193
  }
2213
2194
  // #endregion
2214
2195
  }
2215
- class N extends HTMLElement {
2196
+ class I extends HTMLElement {
2216
2197
  // TODO: Rename to 'data-grid' when migration is complete
2217
2198
  static tagName = "tbw-grid";
2218
- static version = "0.3.0";
2199
+ static version = "0.3.2";
2219
2200
  // ---------------- Framework Adapters ----------------
2220
2201
  /**
2221
2202
  * Registry of framework adapters that handle converting light DOM elements
@@ -2257,53 +2238,55 @@ class N extends HTMLElement {
2257
2238
  return ["rows", "columns", "grid-config", "fit-mode", "edit-on"];
2258
2239
  }
2259
2240
  #n;
2260
- #M = !1;
2241
+ #H = !1;
2261
2242
  // ---------------- Ready Promise ----------------
2262
- #U;
2263
- #X;
2243
+ #Y;
2244
+ #j;
2264
2245
  // #region Input Properties
2265
2246
  // These backing fields store raw user input. They are merged into
2266
2247
  // #effectiveConfig by #mergeEffectiveConfig(). Never read directly
2267
2248
  // for rendering logic - always use effectiveConfig or derived state.
2268
- #r = [];
2249
+ #s = [];
2269
2250
  #c;
2270
2251
  #g;
2252
+ #E;
2271
2253
  #y;
2272
- #S;
2273
2254
  // #endregion
2274
2255
  // #region Private properties
2275
2256
  // All input sources converge here. This is the canonical config
2276
2257
  // that all rendering and logic should read from.
2277
- #t = {};
2278
- #O = !1;
2258
+ #o = {};
2259
+ #M = !1;
2279
2260
  // ---------------- Batched Updates ----------------
2280
2261
  // When multiple properties are set in rapid succession (within same microtask),
2281
2262
  // we batch them into a single update to avoid redundant re-renders.
2282
2263
  #m = !1;
2283
- #k = {
2264
+ #O = {
2284
2265
  rows: !1,
2285
2266
  columns: !1,
2286
2267
  gridConfig: !1,
2287
2268
  fitMode: !1,
2288
2269
  editMode: !1
2289
2270
  };
2290
- #p = 0;
2291
- #R = null;
2292
- #A = !1;
2271
+ #f = 0;
2272
+ #S = null;
2273
+ #R = !1;
2293
2274
  // Cached flag for plugin scroll handlers
2294
- #D;
2275
+ #k;
2295
2276
  // Cached hook to avoid closures
2296
2277
  #T = !1;
2297
- #Y = Xt();
2298
- #s;
2299
- #b;
2278
+ #K = jt();
2279
+ #l;
2280
+ #p;
2300
2281
  #w;
2301
2282
  // Watches first row for size changes (CSS loading, custom renderers)
2283
+ #D = 0;
2284
+ // RAF handle for debounced refreshColumns
2285
+ #d;
2302
2286
  #u;
2303
- #h;
2304
2287
  // Handle for cancelling deferred idle work
2305
2288
  // Pooled scroll event object (reused to avoid GC pressure during scroll)
2306
- #te = {
2289
+ #re = {
2307
2290
  scrollTop: 0,
2308
2291
  scrollLeft: 0,
2309
2292
  scrollHeight: 0,
@@ -2312,7 +2295,7 @@ class N extends HTMLElement {
2312
2295
  clientWidth: 0
2313
2296
  };
2314
2297
  // ---------------- Plugin System ----------------
2315
- #e;
2298
+ #t;
2316
2299
  // ---------------- Event Listeners ----------------
2317
2300
  #x = !1;
2318
2301
  // Guard against adding duplicate component-level listeners
@@ -2320,11 +2303,11 @@ class N extends HTMLElement {
2320
2303
  // Separate controller for DOM scroll listeners (recreated on DOM changes)
2321
2304
  // ---------------- Column State ----------------
2322
2305
  #z;
2323
- #f;
2306
+ #h;
2324
2307
  // ---------------- Shell State ----------------
2325
- #o = Nt();
2308
+ #e = Bt();
2326
2309
  #i;
2327
- #L;
2310
+ #A;
2328
2311
  // #endregion
2329
2312
  // #region Derived State
2330
2313
  // _rows: result of applying plugin processRows hooks
@@ -2336,10 +2319,10 @@ class N extends HTMLElement {
2336
2319
  // This ensures effectiveConfig.columns is the single source of truth for columns
2337
2320
  // _columns always contains ALL columns (including hidden)
2338
2321
  get _columns() {
2339
- return this.#t.columns ?? [];
2322
+ return this.#o.columns ?? [];
2340
2323
  }
2341
2324
  set _columns(e) {
2342
- this.#t.columns = e;
2325
+ this.#o.columns = e;
2343
2326
  }
2344
2327
  // visibleColumns returns only visible columns for rendering
2345
2328
  // This is what header/row rendering should use
@@ -2384,8 +2367,6 @@ class N extends HTMLElement {
2384
2367
  __originalOrder = [];
2385
2368
  // Cached DOM refs for hot path (refreshVirtualWindow) - avoid querySelector per scroll
2386
2369
  __rowsBodyEl = null;
2387
- __scrollAreaEl = null;
2388
- __footerEl = null;
2389
2370
  // #endregion
2390
2371
  // #region Public API Props (getters/setters)
2391
2372
  // Getters return the EFFECTIVE value (after merging), not the raw input.
@@ -2395,43 +2376,43 @@ class N extends HTMLElement {
2395
2376
  return this._rows;
2396
2377
  }
2397
2378
  set rows(e) {
2398
- const o = this.#r;
2399
- this.#r = e, o !== e && this.#C("rows");
2379
+ const o = this.#s;
2380
+ this.#s = e, o !== e && this.#_("rows");
2400
2381
  }
2401
2382
  /**
2402
2383
  * Get the original unfiltered/unprocessed rows.
2403
2384
  * Use this when you need access to all source data regardless of active filters.
2404
2385
  */
2405
2386
  get sourceRows() {
2406
- return this.#r;
2387
+ return this.#s;
2407
2388
  }
2408
2389
  get columns() {
2409
2390
  return [...this._columns];
2410
2391
  }
2411
2392
  set columns(e) {
2412
2393
  const o = this.#c;
2413
- this.#c = e, o !== e && this.#C("columns");
2394
+ this.#c = e, o !== e && this.#_("columns");
2414
2395
  }
2415
2396
  get gridConfig() {
2416
- return this.#t;
2397
+ return this.#o;
2417
2398
  }
2418
2399
  set gridConfig(e) {
2419
2400
  const o = this.#g;
2420
- this.#g = e, o !== e && (this.__lightDomColumnsCache = void 0, this.#C("gridConfig"));
2401
+ this.#g = e, o !== e && (this.__lightDomColumnsCache = void 0, this.#_("gridConfig"));
2421
2402
  }
2422
2403
  get fitMode() {
2423
- return this.#t.fitMode ?? "stretch";
2404
+ return this.#o.fitMode ?? "stretch";
2424
2405
  }
2425
2406
  set fitMode(e) {
2426
- const o = this.#y;
2427
- this.#y = e, o !== e && this.#C("fitMode");
2407
+ const o = this.#E;
2408
+ this.#E = e, o !== e && this.#_("fitMode");
2428
2409
  }
2429
2410
  get editOn() {
2430
- return this.#t.editOn;
2411
+ return this.#o.editOn;
2431
2412
  }
2432
2413
  set editOn(e) {
2433
- const o = this.#S;
2434
- this.#S = e, o !== e && this.#C("editMode");
2414
+ const o = this.#y;
2415
+ this.#y = e, o !== e && this.#_("editMode");
2435
2416
  }
2436
2417
  /**
2437
2418
  * Effective config accessor for internal modules and plugins.
@@ -2440,7 +2421,7 @@ class N extends HTMLElement {
2440
2421
  * @internal Plugin API
2441
2422
  */
2442
2423
  get effectiveConfig() {
2443
- return this.#t;
2424
+ return this.#o;
2444
2425
  }
2445
2426
  /**
2446
2427
  * Get the disconnect signal for event listener cleanup.
@@ -2451,22 +2432,22 @@ class N extends HTMLElement {
2451
2432
  * element.addEventListener('click', handler, { signal: this.grid.disconnectSignal });
2452
2433
  */
2453
2434
  get disconnectSignal() {
2454
- return this.#s || (this.#s = new AbortController()), this.#s.signal;
2435
+ return this.#l || (this.#l = new AbortController()), this.#l.signal;
2455
2436
  }
2456
2437
  // #endregion
2457
2438
  constructor() {
2458
- super(), this.#n = this.attachShadow({ mode: "open" }), this.#oe(), this.#U = new Promise((e) => this.#X = e), this.#i = Ft(this.#o, {
2439
+ super(), this.#n = this.attachShadow({ mode: "open" }), this.#se(), this.#Y = new Promise((e) => this.#j = e), this.#i = Ut(this.#e, {
2459
2440
  getShadow: () => this.#n,
2460
- getShellConfig: () => this.#t?.shell,
2441
+ getShellConfig: () => this.#o?.shell,
2461
2442
  getAccordionIcons: () => ({
2462
- expand: this.#t?.icons?.expand ?? O.expand,
2463
- collapse: this.#t?.icons?.collapse ?? O.collapse
2443
+ expand: this.#o?.icons?.expand ?? O.expand,
2444
+ collapse: this.#o?.icons?.collapse ?? O.collapse
2464
2445
  }),
2465
- emit: (e, o) => this.#d(e, o),
2446
+ emit: (e, o) => this.#q(e, o),
2466
2447
  refreshShellHeader: () => this.refreshShellHeader()
2467
2448
  });
2468
2449
  }
2469
- async #oe() {
2450
+ async #se() {
2470
2451
  const e = new CSSStyleSheet();
2471
2452
  if (de.length > 0) {
2472
2453
  e.replaceSync(de), this.#n.adoptedStyleSheets = [e];
@@ -2477,10 +2458,10 @@ class N extends HTMLElement {
2477
2458
  let o = "";
2478
2459
  for (const n of Array.from(document.styleSheets))
2479
2460
  try {
2480
- const l = Array.from(n.cssRules || []).map((r) => r.cssText).join(`
2461
+ const r = Array.from(n.cssRules || []).map((s) => s.cssText).join(`
2481
2462
  `);
2482
- if (l.includes(".tbw-grid-root") && l.includes(":host")) {
2483
- o = l;
2463
+ if (r.includes(".tbw-grid-root") && r.includes(":host")) {
2464
+ o = r;
2484
2465
  break;
2485
2466
  }
2486
2467
  } catch {
@@ -2502,7 +2483,7 @@ class N extends HTMLElement {
2502
2483
  * @internal Plugin API
2503
2484
  */
2504
2485
  getPlugin(e) {
2505
- return this.#e?.getPlugin(e);
2486
+ return this.#t?.getPlugin(e);
2506
2487
  }
2507
2488
  /**
2508
2489
  * Get a plugin instance by its name.
@@ -2510,7 +2491,7 @@ class N extends HTMLElement {
2510
2491
  * @internal Plugin API
2511
2492
  */
2512
2493
  getPluginByName(e) {
2513
- return this.#e?.getPluginByName(e);
2494
+ return this.#t?.getPluginByName(e);
2514
2495
  }
2515
2496
  /**
2516
2497
  * Request a full re-render of the grid.
@@ -2519,7 +2500,7 @@ class N extends HTMLElement {
2519
2500
  * @internal Plugin API
2520
2501
  */
2521
2502
  requestRender() {
2522
- this.#H(), this.#P(), q(this), z(this), this.refreshVirtualWindow(!0);
2503
+ this.#P(), this.#L(), F(this), z(this), this.refreshVirtualWindow(!0);
2523
2504
  }
2524
2505
  /**
2525
2506
  * Update the grid's column template CSS.
@@ -2536,23 +2517,23 @@ class N extends HTMLElement {
2536
2517
  * @internal Plugin API
2537
2518
  */
2538
2519
  requestAfterRender() {
2539
- this.#e?.afterRender();
2520
+ this.#t?.afterRender();
2540
2521
  }
2541
2522
  /**
2542
2523
  * Initialize plugin system with instances from config.
2543
2524
  * Plugins are class instances passed in gridConfig.plugins[].
2544
2525
  */
2545
- #j() {
2546
- this.#e = new eo(this);
2547
- const e = this.#t?.plugins, o = Array.isArray(e) ? e : [];
2548
- this.#e.attachAll(o);
2526
+ #Z() {
2527
+ this.#t = new oo(this);
2528
+ const e = this.#o?.plugins, o = Array.isArray(e) ? e : [];
2529
+ this.#t.attachAll(o);
2549
2530
  }
2550
2531
  /**
2551
2532
  * Inject all plugin styles into the shadow DOM.
2552
2533
  * Must be called after #render() since innerHTML wipes existing content.
2553
2534
  */
2554
- #K() {
2555
- const e = this.#e?.getAllStyles() ?? "";
2535
+ #J() {
2536
+ const e = this.#t?.getAllStyles() ?? "";
2556
2537
  if (e) {
2557
2538
  const o = document.createElement("style");
2558
2539
  o.setAttribute("data-plugin", "all"), o.textContent = e, this.#n.appendChild(o);
@@ -2562,34 +2543,46 @@ class N extends HTMLElement {
2562
2543
  * Update plugins when grid config changes.
2563
2544
  * With class-based plugins, we need to detach old and attach new.
2564
2545
  */
2565
- #Z() {
2566
- this.#e && this.#e.detachAll(), this.#j(), this.#K(), this.#J(), this.#A = this.#e?.getAll().some((e) => e.onScroll) ?? !1;
2546
+ #Q() {
2547
+ this.#t && this.#t.detachAll();
2548
+ for (const e of this.#e.toolPanels.keys()) {
2549
+ const o = this.#e.lightDomToolPanelIds.has(e), n = this.#e.apiToolPanelIds.has(e);
2550
+ if (!o && !n) {
2551
+ const i = this.#e.panelCleanups.get(e);
2552
+ i && (i(), this.#e.panelCleanups.delete(e)), this.#e.toolPanels.delete(e);
2553
+ }
2554
+ }
2555
+ for (const e of this.#e.headerContents.keys()) {
2556
+ const o = this.#e.headerContentCleanups.get(e);
2557
+ o && (o(), this.#e.headerContentCleanups.delete(e)), this.#e.headerContents.delete(e);
2558
+ }
2559
+ this.#Z(), this.#J(), this.#ee(), this.#R = this.#t?.getAll().some((e) => e.onScroll) ?? !1;
2567
2560
  }
2568
2561
  /**
2569
2562
  * Clean up plugin states when grid disconnects.
2570
2563
  */
2571
- #ne() {
2572
- this.#e?.detachAll();
2564
+ #le() {
2565
+ this.#t?.detachAll();
2573
2566
  }
2574
2567
  /**
2575
2568
  * Collect tool panels and header content from all plugins.
2576
2569
  * Called after plugins are attached but before render.
2577
2570
  */
2578
- #J() {
2579
- if (!this.#e) return;
2580
- const e = this.#e.getToolPanels();
2571
+ #ee() {
2572
+ if (!this.#t) return;
2573
+ const e = this.#t.getToolPanels();
2581
2574
  for (const { panel: n } of e)
2582
- this.#o.toolPanels.has(n.id) || this.#o.toolPanels.set(n.id, n);
2583
- const o = this.#e.getHeaderContents();
2575
+ this.#e.toolPanels.has(n.id) || this.#e.toolPanels.set(n.id, n);
2576
+ const o = this.#t.getHeaderContents();
2584
2577
  for (const { content: n } of o)
2585
- this.#o.headerContents.has(n.id) || this.#o.headerContents.set(n.id, n);
2578
+ this.#e.headerContents.has(n.id) || this.#e.headerContents.set(n.id, n);
2586
2579
  }
2587
2580
  /**
2588
2581
  * Gets a renderer factory for tool panels from registered framework adapters.
2589
2582
  * Returns a factory function that tries each adapter in order until one handles the element.
2590
2583
  */
2591
- #_() {
2592
- const e = N.getAdapters();
2584
+ #b() {
2585
+ const e = I.getAdapters();
2593
2586
  if (e.length === 0 && !this.__frameworkAdapter) return;
2594
2587
  const o = this.__frameworkAdapter;
2595
2588
  return (n) => {
@@ -2599,25 +2592,25 @@ class N extends HTMLElement {
2599
2592
  }
2600
2593
  for (const i of e)
2601
2594
  if (i.createToolPanelRenderer) {
2602
- const l = i.createToolPanelRenderer(n);
2603
- if (l) return l;
2595
+ const r = i.createToolPanelRenderer(n);
2596
+ if (r) return r;
2604
2597
  }
2605
2598
  };
2606
2599
  }
2607
2600
  // ---------------- Lifecycle ----------------
2608
2601
  connectedCallback() {
2609
- this.hasAttribute("tabindex") || (this.tabIndex = 0), this.hasAttribute("version") || this.setAttribute("version", N.version), this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#s && (this.#s.abort(), this.#x = !1), this.#s = new AbortController(), this.#h && (_e(this.#h), this.#h = void 0), V(this, this.#o), F(this, this.#o, this.#_()), this.#l(), this.#j(), this.#J(), this.#M || (this.#F(), this.#K(), this.#M = !0), this.#B(), this.#h = Ot(
2602
+ this.hasAttribute("tabindex") || (this.tabIndex = 0), this.hasAttribute("version") || this.setAttribute("version", I.version), this._rows = Array.isArray(this.#s) ? [...this.#s] : [], this.#l && (this.#l.abort(), this.#x = !1), this.#l = new AbortController(), this.#u && (_e(this.#u), this.#u = void 0), q(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b()), this.#r(), this.#Z(), this.#ee(), this.#H || (this.#U(), this.#J(), this.#H = !0), this.#I(), this.#u = Dt(
2610
2603
  () => {
2611
- this.#ve();
2604
+ this.#Se();
2612
2605
  },
2613
2606
  { timeout: 100 }
2614
2607
  );
2615
2608
  }
2616
2609
  disconnectedCallback() {
2617
- this.#h && (_e(this.#h), this.#h = void 0), this.#ne(), Vt(this.#o), this.#i.setInitialized(!1), this.#L?.(), this.#L = void 0, We(this.#Y), this.#s && (this.#s.abort(), this.#s = void 0), this.#v?.abort(), this.#v = void 0, this.#x = !1, this._resizeController && this._resizeController.dispose(), this.#b && (this.#b.disconnect(), this.#b = void 0), this.#w && (this.#w.disconnect(), this.#w = void 0, this.#I = !1), this.#u && (this.#u.disconnect(), this.#u = void 0), Z(this), this._rowEditSnapshots.clear(), this._changedRowIndices.clear(), this.#E.clear();
2610
+ this.#u && (_e(this.#u), this.#u = void 0), this.#le(), Gt(this.#e), this.#i.setInitialized(!1), this.#A?.(), this.#A = void 0, $e(this.#K), this.#l && (this.#l.abort(), this.#l = void 0), this.#v?.abort(), this.#v = void 0, this.#x = !1, this._resizeController && this._resizeController.dispose(), this.#p && (this.#p.disconnect(), this.#p = void 0), this.#w && (this.#w.disconnect(), this.#w = void 0, this.#B = !1), this.#d && (this.#d.disconnect(), this.#d = void 0), Y(this), this._rowEditSnapshots.clear(), this._changedRowIndices.clear(), this.#C.clear();
2618
2611
  for (const e of this._rowPool)
2619
2612
  e.remove();
2620
- this._rowPool.length = 0, this.__rowsBodyEl = null, this.__scrollAreaEl = null, this.__footerEl = null, this.#O = !1;
2613
+ this._rowPool.length = 0, this.__rowsBodyEl = null, this.#M = !1;
2621
2614
  }
2622
2615
  /**
2623
2616
  * Handle HTML attribute changes.
@@ -2626,116 +2619,116 @@ class N extends HTMLElement {
2626
2619
  */
2627
2620
  attributeChangedCallback(e, o, n) {
2628
2621
  if (o === n || !n || n === "null" || n === "undefined") return;
2629
- const l = {
2622
+ const r = {
2630
2623
  rows: "rows",
2631
2624
  columns: "columns",
2632
2625
  "grid-config": "gridConfig",
2633
2626
  "fit-mode": "fitMode",
2634
2627
  "edit-on": "editOn"
2635
2628
  }[e];
2636
- if (l)
2629
+ if (r)
2637
2630
  if (e === "rows" || e === "columns" || e === "grid-config")
2638
2631
  try {
2639
- this[l] = JSON.parse(n);
2632
+ this[r] = JSON.parse(n);
2640
2633
  } catch {
2641
2634
  console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`, n);
2642
2635
  }
2643
2636
  else
2644
- this[l] = n;
2637
+ this[r] = n;
2645
2638
  }
2646
- #B() {
2639
+ #I() {
2647
2640
  const o = this.#n.querySelector(".tbw-grid-content") ?? this.#n.querySelector(".tbw-grid-root");
2648
- if (this._headerRowEl = o?.querySelector(".header-row"), this._virtualization.totalHeightEl = o?.querySelector(".faux-vscroll-spacer"), this._virtualization.viewportEl = o?.querySelector(".rows-viewport"), this._bodyEl = o?.querySelector(".rows"), this.__rowsBodyEl = o?.querySelector(".rows-body"), this.__scrollAreaEl = o?.querySelector(".tbw-scroll-area"), this.__footerEl = o?.querySelector(".tbw-footer"), this.#i.isInitialized) {
2649
- qe(this.#n, this.#o), qt(this.#n, this.#t?.shell, this.#o);
2650
- const l = this.#t?.shell?.toolPanel?.defaultOpen;
2651
- l && this.#o.toolPanels.has(l) && (this.openToolPanel(), this.#o.expandedSections.add(l));
2641
+ if (this._headerRowEl = o?.querySelector(".header-row"), this._virtualization.totalHeightEl = o?.querySelector(".faux-vscroll-spacer"), this._virtualization.viewportEl = o?.querySelector(".rows-viewport"), this._bodyEl = o?.querySelector(".rows"), this.__rowsBodyEl = o?.querySelector(".rows-body"), this.#i.isInitialized) {
2642
+ Ve(this.#n, this.#e), Vt(this.#n, this.#o?.shell, this.#e);
2643
+ const r = this.#o?.shell?.toolPanel?.defaultOpen;
2644
+ r && this.#e.toolPanels.has(r) && (this.openToolPanel(), this.#e.expandedSections.add(r));
2652
2645
  }
2653
- if (this.setAttribute("data-upgraded", ""), this.#O = !0, this._resizeController = kt(this), this.#a(), this.#ie(o), this.#x)
2646
+ if (this.setAttribute("data-upgraded", ""), this.#M = !0, this._resizeController = zt(this), this.#a(), this.#ae(o), this.#x)
2654
2647
  return;
2655
2648
  this.#x = !0;
2656
2649
  const n = this.disconnectSignal;
2657
- this.addEventListener("keydown", (l) => ft(this, l), { signal: n }), document.addEventListener(
2650
+ this.addEventListener("keydown", (r) => pt(this, r), { signal: n }), document.addEventListener(
2658
2651
  "keydown",
2659
- (l) => {
2660
- l.key === "Escape" && this._activeEditRows !== -1 && D(this, this._activeEditRows, !0);
2652
+ (r) => {
2653
+ r.key === "Escape" && this._activeEditRows !== -1 && D(this, this._activeEditRows, !0);
2661
2654
  },
2662
2655
  { capture: !0, signal: n }
2663
2656
  ), document.addEventListener(
2664
2657
  "mousedown",
2665
- (l) => {
2658
+ (r) => {
2666
2659
  if (this._activeEditRows === -1) return;
2667
- const r = this.findRenderedRowElement(this._activeEditRows);
2668
- !r || (l.composedPath && l.composedPath() || []).includes(r) || D(this, this._activeEditRows, !1);
2660
+ const s = this.findRenderedRowElement(this._activeEditRows);
2661
+ !s || (r.composedPath && r.composedPath() || []).includes(s) || D(this, this._activeEditRows, !1);
2669
2662
  },
2670
2663
  { signal: n }
2671
- ), this.#n.addEventListener("mousedown", (l) => this.#be(l), { signal: n }), document.addEventListener("mousemove", (l) => this.#we(l), { signal: n }), document.addEventListener("mouseup", (l) => this.#ge(l), { signal: n });
2672
- const i = this.#t.rowHeight;
2673
- i && i > 0 ? this._virtualization.rowHeight = i : requestAnimationFrame(() => this.#Q()), queueMicrotask(() => this.#re()), requestAnimationFrame(() => requestAnimationFrame(() => this.#X?.()));
2664
+ ), this.#n.addEventListener("mousedown", (r) => this.#_e(r), { signal: n }), document.addEventListener("mousemove", (r) => this.#Ce(r), { signal: n }), document.addEventListener("mouseup", (r) => this.#Ee(r), { signal: n });
2665
+ const i = this.#o.rowHeight;
2666
+ i && i > 0 ? this._virtualization.rowHeight = i : requestAnimationFrame(() => this.#te()), queueMicrotask(() => this.#de()), requestAnimationFrame(() => requestAnimationFrame(() => this.#j?.()));
2674
2667
  }
2675
2668
  /**
2676
2669
  * Measure actual row height from DOM.
2677
2670
  * Finds the tallest cell to account for custom renderers that may push height.
2678
2671
  */
2679
- #Q() {
2672
+ #te() {
2680
2673
  const e = this._bodyEl?.querySelector(".data-grid-row");
2681
2674
  if (!e) return;
2682
2675
  const o = e.querySelectorAll(".cell");
2683
2676
  let n = 0;
2684
- o.forEach((r) => {
2685
- const s = r.offsetHeight;
2686
- s > n && (n = s);
2677
+ o.forEach((s) => {
2678
+ const l = s.offsetHeight;
2679
+ l > n && (n = l);
2687
2680
  });
2688
- const i = e.getBoundingClientRect(), l = Math.max(i.height, n);
2689
- l > 0 && l !== this._virtualization.rowHeight && (this._virtualization.rowHeight = l, this.refreshVirtualWindow(!0));
2681
+ const i = e.getBoundingClientRect(), r = Math.max(i.height, n);
2682
+ r > 0 && r !== this._virtualization.rowHeight && (this._virtualization.rowHeight = r, this.refreshVirtualWindow(!0));
2690
2683
  }
2691
2684
  /**
2692
2685
  * Set up scroll-related event listeners on DOM elements.
2693
2686
  * These need to be re-attached when the DOM is recreated (e.g., shell toggle).
2694
2687
  * Uses a separate AbortController that is recreated each time.
2695
2688
  */
2696
- #ie(e) {
2689
+ #ae(e) {
2697
2690
  this.#v?.abort(), this.#v = new AbortController();
2698
2691
  const o = this.#v.signal, n = e?.querySelector(".faux-vscroll"), i = e?.querySelector(".rows");
2699
- if (this._virtualization.container = n ?? this, this.#A = this.#e?.getAll().some((l) => l.onScroll) ?? !1, n && i) {
2692
+ if (this._virtualization.container = n ?? this, this.#R = this.#t?.getAll().some((r) => r.onScroll) ?? !1, n && i) {
2700
2693
  n.addEventListener(
2701
2694
  "scroll",
2702
2695
  () => {
2703
- if (!this._virtualization.enabled && !this.#A) return;
2704
- const s = n.scrollTop, a = this._virtualization.rowHeight;
2696
+ if (!this._virtualization.enabled && !this.#R) return;
2697
+ const l = n.scrollTop, a = this._virtualization.rowHeight;
2705
2698
  if (this._rows.length <= this._virtualization.bypassThreshold)
2706
- i.style.transform = `translateY(${-s}px)`;
2699
+ i.style.transform = `translateY(${-l}px)`;
2707
2700
  else {
2708
- const c = Math.floor(s / a), h = c - c % 2, d = -(s - h * a);
2701
+ const c = Math.floor(l / a), f = c - c % 2, d = -(l - f * a);
2709
2702
  i.style.transform = `translateY(${d}px)`;
2710
2703
  }
2711
- this.#R = s, this.#p || (this.#p = requestAnimationFrame(() => {
2712
- this.#p = 0, this.#R !== null && (this.#pe(this.#R), this.#R = null);
2704
+ this.#S = l, this.#f || (this.#f = requestAnimationFrame(() => {
2705
+ this.#f = 0, this.#S !== null && (this.#ve(this.#S), this.#S = null);
2713
2706
  }));
2714
2707
  },
2715
2708
  { passive: !0, signal: o }
2716
2709
  );
2717
- const l = this.#n.querySelector(".tbw-grid-content"), r = this.#n.querySelector(".tbw-scroll-area");
2718
- l && (l.addEventListener(
2710
+ const r = this.#n.querySelector(".tbw-grid-content"), s = this.#n.querySelector(".tbw-scroll-area");
2711
+ r && (r.addEventListener(
2719
2712
  "wheel",
2720
- (s) => {
2721
- const a = s.shiftKey || Math.abs(s.deltaX) > Math.abs(s.deltaY);
2722
- if (a && r) {
2723
- const c = s.shiftKey ? s.deltaY : s.deltaX, { scrollLeft: h, scrollWidth: d, clientWidth: u } = r;
2724
- (c > 0 && h < d - u || c < 0 && h > 0) && (s.preventDefault(), r.scrollLeft += c);
2713
+ (l) => {
2714
+ const a = l.shiftKey || Math.abs(l.deltaX) > Math.abs(l.deltaY);
2715
+ if (a && s) {
2716
+ const c = l.shiftKey ? l.deltaY : l.deltaX, { scrollLeft: f, scrollWidth: d, clientWidth: u } = s;
2717
+ (c > 0 && f < d - u || c < 0 && f > 0) && (l.preventDefault(), s.scrollLeft += c);
2725
2718
  } else if (!a) {
2726
- const { scrollTop: c, scrollHeight: h, clientHeight: d } = n;
2727
- (s.deltaY > 0 && c < h - d || s.deltaY < 0 && c > 0) && (s.preventDefault(), n.scrollTop += s.deltaY);
2719
+ const { scrollTop: c, scrollHeight: f, clientHeight: d } = n;
2720
+ (l.deltaY > 0 && c < f - d || l.deltaY < 0 && c > 0) && (l.preventDefault(), n.scrollTop += l.deltaY);
2728
2721
  }
2729
2722
  },
2730
2723
  { passive: !1, signal: o }
2731
- ), Qt(l, this.#Y, { fauxScrollbar: n, scrollArea: r }, o));
2724
+ ), to(r, this.#K, { fauxScrollbar: n, scrollArea: s }, o));
2732
2725
  }
2733
- this._bodyEl && Lt(this, this._bodyEl, o), this.#b?.disconnect(), this._virtualization.viewportEl && (this.#b = new ResizeObserver(() => {
2734
- this.#p || (this.#p = requestAnimationFrame(() => {
2735
- this.#p = 0, this.refreshVirtualWindow(!0), k(this);
2726
+ this._bodyEl && Ht(this, this._bodyEl, o), this.#p?.disconnect(), this._virtualization.viewportEl && (this.#p = new ResizeObserver(() => {
2727
+ this.#f || (this.#f = requestAnimationFrame(() => {
2728
+ this.#f = 0, this.refreshVirtualWindow(!0), k(this);
2736
2729
  }));
2737
- }), this.#b.observe(this._virtualization.viewportEl)), this._virtualization.enabled && requestAnimationFrame(() => {
2738
- this.refreshVirtualWindow(!0), this.#le();
2730
+ }), this.#p.observe(this._virtualization.viewportEl)), this._virtualization.enabled && requestAnimationFrame(() => {
2731
+ this.refreshVirtualWindow(!0), this.#ce();
2739
2732
  });
2740
2733
  }
2741
2734
  /**
@@ -2743,43 +2736,28 @@ class N extends HTMLElement {
2743
2736
  * Called after rows are rendered to observe the actual content cells.
2744
2737
  * Handles dynamic CSS loading, lazy images, font loading, etc.
2745
2738
  */
2746
- #I = !1;
2739
+ #B = !1;
2747
2740
  // Only set up once per lifecycle
2748
- #le() {
2749
- if (this.#I) return;
2741
+ #ce() {
2742
+ if (this.#B) return;
2750
2743
  const e = this._bodyEl?.querySelector(".data-grid-row");
2751
2744
  if (!e) return;
2752
- this.#I = !0, this.#w?.disconnect();
2745
+ this.#B = !0, this.#w?.disconnect();
2753
2746
  const o = e.querySelectorAll(".cell");
2754
2747
  o.length > 0 && (this.#w = new ResizeObserver(() => {
2755
- this.#Q();
2748
+ this.#te();
2756
2749
  }), o.forEach((n) => this.#w.observe(n)));
2757
2750
  }
2758
2751
  // ---------------- Event Emitters ----------------
2759
- #d(e, o) {
2752
+ #q(e, o) {
2760
2753
  this.dispatchEvent(new CustomEvent(e, { detail: o, bubbles: !0, composed: !0 }));
2761
2754
  }
2762
- _emitCellCommit(e) {
2763
- this.#d("cell-commit", e);
2764
- }
2765
- _emitRowCommit(e) {
2766
- this.#d("row-commit", e);
2767
- }
2768
- _emitSortChange(e) {
2769
- this.#d("sort-change", e);
2770
- }
2771
- _emitColumnResize(e) {
2772
- this.#d("column-resize", e);
2773
- }
2774
- _emitActivateCell(e) {
2775
- this.#d("activate-cell", e);
2776
- }
2777
2755
  /** Update ARIA selection attributes on rendered rows/cells */
2778
- #re() {
2756
+ #de() {
2779
2757
  this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((o, n) => {
2780
2758
  const i = n === this._focusRow;
2781
- o.setAttribute("aria-selected", String(i)), o.querySelectorAll(".cell").forEach((l, r) => {
2782
- l.setAttribute("aria-selected", String(i && r === this._focusCol));
2759
+ o.setAttribute("aria-selected", String(i)), o.querySelectorAll(".cell").forEach((r, s) => {
2760
+ r.setAttribute("aria-selected", String(i && s === this._focusCol));
2783
2761
  });
2784
2762
  });
2785
2763
  }
@@ -2790,83 +2768,95 @@ class N extends HTMLElement {
2790
2768
  * Queue an update for a specific property type.
2791
2769
  * All updates queued within the same microtask are batched together.
2792
2770
  */
2793
- #C(e) {
2794
- this.#k[e] = !0, !this.#m && (this.#m = !0, queueMicrotask(() => this.#se()));
2771
+ #_(e) {
2772
+ this.#O[e] = !0, !this.#m && (this.#m = !0, queueMicrotask(() => this.#ue()));
2795
2773
  }
2796
2774
  /**
2797
2775
  * Process all pending updates in optimal order.
2798
2776
  * Priority: gridConfig first (may affect all), then columns, rows, fitMode, editMode
2799
2777
  */
2800
- #se() {
2801
- if (!this.#m || !this.#O) {
2778
+ #ue() {
2779
+ if (!this.#m || !this.#M) {
2802
2780
  this.#m = !1;
2803
2781
  return;
2804
2782
  }
2805
- const e = this.#k;
2806
- if (this.#m = !1, this.#k = {
2783
+ const e = this.#O;
2784
+ if (this.#m = !1, this.#O = {
2807
2785
  rows: !1,
2808
2786
  columns: !1,
2809
2787
  gridConfig: !1,
2810
2788
  fitMode: !1,
2811
2789
  editMode: !1
2812
2790
  }, e.gridConfig) {
2813
- this.#he();
2791
+ this.#be();
2814
2792
  return;
2815
2793
  }
2816
- e.columns && this.#ce(), e.rows && this.#ae(), e.fitMode && this.#de(), e.editMode && this.#ue();
2794
+ e.columns && this.#fe(), e.rows && this.#he(), e.fitMode && this.#pe(), e.editMode && this.#we();
2817
2795
  }
2818
2796
  // Individual update applicators - these do the actual work
2819
- #ae() {
2820
- this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#H(), this._columns.length > 0 || Array.isArray(this.#t?.columns) && this.#t.columns.length > 0 || Array.isArray(this.#c) && this.#c.length > 0 ? (this.#P(), this.refreshVirtualWindow(!0)) : this.#a();
2797
+ #he() {
2798
+ this._rows = Array.isArray(this.#s) ? [...this.#s] : [], this.#P(), this._columns.length > 0 || Array.isArray(this.#o?.columns) && this.#o.columns.length > 0 || Array.isArray(this.#c) && this.#c.length > 0 ? (this.#L(), this.refreshVirtualWindow(!0)) : this.#a();
2821
2799
  }
2822
- #ce() {
2823
- Z(this), this.#l(), this.#a();
2800
+ #fe() {
2801
+ Y(this), this.#r(), this.#a();
2824
2802
  }
2825
- #de() {
2826
- this.#l(), this.#t.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, be(this)) : (this._columns.forEach((o) => {
2803
+ #pe() {
2804
+ this.#r(), this.#o.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, we(this)) : (this._columns.forEach((o) => {
2827
2805
  !o.__userResized && o.__autoSized && delete o.width;
2828
2806
  }), z(this));
2829
2807
  }
2830
- #ue() {
2831
- this.#l(), this._rowPool.length = 0, this._bodyEl && (this._bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0);
2808
+ #we() {
2809
+ this.#r(), this._rowPool.length = 0, this._bodyEl && (this._bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0);
2832
2810
  }
2833
- #he() {
2834
- const e = !!this.#n.querySelector(".has-shell");
2835
- se(this.#t, this.#o), pe(this), this.#l(), this.#Z();
2836
- const o = se(this.#t, this.#o);
2837
- if (e !== o || !e && o) {
2838
- this.#F(), this.#B();
2811
+ #be() {
2812
+ q(this, this.#e), W(this, this.#e);
2813
+ const e = !!this.#n.querySelector(".has-shell"), o = !!this.#n.querySelector(".tbw-tool-panel"), n = this.#n.querySelectorAll(".tbw-accordion-section").length;
2814
+ pe(this), this.#r(), this.#Q(), V(this, this.#e, this.#b());
2815
+ const i = We(this.#o, this.#e), r = this.#e.toolPanels.size > 0, s = this.#e.toolPanels.size !== n;
2816
+ if (e !== i || !e && i || !o && r || o && s) {
2817
+ this.#U(), this.#I();
2839
2818
  return;
2840
2819
  }
2841
- this.#H(), this.#P(), q(this), z(this), this.refreshVirtualWindow(!0);
2820
+ e && this.#ge(), this.#P(), this.#L(), F(this), z(this), this.refreshVirtualWindow(!0);
2821
+ }
2822
+ /**
2823
+ * Update the shell header DOM in place without a full re-render.
2824
+ * Handles title, toolbar buttons, and other shell header changes.
2825
+ */
2826
+ #ge() {
2827
+ const e = this.#n.querySelector(".tbw-shell-header");
2828
+ if (!e) return;
2829
+ const o = this.#o.shell?.header?.title ?? this.#e.lightDomTitle;
2830
+ let n = e.querySelector(".tbw-shell-title");
2831
+ o ? (n || (n = document.createElement("h2"), n.className = "tbw-shell-title", n.setAttribute("part", "shell-title"), e.insertBefore(n, e.firstChild)), n.textContent = o) : n && n.remove();
2842
2832
  }
2843
2833
  // NOTE: Legacy watch handlers have been replaced by the batched update system.
2844
2834
  // The #queueUpdate() method schedules updates which are processed by #flushPendingUpdates()
2845
2835
  // and individual #apply*Update() methods. This coalesces rapid property changes
2846
2836
  // (e.g., setting rows, columns, gridConfig in quick succession) into a single update cycle.
2847
- #P() {
2848
- if (this.#e) {
2849
- const e = this.#N.length > 0 ? this.#N : this._columns, o = e.filter((l) => !l.hidden), n = e.filter((l) => l.hidden), i = this.#e.processColumns([...o]);
2837
+ #L() {
2838
+ if (this.#t) {
2839
+ const e = this.#N.length > 0 ? this.#N : this._columns, o = e.filter((r) => !r.hidden), n = e.filter((r) => r.hidden), i = this.#t.processColumns([...o]);
2850
2840
  if (i !== o) {
2851
- const l = new Map(i.map((s, a) => [s.field, { col: s, order: a }]));
2852
- if (!o.some((s) => l.has(s.field)) && i.length > 0)
2841
+ const r = new Map(i.map((l, a) => [l.field, { col: l, order: a }]));
2842
+ if (!o.some((l) => r.has(l.field)) && i.length > 0)
2853
2843
  this._columns = [...i, ...n];
2854
2844
  else {
2855
- const s = e.map((a) => {
2845
+ const l = e.map((a) => {
2856
2846
  if (a.hidden) return a;
2857
- const c = l.get(a.field);
2847
+ const c = r.get(a.field);
2858
2848
  return c ? c.col : a;
2859
2849
  });
2860
- this._columns = s;
2850
+ this._columns = l;
2861
2851
  }
2862
2852
  } else
2863
2853
  this._columns = [...e];
2864
2854
  }
2865
2855
  }
2866
2856
  /** Recompute row model via plugin hooks. */
2867
- #H() {
2868
- Z(this);
2869
- const e = Array.isArray(this.#r) ? [...this.#r] : [], o = this.#e?.processRows(e) ?? e;
2857
+ #P() {
2858
+ Y(this);
2859
+ const e = Array.isArray(this.#s) ? [...this.#s] : [], o = this.#t?.processRows(e) ?? e;
2870
2860
  this._rows = o;
2871
2861
  }
2872
2862
  /**
@@ -2887,7 +2877,7 @@ class N extends HTMLElement {
2887
2877
  * - `_columns` is NOT set here (done by #getColumnConfiguration + #processColumns)
2888
2878
  * - Plugins receive config via their attach() method
2889
2879
  */
2890
- #l() {
2880
+ #r() {
2891
2881
  const e = this.#g ? { ...this.#g } : {};
2892
2882
  let o = Array.isArray(e.columns) ? [...e.columns] : [];
2893
2883
  const n = (this.__lightDomColumnsCache || []).map((i) => ({
@@ -2895,42 +2885,62 @@ class N extends HTMLElement {
2895
2885
  }));
2896
2886
  if (n.length) {
2897
2887
  const i = {};
2898
- o.forEach((l) => i[l.field] = l), n.forEach((l) => {
2899
- const r = i[l.field];
2900
- r ? (l.header && !r.header && (r.header = l.header), l.type && !r.type && (r.type = l.type), r.sortable = r.sortable || l.sortable, l.resizable && (r.resizable = !0), l.editable && (r.editable = !0)) : (o.push(l), i[l.field] = l);
2888
+ o.forEach((r) => i[r.field] = r), n.forEach((r) => {
2889
+ const s = i[r.field];
2890
+ if (!s)
2891
+ o.push(r), i[r.field] = r;
2892
+ else {
2893
+ r.header && !s.header && (s.header = r.header), r.type && !s.type && (s.type = r.type), s.sortable = s.sortable || r.sortable, r.resizable && (s.resizable = !0), r.editable && (s.editable = !0);
2894
+ const l = r.renderer || r.viewRenderer, a = s.renderer || s.viewRenderer;
2895
+ l && !a && (s.viewRenderer = l, r.renderer && (s.renderer = l)), r.editor && !s.editor && (s.editor = r.editor);
2896
+ }
2901
2897
  });
2902
2898
  }
2903
2899
  if (this.#c && this.#c.length && (o = [...this.#c]), (!o || o.length === 0) && this._rows.length && (o = Le(this._rows).columns), o.length) {
2904
- o.forEach((r) => {
2905
- r.sortable === void 0 && (r.sortable = !0), r.resizable === void 0 && (r.resizable = !0);
2906
- const s = r;
2907
- s.__originalWidth === void 0 && typeof r.width == "number" && (s.__originalWidth = r.width);
2900
+ o.forEach((s) => {
2901
+ s.sortable === void 0 && (s.sortable = !0), s.resizable === void 0 && (s.resizable = !0);
2902
+ const l = s;
2903
+ l.__originalWidth === void 0 && typeof s.width == "number" && (l.__originalWidth = s.width);
2908
2904
  });
2909
- const i = this.#t.columns;
2910
- i?.some((r) => r.__compiledView || r.__compiledEditor) ? e.columns = i : e.columns = o;
2905
+ const i = this.#o.columns;
2906
+ i?.some((s) => s.__compiledView || s.__compiledEditor) ? e.columns = i : e.columns = o;
2911
2907
  } else {
2912
- const i = this.#t.columns;
2913
- i?.some((l) => l.__compiledView || l.__compiledEditor) && (e.columns = i);
2908
+ const i = this.#o.columns;
2909
+ i?.some((r) => r.__compiledView || r.__compiledEditor) && (e.columns = i);
2914
2910
  }
2915
- this.#y && (e.fitMode = this.#y), e.fitMode || (e.fitMode = "stretch"), this.#S && (e.editOn = this.#S), this.#o.lightDomTitle && (e.shell || (e.shell = {}), e.shell.header || (e.shell.header = {}), e.shell.header.title || (e.shell.header.title = this.#o.lightDomTitle)), e.rowHeight && e.rowHeight > 0 && (this._virtualization.rowHeight = e.rowHeight), e.columnState && !this.#f && (this.#f = e.columnState), this.#t = e, e.fitMode === "fixed" && this._columns.forEach((i) => {
2911
+ this.#E && (e.fitMode = this.#E), e.fitMode || (e.fitMode = "stretch"), this.#y && (e.editOn = this.#y), this.#e.lightDomTitle && (e.shell || (e.shell = {}), e.shell.header || (e.shell.header = {}), e.shell.header.title || (e.shell.header.title = this.#e.lightDomTitle)), e.rowHeight && e.rowHeight > 0 && (this._virtualization.rowHeight = e.rowHeight), e.columnState && !this.#h && (this.#h = e.columnState), this.#o = e, e.fitMode === "fixed" && this._columns.forEach((i) => {
2916
2912
  i.width == null && (i.width = 80);
2917
- }), this.#fe();
2913
+ }), this.#me();
2918
2914
  }
2919
2915
  /**
2920
2916
  * Apply animation configuration to CSS custom properties on the host element.
2921
2917
  * This makes the grid's animation settings available to plugins via CSS variables.
2922
2918
  */
2923
- #fe() {
2919
+ #me() {
2924
2920
  const e = {
2925
- ...Je,
2926
- ...this.#t.animation
2921
+ ...Qe,
2922
+ ...this.#o.animation
2927
2923
  }, o = e.mode ?? "reduced-motion";
2928
2924
  let n = 1;
2929
2925
  o === !1 || o === "off" ? n = 0 : (o === !0 || o === "on") && (n = 1), this.style.setProperty("--tbw-animation-duration", `${e.duration}ms`), this.style.setProperty("--tbw-animation-easing", e.easing ?? "ease-out"), this.style.setProperty("--tbw-animation-enabled", String(n)), this.dataset.animationMode = typeof o == "boolean" ? o ? "on" : "off" : o;
2930
2926
  }
2931
2927
  // ---------------- Delegate Wrappers ----------------
2932
- #q(e, o, n = this.__rowRenderEpoch) {
2933
- this.#D || (this.#D = (i, l, r) => this.#e?.renderRow(i, l, r) ?? !1), mt(this, e, o, n, this.#D);
2928
+ #W(e, o, n = this.__rowRenderEpoch) {
2929
+ this.#k || (this.#k = (i, r, s) => this.#t?.renderRow(i, r, s) ?? !1), vt(this, e, o, n, this.#k);
2930
+ }
2931
+ // Cache for ARIA counts to avoid redundant DOM writes on scroll (hot path)
2932
+ #V = -1;
2933
+ #oe = -1;
2934
+ /**
2935
+ * Updates ARIA row/col counts on the grid container.
2936
+ * Also sets role="rowgroup" on .rows container only when there are rows.
2937
+ * Uses caching to avoid redundant DOM writes on every scroll frame.
2938
+ */
2939
+ #ne(e, o) {
2940
+ if (e === this.#V && o === this.#oe)
2941
+ return;
2942
+ const n = this.#V;
2943
+ this.#V = e, this.#oe = o, this.__rowsBodyEl && (this.__rowsBodyEl.setAttribute("aria-rowcount", String(e)), this.__rowsBodyEl.setAttribute("aria-colcount", String(o))), e !== n && this._bodyEl && (e > 0 ? this._bodyEl.setAttribute("role", "rowgroup") : this._bodyEl.removeAttribute("role"));
2934
2944
  }
2935
2945
  // ---------------- Core Helpers ----------------
2936
2946
  #a() {
@@ -2938,31 +2948,31 @@ class N extends HTMLElement {
2938
2948
  return;
2939
2949
  const e = this.#g?.columns || this.#c || [];
2940
2950
  if (e.length) {
2941
- const n = new Map(this._columns.filter((l) => l.hidden).map((l) => [l.field, !0])), i = e.map((l) => ({
2942
- ...l,
2943
- hidden: n.get(l.field) ?? l.hidden
2951
+ const n = new Map(this._columns.filter((r) => r.hidden).map((r) => [r.field, !0])), i = e.map((r) => ({
2952
+ ...r,
2953
+ hidden: n.get(r.field) ?? r.hidden
2944
2954
  }));
2945
2955
  this._columns = i;
2946
2956
  }
2947
- if (pe(this), this.#l(), this.#Z(), this.#N = [...this._columns], this.#H(), this.#P(), this.#f) {
2948
- const n = this.#f;
2949
- this.#f = void 0, this.#ee(n);
2957
+ if (pe(this), this.#r(), this.#Q(), this.#N = [...this._columns], this.#P(), this.#L(), this.#h) {
2958
+ const n = this.#h;
2959
+ this.#h = void 0, this.#ie(n);
2950
2960
  }
2951
- q(this), z(this), this.refreshVirtualWindow(!0), this.#t.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => be(this)), this._bodyEl && (this._bodyEl.style.display = "", this._bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#e?.afterRender());
2961
+ F(this), z(this), this.refreshVirtualWindow(!0), this.#o.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => we(this)), this._bodyEl && (this._bodyEl.style.display = "", this._bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#t?.afterRender());
2952
2962
  }
2953
2963
  /** Internal method to apply column state without triggering setup loop */
2954
- #ee(e) {
2955
- const o = this.#t.columns ?? [], n = this.#e?.getAll() ?? [];
2956
- Fe(this, e, o, n);
2964
+ #ie(e) {
2965
+ const o = this.#o.columns ?? [], n = this.#t?.getAll() ?? [];
2966
+ Ge(this, e, o, n);
2957
2967
  for (const i of e.columns) {
2958
- const l = o.find((r) => r.field === i.field);
2959
- l && (l.hidden = !i.visible);
2968
+ const r = o.find((s) => s.field === i.field);
2969
+ r && (r.hidden = !i.visible);
2960
2970
  }
2961
2971
  }
2962
- #pe(e) {
2963
- if (this.refreshVirtualWindow(!1), this.#e?.onScrollRender(), this.#A) {
2964
- const o = this._virtualization.container, n = this.#te;
2965
- n.scrollTop = e, n.scrollLeft = o?.scrollLeft ?? 0, n.scrollHeight = o?.scrollHeight ?? 0, n.scrollWidth = o?.scrollWidth ?? 0, n.clientHeight = o?.clientHeight ?? 0, n.clientWidth = o?.clientWidth ?? 0, this.#e?.onScroll(n);
2972
+ #ve(e) {
2973
+ if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#R) {
2974
+ const o = this._virtualization.container, n = this.#re;
2975
+ n.scrollTop = e, n.scrollLeft = o?.scrollLeft ?? 0, n.scrollHeight = o?.scrollHeight ?? 0, n.scrollWidth = o?.scrollWidth ?? 0, n.clientHeight = o?.clientHeight ?? 0, n.clientWidth = o?.clientWidth ?? 0, this.#t?.onScroll(n);
2966
2976
  }
2967
2977
  }
2968
2978
  /**
@@ -2991,18 +3001,18 @@ class N extends HTMLElement {
2991
3001
  * Returns true if any plugin handled the event.
2992
3002
  */
2993
3003
  _dispatchCellClick(e, o, n, i) {
2994
- const l = this._rows[o], r = this._columns[n];
2995
- if (!l || !r) return !1;
2996
- const s = {
2997
- row: l,
3004
+ const r = this._rows[o], s = this._columns[n];
3005
+ if (!r || !s) return !1;
3006
+ const l = {
3007
+ row: r,
2998
3008
  rowIndex: o,
2999
3009
  colIndex: n,
3000
- field: r.field,
3001
- value: l[r.field],
3010
+ field: s.field,
3011
+ value: r[s.field],
3002
3012
  cellEl: i,
3003
3013
  originalEvent: e
3004
3014
  };
3005
- return this.#e?.onCellClick(s) ?? !1;
3015
+ return this.#t?.onCellClick(l) ?? !1;
3006
3016
  }
3007
3017
  /**
3008
3018
  * Dispatch a row click event to the plugin system.
@@ -3010,13 +3020,13 @@ class N extends HTMLElement {
3010
3020
  */
3011
3021
  _dispatchRowClick(e, o, n, i) {
3012
3022
  if (!n) return !1;
3013
- const l = {
3023
+ const r = {
3014
3024
  rowIndex: o,
3015
3025
  row: n,
3016
3026
  rowEl: i,
3017
3027
  originalEvent: e
3018
3028
  };
3019
- return this.#e?.onRowClick(l) ?? !1;
3029
+ return this.#t?.onRowClick(r) ?? !1;
3020
3030
  }
3021
3031
  /**
3022
3032
  * Dispatch a header click event to the plugin system.
@@ -3025,21 +3035,21 @@ class N extends HTMLElement {
3025
3035
  _dispatchHeaderClick(e, o, n) {
3026
3036
  const i = this._columns[o];
3027
3037
  if (!i) return !1;
3028
- const l = {
3038
+ const r = {
3029
3039
  colIndex: o,
3030
3040
  field: i.field,
3031
3041
  column: i,
3032
3042
  headerEl: n,
3033
3043
  originalEvent: e
3034
3044
  };
3035
- return this.#e?.onHeaderClick(l) ?? !1;
3045
+ return this.#t?.onHeaderClick(r) ?? !1;
3036
3046
  }
3037
3047
  /**
3038
3048
  * Dispatch a keyboard event to the plugin system.
3039
3049
  * Returns true if any plugin handled the event.
3040
3050
  */
3041
3051
  _dispatchKeyDown(e) {
3042
- return this.#e?.onKeyDown(e) ?? !1;
3052
+ return this.#t?.onKeyDown(e) ?? !1;
3043
3053
  }
3044
3054
  /**
3045
3055
  * Get horizontal scroll boundary offsets from plugins.
@@ -3047,7 +3057,7 @@ class N extends HTMLElement {
3047
3057
  * when plugins like pinned columns obscure part of the scroll area.
3048
3058
  */
3049
3059
  _getHorizontalScrollOffsets(e, o) {
3050
- return this.#e?.getHorizontalScrollOffsets(e, o) ?? { left: 0, right: 0 };
3060
+ return this.#t?.getHorizontalScrollOffsets(e, o) ?? { left: 0, right: 0 };
3051
3061
  }
3052
3062
  /**
3053
3063
  * Query all plugins with a generic query and collect responses.
@@ -3060,59 +3070,58 @@ class N extends HTMLElement {
3060
3070
  * const canMove = !responses.includes(false);
3061
3071
  */
3062
3072
  queryPlugins(e) {
3063
- return this.#e?.queryPlugins(e) ?? [];
3073
+ return this.#t?.queryPlugins(e) ?? [];
3064
3074
  }
3065
3075
  /**
3066
3076
  * Build a CellMouseEvent from a native MouseEvent.
3067
3077
  * Extracts cell/row information from the event target.
3068
3078
  */
3069
- #W(e, o) {
3079
+ #$(e, o) {
3070
3080
  let n = null;
3071
3081
  const i = e.composedPath?.();
3072
3082
  if (i && i.length > 0 ? n = i[0] : n = e.target, n && !this.#n.contains(n)) {
3073
- const f = this.#n.elementFromPoint(e.clientX, e.clientY);
3074
- f && (n = f);
3083
+ const h = this.#n.elementFromPoint(e.clientX, e.clientY);
3084
+ h && (n = h);
3075
3085
  }
3076
- const l = n?.closest?.("[data-col]"), r = n?.closest?.(".data-grid-row"), s = n?.closest?.(".header-row");
3077
- let a, c, h, d, u, p;
3078
- return l && (a = parseInt(l.getAttribute("data-row") ?? "-1", 10), c = parseInt(l.getAttribute("data-col") ?? "-1", 10), a >= 0 && c >= 0 && (h = this._rows[a], p = this._columns[c], d = p?.field, u = h && d ? h[d] : void 0)), {
3086
+ const r = n?.closest?.("[data-col]"), s = n?.closest?.(".data-grid-row"), l = n?.closest?.(".header-row");
3087
+ let a, c, f, d, u, w;
3088
+ return r && (a = parseInt(r.getAttribute("data-row") ?? "-1", 10), c = parseInt(r.getAttribute("data-col") ?? "-1", 10), a >= 0 && c >= 0 && (f = this._rows[a], w = this._columns[c], d = w?.field, u = f && d ? f[d] : void 0)), {
3079
3089
  type: o,
3080
- row: h,
3090
+ row: f,
3081
3091
  rowIndex: a !== void 0 && a >= 0 ? a : void 0,
3082
3092
  colIndex: c !== void 0 && c >= 0 ? c : void 0,
3083
3093
  field: d,
3084
3094
  value: u,
3085
- column: p,
3095
+ column: w,
3086
3096
  originalEvent: e,
3087
- cellElement: l ?? void 0,
3088
- rowElement: r ?? void 0,
3089
- isHeader: !!s,
3097
+ cellElement: r ?? void 0,
3098
+ rowElement: s ?? void 0,
3099
+ isHeader: !!l,
3090
3100
  cell: a !== void 0 && c !== void 0 && a >= 0 && c >= 0 ? { row: a, col: c } : void 0
3091
3101
  };
3092
3102
  }
3093
- /**
3094
3103
  /**
3095
3104
  * Handle mousedown events and dispatch to plugin system.
3096
3105
  */
3097
- #be(e) {
3098
- const o = this.#W(e, "mousedown");
3099
- (this.#e?.onCellMouseDown(o) ?? !1) && (this.#T = !0);
3106
+ #_e(e) {
3107
+ const o = this.#$(e, "mousedown");
3108
+ (this.#t?.onCellMouseDown(o) ?? !1) && (this.#T = !0);
3100
3109
  }
3101
3110
  /**
3102
3111
  * Handle mousemove events (only when dragging).
3103
3112
  */
3104
- #we(e) {
3113
+ #Ce(e) {
3105
3114
  if (!this.#T) return;
3106
- const o = this.#W(e, "mousemove");
3107
- this.#e?.onCellMouseMove(o);
3115
+ const o = this.#$(e, "mousemove");
3116
+ this.#t?.onCellMouseMove(o);
3108
3117
  }
3109
3118
  /**
3110
3119
  * Handle mouseup events.
3111
3120
  */
3112
- #ge(e) {
3121
+ #Ee(e) {
3113
3122
  if (!this.#T) return;
3114
- const o = this.#W(e, "mouseup");
3115
- this.#e?.onCellMouseUp(o), this.#T = !1;
3123
+ const o = this.#$(e, "mouseup");
3124
+ this.#t?.onCellMouseUp(o), this.#T = !1;
3116
3125
  }
3117
3126
  // API consumed by internal utils (rows.ts) - delegates to editing.ts
3118
3127
  get changedRows() {
@@ -3122,34 +3131,34 @@ class N extends HTMLElement {
3122
3131
  return ze(this);
3123
3132
  }
3124
3133
  async resetChangedRows(e) {
3125
- Ct(this, e);
3134
+ yt(this, e);
3126
3135
  }
3127
3136
  async beginBulkEdit(e) {
3128
- Et(this, e, {
3137
+ St(this, e, {
3129
3138
  findRenderedRowElement: (o) => this.findRenderedRowElement?.(o) ?? null
3130
3139
  });
3131
3140
  }
3132
3141
  async commitActiveRowEdit() {
3133
- yt(this);
3142
+ Rt(this);
3134
3143
  }
3135
3144
  async cancelActiveRowEdit() {
3136
- St(this);
3145
+ Tt(this);
3137
3146
  }
3138
3147
  async ready() {
3139
- return this.#U;
3148
+ return this.#Y;
3140
3149
  }
3141
3150
  async forceLayout() {
3142
3151
  this.#a(), await new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(e)));
3143
3152
  }
3144
3153
  /** Public method: returns a frozen snapshot of the merged effective configuration */
3145
3154
  async getConfig() {
3146
- return Object.freeze({ ...this.#t || {} });
3155
+ return Object.freeze({ ...this.#o || {} });
3147
3156
  }
3148
3157
  // ---------------- Column Visibility API ----------------
3149
3158
  // Delegates to column-state.ts pure functions
3150
3159
  /** Visibility callbacks for column-state.ts functions */
3151
- #$ = {
3152
- emit: (e, o) => this.#d(e, o),
3160
+ #F = {
3161
+ emit: (e, o) => this.#q(e, o),
3153
3162
  clearRowPool: () => {
3154
3163
  this._rowPool.length = 0, this._bodyEl && (this._bodyEl.innerHTML = ""), this.__rowRenderEpoch++;
3155
3164
  },
@@ -3157,29 +3166,29 @@ class N extends HTMLElement {
3157
3166
  requestStateChange: () => this.requestStateChange()
3158
3167
  };
3159
3168
  setColumnVisible(e, o) {
3160
- return xe(this, e, o, this.#$);
3169
+ return Ae(this, e, o, this.#F);
3161
3170
  }
3162
3171
  toggleColumnVisibility(e) {
3163
- return Ue(this, e, this.#$);
3172
+ return Xe(this, e, this.#F);
3164
3173
  }
3165
3174
  isColumnVisible(e) {
3166
- return Xe(this, e);
3175
+ return Ye(this, e);
3167
3176
  }
3168
3177
  showAllColumns() {
3169
- Ye(this, this.#$);
3178
+ je(this, this.#F);
3170
3179
  }
3171
3180
  getAllColumns() {
3172
- return je(this);
3181
+ return Ke(this);
3173
3182
  }
3174
3183
  setColumnOrder(e) {
3175
- Ze(this, e, {
3176
- renderHeader: () => q(this),
3184
+ Je(this, e, {
3185
+ renderHeader: () => F(this),
3177
3186
  updateTemplate: () => z(this),
3178
3187
  refreshVirtualWindow: () => this.refreshVirtualWindow(!0)
3179
3188
  });
3180
3189
  }
3181
3190
  getColumnOrder() {
3182
- return Ke(this);
3191
+ return Ze(this);
3183
3192
  }
3184
3193
  // ---------------- Column State API ----------------
3185
3194
  /**
@@ -3187,15 +3196,15 @@ class N extends HTMLElement {
3187
3196
  * Returns a serializable object suitable for localStorage or database storage.
3188
3197
  */
3189
3198
  getColumnState() {
3190
- const e = this.#e?.getAll() ?? [];
3191
- return Te(this, e);
3199
+ const e = this.#t?.getAll() ?? [];
3200
+ return xe(this, e);
3192
3201
  }
3193
3202
  /**
3194
3203
  * Set the column state, restoring order, width, visibility, sort, and plugin state.
3195
3204
  * Use this to restore previously saved column state.
3196
3205
  */
3197
3206
  set columnState(e) {
3198
- e && (this.#f = e, this.#M && this.#me(e));
3207
+ e && (this.#h = e, this.#H && this.#ye(e));
3199
3208
  }
3200
3209
  /**
3201
3210
  * Get the current column state.
@@ -3206,10 +3215,10 @@ class N extends HTMLElement {
3206
3215
  /**
3207
3216
  * Apply column state internally.
3208
3217
  */
3209
- #me(e) {
3210
- (this.#t.columns ?? []).forEach((n) => {
3218
+ #ye(e) {
3219
+ (this.#o.columns ?? []).forEach((n) => {
3211
3220
  n.hidden = !1;
3212
- }), this.#ee(e), this.#a();
3221
+ }), this.#ie(e), this.#a();
3213
3222
  }
3214
3223
  /**
3215
3224
  * Request a state change event to be emitted.
@@ -3219,10 +3228,10 @@ class N extends HTMLElement {
3219
3228
  * @internal Plugin API
3220
3229
  */
3221
3230
  requestStateChange() {
3222
- this.#z || (this.#z = Ge(
3231
+ this.#z || (this.#z = Ue(
3223
3232
  this,
3224
- () => this.#e?.getAll() ?? [],
3225
- (e) => this.#d("column-state-change", e)
3233
+ () => this.#t?.getAll() ?? [],
3234
+ (e) => this.#q("column-state-change", e)
3226
3235
  )), this.#z();
3227
3236
  }
3228
3237
  /**
@@ -3230,10 +3239,10 @@ class N extends HTMLElement {
3230
3239
  * Clears all user modifications (order, width, visibility, sort).
3231
3240
  */
3232
3241
  resetColumnState() {
3233
- this.#f = void 0, (this.#t.columns ?? []).forEach((n) => {
3242
+ this.#h = void 0, (this.#o.columns ?? []).forEach((n) => {
3234
3243
  n.hidden = !1;
3235
- }), this._sortState = null, this.__originalOrder = [], this.#l(), this.#a();
3236
- const o = this.#e?.getAll() ?? [];
3244
+ }), this._sortState = null, this.__originalOrder = [], this.#r(), this.#a();
3245
+ const o = this.#t?.getAll() ?? [];
3237
3246
  for (const n of o)
3238
3247
  if (n.applyColumnState)
3239
3248
  for (const i of this._columns)
@@ -3285,11 +3294,11 @@ class N extends HTMLElement {
3285
3294
  }
3286
3295
  /** Register a custom tool panel (without creating a plugin). */
3287
3296
  registerToolPanel(e) {
3288
- this.#i.registerToolPanel(e);
3297
+ this.#e.apiToolPanelIds.add(e.id), this.#i.registerToolPanel(e);
3289
3298
  }
3290
3299
  /** Unregister a custom tool panel. */
3291
3300
  unregisterToolPanel(e) {
3292
- this.#i.unregisterToolPanel(e);
3301
+ this.#e.apiToolPanelIds.delete(e), this.#i.unregisterToolPanel(e);
3293
3302
  }
3294
3303
  /** Get registered header content definitions. */
3295
3304
  getHeaderContents() {
@@ -3324,11 +3333,11 @@ class N extends HTMLElement {
3324
3333
  * Call this after dynamically modifying <tbw-grid-header> children.
3325
3334
  */
3326
3335
  refreshShellHeader() {
3327
- V(this, this.#o), F(this, this.#o, this.#_()), this.#F(), this.#B();
3336
+ q(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b()), this.#U(), this.#I();
3328
3337
  }
3329
3338
  // #region Custom Styles API
3330
3339
  /** Map of registered custom style elements by ID */
3331
- #E = /* @__PURE__ */ new Map();
3340
+ #C = /* @__PURE__ */ new Map();
3332
3341
  /**
3333
3342
  * Register custom CSS styles to be injected into the grid's shadow DOM.
3334
3343
  * Use this to style custom cell renderers, editors, or detail panels.
@@ -3354,21 +3363,21 @@ class N extends HTMLElement {
3354
3363
  registerStyles(e, o) {
3355
3364
  this.unregisterStyles(e);
3356
3365
  const n = document.createElement("style");
3357
- n.id = `tbw-custom-${e}`, n.textContent = o, this.#n.appendChild(n), this.#E.set(e, n);
3366
+ n.id = `tbw-custom-${e}`, n.textContent = o, this.#n.appendChild(n), this.#C.set(e, n);
3358
3367
  }
3359
3368
  /**
3360
3369
  * Remove previously registered custom styles.
3361
3370
  * @param id - The ID used when registering the styles
3362
3371
  */
3363
3372
  unregisterStyles(e) {
3364
- const o = this.#E.get(e);
3365
- o && (o.remove(), this.#E.delete(e));
3373
+ const o = this.#C.get(e);
3374
+ o && (o.remove(), this.#C.delete(e));
3366
3375
  }
3367
3376
  /**
3368
3377
  * Get list of registered custom style IDs.
3369
3378
  */
3370
3379
  getRegisteredStyles() {
3371
- return Array.from(this.#E.keys());
3380
+ return Array.from(this.#C.keys());
3372
3381
  }
3373
3382
  // #endregion
3374
3383
  /**
@@ -3376,44 +3385,46 @@ class N extends HTMLElement {
3376
3385
  * This handles frameworks like Angular that project content asynchronously.
3377
3386
  * When shell-related elements are added/changed, the shell header is updated.
3378
3387
  */
3379
- #ve() {
3380
- this.#u && this.#u.disconnect();
3388
+ #Se() {
3389
+ this.#d && this.#d.disconnect();
3381
3390
  let e = null, o = !1, n = !1;
3382
3391
  const i = () => {
3383
3392
  if (e = null, o) {
3384
- const l = this.#o.lightDomTitle;
3385
- if (V(this, this.#o), F(this, this.#o, this.#_()), this.#o.lightDomTitle && !l) {
3386
- this.#l();
3387
- const s = this.#n.querySelector(".tbw-shell-header");
3388
- if (s) {
3389
- const a = ye(
3390
- this.#t.shell,
3391
- this.#o,
3392
- this.#t.icons?.toolPanel
3393
- ), c = document.createElement("div");
3394
- c.innerHTML = a;
3395
- const h = c.firstElementChild;
3396
- h && (s.replaceWith(h), this.#G());
3393
+ const r = this.#e.lightDomTitle, s = this.#e.hasToolButtonsContainer;
3394
+ q(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b());
3395
+ const l = this.#e.lightDomTitle, a = this.#e.hasToolButtonsContainer;
3396
+ if (l && !r || a && !s) {
3397
+ this.#r();
3398
+ const c = this.#n.querySelector(".tbw-shell-header");
3399
+ if (c) {
3400
+ const f = ye(
3401
+ this.#o.shell,
3402
+ this.#e,
3403
+ this.#o.icons?.toolPanel
3404
+ ), d = document.createElement("div");
3405
+ d.innerHTML = f;
3406
+ const u = d.firstElementChild;
3407
+ u && (c.replaceWith(u), this.#X());
3397
3408
  }
3398
3409
  }
3399
3410
  o = !1;
3400
3411
  }
3401
3412
  n && (this.__lightDomColumnsCache = void 0, this.#a(), n = !1);
3402
3413
  };
3403
- this.#u = new MutationObserver((l) => {
3404
- for (const r of l) {
3405
- for (const s of r.addedNodes) {
3406
- if (s.nodeType !== Node.ELEMENT_NODE) continue;
3407
- const c = s.tagName.toLowerCase();
3414
+ this.#d = new MutationObserver((r) => {
3415
+ for (const s of r) {
3416
+ for (const l of s.addedNodes) {
3417
+ if (l.nodeType !== Node.ELEMENT_NODE) continue;
3418
+ const c = l.tagName.toLowerCase();
3408
3419
  c === "tbw-grid-header" ? o = !0 : (c === "tbw-grid-column" || c === "tbw-grid-detail") && (n = !0);
3409
3420
  }
3410
- if (r.type === "attributes" && r.target.nodeType === Node.ELEMENT_NODE) {
3411
- const a = r.target.tagName.toLowerCase();
3421
+ if (s.type === "attributes" && s.target.nodeType === Node.ELEMENT_NODE) {
3422
+ const a = s.target.tagName.toLowerCase();
3412
3423
  a === "tbw-grid-header" ? o = !0 : a === "tbw-grid-column" && (n = !0);
3413
3424
  }
3414
3425
  }
3415
3426
  (o || n) && !e && (e = setTimeout(i, 0));
3416
- }), this.#u.observe(this, {
3427
+ }), this.#d.observe(this, {
3417
3428
  childList: !0,
3418
3429
  subtree: !0,
3419
3430
  attributes: !0,
@@ -3423,23 +3434,34 @@ class N extends HTMLElement {
3423
3434
  /**
3424
3435
  * Re-parse light DOM column elements and refresh the grid.
3425
3436
  * Call this after framework adapters have registered their templates.
3437
+ * Debounced to coalesce multiple calls (e.g., from React StrictMode double-mounting).
3426
3438
  * @internal Used by framework integration libraries (Angular, React, Vue)
3427
3439
  */
3428
3440
  refreshColumns() {
3429
- this.__lightDomColumnsCache = void 0;
3430
- const e = this.#o.lightDomTitle;
3431
- if (V(this, this.#o), F(this, this.#o, this.#_()), this.#o.lightDomTitle && !e) {
3432
- this.#l();
3433
- const n = this.#n.querySelector(".tbw-shell-header");
3434
- if (n) {
3435
- const i = ye(
3436
- this.#t.shell,
3437
- this.#o,
3438
- this.#t.icons?.toolPanel
3439
- ), l = document.createElement("div");
3440
- l.innerHTML = i;
3441
- const r = l.firstElementChild;
3442
- r && (n.replaceWith(r), this.#G());
3441
+ this.#D || (this.#D = requestAnimationFrame(() => {
3442
+ this.#D = 0, this.#Re();
3443
+ }));
3444
+ }
3445
+ /**
3446
+ * Internal implementation of refreshColumns, called after debounce.
3447
+ */
3448
+ #Re() {
3449
+ this.__lightDomColumnsCache = void 0, Y(this);
3450
+ const e = this.#e.lightDomTitle, o = this.#e.hasToolButtonsContainer;
3451
+ q(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b());
3452
+ const n = this.#e.lightDomTitle, i = this.#e.hasToolButtonsContainer;
3453
+ if (n && !e || i && !o) {
3454
+ this.#r();
3455
+ const s = this.#n.querySelector(".tbw-shell-header");
3456
+ if (s) {
3457
+ const l = ye(
3458
+ this.#o.shell,
3459
+ this.#e,
3460
+ this.#o.icons?.toolPanel
3461
+ ), a = document.createElement("div");
3462
+ a.innerHTML = l;
3463
+ const c = a.firstElementChild;
3464
+ c && (s.replaceWith(c), this.#X());
3443
3465
  }
3444
3466
  }
3445
3467
  this.#a();
@@ -3449,9 +3471,9 @@ class N extends HTMLElement {
3449
3471
  * Calculate total height for the faux scrollbar spacer element.
3450
3472
  * Used by both bypass and virtualized rendering paths to ensure consistent scroll behavior.
3451
3473
  */
3452
- #V(e) {
3453
- const o = this._virtualization.rowHeight, n = this._virtualization.container ?? this, i = this._virtualization.viewportEl ?? n, l = n.clientHeight, r = i.clientHeight, a = this.shadowRoot?.querySelector(".tbw-scroll-area"), c = a ? a.clientHeight : l, d = c - r, u = this.#e?.getExtraHeight() ?? 0, p = Math.max(0, l - c);
3454
- return e * o + d + u + p;
3474
+ #G(e) {
3475
+ const o = this._virtualization.rowHeight, n = this._virtualization.container ?? this, i = this._virtualization.viewportEl ?? n, r = n.clientHeight, s = i.clientHeight, a = this.shadowRoot?.querySelector(".tbw-scroll-area"), c = a ? a.clientHeight : r, d = c - s, u = this.#t?.getExtraHeight() ?? 0, w = Math.max(0, r - c);
3476
+ return e * o + d + u + w;
3455
3477
  }
3456
3478
  /**
3457
3479
  * Core virtualization routine. Chooses between bypass (small datasets), grouped window rendering,
@@ -3462,80 +3484,76 @@ class N extends HTMLElement {
3462
3484
  if (!this._bodyEl) return;
3463
3485
  const o = this._rows.length;
3464
3486
  if (!this._virtualization.enabled) {
3465
- this.#q(0, o), this.#e?.afterRender();
3487
+ this.#W(0, o), this.#t?.afterRender();
3466
3488
  return;
3467
3489
  }
3468
3490
  if (this._rows.length <= this._virtualization.bypassThreshold) {
3469
- this._virtualization.start = 0, this._virtualization.end = o, e && (this._bodyEl.style.transform = "translateY(0px)"), this.#q(0, o, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this._virtualization.totalHeightEl && (this._virtualization.totalHeightEl.style.height = `${this.#V(o)}px`), this.__rowsBodyEl?.setAttribute("aria-rowcount", String(o)), this.__rowsBodyEl?.setAttribute("aria-colcount", String(this._visibleColumns.length)), this.#e?.afterRender();
3491
+ this._virtualization.start = 0, this._virtualization.end = o, e && (this._bodyEl.style.transform = "translateY(0px)"), this.#W(0, o, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this._virtualization.totalHeightEl && (this._virtualization.totalHeightEl.style.height = `${this.#G(o)}px`), this.#ne(o, this._visibleColumns.length), this.#t?.afterRender();
3470
3492
  return;
3471
3493
  }
3472
- const n = this._virtualization.container ?? this, i = this._virtualization.viewportEl ?? n, l = i.clientHeight, r = this._virtualization.rowHeight, s = n.scrollTop;
3473
- let a = Math.floor(s / r), c = 0;
3474
- const h = 10;
3475
- for (; c < h; ) {
3476
- const _ = this.#e?.getExtraHeightBefore?.(a) ?? 0, m = Math.floor((s - _) / r);
3477
- if (m >= a || m < 0) break;
3478
- a = m, c++;
3494
+ const n = this._virtualization.container ?? this, i = this._virtualization.viewportEl ?? n, r = i.clientHeight, s = this._virtualization.rowHeight, l = n.scrollTop;
3495
+ let a = Math.floor(l / s), c = 0;
3496
+ const f = 10;
3497
+ for (; c < f; ) {
3498
+ const _ = this.#t?.getExtraHeightBefore?.(a) ?? 0, v = Math.floor((l - _) / s);
3499
+ if (v >= a || v < 0) break;
3500
+ a = v, c++;
3479
3501
  }
3480
3502
  a = a - a % 2, a < 0 && (a = 0);
3481
- const d = this.#e?.adjustVirtualStart(a, s, r);
3503
+ const d = this.#t?.adjustVirtualStart(a, l, s);
3482
3504
  d !== void 0 && d < a && (a = d, a = a - a % 2, a < 0 && (a = 0));
3483
- const u = Math.ceil(l / r) + 3;
3484
- let p = a + u;
3485
- if (p > o && (p = o), this._virtualization.start = a, this._virtualization.end = p, n.clientHeight === 0 && l > 0) {
3505
+ const u = Math.ceil(r / s) + 3;
3506
+ let w = a + u;
3507
+ if (w > o && (w = o), this._virtualization.start = a, this._virtualization.end = w, n.clientHeight === 0 && r > 0) {
3486
3508
  requestAnimationFrame(() => this.refreshVirtualWindow(e));
3487
3509
  return;
3488
3510
  }
3489
- const b = this.#V(o);
3490
- this._virtualization.totalHeightEl && (this._virtualization.totalHeightEl.style.height = `${b}px`);
3491
- const g = this.#e?.getExtraHeightBefore?.(a) ?? 0, w = -(s - a * r - g);
3492
- this._bodyEl.style.transform = `translateY(${w}px)`, this.#q(a, p, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.__rowsBodyEl?.setAttribute("aria-rowcount", String(o)), this.__rowsBodyEl?.setAttribute("aria-colcount", String(this._visibleColumns.length)), e && (this.#e?.afterRender(), queueMicrotask(() => {
3493
- const _ = n.clientHeight, m = i.clientHeight;
3494
- if (_ === 0 && m > 0) return;
3495
- const v = this.#V(o);
3496
- this._virtualization.totalHeightEl && (this._virtualization.totalHeightEl.style.height = `${v}px`);
3511
+ const p = this.#G(o);
3512
+ this._virtualization.totalHeightEl && (this._virtualization.totalHeightEl.style.height = `${p}px`);
3513
+ const g = this.#t?.getExtraHeightBefore?.(a) ?? 0, b = -(l - a * s - g);
3514
+ this._bodyEl.style.transform = `translateY(${b}px)`, this.#W(a, w, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.#ne(o, this._visibleColumns.length), e && (this.#t?.afterRender(), queueMicrotask(() => {
3515
+ const _ = n.clientHeight, v = i.clientHeight;
3516
+ if (_ === 0 && v > 0) return;
3517
+ const m = this.#G(o);
3518
+ this._virtualization.totalHeightEl && (this._virtualization.totalHeightEl.style.height = `${m}px`);
3497
3519
  }));
3498
3520
  }
3499
3521
  // ---------------- Render ----------------
3500
- #F() {
3501
- V(this, this.#o), F(this, this.#o, this.#_()), this.#l();
3502
- const e = this.#t?.shell;
3503
- Ut(this.#n, e, this.#o, this.#t?.icons) && (this.#G(), this.#i.setInitialized(!0));
3522
+ #U() {
3523
+ q(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b()), this.#r();
3524
+ const e = this.#o?.shell;
3525
+ Yt(this.#n, e, this.#e, this.#o?.icons) && (this.#X(), this.#i.setInitialized(!0));
3504
3526
  }
3505
3527
  /**
3506
3528
  * Set up shell event listeners after render.
3507
3529
  */
3508
- #G() {
3509
- Bt(this.#n, this.#t?.shell, this.#o, {
3530
+ #X() {
3531
+ qt(this.#n, this.#o?.shell, this.#e, {
3510
3532
  onPanelToggle: () => this.toggleToolPanel(),
3511
3533
  onSectionToggle: (e) => this.toggleToolPanelSection(e),
3512
- onToolbarButtonClick: (e) => this.#_e(e)
3513
- }), this.#L?.(), this.#L = It(this.#n, this.#t?.shell, (e) => {
3534
+ onToolbarButtonClick: (e) => this.#Te(e)
3535
+ }), this.#A?.(), this.#A = Wt(this.#n, this.#o?.shell, (e) => {
3514
3536
  this.style.setProperty("--tbw-tool-panel-width", `${e}px`);
3515
3537
  });
3516
3538
  }
3517
3539
  /**
3518
- * Handle toolbar button click (for config buttons with action).
3540
+ * Handle toolbar button click.
3541
+ * Note: Config/API buttons use element or render, so they handle their own clicks.
3542
+ * This method is kept for backwards compatibility but may emit an event in the future.
3519
3543
  */
3520
- #_e(e) {
3521
- const n = (this.#t?.shell?.header?.toolbarButtons ?? []).find((l) => l.id === e);
3522
- if (n?.action) {
3523
- n.action();
3524
- return;
3525
- }
3526
- const i = this.#o.toolbarButtons.get(e);
3527
- i?.action && i.action();
3544
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3545
+ #Te(e) {
3528
3546
  }
3529
3547
  }
3530
- customElements.get(N.tagName) || customElements.define(N.tagName, N);
3531
- globalThis.DataGridElement = N;
3532
- const oo = {
3548
+ customElements.get(I.tagName) || customElements.define(I.tagName, I);
3549
+ globalThis.DataGridElement = I;
3550
+ const io = {
3533
3551
  /** Ask if a column can be moved. Context: ColumnConfig. Response: boolean | undefined */
3534
3552
  CAN_MOVE_COLUMN: "canMoveColumn",
3535
3553
  /** Get context menu items. Context: ContextMenuParams. Response: ContextMenuItem[] */
3536
3554
  GET_CONTEXT_MENU_ITEMS: "getContextMenuItems"
3537
3555
  };
3538
- class no {
3556
+ class ro {
3539
3557
  /** Plugin version - override in subclass if needed */
3540
3558
  version = "1.0.0";
3541
3559
  /** CSS styles to inject into the grid's shadow DOM */
@@ -3691,7 +3709,7 @@ class no {
3691
3709
  }
3692
3710
  // #endregion
3693
3711
  }
3694
- const E = {
3712
+ const y = {
3695
3713
  // ─── Core Structure ───────────────────────────────────────────────
3696
3714
  ROOT: "tbw-grid-root",
3697
3715
  HEADER: "header",
@@ -3739,7 +3757,7 @@ const E = {
3739
3757
  // Selection (SelectionPlugin applies, core CSS styles)
3740
3758
  RANGE_SELECTION: "range-selection",
3741
3759
  SELECTION_OVERLAY: "selection-overlay"
3742
- }, j = {
3760
+ }, J = {
3743
3761
  // ─── Core Attributes ──────────────────────────────────────────────
3744
3762
  ROW_INDEX: "data-row-index",
3745
3763
  COL_INDEX: "data-col-index",
@@ -3751,23 +3769,23 @@ const E = {
3751
3769
  // TreePlugin
3752
3770
  STICKY: "data-sticky"
3753
3771
  // PinnedColumnsPlugin
3754
- }, io = {
3755
- ROOT: `.${E.ROOT}`,
3756
- HEADER: `.${E.HEADER}`,
3757
- HEADER_ROW: `.${E.HEADER_ROW}`,
3758
- HEADER_CELL: `.${E.HEADER_CELL}`,
3759
- ROWS_VIEWPORT: `.${E.ROWS_VIEWPORT}`,
3760
- ROWS_CONTAINER: `.${E.ROWS_CONTAINER}`,
3761
- DATA_ROW: `.${E.DATA_ROW}`,
3762
- DATA_CELL: `.${E.DATA_CELL}`,
3763
- GROUP_ROW: `.${E.GROUP_ROW}`,
3772
+ }, so = {
3773
+ ROOT: `.${y.ROOT}`,
3774
+ HEADER: `.${y.HEADER}`,
3775
+ HEADER_ROW: `.${y.HEADER_ROW}`,
3776
+ HEADER_CELL: `.${y.HEADER_CELL}`,
3777
+ ROWS_VIEWPORT: `.${y.ROWS_VIEWPORT}`,
3778
+ ROWS_CONTAINER: `.${y.ROWS_CONTAINER}`,
3779
+ DATA_ROW: `.${y.DATA_ROW}`,
3780
+ DATA_CELL: `.${y.DATA_CELL}`,
3781
+ GROUP_ROW: `.${y.GROUP_ROW}`,
3764
3782
  // By data attribute
3765
- ROW_BY_INDEX: (t) => `.${E.DATA_ROW}[${j.ROW_INDEX}="${t}"]`,
3766
- CELL_BY_FIELD: (t) => `.${E.DATA_CELL}[${j.FIELD}="${t}"]`,
3767
- CELL_AT: (t, e) => `.${E.DATA_ROW}[${j.ROW_INDEX}="${t}"] .${E.DATA_CELL}[${j.COL_INDEX}="${e}"]`,
3783
+ ROW_BY_INDEX: (t) => `.${y.DATA_ROW}[${J.ROW_INDEX}="${t}"]`,
3784
+ CELL_BY_FIELD: (t) => `.${y.DATA_CELL}[${J.FIELD}="${t}"]`,
3785
+ CELL_AT: (t, e) => `.${y.DATA_ROW}[${J.ROW_INDEX}="${t}"] .${y.DATA_CELL}[${J.COL_INDEX}="${e}"]`,
3768
3786
  // State selectors
3769
- SELECTED_ROWS: `.${E.DATA_ROW}.${E.SELECTED}`,
3770
- EDITING_CELL: `.${E.DATA_CELL}.${E.EDITING}`
3787
+ SELECTED_ROWS: `.${y.DATA_ROW}.${y.SELECTED}`,
3788
+ EDITING_CELL: `.${y.DATA_CELL}.${y.EDITING}`
3771
3789
  }, lo = {
3772
3790
  // Colors
3773
3791
  COLOR_BG: "--tbw-color-bg",
@@ -3790,7 +3808,7 @@ const E = {
3790
3808
  // Borders
3791
3809
  BORDER_RADIUS: "--tbw-border-radius",
3792
3810
  FOCUS_OUTLINE: "--tbw-focus-outline"
3793
- }, ro = {
3811
+ }, ao = {
3794
3812
  CELL_COMMIT: "cell-commit",
3795
3813
  ROW_COMMIT: "row-commit",
3796
3814
  CHANGED_ROWS_RESET: "changed-rows-reset",
@@ -3801,7 +3819,7 @@ const E = {
3801
3819
  ACTIVATE_CELL: "activate-cell",
3802
3820
  GROUP_TOGGLE: "group-toggle",
3803
3821
  COLUMN_STATE_CHANGE: "column-state-change"
3804
- }, so = {
3822
+ }, co = {
3805
3823
  // Selection plugin
3806
3824
  SELECTION_CHANGE: "selection-change",
3807
3825
  // Tree plugin
@@ -3832,7 +3850,7 @@ const E = {
3832
3850
  DETAIL_EXPAND: "detail-expand",
3833
3851
  // Grouping rows plugin
3834
3852
  GROUP_EXPAND: "group-expand"
3835
- }, ie = {
3853
+ }, re = {
3836
3854
  sum: (t, e) => t.reduce((o, n) => o + (Number(n[e]) || 0), 0),
3837
3855
  avg: (t, e) => {
3838
3856
  const o = t.reduce((n, i) => n + (Number(i[e]) || 0), 0);
@@ -3843,25 +3861,25 @@ const E = {
3843
3861
  max: (t, e) => Math.max(...t.map((o) => Number(o[e]) || -1 / 0)),
3844
3862
  first: (t, e) => t[0]?.[e],
3845
3863
  last: (t, e) => t[t.length - 1]?.[e]
3846
- }, G = /* @__PURE__ */ new Map(), P = {
3864
+ }, U = /* @__PURE__ */ new Map(), M = {
3847
3865
  /**
3848
3866
  * Register a custom aggregator function.
3849
3867
  */
3850
3868
  register(t, e) {
3851
- G.set(t, e);
3869
+ U.set(t, e);
3852
3870
  },
3853
3871
  /**
3854
3872
  * Unregister a custom aggregator function.
3855
3873
  */
3856
3874
  unregister(t) {
3857
- G.delete(t);
3875
+ U.delete(t);
3858
3876
  },
3859
3877
  /**
3860
3878
  * Get an aggregator function by reference.
3861
3879
  */
3862
3880
  get(t) {
3863
3881
  if (t !== void 0)
3864
- return typeof t == "function" ? t : G.get(t) ?? ie[t];
3882
+ return typeof t == "function" ? t : U.get(t) ?? re[t];
3865
3883
  },
3866
3884
  /**
3867
3885
  * Run an aggregator on a set of rows.
@@ -3874,15 +3892,15 @@ const E = {
3874
3892
  * Check if an aggregator exists.
3875
3893
  */
3876
3894
  has(t) {
3877
- return G.has(t) || t in ie;
3895
+ return U.has(t) || t in re;
3878
3896
  },
3879
3897
  /**
3880
3898
  * List all available aggregator names.
3881
3899
  */
3882
3900
  list() {
3883
- return [...Object.keys(ie), ...G.keys()];
3901
+ return [...Object.keys(re), ...U.keys()];
3884
3902
  }
3885
- }, Ae = {
3903
+ }, Te = {
3886
3904
  sum: (t) => t.reduce((e, o) => e + o, 0),
3887
3905
  avg: (t) => t.length ? t.reduce((e, o) => e + o, 0) / t.length : 0,
3888
3906
  count: (t) => t.length,
@@ -3891,42 +3909,42 @@ const E = {
3891
3909
  first: (t) => t[0] ?? 0,
3892
3910
  last: (t) => t[t.length - 1] ?? 0
3893
3911
  };
3894
- function to(t) {
3895
- return Ae[t] ?? Ae.sum;
3912
+ function no(t) {
3913
+ return Te[t] ?? Te.sum;
3896
3914
  }
3897
- function ao(t, e) {
3898
- return to(t)(e);
3915
+ function uo(t, e) {
3916
+ return no(t)(e);
3899
3917
  }
3900
- const co = P.register.bind(P), uo = P.unregister.bind(P), ho = P.get.bind(P), fo = P.run.bind(P), po = P.list.bind(P);
3918
+ const ho = M.register.bind(M), fo = M.unregister.bind(M), po = M.get.bind(M), wo = M.run.bind(M), bo = M.list.bind(M);
3901
3919
  export {
3902
- no as BaseGridPlugin,
3903
- Je as DEFAULT_ANIMATION_CONFIG,
3920
+ ro as BaseGridPlugin,
3921
+ Qe as DEFAULT_ANIMATION_CONFIG,
3904
3922
  O as DEFAULT_GRID_ICONS,
3905
- ro as DGEvents,
3906
- N as DataGridElement,
3907
- X as FitModeEnum,
3923
+ ao as DGEvents,
3924
+ I as DataGridElement,
3925
+ j as FitModeEnum,
3908
3926
  lo as GridCSSVars,
3909
- E as GridClasses,
3910
- j as GridDataAttrs,
3911
- N as GridElement,
3912
- io as GridSelectors,
3913
- oo as PLUGIN_QUERIES,
3914
- so as PluginEvents,
3915
- eo as PluginManager,
3927
+ y as GridClasses,
3928
+ J as GridDataAttrs,
3929
+ I as GridElement,
3930
+ so as GridSelectors,
3931
+ io as PLUGIN_QUERIES,
3932
+ co as PluginEvents,
3933
+ oo as PluginManager,
3916
3934
  k as a,
3917
- P as aggregatorRegistry,
3918
- Ht as builtInSort,
3919
- le as c,
3920
- Pt as defaultComparator,
3935
+ M as aggregatorRegistry,
3936
+ Ot as builtInSort,
3937
+ se as c,
3938
+ Mt as defaultComparator,
3921
3939
  Pe as e,
3922
3940
  Me as g,
3923
- ho as getAggregator,
3924
- to as getValueAggregator,
3925
- po as listAggregators,
3926
- co as registerAggregator,
3927
- fo as runAggregator,
3928
- ao as runValueAggregator,
3929
- K as s,
3930
- uo as unregisterAggregator
3941
+ po as getAggregator,
3942
+ no as getValueAggregator,
3943
+ bo as listAggregators,
3944
+ ho as registerAggregator,
3945
+ wo as runAggregator,
3946
+ uo as runValueAggregator,
3947
+ Q as s,
3948
+ fo as unregisterAggregator
3931
3949
  };
3932
3950
  //# sourceMappingURL=index.js.map