@toolbox-web/grid 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +2 -2
- package/{index-DG2CZ_Zo.js → index-YjW60MHD.js} +117 -111
- package/index-YjW60MHD.js.map +1 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +3 -3
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +2 -2
- package/umd/grid.umd.js.map +1 -1
- package/index-DG2CZ_Zo.js.map +0 -1
package/umd/grid.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(E,V){typeof exports=="object"&&typeof module<"u"?V(exports):typeof define=="function"&&define.amd?define(["exports"],V):(E=typeof globalThis<"u"?globalThis:E||self,V(E.TbwGrid={}))})(this,(function(E){"use strict";const V=':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{-webkit-user-select:none;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}:host .data-grid-row>.cell.editing input:not([type=checkbox]),:host .data-grid-row>.cell.editing select,:host .data-grid-row>.cell.editing textarea{width:100%;height:100%;max-width:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}:host .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}:host .data-grid-row:hover{background:var(--tbw-color-row-hover)}:host .sortable{cursor:pointer;-webkit-user-select:none;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;-webkit-user-select:none;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}:host .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}:host .cell-focus,:host .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-row-alt);font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}:host .group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px)}:host .group-row .group-toggle{background:none;border:0;cursor:pointer;padding:0 4px 0 0;font:inherit}:host .group-row .group-count{margin-left:4px;opacity:.7}:host .sticky-left,:host .sticky-right{position:sticky;z-index:25}:host .header-row>.cell.sticky-left,:host .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}:host .data-grid-row>.cell.sticky-left,:host .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}:host .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}:host .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}.grid-container{position:relative;width:100%;height:100%}.grid-placeholder{padding:2rem;text-align:center;color:var(--tbw-color-fg);opacity:.6}:host{--tbw-shell-header-height: 44px;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: 14px;--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 280px;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 40px;--tbw-tool-panel-transition: 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}: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;-webkit-user-select:none;user-select:none}:host .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}:host .tbw-accordion-section.single .tbw-accordion-header{cursor:default}:host .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}:host .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}:host .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}:host .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}:host .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .tbw-accordion-content{display:none}:host .tbw-accordion-section.expanded .tbw-accordion-content{display:block}:host .tbw-quick-filter-input{flex:1;max-width:300px;height:28px;padding:0 8px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:13px}:host .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}:host .tbw-selection-summary{font-size:13px;color:var(--tbw-color-fg-muted);white-space:nowrap}@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)}';function Ee(t){const e=new Map;return t._sortState&&e.set(t._sortState.field,{direction:t._sortState.direction===1?"asc":"desc",priority:0}),e}function te(t,e){const o=t._columns,n=Ee(t);return{columns:o.map((i,s)=>{const r={field:i.field,order:s,visible:!0},l=i;l.__renderedWidth!==void 0?r.width=l.__renderedWidth:i.width!==void 0&&(r.width=typeof i.width=="string"?parseFloat(i.width):i.width);const a=n.get(i.field);a&&(r.sort=a);for(const d of e)if(d.getColumnState){const f=d.getColumnState(i.field);f&&Object.assign(r,f)}return r})}}function Ce(t,e,o,n){if(!e.columns||e.columns.length===0)return;const i=new Map(e.columns.map(l=>[l.field,l])),s=o.map(l=>{const a=i.get(l.field);if(!a)return l;const d={...l};return a.width!==void 0&&(d.width=a.width,d.__renderedWidth=a.width),a.visible!==void 0&&(d.hidden=!a.visible),d});s.sort((l,a)=>{const d=i.get(l.field)?.order??1/0,f=i.get(a.field)?.order??1/0;return d-f}),t._columns=s;const r=e.columns.filter(l=>l.sort!==void 0).sort((l,a)=>(l.sort?.priority??0)-(a.sort?.priority??0));if(r.length>0){const l=r[0];l.sort&&(t._sortState={field:l.field,direction:l.sort.direction==="asc"?1:-1})}else t._sortState=null;for(const l of n)if(l.applyColumnState)for(const a of e.columns)l.applyColumnState(a.field,a)}function ye(t,e,o){let n=null;return()=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null;const i=te(t,e());o(i)},100)}}const q={STRETCH:"stretch",FIXED:"fixed"},oe={mode:"reduced-motion",duration:200,easing:"ease-out"},P={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰"};function Se(t){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"}function ne(t,e){if(e&&e.length){const s={};return e.forEach(r=>{r.type&&(s[r.field]=r.type)}),{columns:e,typeMap:s}}const o=t[0]||{},n=Object.keys(o).map(s=>{const r=o[s],l=Se(r);return{field:s,header:s.charAt(0).toUpperCase()+s.slice(1),type:l}}),i={};return n.forEach(s=>{i[s.field]=s.type||"string"}),{columns:n,typeMap:i}}const Re=/{{\s*([^}]+)\s*}}/g,H="__DG_EMPTY__",Ae=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,xe=/__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/,Te=new Set(["script","iframe","object","embed","form","input","button","textarea","select","link","meta","base","style","template","slot","portal","frame","frameset","applet","noscript","noembed","plaintext","xmp","listing"]),ie=/^on\w+$/i,Le=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),Pe=/^\s*(javascript|vbscript|data|blob):/i;function X(t){if(!t||typeof t!="string")return"";if(t.indexOf("<")===-1)return t;const e=document.createElement("template");return e.innerHTML=t,He(e.content),e.innerHTML}function He(t){const e=[],o=t.querySelectorAll("*");for(const n of o){const i=n.tagName.toLowerCase();if(Te.has(i)){e.push(n);continue}if((i==="svg"||n.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(n.attributes).some(l=>ie.test(l.name)||l.name==="href"||l.name==="xlink:href")){e.push(n);continue}const s=[];for(const r of n.attributes){const l=r.name.toLowerCase();if(ie.test(l)){s.push(r.name);continue}if(Le.has(l)&&Pe.test(r.value)){s.push(r.name);continue}if(l==="style"&&/expression\s*\(|javascript:|behavior\s*:/i.test(r.value)){s.push(r.name);continue}}s.forEach(r=>n.removeAttribute(r))}e.forEach(n=>n.remove())}function se(t,e){if(!t||t.indexOf("{{")===-1)return t;const o=[],n=t.replace(Re,(l,a)=>{const d=ke(a,e);return o.push({expr:a.trim(),result:d}),d}),i=Oe(n),s=o.length&&o.every(l=>l.result===""||l.result===H);return/Reflect\.|\bProxy\b|ownKeys\(/.test(t)||s?"":i}function ke(t,e){if(t=(t||"").trim(),!t||/\b(Reflect|Proxy|ownKeys)\b/.test(t))return H;if(t==="value")return e.value==null?H:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const n=t.slice(4),i=e.row?e.row[n]:void 0;return i==null?H:String(i)}if(t.length>80||!Ae.test(t)||xe.test(t))return H;const o=t.match(/\./g);if(o&&o.length>1)return H;try{const i=new Function("value","row",`return (${t});`)(e.value,e.row),s=i==null?"":String(i);return/Reflect|Proxy|ownKeys/.test(s)?H:s||H}catch{return H}}function Oe(t){return t&&t.replace(new RegExp(H,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function Me(t){if(/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.TEXT_NODE&&/Reflect|Proxy|ownKeys/.test(e.textContent||"")&&(e.textContent="")}),/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(/Reflect|Proxy|ownKeys/.test(t.textContent||""))for(;t.firstChild;)t.removeChild(t.firstChild);t.textContent=(t.textContent||"").replace(/Reflect|Proxy|ownKeys/g,"")}(t.textContent||"").trim().length===0&&(t.textContent="")}}function re(t){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(t),o=n=>e?"":se(t,n);return o.__blocked=e,o}function ze(t){return Array.from(t.querySelectorAll("tbw-grid-column")).map(o=>{const n=o.getAttribute("field")||"";if(!n)return null;const i=o.getAttribute("type")||void 0,r=i&&new Set(["number","string","date","boolean","select","typeahead"]).has(i)?i:void 0,l=o.getAttribute("header")||void 0,a=o.hasAttribute("sortable"),d=o.hasAttribute("editable"),f={field:n,type:r,header:l,sortable:a,editable:d};o.hasAttribute("resizable")&&(f.resizable=!0),o.hasAttribute("sizable")&&(f.resizable=!0);const h=o.getAttribute("options");h&&(f.options=h.split(",").map(b=>{const[w,v]=b.includes(":")?b.split(":"):[b.trim(),b.trim()];return{value:w.trim(),label:v?.trim()||w.trim()}}));const p=o.querySelector("tbw-grid-column-view"),c=o.querySelector("tbw-grid-column-editor"),u=o.querySelector("tbw-grid-column-header");return p&&(f.__viewTemplate=p),c&&(f.__editorTemplate=c),u&&(f.__headerTemplate=u),f}).filter(o=>!!o)}function De(t,e){if((!t||!t.length)&&(!e||!e.length))return[];if(!t||!t.length)return e||[];if(!e||!e.length)return t;const o={};e.forEach(i=>o[i.field]=i);const n=t.map(i=>{const s=o[i.field];if(!s)return i;const r={...i};return s.header&&!r.header&&(r.header=s.header),s.type&&!r.type&&(r.type=s.type),r.sortable=i.sortable||s.sortable,(i.resizable===!0||s.resizable===!0)&&(r.resizable=!0),r.editable=i.editable||s.editable,s.__viewTemplate&&(r.__viewTemplate=s.__viewTemplate),s.__editorTemplate&&(r.__editorTemplate=s.__editorTemplate),s.__headerTemplate&&(r.__headerTemplate=s.__headerTemplate),delete o[i.field],r});return Object.keys(o).forEach(i=>n.push(o[i])),n}function Y(t,e){try{t.part?.add?.(e)}catch{}const o=t.getAttribute("part");o?o.split(/\s+/).includes(e)||t.setAttribute("part",o+" "+e):t.setAttribute("part",e)}function Ne(t){t.__lightDomColumnsCache||(t.__originalColumnNodes=Array.from(t.querySelectorAll("tbw-grid-column")),t.__lightDomColumnsCache=t.__originalColumnNodes.length?ze(t):[]);const e=t.__lightDomColumnsCache,o=De(t._columns,e);o.forEach(i=>{i.__viewTemplate&&!i.__compiledView&&(i.__compiledView=re(i.__viewTemplate.innerHTML)),i.__editorTemplate&&!i.__compiledEditor&&(i.__compiledEditor=re(i.__editorTemplate.innerHTML))});const{columns:n}=ne(t._rows,o);t._columns=n}function le(t){const e=t.effectiveConfig?.fitMode||t.fitMode||q.STRETCH;if(e!==q.STRETCH&&e!==q.FIXED||t.__didInitialAutoSize||!t.isConnected)return;const o=t._headerRowEl?.children||[];if(!o.length)return;let n=!1;t._visibleColumns.forEach((i,s)=>{if(i.width)return;const r=o[s];let l=r?r.scrollWidth:0;for(const a of t._rowPool){const d=a.children[s];if(d){const f=d.scrollWidth;f>l&&(l=f)}}l>0&&(i.width=l+2,i.__autoSized=!0,n=!0)}),n&&D(t),t.__didInitialAutoSize=!0}function D(t){(t.effectiveConfig?.fitMode||t.fitMode||q.STRETCH)===q.STRETCH?t._gridTemplate=t._visibleColumns.map(o=>{if(o.width)return`${o.width}px`;const n=o.minWidth;return n!=null?`minmax(${n}px, 1fr)`:"1fr"}).join(" ").trim():t._gridTemplate=t._visibleColumns.map(o=>o.width?`${o.width}px`:"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}function Ie(t){switch(t.type){case"number":return e=>{const o=document.createElement("input");return o.type="number",o.value=e.value!=null?String(e.value):"",o.addEventListener("blur",()=>e.commit(o.value===""?null:Number(o.value))),o.addEventListener("keydown",n=>{n.key==="Enter"&&e.commit(o.value===""?null:Number(o.value)),n.key==="Escape"&&e.cancel()}),o.focus(),o};case"boolean":return e=>{const o=document.createElement("input");return o.type="checkbox",o.checked=!!e.value,o.addEventListener("change",()=>e.commit(o.checked)),o.focus(),o};case"date":return e=>{const o=document.createElement("input");return o.type="date",e.value instanceof Date&&(o.valueAsDate=e.value),o.addEventListener("change",()=>e.commit(o.valueAsDate)),o.addEventListener("keydown",n=>{n.key==="Escape"&&e.cancel()}),o.focus(),o};case"select":case"typeahead":return e=>{const o=document.createElement("select");e.column.multi&&(o.multiple=!0),(typeof e.column.options=="function"?e.column.options():e.column.options||[]).forEach(s=>{const r=document.createElement("option");r.value=String(s.value),r.textContent=s.label,(e.column.multi&&Array.isArray(e.value)&&e.value.includes(s.value)||!e.column.multi&&e.value===s.value)&&(r.selected=!0),o.appendChild(r)});const i=()=>{if(e.column.multi){const s=[];Array.from(o.selectedOptions).forEach(r=>{s.push(r.value)}),e.commit(s)}else e.commit(o.value)};return o.addEventListener("change",i),o.addEventListener("blur",i),o.addEventListener("keydown",s=>{s.key==="Escape"&&e.cancel()}),o.focus(),o};default:return e=>{const o=document.createElement("input");return o.type="text",o.value=e.value!=null?String(e.value):"",o.addEventListener("blur",()=>e.commit(o.value)),o.addEventListener("keydown",n=>{n.key==="Enter"&&e.commit(o.value),n.key==="Escape"&&e.cancel()}),o.focus(),o}}}function qe(t,e){if(t._dispatchKeyDown?.(e))return;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,l=e.composedPath?e.composedPath():[],a=l&&l.length?l[0]:e.target,d=f=>{if(!f)return!1;const h=f.tagName;return!!(h==="INPUT"||h==="SELECT"||h==="TEXTAREA"||f.isContentEditable)};if(!(d(a)&&(e.key==="Home"||e.key==="End"))&&!(d(a)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&a.tagName==="INPUT"&&a.type==="number")&&!(d(a)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(d(a)&&(e.key==="Enter"||e.key==="Escape"))&&!(i&&(r==="select"||r==="typeahead")&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{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),z(t);return}case"ArrowDown":i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.min(o,t._focusRow+1),e.preventDefault();break;case"ArrowUp":i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault();break;case"ArrowRight":t._focusCol=Math.min(n,t._focusCol+1),e.preventDefault();break;case"ArrowLeft":t._focusCol=Math.max(0,t._focusCol-1),e.preventDefault();break;case"Home":(e.ctrlKey||e.metaKey)&&(i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=0),t._focusCol=0,e.preventDefault(),z(t,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=o),t._focusCol=n,e.preventDefault(),z(t,{forceScrollRight:!0});return;case"PageDown":t._focusRow=Math.min(o,t._focusRow+20),e.preventDefault();break;case"PageUp":t._focusRow=Math.max(0,t._focusRow-20),e.preventDefault();break;case"Enter":return typeof t.beginBulkEdit=="function"?t.beginBulkEdit(t._focusRow):t.dispatchEvent(new CustomEvent("activate-cell",{detail:{row:t._focusRow,col:t._focusCol}})),z(t);default:return}z(t)}}function z(t,e){if(t._virtualization?.enabled){const{rowHeight:r,container:l,viewportEl:a}=t._virtualization,d=l,f=a?.clientHeight??d?.clientHeight??0;if(d&&f>0){const h=t._focusRow*r;h<d.scrollTop?d.scrollTop=h:h+r>d.scrollTop+f&&(d.scrollTop=h-f+r)}}t._activeEditRows!==void 0&&t._activeEditRows!==-1||t.refreshVirtualWindow(!1),Array.from(t._bodyEl.querySelectorAll(".cell-focus")).forEach(r=>r.classList.remove("cell-focus")),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(r=>{r.setAttribute("aria-selected","false")});const n=t._focusRow,i=t._virtualization.start??0,s=t._virtualization.end??t._rows.length;if(n>=i&&n<s){const r=t._bodyEl.querySelectorAll(".data-grid-row")[n-i],l=r?.children[t._focusCol];if(l){l.classList.add("cell-focus"),l.setAttribute("aria-selected","true");const a=t.shadowRoot?.querySelector(".tbw-scroll-area");if(a&&l)if(e?.forceScrollLeft)a.scrollLeft=0;else if(e?.forceScrollRight)a.scrollLeft=a.scrollWidth-a.clientWidth;else{const d=t._getHorizontalScrollOffsets?.(r??void 0,l)??{left:0,right:0};if(!d.skipScroll){const f=l.getBoundingClientRect(),h=a.getBoundingClientRect(),p=f.left-h.left+a.scrollLeft,c=p+f.width,u=a.scrollLeft+d.left,b=a.scrollLeft+a.clientWidth-d.right;p<u?a.scrollLeft=p-d.left:c>b&&(a.scrollLeft=c-a.clientWidth+d.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&l.classList.contains("editing")){const d=l.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])');if(d&&document.activeElement!==d)try{d.focus()}catch{}}else if(!l.contains(document.activeElement)){l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{}}}}}const Be="__cellDisplayCache",$e="__cellCacheEpoch";function j(t){t[Be]=void 0,t[$e]=void 0,t.__hasSpecialColumns=void 0}function We(t,e,o,n,i){const s=Math.max(0,o-e),r=t._bodyEl,l=t._visibleColumns,a=l.length;let d=t.__cachedHeaderRowCount;for(d===void 0&&(d=t.shadowRoot?.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=d);t._rowPool.length<s;){const h=document.createElement("div");h.className="data-grid-row",h.setAttribute("role","row"),h.addEventListener("click",p=>ae(t,p,h,!1)),h.addEventListener("dblclick",p=>ae(t,p,h,!0)),t._rowPool.push(h)}if(t._rowPool.length>s){for(let h=s;h<t._rowPool.length;h++){const p=t._rowPool[h];p.parentNode===r&&p.remove()}t._rowPool.length=s}const f=i&&t.__hasRenderRowPlugins!==!1;for(let h=0;h<s;h++){const p=e+h,c=t._rows[p],u=t._rowPool[h];if(u.setAttribute("aria-rowindex",String(p+d+1)),f&&i(c,u,p)){u.__epoch=n,u.__rowDataRef=c,u.parentNode!==r&&r.appendChild(u);continue}const b=u.__epoch,w=u.__rowDataRef,v=u.children.length,A=b===n&&v===a,C=w!==c;let g=!1;if(A&&C){for(let _=0;_<a;_++)if(l[_].externalView&&!u.querySelector(`.cell[data-col="${_}"] [data-external-view]`)){g=!0;break}}if(!A||g){const _=u.querySelector(".cell.editing"),S=t._activeEditRows===p;if(_&&!S)u.__isCustomRow&&(u.className="data-grid-row",u.setAttribute("role","row"),u.__isCustomRow=!1),B(t,u,c,p),u.__epoch=n,u.__rowDataRef=c;else if(_&&S)K(t,u,c,p),u.__rowDataRef=c;else if(u.__isCustomRow&&(u.className="data-grid-row",u.setAttribute("role","row"),u.__isCustomRow=!1),B(t,u,c,p),u.__epoch=n,u.__rowDataRef=c,S){const x=u.children;for(let L=0;L<x.length;L++){const O=t._visibleColumns[L];O&&O.editable&&M(t,c,p,O,x[L])}}}else if(C){const _=u.querySelector(".cell.editing"),S=t._activeEditRows===p;if(_&&!S)B(t,u,c,p),u.__epoch=n,u.__rowDataRef=c;else if(K(t,u,c,p),u.__rowDataRef=c,S&&!_){const x=u.children;for(let L=0;L<x.length;L++){const O=t._visibleColumns[L];O&&O.editable&&M(t,c,p,O,x[L])}}}else{const _=u.querySelector(".cell.editing"),S=t._activeEditRows===p;if(_&&!S)B(t,u,c,p),u.__epoch=n,u.__rowDataRef=c;else if(K(t,u,c,p),S&&!_){const x=u.children;for(let L=0;L<x.length;L++){const O=t._visibleColumns[L];O&&O.editable&&M(t,c,p,O,x[L])}}}const m=t._changedRowIndices.has(p),y=u.classList.contains("changed");m!==y&&u.classList.toggle("changed",m),u.parentNode!==r&&r.appendChild(u)}}function K(t,e,o,n){const i=e.children,s=t._visibleColumns,r=s.length,l=i.length,a=r<l?r:l,d=t._focusRow,f=t._focusCol;let h=t.__hasSpecialColumns;if(h===void 0){h=!1;for(let c=0;c<r;c++){const u=s[c];if(u.__viewTemplate||u.__compiledView||u.viewRenderer||u.externalView||u.format||u.type==="date"||u.type==="boolean"){h=!0;break}}t.__hasSpecialColumns=h}const p=String(n);if(!h){for(let c=0;c<a;c++){const u=i[c],b=o[s[c].field];u.textContent=b==null?"":String(b),u.getAttribute("data-row")!==p&&u.setAttribute("data-row",p);const w=d===n&&f===c,v=u.classList.contains("cell-focus");w!==v&&(u.classList.toggle("cell-focus",w),u.setAttribute("aria-selected",String(w)))}return}for(let c=0;c<a;c++)if(s[c].externalView&&!i[c].querySelector("[data-external-view]")){B(t,e,o,n);return}for(let c=0;c<a;c++){const u=s[c],b=i[c];b.getAttribute("data-row")!==p&&b.setAttribute("data-row",p);const w=d===n&&f===c,v=b.classList.contains("cell-focus");if(w!==v&&(b.classList.toggle("cell-focus",w),b.setAttribute("aria-selected",String(w))),b.classList.contains("editing"))continue;if(u.viewRenderer){const C=o[u.field],g=u.viewRenderer({row:o,value:C,field:u.field,column:u});typeof g=="string"?b.innerHTML=X(g):g?(b.innerHTML="",b.appendChild(g)):b.textContent=C==null?"":String(C);continue}if(u.__viewTemplate||u.__compiledView||u.externalView)continue;const R=o[u.field];let A;if(u.format)try{const C=u.format(R,o);A=C==null?"":String(C)}catch{A=R==null?"":String(R)}else if(u.type==="date"){if(R==null||R==="")A="";else if(R instanceof Date)A=isNaN(R.getTime())?"":R.toLocaleDateString();else{const C=new Date(R);A=isNaN(C.getTime())?"":C.toLocaleDateString()}b.textContent=A}else if(u.type==="boolean"){const C=!!R;b.innerHTML=`<span role="checkbox" aria-checked="${C}" aria-label="${C}">${C?"🗹":"☐"}</span>`}else A=R==null?"":String(R),b.textContent=A}}function B(t,e,o,n){e.innerHTML="";const i=t._visibleColumns,s=i.length,r=t._focusRow,l=t._focusCol,a=t.effectiveConfig?.editOn||t.editOn,d=t,f=document.createDocumentFragment();for(let h=0;h<s;h++){const p=i[h],c=document.createElement("div");c.className="cell",Y(c,"cell"),c.setAttribute("role","gridcell"),c.setAttribute("aria-colindex",String(h+1)),c.setAttribute("data-col",String(h)),c.setAttribute("data-row",String(n)),c.setAttribute("data-field",p.field),p.type,p.type&&c.setAttribute("data-type",p.type);let u=o[p.field];const b=p.format;if(b)try{u=b(u,o)}catch{}const w=p.__compiledView,v=p.__viewTemplate,R=p.viewRenderer,A=p.externalView;let C=!1;if(R){const g=R({row:o,value:u,field:p.field,column:p});typeof g=="string"?(c.innerHTML=X(g),C=!0):g?c.appendChild(g):c.textContent=u==null?"":String(u)}else if(A){const g=A,m=document.createElement("div");m.setAttribute("data-external-view",""),m.setAttribute("data-field",p.field),c.appendChild(m);const y={row:o,value:u,field:p.field,column:p};if(g.mount)try{g.mount({placeholder:m,context:y,spec:g})}catch{}else queueMicrotask(()=>{try{d.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:m,spec:g,context:y}}))}catch{}});m.setAttribute("data-mounted","")}else if(w){const g=w({row:o,value:u,field:p.field,column:p}),m=w.__blocked;c.innerHTML=m?"":X(g),C=!0,m&&(c.textContent="",c.setAttribute("data-blocked-template",""))}else if(v){const g=v.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(g)?(c.textContent="",c.setAttribute("data-blocked-template","")):(c.innerHTML=X(se(g,{row:o,value:u})),C=!0)}else if(p.type==="date")if(u==null||u==="")c.textContent="";else{let g=null;if(u instanceof Date)g=u;else if(typeof u=="number"||typeof u=="string"){const m=new Date(u);isNaN(m.getTime())||(g=m)}c.textContent=g?g.toLocaleDateString():""}else if(p.type==="boolean"){const g=!!u;c.innerHTML=`<span role="checkbox" aria-checked="${g}" aria-label="${g}">${g?"🗹":"☐"}</span>`}else c.textContent=u==null?"":String(u);if(C){Me(c);const g=c.textContent||"";/Proxy|Reflect\.ownKeys/.test(g)&&(c.textContent=g.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(c.textContent||"")&&(c.textContent=""))}c.hasAttribute("data-blocked-template")&&(c.textContent||"").trim().length&&(c.textContent=""),p.editable?(c.tabIndex=0,c.addEventListener("mousedown",()=>{if(c.classList.contains("editing"))return;const g=Number(c.getAttribute("data-row")),m=Number(c.getAttribute("data-col"));isNaN(g)||isNaN(m)||(t._focusRow=g,t._focusCol=m,z(t))}),a==="click"?c.addEventListener("click",g=>{if(c.classList.contains("editing"))return;g.stopPropagation();const m=Number(c.getAttribute("data-row")),y=Number(c.getAttribute("data-col"));if(isNaN(m)||isNaN(y))return;const _=t._rows[m],S=t._visibleColumns[y];!_||!S||(t._focusRow=m,t._focusCol=y,M(t,_,m,S,c))}):c.addEventListener("dblclick",g=>{g.stopPropagation();const m=Number(c.getAttribute("data-row"));if(isNaN(m))return;const y=t._rows[m];if(!y)return;$(t,m,y);const _=t.findRenderedRowElement?.(m);if(_){const S=_.children;for(let x=0;x<S.length;x++){const L=t._visibleColumns[x];L&&L.editable&&M(t,y,m,L,S[x])}}}),c.addEventListener("keydown",g=>{const m=Number(c.getAttribute("data-row")),y=Number(c.getAttribute("data-col"));if(isNaN(m)||isNaN(y))return;const _=t._rows[m],S=t._visibleColumns[y];if(!(!_||!S)){if((S.type==="select"||S.type==="typeahead")&&!c.classList.contains("editing")&&g.key==="Enter"){g.preventDefault(),t._activeEditRows!==m&&$(t,m,_),M(t,_,m,S,c),setTimeout(()=>{const x=c.querySelector("select");try{x?.showPicker?.()}catch{}x?.focus()},0);return}if(S.type==="boolean"&&g.key===" "&&!c.classList.contains("editing")){g.preventDefault(),t._activeEditRows!==m&&$(t,m,_);const x=!_[S.field];Q(t,m,S,x,_),c.innerHTML=`<span role="checkbox" aria-checked="${x}" aria-label="${x}">${x?"🗹":"☐"}</span>`;return}if(g.key==="Enter"&&!c.classList.contains("editing")){g.preventDefault(),g.stopPropagation(),t._focusRow=m,t._focusCol=y,typeof t.beginBulkEdit=="function"?t.beginBulkEdit(m):M(t,_,m,S,c);return}if(g.key==="F2"&&!c.classList.contains("editing")){g.preventDefault(),M(t,_,m,S,c);return}}})):p.type==="boolean"&&(c.hasAttribute("tabindex")||(c.tabIndex=0)),r===n&&l===h?(c.classList.add("cell-focus"),c.setAttribute("aria-selected","true")):c.setAttribute("aria-selected","false"),f.appendChild(c)}e.appendChild(f)}function ae(t,e,o,n){if(e.target?.closest(".resize-handle"))return;const i=o.querySelector(".cell[data-row]");if(!i)return;const s=Number(i.getAttribute("data-row"));if(isNaN(s))return;const r=t._rows[s];if(!r||t._dispatchRowClick?.(e,s,r,o))return;const l=e.target?.closest(".cell[data-col]");if(l){if(l.classList.contains("editing"))return;const d=Number(l.getAttribute("data-col"));if(!isNaN(d)){if(t._dispatchCellClick?.(e,s,d,l))return;t._focusRow=s,t._focusCol=d,z(t)}}if(o.querySelector(".cell.editing")){const d=o.querySelectorAll(".cell.editing");if(!n)return;d.forEach(f=>f.classList.remove("editing"))}const a=t.effectiveConfig?.editOn||t.editOn||"doubleClick";if(a==="click"||a==="doubleClick"&&n)$(t,s,r);else return;Array.from(o.children).forEach((d,f)=>{const h=t._visibleColumns[f];h&&h.editable&&M(t,r,s,h,d)}),l&&queueMicrotask(()=>{const d=o.querySelector(`.cell[data-col="${t._focusCol}"]`);if(d?.classList.contains("editing")){const f=d.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])');try{f?.focus()}catch{}}})}function Z(t){return!(t==="__proto__"||t==="constructor"||t==="prototype")}function $(t,e,o){t._activeEditRows!==e&&(t._rowEditSnapshots.set(e,{...o}),t._activeEditRows=e)}function N(t,e,o){if(t._activeEditRows!==e)return;const n=t._rowEditSnapshots.get(e),i=t._rows[e],s=t.findRenderedRowElement?.(e);if(!o&&s&&i&&s.querySelectorAll(".cell.editing").forEach(l=>{const a=Number(l.getAttribute("data-col"));if(isNaN(a))return;const d=t._visibleColumns[a];if(!d)return;const f=l.querySelector("input,textarea,select");if(f){let h;f instanceof HTMLInputElement&&f.type==="checkbox"?h=f.checked:(h=f.value,d.type==="number"&&h!==""&&(h=Number(h))),i[d.field]!==h&&Q(t,e,d,h,i)}}),o&&n&&i)Object.keys(n).forEach(r=>i[r]=n[r]),t._changedRowIndices.delete(e),j(t);else if(!o){const r=t._changedRowIndices.has(e);t.dispatchEvent(new CustomEvent("row-commit",{detail:{rowIndex:e,row:i,changed:r,changedRows:t.changedRows,changedRowIndices:t.changedRowIndices}}))}t._rowEditSnapshots.delete(e),t._activeEditRows=-1,s&&(B(t,s,t._rows[e],e),t._changedRowIndices.has(e)?s.classList.add("changed"):s.classList.remove("changed")),queueMicrotask(()=>{try{const r=t._focusRow,l=t._focusCol,a=t.findRenderedRowElement?.(r);if(a){Array.from(t._bodyEl.querySelectorAll(".cell-focus")).forEach(f=>f.classList.remove("cell-focus"));const d=a.querySelector(`.cell[data-row="${r}"][data-col="${l}"]`);d&&(d.classList.add("cell-focus"),d.setAttribute("aria-selected","true"),d.hasAttribute("tabindex")||d.setAttribute("tabindex","-1"),d.focus({preventScroll:!0}))}}catch{}})}function Q(t,e,o,n,i){const s=o.field;if(!Z(s)||i[s]===n)return;i[s]=n;const l=!t._changedRowIndices.has(e);t._changedRowIndices.add(e);const a=t.findRenderedRowElement?.(e);a&&a.classList.add("changed"),t.dispatchEvent(new CustomEvent("cell-commit",{detail:{row:i,field:s,value:n,rowIndex:e,changedRows:t.changedRows,changedRowIndices:t.changedRowIndices,firstTimeForRow:l}}))}function M(t,e,o,n,i){if(!n.editable||(t._activeEditRows!==o&&$(t,o,e),i.classList.contains("editing")))return;const s=Z(n.field)?e[n.field]:void 0;i.classList.add("editing");let r=!1;const l=c=>{r||t._activeEditRows===-1||Q(t,o,n,c,e)},a=()=>{r=!0,e[n.field]=Z(n.field)?s:void 0;const c=i.querySelector("input,textarea,select");c&&(typeof HTMLInputElement<"u"&&c instanceof HTMLInputElement&&c.type==="checkbox"?c.checked=!!s:"value"in c&&(c.value=s??""))},d=document.createElement("div");d.style.display="contents",i.innerHTML="",i.appendChild(d),d.addEventListener("keydown",c=>{c.key==="Enter"&&(c.stopPropagation(),c.preventDefault(),r=!0,N(t,o,!1)),c.key==="Escape"&&(c.stopPropagation(),c.preventDefault(),a(),N(t,o,!0))});const f=n.__editorTemplate,h=n.editor||(f?"template":Ie(n)),p=s;if(h==="template"&&f){const c=f.cloneNode(!0),u=n.__compiledEditor;u?c.innerHTML=u({row:e,value:s,field:n.field,column:n}):c.querySelectorAll("*").forEach(w=>{w.childNodes.length===1&&w.firstChild?.nodeType===Node.TEXT_NODE&&(w.textContent=w.textContent?.replace(/{{\s*value\s*}}/g,s==null?"":String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g,(v,R)=>{const A=e[R];return A==null?"":String(A)})||"")});const b=c.querySelector("input,textarea,select");if(b){const w=typeof HTMLInputElement<"u";w&&b instanceof HTMLInputElement&&b.type==="checkbox"?b.checked=!!s:"value"in b&&(b.value=s??""),b.addEventListener("blur",()=>{const v=w&&b instanceof HTMLInputElement&&b.type==="checkbox"?b.checked:b.value;l(v)}),b.addEventListener("keydown",v=>{if(v.key==="Enter"){v.stopPropagation(),v.preventDefault(),r=!0;const R=w&&b instanceof HTMLInputElement&&b.type==="checkbox"?b.checked:b.value;l(R),N(t,o,!1)}v.key==="Escape"&&(v.stopPropagation(),v.preventDefault(),a(),N(t,o,!0))}),w&&b instanceof HTMLInputElement&&b.type==="checkbox"&&b.addEventListener("change",()=>{const v=b.checked;l(v)}),setTimeout(()=>b.focus(),0)}d.appendChild(c)}else if(typeof h=="string"){const c=document.createElement(h);c.value=p,c.addEventListener("change",()=>l(c.value)),d.appendChild(c)}else if(typeof h=="function"){const c=h({row:e,value:p,field:n.field,column:n,commit:l,cancel:a});typeof c=="string"?d.innerHTML=c:d.appendChild(c)}else if(h&&typeof h=="object"){const c=document.createElement("div");c.setAttribute("data-external-editor",""),c.setAttribute("data-field",n.field),d.appendChild(c);const u={row:e,value:p,field:n.field,column:n,commit:l,cancel:a};if(h.mount)try{h.mount({placeholder:c,context:u,spec:h})}catch{}else t.dispatchEvent(new CustomEvent("mount-external-editor",{detail:{placeholder:c,spec:h,context:u}}))}}function ce(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function de(t,e,o){const i=o.find(l=>l.field===e.field)?.sortComparator??ce,{field:s,direction:r}=e;return[...t].sort((l,a)=>i(l[s],a[s],l,a)*r)}function ue(t,e,o,n){t._rows=e,t.__rowRenderEpoch++,t._rowPool.forEach(i=>i.__epoch=-1),W(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:n}})),t.requestStateChange?.()}function he(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),fe(t,e,1)):t._sortState.direction===1?fe(t,e,-1):(t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(n=>n.__epoch=-1),t._rows=t.__originalOrder.slice(),W(t),t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(n=>{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")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),t.requestStateChange?.())}function fe(t,e,o){t._sortState={field:e.field,direction:o};const n={field:e.field,direction:o},i=t._columns,r=(t.effectiveConfig?.sortHandler??de)(t._rows,n,i);r&&typeof r.then=="function"?r.then(l=>{ue(t,l,e,o)}):ue(t,r,e,o)}function Ve(t,e){typeof e=="string"?t.textContent=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}function W(t){t._headerRowEl=t.findHeaderRow();const e=t._headerRowEl;e.innerHTML="",t._visibleColumns.forEach((o,n)=>{const i=document.createElement("div");i.className="cell",Y(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));const s=o.__headerTemplate;if(s)Array.from(s.childNodes).forEach(r=>i.appendChild(r.cloneNode(!0)));else{const r=o.header||o.field,l=document.createElement("span");l.textContent=r,i.appendChild(l)}if(o.sortable){i.classList.add("sortable"),i.tabIndex=0;const r=document.createElement("span");Y(r,"sort-indicator");const l=t._sortState?.field===o.field?t._sortState.direction:0,a={...P,...t.icons},d=l===1?a.sortAsc:l===-1?a.sortDesc:a.sortNone;Ve(r,d),i.appendChild(r),i.setAttribute("aria-sort",l===0?"none":l===1?"ascending":"descending"),i.addEventListener("click",f=>{t._resizeController?.isResizing||t._dispatchHeaderClick?.(f,n,i)||he(t,o)}),i.addEventListener("keydown",f=>{if(f.key==="Enter"||f.key===" "){if(f.preventDefault(),t._dispatchHeaderClick?.(f,n,i))return;he(t,o)}})}if(o.resizable){i.style.position="relative";const r=document.createElement("div");r.className="resize-handle",r.setAttribute("aria-hidden","true"),r.addEventListener("mousedown",l=>{l.stopPropagation(),l.preventDefault(),t._resizeController.start(l,n,i)}),r.addEventListener("dblclick",l=>{l.stopPropagation(),l.preventDefault(),t._resizeController.resetColumn(n)}),i.appendChild(r)}e.appendChild(i)}),e.querySelectorAll(".cell.sortable").forEach(o=>{o.getAttribute("aria-sort")||o.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex"))}function Ge(t){let e=null,o=null,n=null,i=null;const s=a=>{if(!e)return;const d=a.clientX-e.startX,f=Math.max(40,e.startWidth+d),h=t._visibleColumns[e.colIndex];h.width=f,h.__userResized=!0,h.__renderedWidth=f,o==null&&(o=requestAnimationFrame(()=>{o=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:h.field,width:f}}))};let r=!1;const l=()=>{const a=e!==null;a&&(r=!0,requestAnimationFrame(()=>{r=!1})),window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",l),n!==null&&(document.documentElement.style.cursor=n,n=null),i!==null&&(document.body.style.userSelect=i,i=null),e=null,a&&t.requestStateChange&&t.requestStateChange()};return{get isResizing(){return e!==null||r},start(a,d,f){a.preventDefault();const h=f.getBoundingClientRect();e={startX:a.clientX,colIndex:d,startWidth:h.width},window.addEventListener("mousemove",s),window.addEventListener("mouseup",l),n===null&&(n=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",i===null&&(i=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(a){const d=t._visibleColumns[a];d&&(d.__userResized=!1,d.__renderedWidth=void 0,d.width=d.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:d.field,width:d.width}})))},dispose(){l()}}}function G(t){return t?typeof t=="string"?t:t.outerHTML:""}function Fe(){return{toolPanels:new Map,headerContents:new Map,toolbarButtons:new Map,lightDomButtons:[],lightDomHeaderContent:[],isPanelOpen:!1,expandedSections:new Set,headerContentCleanups:new Map,panelCleanups:new Map,toolbarButtonCleanups:new Map,activePanel:null,activePanelCleanup:null}}function Ue(t,e){return!!(t?.header?.title||t?.header?.toolbarButtons?.length||e.toolPanels.size>0||e.headerContents.size>0||e.toolbarButtons.size>0||e.lightDomButtons.length>0||e.lightDomHeaderContent.length>0)}function Xe(t,e,o="☰"){const n=t?.header?.title??"",i=!!n,s=G(o),r=t?.header?.toolbarButtons??[],l=r.length>0,a=e.toolbarButtons.size>0,d=e.lightDomButtons.length>0,f=e.toolPanels.size>0,p=(l||a||d)&&f,c=[...r].sort((w,v)=>(w.order??100)-(v.order??100)),u=[...e.toolbarButtons.values()].sort((w,v)=>(w.order??100)-(v.order??100));let b="";for(const w of c)w.icon&&w.action&&(b+=`<button class="tbw-toolbar-btn" data-btn="${w.id}" title="${w.label}" aria-label="${w.label}"${w.disabled?" disabled":""}>${w.icon}</button>`);for(const w of u)w.icon&&w.action&&(b+=`<button class="tbw-toolbar-btn" data-btn="${w.id}" title="${w.label}" aria-label="${w.label}"${w.disabled?" disabled":""}>${w.icon}</button>`);for(const w of c)(w.element||w.render)&&(b+=`<div class="tbw-toolbar-btn-slot" data-btn-slot="${w.id}"></div>`);for(const w of u)(w.element||w.render)&&(b+=`<div class="tbw-toolbar-btn-slot" data-btn-slot="${w.id}"></div>`);if(d&&(b+='<slot name="toolbar"></slot>'),p&&(b+='<div class="tbw-toolbar-separator"></div>'),f){const w=e.isPanelOpen;b+=`<button class="tbw-toolbar-btn${w?" active":""}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${w}" aria-controls="tbw-tool-panel">${s}</button>`}return`
|
|
1
|
+
(function(E,V){typeof exports=="object"&&typeof module<"u"?V(exports):typeof define=="function"&&define.amd?define(["exports"],V):(E=typeof globalThis<"u"?globalThis:E||self,V(E.TbwGrid={}))})(this,(function(E){"use strict";const V=':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{-webkit-user-select:none;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}:host .data-grid-row>.cell.editing input:not([type=checkbox]),:host .data-grid-row>.cell.editing select,:host .data-grid-row>.cell.editing textarea{width:100%;height:100%;max-width:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}:host .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}:host .data-grid-row:hover{background:var(--tbw-color-row-hover)}:host .sortable{cursor:pointer;-webkit-user-select:none;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;-webkit-user-select:none;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}:host .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}:host .cell-focus,:host .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-row-alt);font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}:host .group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px)}:host .group-row .group-toggle{background:none;border:0;cursor:pointer;padding:0 4px 0 0;font:inherit}:host .group-row .group-count{margin-left:4px;opacity:.7}:host .sticky-left,:host .sticky-right{position:sticky;z-index:25}:host .header-row>.cell.sticky-left,:host .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}:host .data-grid-row>.cell.sticky-left,:host .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}:host .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}:host .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}.grid-container{position:relative;width:100%;height:100%}.grid-placeholder{padding:2rem;text-align:center;color:var(--tbw-color-fg);opacity:.6}:host{--tbw-shell-header-height: 44px;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: 14px;--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 280px;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 40px;--tbw-tool-panel-transition: 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}: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;-webkit-user-select:none;user-select:none}:host .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}:host .tbw-accordion-section.single .tbw-accordion-header{cursor:default}:host .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}:host .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}:host .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}:host .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}:host .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .tbw-accordion-content{display:none}:host .tbw-accordion-section.expanded .tbw-accordion-content{display:block}:host .tbw-quick-filter-input{flex:1;max-width:300px;height:28px;padding:0 8px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:13px}:host .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}:host .tbw-selection-summary{font-size:13px;color:var(--tbw-color-fg-muted);white-space:nowrap}@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)}';function Ee(t){const e=new Map;return t._sortState&&e.set(t._sortState.field,{direction:t._sortState.direction===1?"asc":"desc",priority:0}),e}function te(t,e){const o=t._columns,n=Ee(t);return{columns:o.map((i,s)=>{const r={field:i.field,order:s,visible:!0},l=i;l.__renderedWidth!==void 0?r.width=l.__renderedWidth:i.width!==void 0&&(r.width=typeof i.width=="string"?parseFloat(i.width):i.width);const a=n.get(i.field);a&&(r.sort=a);for(const d of e)if(d.getColumnState){const f=d.getColumnState(i.field);f&&Object.assign(r,f)}return r})}}function Ce(t,e,o,n){if(!e.columns||e.columns.length===0)return;const i=new Map(e.columns.map(l=>[l.field,l])),s=o.map(l=>{const a=i.get(l.field);if(!a)return l;const d={...l};return a.width!==void 0&&(d.width=a.width,d.__renderedWidth=a.width),a.visible!==void 0&&(d.hidden=!a.visible),d});s.sort((l,a)=>{const d=i.get(l.field)?.order??1/0,f=i.get(a.field)?.order??1/0;return d-f}),t._columns=s;const r=e.columns.filter(l=>l.sort!==void 0).sort((l,a)=>(l.sort?.priority??0)-(a.sort?.priority??0));if(r.length>0){const l=r[0];l.sort&&(t._sortState={field:l.field,direction:l.sort.direction==="asc"?1:-1})}else t._sortState=null;for(const l of n)if(l.applyColumnState)for(const a of e.columns)l.applyColumnState(a.field,a)}function ye(t,e,o){let n=null;return()=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null;const i=te(t,e());o(i)},100)}}const q={STRETCH:"stretch",FIXED:"fixed"},oe={mode:"reduced-motion",duration:200,easing:"ease-out"},P={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰"};function Se(t){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"}function ne(t,e){if(e&&e.length){const s={};return e.forEach(r=>{r.type&&(s[r.field]=r.type)}),{columns:e,typeMap:s}}const o=t[0]||{},n=Object.keys(o).map(s=>{const r=o[s],l=Se(r);return{field:s,header:s.charAt(0).toUpperCase()+s.slice(1),type:l}}),i={};return n.forEach(s=>{i[s.field]=s.type||"string"}),{columns:n,typeMap:i}}const Re=/{{\s*([^}]+)\s*}}/g,H="__DG_EMPTY__",Ae=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,xe=/__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/,Te=new Set(["script","iframe","object","embed","form","input","button","textarea","select","link","meta","base","style","template","slot","portal","frame","frameset","applet","noscript","noembed","plaintext","xmp","listing"]),ie=/^on\w+$/i,Le=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),Pe=/^\s*(javascript|vbscript|data|blob):/i;function X(t){if(!t||typeof t!="string")return"";if(t.indexOf("<")===-1)return t;const e=document.createElement("template");return e.innerHTML=t,He(e.content),e.innerHTML}function He(t){const e=[],o=t.querySelectorAll("*");for(const n of o){const i=n.tagName.toLowerCase();if(Te.has(i)){e.push(n);continue}if((i==="svg"||n.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(n.attributes).some(l=>ie.test(l.name)||l.name==="href"||l.name==="xlink:href")){e.push(n);continue}const s=[];for(const r of n.attributes){const l=r.name.toLowerCase();if(ie.test(l)){s.push(r.name);continue}if(Le.has(l)&&Pe.test(r.value)){s.push(r.name);continue}if(l==="style"&&/expression\s*\(|javascript:|behavior\s*:/i.test(r.value)){s.push(r.name);continue}}s.forEach(r=>n.removeAttribute(r))}e.forEach(n=>n.remove())}function se(t,e){if(!t||t.indexOf("{{")===-1)return t;const o=[],n=t.replace(Re,(l,a)=>{const d=ke(a,e);return o.push({expr:a.trim(),result:d}),d}),i=Oe(n),s=o.length&&o.every(l=>l.result===""||l.result===H);return/Reflect\.|\bProxy\b|ownKeys\(/.test(t)||s?"":i}function ke(t,e){if(t=(t||"").trim(),!t||/\b(Reflect|Proxy|ownKeys)\b/.test(t))return H;if(t==="value")return e.value==null?H:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const n=t.slice(4),i=e.row?e.row[n]:void 0;return i==null?H:String(i)}if(t.length>80||!Ae.test(t)||xe.test(t))return H;const o=t.match(/\./g);if(o&&o.length>1)return H;try{const i=new Function("value","row",`return (${t});`)(e.value,e.row),s=i==null?"":String(i);return/Reflect|Proxy|ownKeys/.test(s)?H:s||H}catch{return H}}function Oe(t){return t&&t.replace(new RegExp(H,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function Me(t){if(/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.TEXT_NODE&&/Reflect|Proxy|ownKeys/.test(e.textContent||"")&&(e.textContent="")}),/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(/Reflect|Proxy|ownKeys/.test(t.textContent||""))for(;t.firstChild;)t.removeChild(t.firstChild);t.textContent=(t.textContent||"").replace(/Reflect|Proxy|ownKeys/g,"")}(t.textContent||"").trim().length===0&&(t.textContent="")}}function re(t){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(t),o=n=>e?"":se(t,n);return o.__blocked=e,o}function ze(t){return Array.from(t.querySelectorAll("tbw-grid-column")).map(o=>{const n=o.getAttribute("field")||"";if(!n)return null;const i=o.getAttribute("type")||void 0,r=i&&new Set(["number","string","date","boolean","select","typeahead"]).has(i)?i:void 0,l=o.getAttribute("header")||void 0,a=o.hasAttribute("sortable"),d=o.hasAttribute("editable"),f={field:n,type:r,header:l,sortable:a,editable:d};o.hasAttribute("resizable")&&(f.resizable=!0),o.hasAttribute("sizable")&&(f.resizable=!0);const h=o.getAttribute("options");h&&(f.options=h.split(",").map(b=>{const[w,v]=b.includes(":")?b.split(":"):[b.trim(),b.trim()];return{value:w.trim(),label:v?.trim()||w.trim()}}));const p=o.querySelector("tbw-grid-column-view"),c=o.querySelector("tbw-grid-column-editor"),u=o.querySelector("tbw-grid-column-header");return p&&(f.__viewTemplate=p),c&&(f.__editorTemplate=c),u&&(f.__headerTemplate=u),f}).filter(o=>!!o)}function De(t,e){if((!t||!t.length)&&(!e||!e.length))return[];if(!t||!t.length)return e||[];if(!e||!e.length)return t;const o={};e.forEach(i=>o[i.field]=i);const n=t.map(i=>{const s=o[i.field];if(!s)return i;const r={...i};return s.header&&!r.header&&(r.header=s.header),s.type&&!r.type&&(r.type=s.type),r.sortable=i.sortable||s.sortable,(i.resizable===!0||s.resizable===!0)&&(r.resizable=!0),r.editable=i.editable||s.editable,s.__viewTemplate&&(r.__viewTemplate=s.__viewTemplate),s.__editorTemplate&&(r.__editorTemplate=s.__editorTemplate),s.__headerTemplate&&(r.__headerTemplate=s.__headerTemplate),delete o[i.field],r});return Object.keys(o).forEach(i=>n.push(o[i])),n}function Y(t,e){try{t.part?.add?.(e)}catch{}const o=t.getAttribute("part");o?o.split(/\s+/).includes(e)||t.setAttribute("part",o+" "+e):t.setAttribute("part",e)}function Ne(t){t.__lightDomColumnsCache||(t.__originalColumnNodes=Array.from(t.querySelectorAll("tbw-grid-column")),t.__lightDomColumnsCache=t.__originalColumnNodes.length?ze(t):[]);const e=t.__lightDomColumnsCache,o=De(t._columns,e);o.forEach(i=>{i.__viewTemplate&&!i.__compiledView&&(i.__compiledView=re(i.__viewTemplate.innerHTML)),i.__editorTemplate&&!i.__compiledEditor&&(i.__compiledEditor=re(i.__editorTemplate.innerHTML))});const{columns:n}=ne(t._rows,o);t._columns=n}function le(t){const e=t.effectiveConfig?.fitMode||t.fitMode||q.STRETCH;if(e!==q.STRETCH&&e!==q.FIXED||t.__didInitialAutoSize||!t.isConnected)return;const o=t._headerRowEl?.children||[];if(!o.length)return;let n=!1;t._visibleColumns.forEach((i,s)=>{if(i.width)return;const r=o[s];let l=r?r.scrollWidth:0;for(const a of t._rowPool){const d=a.children[s];if(d){const f=d.scrollWidth;f>l&&(l=f)}}l>0&&(i.width=l+2,i.__autoSized=!0,n=!0)}),n&&D(t),t.__didInitialAutoSize=!0}function D(t){(t.effectiveConfig?.fitMode||t.fitMode||q.STRETCH)===q.STRETCH?t._gridTemplate=t._visibleColumns.map(o=>{if(o.width)return`${o.width}px`;const n=o.minWidth;return n!=null?`minmax(${n}px, 1fr)`:"1fr"}).join(" ").trim():t._gridTemplate=t._visibleColumns.map(o=>o.width?`${o.width}px`:"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}function Ie(t){switch(t.type){case"number":return e=>{const o=document.createElement("input");return o.type="number",o.value=e.value!=null?String(e.value):"",o.addEventListener("blur",()=>e.commit(o.value===""?null:Number(o.value))),o.addEventListener("keydown",n=>{n.key==="Enter"&&e.commit(o.value===""?null:Number(o.value)),n.key==="Escape"&&e.cancel()}),o.focus(),o};case"boolean":return e=>{const o=document.createElement("input");return o.type="checkbox",o.checked=!!e.value,o.addEventListener("change",()=>e.commit(o.checked)),o.focus(),o};case"date":return e=>{const o=document.createElement("input");return o.type="date",e.value instanceof Date&&(o.valueAsDate=e.value),o.addEventListener("change",()=>e.commit(o.valueAsDate)),o.addEventListener("keydown",n=>{n.key==="Escape"&&e.cancel()}),o.focus(),o};case"select":case"typeahead":return e=>{const o=document.createElement("select");e.column.multi&&(o.multiple=!0),(typeof e.column.options=="function"?e.column.options():e.column.options||[]).forEach(s=>{const r=document.createElement("option");r.value=String(s.value),r.textContent=s.label,(e.column.multi&&Array.isArray(e.value)&&e.value.includes(s.value)||!e.column.multi&&e.value===s.value)&&(r.selected=!0),o.appendChild(r)});const i=()=>{if(e.column.multi){const s=[];Array.from(o.selectedOptions).forEach(r=>{s.push(r.value)}),e.commit(s)}else e.commit(o.value)};return o.addEventListener("change",i),o.addEventListener("blur",i),o.addEventListener("keydown",s=>{s.key==="Escape"&&e.cancel()}),o.focus(),o};default:return e=>{const o=document.createElement("input");return o.type="text",o.value=e.value!=null?String(e.value):"",o.addEventListener("blur",()=>e.commit(o.value)),o.addEventListener("keydown",n=>{n.key==="Enter"&&e.commit(o.value),n.key==="Escape"&&e.cancel()}),o.focus(),o}}}function qe(t,e){if(t._dispatchKeyDown?.(e))return;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,l=e.composedPath?e.composedPath():[],a=l&&l.length?l[0]:e.target,d=f=>{if(!f)return!1;const h=f.tagName;return!!(h==="INPUT"||h==="SELECT"||h==="TEXTAREA"||f.isContentEditable)};if(!(d(a)&&(e.key==="Home"||e.key==="End"))&&!(d(a)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&a.tagName==="INPUT"&&a.type==="number")&&!(d(a)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(d(a)&&(e.key==="Enter"||e.key==="Escape"))&&!(i&&(r==="select"||r==="typeahead")&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{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),z(t);return}case"ArrowDown":i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.min(o,t._focusRow+1),e.preventDefault();break;case"ArrowUp":i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault();break;case"ArrowRight":t._focusCol=Math.min(n,t._focusCol+1),e.preventDefault();break;case"ArrowLeft":t._focusCol=Math.max(0,t._focusCol-1),e.preventDefault();break;case"Home":(e.ctrlKey||e.metaKey)&&(i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=0),t._focusCol=0,e.preventDefault(),z(t,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=o),t._focusCol=n,e.preventDefault(),z(t,{forceScrollRight:!0});return;case"PageDown":t._focusRow=Math.min(o,t._focusRow+20),e.preventDefault();break;case"PageUp":t._focusRow=Math.max(0,t._focusRow-20),e.preventDefault();break;case"Enter":return typeof t.beginBulkEdit=="function"?t.beginBulkEdit(t._focusRow):t.dispatchEvent(new CustomEvent("activate-cell",{detail:{row:t._focusRow,col:t._focusCol}})),z(t);default:return}z(t)}}function z(t,e){if(t._virtualization?.enabled){const{rowHeight:r,container:l,viewportEl:a}=t._virtualization,d=l,f=a?.clientHeight??d?.clientHeight??0;if(d&&f>0){const h=t._focusRow*r;h<d.scrollTop?d.scrollTop=h:h+r>d.scrollTop+f&&(d.scrollTop=h-f+r)}}t._activeEditRows!==void 0&&t._activeEditRows!==-1||t.refreshVirtualWindow(!1),Array.from(t._bodyEl.querySelectorAll(".cell-focus")).forEach(r=>r.classList.remove("cell-focus")),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(r=>{r.setAttribute("aria-selected","false")});const n=t._focusRow,i=t._virtualization.start??0,s=t._virtualization.end??t._rows.length;if(n>=i&&n<s){const r=t._bodyEl.querySelectorAll(".data-grid-row")[n-i],l=r?.children[t._focusCol];if(l){l.classList.add("cell-focus"),l.setAttribute("aria-selected","true");const a=t.shadowRoot?.querySelector(".tbw-scroll-area");if(a&&l)if(e?.forceScrollLeft)a.scrollLeft=0;else if(e?.forceScrollRight)a.scrollLeft=a.scrollWidth-a.clientWidth;else{const d=t._getHorizontalScrollOffsets?.(r??void 0,l)??{left:0,right:0};if(!d.skipScroll){const f=l.getBoundingClientRect(),h=a.getBoundingClientRect(),p=f.left-h.left+a.scrollLeft,c=p+f.width,u=a.scrollLeft+d.left,b=a.scrollLeft+a.clientWidth-d.right;p<u?a.scrollLeft=p-d.left:c>b&&(a.scrollLeft=c-a.clientWidth+d.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&l.classList.contains("editing")){const d=l.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])');if(d&&document.activeElement!==d)try{d.focus()}catch{}}else if(!l.contains(document.activeElement)){l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{}}}}}const Be="__cellDisplayCache",$e="__cellCacheEpoch";function j(t){t[Be]=void 0,t[$e]=void 0,t.__hasSpecialColumns=void 0}function We(t,e,o,n,i){const s=Math.max(0,o-e),r=t._bodyEl,l=t._visibleColumns,a=l.length;let d=t.__cachedHeaderRowCount;for(d===void 0&&(d=t.shadowRoot?.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=d);t._rowPool.length<s;){const h=document.createElement("div");h.className="data-grid-row",h.setAttribute("role","row"),h.addEventListener("click",p=>ae(t,p,h,!1)),h.addEventListener("dblclick",p=>ae(t,p,h,!0)),t._rowPool.push(h)}if(t._rowPool.length>s){for(let h=s;h<t._rowPool.length;h++){const p=t._rowPool[h];p.parentNode===r&&p.remove()}t._rowPool.length=s}const f=i&&t.__hasRenderRowPlugins!==!1;for(let h=0;h<s;h++){const p=e+h,c=t._rows[p],u=t._rowPool[h];if(u.setAttribute("aria-rowindex",String(p+d+1)),f&&i(c,u,p)){u.__epoch=n,u.__rowDataRef=c,u.parentNode!==r&&r.appendChild(u);continue}const b=u.__epoch,w=u.__rowDataRef,v=u.children.length,A=b===n&&v===a,y=w!==c;let g=!1;if(A&&y){for(let _=0;_<a;_++)if(l[_].externalView&&!u.querySelector(`.cell[data-col="${_}"] [data-external-view]`)){g=!0;break}}if(!A||g){const _=u.querySelector(".cell.editing"),C=t._activeEditRows===p;if(_&&!C)u.__isCustomRow&&(u.className="data-grid-row",u.setAttribute("role","row"),u.__isCustomRow=!1),B(t,u,c,p),u.__epoch=n,u.__rowDataRef=c;else if(_&&C)K(t,u,c,p),u.__rowDataRef=c;else if(u.__isCustomRow&&(u.className="data-grid-row",u.setAttribute("role","row"),u.__isCustomRow=!1),B(t,u,c,p),u.__epoch=n,u.__rowDataRef=c,C){const x=u.children;for(let L=0;L<x.length;L++){const O=t._visibleColumns[L];O&&O.editable&&M(t,c,p,O,x[L])}}}else if(y){const _=u.querySelector(".cell.editing"),C=t._activeEditRows===p;if(_&&!C)B(t,u,c,p),u.__epoch=n,u.__rowDataRef=c;else if(K(t,u,c,p),u.__rowDataRef=c,C&&!_){const x=u.children;for(let L=0;L<x.length;L++){const O=t._visibleColumns[L];O&&O.editable&&M(t,c,p,O,x[L])}}}else{const _=u.querySelector(".cell.editing"),C=t._activeEditRows===p;if(_&&!C)B(t,u,c,p),u.__epoch=n,u.__rowDataRef=c;else if(K(t,u,c,p),C&&!_){const x=u.children;for(let L=0;L<x.length;L++){const O=t._visibleColumns[L];O&&O.editable&&M(t,c,p,O,x[L])}}}const m=t._changedRowIndices.has(p),R=u.classList.contains("changed");m!==R&&u.classList.toggle("changed",m),u.parentNode!==r&&r.appendChild(u)}}function K(t,e,o,n){const i=e.children,s=t._visibleColumns,r=s.length,l=i.length,a=r<l?r:l,d=t._focusRow,f=t._focusCol;let h=t.__hasSpecialColumns;if(h===void 0){h=!1;for(let c=0;c<r;c++){const u=s[c];if(u.__viewTemplate||u.__compiledView||u.viewRenderer||u.externalView||u.format||u.type==="date"||u.type==="boolean"){h=!0;break}}t.__hasSpecialColumns=h}const p=String(n);if(!h){for(let c=0;c<a;c++){const u=i[c],b=o[s[c].field];u.textContent=b==null?"":String(b),u.getAttribute("data-row")!==p&&u.setAttribute("data-row",p);const w=d===n&&f===c,v=u.classList.contains("cell-focus");w!==v&&(u.classList.toggle("cell-focus",w),u.setAttribute("aria-selected",String(w)))}return}for(let c=0;c<a;c++)if(s[c].externalView&&!i[c].querySelector("[data-external-view]")){B(t,e,o,n);return}for(let c=0;c<a;c++){const u=s[c],b=i[c];b.getAttribute("data-row")!==p&&b.setAttribute("data-row",p);const w=d===n&&f===c,v=b.classList.contains("cell-focus");if(w!==v&&(b.classList.toggle("cell-focus",w),b.setAttribute("aria-selected",String(w))),b.classList.contains("editing"))continue;if(u.viewRenderer){const y=o[u.field],g=u.viewRenderer({row:o,value:y,field:u.field,column:u});typeof g=="string"?b.innerHTML=X(g):g?(b.innerHTML="",b.appendChild(g)):b.textContent=y==null?"":String(y);continue}if(u.__viewTemplate||u.__compiledView||u.externalView)continue;const S=o[u.field];let A;if(u.format)try{const y=u.format(S,o);A=y==null?"":String(y)}catch{A=S==null?"":String(S)}else if(u.type==="date"){if(S==null||S==="")A="";else if(S instanceof Date)A=isNaN(S.getTime())?"":S.toLocaleDateString();else{const y=new Date(S);A=isNaN(y.getTime())?"":y.toLocaleDateString()}b.textContent=A}else if(u.type==="boolean"){const y=!!S;b.innerHTML=`<span role="checkbox" aria-checked="${y}" aria-label="${y}">${y?"🗹":"☐"}</span>`}else A=S==null?"":String(S),b.textContent=A}}function B(t,e,o,n){e.innerHTML="";const i=t._visibleColumns,s=i.length,r=t._focusRow,l=t._focusCol,a=t.effectiveConfig?.editOn||t.editOn,d=t,f=document.createDocumentFragment();for(let h=0;h<s;h++){const p=i[h],c=document.createElement("div");c.className="cell",Y(c,"cell"),c.setAttribute("role","gridcell"),c.setAttribute("aria-colindex",String(h+1)),c.setAttribute("data-col",String(h)),c.setAttribute("data-row",String(n)),c.setAttribute("data-field",p.field),p.type,p.type&&c.setAttribute("data-type",p.type);let u=o[p.field];const b=p.format;if(b)try{u=b(u,o)}catch{}const w=p.__compiledView,v=p.__viewTemplate,S=p.viewRenderer,A=p.externalView;let y=!1;if(S){const g=S({row:o,value:u,field:p.field,column:p});typeof g=="string"?(c.innerHTML=X(g),y=!0):g?c.appendChild(g):c.textContent=u==null?"":String(u)}else if(A){const g=A,m=document.createElement("div");m.setAttribute("data-external-view",""),m.setAttribute("data-field",p.field),c.appendChild(m);const R={row:o,value:u,field:p.field,column:p};if(g.mount)try{g.mount({placeholder:m,context:R,spec:g})}catch{}else queueMicrotask(()=>{try{d.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:m,spec:g,context:R}}))}catch{}});m.setAttribute("data-mounted","")}else if(w){const g=w({row:o,value:u,field:p.field,column:p}),m=w.__blocked;c.innerHTML=m?"":X(g),y=!0,m&&(c.textContent="",c.setAttribute("data-blocked-template",""))}else if(v){const g=v.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(g)?(c.textContent="",c.setAttribute("data-blocked-template","")):(c.innerHTML=X(se(g,{row:o,value:u})),y=!0)}else if(p.type==="date")if(u==null||u==="")c.textContent="";else{let g=null;if(u instanceof Date)g=u;else if(typeof u=="number"||typeof u=="string"){const m=new Date(u);isNaN(m.getTime())||(g=m)}c.textContent=g?g.toLocaleDateString():""}else if(p.type==="boolean"){const g=!!u;c.innerHTML=`<span role="checkbox" aria-checked="${g}" aria-label="${g}">${g?"🗹":"☐"}</span>`}else c.textContent=u==null?"":String(u);if(y){Me(c);const g=c.textContent||"";/Proxy|Reflect\.ownKeys/.test(g)&&(c.textContent=g.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(c.textContent||"")&&(c.textContent=""))}c.hasAttribute("data-blocked-template")&&(c.textContent||"").trim().length&&(c.textContent=""),p.editable?(c.tabIndex=0,c.addEventListener("mousedown",()=>{if(c.classList.contains("editing"))return;const g=Number(c.getAttribute("data-row")),m=Number(c.getAttribute("data-col"));isNaN(g)||isNaN(m)||(t._focusRow=g,t._focusCol=m,z(t))}),a==="click"?c.addEventListener("click",g=>{if(c.classList.contains("editing"))return;g.stopPropagation();const m=Number(c.getAttribute("data-row")),R=Number(c.getAttribute("data-col"));if(isNaN(m)||isNaN(R))return;const _=t._rows[m],C=t._visibleColumns[R];!_||!C||(t._focusRow=m,t._focusCol=R,M(t,_,m,C,c))}):c.addEventListener("dblclick",g=>{g.stopPropagation();const m=Number(c.getAttribute("data-row"));if(isNaN(m))return;const R=t._rows[m];if(!R)return;$(t,m,R);const _=t.findRenderedRowElement?.(m);if(_){const C=_.children;for(let x=0;x<C.length;x++){const L=t._visibleColumns[x];L&&L.editable&&M(t,R,m,L,C[x])}}}),c.addEventListener("keydown",g=>{const m=Number(c.getAttribute("data-row")),R=Number(c.getAttribute("data-col"));if(isNaN(m)||isNaN(R))return;const _=t._rows[m],C=t._visibleColumns[R];if(!(!_||!C)){if((C.type==="select"||C.type==="typeahead")&&!c.classList.contains("editing")&&g.key==="Enter"){g.preventDefault(),t._activeEditRows!==m&&$(t,m,_),M(t,_,m,C,c),setTimeout(()=>{const x=c.querySelector("select");try{x?.showPicker?.()}catch{}x?.focus()},0);return}if(C.type==="boolean"&&g.key===" "&&!c.classList.contains("editing")){g.preventDefault(),t._activeEditRows!==m&&$(t,m,_);const x=!_[C.field];Q(t,m,C,x,_),c.innerHTML=`<span role="checkbox" aria-checked="${x}" aria-label="${x}">${x?"🗹":"☐"}</span>`;return}if(g.key==="Enter"&&!c.classList.contains("editing")){g.preventDefault(),g.stopPropagation(),t._focusRow=m,t._focusCol=R,typeof t.beginBulkEdit=="function"?t.beginBulkEdit(m):M(t,_,m,C,c);return}if(g.key==="F2"&&!c.classList.contains("editing")){g.preventDefault(),M(t,_,m,C,c);return}}})):p.type==="boolean"&&(c.hasAttribute("tabindex")||(c.tabIndex=0)),r===n&&l===h?(c.classList.add("cell-focus"),c.setAttribute("aria-selected","true")):c.setAttribute("aria-selected","false"),f.appendChild(c)}e.appendChild(f)}function ae(t,e,o,n){if(e.target?.closest(".resize-handle"))return;const i=o.querySelector(".cell[data-row]");if(!i)return;const s=Number(i.getAttribute("data-row"));if(isNaN(s))return;const r=t._rows[s];if(!r||t._dispatchRowClick?.(e,s,r,o))return;const l=e.target?.closest(".cell[data-col]");if(l){if(l.classList.contains("editing"))return;const d=Number(l.getAttribute("data-col"));if(!isNaN(d)){if(t._dispatchCellClick?.(e,s,d,l))return;t._focusRow=s,t._focusCol=d,z(t)}}if(o.querySelector(".cell.editing")){const d=o.querySelectorAll(".cell.editing");if(!n)return;d.forEach(f=>f.classList.remove("editing"))}const a=t.effectiveConfig?.editOn||t.editOn||"doubleClick";if(a==="click"||a==="doubleClick"&&n)$(t,s,r);else return;Array.from(o.children).forEach((d,f)=>{const h=t._visibleColumns[f];h&&h.editable&&M(t,r,s,h,d)}),l&&queueMicrotask(()=>{const d=o.querySelector(`.cell[data-col="${t._focusCol}"]`);if(d?.classList.contains("editing")){const f=d.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])');try{f?.focus()}catch{}}})}function Z(t){return!(t==="__proto__"||t==="constructor"||t==="prototype")}function $(t,e,o){t._activeEditRows!==e&&(t._rowEditSnapshots.set(e,{...o}),t._activeEditRows=e)}function N(t,e,o){if(t._activeEditRows!==e)return;const n=t._rowEditSnapshots.get(e),i=t._rows[e],s=t.findRenderedRowElement?.(e);if(!o&&s&&i&&s.querySelectorAll(".cell.editing").forEach(l=>{const a=Number(l.getAttribute("data-col"));if(isNaN(a))return;const d=t._visibleColumns[a];if(!d)return;const f=l.querySelector("input,textarea,select");if(f){let h;f instanceof HTMLInputElement&&f.type==="checkbox"?h=f.checked:(h=f.value,d.type==="number"&&h!==""&&(h=Number(h))),i[d.field]!==h&&Q(t,e,d,h,i)}}),o&&n&&i)Object.keys(n).forEach(r=>i[r]=n[r]),t._changedRowIndices.delete(e),j(t);else if(!o){const r=t._changedRowIndices.has(e);t.dispatchEvent(new CustomEvent("row-commit",{detail:{rowIndex:e,row:i,changed:r,changedRows:t.changedRows,changedRowIndices:t.changedRowIndices}}))}t._rowEditSnapshots.delete(e),t._activeEditRows=-1,s&&(B(t,s,t._rows[e],e),t._changedRowIndices.has(e)?s.classList.add("changed"):s.classList.remove("changed")),queueMicrotask(()=>{try{const r=t._focusRow,l=t._focusCol,a=t.findRenderedRowElement?.(r);if(a){Array.from(t._bodyEl.querySelectorAll(".cell-focus")).forEach(f=>f.classList.remove("cell-focus"));const d=a.querySelector(`.cell[data-row="${r}"][data-col="${l}"]`);d&&(d.classList.add("cell-focus"),d.setAttribute("aria-selected","true"),d.hasAttribute("tabindex")||d.setAttribute("tabindex","-1"),d.focus({preventScroll:!0}))}}catch{}})}function Q(t,e,o,n,i){const s=o.field;if(!Z(s)||i[s]===n)return;i[s]=n;const l=!t._changedRowIndices.has(e);t._changedRowIndices.add(e);const a=t.findRenderedRowElement?.(e);a&&a.classList.add("changed"),t.dispatchEvent(new CustomEvent("cell-commit",{detail:{row:i,field:s,value:n,rowIndex:e,changedRows:t.changedRows,changedRowIndices:t.changedRowIndices,firstTimeForRow:l}}))}function M(t,e,o,n,i){if(!n.editable||(t._activeEditRows!==o&&$(t,o,e),i.classList.contains("editing")))return;const s=Z(n.field)?e[n.field]:void 0;i.classList.add("editing");let r=!1;const l=c=>{r||t._activeEditRows===-1||Q(t,o,n,c,e)},a=()=>{r=!0,e[n.field]=Z(n.field)?s:void 0;const c=i.querySelector("input,textarea,select");c&&(typeof HTMLInputElement<"u"&&c instanceof HTMLInputElement&&c.type==="checkbox"?c.checked=!!s:"value"in c&&(c.value=s??""))},d=document.createElement("div");d.style.display="contents",i.innerHTML="",i.appendChild(d),d.addEventListener("keydown",c=>{c.key==="Enter"&&(c.stopPropagation(),c.preventDefault(),r=!0,N(t,o,!1)),c.key==="Escape"&&(c.stopPropagation(),c.preventDefault(),a(),N(t,o,!0))});const f=n.__editorTemplate,h=n.editor||(f?"template":Ie(n)),p=s;if(h==="template"&&f){const c=f.cloneNode(!0),u=n.__compiledEditor;u?c.innerHTML=u({row:e,value:s,field:n.field,column:n}):c.querySelectorAll("*").forEach(w=>{w.childNodes.length===1&&w.firstChild?.nodeType===Node.TEXT_NODE&&(w.textContent=w.textContent?.replace(/{{\s*value\s*}}/g,s==null?"":String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g,(v,S)=>{const A=e[S];return A==null?"":String(A)})||"")});const b=c.querySelector("input,textarea,select");if(b){const w=typeof HTMLInputElement<"u";w&&b instanceof HTMLInputElement&&b.type==="checkbox"?b.checked=!!s:"value"in b&&(b.value=s??""),b.addEventListener("blur",()=>{const v=w&&b instanceof HTMLInputElement&&b.type==="checkbox"?b.checked:b.value;l(v)}),b.addEventListener("keydown",v=>{if(v.key==="Enter"){v.stopPropagation(),v.preventDefault(),r=!0;const S=w&&b instanceof HTMLInputElement&&b.type==="checkbox"?b.checked:b.value;l(S),N(t,o,!1)}v.key==="Escape"&&(v.stopPropagation(),v.preventDefault(),a(),N(t,o,!0))}),w&&b instanceof HTMLInputElement&&b.type==="checkbox"&&b.addEventListener("change",()=>{const v=b.checked;l(v)}),setTimeout(()=>b.focus(),0)}d.appendChild(c)}else if(typeof h=="string"){const c=document.createElement(h);c.value=p,c.addEventListener("change",()=>l(c.value)),d.appendChild(c)}else if(typeof h=="function"){const c=h({row:e,value:p,field:n.field,column:n,commit:l,cancel:a});typeof c=="string"?d.innerHTML=c:d.appendChild(c)}else if(h&&typeof h=="object"){const c=document.createElement("div");c.setAttribute("data-external-editor",""),c.setAttribute("data-field",n.field),d.appendChild(c);const u={row:e,value:p,field:n.field,column:n,commit:l,cancel:a};if(h.mount)try{h.mount({placeholder:c,context:u,spec:h})}catch{}else t.dispatchEvent(new CustomEvent("mount-external-editor",{detail:{placeholder:c,spec:h,context:u}}))}}function ce(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function de(t,e,o){const i=o.find(l=>l.field===e.field)?.sortComparator??ce,{field:s,direction:r}=e;return[...t].sort((l,a)=>i(l[s],a[s],l,a)*r)}function ue(t,e,o,n){t._rows=e,t.__rowRenderEpoch++,t._rowPool.forEach(i=>i.__epoch=-1),W(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:n}})),t.requestStateChange?.()}function he(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),fe(t,e,1)):t._sortState.direction===1?fe(t,e,-1):(t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(n=>n.__epoch=-1),t._rows=t.__originalOrder.slice(),W(t),t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(n=>{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")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),t.requestStateChange?.())}function fe(t,e,o){t._sortState={field:e.field,direction:o};const n={field:e.field,direction:o},i=t._columns,r=(t.effectiveConfig?.sortHandler??de)(t._rows,n,i);r&&typeof r.then=="function"?r.then(l=>{ue(t,l,e,o)}):ue(t,r,e,o)}function Ve(t,e){typeof e=="string"?t.textContent=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}function W(t){t._headerRowEl=t.findHeaderRow();const e=t._headerRowEl;e.innerHTML="",t._visibleColumns.forEach((o,n)=>{const i=document.createElement("div");i.className="cell",Y(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));const s=o.__headerTemplate;if(s)Array.from(s.childNodes).forEach(r=>i.appendChild(r.cloneNode(!0)));else{const r=o.header||o.field,l=document.createElement("span");l.textContent=r,i.appendChild(l)}if(o.sortable){i.classList.add("sortable"),i.tabIndex=0;const r=document.createElement("span");Y(r,"sort-indicator");const l=t._sortState?.field===o.field?t._sortState.direction:0,a={...P,...t.icons},d=l===1?a.sortAsc:l===-1?a.sortDesc:a.sortNone;Ve(r,d),i.appendChild(r),i.setAttribute("aria-sort",l===0?"none":l===1?"ascending":"descending"),i.addEventListener("click",f=>{t._resizeController?.isResizing||t._dispatchHeaderClick?.(f,n,i)||he(t,o)}),i.addEventListener("keydown",f=>{if(f.key==="Enter"||f.key===" "){if(f.preventDefault(),t._dispatchHeaderClick?.(f,n,i))return;he(t,o)}})}if(o.resizable){i.style.position="relative";const r=document.createElement("div");r.className="resize-handle",r.setAttribute("aria-hidden","true"),r.addEventListener("mousedown",l=>{l.stopPropagation(),l.preventDefault(),t._resizeController.start(l,n,i)}),r.addEventListener("dblclick",l=>{l.stopPropagation(),l.preventDefault(),t._resizeController.resetColumn(n)}),i.appendChild(r)}e.appendChild(i)}),e.querySelectorAll(".cell.sortable").forEach(o=>{o.getAttribute("aria-sort")||o.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex"))}function Ge(t){let e=null,o=null,n=null,i=null;const s=a=>{if(!e)return;const d=a.clientX-e.startX,f=Math.max(40,e.startWidth+d),h=t._visibleColumns[e.colIndex];h.width=f,h.__userResized=!0,h.__renderedWidth=f,o==null&&(o=requestAnimationFrame(()=>{o=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:h.field,width:f}}))};let r=!1;const l=()=>{const a=e!==null;a&&(r=!0,requestAnimationFrame(()=>{r=!1})),window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",l),n!==null&&(document.documentElement.style.cursor=n,n=null),i!==null&&(document.body.style.userSelect=i,i=null),e=null,a&&t.requestStateChange&&t.requestStateChange()};return{get isResizing(){return e!==null||r},start(a,d,f){a.preventDefault();const h=f.getBoundingClientRect();e={startX:a.clientX,colIndex:d,startWidth:h.width},window.addEventListener("mousemove",s),window.addEventListener("mouseup",l),n===null&&(n=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",i===null&&(i=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(a){const d=t._visibleColumns[a];d&&(d.__userResized=!1,d.__renderedWidth=void 0,d.width=d.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:d.field,width:d.width}})))},dispose(){l()}}}function G(t){return t?typeof t=="string"?t:t.outerHTML:""}function Fe(){return{toolPanels:new Map,headerContents:new Map,toolbarButtons:new Map,lightDomButtons:[],lightDomHeaderContent:[],isPanelOpen:!1,expandedSections:new Set,headerContentCleanups:new Map,panelCleanups:new Map,toolbarButtonCleanups:new Map,activePanel:null,activePanelCleanup:null}}function Ue(t,e){return!!(t?.header?.title||t?.header?.toolbarButtons?.length||e.toolPanels.size>0||e.headerContents.size>0||e.toolbarButtons.size>0||e.lightDomButtons.length>0||e.lightDomHeaderContent.length>0)}function Xe(t,e,o="☰"){const n=t?.header?.title??"",i=!!n,s=G(o),r=t?.header?.toolbarButtons??[],l=r.length>0,a=e.toolbarButtons.size>0,d=e.lightDomButtons.length>0,f=e.toolPanels.size>0,p=(l||a||d)&&f,c=[...r].sort((w,v)=>(w.order??100)-(v.order??100)),u=[...e.toolbarButtons.values()].sort((w,v)=>(w.order??100)-(v.order??100));let b="";for(const w of c)w.icon&&w.action&&(b+=`<button class="tbw-toolbar-btn" data-btn="${w.id}" title="${w.label}" aria-label="${w.label}"${w.disabled?" disabled":""}>${w.icon}</button>`);for(const w of u)w.icon&&w.action&&(b+=`<button class="tbw-toolbar-btn" data-btn="${w.id}" title="${w.label}" aria-label="${w.label}"${w.disabled?" disabled":""}>${w.icon}</button>`);for(const w of c)(w.element||w.render)&&(b+=`<div class="tbw-toolbar-btn-slot" data-btn-slot="${w.id}"></div>`);for(const w of u)(w.element||w.render)&&(b+=`<div class="tbw-toolbar-btn-slot" data-btn-slot="${w.id}"></div>`);if(d&&(b+='<slot name="toolbar"></slot>'),p&&(b+='<div class="tbw-toolbar-separator"></div>'),f){const w=e.isPanelOpen;b+=`<button class="tbw-toolbar-btn${w?" active":""}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${w}" aria-controls="tbw-tool-panel">${s}</button>`}return`
|
|
2
2
|
<div class="tbw-shell-header" part="shell-header" role="presentation">
|
|
3
3
|
${i?`<div class="tbw-shell-title">${n}</div>`:""}
|
|
4
4
|
<div class="tbw-shell-content" part="shell-content" role="presentation">
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
${c}
|
|
42
42
|
</div>
|
|
43
43
|
`}function pe(t,e){const o=t.querySelector("tbw-grid-header");if(!o)return;o.style.display="none";const n=o.querySelectorAll("tbw-grid-header-content");e.lightDomHeaderContent=Array.from(n),e.lightDomHeaderContent.forEach(s=>{s.setAttribute("slot","header-content")});const i=o.querySelectorAll("tbw-grid-tool-button");e.lightDomButtons=Array.from(i),e.lightDomButtons.sort((s,r)=>{const l=parseInt(s.getAttribute("order")??"100",10),a=parseInt(r.getAttribute("order")??"100",10);return l-a}),e.lightDomButtons.forEach(s=>{s.setAttribute("slot","toolbar")})}function je(t,e,o,n){const i=t.querySelector(".tbw-shell-toolbar");i&&i.addEventListener("click",r=>{const l=r.target;if(l.closest("[data-panel-toggle]")){n.onPanelToggle();return}const d=l.closest("[data-btn]");if(d){const f=d.getAttribute("data-btn");f&&n.onToolbarButtonClick(f)}});const s=t.querySelector(".tbw-accordion");s&&s.addEventListener("click",r=>{const a=r.target.closest(".tbw-accordion-header");if(a){const f=a.closest("[data-section]")?.getAttribute("data-section");f&&n.onSectionToggle(f)}})}function Ke(t,e,o){const n=t.querySelector(".tbw-tool-panel"),i=t.querySelector("[data-resize-handle]"),s=t.querySelector(".tbw-shell-body");if(!n||!i||!s)return()=>{};const r=e?.toolPanel?.position??"right",l=200;let a=0,d=0,f=0,h=!1;const p=b=>{if(!h)return;b.preventDefault();const w=r==="left"?b.clientX-a:a-b.clientX,v=Math.min(f,Math.max(l,d+w));n.style.width=`${v}px`},c=()=>{if(!h)return;h=!1,i.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const b=n.getBoundingClientRect().width;o(b),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",c)},u=b=>{b.preventDefault(),h=!0,a=b.clientX,d=n.getBoundingClientRect().width,f=s.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",p),document.addEventListener("mouseup",c)};return i.addEventListener("mousedown",u),()=>{i.removeEventListener("mousedown",u),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",c)}}function Ze(t,e,o){const n=[...e?.header?.toolbarButtons??[],...o.toolbarButtons.values()];for(const i of n){const s=t.querySelector(`[data-btn-slot="${i.id}"]`);if(!s)continue;const r=o.toolbarButtonCleanups.get(i.id);if(r&&(r(),o.toolbarButtonCleanups.delete(i.id)),i.element)s.appendChild(i.element);else if(i.render){const l=i.render(s);l&&o.toolbarButtonCleanups.set(i.id,l)}}}function be(t,e){const o=t.querySelector(".tbw-shell-content");if(!o)return;const n=[...e.headerContents.values()].sort((s,r)=>(s.order??100)-(r.order??100)),i=o.querySelector('slot[name="header-content"]');for(const s of n){const r=e.headerContentCleanups.get(s.id);r&&(r(),e.headerContentCleanups.delete(s.id));let l=o.querySelector(`[data-header-content="${s.id}"]`);l||(l=document.createElement("div"),l.setAttribute("data-header-content",s.id),i?o.insertBefore(l,i):o.appendChild(l));const a=s.render(l);a&&e.headerContentCleanups.set(s.id,a)}}function Qe(t,e,o){if(!e.isPanelOpen)return;const n=G(o?.expand??P.expand),i=G(o?.collapse??P.collapse);for(const[s,r]of e.toolPanels){const l=e.expandedSections.has(s),a=t.querySelector(`[data-section="${s}"]`),d=a?.querySelector(".tbw-accordion-content");if(!a||!d)continue;a.classList.toggle("expanded",l);const f=a.querySelector(".tbw-accordion-header");f&&f.setAttribute("aria-expanded",String(l));const h=a.querySelector(".tbw-accordion-chevron");if(h&&(h.innerHTML=l?i:n),l){if(d.children.length===0){const p=r.render(d);p&&e.panelCleanups.set(s,p)}}else{const p=e.panelCleanups.get(s);p&&(p(),e.panelCleanups.delete(s)),d.innerHTML=""}}}function we(t,e){const o=t.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",e.isPanelOpen),o.setAttribute("aria-pressed",String(e.isPanelOpen)))}function ge(t,e){const o=t.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",e.isPanelOpen),e.isPanelOpen||(o.style.width=""))}function Je(t,e){const o=[];for(const n of t?.header?.toolbarButtons??[])o.push({id:n.id,label:n.label,disabled:n.disabled??!1,source:"config"});for(const n of e.toolbarButtons.values())o.push({id:n.id,label:n.label,disabled:n.disabled??!1,source:"config"});for(let n=0;n<e.lightDomButtons.length;n++){const s=e.lightDomButtons[n].querySelector("button");o.push({id:`light-dom-${n}`,label:s?.getAttribute("title")??s?.getAttribute("aria-label")??"",disabled:s?.disabled??!1,source:"light-dom"})}for(const n of e.toolPanels.values())o.push({id:`panel-toggle-${n.id}`,label:n.tooltip??n.title,disabled:!1,source:"panel-toggle",panelId:n.id});return o}function et(t){for(const e of t.headerContentCleanups.values())e();t.headerContentCleanups.clear(),t.activePanelCleanup&&(t.activePanelCleanup(),t.activePanelCleanup=null);for(const e of t.toolbarButtonCleanups.values())e();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}function tt(t,e){let o=!1;const n={get isInitialized(){return o},setInitialized(i){o=i},get isPanelOpen(){return t.isPanelOpen},get activePanel(){return t.isPanelOpen&&t.expandedSections.size>0?[...t.expandedSections][0]:null},get expandedSections(){return[...t.expandedSections]},openToolPanel(){if(t.isPanelOpen)return;if(t.toolPanels.size===0){console.warn("[tbw-grid] No tool panels registered");return}if(t.isPanelOpen=!0,t.expandedSections.size===0&&t.toolPanels.size>0){const r=[...t.toolPanels.values()].sort((l,a)=>(l.order??100)-(a.order??100))[0];r&&t.expandedSections.add(r.id)}const i=e.getShadow();we(i,t),ge(i,t),Qe(i,t,e.getAccordionIcons()),e.emit("tool-panel-open",{sections:n.expandedSections})},closeToolPanel(){if(!t.isPanelOpen)return;for(const s of t.panelCleanups.values())s();t.panelCleanups.clear(),t.activePanelCleanup&&(t.activePanelCleanup(),t.activePanelCleanup=null);for(const s of t.toolPanels.values())s.onClose?.();t.isPanelOpen=!1;const i=e.getShadow();we(i,t),ge(i,t),e.emit("tool-panel-close",{})},toggleToolPanel(){t.isPanelOpen?n.closeToolPanel():n.openToolPanel()},toggleToolPanelSection(i){const s=t.toolPanels.get(i);if(!s){console.warn(`[tbw-grid] Tool panel section "${i}" not found`);return}if(t.toolPanels.size===1)return;const r=e.getShadow(),l=t.expandedSections.has(i);if(l){const a=t.panelCleanups.get(i);a&&(a(),t.panelCleanups.delete(i)),s.onClose?.(),t.expandedSections.delete(i),J(r,i,!1)}else{for(const[a,d]of t.toolPanels)if(a!==i&&t.expandedSections.has(a)){const f=t.panelCleanups.get(a);f&&(f(),t.panelCleanups.delete(a)),d.onClose?.(),t.expandedSections.delete(a),J(r,a,!1);const h=r.querySelector(`[data-section="${a}"] .tbw-accordion-content`);h&&(h.innerHTML="")}t.expandedSections.add(i),J(r,i,!0),ot(r,t,i)}e.emit("tool-panel-section-toggle",{id:i,expanded:!l})},getToolPanels(){return[...t.toolPanels.values()]},registerToolPanel(i){if(t.toolPanels.has(i.id)){console.warn(`[tbw-grid] Tool panel "${i.id}" already registered`);return}t.toolPanels.set(i.id,i),o&&e.refreshShellHeader()},unregisterToolPanel(i){if(t.expandedSections.has(i)){const s=t.panelCleanups.get(i);s&&(s(),t.panelCleanups.delete(i)),t.expandedSections.delete(i)}t.toolPanels.delete(i),o&&e.refreshShellHeader()},getHeaderContents(){return[...t.headerContents.values()]},registerHeaderContent(i){if(t.headerContents.has(i.id)){console.warn(`[tbw-grid] Header content "${i.id}" already registered`);return}t.headerContents.set(i.id,i),o&&be(e.getShadow(),t)},unregisterHeaderContent(i){const s=t.headerContentCleanups.get(i);s&&(s(),t.headerContentCleanups.delete(i)),t.headerContents.get(i)?.onDestroy?.(),t.headerContents.delete(i),e.getShadow().querySelector(`[data-header-content="${i}"]`)?.remove()},getToolbarButtons(){return Je(e.getShellConfig(),t)},registerToolbarButton(i){if(t.toolbarButtons.has(i.id)){console.warn(`[tbw-grid] Toolbar button "${i.id}" already registered`);return}t.toolbarButtons.set(i.id,i),o&&e.refreshShellHeader()},unregisterToolbarButton(i){const s=t.toolbarButtonCleanups.get(i);s&&(s(),t.toolbarButtonCleanups.delete(i)),t.toolbarButtons.delete(i),o&&e.refreshShellHeader()},setToolbarButtonDisabled(i,s){const r=t.toolbarButtons.get(i);r&&(r.disabled=s);const l=e.getShadow().querySelector(`[data-btn="${i}"]`);l&&(l.disabled=s)}};return n}function J(t,e,o){const n=t.querySelector(`[data-section="${e}"]`);n&&n.classList.toggle("expanded",o)}function ot(t,e,o){const n=e.toolPanels.get(o);if(!n?.render)return;const i=t.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!i)return;const s=n.render(i);s&&e.panelCleanups.set(o,s)}class me{constructor(e){this.grid=e}plugins=[];pluginMap=new Map;cellRenderers=new Map;headerRenderers=new Map;cellEditors=new Map;attachAll(e){for(const o of e)this.attach(o)}attach(e){if(this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[o,n]of Object.entries(e.cellRenderers))this.cellRenderers.set(o,n);if(e.headerRenderers)for(const[o,n]of Object.entries(e.headerRenderers))this.headerRenderers.set(o,n);if(e.cellEditors)for(const[o,n]of Object.entries(e.cellEditors))this.cellEditors.set(o,n);e.attach(this.grid)}detachAll(){for(let e=this.plugins.length-1;e>=0;e--)this.plugins[e].detach();this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear()}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(o=>o.name===e)}hasPlugin(e){return this.pluginMap.has(e)}getAll(){return this.plugins}getCellRenderer(e){return this.cellRenderers.get(e)}getHeaderRenderer(e){return this.headerRenderers.get(e)}getCellEditor(e){return this.cellEditors.get(e)}getAllStyles(){return this.plugins.filter(e=>e.styles).map(e=>e.styles).join(`
|
|
44
|
-
`)}processRows(e){let o=[...e];for(const n of this.plugins)n.processRows&&(o=n.processRows(o));return o}processColumns(e){let o=[...e];for(const n of this.plugins)n.processColumns&&(o=n.processColumns(o));return o}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.plugins)e.afterRender?.()}onScrollRender(){for(const e of this.plugins)e.onScrollRender?.()}getExtraHeight(){let e=0;for(const o of this.plugins)typeof o.getExtraHeight=="function"&&(e+=o.getExtraHeight());return e}getExtraHeightBefore(e){let o=0;for(const n of this.plugins)typeof n.getExtraHeightBefore=="function"&&(o+=n.getExtraHeightBefore(e));return o}adjustVirtualStart(e,o,n){let i=e;for(const s of this.plugins)if(typeof s.adjustVirtualStart=="function"){const r=s.adjustVirtualStart(e,o,n);r<i&&(i=r)}return i}renderRow(e,o,n){for(const i of this.plugins)if(i.renderRow?.(e,o,n))return!0;return!1}queryPlugins(e){const o=[];for(const n of this.plugins){const i=n.onPluginQuery?.(e);i!==void 0&&o.push(i)}return o}onKeyDown(e){for(const o of this.plugins)if(o.onKeyDown?.(e))return!0;return!1}onCellClick(e){for(const o of this.plugins)if(o.onCellClick?.(e))return!0;return!1}onRowClick(e){for(const o of this.plugins)if(o.onRowClick?.(e))return!0;return!1}onHeaderClick(e){for(const o of this.plugins)if(o.onHeaderClick?.(e))return!0;return!1}onScroll(e){for(const o of this.plugins)o.onScroll?.(e)}onCellMouseDown(e){for(const o of this.plugins)if(o.onCellMouseDown?.(e))return!0;return!1}onCellMouseMove(e){for(const o of this.plugins)if(o.onCellMouseMove?.(e))return!0;return!1}onCellMouseUp(e){for(const o of this.plugins)if(o.onCellMouseUp?.(e))return!0;return!1}getHorizontalScrollOffsets(e,o){let n=0,i=0,s=!1;for(const r of this.plugins){const l=r.getHorizontalScrollOffsets?.(e,o);l&&(n+=l.left,i+=l.right,l.skipScroll&&(s=!0))}return{left:n,right:i,skipScroll:s}}getToolPanels(){const e=[];for(const o of this.plugins){const n=o.getToolPanel?.();n&&e.push({plugin:o,panel:n})}return e.sort((o,n)=>(o.panel.order??0)-(n.panel.order??0))}getHeaderContents(){const e=[];for(const o of this.plugins){const n=o.getHeaderContent?.();n&&e.push({plugin:o,content:n})}return e.sort((o,n)=>(o.content.order??0)-(n.content.order??0))}}class I extends HTMLElement{static tagName="tbw-grid";static version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";static get observedAttributes(){return["rows","columns","grid-config","fit-mode","edit-on"]}#o;#M=!1;#B;#$;#r=[];#l;#g;#C;#y;#t={};#p=!1;#b=0;#S=null;#R=!1;#z;#A=!1;#x=null;#T=null;#L=null;#P=null;#m=null;#v=null;#_=null;#d=0;#u=0;#w=0;#a;#E;#e;#D;#h;#i=Fe();#n;#H;_rows=[];#N=[];get _columns(){return this.#t.columns??[]}set _columns(e){this.#t.columns=e}get _visibleColumns(){return this._columns.filter(e=>!e.hidden)}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;_virtualization={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null};_focusRow=0;_focusCol=0;_sortState=null;_activeEditRows=-1;_rowEditSnapshots=new Map;_changedRowIndices=new Set;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;__lightDomColumnsCache;__originalColumnNodes;__originalOrder=[];get rows(){return this._rows}set rows(e){const o=this.#r;this.#r=e,o!==e&&this.#ee()}get sourceRows(){return this.#r}get columns(){return[...this._columns]}set columns(e){const o=this.#l;this.#l=e,o!==e&&this.#te()}get gridConfig(){return this.#t}set gridConfig(e){const o=this.#g;this.#g=e,o!==e&&this.#oe()}get fitMode(){return this.#t.fitMode??"stretch"}set fitMode(e){const o=this.#C;this.#C=e,o!==e&&this.#Q()}get editOn(){return this.#t.editOn}set editOn(e){const o=this.#y;this.#y=e,o!==e&&this.#J()}get effectiveConfig(){return this.#t}get disconnectSignal(){return this.#a||(this.#a=new AbortController),this.#a.signal}constructor(){super(),this.#o=this.attachShadow({mode:"open"}),this.#Y(),this.#B=new Promise(e=>this.#$=e),this.#n=tt(this.#i,{getShadow:()=>this.#o,getShellConfig:()=>this.#t?.shell,getAccordionIcons:()=>({expand:this.#t?.icons?.expand??P.expand,collapse:this.#t?.icons?.collapse??P.collapse}),emit:(e,o)=>this.#s(e,o),refreshShellHeader:()=>this.refreshShellHeader()})}#Y(){const e=new CSSStyleSheet;e.replaceSync(V),this.#o.adoptedStyleSheets=[e]}getPlugin(e){return this.#e?.getPlugin(e)}getPluginByName(e){return this.#e?.getPluginByName(e)}requestRender(){this.#O(),this.#k(),W(this),D(this),this.refreshVirtualWindow(!0)}updateTemplate(){D(this)}requestAfterRender(){this.#e?.afterRender()}#W(){this.#e=new me(this);const e=this.#t?.plugins,o=Array.isArray(e)?e:[];this.#e.attachAll(o)}#V(){const e=this.#e?.getAllStyles()??"";if(e){const o=document.createElement("style");o.setAttribute("data-plugin","all"),o.textContent=e,this.#o.appendChild(o)}}#G(){this.#e&&this.#e.detachAll(),this.#W(),this.#V(),this.#R=this.#e?.getAll().some(e=>e.onScroll)??!1}#j(){this.#e?.detachAll()}#K(){if(!this.#e)return;const e=this.#e.getToolPanels();for(const{panel:n}of e)this.#i.toolPanels.has(n.id)||this.#i.toolPanels.set(n.id,n);const o=this.#e.getHeaderContents();for(const{content:n}of o)this.#i.headerContents.has(n.id)||this.#i.headerContents.set(n.id,n)}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",I.version),this._rows=Array.isArray(this.#r)?[...this.#r]:[],this.#a?.abort(),this.#a=new AbortController,this.#f(),this.#W(),this.#K(),this.#M||(this.#X(),this.#V(),this.#M=!0),this.#F()}disconnectedCallback(){this.#j(),et(this.#i),this.#n.setInitialized(!1),this.#H?.(),this.#H=void 0,this.#a&&(this.#a.abort(),this.#a=void 0),this._resizeController&&this._resizeController.dispose(),this.#E&&(this.#E.disconnect(),this.#E=void 0),this.#p=!1}attributeChangedCallback(e,o,n){if(o===n||!n||n==="null"||n==="undefined")return;const s={rows:"rows",columns:"columns","grid-config":"gridConfig","fit-mode":"fitMode","edit-on":"editOn"}[e];if(s)if(e==="rows"||e==="columns"||e==="grid-config")try{this[s]=JSON.parse(n)}catch{console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`,n)}else this[s]=n}#F(){const o=this.#o.querySelector(".tbw-grid-content")??this.#o.querySelector(".tbw-grid-root");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.#n.isInitialized){be(this.#o,this.#i),Ze(this.#o,this.#t?.shell,this.#i);const l=this.#t?.shell?.toolPanel?.defaultOpen;l&&this.#i.toolPanels.has(l)&&(this.openToolPanel(),this.#i.expandedSections.add(l))}this.setAttribute("data-upgraded",""),this.#p=!0;const n=this.disconnectSignal;this._resizeController=Ge(this),this.#c(),this.addEventListener("keydown",l=>qe(this,l),{signal:n}),document.addEventListener("keydown",l=>{l.key==="Escape"&&this._activeEditRows!==-1&&N(this,this._activeEditRows,!0)},{capture:!0,signal:n}),document.addEventListener("mousedown",l=>{if(this._activeEditRows===-1)return;const a=this.findRenderedRowElement(this._activeEditRows);!a||(l.composedPath&&l.composedPath()||[]).includes(a)||N(this,this._activeEditRows,!1)},{signal:n});const i=o?.querySelector(".faux-vscroll"),s=o?.querySelector(".rows");if(this._virtualization.container=i??this,this.#R=this.#e?.getAll().some(l=>l.onScroll)??!1,i&&s){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#R)return;const d=i.scrollTop,f=this._virtualization.rowHeight,h=Math.floor(d/f),p=h-h%2,c=-(d-p*f);s.style.transform=`translateY(${c}px)`,this.#S=d,this.#b||(this.#b=requestAnimationFrame(()=>{this.#b=0,this.#S!==null&&(this.#ie(this.#S),this.#S=null)}))},{passive:!0,signal:n});const l=this.#o.querySelector(".tbw-grid-content"),a=this.#o.querySelector(".tbw-scroll-area");l&&(l.addEventListener("wheel",d=>{const f=d.shiftKey||Math.abs(d.deltaX)>Math.abs(d.deltaY);if(f&&a){const h=d.shiftKey?d.deltaY:d.deltaX,{scrollLeft:p,scrollWidth:c,clientWidth:u}=a;(h>0&&p<c-u||h<0&&p>0)&&(d.preventDefault(),a.scrollLeft+=h)}else if(!f){const{scrollTop:h,scrollHeight:p,clientHeight:c}=i;(d.deltaY>0&&h<p-c||d.deltaY<0&&h>0)&&(d.preventDefault(),i.scrollTop+=d.deltaY)}},{passive:!1,signal:n}),l.addEventListener("touchstart",d=>{d.touches.length===1&&(this.#w&&(cancelAnimationFrame(this.#w),this.#w=0),this.#x=d.touches[0].clientY,this.#T=d.touches[0].clientX,this.#m=d.touches[0].clientY,this.#v=d.touches[0].clientX,this.#_=performance.now(),this.#L=i.scrollTop,this.#P=a?.scrollLeft??0,this.#d=0,this.#u=0)},{passive:!0,signal:n}),l.addEventListener("touchmove",d=>{if(d.touches.length===1&&this.#x!==null&&this.#T!==null&&this.#L!==null&&this.#P!==null){const f=d.touches[0].clientY,h=d.touches[0].clientX,p=performance.now(),c=this.#x-f,u=this.#T-h;if(this.#_!==null&&this.#m!==null&&this.#v!==null){const g=p-this.#_;g>0&&(this.#d=(this.#m-f)/g,this.#u=(this.#v-h)/g)}this.#m=f,this.#v=h,this.#_=p;const{scrollTop:b,scrollHeight:w,clientHeight:v}=i,R=w-v,A=c>0&&b<R||c<0&&b>0;let C=!1;if(a){const{scrollLeft:g,scrollWidth:m,clientWidth:y}=a,_=m-y;C=u>0&&g<_||u<0&&g>0}A&&(i.scrollTop=this.#L+c),C&&a&&(a.scrollLeft=this.#P+u),(A||C)&&d.preventDefault()}},{passive:!1,signal:n}),l.addEventListener("touchend",()=>{(Math.abs(this.#d)>.1||Math.abs(this.#u)>.1)&&this.#se(i,a),this.#x=null,this.#T=null,this.#L=null,this.#P=null,this.#m=null,this.#v=null,this.#_=null},{passive:!0,signal:n}))}this.#o.addEventListener("mousedown",l=>this.#re(l),{signal:n}),document.addEventListener("mousemove",l=>this.#le(l),{signal:n}),document.addEventListener("mouseup",l=>this.#ae(l),{signal:n}),this._virtualization.enabled&&requestAnimationFrame(()=>this.refreshVirtualWindow(!0));const r=this.#t.rowHeight;r&&r>0?this._virtualization.rowHeight=r:requestAnimationFrame(()=>{const l=this._bodyEl?.querySelector(".data-grid-row");if(l){const a=l.getBoundingClientRect().height;a>0&&(this._virtualization.rowHeight=a,this.refreshVirtualWindow(!0))}}),this._virtualization.viewportEl&&(this.#E=new ResizeObserver(()=>{this.#b||(this.#b=requestAnimationFrame(()=>{this.#b=0,this.refreshVirtualWindow(!0),z(this)}))}),this.#E.observe(this._virtualization.viewportEl)),queueMicrotask(()=>this.#Z()),requestAnimationFrame(()=>requestAnimationFrame(()=>this.#$?.()))}#s(e,o){this.dispatchEvent(new CustomEvent(e,{detail:o,bubbles:!0,composed:!0}))}_emitCellCommit(e){this.#s("cell-commit",e)}_emitRowCommit(e){this.#s("row-commit",e)}_emitSortChange(e){this.#s("sort-change",e)}_emitColumnResize(e){this.#s("column-resize",e)}_emitActivateCell(e){this.#s("activate-cell",e)}#Z(){this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((o,n)=>{const i=n===this._focusRow;o.setAttribute("aria-selected",String(i)),o.querySelectorAll(".cell").forEach((s,r)=>{s.setAttribute("aria-selected",String(i&&r===this._focusCol))})})}#Q(){if(!this.#p)return;this.#f(),this.#t.fitMode==="fixed"?(this.__didInitialAutoSize=!1,le(this)):(this._columns.forEach(o=>{!o.__userResized&&o.__autoSized&&delete o.width}),D(this))}#J(){this.#p&&(this.#f(),this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++,this.refreshVirtualWindow(!0))}#ee(){this._rows=Array.isArray(this.#r)?[...this.#r]:[],this.#O(),this._columns.length>0||Array.isArray(this.#t?.columns)&&this.#t.columns.length>0||Array.isArray(this.#l)&&this.#l.length>0?(this.#k(),this.refreshVirtualWindow(!0)):this.#c()}#te(){j(this),this.#p&&(this.#f(),this.#c())}#oe(){this.#p&&(this.#f(),this.#G(),this.#O(),this.#k(),W(this),D(this),this.refreshVirtualWindow(!0))}#k(){if(this.#e){const e=this.#N.length>0?this.#N:this._columns,o=e.filter(s=>!s.hidden),n=e.filter(s=>s.hidden),i=this.#e.processColumns([...o]);if(i!==o){const s=new Map(i.map((l,a)=>[l.field,{col:l,order:a}]));if(!o.some(l=>s.has(l.field))&&i.length>0)this._columns=[...i,...n];else{const l=e.map(a=>{if(a.hidden)return a;const d=s.get(a.field);return d?d.col:a});this._columns=l}}else this._columns=[...e]}}#O(){j(this);const e=Array.isArray(this.#r)?[...this.#r]:[],o=this.#e?.processRows(e)??e;this._rows=o}#f(){const e=this.#g?{...this.#g}:{};let o=Array.isArray(e.columns)?[...e.columns]:[];const n=(this.__lightDomColumnsCache||[]).map(i=>({...i}));if(n.length){const i={};o.forEach(s=>i[s.field]=s),n.forEach(s=>{const r=i[s.field];r?(s.header&&!r.header&&(r.header=s.header),s.type&&!r.type&&(r.type=s.type),r.sortable=r.sortable||s.sortable,s.resizable&&(r.resizable=!0),s.editable&&(r.editable=!0)):(o.push(s),i[s.field]=s)})}if(this.#l&&this.#l.length&&(o=[...this.#l]),(!o||o.length===0)&&this._rows.length&&(o=ne(this._rows).columns),o.length){o.forEach(r=>{r.sortable===void 0&&(r.sortable=!0),r.resizable===void 0&&(r.resizable=!0);const l=r;l.__originalWidth===void 0&&typeof r.width=="number"&&(l.__originalWidth=r.width)});const i=this.#t.columns;i?.some(r=>r.__compiledView||r.__compiledEditor)?e.columns=i:e.columns=o}else{const i=this.#t.columns;i?.some(s=>s.__compiledView||s.__compiledEditor)&&(e.columns=i)}this.#C&&(e.fitMode=this.#C),e.fitMode||(e.fitMode="stretch"),this.#y&&(e.editOn=this.#y),e.rowHeight&&e.rowHeight>0&&(this._virtualization.rowHeight=e.rowHeight),e.columnState&&!this.#h&&(this.#h=e.columnState),this.#t=e,e.fitMode==="fixed"&&this._columns.forEach(i=>{i.width==null&&(i.width=80)}),this.#ne()}#ne(){const e={...oe,...this.#t.animation},o=e.mode??"reduced-motion";let n=1;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}#I(e,o,n=this.__rowRenderEpoch){this.#z||(this.#z=(i,s,r)=>this.#e?.renderRow(i,s,r)??!1),We(this,e,o,n,this.#z)}#c(){if(!this.isConnected||!this._headerRowEl||!this._bodyEl)return;const e=this.#g?.columns||this.#l||[];if(e.length){const n=new Map(this._columns.filter(s=>s.hidden).map(s=>[s.field,!0])),i=e.map(s=>({...s,hidden:n.get(s.field)??s.hidden}));this._columns=i}if(Ne(this),this.#f(),this.#G(),this.#N=[...this._columns],this.#O(),this.#k(),this.#h){const n=this.#h;this.#h=void 0,this.#U(n)}W(this),D(this),this.refreshVirtualWindow(!0),this.#t.fitMode==="fixed"&&!this.__didInitialAutoSize&&requestAnimationFrame(()=>le(this)),this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),queueMicrotask(()=>this.#e?.afterRender())}#U(e){const o=this.#t.columns??[],n=this.#e?.getAll()??[];Ce(this,e,o,n);for(const i of e.columns){const s=o.find(r=>r.field===i.field);s&&(s.hidden=!i.visible)}}#ie(e){if(this.refreshVirtualWindow(!1),this.#e?.onScrollRender(),this.#R){const o=this._virtualization.container,n={scrollTop:e,scrollLeft:o?.scrollLeft??0,scrollHeight:o?.scrollHeight??0,scrollWidth:o?.scrollWidth??0,clientHeight:o?.clientHeight??0,clientWidth:o?.clientWidth??0,originalEvent:new Event("scroll")};this.#e?.onScroll(n)}}findHeaderRow(){return this.#o.querySelector(".header-row")}findRenderedRowElement(e){return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find(o=>{const n=o.querySelector(".cell[data-row]");return n&&Number(n.getAttribute("data-row"))===e})||null}_dispatchCellClick(e,o,n,i){const s=this._rows[o],r=this._columns[n];if(!s||!r)return!1;const l={row:s,rowIndex:o,colIndex:n,field:r.field,value:s[r.field],cellEl:i,originalEvent:e};return this.#e?.onCellClick(l)??!1}_dispatchRowClick(e,o,n,i){if(!n)return!1;const s={rowIndex:o,row:n,rowEl:i,originalEvent:e};return this.#e?.onRowClick(s)??!1}_dispatchHeaderClick(e,o,n){const i=this._columns[o];if(!i)return!1;const s={colIndex:o,field:i.field,column:i,headerEl:n,originalEvent:e};return this.#e?.onHeaderClick(s)??!1}_dispatchKeyDown(e){return this.#e?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,o){return this.#e?.getHorizontalScrollOffsets(e,o)??{left:0,right:0}}queryPlugins(e){return this.#e?.queryPlugins(e)??[]}#q(e,o){let n=null;const i=e.composedPath?.();if(i&&i.length>0?n=i[0]:n=e.target,n&&!this.#o.contains(n)){const u=this.#o.elementFromPoint(e.clientX,e.clientY);u&&(n=u)}const s=n?.closest?.("[data-col]"),r=n?.closest?.(".data-grid-row"),l=n?.closest?.(".header-row");let a,d,f,h,p,c;return s&&(a=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),a>=0&&d>=0&&(f=this._rows[a],c=this._columns[d],h=c?.field,p=f&&h?f[h]:void 0)),{type:o,row:f,rowIndex:a!==void 0&&a>=0?a:void 0,colIndex:d!==void 0&&d>=0?d:void 0,field:h,value:p,column:c,originalEvent:e,cellElement:s??void 0,rowElement:r??void 0,isHeader:!!l,cell:a!==void 0&&d!==void 0&&a>=0&&d>=0?{row:a,col:d}:void 0}}#se(e,o){const s=()=>{this.#d*=.95,this.#u*=.95;const r=this.#d*16,l=this.#u*16;Math.abs(this.#d)>.01&&(e.scrollTop+=r),Math.abs(this.#u)>.01&&o&&(o.scrollLeft+=l),Math.abs(this.#d)>.01||Math.abs(this.#u)>.01?this.#w=requestAnimationFrame(s):this.#w=0};this.#w=requestAnimationFrame(s)}#re(e){const o=this.#q(e,"mousedown");(this.#e?.onCellMouseDown(o)??!1)&&(this.#A=!0)}#le(e){if(!this.#A)return;const o=this.#q(e,"mousemove");this.#e?.onCellMouseMove(o)}#ae(e){if(!this.#A)return;const o=this.#q(e,"mouseup");this.#e?.onCellMouseUp(o),this.#A=!1}get changedRows(){return Array.from(this._changedRowIndices).map(e=>this._rows[e])}get changedRowIndices(){return Array.from(this._changedRowIndices)}async resetChangedRows(e){this._changedRowIndices.clear(),e||this.#s("changed-rows-reset",{rows:this.changedRows,indices:this.changedRowIndices}),this._rowPool.forEach(o=>o.classList.remove("changed"))}async beginBulkEdit(e){if(!this._columns.some(s=>s.editable))return;const n=this._rows[e];$(this,e,n);const i=this.findRenderedRowElement?.(e);i&&(Array.from(i.children).forEach((s,r)=>{const l=this._visibleColumns[r];if(l?.editable){const a=s;a.classList.contains("editing")||M(this,n,e,l,a)}}),queueMicrotask(()=>{const s=i.querySelector(`.cell[data-col="${this._focusCol}"]`);if(s?.classList.contains("editing")){const r=s.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])');try{r?.focus()}catch{}}}))}async commitActiveRowEdit(){this._activeEditRows!==-1&&N(this,this._activeEditRows,!1)}async ready(){return this.#B}async forceLayout(){this.#c(),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)))}async getConfig(){return Object.freeze({...this.#t||{}})}setColumnVisible(e,o){const n=this.#t.columns,i=n?.find(l=>l.field===e);if(!i||!o&&i.lockVisible||!o&&(n??[]).filter(a=>!a.hidden&&a.field!==e).length===0)return!1;const s=!!i.hidden,r=!o;return s!==r?(i.hidden=r,this.#s("column-visibility",{field:e,visible:o,visibleColumns:(n??[]).filter(l=>!l.hidden).map(l=>l.field)}),this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++,this.#c(),this.requestStateChange(),!0):!1}toggleColumnVisibility(e){const i=!!this.#t.columns?.find(s=>s.field===e)?.hidden;return this.setColumnVisible(e,i)}isColumnVisible(e){const n=this.#t.columns?.find(i=>i.field===e);return n?!n.hidden:!1}showAllColumns(){const e=this.#t.columns;e?.some(n=>n.hidden)&&(e?.forEach(n=>{n.hidden=!1}),this.#s("column-visibility",{visibleColumns:(e??[]).map(n=>n.field)}),this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++,this.#c(),this.requestStateChange())}getAllColumns(){return(this.#t.columns??[]).map(o=>({field:o.field,header:o.header||o.field,visible:!o.hidden,lockVisible:o.lockVisible}))}setColumnOrder(e){if(!e.length)return;const o=new Map(this._columns.map(i=>[i.field,i])),n=[];for(const i of e){const s=o.get(i);s&&(n.push(s),o.delete(i))}for(const i of o.values())n.push(i);this._columns=n,W(this),D(this),this.refreshVirtualWindow(!0)}getColumnOrder(){return this._columns.map(e=>e.field)}getColumnState(){const e=this.#e?.getAll()??[];return te(this,e)}set columnState(e){e&&(this.#h=e,this.#M&&this.#ce(e))}get columnState(){return this.getColumnState()}#ce(e){(this.#t.columns??[]).forEach(n=>{n.hidden=!1}),this.#U(e),this.#c()}requestStateChange(){this.#D||(this.#D=ye(this,()=>this.#e?.getAll()??[],e=>this.#s("column-state-change",e))),this.#D()}resetColumnState(){this.#h=void 0,(this.#t.columns??[]).forEach(n=>{n.hidden=!1}),this._sortState=null,this.__originalOrder=[],this.#f(),this.#c();const o=this.#e?.getAll()??[];for(const n of o)if(n.applyColumnState)for(const i of this._columns)n.applyColumnState(i.field,{field:i.field,order:0,visible:!0});this.requestStateChange()}get isToolPanelOpen(){return this.#n.isPanelOpen}get activeToolPanel(){return this.#n.activePanel}get expandedToolPanelSections(){return this.#n.expandedSections}openToolPanel(){this.#n.openToolPanel()}closeToolPanel(){this.#n.closeToolPanel()}toggleToolPanel(){this.#n.toggleToolPanel()}toggleToolPanelSection(e){this.#n.toggleToolPanelSection(e)}getToolPanels(){return this.#n.getToolPanels()}registerToolPanel(e){this.#n.registerToolPanel(e)}unregisterToolPanel(e){this.#n.unregisterToolPanel(e)}getHeaderContents(){return this.#n.getHeaderContents()}registerHeaderContent(e){this.#n.registerHeaderContent(e)}unregisterHeaderContent(e){this.#n.unregisterHeaderContent(e)}getToolbarButtons(){return this.#n.getToolbarButtons()}registerToolbarButton(e){this.#n.registerToolbarButton(e)}unregisterToolbarButton(e){this.#n.unregisterToolbarButton(e)}setToolbarButtonDisabled(e,o){this.#n.setToolbarButtonDisabled(e,o)}refreshShellHeader(){pe(this,this.#i),this.#X(),this.#F()}refreshVirtualWindow(e=!1){if(!this._bodyEl)return;const o=this._rows.length;if(!this._virtualization.enabled){this.#I(0,o),this.#e?.afterRender();return}if(this._rows.length<=this._virtualization.bypassThreshold){if(this._virtualization.start=0,this._virtualization.end=o,this._bodyEl.style.transform="translateY(0px)",this.#I(0,o,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this._virtualization.totalHeightEl){const y=this.#o.querySelector(".tbw-scroll-area"),_=y?y.offsetHeight-y.clientHeight:0;this._virtualization.totalHeightEl.style.height=`${o*this._virtualization.rowHeight+_}px`}const m=this.#o.querySelector(".rows-body");m?.setAttribute("aria-rowcount",String(o)),m?.setAttribute("aria-colcount",String(this._visibleColumns.length)),this.#e?.afterRender();return}const n=this._virtualization.container??this,s=(this._virtualization.viewportEl??n).clientHeight,r=this._virtualization.rowHeight,l=n.scrollTop;let a=Math.floor(l/r),d=0;const f=10;for(;d<f;){const m=this.#e?.getExtraHeightBefore?.(a)??0,y=Math.floor((l-m)/r);if(y>=a||y<0)break;a=y,d++}a=a-a%2,a<0&&(a=0);const h=this.#e?.adjustVirtualStart(a,l,r);h!==void 0&&h<a&&(a=h,a=a-a%2,a<0&&(a=0));const p=Math.ceil(s/r)+3;let c=a+p;c>o&&(c=o),this._virtualization.start=a,this._virtualization.end=c;const b=this.#o.querySelector(".tbw-footer")?.offsetHeight??0,w=this.#e?.getExtraHeight()??0,v=this.#o.querySelector(".tbw-scroll-area"),R=v?v.offsetHeight-v.clientHeight:0;this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${o*r+r+b+w+R}px`);const A=this.#e?.getExtraHeightBefore?.(a)??0,C=-(l-a*r-A);this._bodyEl.style.transform=`translateY(${C}px)`,this.#I(a,c,e?++this.__rowRenderEpoch:this.__rowRenderEpoch);const g=this.#o.querySelector(".rows-body");g?.setAttribute("aria-rowcount",String(o)),g?.setAttribute("aria-colcount",String(this._visibleColumns.length)),e&&this.#e?.afterRender()}#X(){pe(this,this.#i);const e=this.#t?.shell,o=Ue(e,this.#i),n=`
|
|
44
|
+
`)}processRows(e){let o=[...e];for(const n of this.plugins)n.processRows&&(o=n.processRows(o));return o}processColumns(e){let o=[...e];for(const n of this.plugins)n.processColumns&&(o=n.processColumns(o));return o}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.plugins)e.afterRender?.()}onScrollRender(){for(const e of this.plugins)e.onScrollRender?.()}getExtraHeight(){let e=0;for(const o of this.plugins)typeof o.getExtraHeight=="function"&&(e+=o.getExtraHeight());return e}getExtraHeightBefore(e){let o=0;for(const n of this.plugins)typeof n.getExtraHeightBefore=="function"&&(o+=n.getExtraHeightBefore(e));return o}adjustVirtualStart(e,o,n){let i=e;for(const s of this.plugins)if(typeof s.adjustVirtualStart=="function"){const r=s.adjustVirtualStart(e,o,n);r<i&&(i=r)}return i}renderRow(e,o,n){for(const i of this.plugins)if(i.renderRow?.(e,o,n))return!0;return!1}queryPlugins(e){const o=[];for(const n of this.plugins){const i=n.onPluginQuery?.(e);i!==void 0&&o.push(i)}return o}onKeyDown(e){for(const o of this.plugins)if(o.onKeyDown?.(e))return!0;return!1}onCellClick(e){for(const o of this.plugins)if(o.onCellClick?.(e))return!0;return!1}onRowClick(e){for(const o of this.plugins)if(o.onRowClick?.(e))return!0;return!1}onHeaderClick(e){for(const o of this.plugins)if(o.onHeaderClick?.(e))return!0;return!1}onScroll(e){for(const o of this.plugins)o.onScroll?.(e)}onCellMouseDown(e){for(const o of this.plugins)if(o.onCellMouseDown?.(e))return!0;return!1}onCellMouseMove(e){for(const o of this.plugins)if(o.onCellMouseMove?.(e))return!0;return!1}onCellMouseUp(e){for(const o of this.plugins)if(o.onCellMouseUp?.(e))return!0;return!1}getHorizontalScrollOffsets(e,o){let n=0,i=0,s=!1;for(const r of this.plugins){const l=r.getHorizontalScrollOffsets?.(e,o);l&&(n+=l.left,i+=l.right,l.skipScroll&&(s=!0))}return{left:n,right:i,skipScroll:s}}getToolPanels(){const e=[];for(const o of this.plugins){const n=o.getToolPanel?.();n&&e.push({plugin:o,panel:n})}return e.sort((o,n)=>(o.panel.order??0)-(n.panel.order??0))}getHeaderContents(){const e=[];for(const o of this.plugins){const n=o.getHeaderContent?.();n&&e.push({plugin:o,content:n})}return e.sort((o,n)=>(o.content.order??0)-(n.content.order??0))}}class I extends HTMLElement{static tagName="tbw-grid";static version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";static get observedAttributes(){return["rows","columns","grid-config","fit-mode","edit-on"]}#o;#M=!1;#B;#$;#r=[];#l;#g;#C;#y;#t={};#p=!1;#b=0;#S=null;#R=!1;#z;#A=!1;#x=null;#T=null;#L=null;#P=null;#m=null;#v=null;#_=null;#d=0;#u=0;#w=0;#a;#E;#e;#D;#h;#i=Fe();#n;#H;_rows=[];#N=[];get _columns(){return this.#t.columns??[]}set _columns(e){this.#t.columns=e}get _visibleColumns(){return this._columns.filter(e=>!e.hidden)}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;_virtualization={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null};_focusRow=0;_focusCol=0;_sortState=null;_activeEditRows=-1;_rowEditSnapshots=new Map;_changedRowIndices=new Set;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;__lightDomColumnsCache;__originalColumnNodes;__originalOrder=[];get rows(){return this._rows}set rows(e){const o=this.#r;this.#r=e,o!==e&&this.#ee()}get sourceRows(){return this.#r}get columns(){return[...this._columns]}set columns(e){const o=this.#l;this.#l=e,o!==e&&this.#te()}get gridConfig(){return this.#t}set gridConfig(e){const o=this.#g;this.#g=e,o!==e&&this.#oe()}get fitMode(){return this.#t.fitMode??"stretch"}set fitMode(e){const o=this.#C;this.#C=e,o!==e&&this.#Q()}get editOn(){return this.#t.editOn}set editOn(e){const o=this.#y;this.#y=e,o!==e&&this.#J()}get effectiveConfig(){return this.#t}get disconnectSignal(){return this.#a||(this.#a=new AbortController),this.#a.signal}constructor(){super(),this.#o=this.attachShadow({mode:"open"}),this.#Y(),this.#B=new Promise(e=>this.#$=e),this.#n=tt(this.#i,{getShadow:()=>this.#o,getShellConfig:()=>this.#t?.shell,getAccordionIcons:()=>({expand:this.#t?.icons?.expand??P.expand,collapse:this.#t?.icons?.collapse??P.collapse}),emit:(e,o)=>this.#s(e,o),refreshShellHeader:()=>this.refreshShellHeader()})}#Y(){const e=new CSSStyleSheet;e.replaceSync(V),this.#o.adoptedStyleSheets=[e]}getPlugin(e){return this.#e?.getPlugin(e)}getPluginByName(e){return this.#e?.getPluginByName(e)}requestRender(){this.#O(),this.#k(),W(this),D(this),this.refreshVirtualWindow(!0)}updateTemplate(){D(this)}requestAfterRender(){this.#e?.afterRender()}#W(){this.#e=new me(this);const e=this.#t?.plugins,o=Array.isArray(e)?e:[];this.#e.attachAll(o)}#V(){const e=this.#e?.getAllStyles()??"";if(e){const o=document.createElement("style");o.setAttribute("data-plugin","all"),o.textContent=e,this.#o.appendChild(o)}}#G(){this.#e&&this.#e.detachAll(),this.#W(),this.#V(),this.#R=this.#e?.getAll().some(e=>e.onScroll)??!1}#j(){this.#e?.detachAll()}#K(){if(!this.#e)return;const e=this.#e.getToolPanels();for(const{panel:n}of e)this.#i.toolPanels.has(n.id)||this.#i.toolPanels.set(n.id,n);const o=this.#e.getHeaderContents();for(const{content:n}of o)this.#i.headerContents.has(n.id)||this.#i.headerContents.set(n.id,n)}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",I.version),this._rows=Array.isArray(this.#r)?[...this.#r]:[],this.#a?.abort(),this.#a=new AbortController,this.#f(),this.#W(),this.#K(),this.#M||(this.#X(),this.#V(),this.#M=!0),this.#F()}disconnectedCallback(){this.#j(),et(this.#i),this.#n.setInitialized(!1),this.#H?.(),this.#H=void 0,this.#a&&(this.#a.abort(),this.#a=void 0),this._resizeController&&this._resizeController.dispose(),this.#E&&(this.#E.disconnect(),this.#E=void 0),this.#p=!1}attributeChangedCallback(e,o,n){if(o===n||!n||n==="null"||n==="undefined")return;const s={rows:"rows",columns:"columns","grid-config":"gridConfig","fit-mode":"fitMode","edit-on":"editOn"}[e];if(s)if(e==="rows"||e==="columns"||e==="grid-config")try{this[s]=JSON.parse(n)}catch{console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`,n)}else this[s]=n}#F(){const o=this.#o.querySelector(".tbw-grid-content")??this.#o.querySelector(".tbw-grid-root");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.#n.isInitialized){be(this.#o,this.#i),Ze(this.#o,this.#t?.shell,this.#i);const l=this.#t?.shell?.toolPanel?.defaultOpen;l&&this.#i.toolPanels.has(l)&&(this.openToolPanel(),this.#i.expandedSections.add(l))}this.setAttribute("data-upgraded",""),this.#p=!0;const n=this.disconnectSignal;this._resizeController=Ge(this),this.#c(),this.addEventListener("keydown",l=>qe(this,l),{signal:n}),document.addEventListener("keydown",l=>{l.key==="Escape"&&this._activeEditRows!==-1&&N(this,this._activeEditRows,!0)},{capture:!0,signal:n}),document.addEventListener("mousedown",l=>{if(this._activeEditRows===-1)return;const a=this.findRenderedRowElement(this._activeEditRows);!a||(l.composedPath&&l.composedPath()||[]).includes(a)||N(this,this._activeEditRows,!1)},{signal:n});const i=o?.querySelector(".faux-vscroll"),s=o?.querySelector(".rows");if(this._virtualization.container=i??this,this.#R=this.#e?.getAll().some(l=>l.onScroll)??!1,i&&s){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#R)return;const d=i.scrollTop,f=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)s.style.transform=`translateY(${-d}px)`;else{const h=Math.floor(d/f),p=h-h%2,c=-(d-p*f);s.style.transform=`translateY(${c}px)`}this.#S=d,this.#b||(this.#b=requestAnimationFrame(()=>{this.#b=0,this.#S!==null&&(this.#ie(this.#S),this.#S=null)}))},{passive:!0,signal:n});const l=this.#o.querySelector(".tbw-grid-content"),a=this.#o.querySelector(".tbw-scroll-area");l&&(l.addEventListener("wheel",d=>{const f=d.shiftKey||Math.abs(d.deltaX)>Math.abs(d.deltaY);if(f&&a){const h=d.shiftKey?d.deltaY:d.deltaX,{scrollLeft:p,scrollWidth:c,clientWidth:u}=a;(h>0&&p<c-u||h<0&&p>0)&&(d.preventDefault(),a.scrollLeft+=h)}else if(!f){const{scrollTop:h,scrollHeight:p,clientHeight:c}=i;(d.deltaY>0&&h<p-c||d.deltaY<0&&h>0)&&(d.preventDefault(),i.scrollTop+=d.deltaY)}},{passive:!1,signal:n}),l.addEventListener("touchstart",d=>{d.touches.length===1&&(this.#w&&(cancelAnimationFrame(this.#w),this.#w=0),this.#x=d.touches[0].clientY,this.#T=d.touches[0].clientX,this.#m=d.touches[0].clientY,this.#v=d.touches[0].clientX,this.#_=performance.now(),this.#L=i.scrollTop,this.#P=a?.scrollLeft??0,this.#d=0,this.#u=0)},{passive:!0,signal:n}),l.addEventListener("touchmove",d=>{if(d.touches.length===1&&this.#x!==null&&this.#T!==null&&this.#L!==null&&this.#P!==null){const f=d.touches[0].clientY,h=d.touches[0].clientX,p=performance.now(),c=this.#x-f,u=this.#T-h;if(this.#_!==null&&this.#m!==null&&this.#v!==null){const g=p-this.#_;g>0&&(this.#d=(this.#m-f)/g,this.#u=(this.#v-h)/g)}this.#m=f,this.#v=h,this.#_=p;const{scrollTop:b,scrollHeight:w,clientHeight:v}=i,S=w-v,A=c>0&&b<S||c<0&&b>0;let y=!1;if(a){const{scrollLeft:g,scrollWidth:m,clientWidth:R}=a,_=m-R;y=u>0&&g<_||u<0&&g>0}A&&(i.scrollTop=this.#L+c),y&&a&&(a.scrollLeft=this.#P+u),(A||y)&&d.preventDefault()}},{passive:!1,signal:n}),l.addEventListener("touchend",()=>{(Math.abs(this.#d)>.1||Math.abs(this.#u)>.1)&&this.#se(i,a),this.#x=null,this.#T=null,this.#L=null,this.#P=null,this.#m=null,this.#v=null,this.#_=null},{passive:!0,signal:n}))}this.#o.addEventListener("mousedown",l=>this.#re(l),{signal:n}),document.addEventListener("mousemove",l=>this.#le(l),{signal:n}),document.addEventListener("mouseup",l=>this.#ae(l),{signal:n}),this._virtualization.enabled&&requestAnimationFrame(()=>this.refreshVirtualWindow(!0));const r=this.#t.rowHeight;r&&r>0?this._virtualization.rowHeight=r:requestAnimationFrame(()=>{const l=this._bodyEl?.querySelector(".data-grid-row");if(l){const a=l.getBoundingClientRect().height;a>0&&(this._virtualization.rowHeight=a,this.refreshVirtualWindow(!0))}}),this._virtualization.viewportEl&&(this.#E=new ResizeObserver(()=>{this.#b||(this.#b=requestAnimationFrame(()=>{this.#b=0,this.refreshVirtualWindow(!0),z(this)}))}),this.#E.observe(this._virtualization.viewportEl)),queueMicrotask(()=>this.#Z()),requestAnimationFrame(()=>requestAnimationFrame(()=>this.#$?.()))}#s(e,o){this.dispatchEvent(new CustomEvent(e,{detail:o,bubbles:!0,composed:!0}))}_emitCellCommit(e){this.#s("cell-commit",e)}_emitRowCommit(e){this.#s("row-commit",e)}_emitSortChange(e){this.#s("sort-change",e)}_emitColumnResize(e){this.#s("column-resize",e)}_emitActivateCell(e){this.#s("activate-cell",e)}#Z(){this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((o,n)=>{const i=n===this._focusRow;o.setAttribute("aria-selected",String(i)),o.querySelectorAll(".cell").forEach((s,r)=>{s.setAttribute("aria-selected",String(i&&r===this._focusCol))})})}#Q(){if(!this.#p)return;this.#f(),this.#t.fitMode==="fixed"?(this.__didInitialAutoSize=!1,le(this)):(this._columns.forEach(o=>{!o.__userResized&&o.__autoSized&&delete o.width}),D(this))}#J(){this.#p&&(this.#f(),this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++,this.refreshVirtualWindow(!0))}#ee(){this._rows=Array.isArray(this.#r)?[...this.#r]:[],this.#O(),this._columns.length>0||Array.isArray(this.#t?.columns)&&this.#t.columns.length>0||Array.isArray(this.#l)&&this.#l.length>0?(this.#k(),this.refreshVirtualWindow(!0)):this.#c()}#te(){j(this),this.#p&&(this.#f(),this.#c())}#oe(){this.#p&&(this.#f(),this.#G(),this.#O(),this.#k(),W(this),D(this),this.refreshVirtualWindow(!0))}#k(){if(this.#e){const e=this.#N.length>0?this.#N:this._columns,o=e.filter(s=>!s.hidden),n=e.filter(s=>s.hidden),i=this.#e.processColumns([...o]);if(i!==o){const s=new Map(i.map((l,a)=>[l.field,{col:l,order:a}]));if(!o.some(l=>s.has(l.field))&&i.length>0)this._columns=[...i,...n];else{const l=e.map(a=>{if(a.hidden)return a;const d=s.get(a.field);return d?d.col:a});this._columns=l}}else this._columns=[...e]}}#O(){j(this);const e=Array.isArray(this.#r)?[...this.#r]:[],o=this.#e?.processRows(e)??e;this._rows=o}#f(){const e=this.#g?{...this.#g}:{};let o=Array.isArray(e.columns)?[...e.columns]:[];const n=(this.__lightDomColumnsCache||[]).map(i=>({...i}));if(n.length){const i={};o.forEach(s=>i[s.field]=s),n.forEach(s=>{const r=i[s.field];r?(s.header&&!r.header&&(r.header=s.header),s.type&&!r.type&&(r.type=s.type),r.sortable=r.sortable||s.sortable,s.resizable&&(r.resizable=!0),s.editable&&(r.editable=!0)):(o.push(s),i[s.field]=s)})}if(this.#l&&this.#l.length&&(o=[...this.#l]),(!o||o.length===0)&&this._rows.length&&(o=ne(this._rows).columns),o.length){o.forEach(r=>{r.sortable===void 0&&(r.sortable=!0),r.resizable===void 0&&(r.resizable=!0);const l=r;l.__originalWidth===void 0&&typeof r.width=="number"&&(l.__originalWidth=r.width)});const i=this.#t.columns;i?.some(r=>r.__compiledView||r.__compiledEditor)?e.columns=i:e.columns=o}else{const i=this.#t.columns;i?.some(s=>s.__compiledView||s.__compiledEditor)&&(e.columns=i)}this.#C&&(e.fitMode=this.#C),e.fitMode||(e.fitMode="stretch"),this.#y&&(e.editOn=this.#y),e.rowHeight&&e.rowHeight>0&&(this._virtualization.rowHeight=e.rowHeight),e.columnState&&!this.#h&&(this.#h=e.columnState),this.#t=e,e.fitMode==="fixed"&&this._columns.forEach(i=>{i.width==null&&(i.width=80)}),this.#ne()}#ne(){const e={...oe,...this.#t.animation},o=e.mode??"reduced-motion";let n=1;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}#I(e,o,n=this.__rowRenderEpoch){this.#z||(this.#z=(i,s,r)=>this.#e?.renderRow(i,s,r)??!1),We(this,e,o,n,this.#z)}#c(){if(!this.isConnected||!this._headerRowEl||!this._bodyEl)return;const e=this.#g?.columns||this.#l||[];if(e.length){const n=new Map(this._columns.filter(s=>s.hidden).map(s=>[s.field,!0])),i=e.map(s=>({...s,hidden:n.get(s.field)??s.hidden}));this._columns=i}if(Ne(this),this.#f(),this.#G(),this.#N=[...this._columns],this.#O(),this.#k(),this.#h){const n=this.#h;this.#h=void 0,this.#U(n)}W(this),D(this),this.refreshVirtualWindow(!0),this.#t.fitMode==="fixed"&&!this.__didInitialAutoSize&&requestAnimationFrame(()=>le(this)),this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),queueMicrotask(()=>this.#e?.afterRender())}#U(e){const o=this.#t.columns??[],n=this.#e?.getAll()??[];Ce(this,e,o,n);for(const i of e.columns){const s=o.find(r=>r.field===i.field);s&&(s.hidden=!i.visible)}}#ie(e){if(this.refreshVirtualWindow(!1),this.#e?.onScrollRender(),this.#R){const o=this._virtualization.container,n={scrollTop:e,scrollLeft:o?.scrollLeft??0,scrollHeight:o?.scrollHeight??0,scrollWidth:o?.scrollWidth??0,clientHeight:o?.clientHeight??0,clientWidth:o?.clientWidth??0,originalEvent:new Event("scroll")};this.#e?.onScroll(n)}}findHeaderRow(){return this.#o.querySelector(".header-row")}findRenderedRowElement(e){return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find(o=>{const n=o.querySelector(".cell[data-row]");return n&&Number(n.getAttribute("data-row"))===e})||null}_dispatchCellClick(e,o,n,i){const s=this._rows[o],r=this._columns[n];if(!s||!r)return!1;const l={row:s,rowIndex:o,colIndex:n,field:r.field,value:s[r.field],cellEl:i,originalEvent:e};return this.#e?.onCellClick(l)??!1}_dispatchRowClick(e,o,n,i){if(!n)return!1;const s={rowIndex:o,row:n,rowEl:i,originalEvent:e};return this.#e?.onRowClick(s)??!1}_dispatchHeaderClick(e,o,n){const i=this._columns[o];if(!i)return!1;const s={colIndex:o,field:i.field,column:i,headerEl:n,originalEvent:e};return this.#e?.onHeaderClick(s)??!1}_dispatchKeyDown(e){return this.#e?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,o){return this.#e?.getHorizontalScrollOffsets(e,o)??{left:0,right:0}}queryPlugins(e){return this.#e?.queryPlugins(e)??[]}#q(e,o){let n=null;const i=e.composedPath?.();if(i&&i.length>0?n=i[0]:n=e.target,n&&!this.#o.contains(n)){const u=this.#o.elementFromPoint(e.clientX,e.clientY);u&&(n=u)}const s=n?.closest?.("[data-col]"),r=n?.closest?.(".data-grid-row"),l=n?.closest?.(".header-row");let a,d,f,h,p,c;return s&&(a=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),a>=0&&d>=0&&(f=this._rows[a],c=this._columns[d],h=c?.field,p=f&&h?f[h]:void 0)),{type:o,row:f,rowIndex:a!==void 0&&a>=0?a:void 0,colIndex:d!==void 0&&d>=0?d:void 0,field:h,value:p,column:c,originalEvent:e,cellElement:s??void 0,rowElement:r??void 0,isHeader:!!l,cell:a!==void 0&&d!==void 0&&a>=0&&d>=0?{row:a,col:d}:void 0}}#se(e,o){const s=()=>{this.#d*=.95,this.#u*=.95;const r=this.#d*16,l=this.#u*16;Math.abs(this.#d)>.01&&(e.scrollTop+=r),Math.abs(this.#u)>.01&&o&&(o.scrollLeft+=l),Math.abs(this.#d)>.01||Math.abs(this.#u)>.01?this.#w=requestAnimationFrame(s):this.#w=0};this.#w=requestAnimationFrame(s)}#re(e){const o=this.#q(e,"mousedown");(this.#e?.onCellMouseDown(o)??!1)&&(this.#A=!0)}#le(e){if(!this.#A)return;const o=this.#q(e,"mousemove");this.#e?.onCellMouseMove(o)}#ae(e){if(!this.#A)return;const o=this.#q(e,"mouseup");this.#e?.onCellMouseUp(o),this.#A=!1}get changedRows(){return Array.from(this._changedRowIndices).map(e=>this._rows[e])}get changedRowIndices(){return Array.from(this._changedRowIndices)}async resetChangedRows(e){this._changedRowIndices.clear(),e||this.#s("changed-rows-reset",{rows:this.changedRows,indices:this.changedRowIndices}),this._rowPool.forEach(o=>o.classList.remove("changed"))}async beginBulkEdit(e){if(!this._columns.some(s=>s.editable))return;const n=this._rows[e];$(this,e,n);const i=this.findRenderedRowElement?.(e);i&&(Array.from(i.children).forEach((s,r)=>{const l=this._visibleColumns[r];if(l?.editable){const a=s;a.classList.contains("editing")||M(this,n,e,l,a)}}),queueMicrotask(()=>{const s=i.querySelector(`.cell[data-col="${this._focusCol}"]`);if(s?.classList.contains("editing")){const r=s.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])');try{r?.focus()}catch{}}}))}async commitActiveRowEdit(){this._activeEditRows!==-1&&N(this,this._activeEditRows,!1)}async ready(){return this.#B}async forceLayout(){this.#c(),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)))}async getConfig(){return Object.freeze({...this.#t||{}})}setColumnVisible(e,o){const n=this.#t.columns,i=n?.find(l=>l.field===e);if(!i||!o&&i.lockVisible||!o&&(n??[]).filter(a=>!a.hidden&&a.field!==e).length===0)return!1;const s=!!i.hidden,r=!o;return s!==r?(i.hidden=r,this.#s("column-visibility",{field:e,visible:o,visibleColumns:(n??[]).filter(l=>!l.hidden).map(l=>l.field)}),this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++,this.#c(),this.requestStateChange(),!0):!1}toggleColumnVisibility(e){const i=!!this.#t.columns?.find(s=>s.field===e)?.hidden;return this.setColumnVisible(e,i)}isColumnVisible(e){const n=this.#t.columns?.find(i=>i.field===e);return n?!n.hidden:!1}showAllColumns(){const e=this.#t.columns;e?.some(n=>n.hidden)&&(e?.forEach(n=>{n.hidden=!1}),this.#s("column-visibility",{visibleColumns:(e??[]).map(n=>n.field)}),this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++,this.#c(),this.requestStateChange())}getAllColumns(){return(this.#t.columns??[]).map(o=>({field:o.field,header:o.header||o.field,visible:!o.hidden,lockVisible:o.lockVisible}))}setColumnOrder(e){if(!e.length)return;const o=new Map(this._columns.map(i=>[i.field,i])),n=[];for(const i of e){const s=o.get(i);s&&(n.push(s),o.delete(i))}for(const i of o.values())n.push(i);this._columns=n,W(this),D(this),this.refreshVirtualWindow(!0)}getColumnOrder(){return this._columns.map(e=>e.field)}getColumnState(){const e=this.#e?.getAll()??[];return te(this,e)}set columnState(e){e&&(this.#h=e,this.#M&&this.#ce(e))}get columnState(){return this.getColumnState()}#ce(e){(this.#t.columns??[]).forEach(n=>{n.hidden=!1}),this.#U(e),this.#c()}requestStateChange(){this.#D||(this.#D=ye(this,()=>this.#e?.getAll()??[],e=>this.#s("column-state-change",e))),this.#D()}resetColumnState(){this.#h=void 0,(this.#t.columns??[]).forEach(n=>{n.hidden=!1}),this._sortState=null,this.__originalOrder=[],this.#f(),this.#c();const o=this.#e?.getAll()??[];for(const n of o)if(n.applyColumnState)for(const i of this._columns)n.applyColumnState(i.field,{field:i.field,order:0,visible:!0});this.requestStateChange()}get isToolPanelOpen(){return this.#n.isPanelOpen}get activeToolPanel(){return this.#n.activePanel}get expandedToolPanelSections(){return this.#n.expandedSections}openToolPanel(){this.#n.openToolPanel()}closeToolPanel(){this.#n.closeToolPanel()}toggleToolPanel(){this.#n.toggleToolPanel()}toggleToolPanelSection(e){this.#n.toggleToolPanelSection(e)}getToolPanels(){return this.#n.getToolPanels()}registerToolPanel(e){this.#n.registerToolPanel(e)}unregisterToolPanel(e){this.#n.unregisterToolPanel(e)}getHeaderContents(){return this.#n.getHeaderContents()}registerHeaderContent(e){this.#n.registerHeaderContent(e)}unregisterHeaderContent(e){this.#n.unregisterHeaderContent(e)}getToolbarButtons(){return this.#n.getToolbarButtons()}registerToolbarButton(e){this.#n.registerToolbarButton(e)}unregisterToolbarButton(e){this.#n.unregisterToolbarButton(e)}setToolbarButtonDisabled(e,o){this.#n.setToolbarButtonDisabled(e,o)}refreshShellHeader(){pe(this,this.#i),this.#X(),this.#F()}refreshVirtualWindow(e=!1){if(!this._bodyEl)return;const o=this._rows.length;if(!this._virtualization.enabled){this.#I(0,o),this.#e?.afterRender();return}if(this._rows.length<=this._virtualization.bypassThreshold){if(this._virtualization.start=0,this._virtualization.end=o,e&&(this._bodyEl.style.transform="translateY(0px)"),this.#I(0,o,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this._virtualization.totalHeightEl){const R=this._virtualization.container?.clientHeight??0,_=this._virtualization.viewportEl?.clientHeight??R,C=R-_;this._virtualization.totalHeightEl.style.height=`${o*this._virtualization.rowHeight+C}px`}const m=this.#o.querySelector(".rows-body");m?.setAttribute("aria-rowcount",String(o)),m?.setAttribute("aria-colcount",String(this._visibleColumns.length)),this.#e?.afterRender();return}const n=this._virtualization.container??this,s=(this._virtualization.viewportEl??n).clientHeight,r=this._virtualization.rowHeight,l=n.scrollTop;let a=Math.floor(l/r),d=0;const f=10;for(;d<f;){const m=this.#e?.getExtraHeightBefore?.(a)??0,R=Math.floor((l-m)/r);if(R>=a||R<0)break;a=R,d++}a=a-a%2,a<0&&(a=0);const h=this.#e?.adjustVirtualStart(a,l,r);h!==void 0&&h<a&&(a=h,a=a-a%2,a<0&&(a=0));const p=Math.ceil(s/r)+3;let c=a+p;c>o&&(c=o),this._virtualization.start=a,this._virtualization.end=c;const b=this.#o.querySelector(".tbw-footer")?.offsetHeight??0,w=this.#e?.getExtraHeight()??0,v=this.#o.querySelector(".tbw-scroll-area"),S=v?v.offsetHeight-v.clientHeight:0;this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${o*r+r+b+w+S}px`);const A=this.#e?.getExtraHeightBefore?.(a)??0,y=-(l-a*r-A);this._bodyEl.style.transform=`translateY(${y}px)`,this.#I(a,c,e?++this.__rowRenderEpoch:this.__rowRenderEpoch);const g=this.#o.querySelector(".rows-body");g?.setAttribute("aria-rowcount",String(o)),g?.setAttribute("aria-colcount",String(this._visibleColumns.length)),e&&this.#e?.afterRender()}#X(){pe(this,this.#i);const e=this.#t?.shell,o=Ue(e,this.#i),n=`
|
|
45
45
|
<div class="tbw-scroll-area">
|
|
46
46
|
<div class="rows-body-wrapper">
|
|
47
47
|
<div class="rows-body" role="grid">
|