@toolbox-web/grid 1.13.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +1483 -1403
- package/all.js.map +1 -1
- package/index.js +11 -4
- package/index.js.map +1 -1
- package/lib/core/internal/row-animation.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +1 -1
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +44 -1
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +69 -8
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.d.ts +1 -1
- package/lib/plugins/clipboard/index.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +257 -192
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +31 -0
- package/lib/plugins/clipboard/types.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +8 -0
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.js +75 -60
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/context-menu/types.d.ts +7 -0
- package/lib/plugins/context-menu/types.d.ts.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/editors.d.ts +2 -2
- package/lib/plugins/editing/editors.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +420 -381
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/editing/types.d.ts +6 -23
- package/lib/plugins/editing/types.d.ts.map +1 -1
- package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
- package/lib/plugins/export/index.js +75 -66
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.d.ts +1 -1
- package/lib/plugins/filtering/index.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +1 -0
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +118 -87
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pinned-rows/pinned-rows.d.ts +2 -1
- package/lib/plugins/pinned-rows/pinned-rows.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/types.d.ts +23 -2
- package/lib/plugins/pinned-rows/types.d.ts.map +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +147 -139
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/shared/data-collection.d.ts +33 -0
- package/lib/plugins/shared/data-collection.d.ts.map +1 -0
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +23 -23
- 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/umd/plugins/clipboard.umd.js +5 -5
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/export.umd.js +7 -7
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
package/umd/grid.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(y,U){typeof exports=="object"&&typeof module<"u"?U(exports):typeof define=="function"&&define.amd?define(["exports"],U):(y=typeof globalThis<"u"?globalThis:y||self,U(y.TbwGrid={}))})(this,(function(y){"use strict";function U(){return{rowCount:-1,colCount:-1,ariaLabel:void 0,ariaDescribedBy:void 0}}function ft(t,e,i,o,n){if(o===t.rowCount&&n===t.colCount)return!1;const r=t.rowCount;return t.rowCount=o,t.colCount=n,e&&(e.setAttribute("aria-rowcount",String(o)),e.setAttribute("aria-colcount",String(n))),o!==r&&i&&(o>0?i.setAttribute("role","rowgroup"):i.removeAttribute("role")),!0}function gt(t,e){const i=t?.gridAriaLabel;return i||(t?.shell?.header?.title??e?.lightDomTitle??void 0)}function pt(t,e,i,o){if(!e)return!1;let n=!1;const r=gt(i,o);r!==t.ariaLabel&&(t.ariaLabel=r,r?e.setAttribute("aria-label",r):e.removeAttribute("aria-label"),n=!0);const s=i?.gridAriaDescribedBy;return s!==t.ariaDescribedBy&&(t.ariaDescribedBy=s,s?e.setAttribute("aria-describedby",s):e.removeAttribute("aria-describedby"),n=!0),n}const $={STRETCH:"stretch",FIXED:"fixed"},Se={mode:"reduced-motion",duration:200,easing:"ease-out"},Re='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',M={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:Re,filterActive:Re,print:"🖨️"};function wt(t){return Array.from(t.querySelectorAll("tbw-grid-column")).map(i=>{const o=i.getAttribute("field")||"";if(!o)return null;const n=i.getAttribute("type")||void 0,s=n&&new Set(["number","string","date","boolean","select"]).has(n)?n:void 0,l=i.getAttribute("header")||void 0,a=i.hasAttribute("sortable"),c=i.hasAttribute("editable"),d={field:o,type:s,header:l,sortable:a,editable:c},f=i.getAttribute("width");if(f){const b=parseFloat(f);!isNaN(b)&&/^\d+(\.\d+)?$/.test(f.trim())?d.width=b:d.width=f}const u=i.getAttribute("minWidth")||i.getAttribute("min-width");if(u){const b=parseFloat(u);isNaN(b)||(d.minWidth=b)}i.hasAttribute("resizable")&&(d.resizable=!0),i.hasAttribute("sizable")&&(d.resizable=!0);const g=i.getAttribute("editor"),p=i.getAttribute("renderer");g&&(d.__editorName=g),p&&(d.__rendererName=p);const h=i.getAttribute("options");h&&(d.options=h.split(",").map(b=>{const[I,A]=b.includes(":")?b.split(":"):[b.trim(),b.trim()];return{value:I.trim(),label:A?.trim()||I.trim()}}));const w=i.querySelector("tbw-grid-column-view"),C=i.querySelector("tbw-grid-column-editor"),m=i.querySelector("tbw-grid-column-header");w&&(d.__viewTemplate=w),C&&(d.__editorTemplate=C),m&&(d.__headerTemplate=m);const R=globalThis.DataGridElement?.getAdapters?.()??[],T=w??i,v=R.find(b=>b.canHandle(T));if(v){const b=v.createRenderer(T);b&&(d.viewRenderer=b)}const S=C??i,E=R.find(b=>b.canHandle(S));if(E){const b=E.createEditor(S);b&&(d.editor=b)}return d}).filter(i=>!!i)}function Ae(t,e){if((!t||!t.length)&&(!e||!e.length))return[];if(!t||!t.length)return e||[];if(!e||!e.length)return t;const i={};e.forEach(n=>{const r=i[n.field];if(r){n.header&&!r.header&&(r.header=n.header),n.type&&!r.type&&(r.type=n.type),n.sortable&&(r.sortable=!0),n.editable&&(r.editable=!0),n.resizable&&(r.resizable=!0),n.width!=null&&r.width==null&&(r.width=n.width),n.minWidth!=null&&r.minWidth==null&&(r.minWidth=n.minWidth),n.__viewTemplate&&(r.__viewTemplate=n.__viewTemplate),n.__editorTemplate&&(r.__editorTemplate=n.__editorTemplate),n.__headerTemplate&&(r.__headerTemplate=n.__headerTemplate);const s=n.renderer||n.viewRenderer,l=r.renderer||r.viewRenderer;s&&!l&&(r.viewRenderer=s,n.renderer&&(r.renderer=s)),n.editor&&!r.editor&&(r.editor=n.editor)}else i[n.field]={...n}});const o=t.map(n=>{const r=i[n.field];if(!r)return n;const s={...n};r.header&&!s.header&&(s.header=r.header),r.type&&!s.type&&(s.type=r.type),s.sortable=n.sortable||r.sortable,(n.resizable===!0||r.resizable===!0)&&(s.resizable=!0),s.editable=n.editable||r.editable,r.width!=null&&s.width==null&&(s.width=r.width),r.minWidth!=null&&s.minWidth==null&&(s.minWidth=r.minWidth),r.__viewTemplate&&(s.__viewTemplate=r.__viewTemplate),r.__editorTemplate&&(s.__editorTemplate=r.__editorTemplate),r.__headerTemplate&&(s.__headerTemplate=r.__headerTemplate);const l=r.renderer||r.viewRenderer,a=s.renderer||s.viewRenderer;return l&&!a&&(s.viewRenderer=l,r.renderer&&(s.renderer=l)),r.editor&&!s.editor&&(s.editor=r.editor),delete i[n.field],s});return Object.keys(i).forEach(n=>o.push(i[n])),o}function Te(t,e){try{t.part?.add?.(e)}catch{}const i=t.getAttribute("part");i?i.split(/\s+/).includes(e)||t.setAttribute("part",i+" "+e):t.setAttribute("part",e)}function xe(t){const e=t.effectiveConfig?.fitMode||t.fitMode||$.STRETCH;if(e!==$.STRETCH&&e!==$.FIXED||t.__didInitialAutoSize||!t.isConnected)return;const i=Array.from(t._headerRowEl?.children||[]);if(!i.length)return;let o=!1;t._visibleColumns.forEach((n,r)=>{if(n.width)return;const s=i[r];let l=s?s.scrollWidth:0;for(const a of t._rowPool){const c=a.children[r];if(c){const d=c.scrollWidth;d>l&&(l=d)}}l>0&&(n.width=l+2,n.__autoSized=!0,o=!0)}),o&&V(t),t.__didInitialAutoSize=!0}function V(t){(t.effectiveConfig?.fitMode||t.fitMode||$.STRETCH)===$.STRETCH?t._gridTemplate=t._visibleColumns.map(i=>{if(i.width)return`${i.width}px`;const o=i.minWidth;return o!=null?`minmax(${o}px, 1fr)`:"1fr"}).join(" ").trim():t._gridTemplate=t._visibleColumns.map(i=>i.width?`${i.width}px`:"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}function bt(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 mt(t,e){const i=t[0]||{},o=Object.keys(i).map(r=>{const s=i[r],l=bt(s);return{field:r,header:r.charAt(0).toUpperCase()+r.slice(1),type:l}}),n={};return o.forEach(r=>{n[r.field]=r.type||"string"}),{columns:o,typeMap:n}}const vt=/{{\s*([^}]+)\s*}}/g,z="__DG_EMPTY__",Ct=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,yt=/__(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/;function _t(t){return!t||typeof t!="string"?"":t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Et=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"]),He=/^on\w+$/i,St=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),Rt=/^\s*(javascript|vbscript|data|blob):/i;function W(t){if(!t||typeof t!="string")return"";if(t.indexOf("<")===-1)return t;const e=document.createElement("template");return e.innerHTML=t,At(e.content),e.innerHTML}function At(t){const e=[],i=t.querySelectorAll("*");for(const o of i){const n=o.tagName.toLowerCase();if(Et.has(n)){e.push(o);continue}if((n==="svg"||o.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(o.attributes).some(l=>He.test(l.name)||l.name==="href"||l.name==="xlink:href")){e.push(o);continue}const r=[];for(const s of o.attributes){const l=s.name.toLowerCase();if(He.test(l)){r.push(s.name);continue}if(St.has(l)&&Rt.test(s.value)){r.push(s.name);continue}if(l==="style"&&/expression\s*\(|javascript:|behavior\s*:/i.test(s.value)){r.push(s.name);continue}}r.forEach(s=>o.removeAttribute(s))}e.forEach(o=>o.remove())}function Le(t,e){if(!t||t.indexOf("{{")===-1)return t;const i=[],o=t.replace(vt,(l,a)=>{const c=Tt(a,e);return i.push({expr:a.trim(),result:c}),c}),n=xt(o),r=i.length&&i.every(l=>l.result===""||l.result===z);return N.test(t)||r?"":n}function Tt(t,e){if(t=(t||"").trim(),!t||N.test(t))return z;if(t==="value")return e.value==null?z:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const o=t.slice(4),n=e.row?e.row[o]:void 0;return n==null?z:String(n)}if(t.length>80||!Ct.test(t)||yt.test(t))return z;const i=t.match(/\./g);if(i&&i.length>1)return z;try{const n=new Function("value","row",`return (${t});`)(e.value,e.row),r=n==null?"":String(n);return N.test(r)?z:r||z}catch{return z}}const N=/Reflect|Proxy|ownKeys/;function xt(t){return t&&t.replace(new RegExp(z,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,"")}function Ht(t){if(N.test(t.textContent||"")){for(const e of t.childNodes)e.nodeType===Node.TEXT_NODE&&N.test(e.textContent||"")&&(e.textContent="");N.test(t.textContent||"")&&(t.textContent="")}}function Pe(t){const e=N.test(t),i=(o=>e?"":Le(t,o));return i.__blocked=e,i}const Lt=100;class Pt{#l;#n;#u;#d;#h;#a={};#o={};#f=!0;#w=[];#v;#s;#C;#r;#g;constructor(e){this.#r=e}get original(){return this.#a}get effective(){return this.#o}get columns(){return this.#o.columns??[]}set columns(e){this.#o.columns=e}get lightDomColumnsCache(){return this.#d}set lightDomColumnsCache(e){this.#d=e}get originalColumnNodes(){return this.#h}set originalColumnNodes(e){this.#h=e}get lightDomTitle(){return this.#g}set lightDomTitle(e){this.#g=e}get initialColumnState(){return this.#C}set initialColumnState(e){this.#C=e}get sourcesChanged(){return this.#f}markSourcesChanged(){this.#f=!0}setGridConfig(e){this.#l=e,this.#f=!0,this.#d=void 0}getGridConfig(){return this.#l}setColumns(e){this.#n=e,this.#f=!0}getColumns(){return this.#n}setFitMode(e){this.#u=e,this.#f=!0}getFitMode(){return this.#u}merge(){const e=(this.#o.columns?.length??0)>0;if(!this.#f&&e)return;const i=this.#k();this.#f=!1,this.#a=i,Object.freeze(this.#a),this.#a.columns&&Object.freeze(this.#a.columns),this.#o=this.#T(this.#a),this.#m()}#T(e){const i={...e};return e.columns&&(i.columns=e.columns.map(o=>({...o}))),e.shell&&(i.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(o=>({...o})),headerContents:e.shell.headerContents?.map(o=>({...o}))}),i}#m(){const e=this.#o;this.#z(),typeof e.rowHeight=="number"&&e.rowHeight>0&&this.#r.setRowHeight(e.rowHeight),e.fitMode==="fixed"&&this.columns.forEach(o=>{o.width==null&&(o.width=80)}),this.#r.applyAnimationConfig(e)}#z(){const e=this.#o.typeDefaults;if(!e)return;const i=this.columns;for(const o of i){if(!o.type)continue;const n=e[o.type];n&&(!o.renderer&&!o.viewRenderer&&n.renderer&&(o.renderer=n.renderer),!o.format&&n.format&&(o.format=n.format),!o.editor&&n.editor&&(o.editor=n.editor),!o.editorParams&&n.editorParams&&(o.editorParams=n.editorParams))}}#k(){const e=this.#l?{...this.#l}:{},i=Array.isArray(e.columns)?[...e.columns]:[],o=(this.#d??[]).map(s=>({...s}));let n=Ae(i,o);this.#n&&this.#n.length&&(n=Ae(this.#n,o));const r=this.#r.getRows();return n.length===0&&r.length&&(n=mt(r).columns),n.length&&(n.forEach(s=>{s.sortable===void 0&&(s.sortable=!0),s.resizable===void 0&&(s.resizable=!0),s.__originalWidth===void 0&&typeof s.width=="number"&&(s.__originalWidth=s.width)}),n.forEach(s=>{s.__viewTemplate&&!s.__compiledView&&(s.__compiledView=Pe(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=Pe(s.__editorTemplate.innerHTML))}),e.columns=n),this.#u&&(e.fitMode=this.#u),e.fitMode||(e.fitMode="stretch"),this.#b(e),e.columnState&&!this.#C&&(this.#C=e.columnState),e}#b(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const i=this.#r.getShellLightDomTitle();i&&(this.#g=i),this.#g&&!e.shell.header.title&&(e.shell.header.title=this.#g);const o=this.#r.getShellLightDomHeaderContent();o?.length>0&&(e.shell.header.lightDomContent=o),this.#r.getShellHasToolButtonsContainer()&&(e.shell.header.hasToolButtonsContainer=!0);const n=this.#r.getShellToolPanels();if(n.size>0){const f=Array.from(n.values());f.sort((u,g)=>(u.order??100)-(g.order??100)),e.shell.toolPanels=f}const r=this.#r.getShellHeaderContents();if(r.size>0){const f=Array.from(r.values());f.sort((u,g)=>(u.order??100)-(g.order??100)),e.shell.headerContents=f}const s=this.#r.getShellToolbarContents(),l=Array.from(s.values()),a=this.#l?.shell?.header?.toolbarContents??[],c=new Set(a.map(f=>f.id)),d=[...a];for(const f of l)c.has(f.id)||d.push(f);d.sort((f,u)=>(f.order??0)-(u.order??0)),e.shell.header.toolbarContents=d}collectState(e){const i=this.columns,o=this.#y();return{columns:i.map((n,r)=>{const s={field:n.field,order:r,visible:!n.hidden},l=n;l.__renderedWidth!==void 0?s.width=l.__renderedWidth:n.width!==void 0&&(s.width=typeof n.width=="string"?parseFloat(n.width):n.width);const a=o.get(n.field);a&&(s.sort=a);for(const c of e)if(c.getColumnState){const d=c.getColumnState(n.field);d&&Object.assign(s,d)}return s})}}applyState(e,i){if(!e.columns||e.columns.length===0)return;const o=this.columns,n=new Map(e.columns.map(l=>[l.field,l])),r=o.map(l=>{const a=n.get(l.field);if(!a)return l;const c={...l};return a.width!==void 0&&(c.width=a.width,c.__renderedWidth=a.width),a.visible!==void 0&&(c.hidden=!a.visible),c});r.sort((l,a)=>{const c=n.get(l.field)?.order??1/0,d=n.get(a.field)?.order??1/0;return c-d}),this.columns=r;const s=e.columns.filter(l=>l.sort!==void 0).sort((l,a)=>(l.sort?.priority??0)-(a.sort?.priority??0));if(s.length>0){const l=s[0];l.sort&&this.#r.setSortState({field:l.field,direction:l.sort.direction==="asc"?1:-1})}else this.#r.setSortState(null);for(const l of i)if(l.applyColumnState)for(const a of e.columns)l.applyColumnState(a.field,a)}resetState(e){this.#C=void 0,this.#r.setSortState(null),this.#o=this.#T(this.#a),this.#m();for(const i of e)if(i.applyColumnState)for(const o of this.columns)i.applyColumnState(o.field,{field:o.field,order:0,visible:!0});this.requestStateChange(e)}#y(){const e=new Map,i=this.#r.getSortState();return i&&e.set(i.field,{direction:i.direction===1?"asc":"desc",priority:0}),e}requestStateChange(e){this.#s&&clearTimeout(this.#s),this.#s=setTimeout(()=>{this.#s=void 0;const i=this.collectState(e);this.#r.emit("column-state-change",i)},Lt)}setColumnVisible(e,i){const o=this.columns,n=o.find(s=>s.field===e);return!n||!i&&n.lockVisible||!i&&o.filter(l=>!l.hidden&&l.field!==e).length===0||!!n.hidden===!i?!1:(n.hidden=!i,this.#r.emit("column-visibility",{field:e,visible:i,visibleColumns:o.filter(s=>!s.hidden).map(s=>s.field)}),this.#r.clearRowPool(),this.#r.setup(),!0)}toggleColumnVisibility(e){const i=this.columns.find(o=>o.field===e);return i?this.setColumnVisible(e,!!i.hidden):!1}isColumnVisible(e){const i=this.columns.find(o=>o.field===e);return i?!i.hidden:!1}showAllColumns(){const e=this.columns;e.some(i=>i.hidden)&&(e.forEach(i=>i.hidden=!1),this.#r.emit("column-visibility",{visibleColumns:e.map(i=>i.field)}),this.#r.clearRowPool(),this.#r.setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:e.meta?.utility===!0}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const i=new Map(this.columns.map(n=>[n.field,n])),o=[];for(const n of e){const r=i.get(n);r&&(o.push(r),i.delete(n))}for(const n of i.values())o.push(n);this.columns=o,this.#r.renderHeader(),this.#r.updateTemplate(),this.#r.refreshVirtualWindow()}parseLightDomColumns(e){this.#d||(this.#h=Array.from(e.querySelectorAll("tbw-grid-column")),this.#d=this.#h.length?wt(e):[])}clearLightDomCache(){this.#d=void 0}#p=new Map;registerLightDomHandler(e,i){this.#p.set(e.toLowerCase(),i)}unregisterLightDomHandler(e){this.#p.delete(e.toLowerCase())}observeLightDOM(e){this.#v&&this.#v.disconnect();const i=new Set;let o=null;const n=()=>{o=null;for(const r of i)this.#p.get(r)?.();i.clear()};this.#v=new MutationObserver(r=>{for(const s of r){for(const l of s.addedNodes){if(l.nodeType!==Node.ELEMENT_NODE)continue;const c=l.tagName.toLowerCase();this.#p.has(c)&&i.add(c)}if(s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE){const a=s.target.tagName.toLowerCase();this.#p.has(a)&&i.add(a)}}i.size>0&&!o&&(o=setTimeout(n,0))}),this.#v.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#w.push(e)}notifyChange(){for(const e of this.#w)e()}dispose(){this.#v?.disconnect(),this.#w=[],this.#s&&clearTimeout(this.#s)}}function se(){if(typeof window<"u"&&window.location){const t=window.location.hostname;if(t==="localhost"||t==="127.0.0.1"||t==="::1")return!0}return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function ze(t){return`<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t?"🗹":"☐"}</span>`}function De(t){if(t==null||t==="")return"";if(t instanceof Date)return isNaN(t.getTime())?"":t.toLocaleDateString();if(typeof t=="number"||typeof t=="string"){const e=new Date(t);return isNaN(e.getTime())?"":e.toLocaleDateString()}return""}function Oe(t){if(!t)return-1;const e=t.getAttribute("data-row");if(e)return parseInt(e,10);const i=t.closest(".data-grid-row");if(!i)return-1;const o=i.parentElement;if(!o)return-1;const n=o.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<n.length;r++)if(n[r]===i)return r;return-1}function zt(t){if(!t)return-1;const e=t.getAttribute("data-col");return e?parseInt(e,10):-1}function le(t){t&&t.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function Dt(t){try{if(getComputedStyle(t).direction==="rtl")return"rtl"}catch{}try{if(t.closest?.("[dir]")?.getAttribute("dir")==="rtl")return"rtl"}catch{}return"ltr"}function Me(t){return Dt(t)==="rtl"}function ke(t,e){const i=e.renderer||e.viewRenderer;if(i)return i;if(!e.type)return;const o=t.__frameworkAdapter;if(o?.getTypeDefault){const n=o.getTypeDefault(e.type);if(n?.renderer)return n.renderer}}function Ie(t,e){if(e.format)return e.format;if(!e.type)return;const i=t.__frameworkAdapter;if(i?.getTypeDefault){const o=i.getTypeDefault(e.type);if(o?.format)return o.format}}const Ne='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function ae(t){return(t.__editingCellCount??0)>0}function ce(t){t.__editingCellCount=0,t.removeAttribute("data-has-editing"),t.querySelectorAll(".cell.editing").forEach(i=>i.classList.remove("editing"))}const qe=document.createElement("template");qe.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const $e=document.createElement("template");$e.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function Ot(){return qe.content.firstElementChild.cloneNode(!0)}function Mt(){return $e.content.firstElementChild.cloneNode(!0)}function K(t){t.__cellDisplayCache=void 0,t.__cellCacheEpoch=void 0,t.__hasSpecialColumns=void 0}function kt(t,e,i,o,n){const r=Math.max(0,i-e),s=t._bodyEl,l=t._visibleColumns,a=l.length;let c=t.__cachedHeaderRowCount;for(c===void 0&&(c=t.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=c);t._rowPool.length<r;){const u=Mt();t._rowPool.push(u)}if(t._rowPool.length>r){for(let u=r;u<t._rowPool.length;u++){const g=t._rowPool[u];g.parentNode===s&&g.remove()}t._rowPool.length=r}const d=n&&t.__hasRenderRowPlugins!==!1,f=t._hasAfterRowRenderHook?.()??!1;for(let u=0;u<r;u++){const g=e+u,p=t._rows[g],h=t._rowPool[u];if(h.setAttribute("aria-rowindex",String(g+c+1)),d&&n(p,h,g)){h.__epoch=o,h.__rowDataRef=p,h.parentNode!==s&&s.appendChild(h);continue}const w=h.__epoch,C=h.__rowDataRef,m=h.children.length,R=w===o&&m===a,T=C!==p;let v=!1;if(R&&T){for(let A=0;A<a;A++)if(l[A].externalView&&!h.querySelector(`.cell[data-col="${A}"] [data-external-view]`)){v=!0;break}}if(!R||v){const A=ae(h),x=t._activeEditRows===g;A&&!x?(h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),ce(h),G(t,h,p,g),h.__epoch=o,h.__rowDataRef=p):A&&x?(de(t,h,p,g),h.__rowDataRef=p):(h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),G(t,h,p,g),h.__epoch=o,h.__rowDataRef=p)}else if(T){const A=ae(h),x=t._activeEditRows===g;A&&!x?(ce(h),G(t,h,p,g),h.__epoch=o,h.__rowDataRef=p):(de(t,h,p,g),h.__rowDataRef=p)}else{const A=ae(h),x=t._activeEditRows===g;A&&!x?(ce(h),G(t,h,p,g),h.__epoch=o,h.__rowDataRef=p):de(t,h,p,g)}let S=!1;const E=t.changedRowIds;if(E&&E.length>0)try{const A=t.getRowId?.(p);A&&(S=E.includes(A))}catch{}const b=h.classList.contains("changed");S!==b&&h.classList.toggle("changed",S);const I=t.effectiveConfig?.rowClass;if(I){const A=h.getAttribute("data-dynamic-classes");A&&A.split(" ").forEach(x=>x&&h.classList.remove(x));try{const x=I(p);if(x&&x.length>0){const Ee=x.filter(re=>re&&typeof re=="string");Ee.forEach(re=>h.classList.add(re)),h.setAttribute("data-dynamic-classes",Ee.join(" "))}else h.removeAttribute("data-dynamic-classes")}catch(x){console.warn("[tbw-grid] rowClass callback error:",x),h.removeAttribute("data-dynamic-classes")}}f&&t._afterRowRender?.({row:p,rowIndex:g,rowElement:h}),h.parentNode!==s&&s.appendChild(h)}}function de(t,e,i,o){const n=e.children,r=t._visibleColumns,s=r.length,l=n.length,a=s<l?s:l,c=t._focusRow,d=t._focusCol,f=t._hasAfterCellRenderHook?.()??!1;let u=t.__hasSpecialColumns;if(u===void 0){u=!1;const p=t.__frameworkAdapter;for(let h=0;h<s;h++){const w=r[h];if(w.__viewTemplate||w.__compiledView||w.renderer||w.viewRenderer||w.externalView||w.format||w.type==="date"||w.type==="boolean"||w.type&&p?.getTypeDefault?.(w.type)?.renderer||w.type&&p?.getTypeDefault?.(w.type)?.format){u=!0;break}}t.__hasSpecialColumns=u}const g=String(o);if(!u){for(let p=0;p<a;p++){const h=n[p];if(h.classList.contains("editing"))continue;const w=r[p],C=i[w.field];h.textContent=C==null?"":String(C),h.getAttribute("data-row")!==g&&h.setAttribute("data-row",g);const m=c===o&&d===p,_=h.classList.contains("cell-focus");m!==_&&(h.classList.toggle("cell-focus",m),h.setAttribute("aria-selected",String(m))),f&&t._afterCellRender?.({row:i,rowIndex:o,column:w,colIndex:p,value:C,cellElement:h,rowElement:e})}return}for(let p=0;p<a;p++)if(r[p].externalView&&!n[p].querySelector("[data-external-view]")){G(t,e,i,o);return}for(let p=0;p<a;p++){const h=r[p],w=n[p];w.getAttribute("data-row")!==g&&w.setAttribute("data-row",g);const C=c===o&&d===p,m=w.classList.contains("cell-focus");C!==m&&(w.classList.toggle("cell-focus",C),w.setAttribute("aria-selected",String(C)));const _=h.cellClass;if(_){const E=w.getAttribute("data-dynamic-classes");E&&E.split(" ").forEach(b=>b&&w.classList.remove(b));try{const b=i[h.field],I=_(b,i,h);if(I&&I.length>0){const A=I.filter(x=>x&&typeof x=="string");A.forEach(x=>w.classList.add(x)),w.setAttribute("data-dynamic-classes",A.join(" "))}else w.removeAttribute("data-dynamic-classes")}catch(b){console.warn(`[tbw-grid] cellClass callback error for column '${h.field}':`,b),w.removeAttribute("data-dynamic-classes")}}if(w.classList.contains("editing"))continue;const R=ke(t,h);if(R){const E=i[h.field],b=R({row:i,value:E,field:h.field,column:h,cellEl:w});typeof b=="string"?w.innerHTML=W(b):b instanceof Node?b.parentElement!==w&&(w.innerHTML="",w.appendChild(b)):b==null&&(w.textContent=E==null?"":String(E)),f&&t._afterCellRender?.({row:i,rowIndex:o,column:h,colIndex:p,value:E,cellElement:w,rowElement:e});continue}if(h.__viewTemplate||h.__compiledView||h.externalView)continue;const T=i[h.field];let v;const S=Ie(t,h);if(S){try{const E=S(T,i);v=E==null?"":String(E)}catch(E){console.warn(`[tbw-grid] Format error in column '${h.field}':`,E),v=T==null?"":String(T)}w.textContent=v}else h.type==="date"?(v=De(T),w.textContent=v):h.type==="boolean"?w.innerHTML=ze(!!T):(v=T==null?"":String(T),w.textContent=v);f&&t._afterCellRender?.({row:i,rowIndex:o,column:h,colIndex:p,value:T,cellElement:w,rowElement:e})}}function G(t,e,i,o){e.innerHTML="";const n=t._visibleColumns,r=n.length,s=t._focusRow,l=t._focusCol,a=t,c=t._hasAfterCellRenderHook?.()??!1,d=document.createDocumentFragment();for(let f=0;f<r;f++){const u=n[f],g=Ot();g.setAttribute("aria-colindex",String(f+1)),g.setAttribute("data-col",String(f)),g.setAttribute("data-row",String(o)),g.setAttribute("data-field",u.field),g.setAttribute("data-header",u.header??u.field),u.type&&g.setAttribute("data-type",u.type);let p=i[u.field];const h=Ie(t,u);if(h)try{p=h(p,i)}catch(v){console.warn(`[tbw-grid] Format error in column '${u.field}':`,v)}const w=u.__compiledView,C=u.__viewTemplate,m=ke(t,u),_=u.externalView;let R=!1;if(m){const v=m({row:i,value:p,field:u.field,column:u,cellEl:g});typeof v=="string"?(g.innerHTML=W(v),R=!0):v instanceof Node?v.parentElement!==g&&(g.textContent="",g.appendChild(v)):v==null&&(g.textContent=p==null?"":String(p))}else if(_){const v=_,S=document.createElement("div");S.setAttribute("data-external-view",""),S.setAttribute("data-field",u.field),g.appendChild(S);const E={row:i,value:p,field:u.field,column:u};if(v.mount)try{v.mount({placeholder:S,context:E,spec:v})}catch(b){console.warn(`[tbw-grid] External view mount error for column '${u.field}':`,b)}else queueMicrotask(()=>{try{a.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:S,spec:v,context:E}}))}catch(b){console.warn(`[tbw-grid] External view event dispatch error for column '${u.field}':`,b)}});S.setAttribute("data-mounted","")}else if(w){const v=w({row:i,value:p,field:u.field,column:u}),S=w.__blocked;g.innerHTML=S?"":W(v),R=!0,S&&(g.textContent="",g.setAttribute("data-blocked-template",""))}else if(C){const v=C.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(v)?(g.textContent="",g.setAttribute("data-blocked-template","")):(g.innerHTML=W(Le(v,{row:i,value:p})),R=!0)}else h?g.textContent=p==null?"":String(p):u.type==="date"?g.textContent=De(p):u.type==="boolean"?g.innerHTML=ze(!!p):g.textContent=p==null?"":String(p);if(R){Ht(g);const v=g.textContent||"";/Proxy|Reflect\.ownKeys/.test(v)&&(g.textContent=v.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(g.textContent||"")&&(g.textContent=""))}g.hasAttribute("data-blocked-template")&&(g.textContent||"").trim().length&&(g.textContent=""),u.editable?g.tabIndex=0:u.type==="boolean"&&(g.hasAttribute("tabindex")||(g.tabIndex=0)),s===o&&l===f?(g.classList.add("cell-focus"),g.setAttribute("aria-selected","true")):g.setAttribute("aria-selected","false");const T=u.cellClass;if(T)try{const v=i[u.field],S=T(v,i,u);if(S&&S.length>0){const E=S.filter(b=>b&&typeof b=="string");E.forEach(b=>g.classList.add(b)),g.setAttribute("data-dynamic-classes",E.join(" "))}}catch(v){console.warn(`[tbw-grid] cellClass callback error for column '${u.field}':`,v)}c&&t._afterCellRender?.({row:i,rowIndex:o,column:u,colIndex:f,value:p,cellElement:g,rowElement:e}),d.appendChild(g)}e.appendChild(d)}function We(t,e,i){if(e.target?.closest(".resize-handle"))return;const o=i.querySelector(".cell[data-row]"),n=Oe(o);if(n<0)return;const r=t._rows[n];if(!r||t._dispatchRowClick?.(e,n,r,i))return;const s=e.target?.closest(".cell[data-col]");if(s){const l=Number(s.getAttribute("data-col"));if(!isNaN(l)){if(t._dispatchCellClick?.(e,n,l,s))return;const a=t._focusRow!==n||t._focusCol!==l;if(t._focusRow=n,t._focusCol=l,s.classList.contains("editing")){a&&(le(t._bodyEl??t),s.classList.add("cell-focus"));const c=s.querySelector(Ne);try{c?.focus({preventScroll:!0})}catch{}return}F(t)}}}function It(t,e){if(t._dispatchKeyDown?.(e))return;const i=t._rows.length-1,o=t._visibleColumns.length-1,n=t._activeEditRows!==void 0&&t._activeEditRows!==-1,s=t._visibleColumns[t._focusCol]?.type,l=e.composedPath?.()??[],a=l.length?l[0]:e.target,c=d=>{if(!d)return!1;const f=d.tagName;return!!(f==="INPUT"||f==="SELECT"||f==="TEXTAREA"||d.isContentEditable)};if(!(c(a)&&(e.key==="Home"||e.key==="End"))&&!(c(a)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&a.tagName==="INPUT"&&a.type==="number")&&!(c(a)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(c(a)&&(e.key==="Enter"||e.key==="Escape"))&&!(n&&s==="select"&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{e.preventDefault(),!e.shiftKey?t._focusCol<o?t._focusCol+=1:(typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow<i&&(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=o),F(t);return}case"ArrowDown":n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.min(i,t._focusRow+1),e.preventDefault();break;case"ArrowUp":n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault();break;case"ArrowRight":{Me(t)?t._focusCol=Math.max(0,t._focusCol-1):t._focusCol=Math.min(o,t._focusCol+1),e.preventDefault();break}case"ArrowLeft":{Me(t)?t._focusCol=Math.min(o,t._focusCol+1):t._focusCol=Math.max(0,t._focusCol-1),e.preventDefault();break}case"Home":(e.ctrlKey||e.metaKey)&&(n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=0),t._focusCol=0,e.preventDefault(),F(t,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=i),t._focusCol=o,e.preventDefault(),F(t,{forceScrollRight:!0});return;case"PageDown":t._focusRow=Math.min(i,t._focusRow+20),e.preventDefault();break;case"PageUp":t._focusRow=Math.max(0,t._focusRow-20),e.preventDefault();break;case"Enter":{const d=t._focusRow,f=t._focusCol,u=t._visibleColumns[f],g=t._rows[d],p=u?.field??"",h=p&&g?g[p]:void 0,w=t.querySelector(`[data-row="${d}"][data-col="${f}"]`),C={rowIndex:d,colIndex:f,field:p,value:h,row:g,cellEl:w,trigger:"keyboard",originalEvent:e},m=new CustomEvent("cell-activate",{cancelable:!0,detail:C});t.dispatchEvent(m);const _=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:d,col:f}});if(t.dispatchEvent(_),m.defaultPrevented||_.defaultPrevented){e.preventDefault();return}break}default:return}F(t)}}function F(t,e){if(t._virtualization?.enabled){const{rowHeight:s,container:l,viewportEl:a}=t._virtualization,c=l,d=a?.clientHeight??c?.clientHeight??0;if(c&&d>0){const f=t._focusRow*s;f<c.scrollTop?c.scrollTop=f:f+s>c.scrollTop+d&&(c.scrollTop=f-d+s)}}const i=t._activeEditRows!==void 0&&t._activeEditRows!==-1;i||t.refreshVirtualWindow(!1),le(t._bodyEl),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(s=>{s.setAttribute("aria-selected","false")});const o=t._focusRow,n=t._virtualization.start??0,r=t._virtualization.end??t._rows.length;if(o>=n&&o<r){const s=t._bodyEl.querySelectorAll(".data-grid-row")[o-n];let l=s?.children[t._focusCol];if((!l||!l.classList?.contains("cell"))&&(l=s?.querySelector(`.cell[data-col="${t._focusCol}"]`)??s?.querySelector(".cell[data-col]")),l){l.classList.add("cell-focus"),l.setAttribute("aria-selected","true");const a=t.querySelector(".tbw-scroll-area");if(a&&l&&(!i||e?.forceHorizontalScroll))if(e?.forceScrollLeft)a.scrollLeft=0;else if(e?.forceScrollRight)a.scrollLeft=a.scrollWidth-a.clientWidth;else{const c=t._getHorizontalScrollOffsets?.(s??void 0,l)??{left:0,right:0};if(!c.skipScroll){const d=l.getBoundingClientRect(),f=a.getBoundingClientRect(),u=d.left-f.left+a.scrollLeft,g=u+d.width,p=a.scrollLeft+c.left,h=a.scrollLeft+a.clientWidth-c.right;u<p?a.scrollLeft=u-c.left:g>h&&(a.scrollLeft=g-a.clientWidth+c.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&l.classList.contains("editing")){const c=l.querySelector(Ne);if(c&&document.activeElement!==c)try{c.focus({preventScroll:!0})}catch{}}else if(!l.contains(document.activeElement)){l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{}}}}}const Q=new WeakMap;function Nt(t,e){const i=Oe(e),o=zt(e);i<0||o<0||(t._focusRow=i,t._focusCol=o,le(t._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function he(t,e,i,o){let n=null;const r=i.composedPath?.();if(r&&r.length>0?n=r[0]:n=i.target,n&&!e.contains(n)){const h=document.elementFromPoint(i.clientX,i.clientY);h&&(n=h)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),a=n?.closest?.(".header-row");let c,d,f,u,g,p;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(f=t._rows[c],p=t._columns[d],u=p?.field,g=f&&u?f[u]:void 0)),{type:o,row:f,rowIndex:c!==void 0&&c>=0?c:void 0,colIndex:d!==void 0&&d>=0?d:void 0,field:u,value:g,column:p,originalEvent:i,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:c!==void 0&&d!==void 0&&c>=0&&d>=0?{row:c,col:d}:void 0}}function qt(t,e,i){const o=he(t,e,i,"mousedown");(t._dispatchCellMouseDown?.(o)??!1)&&Q.set(t,!0)}function $t(t,e,i){if(!Q.get(t))return;const o=he(t,e,i,"mousemove");t._dispatchCellMouseMove?.(o)}function Wt(t,e,i){if(!Q.get(t))return;const o=he(t,e,i,"mouseup");t._dispatchCellMouseUp?.(o),Q.set(t,!1)}function Ft(t,e,i){e.addEventListener("mousedown",o=>{const n=o.target.closest(".cell[data-col]");n&&(n.classList.contains("editing")||Nt(t,n))},{signal:i}),e.addEventListener("click",o=>{const n=o.target.closest(".data-grid-row");n&&We(t,o,n)},{signal:i}),e.addEventListener("dblclick",o=>{const n=o.target.closest(".data-grid-row");n&&We(t,o,n)},{signal:i})}function Ut(t,e,i,o){e.addEventListener("keydown",n=>It(t,n),{signal:o}),i.addEventListener("mousedown",n=>qt(t,i,n),{signal:o}),document.addEventListener("mousemove",n=>$t(t,i,n),{signal:o}),document.addEventListener("mouseup",n=>Wt(t,i,n),{signal:o})}function Fe(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function Ue(t,e,i){const n=i.find(l=>l.field===e.field)?.sortComparator??Fe,{field:r,direction:s}=e;return[...t].sort((l,a)=>n(l[r],a[r],l,a)*s)}function Ve(t,e,i,o){t._rows=e,t.__rowRenderEpoch++,t._rowPool.forEach(n=>n.__epoch=-1),ie(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:i.field,direction:o}})),t.requestStateChange?.()}function Ge(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),Be(t,e,1)):t._sortState.direction===1?Be(t,e,-1):(t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(o=>o.__epoch=-1),t._rows=t.__originalOrder.slice(),ie(t),t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(o=>{o.getAttribute("aria-sort")?(o.getAttribute("aria-sort")==="ascending"||o.getAttribute("aria-sort")==="descending")&&(t._sortState||o.setAttribute("aria-sort","none")):o.setAttribute("aria-sort","none")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),t.requestStateChange?.())}function Be(t,e,i){t._sortState={field:e.field,direction:i};const o={field:e.field,direction:i},n=t._columns,s=(t.effectiveConfig?.sortHandler??Ue)(t._rows,o,n);s&&typeof s.then=="function"?s.then(l=>{Ve(t,l,e,i)}):Ve(t,s,e,i)}function B(t,e){return t.effectiveConfig?.sortable!==!1&&e.sortable===!0}function Z(t,e){return t.effectiveConfig?.resizable!==!1&&e.resizable!==!1}function Vt(t,e){typeof e=="string"?t.textContent=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}function J(t,e){const i=document.createElement("span");Te(i,"sort-indicator");const o=t._sortState?.field===e.field?t._sortState.direction:0,n={...M,...t.icons},r=o===1?n.sortAsc:o===-1?n.sortDesc:n.sortNone;return Vt(i,r),i}function ee(t,e,i){const o=document.createElement("div");return o.className="resize-handle",o.setAttribute("aria-hidden","true"),o.addEventListener("mousedown",n=>{n.stopPropagation(),n.preventDefault(),t._resizeController.start(n,e,i)}),o.addEventListener("dblclick",n=>{n.stopPropagation(),n.preventDefault(),t._resizeController.resetColumn(e)}),o}function te(t,e,i,o){o.classList.add("sortable"),o.tabIndex=0;const n=t._sortState?.field===e.field?t._sortState.direction:0;o.setAttribute("aria-sort",n===0?"none":n===1?"ascending":"descending"),o.addEventListener("click",r=>{t._resizeController?.isResizing||t._dispatchHeaderClick?.(r,i,o)||Ge(t,e)}),o.addEventListener("keydown",r=>{if(r.key==="Enter"||r.key===" "){if(r.preventDefault(),t._dispatchHeaderClick?.(r,i,o))return;Ge(t,e)}})}function Gt(t,e){if(e!=null)if(typeof e=="string"){const i=document.createElement("span");for(i.innerHTML=W(e);i.firstChild;)t.appendChild(i.firstChild)}else e instanceof Node&&t.appendChild(e)}function ie(t){t._headerRowEl=t.findHeaderRow();const e=t._headerRowEl;e&&(e.innerHTML="",t._visibleColumns.forEach((i,o)=>{const n=document.createElement("div");n.className="cell",Te(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(o+1)),n.setAttribute("data-field",i.field),n.setAttribute("data-col",String(o));const r=i.header??i.field,s=t._sortState?.field===i.field?t._sortState.direction:0,l=s===1?"asc":s===-1?"desc":null;if(i.headerRenderer){const a={column:i,value:r,sortState:l,filterActive:!1,cellEl:n,renderSortIcon:()=>B(t,i)?J(t,i):null,renderFilterButton:()=>null},c=i.headerRenderer(a);Gt(n,c),B(t,i)&&te(t,i,o,n),Z(t,i)&&(n.classList.add("resizable"),n.appendChild(ee(t,o,n)))}else if(i.headerLabelRenderer){const a={column:i,value:r},c=i.headerLabelRenderer(a),d=document.createElement("span");c==null?d.textContent=r:typeof c=="string"?d.innerHTML=W(c):c instanceof Node&&d.appendChild(c),n.appendChild(d),B(t,i)&&(te(t,i,o,n),n.appendChild(J(t,i))),Z(t,i)&&(n.classList.add("resizable"),n.appendChild(ee(t,o,n)))}else if(i.__headerTemplate)Array.from(i.__headerTemplate.childNodes).forEach(a=>n.appendChild(a.cloneNode(!0))),B(t,i)&&(te(t,i,o,n),n.appendChild(J(t,i))),Z(t,i)&&(n.classList.add("resizable"),n.appendChild(ee(t,o,n)));else{const a=document.createElement("span");a.textContent=r,n.appendChild(a),B(t,i)&&(te(t,i,o,n),n.appendChild(J(t,i))),Z(t,i)&&(n.classList.add("resizable"),n.appendChild(ee(t,o,n)))}e.appendChild(n)}),e.querySelectorAll(".cell.sortable").forEach(i=>{i.getAttribute("aria-sort")||i.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex")))}const Xe=typeof requestIdleCallback=="function";function Bt(t,e){return Xe?requestIdleCallback(t,e):window.setTimeout(()=>{const i=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-i))})},1)}function Ye(t){Xe?cancelIdleCallback(t):clearTimeout(t)}function Xt(t){const e=document.createElement("div");return e.className=`tbw-spinner tbw-spinner--${t}`,e.setAttribute("role","progressbar"),e.setAttribute("aria-label","Loading"),e}function Yt(t,e){if(e){const o=e({size:t});if(typeof o=="string"){const n=document.createElement("div");return n.innerHTML=o,n}return o}return Xt(t)}function jt(t){const e=document.createElement("div");return e.className="tbw-loading-overlay",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.appendChild(Yt("large",t)),e}function Kt(t,e){t.appendChild(e)}function Qt(t){t?.remove()}function Zt(t,e){e?(t.classList.add("tbw-row-loading"),t.setAttribute("aria-busy","true")):(t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy"))}function Jt(t,e){e?(t.classList.add("tbw-cell-loading"),t.setAttribute("aria-busy","true")):(t.classList.remove("tbw-cell-loading"),t.removeAttribute("aria-busy"))}var H=(t=>(t[t.STYLE=1]="STYLE",t[t.VIRTUALIZATION=2]="VIRTUALIZATION",t[t.HEADER=3]="HEADER",t[t.ROWS=4]="ROWS",t[t.COLUMNS=5]="COLUMNS",t[t.FULL=6]="FULL",t))(H||{});class ei{#l;#n=0;#u=0;#d=null;#h=null;#a=null;#o=!1;constructor(e){this.#l=e}requestPhase(e,i){e>this.#n&&(this.#n=e),this.#u===0&&(this.#f(),this.#u=requestAnimationFrame(()=>this.#w()))}whenReady(){return this.#d?this.#d:Promise.resolve()}setInitialReadyResolver(e){this.#a=e}cancel(){this.#u!==0&&(cancelAnimationFrame(this.#u),this.#u=0),this.#n=0,this.#h&&(this.#h(),this.#h=null,this.#d=null)}get isPending(){return this.#n!==0}get pendingPhase(){return this.#n}#f(){this.#d||(this.#d=new Promise(e=>{this.#h=e}))}#w(){if(this.#u=0,!this.#l.isConnected()){this.#n=0,this.#h&&(this.#h(),this.#h=null,this.#d=null);return}const e=this.#n;this.#n=0,e>=5&&this.#l.mergeConfig(),e>=4&&this.#l.processRows(),e>=5&&(this.#l.processColumns(),this.#l.updateTemplate()),e>=3&&this.#l.renderHeader(),e>=2&&this.#l.renderVirtualWindow(),e>=1&&this.#l.afterRender(),!this.#o&&this.#a&&(this.#o=!0,this.#a()),this.#h&&(this.#h(),this.#h=null,this.#d=null)}}function je(t){let e=null,i=null,o=null,n=null;const r=a=>{if(!e)return;const c=a.clientX-e.startX,d=Math.max(40,e.startWidth+c),f=t._visibleColumns[e.colIndex];f.width=d,f.__userResized=!0,f.__renderedWidth=d,i==null&&(i=requestAnimationFrame(()=>{i=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:f.field,width:d}}))};let s=!1;const l=()=>{const a=e!==null;a&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),o!==null&&(document.documentElement.style.cursor=o,o=null),n!==null&&(document.body.style.userSelect=n,n=null),e=null,a&&t.requestStateChange&&t.requestStateChange()};return{get isResizing(){return e!==null||s},start(a,c,d){a.preventDefault();const f=t._visibleColumns[c],u=typeof f?.width=="number"?f.width:void 0,g=f?.__renderedWidth??u??d.getBoundingClientRect().width;e={startX:a.clientX,colIndex:c,startWidth:g},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),o===null&&(o=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",n===null&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(a){const c=t._visibleColumns[a];c&&(c.__userResized=!1,c.__renderedWidth=void 0,c.width=c.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:c.field,width:c.width}})))},dispose(){l()}}}const ue="data-animating",ti={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},ii={change:500,insert:300,remove:200};function oi(t){const e=t.trim().toLowerCase();return e.endsWith("ms")?parseFloat(e):e.endsWith("s")?parseFloat(e)*1e3:parseFloat(e)}function ni(t,e){const i=ti[e],o=getComputedStyle(t).getPropertyValue(i);if(o){const n=oi(o);if(!isNaN(n)&&n>0)return n}return ii[e]}function ri(t,e,i){t.removeAttribute(ue),t.offsetWidth,t.setAttribute(ue,e);const o=ni(t,e);setTimeout(()=>{e!=="remove"&&t.removeAttribute(ue)},o)}function fe(t,e,i){if(e<0)return!1;const o=t.findRenderedRowElement?.(e);return o?(ri(o,i),!0):!1}function si(t,e,i){let o=0;for(const n of e)fe(t,n,i)&&o++;return o}function li(t,e,i){const o=t._rows??[],n=t.getRowId;if(!n)return!1;const r=o.findIndex(s=>n(s)===e);return r<0?!1:fe(t,r,i)}function oe(t,e,i){const o=document.createElement(t);if(e)for(const n in e){const r=e[n];r!=null&&o.setAttribute(n,r)}return o}function P(t,e){const i=document.createElement("div");if(t&&(i.className=t),e)for(const o in e){const n=e[o];n!=null&&i.setAttribute(o,n)}return i}function Ke(t,e,i){const o=document.createElement("button");if(t&&(o.className=t),e)for(const n in e){const r=e[n];r!=null&&o.setAttribute(n,r)}return o}const Qe=document.createElement("template");Qe.innerHTML=`
|
|
1
|
+
(function(y,U){typeof exports=="object"&&typeof module<"u"?U(exports):typeof define=="function"&&define.amd?define(["exports"],U):(y=typeof globalThis<"u"?globalThis:y||self,U(y.TbwGrid={}))})(this,(function(y){"use strict";function U(){return{rowCount:-1,colCount:-1,ariaLabel:void 0,ariaDescribedBy:void 0}}function ft(t,e,i,o,n){if(o===t.rowCount&&n===t.colCount)return!1;const r=t.rowCount;return t.rowCount=o,t.colCount=n,e&&(e.setAttribute("aria-rowcount",String(o)),e.setAttribute("aria-colcount",String(n))),o!==r&&i&&(o>0?i.setAttribute("role","rowgroup"):i.removeAttribute("role")),!0}function gt(t,e){const i=t?.gridAriaLabel;return i||(t?.shell?.header?.title??e?.lightDomTitle??void 0)}function pt(t,e,i,o){if(!e)return!1;let n=!1;const r=gt(i,o);r!==t.ariaLabel&&(t.ariaLabel=r,r?e.setAttribute("aria-label",r):e.removeAttribute("aria-label"),n=!0);const s=i?.gridAriaDescribedBy;return s!==t.ariaDescribedBy&&(t.ariaDescribedBy=s,s?e.setAttribute("aria-describedby",s):e.removeAttribute("aria-describedby"),n=!0),n}const $={STRETCH:"stretch",FIXED:"fixed"},Se={mode:"reduced-motion",duration:200,easing:"ease-out"},Re='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',M={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:Re,filterActive:Re,print:"🖨️"};function wt(t){return Array.from(t.querySelectorAll("tbw-grid-column")).map(i=>{const o=i.getAttribute("field")||"";if(!o)return null;const n=i.getAttribute("type")||void 0,s=n&&new Set(["number","string","date","boolean","select"]).has(n)?n:void 0,l=i.getAttribute("header")||void 0,a=i.hasAttribute("sortable"),c=i.hasAttribute("editable"),d={field:o,type:s,header:l,sortable:a,editable:c},f=i.getAttribute("width");if(f){const b=parseFloat(f);!isNaN(b)&&/^\d+(\.\d+)?$/.test(f.trim())?d.width=b:d.width=f}const u=i.getAttribute("minWidth")||i.getAttribute("min-width");if(u){const b=parseFloat(u);isNaN(b)||(d.minWidth=b)}i.hasAttribute("resizable")&&(d.resizable=!0),i.hasAttribute("sizable")&&(d.resizable=!0);const g=i.getAttribute("editor"),p=i.getAttribute("renderer");g&&(d.__editorName=g),p&&(d.__rendererName=p);const h=i.getAttribute("options");h&&(d.options=h.split(",").map(b=>{const[I,A]=b.includes(":")?b.split(":"):[b.trim(),b.trim()];return{value:I.trim(),label:A?.trim()||I.trim()}}));const w=i.querySelector("tbw-grid-column-view"),C=i.querySelector("tbw-grid-column-editor"),m=i.querySelector("tbw-grid-column-header");w&&(d.__viewTemplate=w),C&&(d.__editorTemplate=C),m&&(d.__headerTemplate=m);const R=globalThis.DataGridElement?.getAdapters?.()??[],T=w??i,v=R.find(b=>b.canHandle(T));if(v){const b=v.createRenderer(T);b&&(d.viewRenderer=b)}const S=C??i,E=R.find(b=>b.canHandle(S));if(E){const b=E.createEditor(S);b&&(d.editor=b)}return d}).filter(i=>!!i)}function Ae(t,e){if((!t||!t.length)&&(!e||!e.length))return[];if(!t||!t.length)return e||[];if(!e||!e.length)return t;const i={};e.forEach(n=>{const r=i[n.field];if(r){n.header&&!r.header&&(r.header=n.header),n.type&&!r.type&&(r.type=n.type),n.sortable&&(r.sortable=!0),n.editable&&(r.editable=!0),n.resizable&&(r.resizable=!0),n.width!=null&&r.width==null&&(r.width=n.width),n.minWidth!=null&&r.minWidth==null&&(r.minWidth=n.minWidth),n.__viewTemplate&&(r.__viewTemplate=n.__viewTemplate),n.__editorTemplate&&(r.__editorTemplate=n.__editorTemplate),n.__headerTemplate&&(r.__headerTemplate=n.__headerTemplate);const s=n.renderer||n.viewRenderer,l=r.renderer||r.viewRenderer;s&&!l&&(r.viewRenderer=s,n.renderer&&(r.renderer=s)),n.editor&&!r.editor&&(r.editor=n.editor)}else i[n.field]={...n}});const o=t.map(n=>{const r=i[n.field];if(!r)return n;const s={...n};r.header&&!s.header&&(s.header=r.header),r.type&&!s.type&&(s.type=r.type),s.sortable=n.sortable||r.sortable,(n.resizable===!0||r.resizable===!0)&&(s.resizable=!0),s.editable=n.editable||r.editable,r.width!=null&&s.width==null&&(s.width=r.width),r.minWidth!=null&&s.minWidth==null&&(s.minWidth=r.minWidth),r.__viewTemplate&&(s.__viewTemplate=r.__viewTemplate),r.__editorTemplate&&(s.__editorTemplate=r.__editorTemplate),r.__headerTemplate&&(s.__headerTemplate=r.__headerTemplate);const l=r.renderer||r.viewRenderer,a=s.renderer||s.viewRenderer;return l&&!a&&(s.viewRenderer=l,r.renderer&&(s.renderer=l)),r.editor&&!s.editor&&(s.editor=r.editor),delete i[n.field],s});return Object.keys(i).forEach(n=>o.push(i[n])),o}function Te(t,e){try{t.part?.add?.(e)}catch{}const i=t.getAttribute("part");i?i.split(/\s+/).includes(e)||t.setAttribute("part",i+" "+e):t.setAttribute("part",e)}function xe(t){const e=t.effectiveConfig?.fitMode||t.fitMode||$.STRETCH;if(e!==$.STRETCH&&e!==$.FIXED||t.__didInitialAutoSize||!t.isConnected)return;const i=Array.from(t._headerRowEl?.children||[]);if(!i.length)return;let o=!1;t._visibleColumns.forEach((n,r)=>{if(n.width)return;const s=i[r];let l=s?s.scrollWidth:0;for(const a of t._rowPool){const c=a.children[r];if(c){const d=c.scrollWidth;d>l&&(l=d)}}l>0&&(n.width=l+2,n.__autoSized=!0,o=!0)}),o&&V(t),t.__didInitialAutoSize=!0}function V(t){(t.effectiveConfig?.fitMode||t.fitMode||$.STRETCH)===$.STRETCH?t._gridTemplate=t._visibleColumns.map(i=>{if(i.width)return`${i.width}px`;const o=i.minWidth;return o!=null?`minmax(${o}px, 1fr)`:"1fr"}).join(" ").trim():t._gridTemplate=t._visibleColumns.map(i=>i.width?`${i.width}px`:"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}function bt(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 mt(t,e){const i=t[0]||{},o=Object.keys(i).map(r=>{const s=i[r],l=bt(s);return{field:r,header:r.charAt(0).toUpperCase()+r.slice(1),type:l}}),n={};return o.forEach(r=>{n[r.field]=r.type||"string"}),{columns:o,typeMap:n}}const vt=/{{\s*([^}]+)\s*}}/g,z="__DG_EMPTY__",Ct=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,yt=/__(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/;function _t(t){return!t||typeof t!="string"?"":t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Et=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"]),He=/^on\w+$/i,St=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),Rt=/^\s*(javascript|vbscript|data|blob):/i;function W(t){if(!t||typeof t!="string")return"";if(t.indexOf("<")===-1)return t;const e=document.createElement("template");return e.innerHTML=t,At(e.content),e.innerHTML}function At(t){const e=[],i=t.querySelectorAll("*");for(const o of i){const n=o.tagName.toLowerCase();if(Et.has(n)){e.push(o);continue}if((n==="svg"||o.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(o.attributes).some(l=>He.test(l.name)||l.name==="href"||l.name==="xlink:href")){e.push(o);continue}const r=[];for(const s of o.attributes){const l=s.name.toLowerCase();if(He.test(l)){r.push(s.name);continue}if(St.has(l)&&Rt.test(s.value)){r.push(s.name);continue}if(l==="style"&&/expression\s*\(|javascript:|behavior\s*:/i.test(s.value)){r.push(s.name);continue}}r.forEach(s=>o.removeAttribute(s))}e.forEach(o=>o.remove())}function Le(t,e){if(!t||t.indexOf("{{")===-1)return t;const i=[],o=t.replace(vt,(l,a)=>{const c=Tt(a,e);return i.push({expr:a.trim(),result:c}),c}),n=xt(o),r=i.length&&i.every(l=>l.result===""||l.result===z);return N.test(t)||r?"":n}function Tt(t,e){if(t=(t||"").trim(),!t||N.test(t))return z;if(t==="value")return e.value==null?z:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const o=t.slice(4),n=e.row?e.row[o]:void 0;return n==null?z:String(n)}if(t.length>80||!Ct.test(t)||yt.test(t))return z;const i=t.match(/\./g);if(i&&i.length>1)return z;try{const n=new Function("value","row",`return (${t});`)(e.value,e.row),r=n==null?"":String(n);return N.test(r)?z:r||z}catch{return z}}const N=/Reflect|Proxy|ownKeys/;function xt(t){return t&&t.replace(new RegExp(z,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,"")}function Ht(t){if(N.test(t.textContent||"")){for(const e of t.childNodes)e.nodeType===Node.TEXT_NODE&&N.test(e.textContent||"")&&(e.textContent="");N.test(t.textContent||"")&&(t.textContent="")}}function Pe(t){const e=N.test(t),i=(o=>e?"":Le(t,o));return i.__blocked=e,i}const Lt=100;class Pt{#l;#n;#u;#d;#h;#a={};#o={};#f=!0;#w=[];#v;#s;#C;#r;#g;constructor(e){this.#r=e}get original(){return this.#a}get effective(){return this.#o}get columns(){return this.#o.columns??[]}set columns(e){this.#o.columns=e}get lightDomColumnsCache(){return this.#d}set lightDomColumnsCache(e){this.#d=e}get originalColumnNodes(){return this.#h}set originalColumnNodes(e){this.#h=e}get lightDomTitle(){return this.#g}set lightDomTitle(e){this.#g=e}get initialColumnState(){return this.#C}set initialColumnState(e){this.#C=e}get sourcesChanged(){return this.#f}markSourcesChanged(){this.#f=!0}setGridConfig(e){this.#l=e,this.#f=!0,this.#d=void 0}getGridConfig(){return this.#l}setColumns(e){this.#n=e,this.#f=!0}getColumns(){return this.#n}setFitMode(e){this.#u=e,this.#f=!0}getFitMode(){return this.#u}merge(){const e=(this.#o.columns?.length??0)>0;if(!this.#f&&e)return;const i=this.#k();this.#f=!1,this.#a=i,Object.freeze(this.#a),this.#a.columns&&Object.freeze(this.#a.columns),this.#o=this.#T(this.#a),this.#m()}#T(e){const i={...e};return e.columns&&(i.columns=e.columns.map(o=>({...o}))),e.shell&&(i.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(o=>({...o})),headerContents:e.shell.headerContents?.map(o=>({...o}))}),i}#m(){const e=this.#o;this.#z(),typeof e.rowHeight=="number"&&e.rowHeight>0&&this.#r.setRowHeight(e.rowHeight),e.fitMode==="fixed"&&this.columns.forEach(o=>{o.width==null&&(o.width=80)}),this.#r.applyAnimationConfig(e)}#z(){const e=this.#o.typeDefaults;if(!e)return;const i=this.columns;for(const o of i){if(!o.type)continue;const n=e[o.type];n&&(!o.renderer&&!o.viewRenderer&&n.renderer&&(o.renderer=n.renderer),!o.format&&n.format&&(o.format=n.format),!o.editor&&n.editor&&(o.editor=n.editor),!o.editorParams&&n.editorParams&&(o.editorParams=n.editorParams))}}#k(){const e=this.#l?{...this.#l}:{},i=Array.isArray(e.columns)?[...e.columns]:[],o=(this.#d??[]).map(s=>({...s}));let n=Ae(i,o);this.#n&&this.#n.length&&(n=Ae(this.#n,o));const r=this.#r.getRows();return n.length===0&&r.length&&(n=mt(r).columns),n.length&&(n.forEach(s=>{s.sortable===void 0&&(s.sortable=!0),s.resizable===void 0&&(s.resizable=!0),s.__originalWidth===void 0&&typeof s.width=="number"&&(s.__originalWidth=s.width)}),n.forEach(s=>{s.__viewTemplate&&!s.__compiledView&&(s.__compiledView=Pe(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=Pe(s.__editorTemplate.innerHTML))}),e.columns=n),this.#u&&(e.fitMode=this.#u),e.fitMode||(e.fitMode="stretch"),this.#b(e),e.columnState&&!this.#C&&(this.#C=e.columnState),e}#b(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const i=this.#r.getShellLightDomTitle();i&&(this.#g=i),this.#g&&!e.shell.header.title&&(e.shell.header.title=this.#g);const o=this.#r.getShellLightDomHeaderContent();o?.length>0&&(e.shell.header.lightDomContent=o),this.#r.getShellHasToolButtonsContainer()&&(e.shell.header.hasToolButtonsContainer=!0);const n=this.#r.getShellToolPanels();if(n.size>0){const f=Array.from(n.values());f.sort((u,g)=>(u.order??100)-(g.order??100)),e.shell.toolPanels=f}const r=this.#r.getShellHeaderContents();if(r.size>0){const f=Array.from(r.values());f.sort((u,g)=>(u.order??100)-(g.order??100)),e.shell.headerContents=f}const s=this.#r.getShellToolbarContents(),l=Array.from(s.values()),a=this.#l?.shell?.header?.toolbarContents??[],c=new Set(a.map(f=>f.id)),d=[...a];for(const f of l)c.has(f.id)||d.push(f);d.sort((f,u)=>(f.order??0)-(u.order??0)),e.shell.header.toolbarContents=d}collectState(e){const i=this.columns,o=this.#y();return{columns:i.map((n,r)=>{const s={field:n.field,order:r,visible:!n.hidden},l=n;l.__renderedWidth!==void 0?s.width=l.__renderedWidth:n.width!==void 0&&(s.width=typeof n.width=="string"?parseFloat(n.width):n.width);const a=o.get(n.field);a&&(s.sort=a);for(const c of e)if(c.getColumnState){const d=c.getColumnState(n.field);d&&Object.assign(s,d)}return s})}}applyState(e,i){if(!e.columns||e.columns.length===0)return;const o=this.columns,n=new Map(e.columns.map(l=>[l.field,l])),r=o.map(l=>{const a=n.get(l.field);if(!a)return l;const c={...l};return a.width!==void 0&&(c.width=a.width,c.__renderedWidth=a.width),a.visible!==void 0&&(c.hidden=!a.visible),c});r.sort((l,a)=>{const c=n.get(l.field)?.order??1/0,d=n.get(a.field)?.order??1/0;return c-d}),this.columns=r;const s=e.columns.filter(l=>l.sort!==void 0).sort((l,a)=>(l.sort?.priority??0)-(a.sort?.priority??0));if(s.length>0){const l=s[0];l.sort&&this.#r.setSortState({field:l.field,direction:l.sort.direction==="asc"?1:-1})}else this.#r.setSortState(null);for(const l of i)if(l.applyColumnState)for(const a of e.columns)l.applyColumnState(a.field,a)}resetState(e){this.#C=void 0,this.#r.setSortState(null),this.#o=this.#T(this.#a),this.#m();for(const i of e)if(i.applyColumnState)for(const o of this.columns)i.applyColumnState(o.field,{field:o.field,order:0,visible:!0});this.requestStateChange(e)}#y(){const e=new Map,i=this.#r.getSortState();return i&&e.set(i.field,{direction:i.direction===1?"asc":"desc",priority:0}),e}requestStateChange(e){this.#s&&clearTimeout(this.#s),this.#s=setTimeout(()=>{this.#s=void 0;const i=this.collectState(e);this.#r.emit("column-state-change",i)},Lt)}setColumnVisible(e,i){const o=this.columns,n=o.find(s=>s.field===e);return!n||!i&&n.lockVisible||!i&&o.filter(l=>!l.hidden&&l.field!==e).length===0||!!n.hidden===!i?!1:(n.hidden=!i,this.#r.emit("column-visibility",{field:e,visible:i,visibleColumns:o.filter(s=>!s.hidden).map(s=>s.field)}),this.#r.clearRowPool(),this.#r.setup(),!0)}toggleColumnVisibility(e){const i=this.columns.find(o=>o.field===e);return i?this.setColumnVisible(e,!!i.hidden):!1}isColumnVisible(e){const i=this.columns.find(o=>o.field===e);return i?!i.hidden:!1}showAllColumns(){const e=this.columns;e.some(i=>i.hidden)&&(e.forEach(i=>i.hidden=!1),this.#r.emit("column-visibility",{visibleColumns:e.map(i=>i.field)}),this.#r.clearRowPool(),this.#r.setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:e.meta?.utility===!0}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const i=new Map(this.columns.map(n=>[n.field,n])),o=[];for(const n of e){const r=i.get(n);r&&(o.push(r),i.delete(n))}for(const n of i.values())o.push(n);this.columns=o,this.#r.renderHeader(),this.#r.updateTemplate(),this.#r.refreshVirtualWindow()}parseLightDomColumns(e){this.#d||(this.#h=Array.from(e.querySelectorAll("tbw-grid-column")),this.#d=this.#h.length?wt(e):[])}clearLightDomCache(){this.#d=void 0}#p=new Map;registerLightDomHandler(e,i){this.#p.set(e.toLowerCase(),i)}unregisterLightDomHandler(e){this.#p.delete(e.toLowerCase())}observeLightDOM(e){this.#v&&this.#v.disconnect();const i=new Set;let o=null;const n=()=>{o=null;for(const r of i)this.#p.get(r)?.();i.clear()};this.#v=new MutationObserver(r=>{for(const s of r){for(const l of s.addedNodes){if(l.nodeType!==Node.ELEMENT_NODE)continue;const c=l.tagName.toLowerCase();this.#p.has(c)&&i.add(c)}if(s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE){const a=s.target.tagName.toLowerCase();this.#p.has(a)&&i.add(a)}}i.size>0&&!o&&(o=setTimeout(n,0))}),this.#v.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#w.push(e)}notifyChange(){for(const e of this.#w)e()}dispose(){this.#v?.disconnect(),this.#w=[],this.#s&&clearTimeout(this.#s)}}function se(){if(typeof window<"u"&&window.location){const t=window.location.hostname;if(t==="localhost"||t==="127.0.0.1"||t==="::1")return!0}return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function ze(t){return`<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t?"🗹":"☐"}</span>`}function De(t){if(t==null||t==="")return"";if(t instanceof Date)return isNaN(t.getTime())?"":t.toLocaleDateString();if(typeof t=="number"||typeof t=="string"){const e=new Date(t);return isNaN(e.getTime())?"":e.toLocaleDateString()}return""}function Oe(t){if(!t)return-1;const e=t.getAttribute("data-row");if(e)return parseInt(e,10);const i=t.closest(".data-grid-row");if(!i)return-1;const o=i.parentElement;if(!o)return-1;const n=o.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<n.length;r++)if(n[r]===i)return r;return-1}function zt(t){if(!t)return-1;const e=t.getAttribute("data-col");return e?parseInt(e,10):-1}function le(t){t&&t.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function Dt(t){try{if(getComputedStyle(t).direction==="rtl")return"rtl"}catch{}try{if(t.closest?.("[dir]")?.getAttribute("dir")==="rtl")return"rtl"}catch{}return"ltr"}function Me(t){return Dt(t)==="rtl"}function ke(t,e){const i=e.renderer||e.viewRenderer;if(i)return i;if(!e.type)return;const o=t.__frameworkAdapter;if(o?.getTypeDefault){const n=o.getTypeDefault(e.type);if(n?.renderer)return n.renderer}}function Ie(t,e){if(e.format)return e.format;if(!e.type)return;const i=t.__frameworkAdapter;if(i?.getTypeDefault){const o=i.getTypeDefault(e.type);if(o?.format)return o.format}}const Ne='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function ae(t){return(t.__editingCellCount??0)>0}function ce(t){t.__editingCellCount=0,t.removeAttribute("data-has-editing"),t.querySelectorAll(".cell.editing").forEach(i=>i.classList.remove("editing"))}const qe=document.createElement("template");qe.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const $e=document.createElement("template");$e.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function Ot(){return qe.content.firstElementChild.cloneNode(!0)}function Mt(){return $e.content.firstElementChild.cloneNode(!0)}function K(t){t.__cellDisplayCache=void 0,t.__cellCacheEpoch=void 0,t.__hasSpecialColumns=void 0}function kt(t,e,i,o,n){const r=Math.max(0,i-e),s=t._bodyEl,l=t._visibleColumns,a=l.length;let c=t.__cachedHeaderRowCount;for(c===void 0&&(c=t.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=c);t._rowPool.length<r;){const u=Mt();t._rowPool.push(u)}if(t._rowPool.length>r){for(let u=r;u<t._rowPool.length;u++){const g=t._rowPool[u];g.parentNode===s&&g.remove()}t._rowPool.length=r}const d=n&&t.__hasRenderRowPlugins!==!1,f=t._hasAfterRowRenderHook?.()??!1;for(let u=0;u<r;u++){const g=e+u,p=t._rows[g],h=t._rowPool[u];if(h.setAttribute("aria-rowindex",String(g+c+1)),d&&n(p,h,g)){h.__epoch=o,h.__rowDataRef=p,h.parentNode!==s&&s.appendChild(h);continue}const w=h.__epoch,C=h.__rowDataRef,m=h.children.length,R=w===o&&m===a,T=C!==p;let v=!1;if(R&&T){for(let A=0;A<a;A++)if(l[A].externalView&&!h.querySelector(`.cell[data-col="${A}"] [data-external-view]`)){v=!0;break}}if(!R||v){const A=ae(h),x=t._activeEditRows===g;A&&!x?(h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),ce(h),G(t,h,p,g),h.__epoch=o,h.__rowDataRef=p):A&&x?(de(t,h,p,g),h.__rowDataRef=p):(h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),G(t,h,p,g),h.__epoch=o,h.__rowDataRef=p)}else if(T){const A=ae(h),x=t._activeEditRows===g;A&&!x?(ce(h),G(t,h,p,g),h.__epoch=o,h.__rowDataRef=p):(de(t,h,p,g),h.__rowDataRef=p)}else{const A=ae(h),x=t._activeEditRows===g;A&&!x?(ce(h),G(t,h,p,g),h.__epoch=o,h.__rowDataRef=p):de(t,h,p,g)}let S=!1;const E=t.changedRowIds;if(E&&E.length>0)try{const A=t.getRowId?.(p);A&&(S=E.includes(A))}catch{}const b=h.classList.contains("changed");S!==b&&h.classList.toggle("changed",S);const I=t.effectiveConfig?.rowClass;if(I){const A=h.getAttribute("data-dynamic-classes");A&&A.split(" ").forEach(x=>x&&h.classList.remove(x));try{const x=I(p);if(x&&x.length>0){const Ee=x.filter(re=>re&&typeof re=="string");Ee.forEach(re=>h.classList.add(re)),h.setAttribute("data-dynamic-classes",Ee.join(" "))}else h.removeAttribute("data-dynamic-classes")}catch(x){console.warn("[tbw-grid] rowClass callback error:",x),h.removeAttribute("data-dynamic-classes")}}f&&t._afterRowRender?.({row:p,rowIndex:g,rowElement:h}),h.parentNode!==s&&s.appendChild(h)}}function de(t,e,i,o){const n=e.children,r=t._visibleColumns,s=r.length,l=n.length,a=s<l?s:l,c=t._focusRow,d=t._focusCol,f=t._hasAfterCellRenderHook?.()??!1;let u=t.__hasSpecialColumns;if(u===void 0){u=!1;const p=t.__frameworkAdapter;for(let h=0;h<s;h++){const w=r[h];if(w.__viewTemplate||w.__compiledView||w.renderer||w.viewRenderer||w.externalView||w.format||w.type==="date"||w.type==="boolean"||w.type&&p?.getTypeDefault?.(w.type)?.renderer||w.type&&p?.getTypeDefault?.(w.type)?.format){u=!0;break}}t.__hasSpecialColumns=u}const g=String(o);if(!u){for(let p=0;p<a;p++){const h=n[p];if(h.classList.contains("editing"))continue;const w=r[p],C=i[w.field];h.textContent=C==null?"":String(C),h.getAttribute("data-row")!==g&&h.setAttribute("data-row",g);const m=c===o&&d===p,_=h.classList.contains("cell-focus");m!==_&&(h.classList.toggle("cell-focus",m),h.setAttribute("aria-selected",String(m))),f&&t._afterCellRender?.({row:i,rowIndex:o,column:w,colIndex:p,value:C,cellElement:h,rowElement:e})}return}for(let p=0;p<a;p++)if(r[p].externalView&&!n[p].querySelector("[data-external-view]")){G(t,e,i,o);return}for(let p=0;p<a;p++){const h=r[p],w=n[p];w.getAttribute("data-row")!==g&&w.setAttribute("data-row",g);const C=c===o&&d===p,m=w.classList.contains("cell-focus");C!==m&&(w.classList.toggle("cell-focus",C),w.setAttribute("aria-selected",String(C)));const _=h.cellClass;if(_){const E=w.getAttribute("data-dynamic-classes");E&&E.split(" ").forEach(b=>b&&w.classList.remove(b));try{const b=i[h.field],I=_(b,i,h);if(I&&I.length>0){const A=I.filter(x=>x&&typeof x=="string");A.forEach(x=>w.classList.add(x)),w.setAttribute("data-dynamic-classes",A.join(" "))}else w.removeAttribute("data-dynamic-classes")}catch(b){console.warn(`[tbw-grid] cellClass callback error for column '${h.field}':`,b),w.removeAttribute("data-dynamic-classes")}}if(w.classList.contains("editing"))continue;const R=ke(t,h);if(R){const E=i[h.field],b=R({row:i,value:E,field:h.field,column:h,cellEl:w});typeof b=="string"?w.innerHTML=W(b):b instanceof Node?b.parentElement!==w&&(w.innerHTML="",w.appendChild(b)):b==null&&(w.textContent=E==null?"":String(E)),f&&t._afterCellRender?.({row:i,rowIndex:o,column:h,colIndex:p,value:E,cellElement:w,rowElement:e});continue}if(h.__viewTemplate||h.__compiledView||h.externalView)continue;const T=i[h.field];let v;const S=Ie(t,h);if(S){try{const E=S(T,i);v=E==null?"":String(E)}catch(E){console.warn(`[tbw-grid] Format error in column '${h.field}':`,E),v=T==null?"":String(T)}w.textContent=v}else h.type==="date"?(v=De(T),w.textContent=v):h.type==="boolean"?w.innerHTML=ze(!!T):(v=T==null?"":String(T),w.textContent=v);f&&t._afterCellRender?.({row:i,rowIndex:o,column:h,colIndex:p,value:T,cellElement:w,rowElement:e})}}function G(t,e,i,o){e.innerHTML="";const n=t._visibleColumns,r=n.length,s=t._focusRow,l=t._focusCol,a=t,c=t._hasAfterCellRenderHook?.()??!1,d=document.createDocumentFragment();for(let f=0;f<r;f++){const u=n[f],g=Ot();g.setAttribute("aria-colindex",String(f+1)),g.setAttribute("data-col",String(f)),g.setAttribute("data-row",String(o)),g.setAttribute("data-field",u.field),g.setAttribute("data-header",u.header??u.field),u.type&&g.setAttribute("data-type",u.type);let p=i[u.field];const h=Ie(t,u);if(h)try{p=h(p,i)}catch(v){console.warn(`[tbw-grid] Format error in column '${u.field}':`,v)}const w=u.__compiledView,C=u.__viewTemplate,m=ke(t,u),_=u.externalView;let R=!1;if(m){const v=m({row:i,value:p,field:u.field,column:u,cellEl:g});typeof v=="string"?(g.innerHTML=W(v),R=!0):v instanceof Node?v.parentElement!==g&&(g.textContent="",g.appendChild(v)):v==null&&(g.textContent=p==null?"":String(p))}else if(_){const v=_,S=document.createElement("div");S.setAttribute("data-external-view",""),S.setAttribute("data-field",u.field),g.appendChild(S);const E={row:i,value:p,field:u.field,column:u};if(v.mount)try{v.mount({placeholder:S,context:E,spec:v})}catch(b){console.warn(`[tbw-grid] External view mount error for column '${u.field}':`,b)}else queueMicrotask(()=>{try{a.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:S,spec:v,context:E}}))}catch(b){console.warn(`[tbw-grid] External view event dispatch error for column '${u.field}':`,b)}});S.setAttribute("data-mounted","")}else if(w){const v=w({row:i,value:p,field:u.field,column:u}),S=w.__blocked;g.innerHTML=S?"":W(v),R=!0,S&&(g.textContent="",g.setAttribute("data-blocked-template",""))}else if(C){const v=C.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(v)?(g.textContent="",g.setAttribute("data-blocked-template","")):(g.innerHTML=W(Le(v,{row:i,value:p})),R=!0)}else h?g.textContent=p==null?"":String(p):u.type==="date"?g.textContent=De(p):u.type==="boolean"?g.innerHTML=ze(!!p):g.textContent=p==null?"":String(p);if(R){Ht(g);const v=g.textContent||"";/Proxy|Reflect\.ownKeys/.test(v)&&(g.textContent=v.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(g.textContent||"")&&(g.textContent=""))}g.hasAttribute("data-blocked-template")&&(g.textContent||"").trim().length&&(g.textContent=""),u.editable?g.tabIndex=0:u.type==="boolean"&&(g.hasAttribute("tabindex")||(g.tabIndex=0)),s===o&&l===f?(g.classList.add("cell-focus"),g.setAttribute("aria-selected","true")):g.setAttribute("aria-selected","false");const T=u.cellClass;if(T)try{const v=i[u.field],S=T(v,i,u);if(S&&S.length>0){const E=S.filter(b=>b&&typeof b=="string");E.forEach(b=>g.classList.add(b)),g.setAttribute("data-dynamic-classes",E.join(" "))}}catch(v){console.warn(`[tbw-grid] cellClass callback error for column '${u.field}':`,v)}c&&t._afterCellRender?.({row:i,rowIndex:o,column:u,colIndex:f,value:p,cellElement:g,rowElement:e}),d.appendChild(g)}e.appendChild(d)}function We(t,e,i){if(e.target?.closest(".resize-handle"))return;const o=i.querySelector(".cell[data-row]"),n=Oe(o);if(n<0)return;const r=t._rows[n];if(!r||t._dispatchRowClick?.(e,n,r,i))return;const s=e.target?.closest(".cell[data-col]");if(s){const l=Number(s.getAttribute("data-col"));if(!isNaN(l)){if(t._dispatchCellClick?.(e,n,l,s))return;const a=t._focusRow!==n||t._focusCol!==l;if(t._focusRow=n,t._focusCol=l,s.classList.contains("editing")){a&&(le(t._bodyEl??t),s.classList.add("cell-focus"));const c=s.querySelector(Ne);try{c?.focus({preventScroll:!0})}catch{}return}F(t)}}}function It(t,e){if(t._dispatchKeyDown?.(e))return;const i=t._rows.length-1,o=t._visibleColumns.length-1,n=t._activeEditRows!==void 0&&t._activeEditRows!==-1,s=t._visibleColumns[t._focusCol]?.type,l=e.composedPath?.()??[],a=l.length?l[0]:e.target,c=d=>{if(!d)return!1;const f=d.tagName;return!!(f==="INPUT"||f==="SELECT"||f==="TEXTAREA"||d.isContentEditable)};if(!(c(a)&&(e.key==="Home"||e.key==="End"))&&!(c(a)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&a.tagName==="INPUT"&&a.type==="number")&&!(c(a)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(c(a)&&(e.key==="Enter"||e.key==="Escape"))&&!(n&&s==="select"&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{e.preventDefault(),!e.shiftKey?t._focusCol<o?t._focusCol+=1:(typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow<i&&(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=o),F(t);return}case"ArrowDown":n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.min(i,t._focusRow+1),e.preventDefault();break;case"ArrowUp":n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault();break;case"ArrowRight":{Me(t)?t._focusCol=Math.max(0,t._focusCol-1):t._focusCol=Math.min(o,t._focusCol+1),e.preventDefault();break}case"ArrowLeft":{Me(t)?t._focusCol=Math.min(o,t._focusCol+1):t._focusCol=Math.max(0,t._focusCol-1),e.preventDefault();break}case"Home":(e.ctrlKey||e.metaKey)&&(n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=0),t._focusCol=0,e.preventDefault(),F(t,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=i),t._focusCol=o,e.preventDefault(),F(t,{forceScrollRight:!0});return;case"PageDown":t._focusRow=Math.min(i,t._focusRow+20),e.preventDefault();break;case"PageUp":t._focusRow=Math.max(0,t._focusRow-20),e.preventDefault();break;case"Enter":{const d=t._focusRow,f=t._focusCol,u=t._visibleColumns[f],g=t._rows[d],p=u?.field??"",h=p&&g?g[p]:void 0,w=t.querySelector(`[data-row="${d}"][data-col="${f}"]`),C={rowIndex:d,colIndex:f,field:p,value:h,row:g,cellEl:w,trigger:"keyboard",originalEvent:e},m=new CustomEvent("cell-activate",{cancelable:!0,detail:C});t.dispatchEvent(m);const _=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:d,col:f}});if(t.dispatchEvent(_),m.defaultPrevented||_.defaultPrevented){e.preventDefault();return}break}default:return}F(t)}}function F(t,e){if(t._virtualization?.enabled){const{rowHeight:s,container:l,viewportEl:a}=t._virtualization,c=l,d=a?.clientHeight??c?.clientHeight??0;if(c&&d>0){const f=t._focusRow*s;f<c.scrollTop?c.scrollTop=f:f+s>c.scrollTop+d&&(c.scrollTop=f-d+s)}}const i=t._activeEditRows!==void 0&&t._activeEditRows!==-1;i||t.refreshVirtualWindow(!1),le(t._bodyEl),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(s=>{s.setAttribute("aria-selected","false")});const o=t._focusRow,n=t._virtualization.start??0,r=t._virtualization.end??t._rows.length;if(o>=n&&o<r){const s=t._bodyEl.querySelectorAll(".data-grid-row")[o-n];let l=s?.children[t._focusCol];if((!l||!l.classList?.contains("cell"))&&(l=s?.querySelector(`.cell[data-col="${t._focusCol}"]`)??s?.querySelector(".cell[data-col]")),l){l.classList.add("cell-focus"),l.setAttribute("aria-selected","true");const a=t.querySelector(".tbw-scroll-area");if(a&&l&&(!i||e?.forceHorizontalScroll))if(e?.forceScrollLeft)a.scrollLeft=0;else if(e?.forceScrollRight)a.scrollLeft=a.scrollWidth-a.clientWidth;else{const c=t._getHorizontalScrollOffsets?.(s??void 0,l)??{left:0,right:0};if(!c.skipScroll){const d=l.getBoundingClientRect(),f=a.getBoundingClientRect(),u=d.left-f.left+a.scrollLeft,g=u+d.width,p=a.scrollLeft+c.left,h=a.scrollLeft+a.clientWidth-c.right;u<p?a.scrollLeft=u-c.left:g>h&&(a.scrollLeft=g-a.clientWidth+c.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&l.classList.contains("editing")){const c=l.querySelector(Ne);if(c&&document.activeElement!==c)try{c.focus({preventScroll:!0})}catch{}}else if(!l.contains(document.activeElement)){l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{}}}}}const Q=new WeakMap;function Nt(t,e){const i=Oe(e),o=zt(e);i<0||o<0||(t._focusRow=i,t._focusCol=o,le(t._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function he(t,e,i,o){let n=null;const r=i.composedPath?.();if(r&&r.length>0?n=r[0]:n=i.target,n&&!e.contains(n)){const h=document.elementFromPoint(i.clientX,i.clientY);h&&(n=h)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),a=n?.closest?.(".header-row");let c,d,f,u,g,p;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(f=t._rows[c],p=t._columns[d],u=p?.field,g=f&&u?f[u]:void 0)),{type:o,row:f,rowIndex:c!==void 0&&c>=0?c:void 0,colIndex:d!==void 0&&d>=0?d:void 0,field:u,value:g,column:p,originalEvent:i,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:c!==void 0&&d!==void 0&&c>=0&&d>=0?{row:c,col:d}:void 0}}function qt(t,e,i){const o=he(t,e,i,"mousedown");(t._dispatchCellMouseDown?.(o)??!1)&&Q.set(t,!0)}function $t(t,e,i){if(!Q.get(t))return;const o=he(t,e,i,"mousemove");t._dispatchCellMouseMove?.(o)}function Wt(t,e,i){if(!Q.get(t))return;const o=he(t,e,i,"mouseup");t._dispatchCellMouseUp?.(o),Q.set(t,!1)}function Ft(t,e,i){e.addEventListener("mousedown",o=>{const n=o.target.closest(".cell[data-col]");n&&(n.classList.contains("editing")||Nt(t,n))},{signal:i}),e.addEventListener("click",o=>{const n=o.target.closest(".data-grid-row");n&&We(t,o,n)},{signal:i}),e.addEventListener("dblclick",o=>{const n=o.target.closest(".data-grid-row");n&&We(t,o,n)},{signal:i})}function Ut(t,e,i,o){e.addEventListener("keydown",n=>It(t,n),{signal:o}),i.addEventListener("mousedown",n=>qt(t,i,n),{signal:o}),document.addEventListener("mousemove",n=>$t(t,i,n),{signal:o}),document.addEventListener("mouseup",n=>Wt(t,i,n),{signal:o})}function Fe(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function Ue(t,e,i){const n=i.find(l=>l.field===e.field)?.sortComparator??Fe,{field:r,direction:s}=e;return[...t].sort((l,a)=>n(l[r],a[r],l,a)*s)}function Ve(t,e,i,o){t._rows=e,t.__rowRenderEpoch++,t._rowPool.forEach(n=>n.__epoch=-1),ie(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:i.field,direction:o}})),t.requestStateChange?.()}function Ge(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),Be(t,e,1)):t._sortState.direction===1?Be(t,e,-1):(t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(o=>o.__epoch=-1),t._rows=t.__originalOrder.slice(),ie(t),t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(o=>{o.getAttribute("aria-sort")?(o.getAttribute("aria-sort")==="ascending"||o.getAttribute("aria-sort")==="descending")&&(t._sortState||o.setAttribute("aria-sort","none")):o.setAttribute("aria-sort","none")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),t.requestStateChange?.())}function Be(t,e,i){t._sortState={field:e.field,direction:i};const o={field:e.field,direction:i},n=t._columns,s=(t.effectiveConfig?.sortHandler??Ue)(t._rows,o,n);s&&typeof s.then=="function"?s.then(l=>{Ve(t,l,e,i)}):Ve(t,s,e,i)}function B(t,e){return t.effectiveConfig?.sortable!==!1&&e.sortable===!0}function Z(t,e){return t.effectiveConfig?.resizable!==!1&&e.resizable!==!1}function Vt(t,e){typeof e=="string"?t.textContent=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}function J(t,e){const i=document.createElement("span");Te(i,"sort-indicator");const o=t._sortState?.field===e.field?t._sortState.direction:0,n={...M,...t.icons},r=o===1?n.sortAsc:o===-1?n.sortDesc:n.sortNone;return Vt(i,r),i}function ee(t,e,i){const o=document.createElement("div");return o.className="resize-handle",o.setAttribute("aria-hidden","true"),o.addEventListener("mousedown",n=>{n.stopPropagation(),n.preventDefault(),t._resizeController.start(n,e,i)}),o.addEventListener("dblclick",n=>{n.stopPropagation(),n.preventDefault(),t._resizeController.resetColumn(e)}),o}function te(t,e,i,o){o.classList.add("sortable"),o.tabIndex=0;const n=t._sortState?.field===e.field?t._sortState.direction:0;o.setAttribute("aria-sort",n===0?"none":n===1?"ascending":"descending"),o.addEventListener("click",r=>{t._resizeController?.isResizing||t._dispatchHeaderClick?.(r,i,o)||Ge(t,e)}),o.addEventListener("keydown",r=>{if(r.key==="Enter"||r.key===" "){if(r.preventDefault(),t._dispatchHeaderClick?.(r,i,o))return;Ge(t,e)}})}function Gt(t,e){if(e!=null)if(typeof e=="string"){const i=document.createElement("span");for(i.innerHTML=W(e);i.firstChild;)t.appendChild(i.firstChild)}else e instanceof Node&&t.appendChild(e)}function ie(t){t._headerRowEl=t.findHeaderRow();const e=t._headerRowEl;e&&(e.innerHTML="",t._visibleColumns.forEach((i,o)=>{const n=document.createElement("div");n.className="cell",Te(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(o+1)),n.setAttribute("data-field",i.field),n.setAttribute("data-col",String(o));const r=i.header??i.field,s=t._sortState?.field===i.field?t._sortState.direction:0,l=s===1?"asc":s===-1?"desc":null;if(i.headerRenderer){const a={column:i,value:r,sortState:l,filterActive:!1,cellEl:n,renderSortIcon:()=>B(t,i)?J(t,i):null,renderFilterButton:()=>null},c=i.headerRenderer(a);Gt(n,c),B(t,i)&&te(t,i,o,n),Z(t,i)&&(n.classList.add("resizable"),n.appendChild(ee(t,o,n)))}else if(i.headerLabelRenderer){const a={column:i,value:r},c=i.headerLabelRenderer(a),d=document.createElement("span");c==null?d.textContent=r:typeof c=="string"?d.innerHTML=W(c):c instanceof Node&&d.appendChild(c),n.appendChild(d),B(t,i)&&(te(t,i,o,n),n.appendChild(J(t,i))),Z(t,i)&&(n.classList.add("resizable"),n.appendChild(ee(t,o,n)))}else if(i.__headerTemplate)Array.from(i.__headerTemplate.childNodes).forEach(a=>n.appendChild(a.cloneNode(!0))),B(t,i)&&(te(t,i,o,n),n.appendChild(J(t,i))),Z(t,i)&&(n.classList.add("resizable"),n.appendChild(ee(t,o,n)));else{const a=document.createElement("span");a.textContent=r,n.appendChild(a),B(t,i)&&(te(t,i,o,n),n.appendChild(J(t,i))),Z(t,i)&&(n.classList.add("resizable"),n.appendChild(ee(t,o,n)))}e.appendChild(n)}),e.querySelectorAll(".cell.sortable").forEach(i=>{i.getAttribute("aria-sort")||i.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex")))}const Xe=typeof requestIdleCallback=="function";function Bt(t,e){return Xe?requestIdleCallback(t,e):window.setTimeout(()=>{const i=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-i))})},1)}function Ye(t){Xe?cancelIdleCallback(t):clearTimeout(t)}function Xt(t){const e=document.createElement("div");return e.className=`tbw-spinner tbw-spinner--${t}`,e.setAttribute("role","progressbar"),e.setAttribute("aria-label","Loading"),e}function Yt(t,e){if(e){const o=e({size:t});if(typeof o=="string"){const n=document.createElement("div");return n.innerHTML=o,n}return o}return Xt(t)}function jt(t){const e=document.createElement("div");return e.className="tbw-loading-overlay",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.appendChild(Yt("large",t)),e}function Kt(t,e){t.appendChild(e)}function Qt(t){t?.remove()}function Zt(t,e){e?(t.classList.add("tbw-row-loading"),t.setAttribute("aria-busy","true")):(t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy"))}function Jt(t,e){e?(t.classList.add("tbw-cell-loading"),t.setAttribute("aria-busy","true")):(t.classList.remove("tbw-cell-loading"),t.removeAttribute("aria-busy"))}var H=(t=>(t[t.STYLE=1]="STYLE",t[t.VIRTUALIZATION=2]="VIRTUALIZATION",t[t.HEADER=3]="HEADER",t[t.ROWS=4]="ROWS",t[t.COLUMNS=5]="COLUMNS",t[t.FULL=6]="FULL",t))(H||{});class ei{#l;#n=0;#u=0;#d=null;#h=null;#a=null;#o=!1;constructor(e){this.#l=e}requestPhase(e,i){e>this.#n&&(this.#n=e),this.#u===0&&(this.#f(),this.#u=requestAnimationFrame(()=>this.#w()))}whenReady(){return this.#d?this.#d:Promise.resolve()}setInitialReadyResolver(e){this.#a=e}cancel(){this.#u!==0&&(cancelAnimationFrame(this.#u),this.#u=0),this.#n=0,this.#h&&(this.#h(),this.#h=null,this.#d=null)}get isPending(){return this.#n!==0}get pendingPhase(){return this.#n}#f(){this.#d||(this.#d=new Promise(e=>{this.#h=e}))}#w(){if(this.#u=0,!this.#l.isConnected()){this.#n=0,this.#h&&(this.#h(),this.#h=null,this.#d=null);return}const e=this.#n;this.#n=0,e>=5&&this.#l.mergeConfig(),e>=4&&this.#l.processRows(),e>=5&&(this.#l.processColumns(),this.#l.updateTemplate()),e>=3&&this.#l.renderHeader(),e>=2&&this.#l.renderVirtualWindow(),e>=1&&this.#l.afterRender(),!this.#o&&this.#a&&(this.#o=!0,this.#a()),this.#h&&(this.#h(),this.#h=null,this.#d=null)}}function je(t){let e=null,i=null,o=null,n=null;const r=a=>{if(!e)return;const c=a.clientX-e.startX,d=Math.max(40,e.startWidth+c),f=t._visibleColumns[e.colIndex];f.width=d,f.__userResized=!0,f.__renderedWidth=d,i==null&&(i=requestAnimationFrame(()=>{i=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:f.field,width:d}}))};let s=!1;const l=()=>{const a=e!==null;a&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),o!==null&&(document.documentElement.style.cursor=o,o=null),n!==null&&(document.body.style.userSelect=n,n=null),e=null,a&&t.requestStateChange&&t.requestStateChange()};return{get isResizing(){return e!==null||s},start(a,c,d){a.preventDefault();const f=t._visibleColumns[c],u=typeof f?.width=="number"?f.width:void 0,g=f?.__renderedWidth??u??d.getBoundingClientRect().width;e={startX:a.clientX,colIndex:c,startWidth:g},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),o===null&&(o=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",n===null&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(a){const c=t._visibleColumns[a];c&&(c.__userResized=!1,c.__renderedWidth=void 0,c.width=c.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:c.field,width:c.width}})))},dispose(){l()}}}const ue="data-animating",ti={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},ii={change:500,insert:300,remove:200};function oi(t){const e=t.trim().toLowerCase();return e.endsWith("ms")?parseFloat(e):e.endsWith("s")?parseFloat(e)*1e3:parseFloat(e)}function ni(t,e){const i=ti[e],o=getComputedStyle(t).getPropertyValue(i);if(o){const n=oi(o);if(!isNaN(n)&&n>0)return n}return ii[e]}function ri(t,e,i){t.removeAttribute(ue),t.offsetWidth,t.setAttribute(ue,e);const o=ni(t,e);setTimeout(()=>{e!=="remove"&&t.removeAttribute(ue)},o)}function fe(t,e,i){if(e<0)return!1;const o=t.findRenderedRowElement?.(e);return o?(ri(o,i),!0):!1}function si(t,e,i){let o=0;for(const n of e)fe(t,n,i)&&o++;return o}function li(t,e,i){const o=t._rows??[],n=t.getRowId;if(!n)return!1;const r=o.findIndex(s=>{if(s==null)return!1;try{return n(s)===e}catch{return!1}});return r<0?!1:fe(t,r,i)}function oe(t,e,i){const o=document.createElement(t);if(e)for(const n in e){const r=e[n];r!=null&&o.setAttribute(n,r)}return o}function P(t,e){const i=document.createElement("div");if(t&&(i.className=t),e)for(const o in e){const n=e[o];n!=null&&i.setAttribute(o,n)}return i}function Ke(t,e,i){const o=document.createElement("button");if(t&&(o.className=t),e)for(const n in e){const r=e[n];r!=null&&o.setAttribute(n,r)}return o}const Qe=document.createElement("template");Qe.innerHTML=`
|
|
2
2
|
<div class="tbw-scroll-area">
|
|
3
3
|
<div class="rows-body-wrapper">
|
|
4
4
|
<div class="rows-body" role="grid">
|
|
@@ -78,7 +78,7 @@ ${D(o.name)}Plugin and ${D(s.name)}Plugin are both loaded, but they are currentl
|
|
|
78
78
|
/* Declare layer order - earlier layers have lower priority */
|
|
79
79
|
@layer tbw-base, tbw-plugins, tbw-theme;
|
|
80
80
|
|
|
81
|
-
@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--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-warning: light-dark(hsl(38, 92%, 50%), hsl(38, 92%, 50%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-danger: var(--tbw-color-error);--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, #666666);--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-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-v: var(--tbw-spacing-xs);--tbw-cell-padding-h: var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-cell-padding-v) var(--tbw-cell-padding-h);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-
|
|
81
|
+
@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--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-warning: light-dark(hsl(38, 92%, 50%), hsl(38, 92%, 50%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-danger: var(--tbw-color-error);--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, #666666);--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-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-v: var(--tbw-spacing-xs);--tbw-cell-padding-h: var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-cell-padding-v) var(--tbw-cell-padding-h);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-width: 1px;--tbw-border-style: solid;--tbw-border-input: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-strong);--tbw-border-header: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-header);--tbw-row-divider: var(--tbw-border-width) var(--tbw-border-style) 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-width: 2px;--tbw-focus-outline: var(--tbw-focus-outline-width) var(--tbw-border-style) 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: var(--tbw-spacing-sm);--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--tbw-row-change-duration: .5s;--tbw-row-insert-duration: .3s;--tbw-row-remove-duration: .2s;--tbw-row-change-color: rgba(from var(--tbw-color-accent) r g b / 25%);--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-sort-indicator-display: inline-flex;--tbw-sort-indicator-visibility: visible;--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm)}}
|
|
82
82
|
@layer tbw-base{tbw-grid{color-scheme:inherit;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);font-feature-settings:"tnum","lnum";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}tbw-grid,tbw-grid *{box-sizing:border-box}tbw-grid .tbw-grid-root{position:relative;display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root:has(.selected){-webkit-user-select:none;user-select:none}tbw-grid .rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}tbw-grid .rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}tbw-grid .rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}tbw-grid .rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip}tbw-grid .rows-viewport .rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}tbw-grid .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)}tbw-grid .faux-vscroll-spacer{width:1px}tbw-grid[data-has-focus] .cell-focus,tbw-grid[data-has-focus] .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .sticky-left,tbw-grid .sticky-right{position:sticky;z-index:25}tbw-grid .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}tbw-grid .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}}
|
|
83
83
|
@layer tbw-base{tbw-grid .header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}tbw-grid .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)}tbw-grid .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))}tbw-grid .header-group-cell:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .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);text-transform:var(--tbw-header-text-transform);letter-spacing:var(--tbw-header-letter-spacing)}tbw-grid .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:visible;min-width:0}tbw-grid .header-row>.cell>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:inherit}tbw-grid .header-row>.cell>span[part~=sort-indicator]{flex-shrink:0;opacity:.6;color:var(--tbw-sort-indicator-color);display:var(--tbw-sort-indicator-display, inline-flex);visibility:var(--tbw-sort-indicator-visibility, visible);transition:opacity .15s,visibility 0s,display 0s allow-discrete;transition-behavior:allow-discrete}tbw-grid .header-row>.cell:hover>span[part~=sort-indicator]{display:inline-flex;visibility:visible}tbw-grid .header-row>.cell[aria-sort=ascending]>span[part~=sort-indicator],tbw-grid .header-row>.cell[aria-sort=descending]>span[part~=sort-indicator]{display:inline-flex;visibility:visible;opacity:1;color:var(--tbw-sort-indicator-active-color)}tbw-grid .header-row>.cell:last-child{border-right:0}tbw-grid .header-row>.cell:last-child .resize-handle{right:0;width:calc(var(--tbw-resize-handle-width) / 2)}tbw-grid .header-row>.cell.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row>.cell.resizable{position:relative}tbw-grid .header-row>.cell.sticky-left,tbw-grid .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}tbw-grid .sortable{cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .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)}tbw-grid .resize-handle:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-indicator-width, 2px);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}tbw-grid .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}tbw-grid .resize-handle:hover:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}}
|
|
84
84
|
@layer tbw-base{tbw-grid .data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style}tbw-grid .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid .data-grid-row:hover{background:var(--tbw-color-row-hover)}tbw-grid .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);align-content:center;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}tbw-grid .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}tbw-grid .data-grid-row>.cell:last-child{border-right:0}tbw-grid .data-grid-row>.cell[data-type=boolean]{text-align:center}tbw-grid .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}tbw-grid .data-grid-row>.cell.selected:focus-visible,tbw-grid .data-grid-row>.cell:focus-visible:not(.cell-focus){outline:none}tbw-grid .data-grid-row>.cell.sticky-left,tbw-grid .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}tbw-grid .selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}}
|