@toolbox-web/grid 2.17.0 → 2.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/all.js +1 -1
  2. package/all.js.map +1 -1
  3. package/index.js +1 -1
  4. package/lib/features/registry.js +1 -1
  5. package/lib/plugins/clipboard/index.js +1 -1
  6. package/lib/plugins/column-virtualization/index.js +1 -1
  7. package/lib/plugins/context-menu/index.js +1 -1
  8. package/lib/plugins/editing/index.js +1 -1
  9. package/lib/plugins/export/index.js +1 -1
  10. package/lib/plugins/filtering/index.js +1 -1
  11. package/lib/plugins/grouping-columns/index.js +1 -1
  12. package/lib/plugins/grouping-rows/index.js +1 -1
  13. package/lib/plugins/master-detail/index.js +1 -1
  14. package/lib/plugins/multi-sort/index.js +1 -1
  15. package/lib/plugins/pinned-columns/index.js +1 -1
  16. package/lib/plugins/pinned-rows/index.js +1 -1
  17. package/lib/plugins/pivot/index.js +1 -1
  18. package/lib/plugins/print/index.js +1 -1
  19. package/lib/plugins/reorder-columns/index.js +1 -1
  20. package/lib/plugins/reorder-rows/index.js +1 -1
  21. package/lib/plugins/responsive/index.js +1 -1
  22. package/lib/plugins/row-drag-drop/index.js +1 -1
  23. package/lib/plugins/selection/index.js +1 -1
  24. package/lib/plugins/selection/index.js.map +1 -1
  25. package/lib/plugins/server-side/index.js +1 -1
  26. package/lib/plugins/shell/index.js +1 -1
  27. package/lib/plugins/sticky-rows/index.js +1 -1
  28. package/lib/plugins/tooltip/index.js +1 -1
  29. package/lib/plugins/tree/index.js +1 -1
  30. package/lib/plugins/undo-redo/index.js +1 -1
  31. package/lib/plugins/visibility/index.js +1 -1
  32. package/package.json +1 -1
  33. package/umd/grid.all.umd.js +1 -1
  34. package/umd/grid.all.umd.js.map +1 -1
  35. package/umd/grid.umd.js +1 -1
  36. package/umd/plugins/selection.umd.js +1 -1
  37. package/umd/plugins/selection.umd.js.map +1 -1
@@ -1,2 +1,2 @@
1
- function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}const e="TBW140";function o(e,o,r,s){return`${t(r,s)} ${e}: ${o}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}function r(t,e,r,s){console.debug(o(t,e,r,s))}function s(t,e,r,s){console.error(o(t,e,r,s))}const i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"},n="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${n.slice(3).join("|")}|this\\b`);const a=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".split("|")),l=/^on\w+$/i,d=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),c=/^\s*(javascript|vbscript|data|blob):/i;function u(t){if(!t||"string"!=typeof t)return"";if(-1===t.indexOf("<"))return t;const e=document.createElement("template");return e.innerHTML=t,function(t){const e=[],o=t.querySelectorAll("*");for(const r of o){const t=r.tagName.toLowerCase();if(a.has(t)){e.push(r);continue}if("svg"===t||"http://www.w3.org/2000/svg"===r.namespaceURI){if(Array.from(r.attributes).some(t=>l.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(r);continue}}const o=[];for(const e of r.attributes){const t=e.name.toLowerCase();l.test(t)?o.push(e.name):(d.has(t)&&c.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&o.push(e.name)}o.forEach(t=>r.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content),e.innerHTML}class h{static dependencies;static manifest;aliases;version="2.17.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}get resolvedConfig(){return this.#t?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(t){if(0===t.length)return;const e={...this.userConfig},r={};for(const o of Object.keys(e))r[o]=this;for(const s of t){const t=s.userConfig;for(const[i,n]of Object.entries(t)){if(void 0===n)continue;if(!(i in e)){e[i]=n,r[i]=s;continue}if(e[i]===n)continue;const t=r[i]?.constructor.name??this.constructor.name,a=s.constructor.name,l=o("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${i}" supplied by both ${t} and ${a}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(l)}}Object.assign(this.userConfig,e)}refreshUserConfigFrom(t){const e=this.userConfig;for(const o of Object.keys(e))delete e[o];Object.assign(e,t.userConfig)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const o=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...i,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(e,10);if(!isNaN(o))return o}return 200}setIcon(t,e,o){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const r=this.#e(e,o);void 0!==r?"string"==typeof r?t.innerHTML=u(r):r instanceof HTMLElement&&(t.innerHTML="",t.appendChild(r.cloneNode(!0))):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(o,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const r=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return r?t.insertBefore(o,r):t.appendChild(o),o}warn(e,r){void 0!==r?console.warn(o(e,r,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(t,e){throw new Error(o(t,e,this.gridElement.id,this.name))}}const g=/* @__PURE__ */new WeakMap;function f(t,e,o=-1){if(!e.valueAccessor)return t?.[e.field];if("object"!=typeof t||null===t)return e.valueAccessor({row:t,column:e,rowIndex:o});const r=t,s=e.field;let i=g.get(r);if(i){const t=i.get(s);if(void 0!==t)return t.v}else i=/* @__PURE__ */new Map,g.set(r,i);const n=e.valueAccessor({row:t,column:e,rowIndex:o});return i.set(s,{v:n}),n}function m(t,e,o){const r=o.find(t=>t.field===e.field),s=r?.sortComparator,{field:i,direction:n}=e,a=[...t];return s?r?.valueAccessor?a.sort((t,e)=>s(f(t,r),f(e,r),t,e)*n):a.sort((t,e)=>s(t[i],e[i],t,e)*n):r?.valueAccessor?function(t,e,o){t.sort((t,r)=>{const s=b(t,r);if(0!==s)return s;const i=f(t,e),n=f(r,e);return null==i&&null==n?0:null==i?-o:null==n||i>n?o:i<n?-o:0})}(a,r,n):function(t,e,o){t.sort((t,r)=>{const s=b(t,r);if(0!==s)return s;const i=t[e],n=r[e];return null==i&&null==n?0:null==i?-o:null==n||i>n?o:i<n?-o:0})}(a,i,n),a}function b(t,e){const o=!0===t?.__loading;return o===(!0===e?.__loading)?0:o?1:-1}function p(t,e){return Math.floor(t/e)}function w(){return new DOMException("Aborted","AbortError")}function C(t,e,o,r,s){const i=function(t,e){return{start:t*e,end:(t+1)*e}}(e,o);return function(t,e){return e.aborted?Promise.reject(w()):"object"!=typeof(o=t)||null===o||"function"!=typeof o.subscribe||"function"==typeof o.then?new Promise((o,r)=>{const s=()=>r(w());e.addEventListener("abort",s,{once:!0}),Promise.resolve(t).then(t=>{e.removeEventListener("abort",s),o(t)},t=>{e.removeEventListener("abort",s),r(t)})}):new Promise((o,r)=>{let s=!1;const i=t.subscribe({next:t=>{s||(s=!0,o(t),i.unsubscribe())},error:t=>{s||(s=!0,r(t))},complete:()=>{s||(s=!0,r(new Error("getRows observable completed without emitting a value")))}});s||e.addEventListener("abort",()=>{s||(s=!0,i.unsubscribe(),r(w()))},{once:!0})});var o}(t.getRows({startNode:i.start,endNode:i.end,pageSize:i.end-i.start,sortModel:r.sortModel,filterModel:r.filterModel,signal:s}),s)}function v(t,e,o){const r=p(t,e),s=o.get(r);if(!s)return;return s[t%e]}function S(t){let e=null;return{async getRows({startNode:o,endNode:r,signal:s}){const{rows:i,total:n}=await(o=>(e||(e=fetch(t,{signal:o}).then(async e=>{if(!e.ok)throw new Error(`Failed to fetch "${t}": ${e.status} ${e.statusText}`);const o=await e.json();if(Array.isArray(o))return{rows:o,total:o.length};const r=o??{},s=Array.isArray(r.rows)?r.rows:[];return{rows:s,total:"number"==typeof r.totalNodeCount?r.totalNodeCount:s.length}}).catch(t=>{throw e=null,t})),e))(s);return{rows:i.slice(o,r),totalNodeCount:n}}}}class k extends h{static manifest={modifiesRowStructure:!0,hookPriority:{processRows:-10},incompatibleWith:[{name:"pivot",reason:"PivotPlugin requires the full dataset to compute aggregations. ServerSidePlugin lazy-loads rows in blocks, so pivot aggregation cannot be performed client-side."}],events:[{type:"datasource:data",description:"Root data page/block loaded"},{type:"datasource:children",description:"Child data loaded for a parent context"},{type:"datasource:loading",description:"Loading state changed"},{type:"datasource:error",description:"Fetch operation failed"}],queries:[{type:"datasource:fetch-children",description:"Request child rows for a parent context"},{type:"datasource:is-active",description:"Check if ServerSide plugin has an active data source"}]};name="serverSide";get defaultConfig(){return{maxConcurrentRequests:2}}dataSource=null;totalNodeCount=0;infiniteScrollMode=!1;loadedBlocks=/* @__PURE__ */new Map;loadingBlocks=/* @__PURE__ */new Set;blockControllers=/* @__PURE__ */new Map;lastRequestId=0;scrollDebounceTimer;managedNodes=[];attach(t){if(super.attach(t),this.on("sort-change",()=>{"local"===this.config.sortMode?this.requestRender():this.onModelChange()}),this.on("filter-change",()=>{"local"===this.config.filterMode?this.requestRender():this.onModelChange()}),this.config.dataSource)return void this.setDataSource(this.config.dataSource);const e=this.gridElement?.getAttribute("data-src");e&&this.setDataSource(S(e))}detach(){this.dataSource=null,this.totalNodeCount=0,this.infiniteScrollMode=!1,this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.abortAllBlocks(),this.managedNodes=[],this.lastRequestId=0,this.scrollDebounceTimer&&(clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=void 0)}abortAllBlocks(){for(const t of this.blockControllers.values())t.abort();this.blockControllers.clear()}getEnrichmentParams(){const t="local"===this.config.sortMode,e="local"===this.config.filterMode,o=t?void 0:this.grid?.query?.("sort:get-model",null),r=e?void 0:this.grid?.query?.("filter:get-model",null);let s=o?.[0];const i=this.grid;if(!t&&!s&&i?._sortState){const{field:t,direction:e}=i._sortState;s=[{field:t,direction:1===e?"asc":"desc"}]}return{sortModel:s,filterModel:r?.[0]}}getViewportMapping(t,e){const o={viewportStart:t,viewportEnd:e},r=this.grid?.query?.("datasource:viewport-mapping",o);return r?.[0]?r[0]:{startNode:t,endNode:e,totalLoadedNodes:this.totalNodeCount}}onModelChange(){this.dataSource&&(this.abortAllBlocks(),this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.managedNodes=[],this.totalNodeCount=0,this.infiniteScrollMode=!1,this.requestRender(),this.loadRequiredBlocks())}applyServerResult(t,e,o){void 0!==t.lastNode?(this.totalNodeCount=t.lastNode+1,this.infiniteScrollMode=!1):-1===t.totalNodeCount?this.infiniteScrollMode=!0:(this.totalNodeCount=t.totalNodeCount,this.infiniteScrollMode=!1),this.infiniteScrollMode&&t.rows.length<o&&(this.totalNodeCount=e*o+t.rows.length,this.infiniteScrollMode=!1)}getInfiniteScrollEstimate(t){let e=0;for(const[o,r]of this.loadedBlocks){const s=o*t+r.length;s>e&&(e=s)}return e+t}loadRequiredBlocks(){if(!this.dataSource)return;const t=this.grid,o=this.config.pageSize??this.config.cacheBlockSize??100,i=this.getViewportMapping(t._virtualization.start,t._virtualization.end),n=Math.max(0,this.config.loadThreshold??0),a=Math.max(0,i.startNode-n),l=this.totalNodeCount>0?this.totalNodeCount:1/0,d=Math.min(l,i.endNode+n);if(d<=a)return;const c=function(t,e,o){const r=p(t,o),s=p(e-1,o),i=[];for(let n=r;n<=s;n++)i.push(n);return i}(a,d,o),u=this.getEnrichmentParams(),h=this.grid?.getAttribute?.("id")??void 0;for(const g of c){if(this.loadedBlocks.has(g)||this.loadingBlocks.has(g))continue;if(this.loadingBlocks.size>=(this.config.maxConcurrentRequests??2)){r("TBW143","Concurrent request limit reached, deferring block load",h);break}this.loadingBlocks.add(g);const t=new AbortController;this.blockControllers.set(g,t),this.broadcast("datasource:loading",{loading:!0}),C(this.dataSource,g,o,u,t.signal).then(e=>{if(this.blockControllers.delete(g),t.signal.aborted)return this.loadingBlocks.delete(g),void(0===this.loadingBlocks.size&&this.broadcast("datasource:loading",{loading:!1}));this.loadedBlocks.set(g,e.rows);const r=this.managedNodes.length;this.applyServerResult(e,g,o),this.loadingBlocks.delete(g);const s=g*o;for(let t=0;t<e.rows.length;t++)s+t<this.managedNodes.length&&(this.managedNodes[s+t]=e.rows[t]);const i={rows:e.rows,totalNodeCount:e.totalNodeCount,startNode:s,endNode:s+e.rows.length,claimed:!1};this.broadcast("datasource:data",i),0===this.loadingBlocks.size&&this.broadcast("datasource:loading",{loading:!1});0===r||this.managedNodes.length<(Number.isFinite(this.totalNodeCount)?this.totalNodeCount:0)?this.requestRender():this.requestVirtualRefresh(),this.loadRequiredBlocks()}).catch(o=>{if(this.blockControllers.delete(g),this.loadingBlocks.delete(g),t.signal.aborted)return void(0===this.loadingBlocks.size&&this.broadcast("datasource:loading",{loading:!1}));const r=o instanceof Error?o:new Error(String(o));s(e,`getRows() failed: ${r.message}`,h),this.broadcast("datasource:error",{error:r}),0===this.loadingBlocks.size&&this.broadcast("datasource:loading",{loading:!1})})}}processRows(t){if(!this.dataSource)return[...t];const e=this.config.pageSize??this.config.cacheBlockSize??100,o=this.infiniteScrollMode?this.getInfiniteScrollEstimate(e):Number.isFinite(this.totalNodeCount)&&this.totalNodeCount>=0?this.totalNodeCount:0;for(;this.managedNodes.length<o;){const t=this.managedNodes.length;this.managedNodes.push({__loading:!0,__index:t})}this.managedNodes.length=o;for(let s=0;s<o;s++){const t=v(s,e,this.loadedBlocks);t&&(this.managedNodes[s]=t)}const r=this.grid;if("local"===this.config.sortMode&&r?._sortState){const t=r._columns??[],e=(r.effectiveConfig?.sortHandler??m)(this.managedNodes,r._sortState,t);return e&&"function"==typeof e.then?(e.catch(()=>{}),this.managedNodes):e}return this.managedNodes}onScroll(t){this.dataSource&&(this.loadRequiredBlocks(),this.scrollDebounceTimer&&clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=setTimeout(()=>{this.loadRequiredBlocks()},100))}handleQuery(t){switch(t.type){case"datasource:is-active":return null!=this.dataSource;case"datasource:fetch-children":{const{context:e}=t.context;return void this.fetchChildren(e)}}}fetchChildren(t){if(!this.dataSource)return;const e=this.grid?.getAttribute?.("id")??void 0;if(!this.dataSource.getChildRows)return void function(t,e,r,s){console.warn(o(t,e,r,s))}("TBW142",`Plugin "${t.source}" requested child rows but getChildRows() is not implemented on the dataSource`,e);const r=this.getEnrichmentParams();this.broadcast("datasource:loading",{loading:!0,context:t}),this.dataSource.getChildRows({context:t,sortModel:r.sortModel,filterModel:r.filterModel}).then(e=>{const o={rows:e.rows,context:t,claimed:!1};this.broadcast("datasource:children",o),this.broadcast("datasource:loading",{loading:!1,context:t})}).catch(o=>{const r=o instanceof Error?o:new Error(String(o));s("TBW141",`getChildRows() failed: ${r.message}`,e),this.broadcast("datasource:error",{error:r,context:t}),this.broadcast("datasource:loading",{loading:!1,context:t})})}setDataSource(t){this.abortAllBlocks(),this.dataSource=t,this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.managedNodes=[],this.totalNodeCount=0,this.infiniteScrollMode=!1;const o=this.config.pageSize??this.config.cacheBlockSize??100,r=this.getEnrichmentParams(),i=this.grid?.getAttribute?.("id")??void 0,n=new AbortController;this.blockControllers.set(0,n),this.loadingBlocks.add(0),this.broadcast("datasource:loading",{loading:!0}),C(t,0,o,r,n.signal).then(t=>{if(this.blockControllers.delete(0),this.loadingBlocks.delete(0),n.signal.aborted)return void this.broadcast("datasource:loading",{loading:!1});this.loadedBlocks.set(0,t.rows),this.applyServerResult(t,0,o);const e={rows:t.rows,totalNodeCount:t.totalNodeCount,startNode:0,endNode:t.rows.length,claimed:!1};this.broadcast("datasource:data",e),this.broadcast("datasource:loading",{loading:!1}),this.requestRender(),(this.config.loadThreshold??0)>0&&this.loadRequiredBlocks()}).catch(t=>{if(this.blockControllers.delete(0),this.loadingBlocks.delete(0),n.signal.aborted)return void this.broadcast("datasource:loading",{loading:!1});const o=t instanceof Error?t:new Error(String(t));s(e,`getRows() failed: ${o.message}`,i),this.broadcast("datasource:error",{error:o}),this.broadcast("datasource:loading",{loading:!1})})}refresh(){if(!this.dataSource)return;const t=this.dataSource;this.abortAllBlocks(),this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.managedNodes=[],this.totalNodeCount=0,this.infiniteScrollMode=!1,this.setDataSource(t)}purgeCache(){this.abortAllBlocks(),this.loadedBlocks.clear(),this.managedNodes=[]}getTotalNodeCount(){return this.totalNodeCount}getTotalRowCount(){return this.totalNodeCount}isNodeLoaded(t){const e=p(t,this.config.pageSize??this.config.cacheBlockSize??100);return this.loadedBlocks.has(e)}isRowLoaded(t){return this.isNodeLoaded(t)}getLoadedBlockCount(){return this.loadedBlocks.size}}export{k as ServerSidePlugin};
1
+ function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}const e="TBW140";function o(e,o,r,s){return`${t(r,s)} ${e}: ${o}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}function r(t,e,r,s){console.debug(o(t,e,r,s))}function s(t,e,r,s){console.error(o(t,e,r,s))}const i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"},n="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${n.slice(3).join("|")}|this\\b`);const a=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".split("|")),l=/^on\w+$/i,d=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),c=/^\s*(javascript|vbscript|data|blob):/i;function u(t){if(!t||"string"!=typeof t)return"";if(-1===t.indexOf("<"))return t;const e=document.createElement("template");return e.innerHTML=t,function(t){const e=[],o=t.querySelectorAll("*");for(const r of o){const t=r.tagName.toLowerCase();if(a.has(t)){e.push(r);continue}if("svg"===t||"http://www.w3.org/2000/svg"===r.namespaceURI){if(Array.from(r.attributes).some(t=>l.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(r);continue}}const o=[];for(const e of r.attributes){const t=e.name.toLowerCase();l.test(t)?o.push(e.name):(d.has(t)&&c.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&o.push(e.name)}o.forEach(t=>r.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content),e.innerHTML}class h{static dependencies;static manifest;aliases;version="2.17.1";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}get resolvedConfig(){return this.#t?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(t){if(0===t.length)return;const e={...this.userConfig},r={};for(const o of Object.keys(e))r[o]=this;for(const s of t){const t=s.userConfig;for(const[i,n]of Object.entries(t)){if(void 0===n)continue;if(!(i in e)){e[i]=n,r[i]=s;continue}if(e[i]===n)continue;const t=r[i]?.constructor.name??this.constructor.name,a=s.constructor.name,l=o("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${i}" supplied by both ${t} and ${a}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(l)}}Object.assign(this.userConfig,e)}refreshUserConfigFrom(t){const e=this.userConfig;for(const o of Object.keys(e))delete e[o];Object.assign(e,t.userConfig)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const o=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...i,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(e,10);if(!isNaN(o))return o}return 200}setIcon(t,e,o){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const r=this.#e(e,o);void 0!==r?"string"==typeof r?t.innerHTML=u(r):r instanceof HTMLElement&&(t.innerHTML="",t.appendChild(r.cloneNode(!0))):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(o,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const r=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return r?t.insertBefore(o,r):t.appendChild(o),o}warn(e,r){void 0!==r?console.warn(o(e,r,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(t,e){throw new Error(o(t,e,this.gridElement.id,this.name))}}const g=/* @__PURE__ */new WeakMap;function f(t,e,o=-1){if(!e.valueAccessor)return t?.[e.field];if("object"!=typeof t||null===t)return e.valueAccessor({row:t,column:e,rowIndex:o});const r=t,s=e.field;let i=g.get(r);if(i){const t=i.get(s);if(void 0!==t)return t.v}else i=/* @__PURE__ */new Map,g.set(r,i);const n=e.valueAccessor({row:t,column:e,rowIndex:o});return i.set(s,{v:n}),n}function m(t,e,o){const r=o.find(t=>t.field===e.field),s=r?.sortComparator,{field:i,direction:n}=e,a=[...t];return s?r?.valueAccessor?a.sort((t,e)=>s(f(t,r),f(e,r),t,e)*n):a.sort((t,e)=>s(t[i],e[i],t,e)*n):r?.valueAccessor?function(t,e,o){t.sort((t,r)=>{const s=b(t,r);if(0!==s)return s;const i=f(t,e),n=f(r,e);return null==i&&null==n?0:null==i?-o:null==n||i>n?o:i<n?-o:0})}(a,r,n):function(t,e,o){t.sort((t,r)=>{const s=b(t,r);if(0!==s)return s;const i=t[e],n=r[e];return null==i&&null==n?0:null==i?-o:null==n||i>n?o:i<n?-o:0})}(a,i,n),a}function b(t,e){const o=!0===t?.__loading;return o===(!0===e?.__loading)?0:o?1:-1}function p(t,e){return Math.floor(t/e)}function w(){return new DOMException("Aborted","AbortError")}function C(t,e,o,r,s){const i=function(t,e){return{start:t*e,end:(t+1)*e}}(e,o);return function(t,e){return e.aborted?Promise.reject(w()):"object"!=typeof(o=t)||null===o||"function"!=typeof o.subscribe||"function"==typeof o.then?new Promise((o,r)=>{const s=()=>r(w());e.addEventListener("abort",s,{once:!0}),Promise.resolve(t).then(t=>{e.removeEventListener("abort",s),o(t)},t=>{e.removeEventListener("abort",s),r(t)})}):new Promise((o,r)=>{let s=!1;const i=t.subscribe({next:t=>{s||(s=!0,o(t),i.unsubscribe())},error:t=>{s||(s=!0,r(t))},complete:()=>{s||(s=!0,r(new Error("getRows observable completed without emitting a value")))}});s||e.addEventListener("abort",()=>{s||(s=!0,i.unsubscribe(),r(w()))},{once:!0})});var o}(t.getRows({startNode:i.start,endNode:i.end,pageSize:i.end-i.start,sortModel:r.sortModel,filterModel:r.filterModel,signal:s}),s)}function v(t,e,o){const r=p(t,e),s=o.get(r);if(!s)return;return s[t%e]}function S(t){let e=null;return{async getRows({startNode:o,endNode:r,signal:s}){const{rows:i,total:n}=await(o=>(e||(e=fetch(t,{signal:o}).then(async e=>{if(!e.ok)throw new Error(`Failed to fetch "${t}": ${e.status} ${e.statusText}`);const o=await e.json();if(Array.isArray(o))return{rows:o,total:o.length};const r=o??{},s=Array.isArray(r.rows)?r.rows:[];return{rows:s,total:"number"==typeof r.totalNodeCount?r.totalNodeCount:s.length}}).catch(t=>{throw e=null,t})),e))(s);return{rows:i.slice(o,r),totalNodeCount:n}}}}class k extends h{static manifest={modifiesRowStructure:!0,hookPriority:{processRows:-10},incompatibleWith:[{name:"pivot",reason:"PivotPlugin requires the full dataset to compute aggregations. ServerSidePlugin lazy-loads rows in blocks, so pivot aggregation cannot be performed client-side."}],events:[{type:"datasource:data",description:"Root data page/block loaded"},{type:"datasource:children",description:"Child data loaded for a parent context"},{type:"datasource:loading",description:"Loading state changed"},{type:"datasource:error",description:"Fetch operation failed"}],queries:[{type:"datasource:fetch-children",description:"Request child rows for a parent context"},{type:"datasource:is-active",description:"Check if ServerSide plugin has an active data source"}]};name="serverSide";get defaultConfig(){return{maxConcurrentRequests:2}}dataSource=null;totalNodeCount=0;infiniteScrollMode=!1;loadedBlocks=/* @__PURE__ */new Map;loadingBlocks=/* @__PURE__ */new Set;blockControllers=/* @__PURE__ */new Map;lastRequestId=0;scrollDebounceTimer;managedNodes=[];attach(t){if(super.attach(t),this.on("sort-change",()=>{"local"===this.config.sortMode?this.requestRender():this.onModelChange()}),this.on("filter-change",()=>{"local"===this.config.filterMode?this.requestRender():this.onModelChange()}),this.config.dataSource)return void this.setDataSource(this.config.dataSource);const e=this.gridElement?.getAttribute("data-src");e&&this.setDataSource(S(e))}detach(){this.dataSource=null,this.totalNodeCount=0,this.infiniteScrollMode=!1,this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.abortAllBlocks(),this.managedNodes=[],this.lastRequestId=0,this.scrollDebounceTimer&&(clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=void 0)}abortAllBlocks(){for(const t of this.blockControllers.values())t.abort();this.blockControllers.clear()}getEnrichmentParams(){const t="local"===this.config.sortMode,e="local"===this.config.filterMode,o=t?void 0:this.grid?.query?.("sort:get-model",null),r=e?void 0:this.grid?.query?.("filter:get-model",null);let s=o?.[0];const i=this.grid;if(!t&&!s&&i?._sortState){const{field:t,direction:e}=i._sortState;s=[{field:t,direction:1===e?"asc":"desc"}]}return{sortModel:s,filterModel:r?.[0]}}getViewportMapping(t,e){const o={viewportStart:t,viewportEnd:e},r=this.grid?.query?.("datasource:viewport-mapping",o);return r?.[0]?r[0]:{startNode:t,endNode:e,totalLoadedNodes:this.totalNodeCount}}onModelChange(){this.dataSource&&(this.abortAllBlocks(),this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.managedNodes=[],this.totalNodeCount=0,this.infiniteScrollMode=!1,this.requestRender(),this.loadRequiredBlocks())}applyServerResult(t,e,o){void 0!==t.lastNode?(this.totalNodeCount=t.lastNode+1,this.infiniteScrollMode=!1):-1===t.totalNodeCount?this.infiniteScrollMode=!0:(this.totalNodeCount=t.totalNodeCount,this.infiniteScrollMode=!1),this.infiniteScrollMode&&t.rows.length<o&&(this.totalNodeCount=e*o+t.rows.length,this.infiniteScrollMode=!1)}getInfiniteScrollEstimate(t){let e=0;for(const[o,r]of this.loadedBlocks){const s=o*t+r.length;s>e&&(e=s)}return e+t}loadRequiredBlocks(){if(!this.dataSource)return;const t=this.grid,o=this.config.pageSize??this.config.cacheBlockSize??100,i=this.getViewportMapping(t._virtualization.start,t._virtualization.end),n=Math.max(0,this.config.loadThreshold??0),a=Math.max(0,i.startNode-n),l=this.totalNodeCount>0?this.totalNodeCount:1/0,d=Math.min(l,i.endNode+n);if(d<=a)return;const c=function(t,e,o){const r=p(t,o),s=p(e-1,o),i=[];for(let n=r;n<=s;n++)i.push(n);return i}(a,d,o),u=this.getEnrichmentParams(),h=this.grid?.getAttribute?.("id")??void 0;for(const g of c){if(this.loadedBlocks.has(g)||this.loadingBlocks.has(g))continue;if(this.loadingBlocks.size>=(this.config.maxConcurrentRequests??2)){r("TBW143","Concurrent request limit reached, deferring block load",h);break}this.loadingBlocks.add(g);const t=new AbortController;this.blockControllers.set(g,t),this.broadcast("datasource:loading",{loading:!0}),C(this.dataSource,g,o,u,t.signal).then(e=>{if(this.blockControllers.delete(g),t.signal.aborted)return this.loadingBlocks.delete(g),void(0===this.loadingBlocks.size&&this.broadcast("datasource:loading",{loading:!1}));this.loadedBlocks.set(g,e.rows);const r=this.managedNodes.length;this.applyServerResult(e,g,o),this.loadingBlocks.delete(g);const s=g*o;for(let t=0;t<e.rows.length;t++)s+t<this.managedNodes.length&&(this.managedNodes[s+t]=e.rows[t]);const i={rows:e.rows,totalNodeCount:e.totalNodeCount,startNode:s,endNode:s+e.rows.length,claimed:!1};this.broadcast("datasource:data",i),0===this.loadingBlocks.size&&this.broadcast("datasource:loading",{loading:!1});0===r||this.managedNodes.length<(Number.isFinite(this.totalNodeCount)?this.totalNodeCount:0)?this.requestRender():this.requestVirtualRefresh(),this.loadRequiredBlocks()}).catch(o=>{if(this.blockControllers.delete(g),this.loadingBlocks.delete(g),t.signal.aborted)return void(0===this.loadingBlocks.size&&this.broadcast("datasource:loading",{loading:!1}));const r=o instanceof Error?o:new Error(String(o));s(e,`getRows() failed: ${r.message}`,h),this.broadcast("datasource:error",{error:r}),0===this.loadingBlocks.size&&this.broadcast("datasource:loading",{loading:!1})})}}processRows(t){if(!this.dataSource)return[...t];const e=this.config.pageSize??this.config.cacheBlockSize??100,o=this.infiniteScrollMode?this.getInfiniteScrollEstimate(e):Number.isFinite(this.totalNodeCount)&&this.totalNodeCount>=0?this.totalNodeCount:0;for(;this.managedNodes.length<o;){const t=this.managedNodes.length;this.managedNodes.push({__loading:!0,__index:t})}this.managedNodes.length=o;for(let s=0;s<o;s++){const t=v(s,e,this.loadedBlocks);t&&(this.managedNodes[s]=t)}const r=this.grid;if("local"===this.config.sortMode&&r?._sortState){const t=r._columns??[],e=(r.effectiveConfig?.sortHandler??m)(this.managedNodes,r._sortState,t);return e&&"function"==typeof e.then?(e.catch(()=>{}),this.managedNodes):e}return this.managedNodes}onScroll(t){this.dataSource&&(this.loadRequiredBlocks(),this.scrollDebounceTimer&&clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=setTimeout(()=>{this.loadRequiredBlocks()},100))}handleQuery(t){switch(t.type){case"datasource:is-active":return null!=this.dataSource;case"datasource:fetch-children":{const{context:e}=t.context;return void this.fetchChildren(e)}}}fetchChildren(t){if(!this.dataSource)return;const e=this.grid?.getAttribute?.("id")??void 0;if(!this.dataSource.getChildRows)return void function(t,e,r,s){console.warn(o(t,e,r,s))}("TBW142",`Plugin "${t.source}" requested child rows but getChildRows() is not implemented on the dataSource`,e);const r=this.getEnrichmentParams();this.broadcast("datasource:loading",{loading:!0,context:t}),this.dataSource.getChildRows({context:t,sortModel:r.sortModel,filterModel:r.filterModel}).then(e=>{const o={rows:e.rows,context:t,claimed:!1};this.broadcast("datasource:children",o),this.broadcast("datasource:loading",{loading:!1,context:t})}).catch(o=>{const r=o instanceof Error?o:new Error(String(o));s("TBW141",`getChildRows() failed: ${r.message}`,e),this.broadcast("datasource:error",{error:r,context:t}),this.broadcast("datasource:loading",{loading:!1,context:t})})}setDataSource(t){this.abortAllBlocks(),this.dataSource=t,this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.managedNodes=[],this.totalNodeCount=0,this.infiniteScrollMode=!1;const o=this.config.pageSize??this.config.cacheBlockSize??100,r=this.getEnrichmentParams(),i=this.grid?.getAttribute?.("id")??void 0,n=new AbortController;this.blockControllers.set(0,n),this.loadingBlocks.add(0),this.broadcast("datasource:loading",{loading:!0}),C(t,0,o,r,n.signal).then(t=>{if(this.blockControllers.delete(0),this.loadingBlocks.delete(0),n.signal.aborted)return void this.broadcast("datasource:loading",{loading:!1});this.loadedBlocks.set(0,t.rows),this.applyServerResult(t,0,o);const e={rows:t.rows,totalNodeCount:t.totalNodeCount,startNode:0,endNode:t.rows.length,claimed:!1};this.broadcast("datasource:data",e),this.broadcast("datasource:loading",{loading:!1}),this.requestRender(),(this.config.loadThreshold??0)>0&&this.loadRequiredBlocks()}).catch(t=>{if(this.blockControllers.delete(0),this.loadingBlocks.delete(0),n.signal.aborted)return void this.broadcast("datasource:loading",{loading:!1});const o=t instanceof Error?t:new Error(String(t));s(e,`getRows() failed: ${o.message}`,i),this.broadcast("datasource:error",{error:o}),this.broadcast("datasource:loading",{loading:!1})})}refresh(){if(!this.dataSource)return;const t=this.dataSource;this.abortAllBlocks(),this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.managedNodes=[],this.totalNodeCount=0,this.infiniteScrollMode=!1,this.setDataSource(t)}purgeCache(){this.abortAllBlocks(),this.loadedBlocks.clear(),this.managedNodes=[]}getTotalNodeCount(){return this.totalNodeCount}getTotalRowCount(){return this.totalNodeCount}isNodeLoaded(t){const e=p(t,this.config.pageSize??this.config.cacheBlockSize??100);return this.loadedBlocks.has(e)}isRowLoaded(t){return this.isNodeLoaded(t)}getLoadedBlockCount(){return this.loadedBlocks.size}}export{k as ServerSidePlugin};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- function e(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const t="TBW072",o="TBW073";function n(t,o,n,r){return`${e(n,r)} ${t}: ${o}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(t)}`}function r(e,t,o,r){console.warn(n(e,t,o,r))}const l="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${l.slice(3).join("|")}|this\\b`);const s=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".split("|")),i=/^on\w+$/i,a=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),d=/^\s*(javascript|vbscript|data|blob):/i;function c(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],o=e.querySelectorAll("*");for(const n of o){const e=n.tagName.toLowerCase();if(s.has(e)){t.push(n);continue}if("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI){if(Array.from(n.attributes).some(e=>i.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}}const o=[];for(const t of n.attributes){const e=t.name.toLowerCase();i.test(e)?o.push(t.name):(a.has(e)&&d.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}const h={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class p{static dependencies;static manifest;aliases;version="2.17.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},o={};for(const n of Object.keys(t))o[n]=this;for(const r of e){const e=r.userConfig;for(const[l,s]of Object.entries(e)){if(void 0===s)continue;if(!(l in t)){t[l]=s,o[l]=r;continue}if(t[l]===s)continue;const e=o[l]?.constructor.name??this.constructor.name,i=r.constructor.name,a=n("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${l}" supplied by both ${e} and ${i}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig;for(const o of Object.keys(t))delete t[o];Object.assign(t,e.userConfig)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const o=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...h,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(t,10);if(!isNaN(o))return o}return 200}setIcon(e,t,o){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,o);void 0!==n?"string"==typeof n?e.innerHTML=c(n):n instanceof HTMLElement&&(e.innerHTML="",e.appendChild(n.cloneNode(!0))):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(o,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(o,n):e.appendChild(o),o}warn(t,o){void 0!==o?console.warn(n(t,o,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(e,t){throw new Error(n(e,t,this.gridElement.id,this.name))}}const u="tbw-grid-root";function g(e,t){if(t)for(const o in t){const n=t[o];null!=n&&e.setAttribute(o,n)}}function b(e,t,o){const n=document.createElement(e);return g(n,t),n}function f(e,t){const o=document.createElement("div");return e&&(o.className=e),g(o,t),o}function w(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),g(n,t),n}const m=document.createElement("template");function C(){return m.content.cloneNode(!0)}function v(e){const t=document.createDocumentFragment(),o=f(e.hasShell?`${u} has-shell`:u);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=f("tbw-grid-content");e.appendChild(C()),o.appendChild(e)}return t.appendChild(o),t}function y(e){const t=f("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=f("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=f("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=f("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const s of e.configButtons)s.hasRender&&n.appendChild(f("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));for(const s of e.apiButtons)s.hasRender&&n.appendChild(f("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));const r=e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender),l=e.hasPanels&&!1!==e.showToggle;if(r&&l&&n.appendChild(f("tbw-toolbar-separator")),l){const t=w(e.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(e.isPanelOpen),"aria-controls":"tbw-tool-panel"});t.dataset.icon="tool-panel",void 0!==e.toolPanelIcon&&(t.innerHTML=c(e.toolPanelIcon)),n.appendChild(t)}return t.appendChild(n),t}function P(e){const t=e.mode??"overlay",o=f("tbw-shell-body",{"data-mode":t}),n=e.panels.length>0,r=1===e.panels.length,l=f("tbw-grid-content");l.appendChild(C());let s=null;if(n){s=b("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel",..."dropdown"===t?{popover:"manual"}:{}});const o="left"===e.position?"right":"left";s.appendChild(f("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":o,"aria-hidden":"true"}));const n=e=>{const t=w(e?"tbw-tool-panel-close tbw-tool-panel-close--inline":"tbw-tool-panel-close",{part:"tool-panel-close","data-panel-close":"",title:"Close panel","aria-label":"Close panel","aria-controls":"tbw-tool-panel"});return t.textContent="✕",t},l=!0===e.showCloseButton&&r;if(e.showCloseButton&&!r){const e=f("tbw-tool-panel-header",{part:"tool-panel-header"});e.appendChild(n(!1)),s.appendChild(e)}const i=f("tbw-tool-panel-content",{role:"presentation"}),a=f("tbw-accordion");for(const t of e.panels){const o=f(`tbw-accordion-section${t.isExpanded?" expanded":""}${r?" single":""}${l?" has-inline-close":""}`,{"data-section":t.id}),s=w("tbw-accordion-header",{"aria-expanded":String(t.isExpanded),"aria-controls":`tbw-section-${t.id}`});if(r&&s.setAttribute("aria-disabled","true"),t.icon){const e=b("span",{class:"tbw-accordion-icon"});e.innerHTML=c(t.icon),s.appendChild(e)}const i=b("span",{class:"tbw-accordion-title"});if(i.textContent=t.title,s.appendChild(i),!r){const t=b("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=c(e.expandIcon)),s.appendChild(t)}if(l){const e=f("tbw-accordion-header-row");e.appendChild(s),e.appendChild(n(!0)),o.appendChild(e)}else o.appendChild(s);o.appendChild(f("tbw-accordion-content",{id:`tbw-section-${t.id}`,role:"presentation"})),a.appendChild(o)}i.appendChild(a),s.appendChild(i)}return"left"===e.position&&s?(o.appendChild(s),o.appendChild(l)):(o.appendChild(l),s&&o.appendChild(s)),o}function x(e){return e?"string"==typeof e?c(e):e.outerHTML:""}function S(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function T(e){return!1!==e?.header?.visible}function O(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const n=o.querySelectorAll("tbw-grid-header-content");n.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(n)),o.style.display="none"}function E(e,t,o){const n=e.querySelector(":scope > tbw-grid-tool-buttons");if(!n)return;t.hasToolButtonsContainer=!0;const r="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(r))return;const l={id:r,order:0,render:e=>{for(;n.firstChild;)e.appendChild(n.firstChild);return()=>{for(;e.firstChild;)n.appendChild(e.firstChild)}}};t.toolbarContents.set(r,l),t.lightDomToolbarContentIds.add(r),n.style.display="none"}function _(e,t,n){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const l=e,s=l.getAttribute("id"),i=l.getAttribute("title");if(!s||!i)return void r("TBW070",`Tool panel missing required id or title attribute: id="${s??""}", title="${i??""}"`);const a=l.getAttribute("icon")??void 0,d=l.getAttribute("tooltip")??void 0,h=parseInt(l.getAttribute("order")??"100",10);let p;const u=n?.(l);if(u)p=u;else{const e=c(l.innerHTML.trim());p=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const g=t.toolPanels.get(s);if(g&&!t.lightDomToolPanelIds.has(s))return r(o,`Tool panel "${s}" is already provided by a plugin or the grid API; ignoring the matching light-DOM <tbw-grid-tool-panel>.`),void(l.style.display="none");if(g){if(u){const e=!t.adapterBoundToolPanelIds.has(s),o=g.order!==h||g.icon!==a||g.tooltip!==d;if(g.render=p,g.order=h,g.icon=a,g.tooltip=d,t.adapterBoundToolPanelIds.add(s),e||o){const e=t.panelCleanups.get(s);e&&(e(),t.panelCleanups.delete(s))}}return}const b={id:s,title:i,icon:a,tooltip:d,order:h,render:p};t.toolPanels.set(s,b),t.lightDomToolPanelIds.add(s),u&&t.adapterBoundToolPanelIds.add(s),l.style.display="none"})}function D(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function L(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,n=t.headerContents.size>0;if(!o&&!n)return;const r=e.querySelector(".tbw-shell-content");if(!r)return;if(o){for(const e of t.lightDomHeaderContent)e.style.display="",r.appendChild(e);t.lightDomContentMoved=!0}const l=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of l){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let o=r.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),r.appendChild(o));const n=s.render(o);n&&t.headerContentCleanups.set(s.id,n)}}function R(e,t,o){if(t.isPanelOpen)for(const[n,r]of t.toolPanels){const o=t.expandedSections.has(n),l=e.querySelector(`[data-section="${n}"]`),s=l?.querySelector(".tbw-accordion-content");if(!l||!s)continue;l.classList.toggle("expanded",o);const i=l.querySelector(".tbw-accordion-header");if(i&&i.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=r.render(s);e&&t.panelCleanups.set(n,e)}}else{const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n)),s.innerHTML=""}}}function A(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function H(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}m.innerHTML='\n <div class="tbw-scroll-area">\n <div class="rows-body-wrapper">\n <div class="rows-body" role="grid">\n <div class="header" role="rowgroup">\n <div class="header-row" role="row" part="header-row"></div>\n </div>\n <div class="rows-container" role="presentation">\n <div class="rows-viewport" role="presentation">\n <div class="rows"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class="faux-vscroll">\n <div class="faux-vscroll-spacer"></div>\n </div>\n <div class="tbw-sr-only" aria-live="polite" aria-atomic="true"></div>\n';const k="--tbw-tool-panel-anchor";let q=0;function $(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",k)}function z(e,t,o,n){const r=e.querySelector(".tbw-tool-panel");if(r){if(t.dropdownAnchorEl=o,r.dataset.anchor=n?"corner":"below",r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}if($()){const e=`${k}-${++q}`;t.dropdownAnchorName=e,o.style.setProperty("anchor-name",e),r.style.setProperty("position-anchor",e),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right")}else!function(e,t,o){const n=t.getBoundingClientRect(),r=e.getAttribute("data-position")??"right";if(e.style.position="fixed",e.style.top=`${Math.round((o?n.top:n.bottom)+4)}px`,"left"===r)e.style.left=`${Math.round(n.left)}px`,e.style.right="auto";else{const t="undefined"!=typeof window?window.innerWidth:0;e.style.left="auto",e.style.right=`${Math.round(t-n.right)}px`}}(r,o,n)}}function I(e){for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear(),e.lightDomContentMoved=!1}function M(e,t,o){const n=void 0!==o?.toolPanel?x(o.toolPanel):void 0,r=void 0!==o?.expand?x(o.expand):void 0,l=void 0!==o?.collapse?x(o.collapse):void 0,s=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),i=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:i.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:n,showToggle:!1!==e.header?.toolPanelToggle&&!0!==e.toolPanel?.locked,configButtons:s.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},bodyOptions:{position:e.toolPanel?.position??"right",mode:e.toolPanel?.mode??"overlay",isPanelOpen:t.isPanelOpen,expandIcon:r,collapseIcon:l,showCloseButton:!1===e.header?.visible&&!0!==e.toolPanel?.locked&&"dropdown"!==(e.toolPanel?.mode??"overlay"),panels:i.map(e=>({id:e.id,title:e.title,icon:x(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function B(e,t,o,n){const r=e.querySelector(`.${u}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=S(t),l=[];for(let s=e.firstChild;s;s=s.nextSibling)1===s.nodeType&&s.classList.contains(u)||l.push(s);e.replaceChildren();for(const s of l)e.appendChild(s);if(r){const{headerOptions:r,bodyOptions:l}=M(t,o,n),s=v({hasShell:!0,shellHeader:T(t)?y(r):void 0,shellBody:P(l)});e.appendChild(s)}else{const t=v({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const s=S(t);if(r.replaceChildren(),s){r.className=`${u} has-shell`;const{headerOptions:e,bodyOptions:s}=M(t,o,n),i=T(t)?y(e):void 0,a=P(s),d=a.querySelector(".tbw-grid-content");d&&d.replaceWith(l),i&&r.appendChild(i),r.appendChild(a)}else r.className=u,r.appendChild(l);return s}function N(e,n){let l=!1;const s={get isInitialized(){return l},setInitialized(e){l=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(o,l){if(0===e.toolPanels.size)return void r("TBW071","No tool panels registered",n.id);let i;if(void 0!==o&&(e.toolPanels.has(o)?i=o:r(t,`Tool panel "${o}" not found`,n.id)),e.isPanelOpen&&i&&e.expandedSections.has(i))return;if(e.isPanelOpen&&i&&!e.expandedSections.has(i))return void s.toggleToolPanelSection(i);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(i)e.expandedSections.add(i);else{const t=n.effectiveConfig?.shell?.toolPanel?.defaultOpen;if(t&&e.toolPanels.has(t))e.expandedSections.add(t);else{const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}}else if(i&&!e.expandedSections.has(i)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(i)}const a=n._renderRoot;if(A(a,e),H(a,e),R(a,e,n._accordionIcons),"dropdown"===n.effectiveConfig?.shell?.toolPanel?.mode){const{el:t,corner:o}=function(e){if(e)return{el:e,corner:!1};const t=n._renderRoot.querySelector("[data-panel-toggle]");return t?{el:t,corner:!1}:{el:n._hostElement,corner:!0}}(l?.anchor);z(a,e,t,o)}n._emit("tool-panel-open",{sections:s.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(n.effectiveConfig?.shell?.toolPanel?.locked)return;for(const o of e.panelCleanups.values())o();e.panelCleanups.clear();for(const o of e.toolPanels.values())o.onClose?.();e.isPanelOpen=!1;const t=n._renderRoot;A(t,e),H(t,e),"dropdown"===n.effectiveConfig?.shell?.toolPanel?.mode&&function(e,t){const o=e.querySelector(".tbw-tool-panel");if(o){if(o.hasAttribute("popover")&&"function"==typeof o.hidePopover)try{o.hidePopover()}catch{}o.style.removeProperty("position-anchor"),o.style.removeProperty("position"),o.style.removeProperty("top"),o.style.removeProperty("left"),o.style.removeProperty("right"),delete o.dataset.anchor}t.dropdownAnchorEl&&(t.dropdownAnchorEl.style.removeProperty("anchor-name"),t.dropdownAnchorEl=null),t.dropdownAnchorName=null}(t,e),n._emit("tool-panel-close",{})},toggleToolPanel(t){e.isPanelOpen?s.closeToolPanel():s.openToolPanel(void 0,t)},reanchorOpenDropdown(){if(!e.isPanelOpen)return;if("dropdown"!==n.effectiveConfig?.shell?.toolPanel?.mode)return;const t=e.dropdownAnchorEl;if(t&&t.isConnected&&e.dropdownAnchorName&&t.style.getPropertyValue("anchor-name")===e.dropdownAnchorName)return;if(!e.dropdownAnchorName&&t&&t.isConnected&&t!==n._hostElement){const e=n._renderRoot.querySelector(".tbw-tool-panel");if("below"===e?.dataset.anchor)return}const o=n._renderRoot.querySelector("[data-panel-toggle]");if(o&&o!==n._hostElement){if(e.dropdownAnchorName&&$()&&function(e,t,o){const n=t.dropdownAnchorName;if(!n)return!1;const r=e.querySelector(".tbw-tool-panel");if(!r)return!1;const l=t.dropdownAnchorEl;if(l&&l!==o&&l.style.removeProperty("anchor-name"),o.style.setProperty("anchor-name",n),r.style.setProperty("position-anchor",n),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right"),r.dataset.anchor="below",t.dropdownAnchorEl=o,r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}return!0}(n._renderRoot,e,o))return;z(n._renderRoot,e,o,!1)}else t!==n._hostElement||z(n._renderRoot,e,n._hostElement,!0)},toggleToolPanelSection(o){const l=e.toolPanels.get(o);if(!l)return void r(t,`Tool panel section "${o}" not found`,n.id);if(1===e.toolPanels.size)return;const s=n._renderRoot,i=e.expandedSections.has(o);if(i){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),l.onClose?.(),e.expandedSections.delete(o),j(s,o,!1)}else{for(const[t,n]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),n.onClose?.(),e.expandedSections.delete(t),j(s,t,!1);const r=s.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),j(s,o,!0),function(e,t,o){const n=t.toolPanels.get(o);if(!n?.render)return;const r=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!r)return;const l=n.render(r);l&&t.panelCleanups.set(o,l)}(s,e,o)}n._emit("tool-panel-section-toggle",{id:o,expanded:!i})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(t){e.toolPanels.has(t.id)?r(o,`Tool panel "${t.id}" already registered`,n.id):(e.toolPanels.set(t.id,t),l&&n.refreshShellHeader?.())},unregisterToolPanel(t){if(e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),e.expandedSections.delete(t)}e.toolPanels.delete(t),l&&n.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(t){e.headerContents.has(t.id)?r("TBW074",`Header content "${t.id}" already registered`,n.id):(e.headerContents.set(t.id,t),l&&L(n._renderRoot,e))},unregisterHeaderContent(t){const o=e.headerContentCleanups.get(t);o&&(o(),e.headerContentCleanups.delete(t));const r=e.headerContents.get(t);r?.onDestroy?.(),e.headerContents.delete(t);const l=n._renderRoot.querySelector(`[data-header-content="${t}"]`);l?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(t){e.toolbarContents.has(t.id)?r("TBW075",`Toolbar content "${t.id}" already registered`,n.id):(e.toolbarContents.set(t.id,t),l&&n.refreshShellHeader?.())},unregisterToolbarContent(t){const o=e.toolbarContentCleanups.get(t);o&&(o(),e.toolbarContentCleanups.delete(t));const r=e.toolbarContents.get(t);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(t),l&&n.refreshShellHeader?.()}};return s}function j(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}class W extends p{name="shell";styles="@layer tbw-base{tbw-grid .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden;touch-action:none}}@layer tbw-base{tbw-grid .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:var(--tbw-z-layer-toolpanel, 31);box-shadow:-2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel{position:relative;inset:auto;flex-shrink:0;box-shadow:none;z-index:auto;border-left:none;border-right:none}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel.open{border-left:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel[data-position=left].open{border-left:none;border-right:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel-resize{display:none}tbw-grid .tbw-tool-panel[popover]{position:fixed;inset:auto;width:var(--tbw-tool-panel-width);max-width:calc(100vw - 16px);height:auto;max-height:min(70vh,480px);overflow:hidden auto;margin:4px 0 0;padding:0;border:1px solid var(--tbw-tool-panel-border);border-radius:var(--tbw-border-radius, 6px);box-shadow:0 8px 24px var(--tbw-color-shadow);transition:none;display:none}tbw-grid .tbw-tool-panel[popover]:popover-open,tbw-grid .tbw-tool-panel[popover].open{display:flex;width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel[popover] .tbw-tool-panel-resize{display:none}@supports (anchor-name: --x){tbw-grid .tbw-tool-panel[popover]{top:anchor(bottom);right:anchor(right);left:auto;position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline}tbw-grid .tbw-tool-panel[popover][data-anchor=corner]{top:anchor(top)}tbw-grid .tbw-tool-panel[popover][data-position=left]{left:anchor(left);right:auto}}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:flex-end;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-accordion-header-row{display:flex;align-items:stretch}tbw-grid .tbw-accordion-header-row .tbw-accordion-header{flex:1;min-width:0}tbw-grid .tbw-tool-panel-close--inline{align-self:center;flex-shrink:0;margin-inline-end:8px}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}}";#o;#n;#r;#l;#s;#i;#a;#d=!1;get hasState(){return void 0!==this.#o}ensureState(e){if(this.#o)return;const t={toolPanels:/* @__PURE__ */new Map,headerContents:/* @__PURE__ */new Map,toolbarContents:/* @__PURE__ */new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:/* @__PURE__ */new Set,adapterBoundToolPanelIds:/* @__PURE__ */new Set,lightDomToolbarContentIds:/* @__PURE__ */new Set,apiToolPanelIds:/* @__PURE__ */new Set,apiHeaderContentIds:/* @__PURE__ */new Set,isPanelOpen:!1,expandedSections:/* @__PURE__ */new Set,headerContentCleanups:/* @__PURE__ */new Map,panelCleanups:/* @__PURE__ */new Map,toolbarContentCleanups:/* @__PURE__ */new Map,lightDomContentMoved:!1,dropdownAnchorEl:null,dropdownAnchorName:null};this.#o=t,this.#n=N(t,e)}get shellState(){return this.#o}get shellController(){return this.#n}get isToolPanelOpen(){return!!this.hasState&&this.shellController.isPanelOpen}get expandedToolPanelSections(){return this.hasState?this.shellController.expandedSections:[]}openToolPanel(e,t){this.shellController?.openToolPanel(e,t)}closeToolPanel(){this.shellController?.closeToolPanel()}toggleToolPanel(e){this.shellController?.toggleToolPanel(e)}toggleToolPanelSection(e){this.shellController?.toggleToolPanelSection(e)}getToolPanels(){return this.hasState?this.shellController.getToolPanels():[]}registerToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.add(e.id),this.shellController.registerToolPanel(e))}unregisterToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.delete(e),this.shellController.unregisterToolPanel(e))}getHeaderContents(){return this.hasState?this.shellController.getHeaderContents():[]}registerHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.add(e.id),this.shellController.registerHeaderContent(e))}unregisterHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.delete(e),this.shellController.unregisterHeaderContent(e))}getToolbarContents(){return this.hasState?this.shellController.getToolbarContents():[]}registerToolbarContent(e){this.shellController?.registerToolbarContent(e)}unregisterToolbarContent(e){this.shellController?.unregisterToolbarContent(e)}attach(e){super.attach(e);const t=()=>this.#c(e);this.#i=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#h(e){const t=e._hostElement;O(t,this.shellState),E(t,this.shellState),_(t,this.shellState,e._getToolPanelRendererFactory())}#c(e){if(!this.hasState)return;const t=this.shellState,o=t.lightDomTitle,n=t.hasToolButtonsContainer;this.#h(e);const r=t.lightDomTitle,l=t.hasToolButtonsContainer;(r&&!o||l&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(I(t),this.afterStructuralRender()))}_parseLightDomHeader(e){const t=e._hostElement;O(t,this.shellState),E(t,this.shellState)}_parseLightDomToolPanels(e){_(e._hostElement,this.shellState,e._getToolPanelRendererFactory())}_parseLightDomAll(e){this._parseLightDomHeader(e),this._parseLightDomToolPanels(e)}_prepareForRerender(){this.hasState&&I(this.shellState)}_renderOpenPanelContent(e){this.hasState&&R(e._renderRoot,this.shellState)}_shouldRenderHeader(e){return S(e)}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.resolvedConfig;if(e.shell={...o,...e.shell},e.shell.header={...o.header,...e.shell.header},t.lightDomTitle&&!e.shell.header.title&&(e.shell.header.title=t.lightDomTitle),t.lightDomHeaderContent?.length>0&&(e.shell.header.lightDomContent=t.lightDomHeaderContent),t.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0),t.toolPanels.size>0){const o=Array.from(t.toolPanels.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=o}if(t.headerContents.size>0){const o=Array.from(t.headerContents.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=o}const n=Array.from(t.toolbarContents.values()),r=this.grid?._sourceConfig?.shell?.header?.toolbarContents??[],l=new Set(r.map(e=>e.id)),s=[...r];for(const i of n)l.has(i.id)||s.push(i);s.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=s}afterStructuralRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;B(e._renderRoot,e.effectiveConfig?.shell,{isPanelOpen:t.isPanelOpen,expandedSections:t.expandedSections},e.effectiveConfig?.icons)&&(this.#p(e),this.shellController.setInitialized(!0),this.#u(e))}afterRender(){const e=this.grid;e&&this.hasState&&(this.shellState.isPanelOpen?(this.shellController.reanchorOpenDropdown(),this.#g(e)):this.#b())}#g(e){"dropdown"===e.effectiveConfig?.shell?.toolPanel?.mode?"undefined"!=typeof MutationObserver&&(this.#a||(this.#a=new MutationObserver(()=>{this.grid&&this.hasState&&this.shellState.isPanelOpen?this.shellController.reanchorOpenDropdown():this.#b()})),this.#d||(this.#a.observe(e._renderRoot,{childList:!0,subtree:!0}),this.#d=!0)):this.#b()}#b(){this.#a&&this.#d&&(this.#a.disconnect(),this.#d=!1)}#u(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;L(o,t),function(e,t,o){const n=t?.header?.toolbarContents??[],r=[...o.toolbarContents.values()],l=new Set(n.map(e=>e.id)),s=[...n];for(const i of r)l.has(i.id)||s.push(i);for(const i of s){if(o.toolbarContentCleanups.has(i.id))continue;if(!i.render)continue;const t=e.querySelector(`[data-toolbar-content="${i.id}"]`);if(!t)continue;const n=i.render(t);n&&o.toolbarContentCleanups.set(i.id,n)}}(o,n,t);const r=n?.toolPanel,l=r?.defaultOpen;l&&t.toolPanels.has(l)&&t.expandedSections.add(l);const s=!0===r?.locked||"open"===r?.initialState||void 0===r?.initialState&&void 0!==l&&t.toolPanels.has(l);!t.isPanelOpen&&t.toolPanels.size>0&&s&&this.openToolPanel(),t.isPanelOpen&&(H(o,t),R(o,t,(e.effectiveConfig,e.effectiveConfig)),A(o,t),this.shellController.reanchorOpenDropdown())}#p(e){const t=e._renderRoot,o=e.effectiveConfig?.shell,n=this.shellState;!function(e,t,o,n){const r=e.querySelector(".tbw-shell-toolbar");r&&r.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&n.onPanelToggle()});const l=e.querySelector(".tbw-tool-panel");l&&n.onPanelClose&&l.addEventListener("click",e=>{e.target.closest("[data-panel-close]")&&n.onPanelClose()});const s=e.querySelector(".tbw-accordion");s&&s.addEventListener("click",e=>{const t=e.target.closest(".tbw-accordion-header");if(t){const e=t.closest("[data-section]"),o=e?.getAttribute("data-section");o&&n.onSectionToggle(o)}})}(t,0,0,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onPanelClose:()=>this.closeToolPanel()}),this.#r?.(),this.#r=function(e,t,o){const n=e.querySelector(".tbw-tool-panel"),r=e.querySelector("[data-resize-handle]"),l=e.querySelector(".tbw-shell-body");if(!n||!r||!l)return()=>{};const s=t?.toolPanel?.position??"right";let i=0,a=0,d=0,c=!1;const h=e=>{if(!c)return;e.preventDefault();const t="left"===s?e.clientX-i:i-e.clientX,o=Math.min(d,Math.max(200,a+t));n.style.width=`${o}px`},p=()=>{if(!c)return;c=!1,r.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=n.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)},u=e=>{e.preventDefault(),c=!0,i=e.clientX,a=n.getBoundingClientRect().width,d=l.getBoundingClientRect().width-20,r.classList.add("resizing"),n.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)};return r.addEventListener("mousedown",u),()=>{r.removeEventListener("mousedown",u),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)}}(t,o,t=>{e._hostElement.style.setProperty("--tbw-tool-panel-width",`${t}px`)}),this.#l?.(),this.#l=function(e,t,o,n){const r=t?.toolPanel?.mode;if("dropdown"!==r&&!t?.toolPanel?.closeOnClickOutside)return()=>{};if("push"===r)return()=>{};const l=t=>{if(!o.isPanelOpen)return;const r=o.dropdownAnchorEl;for(const o of t.composedPath()){if(null!=r&&o===r)return;if(o instanceof Element&&(o.classList?.contains("tbw-tool-panel")||o.matches?.("[data-panel-toggle]"))&&D(o,e))return}n()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)}(e._hostElement,o,n,()=>this.closeToolPanel()),this.#s?.(),this.#s=function(e,t,o){if("push"===e?.toolPanel?.mode)return()=>{};const n=e=>{"Escape"!==e.key||e.defaultPrevented||t.isPanelOpen&&o()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}(o,n,()=>this.closeToolPanel())}#f(){this.#r?.(),this.#r=void 0,this.#l?.(),this.#l=void 0,this.#s?.(),this.#s=void 0}detach(){super.detach()}disposeShellState(){this.#f(),this.#b(),this.#a=void 0;const e=this.grid;e&&this.#i&&(e._unregisterLightDomHandler("tbw-grid-header"),e._unregisterLightDomHandler("tbw-grid-tool-buttons"),e._unregisterLightDomHandler("tbw-grid-tool-panel"),this.#i=void 0),this.#o&&(!function(e){for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.toolbarContents.values())t.onDestroy?.();if(e.isPanelOpen)for(const t of e.expandedSections){const o=e.toolPanels.get(t);o?.onClose?.()}e.isPanelOpen=!1,e.expandedSections.clear(),e.toolPanels.clear(),e.headerContents.clear(),e.toolbarContents.clear(),e.lightDomHeaderContent=[],e.lightDomToolPanelIds.clear(),e.adapterBoundToolPanelIds.clear(),e.lightDomToolbarContentIds.clear(),e.lightDomContentMoved=!1}(this.#o),this.#n?.setInitialized(!1))}}export{W as ShellPlugin};
1
+ function e(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const t="TBW072",o="TBW073";function n(t,o,n,r){return`${e(n,r)} ${t}: ${o}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(t)}`}function r(e,t,o,r){console.warn(n(e,t,o,r))}const l="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${l.slice(3).join("|")}|this\\b`);const s=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".split("|")),i=/^on\w+$/i,a=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),d=/^\s*(javascript|vbscript|data|blob):/i;function c(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],o=e.querySelectorAll("*");for(const n of o){const e=n.tagName.toLowerCase();if(s.has(e)){t.push(n);continue}if("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI){if(Array.from(n.attributes).some(e=>i.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}}const o=[];for(const t of n.attributes){const e=t.name.toLowerCase();i.test(e)?o.push(t.name):(a.has(e)&&d.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}const h={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class p{static dependencies;static manifest;aliases;version="2.17.1";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},o={};for(const n of Object.keys(t))o[n]=this;for(const r of e){const e=r.userConfig;for(const[l,s]of Object.entries(e)){if(void 0===s)continue;if(!(l in t)){t[l]=s,o[l]=r;continue}if(t[l]===s)continue;const e=o[l]?.constructor.name??this.constructor.name,i=r.constructor.name,a=n("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${l}" supplied by both ${e} and ${i}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig;for(const o of Object.keys(t))delete t[o];Object.assign(t,e.userConfig)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const o=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...h,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(t,10);if(!isNaN(o))return o}return 200}setIcon(e,t,o){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,o);void 0!==n?"string"==typeof n?e.innerHTML=c(n):n instanceof HTMLElement&&(e.innerHTML="",e.appendChild(n.cloneNode(!0))):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(o,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(o,n):e.appendChild(o),o}warn(t,o){void 0!==o?console.warn(n(t,o,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(e,t){throw new Error(n(e,t,this.gridElement.id,this.name))}}const u="tbw-grid-root";function g(e,t){if(t)for(const o in t){const n=t[o];null!=n&&e.setAttribute(o,n)}}function b(e,t,o){const n=document.createElement(e);return g(n,t),n}function f(e,t){const o=document.createElement("div");return e&&(o.className=e),g(o,t),o}function w(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),g(n,t),n}const m=document.createElement("template");function C(){return m.content.cloneNode(!0)}function v(e){const t=document.createDocumentFragment(),o=f(e.hasShell?`${u} has-shell`:u);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=f("tbw-grid-content");e.appendChild(C()),o.appendChild(e)}return t.appendChild(o),t}function y(e){const t=f("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=f("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=f("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=f("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const s of e.configButtons)s.hasRender&&n.appendChild(f("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));for(const s of e.apiButtons)s.hasRender&&n.appendChild(f("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));const r=e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender),l=e.hasPanels&&!1!==e.showToggle;if(r&&l&&n.appendChild(f("tbw-toolbar-separator")),l){const t=w(e.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(e.isPanelOpen),"aria-controls":"tbw-tool-panel"});t.dataset.icon="tool-panel",void 0!==e.toolPanelIcon&&(t.innerHTML=c(e.toolPanelIcon)),n.appendChild(t)}return t.appendChild(n),t}function P(e){const t=e.mode??"overlay",o=f("tbw-shell-body",{"data-mode":t}),n=e.panels.length>0,r=1===e.panels.length,l=f("tbw-grid-content");l.appendChild(C());let s=null;if(n){s=b("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel",..."dropdown"===t?{popover:"manual"}:{}});const o="left"===e.position?"right":"left";s.appendChild(f("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":o,"aria-hidden":"true"}));const n=e=>{const t=w(e?"tbw-tool-panel-close tbw-tool-panel-close--inline":"tbw-tool-panel-close",{part:"tool-panel-close","data-panel-close":"",title:"Close panel","aria-label":"Close panel","aria-controls":"tbw-tool-panel"});return t.textContent="✕",t},l=!0===e.showCloseButton&&r;if(e.showCloseButton&&!r){const e=f("tbw-tool-panel-header",{part:"tool-panel-header"});e.appendChild(n(!1)),s.appendChild(e)}const i=f("tbw-tool-panel-content",{role:"presentation"}),a=f("tbw-accordion");for(const t of e.panels){const o=f(`tbw-accordion-section${t.isExpanded?" expanded":""}${r?" single":""}${l?" has-inline-close":""}`,{"data-section":t.id}),s=w("tbw-accordion-header",{"aria-expanded":String(t.isExpanded),"aria-controls":`tbw-section-${t.id}`});if(r&&s.setAttribute("aria-disabled","true"),t.icon){const e=b("span",{class:"tbw-accordion-icon"});e.innerHTML=c(t.icon),s.appendChild(e)}const i=b("span",{class:"tbw-accordion-title"});if(i.textContent=t.title,s.appendChild(i),!r){const t=b("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=c(e.expandIcon)),s.appendChild(t)}if(l){const e=f("tbw-accordion-header-row");e.appendChild(s),e.appendChild(n(!0)),o.appendChild(e)}else o.appendChild(s);o.appendChild(f("tbw-accordion-content",{id:`tbw-section-${t.id}`,role:"presentation"})),a.appendChild(o)}i.appendChild(a),s.appendChild(i)}return"left"===e.position&&s?(o.appendChild(s),o.appendChild(l)):(o.appendChild(l),s&&o.appendChild(s)),o}function x(e){return e?"string"==typeof e?c(e):e.outerHTML:""}function S(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function T(e){return!1!==e?.header?.visible}function O(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const n=o.querySelectorAll("tbw-grid-header-content");n.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(n)),o.style.display="none"}function E(e,t,o){const n=e.querySelector(":scope > tbw-grid-tool-buttons");if(!n)return;t.hasToolButtonsContainer=!0;const r="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(r))return;const l={id:r,order:0,render:e=>{for(;n.firstChild;)e.appendChild(n.firstChild);return()=>{for(;e.firstChild;)n.appendChild(e.firstChild)}}};t.toolbarContents.set(r,l),t.lightDomToolbarContentIds.add(r),n.style.display="none"}function _(e,t,n){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const l=e,s=l.getAttribute("id"),i=l.getAttribute("title");if(!s||!i)return void r("TBW070",`Tool panel missing required id or title attribute: id="${s??""}", title="${i??""}"`);const a=l.getAttribute("icon")??void 0,d=l.getAttribute("tooltip")??void 0,h=parseInt(l.getAttribute("order")??"100",10);let p;const u=n?.(l);if(u)p=u;else{const e=c(l.innerHTML.trim());p=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const g=t.toolPanels.get(s);if(g&&!t.lightDomToolPanelIds.has(s))return r(o,`Tool panel "${s}" is already provided by a plugin or the grid API; ignoring the matching light-DOM <tbw-grid-tool-panel>.`),void(l.style.display="none");if(g){if(u){const e=!t.adapterBoundToolPanelIds.has(s),o=g.order!==h||g.icon!==a||g.tooltip!==d;if(g.render=p,g.order=h,g.icon=a,g.tooltip=d,t.adapterBoundToolPanelIds.add(s),e||o){const e=t.panelCleanups.get(s);e&&(e(),t.panelCleanups.delete(s))}}return}const b={id:s,title:i,icon:a,tooltip:d,order:h,render:p};t.toolPanels.set(s,b),t.lightDomToolPanelIds.add(s),u&&t.adapterBoundToolPanelIds.add(s),l.style.display="none"})}function D(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function L(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,n=t.headerContents.size>0;if(!o&&!n)return;const r=e.querySelector(".tbw-shell-content");if(!r)return;if(o){for(const e of t.lightDomHeaderContent)e.style.display="",r.appendChild(e);t.lightDomContentMoved=!0}const l=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of l){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let o=r.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),r.appendChild(o));const n=s.render(o);n&&t.headerContentCleanups.set(s.id,n)}}function R(e,t,o){if(t.isPanelOpen)for(const[n,r]of t.toolPanels){const o=t.expandedSections.has(n),l=e.querySelector(`[data-section="${n}"]`),s=l?.querySelector(".tbw-accordion-content");if(!l||!s)continue;l.classList.toggle("expanded",o);const i=l.querySelector(".tbw-accordion-header");if(i&&i.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=r.render(s);e&&t.panelCleanups.set(n,e)}}else{const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n)),s.innerHTML=""}}}function A(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function H(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}m.innerHTML='\n <div class="tbw-scroll-area">\n <div class="rows-body-wrapper">\n <div class="rows-body" role="grid">\n <div class="header" role="rowgroup">\n <div class="header-row" role="row" part="header-row"></div>\n </div>\n <div class="rows-container" role="presentation">\n <div class="rows-viewport" role="presentation">\n <div class="rows"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class="faux-vscroll">\n <div class="faux-vscroll-spacer"></div>\n </div>\n <div class="tbw-sr-only" aria-live="polite" aria-atomic="true"></div>\n';const k="--tbw-tool-panel-anchor";let q=0;function $(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",k)}function z(e,t,o,n){const r=e.querySelector(".tbw-tool-panel");if(r){if(t.dropdownAnchorEl=o,r.dataset.anchor=n?"corner":"below",r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}if($()){const e=`${k}-${++q}`;t.dropdownAnchorName=e,o.style.setProperty("anchor-name",e),r.style.setProperty("position-anchor",e),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right")}else!function(e,t,o){const n=t.getBoundingClientRect(),r=e.getAttribute("data-position")??"right";if(e.style.position="fixed",e.style.top=`${Math.round((o?n.top:n.bottom)+4)}px`,"left"===r)e.style.left=`${Math.round(n.left)}px`,e.style.right="auto";else{const t="undefined"!=typeof window?window.innerWidth:0;e.style.left="auto",e.style.right=`${Math.round(t-n.right)}px`}}(r,o,n)}}function I(e){for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear(),e.lightDomContentMoved=!1}function M(e,t,o){const n=void 0!==o?.toolPanel?x(o.toolPanel):void 0,r=void 0!==o?.expand?x(o.expand):void 0,l=void 0!==o?.collapse?x(o.collapse):void 0,s=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),i=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:i.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:n,showToggle:!1!==e.header?.toolPanelToggle&&!0!==e.toolPanel?.locked,configButtons:s.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},bodyOptions:{position:e.toolPanel?.position??"right",mode:e.toolPanel?.mode??"overlay",isPanelOpen:t.isPanelOpen,expandIcon:r,collapseIcon:l,showCloseButton:!1===e.header?.visible&&!0!==e.toolPanel?.locked&&"dropdown"!==(e.toolPanel?.mode??"overlay"),panels:i.map(e=>({id:e.id,title:e.title,icon:x(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function B(e,t,o,n){const r=e.querySelector(`.${u}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=S(t),l=[];for(let s=e.firstChild;s;s=s.nextSibling)1===s.nodeType&&s.classList.contains(u)||l.push(s);e.replaceChildren();for(const s of l)e.appendChild(s);if(r){const{headerOptions:r,bodyOptions:l}=M(t,o,n),s=v({hasShell:!0,shellHeader:T(t)?y(r):void 0,shellBody:P(l)});e.appendChild(s)}else{const t=v({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const s=S(t);if(r.replaceChildren(),s){r.className=`${u} has-shell`;const{headerOptions:e,bodyOptions:s}=M(t,o,n),i=T(t)?y(e):void 0,a=P(s),d=a.querySelector(".tbw-grid-content");d&&d.replaceWith(l),i&&r.appendChild(i),r.appendChild(a)}else r.className=u,r.appendChild(l);return s}function N(e,n){let l=!1;const s={get isInitialized(){return l},setInitialized(e){l=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(o,l){if(0===e.toolPanels.size)return void r("TBW071","No tool panels registered",n.id);let i;if(void 0!==o&&(e.toolPanels.has(o)?i=o:r(t,`Tool panel "${o}" not found`,n.id)),e.isPanelOpen&&i&&e.expandedSections.has(i))return;if(e.isPanelOpen&&i&&!e.expandedSections.has(i))return void s.toggleToolPanelSection(i);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(i)e.expandedSections.add(i);else{const t=n.effectiveConfig?.shell?.toolPanel?.defaultOpen;if(t&&e.toolPanels.has(t))e.expandedSections.add(t);else{const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}}else if(i&&!e.expandedSections.has(i)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(i)}const a=n._renderRoot;if(A(a,e),H(a,e),R(a,e,n._accordionIcons),"dropdown"===n.effectiveConfig?.shell?.toolPanel?.mode){const{el:t,corner:o}=function(e){if(e)return{el:e,corner:!1};const t=n._renderRoot.querySelector("[data-panel-toggle]");return t?{el:t,corner:!1}:{el:n._hostElement,corner:!0}}(l?.anchor);z(a,e,t,o)}n._emit("tool-panel-open",{sections:s.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(n.effectiveConfig?.shell?.toolPanel?.locked)return;for(const o of e.panelCleanups.values())o();e.panelCleanups.clear();for(const o of e.toolPanels.values())o.onClose?.();e.isPanelOpen=!1;const t=n._renderRoot;A(t,e),H(t,e),"dropdown"===n.effectiveConfig?.shell?.toolPanel?.mode&&function(e,t){const o=e.querySelector(".tbw-tool-panel");if(o){if(o.hasAttribute("popover")&&"function"==typeof o.hidePopover)try{o.hidePopover()}catch{}o.style.removeProperty("position-anchor"),o.style.removeProperty("position"),o.style.removeProperty("top"),o.style.removeProperty("left"),o.style.removeProperty("right"),delete o.dataset.anchor}t.dropdownAnchorEl&&(t.dropdownAnchorEl.style.removeProperty("anchor-name"),t.dropdownAnchorEl=null),t.dropdownAnchorName=null}(t,e),n._emit("tool-panel-close",{})},toggleToolPanel(t){e.isPanelOpen?s.closeToolPanel():s.openToolPanel(void 0,t)},reanchorOpenDropdown(){if(!e.isPanelOpen)return;if("dropdown"!==n.effectiveConfig?.shell?.toolPanel?.mode)return;const t=e.dropdownAnchorEl;if(t&&t.isConnected&&e.dropdownAnchorName&&t.style.getPropertyValue("anchor-name")===e.dropdownAnchorName)return;if(!e.dropdownAnchorName&&t&&t.isConnected&&t!==n._hostElement){const e=n._renderRoot.querySelector(".tbw-tool-panel");if("below"===e?.dataset.anchor)return}const o=n._renderRoot.querySelector("[data-panel-toggle]");if(o&&o!==n._hostElement){if(e.dropdownAnchorName&&$()&&function(e,t,o){const n=t.dropdownAnchorName;if(!n)return!1;const r=e.querySelector(".tbw-tool-panel");if(!r)return!1;const l=t.dropdownAnchorEl;if(l&&l!==o&&l.style.removeProperty("anchor-name"),o.style.setProperty("anchor-name",n),r.style.setProperty("position-anchor",n),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right"),r.dataset.anchor="below",t.dropdownAnchorEl=o,r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}return!0}(n._renderRoot,e,o))return;z(n._renderRoot,e,o,!1)}else t!==n._hostElement||z(n._renderRoot,e,n._hostElement,!0)},toggleToolPanelSection(o){const l=e.toolPanels.get(o);if(!l)return void r(t,`Tool panel section "${o}" not found`,n.id);if(1===e.toolPanels.size)return;const s=n._renderRoot,i=e.expandedSections.has(o);if(i){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),l.onClose?.(),e.expandedSections.delete(o),j(s,o,!1)}else{for(const[t,n]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),n.onClose?.(),e.expandedSections.delete(t),j(s,t,!1);const r=s.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),j(s,o,!0),function(e,t,o){const n=t.toolPanels.get(o);if(!n?.render)return;const r=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!r)return;const l=n.render(r);l&&t.panelCleanups.set(o,l)}(s,e,o)}n._emit("tool-panel-section-toggle",{id:o,expanded:!i})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(t){e.toolPanels.has(t.id)?r(o,`Tool panel "${t.id}" already registered`,n.id):(e.toolPanels.set(t.id,t),l&&n.refreshShellHeader?.())},unregisterToolPanel(t){if(e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),e.expandedSections.delete(t)}e.toolPanels.delete(t),l&&n.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(t){e.headerContents.has(t.id)?r("TBW074",`Header content "${t.id}" already registered`,n.id):(e.headerContents.set(t.id,t),l&&L(n._renderRoot,e))},unregisterHeaderContent(t){const o=e.headerContentCleanups.get(t);o&&(o(),e.headerContentCleanups.delete(t));const r=e.headerContents.get(t);r?.onDestroy?.(),e.headerContents.delete(t);const l=n._renderRoot.querySelector(`[data-header-content="${t}"]`);l?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(t){e.toolbarContents.has(t.id)?r("TBW075",`Toolbar content "${t.id}" already registered`,n.id):(e.toolbarContents.set(t.id,t),l&&n.refreshShellHeader?.())},unregisterToolbarContent(t){const o=e.toolbarContentCleanups.get(t);o&&(o(),e.toolbarContentCleanups.delete(t));const r=e.toolbarContents.get(t);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(t),l&&n.refreshShellHeader?.()}};return s}function j(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}class W extends p{name="shell";styles="@layer tbw-base{tbw-grid .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden;touch-action:none}}@layer tbw-base{tbw-grid .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:var(--tbw-z-layer-toolpanel, 31);box-shadow:-2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel{position:relative;inset:auto;flex-shrink:0;box-shadow:none;z-index:auto;border-left:none;border-right:none}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel.open{border-left:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel[data-position=left].open{border-left:none;border-right:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel-resize{display:none}tbw-grid .tbw-tool-panel[popover]{position:fixed;inset:auto;width:var(--tbw-tool-panel-width);max-width:calc(100vw - 16px);height:auto;max-height:min(70vh,480px);overflow:hidden auto;margin:4px 0 0;padding:0;border:1px solid var(--tbw-tool-panel-border);border-radius:var(--tbw-border-radius, 6px);box-shadow:0 8px 24px var(--tbw-color-shadow);transition:none;display:none}tbw-grid .tbw-tool-panel[popover]:popover-open,tbw-grid .tbw-tool-panel[popover].open{display:flex;width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel[popover] .tbw-tool-panel-resize{display:none}@supports (anchor-name: --x){tbw-grid .tbw-tool-panel[popover]{top:anchor(bottom);right:anchor(right);left:auto;position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline}tbw-grid .tbw-tool-panel[popover][data-anchor=corner]{top:anchor(top)}tbw-grid .tbw-tool-panel[popover][data-position=left]{left:anchor(left);right:auto}}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:flex-end;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-accordion-header-row{display:flex;align-items:stretch}tbw-grid .tbw-accordion-header-row .tbw-accordion-header{flex:1;min-width:0}tbw-grid .tbw-tool-panel-close--inline{align-self:center;flex-shrink:0;margin-inline-end:8px}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}}";#o;#n;#r;#l;#s;#i;#a;#d=!1;get hasState(){return void 0!==this.#o}ensureState(e){if(this.#o)return;const t={toolPanels:/* @__PURE__ */new Map,headerContents:/* @__PURE__ */new Map,toolbarContents:/* @__PURE__ */new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:/* @__PURE__ */new Set,adapterBoundToolPanelIds:/* @__PURE__ */new Set,lightDomToolbarContentIds:/* @__PURE__ */new Set,apiToolPanelIds:/* @__PURE__ */new Set,apiHeaderContentIds:/* @__PURE__ */new Set,isPanelOpen:!1,expandedSections:/* @__PURE__ */new Set,headerContentCleanups:/* @__PURE__ */new Map,panelCleanups:/* @__PURE__ */new Map,toolbarContentCleanups:/* @__PURE__ */new Map,lightDomContentMoved:!1,dropdownAnchorEl:null,dropdownAnchorName:null};this.#o=t,this.#n=N(t,e)}get shellState(){return this.#o}get shellController(){return this.#n}get isToolPanelOpen(){return!!this.hasState&&this.shellController.isPanelOpen}get expandedToolPanelSections(){return this.hasState?this.shellController.expandedSections:[]}openToolPanel(e,t){this.shellController?.openToolPanel(e,t)}closeToolPanel(){this.shellController?.closeToolPanel()}toggleToolPanel(e){this.shellController?.toggleToolPanel(e)}toggleToolPanelSection(e){this.shellController?.toggleToolPanelSection(e)}getToolPanels(){return this.hasState?this.shellController.getToolPanels():[]}registerToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.add(e.id),this.shellController.registerToolPanel(e))}unregisterToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.delete(e),this.shellController.unregisterToolPanel(e))}getHeaderContents(){return this.hasState?this.shellController.getHeaderContents():[]}registerHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.add(e.id),this.shellController.registerHeaderContent(e))}unregisterHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.delete(e),this.shellController.unregisterHeaderContent(e))}getToolbarContents(){return this.hasState?this.shellController.getToolbarContents():[]}registerToolbarContent(e){this.shellController?.registerToolbarContent(e)}unregisterToolbarContent(e){this.shellController?.unregisterToolbarContent(e)}attach(e){super.attach(e);const t=()=>this.#c(e);this.#i=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#h(e){const t=e._hostElement;O(t,this.shellState),E(t,this.shellState),_(t,this.shellState,e._getToolPanelRendererFactory())}#c(e){if(!this.hasState)return;const t=this.shellState,o=t.lightDomTitle,n=t.hasToolButtonsContainer;this.#h(e);const r=t.lightDomTitle,l=t.hasToolButtonsContainer;(r&&!o||l&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(I(t),this.afterStructuralRender()))}_parseLightDomHeader(e){const t=e._hostElement;O(t,this.shellState),E(t,this.shellState)}_parseLightDomToolPanels(e){_(e._hostElement,this.shellState,e._getToolPanelRendererFactory())}_parseLightDomAll(e){this._parseLightDomHeader(e),this._parseLightDomToolPanels(e)}_prepareForRerender(){this.hasState&&I(this.shellState)}_renderOpenPanelContent(e){this.hasState&&R(e._renderRoot,this.shellState)}_shouldRenderHeader(e){return S(e)}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.resolvedConfig;if(e.shell={...o,...e.shell},e.shell.header={...o.header,...e.shell.header},t.lightDomTitle&&!e.shell.header.title&&(e.shell.header.title=t.lightDomTitle),t.lightDomHeaderContent?.length>0&&(e.shell.header.lightDomContent=t.lightDomHeaderContent),t.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0),t.toolPanels.size>0){const o=Array.from(t.toolPanels.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=o}if(t.headerContents.size>0){const o=Array.from(t.headerContents.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=o}const n=Array.from(t.toolbarContents.values()),r=this.grid?._sourceConfig?.shell?.header?.toolbarContents??[],l=new Set(r.map(e=>e.id)),s=[...r];for(const i of n)l.has(i.id)||s.push(i);s.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=s}afterStructuralRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;B(e._renderRoot,e.effectiveConfig?.shell,{isPanelOpen:t.isPanelOpen,expandedSections:t.expandedSections},e.effectiveConfig?.icons)&&(this.#p(e),this.shellController.setInitialized(!0),this.#u(e))}afterRender(){const e=this.grid;e&&this.hasState&&(this.shellState.isPanelOpen?(this.shellController.reanchorOpenDropdown(),this.#g(e)):this.#b())}#g(e){"dropdown"===e.effectiveConfig?.shell?.toolPanel?.mode?"undefined"!=typeof MutationObserver&&(this.#a||(this.#a=new MutationObserver(()=>{this.grid&&this.hasState&&this.shellState.isPanelOpen?this.shellController.reanchorOpenDropdown():this.#b()})),this.#d||(this.#a.observe(e._renderRoot,{childList:!0,subtree:!0}),this.#d=!0)):this.#b()}#b(){this.#a&&this.#d&&(this.#a.disconnect(),this.#d=!1)}#u(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;L(o,t),function(e,t,o){const n=t?.header?.toolbarContents??[],r=[...o.toolbarContents.values()],l=new Set(n.map(e=>e.id)),s=[...n];for(const i of r)l.has(i.id)||s.push(i);for(const i of s){if(o.toolbarContentCleanups.has(i.id))continue;if(!i.render)continue;const t=e.querySelector(`[data-toolbar-content="${i.id}"]`);if(!t)continue;const n=i.render(t);n&&o.toolbarContentCleanups.set(i.id,n)}}(o,n,t);const r=n?.toolPanel,l=r?.defaultOpen;l&&t.toolPanels.has(l)&&t.expandedSections.add(l);const s=!0===r?.locked||"open"===r?.initialState||void 0===r?.initialState&&void 0!==l&&t.toolPanels.has(l);!t.isPanelOpen&&t.toolPanels.size>0&&s&&this.openToolPanel(),t.isPanelOpen&&(H(o,t),R(o,t,(e.effectiveConfig,e.effectiveConfig)),A(o,t),this.shellController.reanchorOpenDropdown())}#p(e){const t=e._renderRoot,o=e.effectiveConfig?.shell,n=this.shellState;!function(e,t,o,n){const r=e.querySelector(".tbw-shell-toolbar");r&&r.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&n.onPanelToggle()});const l=e.querySelector(".tbw-tool-panel");l&&n.onPanelClose&&l.addEventListener("click",e=>{e.target.closest("[data-panel-close]")&&n.onPanelClose()});const s=e.querySelector(".tbw-accordion");s&&s.addEventListener("click",e=>{const t=e.target.closest(".tbw-accordion-header");if(t){const e=t.closest("[data-section]"),o=e?.getAttribute("data-section");o&&n.onSectionToggle(o)}})}(t,0,0,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onPanelClose:()=>this.closeToolPanel()}),this.#r?.(),this.#r=function(e,t,o){const n=e.querySelector(".tbw-tool-panel"),r=e.querySelector("[data-resize-handle]"),l=e.querySelector(".tbw-shell-body");if(!n||!r||!l)return()=>{};const s=t?.toolPanel?.position??"right";let i=0,a=0,d=0,c=!1;const h=e=>{if(!c)return;e.preventDefault();const t="left"===s?e.clientX-i:i-e.clientX,o=Math.min(d,Math.max(200,a+t));n.style.width=`${o}px`},p=()=>{if(!c)return;c=!1,r.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=n.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)},u=e=>{e.preventDefault(),c=!0,i=e.clientX,a=n.getBoundingClientRect().width,d=l.getBoundingClientRect().width-20,r.classList.add("resizing"),n.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)};return r.addEventListener("mousedown",u),()=>{r.removeEventListener("mousedown",u),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)}}(t,o,t=>{e._hostElement.style.setProperty("--tbw-tool-panel-width",`${t}px`)}),this.#l?.(),this.#l=function(e,t,o,n){const r=t?.toolPanel?.mode;if("dropdown"!==r&&!t?.toolPanel?.closeOnClickOutside)return()=>{};if("push"===r)return()=>{};const l=t=>{if(!o.isPanelOpen)return;const r=o.dropdownAnchorEl;for(const o of t.composedPath()){if(null!=r&&o===r)return;if(o instanceof Element&&(o.classList?.contains("tbw-tool-panel")||o.matches?.("[data-panel-toggle]"))&&D(o,e))return}n()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)}(e._hostElement,o,n,()=>this.closeToolPanel()),this.#s?.(),this.#s=function(e,t,o){if("push"===e?.toolPanel?.mode)return()=>{};const n=e=>{"Escape"!==e.key||e.defaultPrevented||t.isPanelOpen&&o()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}(o,n,()=>this.closeToolPanel())}#f(){this.#r?.(),this.#r=void 0,this.#l?.(),this.#l=void 0,this.#s?.(),this.#s=void 0}detach(){super.detach()}disposeShellState(){this.#f(),this.#b(),this.#a=void 0;const e=this.grid;e&&this.#i&&(e._unregisterLightDomHandler("tbw-grid-header"),e._unregisterLightDomHandler("tbw-grid-tool-buttons"),e._unregisterLightDomHandler("tbw-grid-tool-panel"),this.#i=void 0),this.#o&&(!function(e){for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.toolbarContents.values())t.onDestroy?.();if(e.isPanelOpen)for(const t of e.expandedSections){const o=e.toolPanels.get(t);o?.onClose?.()}e.isPanelOpen=!1,e.expandedSections.clear(),e.toolPanels.clear(),e.headerContents.clear(),e.toolbarContents.clear(),e.lightDomHeaderContent=[],e.lightDomToolPanelIds.clear(),e.adapterBoundToolPanelIds.clear(),e.lightDomToolbarContentIds.clear(),e.lightDomContentMoved=!1}(this.#o),this.#n?.setInitialized(!1))}}export{W as ShellPlugin};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function e(e,i,s,n){return`${t(s,n)} ${e}: ${i}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}const i="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${i.slice(3).join("|")}|this\\b`);const s=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".split("|")),n=/^on\w+$/i,r=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),o=/^\s*(javascript|vbscript|data|blob):/i;function c(t){if(!t||"string"!=typeof t)return"";if(-1===t.indexOf("<"))return t;const e=document.createElement("template");return e.innerHTML=t,function(t){const e=[],i=t.querySelectorAll("*");for(const c of i){const t=c.tagName.toLowerCase();if(s.has(t)){e.push(c);continue}if("svg"===t||"http://www.w3.org/2000/svg"===c.namespaceURI){if(Array.from(c.attributes).some(t=>n.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(c);continue}}const i=[];for(const e of c.attributes){const t=e.name.toLowerCase();n.test(t)?i.push(e.name):(r.has(t)&&o.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&i.push(e.name)}i.forEach(t=>c.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content),e.innerHTML}const a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class l{static dependencies;static manifest;aliases;version="2.17.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}get resolvedConfig(){return this.#t?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(t){if(0===t.length)return;const i={...this.userConfig},s={};for(const e of Object.keys(i))s[e]=this;for(const n of t){const t=n.userConfig;for(const[r,o]of Object.entries(t)){if(void 0===o)continue;if(!(r in i)){i[r]=o,s[r]=n;continue}if(i[r]===o)continue;const t=s[r]?.constructor.name??this.constructor.name,c=n.constructor.name,a=e("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${r}" supplied by both ${t} and ${c}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,i)}refreshUserConfigFrom(t){const e=this.userConfig;for(const i of Object.keys(e))delete e[i];Object.assign(e,t.userConfig)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...a,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(e,10);if(!isNaN(i))return i}return 200}setIcon(t,e,i){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const s=this.#e(e,i);void 0!==s?"string"==typeof s?t.innerHTML=c(s):s instanceof HTMLElement&&(t.innerHTML="",t.appendChild(s.cloneNode(!0))):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const i=document.createElement("span");i.setAttribute("part","sort-indicator"),i.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(i,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(i,"sortNone"));const s=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return s?t.insertBefore(i,s):t.appendChild(i),i}warn(i,s){void 0!==s?console.warn(e(i,s,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${i}`)}throwDiagnostic(t,i){throw new Error(e(t,i,this.gridElement.id,this.name))}}class h extends l{name="stickyRows";styles="@layer tbw-plugins{.tbw-sticky-rows{position:absolute;top:0;left:0;display:block;z-index:var(--tbw-z-layer-sticky-rows, 22);background:var(--tbw-color-bg, var(--tbw-color-panel-bg));min-width:100%;width:fit-content;overflow:visible}.tbw-sticky-rows:empty{display:none}.tbw-sticky-rows .tbw-sticky-row{box-shadow:0 1px 0 var(--tbw-color-border);background:var(--tbw-color-bg, var(--tbw-color-panel-bg))}.tbw-sticky-rows[data-mode=push] .tbw-sticky-row{will-change:transform}}";get defaultConfig(){return{mode:"push",maxStacked:1/0}}container=null;stickyIndices=[];cloneCache=/* @__PURE__ */new Map;displayedIndices=[];lastPushOffset=0;detach(){this.container?.remove(),this.container=null,this.cloneCache.clear(),this.stickyIndices=[],this.displayedIndices=[],this.lastPushOffset=0}afterRender(){this.recomputeStickyIndices(),this.ensureContainer(),this.primeCloneCache(),this.refreshDisplay()}onScrollRender(){this.primeCloneCache(),this.refreshClonesInWindow(),this.refreshDisplay()}onScroll(t){this.refreshDisplay(t.scrollTop)}resolvePredicate(){const t=this.config.isSticky;if("function"==typeof t)return t;if("string"==typeof t){const e=t;return t=>null!=t&&"object"==typeof t&&Boolean(t[e])}return()=>!1}recomputeStickyIndices(){const t=this.rows,e=this.resolvePredicate(),i=[];for(let s=0;s<t.length;s++)e(t[s],s)&&i.push(s);(i.length!==this.stickyIndices.length||i.some((t,e)=>t!==this.stickyIndices[e]))&&this.cloneCache.clear(),this.stickyIndices=i}ensureContainer(){const t=this.gridElement;if(!t)return;const e=t.querySelector(".rows-viewport");e?this.container&&e.contains(this.container)||(this.container=document.createElement("div"),this.container.className="tbw-sticky-rows",this.container.setAttribute("role","presentation"),this.container.dataset.mode=this.config.mode??"push",this.config.className&&this.container.classList.add(this.config.className),e.insertBefore(this.container,e.firstChild)):this.container=null}offsetOf(t){const e=this.getVirtualState(),i=e?.positionCache;if(i&&i[t])return i[t].offset;return t*(e?.rowHeight??28)}heightOf(t){const e=this.getVirtualState(),i=e?.positionCache;return i&&i[t]?i[t].height:e?.rowHeight??28}getVirtualState(){return this.grid?._virtualization}getCurrentScrollTop(){const t=this.getVirtualState(),e=t?.container?.scrollTop;return"number"==typeof e?e:"number"!=typeof t?.start||"number"!=typeof t?.rowHeight||t.positionCache&&t.positionCache.length?t?.positionCache&&"number"==typeof t.start&&t.positionCache[t.start]?t.positionCache[t.start].offset:0:t.start*t.rowHeight}computeDisplay(t){if("stack"===this.config.mode){const e=this.config.maxStacked??1/0,i=[];let s=0;for(const n of this.stickyIndices)if(i.length<e){if(!(this.offsetOf(n)<t+s))break;i.push(n),s+=this.heightOf(n)}else{const e=this.heightOf(i[0]);if(!(this.offsetOf(n)<t+s-e))break;i.shift(),s-=e,i.push(n),s+=this.heightOf(n)}if(i.length===e&&i.length>0){const e=this.findNextSticky(i[i.length-1]);if(null!=e){const n=this.offsetOf(e)-(t+s);if(n<0){const t=this.heightOf(i[0]);return{indices:i,pushOffset:Math.min(-n,t)}}}}return{indices:i,pushOffset:0}}const e=[];for(const r of this.stickyIndices){if(!(this.offsetOf(r)<t))break;e.push(r)}if(0===e.length)return{indices:e,pushOffset:0};const i=e[e.length-1],s=this.findNextSticky(i);let n=0;if(null!=s){const e=this.heightOf(i),r=this.offsetOf(s)-t;r<e&&(n=e-Math.max(0,r))}return{indices:[i],pushOffset:n}}findRenderedRow(t){const e=this.gridElement;if(!e)return null;const i=e.querySelector(`.rows .data-grid-row .cell[data-row="${t}"]`);return i?.parentElement??null}buildClone(t){const e=this.findRenderedRow(t);if(!e)return this.cloneCache.get(t)??null;const i=e.cloneNode(!0);return i.classList.add("tbw-sticky-row"),i.removeAttribute("aria-rowindex"),i.setAttribute("aria-hidden","true"),i.dataset.stickyRow=String(t),i.classList.remove("row-focus","cell-focus"),i.querySelectorAll(".cell-focus, .row-focus").forEach(t=>t.classList.remove("cell-focus","row-focus")),i.removeAttribute("tabindex"),i.querySelectorAll("[tabindex]").forEach(t=>t.removeAttribute("tabindex")),this.cloneCache.set(t,i),i}refreshClonesInWindow(){if(this.displayedIndices.length)for(const t of this.displayedIndices){if(this.findRenderedRow(t)){const e=this.buildClone(t),i=this.container?.querySelector(`[data-sticky-row="${t}"]`);e&&i&&i!==e&&i.replaceWith(e)}}}primeCloneCache(){if(this.stickyIndices.length)for(const t of this.stickyIndices)this.findRenderedRow(t)&&this.buildClone(t)}refreshDisplay(t){if(!this.container)return;const e=t??this.getCurrentScrollTop(),{indices:i,pushOffset:s}=this.computeDisplay(e);this.container.dataset.mode!==this.config.mode&&(this.container.dataset.mode=this.config.mode??"push");if(!(i.length===this.displayedIndices.length&&i.every((t,e)=>t===this.displayedIndices[e]))){const t=document.createDocumentFragment(),e=[];for(const s of i){let i=this.cloneCache.get(s)??null;i=this.buildClone(s)??i,i&&(t.appendChild(i),e.push(s))}this.container.replaceChildren(t),this.displayedIndices=e}s!==this.lastPushOffset&&(this.container.style.transform=s>0?`translateY(${-s}px)`:"",this.lastPushOffset=s)}findNextSticky(t){for(const e of this.stickyIndices)if(e>t)return e;return null}}export{h as StickyRowsPlugin};
1
+ function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function e(e,i,s,n){return`${t(s,n)} ${e}: ${i}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}const i="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${i.slice(3).join("|")}|this\\b`);const s=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".split("|")),n=/^on\w+$/i,r=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),o=/^\s*(javascript|vbscript|data|blob):/i;function c(t){if(!t||"string"!=typeof t)return"";if(-1===t.indexOf("<"))return t;const e=document.createElement("template");return e.innerHTML=t,function(t){const e=[],i=t.querySelectorAll("*");for(const c of i){const t=c.tagName.toLowerCase();if(s.has(t)){e.push(c);continue}if("svg"===t||"http://www.w3.org/2000/svg"===c.namespaceURI){if(Array.from(c.attributes).some(t=>n.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(c);continue}}const i=[];for(const e of c.attributes){const t=e.name.toLowerCase();n.test(t)?i.push(e.name):(r.has(t)&&o.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&i.push(e.name)}i.forEach(t=>c.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content),e.innerHTML}const a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class l{static dependencies;static manifest;aliases;version="2.17.1";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}get resolvedConfig(){return this.#t?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(t){if(0===t.length)return;const i={...this.userConfig},s={};for(const e of Object.keys(i))s[e]=this;for(const n of t){const t=n.userConfig;for(const[r,o]of Object.entries(t)){if(void 0===o)continue;if(!(r in i)){i[r]=o,s[r]=n;continue}if(i[r]===o)continue;const t=s[r]?.constructor.name??this.constructor.name,c=n.constructor.name,a=e("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${r}" supplied by both ${t} and ${c}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,i)}refreshUserConfigFrom(t){const e=this.userConfig;for(const i of Object.keys(e))delete e[i];Object.assign(e,t.userConfig)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...a,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(e,10);if(!isNaN(i))return i}return 200}setIcon(t,e,i){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const s=this.#e(e,i);void 0!==s?"string"==typeof s?t.innerHTML=c(s):s instanceof HTMLElement&&(t.innerHTML="",t.appendChild(s.cloneNode(!0))):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const i=document.createElement("span");i.setAttribute("part","sort-indicator"),i.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(i,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(i,"sortNone"));const s=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return s?t.insertBefore(i,s):t.appendChild(i),i}warn(i,s){void 0!==s?console.warn(e(i,s,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${i}`)}throwDiagnostic(t,i){throw new Error(e(t,i,this.gridElement.id,this.name))}}class h extends l{name="stickyRows";styles="@layer tbw-plugins{.tbw-sticky-rows{position:absolute;top:0;left:0;display:block;z-index:var(--tbw-z-layer-sticky-rows, 22);background:var(--tbw-color-bg, var(--tbw-color-panel-bg));min-width:100%;width:fit-content;overflow:visible}.tbw-sticky-rows:empty{display:none}.tbw-sticky-rows .tbw-sticky-row{box-shadow:0 1px 0 var(--tbw-color-border);background:var(--tbw-color-bg, var(--tbw-color-panel-bg))}.tbw-sticky-rows[data-mode=push] .tbw-sticky-row{will-change:transform}}";get defaultConfig(){return{mode:"push",maxStacked:1/0}}container=null;stickyIndices=[];cloneCache=/* @__PURE__ */new Map;displayedIndices=[];lastPushOffset=0;detach(){this.container?.remove(),this.container=null,this.cloneCache.clear(),this.stickyIndices=[],this.displayedIndices=[],this.lastPushOffset=0}afterRender(){this.recomputeStickyIndices(),this.ensureContainer(),this.primeCloneCache(),this.refreshDisplay()}onScrollRender(){this.primeCloneCache(),this.refreshClonesInWindow(),this.refreshDisplay()}onScroll(t){this.refreshDisplay(t.scrollTop)}resolvePredicate(){const t=this.config.isSticky;if("function"==typeof t)return t;if("string"==typeof t){const e=t;return t=>null!=t&&"object"==typeof t&&Boolean(t[e])}return()=>!1}recomputeStickyIndices(){const t=this.rows,e=this.resolvePredicate(),i=[];for(let s=0;s<t.length;s++)e(t[s],s)&&i.push(s);(i.length!==this.stickyIndices.length||i.some((t,e)=>t!==this.stickyIndices[e]))&&this.cloneCache.clear(),this.stickyIndices=i}ensureContainer(){const t=this.gridElement;if(!t)return;const e=t.querySelector(".rows-viewport");e?this.container&&e.contains(this.container)||(this.container=document.createElement("div"),this.container.className="tbw-sticky-rows",this.container.setAttribute("role","presentation"),this.container.dataset.mode=this.config.mode??"push",this.config.className&&this.container.classList.add(this.config.className),e.insertBefore(this.container,e.firstChild)):this.container=null}offsetOf(t){const e=this.getVirtualState(),i=e?.positionCache;if(i&&i[t])return i[t].offset;return t*(e?.rowHeight??28)}heightOf(t){const e=this.getVirtualState(),i=e?.positionCache;return i&&i[t]?i[t].height:e?.rowHeight??28}getVirtualState(){return this.grid?._virtualization}getCurrentScrollTop(){const t=this.getVirtualState(),e=t?.container?.scrollTop;return"number"==typeof e?e:"number"!=typeof t?.start||"number"!=typeof t?.rowHeight||t.positionCache&&t.positionCache.length?t?.positionCache&&"number"==typeof t.start&&t.positionCache[t.start]?t.positionCache[t.start].offset:0:t.start*t.rowHeight}computeDisplay(t){if("stack"===this.config.mode){const e=this.config.maxStacked??1/0,i=[];let s=0;for(const n of this.stickyIndices)if(i.length<e){if(!(this.offsetOf(n)<t+s))break;i.push(n),s+=this.heightOf(n)}else{const e=this.heightOf(i[0]);if(!(this.offsetOf(n)<t+s-e))break;i.shift(),s-=e,i.push(n),s+=this.heightOf(n)}if(i.length===e&&i.length>0){const e=this.findNextSticky(i[i.length-1]);if(null!=e){const n=this.offsetOf(e)-(t+s);if(n<0){const t=this.heightOf(i[0]);return{indices:i,pushOffset:Math.min(-n,t)}}}}return{indices:i,pushOffset:0}}const e=[];for(const r of this.stickyIndices){if(!(this.offsetOf(r)<t))break;e.push(r)}if(0===e.length)return{indices:e,pushOffset:0};const i=e[e.length-1],s=this.findNextSticky(i);let n=0;if(null!=s){const e=this.heightOf(i),r=this.offsetOf(s)-t;r<e&&(n=e-Math.max(0,r))}return{indices:[i],pushOffset:n}}findRenderedRow(t){const e=this.gridElement;if(!e)return null;const i=e.querySelector(`.rows .data-grid-row .cell[data-row="${t}"]`);return i?.parentElement??null}buildClone(t){const e=this.findRenderedRow(t);if(!e)return this.cloneCache.get(t)??null;const i=e.cloneNode(!0);return i.classList.add("tbw-sticky-row"),i.removeAttribute("aria-rowindex"),i.setAttribute("aria-hidden","true"),i.dataset.stickyRow=String(t),i.classList.remove("row-focus","cell-focus"),i.querySelectorAll(".cell-focus, .row-focus").forEach(t=>t.classList.remove("cell-focus","row-focus")),i.removeAttribute("tabindex"),i.querySelectorAll("[tabindex]").forEach(t=>t.removeAttribute("tabindex")),this.cloneCache.set(t,i),i}refreshClonesInWindow(){if(this.displayedIndices.length)for(const t of this.displayedIndices){if(this.findRenderedRow(t)){const e=this.buildClone(t),i=this.container?.querySelector(`[data-sticky-row="${t}"]`);e&&i&&i!==e&&i.replaceWith(e)}}}primeCloneCache(){if(this.stickyIndices.length)for(const t of this.stickyIndices)this.findRenderedRow(t)&&this.buildClone(t)}refreshDisplay(t){if(!this.container)return;const e=t??this.getCurrentScrollTop(),{indices:i,pushOffset:s}=this.computeDisplay(e);this.container.dataset.mode!==this.config.mode&&(this.container.dataset.mode=this.config.mode??"push");if(!(i.length===this.displayedIndices.length&&i.every((t,e)=>t===this.displayedIndices[e]))){const t=document.createDocumentFragment(),e=[];for(const s of i){let i=this.cloneCache.get(s)??null;i=this.buildClone(s)??i,i&&(t.appendChild(i),e.push(s))}this.container.replaceChildren(t),this.displayedIndices=e}s!==this.lastPushOffset&&(this.container.style.transform=s>0?`translateY(${-s}px)`:"",this.lastPushOffset=s)}findNextSticky(t){for(const e of this.stickyIndices)if(e>t)return e;return null}}export{h as StickyRowsPlugin};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function e(e,o,r,i){return`${t(r,i)} ${e}: ${o}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}const o="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${o.slice(3).join("|")}|this\\b`);const r=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".split("|")),i=/^on\w+$/i,n=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),s=/^\s*(javascript|vbscript|data|blob):/i;function l(t){if(!t||"string"!=typeof t)return"";if(-1===t.indexOf("<"))return t;const e=document.createElement("template");return e.innerHTML=t,function(t){const e=[],o=t.querySelectorAll("*");for(const l of o){const t=l.tagName.toLowerCase();if(r.has(t)){e.push(l);continue}if("svg"===t||"http://www.w3.org/2000/svg"===l.namespaceURI){if(Array.from(l.attributes).some(t=>i.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(l);continue}}const o=[];for(const e of l.attributes){const t=e.name.toLowerCase();i.test(t)?o.push(e.name):(n.has(t)&&s.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&o.push(e.name)}o.forEach(t=>l.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content),e.innerHTML}const a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class c{static dependencies;static manifest;aliases;version="2.17.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}get resolvedConfig(){return this.#t?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(t){if(0===t.length)return;const o={...this.userConfig},r={};for(const e of Object.keys(o))r[e]=this;for(const i of t){const t=i.userConfig;for(const[n,s]of Object.entries(t)){if(void 0===s)continue;if(!(n in o)){o[n]=s,r[n]=i;continue}if(o[n]===s)continue;const t=r[n]?.constructor.name??this.constructor.name,l=i.constructor.name,a=e("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${n}" supplied by both ${t} and ${l}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,o)}refreshUserConfigFrom(t){const e=this.userConfig;for(const o of Object.keys(e))delete e[o];Object.assign(e,t.userConfig)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const o=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...a,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(e,10);if(!isNaN(o))return o}return 200}setIcon(t,e,o){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const r=this.#e(e,o);void 0!==r?"string"==typeof r?t.innerHTML=l(r):r instanceof HTMLElement&&(t.innerHTML="",t.appendChild(r.cloneNode(!0))):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(o,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const r=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return r?t.insertBefore(o,r):t.appendChild(o),o}warn(o,r){void 0!==r?console.warn(e(o,r,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${o}`)}throwDiagnostic(t,o){throw new Error(e(t,o,this.gridElement.id,this.name))}}function p(t){return t.scrollWidth>t.clientWidth}function d(){return"function"==typeof HTMLElement.prototype?.showPopover}class h extends c{name="tooltip";styles='@layer tbw-plugins{.tbw-tooltip-popover{margin:0;padding:var(--tbw-tooltip-padding, var(--tbw-spacing-sm, .375rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-tooltip-bg, light-dark(#333338, #484850));color:var(--tbw-tooltip-fg, light-dark(#f5f5f5, #f0f0f0));border:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-radius:var(--tbw-tooltip-radius, var(--tbw-border-radius, .25rem));box-shadow:none;filter:var(--tbw-tooltip-shadow, drop-shadow(0 4px 4px rgba(0, 0, 0, .45)));font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-tooltip-font-size, var(--tbw-font-size-sm, .9285em));max-width:var(--tbw-tooltip-max-width, 300px);white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word;pointer-events:none;z-index:10001}.tbw-tooltip-popover.tbw-tooltip-multiline{white-space:pre;max-width:none;word-wrap:normal;overflow-wrap:normal}.tbw-tooltip-popover:after{content:"";position:absolute;width:var(--tbw-tooltip-arrow-size, 14px);height:var(--tbw-tooltip-arrow-size, 14px);left:var(--tbw-tooltip-arrow-offset, 16px);background:inherit;pointer-events:none}.tbw-tooltip-popover:not(.tbw-tooltip-above):after{top:calc(var(--tbw-tooltip-arrow-size, 14px) / -2);transform:rotate(45deg);border-top:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-left:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));clip-path:polygon(0 0,100% 0,0 100%)}.tbw-tooltip-popover.tbw-tooltip-above:after{bottom:calc(var(--tbw-tooltip-arrow-size, 14px) / -2);transform:rotate(45deg);border-bottom:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-right:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));clip-path:polygon(100% 0,100% 100%,0 100%)}@supports (anchor-name: --test){.tbw-tooltip-popover{position-anchor:--tbw-tooltip-anchor;top:calc(anchor(bottom) + 11px);left:anchor(left);position-try-fallbacks:--tbw-tooltip-flip-above}@position-try --tbw-tooltip-flip-above{top:auto;bottom:calc(anchor(top) + 11px)}}}';static manifest={ownedProperties:[{property:"cellTooltip",level:"column",description:'the "cellTooltip" column property'},{property:"headerTooltip",level:"column",description:'the "headerTooltip" column property'}],configRules:[]};#o=null;#r=null;#i=!1;get#n(){return!1!==this.config.header}get#s(){return!1!==this.config.cell}attach(t){super.attach(t)}detach(){this.#l(),this.#o?.remove(),this.#o=null,this.#i=!1,super.detach()}afterRender(){this.#a(),this.#c()}#a(){if(this.#o)return;const t=document.createElement("div");t.className="tbw-tooltip-popover",t.setAttribute("popover","hint"),t.style.overflow="visible",t.style.margin="0",document.body.appendChild(t),this.#o=t}#p(t,e){if(this.#o){if(this.#d(),t.style.setProperty("anchor-name","--tbw-tooltip-anchor"),this.#r=t,this.#o.textContent=e,this.#o.classList.toggle("tbw-tooltip-multiline",e.includes("\n")),d())try{this.#o.showPopover()}catch{}"undefined"!=typeof CSS&&!0===CSS.supports?.("anchor-name","--test")?requestAnimationFrame(()=>this.#h(t)):this.#u(t)}}#l(){if(this.#o){if(d())try{this.#o.hidePopover()}catch{}this.#o.classList.remove("tbw-tooltip-above")}this.#d()}#d(){this.#r&&("--tbw-tooltip-anchor"===this.#r.style.getPropertyValue("anchor-name")&&this.#r.style.removeProperty("anchor-name"),this.#r=null)}#u(t){if(!this.#o)return;const e=t.getBoundingClientRect();this.#o.style.position="fixed",this.#o.style.left=`${e.left}px`;window.innerHeight-e.bottom<80?(this.#o.style.top="",this.#o.style.bottom=window.innerHeight-e.top+11+"px",this.#o.classList.add("tbw-tooltip-above")):(this.#o.style.top=`${e.bottom+11}px`,this.#o.style.bottom="",this.#o.classList.remove("tbw-tooltip-above"))}#h(t){if(!this.#o)return;const e=t.getBoundingClientRect(),o=this.#o.getBoundingClientRect();this.#o.classList.toggle("tbw-tooltip-above",o.bottom<=e.top)}#c(){if(this.#i)return;const t=this.gridElement?.querySelector(".tbw-grid-root");t&&(this.#i=!0,t.addEventListener("mouseover",t=>this.#f(t),{signal:this.disconnectSignal}),t.addEventListener("mouseout",t=>this.#g(t),{signal:this.disconnectSignal}))}#f(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"]');if(o&&this.#n)return void this.#b(o);const r=e.closest("[data-row][data-col]");r&&this.#s&&!r.style.getPropertyValue("anchor-name")&&this.#m(r)}#g(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"], [data-row][data-col]');if(!o)return;const r=t.relatedTarget;r&&o.contains(r)||this.#l()}#b(t){const e=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0)return;const o=this.visibleColumns[e];if(!o)return;const r=function(t,e){const o=t.headerTooltip;if(!1===o)return null;if("string"==typeof o)return o;if("function"==typeof o)return o({column:t,value:t.header??t.field});const r=e.querySelector("span:first-child")??e;return p(r)&&r.textContent?.trim()||null}(o,t);r&&this.#p(t,r)}#m(t){const e=parseInt(t.getAttribute("data-row")??"-1",10),o=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0||o<0)return;const r=this.visibleColumns[o];if(!r)return;const i=this.rows[e],n=i?.[r.field],s=function(t,e,o,r,i){const n=t.cellTooltip;if(!1===n)return null;if("string"==typeof n)return n;if("function"==typeof n)return n({value:r,row:o,column:t,field:t.field,grid:i});return p(e)&&e.textContent?.trim()||null}(r,t,i,n,this.grid);s&&this.#p(t,s)}}export{h as TooltipPlugin};
1
+ function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function e(e,o,r,i){return`${t(r,i)} ${e}: ${o}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}const o="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${o.slice(3).join("|")}|this\\b`);const r=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".split("|")),i=/^on\w+$/i,n=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),s=/^\s*(javascript|vbscript|data|blob):/i;function l(t){if(!t||"string"!=typeof t)return"";if(-1===t.indexOf("<"))return t;const e=document.createElement("template");return e.innerHTML=t,function(t){const e=[],o=t.querySelectorAll("*");for(const l of o){const t=l.tagName.toLowerCase();if(r.has(t)){e.push(l);continue}if("svg"===t||"http://www.w3.org/2000/svg"===l.namespaceURI){if(Array.from(l.attributes).some(t=>i.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(l);continue}}const o=[];for(const e of l.attributes){const t=e.name.toLowerCase();i.test(t)?o.push(e.name):(n.has(t)&&s.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&o.push(e.name)}o.forEach(t=>l.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content),e.innerHTML}const a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class c{static dependencies;static manifest;aliases;version="2.17.1";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}get resolvedConfig(){return this.#t?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(t){if(0===t.length)return;const o={...this.userConfig},r={};for(const e of Object.keys(o))r[e]=this;for(const i of t){const t=i.userConfig;for(const[n,s]of Object.entries(t)){if(void 0===s)continue;if(!(n in o)){o[n]=s,r[n]=i;continue}if(o[n]===s)continue;const t=r[n]?.constructor.name??this.constructor.name,l=i.constructor.name,a=e("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${n}" supplied by both ${t} and ${l}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,o)}refreshUserConfigFrom(t){const e=this.userConfig;for(const o of Object.keys(e))delete e[o];Object.assign(e,t.userConfig)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const o=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...a,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(e,10);if(!isNaN(o))return o}return 200}setIcon(t,e,o){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const r=this.#e(e,o);void 0!==r?"string"==typeof r?t.innerHTML=l(r):r instanceof HTMLElement&&(t.innerHTML="",t.appendChild(r.cloneNode(!0))):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(o,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const r=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return r?t.insertBefore(o,r):t.appendChild(o),o}warn(o,r){void 0!==r?console.warn(e(o,r,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${o}`)}throwDiagnostic(t,o){throw new Error(e(t,o,this.gridElement.id,this.name))}}function p(t){return t.scrollWidth>t.clientWidth}function d(){return"function"==typeof HTMLElement.prototype?.showPopover}class h extends c{name="tooltip";styles='@layer tbw-plugins{.tbw-tooltip-popover{margin:0;padding:var(--tbw-tooltip-padding, var(--tbw-spacing-sm, .375rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-tooltip-bg, light-dark(#333338, #484850));color:var(--tbw-tooltip-fg, light-dark(#f5f5f5, #f0f0f0));border:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-radius:var(--tbw-tooltip-radius, var(--tbw-border-radius, .25rem));box-shadow:none;filter:var(--tbw-tooltip-shadow, drop-shadow(0 4px 4px rgba(0, 0, 0, .45)));font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-tooltip-font-size, var(--tbw-font-size-sm, .9285em));max-width:var(--tbw-tooltip-max-width, 300px);white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word;pointer-events:none;z-index:10001}.tbw-tooltip-popover.tbw-tooltip-multiline{white-space:pre;max-width:none;word-wrap:normal;overflow-wrap:normal}.tbw-tooltip-popover:after{content:"";position:absolute;width:var(--tbw-tooltip-arrow-size, 14px);height:var(--tbw-tooltip-arrow-size, 14px);left:var(--tbw-tooltip-arrow-offset, 16px);background:inherit;pointer-events:none}.tbw-tooltip-popover:not(.tbw-tooltip-above):after{top:calc(var(--tbw-tooltip-arrow-size, 14px) / -2);transform:rotate(45deg);border-top:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-left:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));clip-path:polygon(0 0,100% 0,0 100%)}.tbw-tooltip-popover.tbw-tooltip-above:after{bottom:calc(var(--tbw-tooltip-arrow-size, 14px) / -2);transform:rotate(45deg);border-bottom:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-right:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));clip-path:polygon(100% 0,100% 100%,0 100%)}@supports (anchor-name: --test){.tbw-tooltip-popover{position-anchor:--tbw-tooltip-anchor;top:calc(anchor(bottom) + 11px);left:anchor(left);position-try-fallbacks:--tbw-tooltip-flip-above}@position-try --tbw-tooltip-flip-above{top:auto;bottom:calc(anchor(top) + 11px)}}}';static manifest={ownedProperties:[{property:"cellTooltip",level:"column",description:'the "cellTooltip" column property'},{property:"headerTooltip",level:"column",description:'the "headerTooltip" column property'}],configRules:[]};#o=null;#r=null;#i=!1;get#n(){return!1!==this.config.header}get#s(){return!1!==this.config.cell}attach(t){super.attach(t)}detach(){this.#l(),this.#o?.remove(),this.#o=null,this.#i=!1,super.detach()}afterRender(){this.#a(),this.#c()}#a(){if(this.#o)return;const t=document.createElement("div");t.className="tbw-tooltip-popover",t.setAttribute("popover","hint"),t.style.overflow="visible",t.style.margin="0",document.body.appendChild(t),this.#o=t}#p(t,e){if(this.#o){if(this.#d(),t.style.setProperty("anchor-name","--tbw-tooltip-anchor"),this.#r=t,this.#o.textContent=e,this.#o.classList.toggle("tbw-tooltip-multiline",e.includes("\n")),d())try{this.#o.showPopover()}catch{}"undefined"!=typeof CSS&&!0===CSS.supports?.("anchor-name","--test")?requestAnimationFrame(()=>this.#h(t)):this.#u(t)}}#l(){if(this.#o){if(d())try{this.#o.hidePopover()}catch{}this.#o.classList.remove("tbw-tooltip-above")}this.#d()}#d(){this.#r&&("--tbw-tooltip-anchor"===this.#r.style.getPropertyValue("anchor-name")&&this.#r.style.removeProperty("anchor-name"),this.#r=null)}#u(t){if(!this.#o)return;const e=t.getBoundingClientRect();this.#o.style.position="fixed",this.#o.style.left=`${e.left}px`;window.innerHeight-e.bottom<80?(this.#o.style.top="",this.#o.style.bottom=window.innerHeight-e.top+11+"px",this.#o.classList.add("tbw-tooltip-above")):(this.#o.style.top=`${e.bottom+11}px`,this.#o.style.bottom="",this.#o.classList.remove("tbw-tooltip-above"))}#h(t){if(!this.#o)return;const e=t.getBoundingClientRect(),o=this.#o.getBoundingClientRect();this.#o.classList.toggle("tbw-tooltip-above",o.bottom<=e.top)}#c(){if(this.#i)return;const t=this.gridElement?.querySelector(".tbw-grid-root");t&&(this.#i=!0,t.addEventListener("mouseover",t=>this.#f(t),{signal:this.disconnectSignal}),t.addEventListener("mouseout",t=>this.#g(t),{signal:this.disconnectSignal}))}#f(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"]');if(o&&this.#n)return void this.#b(o);const r=e.closest("[data-row][data-col]");r&&this.#s&&!r.style.getPropertyValue("anchor-name")&&this.#m(r)}#g(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"], [data-row][data-col]');if(!o)return;const r=t.relatedTarget;r&&o.contains(r)||this.#l()}#b(t){const e=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0)return;const o=this.visibleColumns[e];if(!o)return;const r=function(t,e){const o=t.headerTooltip;if(!1===o)return null;if("string"==typeof o)return o;if("function"==typeof o)return o({column:t,value:t.header??t.field});const r=e.querySelector("span:first-child")??e;return p(r)&&r.textContent?.trim()||null}(o,t);r&&this.#p(t,r)}#m(t){const e=parseInt(t.getAttribute("data-row")??"-1",10),o=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0||o<0)return;const r=this.visibleColumns[o];if(!r)return;const i=this.rows[e],n=i?.[r.field],s=function(t,e,o,r,i){const n=t.cellTooltip;if(!1===n)return null;if("string"==typeof n)return n;if("function"==typeof n)return n({value:r,row:o,column:t,field:t.field,grid:i});return p(e)&&e.textContent?.trim()||null}(r,t,i,n,this.grid);s&&this.#p(t,s)}}export{h as TooltipPlugin};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- const e="expanded",t="tree-toggle",r={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function n(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function i(e,t,r,i){return`${n(r,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}const s="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${s.slice(3).join("|")}|this\\b`);const o=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".split("|")),a=/^on\w+$/i,d=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),l=/^\s*(javascript|vbscript|data|blob):/i;function c(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],r=e.querySelectorAll("*");for(const n of r){const e=n.tagName.toLowerCase();if(o.has(e)){t.push(n);continue}if("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI){if(Array.from(n.attributes).some(e=>a.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}}const r=[];for(const t of n.attributes){const e=t.name.toLowerCase();a.test(e)?r.push(t.name):(d.has(e)&&l.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&r.push(t.name)}r.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}class h{static dependencies;static manifest;aliases;version="2.17.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},r={};for(const n of Object.keys(t))r[n]=this;for(const n of e){const e=n.userConfig;for(const[s,o]of Object.entries(e)){if(void 0===o)continue;if(!(s in t)){t[s]=o,r[s]=n;continue}if(t[s]===o)continue;const e=r[s]?.constructor.name??this.constructor.name,a=n.constructor.name,d=i("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${s}" supplied by both ${e} and ${a}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(d)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig;for(const r of Object.keys(t))delete t[r];Object.assign(t,e.userConfig)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...r,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}setIcon(e,t,r){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,r);void 0!==n?"string"==typeof n?e.innerHTML=c(n):n instanceof HTMLElement&&(e.innerHTML="",e.appendChild(n.cloneNode(!0))):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const r=document.createElement("span");r.setAttribute("part","sort-indicator"),r.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(r,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(r,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(r,n):e.appendChild(r),r}warn(e,t){void 0!==t?console.warn(i(e,t,this.gridElement.id,this.name)):console.warn(`${n(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(i(e,t,this.gridElement.id,this.name))}}const u=/* @__PURE__ */new WeakMap;function f(e,t,r=-1){if(!t.valueAccessor)return e?.[t.field];if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:r});const n=e,i=t.field;let s=u.get(n);if(s){const e=s.get(i);if(void 0!==e)return e.v}else s=/* @__PURE__ */new Map,u.set(n,s);const o=t.valueAccessor({row:e,column:t,rowIndex:r});return s.set(i,{v:o}),o}function g(e,t,r){const n=r.find(e=>e.field===t.field),i=n?.sortComparator,{field:s,direction:o}=t,a=[...e];return i?n?.valueAccessor?a.sort((e,t)=>i(f(e,n),f(t,n),e,t)*o):a.sort((e,t)=>i(e[s],t[s],e,t)*o):n?.valueAccessor?function(e,t,r){e.sort((e,n)=>{const i=p(e,n);if(0!==i)return i;const s=f(e,t),o=f(n,t);return null==s&&null==o?0:null==s?-r:null==o||s>o?r:s<o?-r:0})}(a,n,o):function(e,t,r){e.sort((e,n)=>{const i=p(e,n);if(0!==i)return i;const s=e[t],o=n[t];return null==s&&null==o?0:null==s?-r:null==o||s>o?r:s<o?-r:0})}(a,s,o),a}function p(e,t){const r=!0===e?.__loading;return r===(!0===t?.__loading)?0:r?1:-1}function y(e,t,r){return void 0!==e.id?String(e.id):r?`${r}-${t}`:String(t)}function w(e,t){const r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r}function m(e,t,r=null,n=0){const i=t.childrenField??"children",s=/* @__PURE__ */new Set;for(let o=0;o<e.length;o++){const a=e[o],d=y(a,o,r),l=a[i];if(Array.isArray(l)&&l.length>0){s.add(d);const e=m(l,t,d,n+1);for(const t of e)s.add(t)}}return s}function b(e,t,r,n=null,i=0){const s=r.childrenField??"children";for(let o=0;o<e.length;o++){const a=e[o],d=y(a,o,n);if(d===t)return[d];const l=a[s];if(Array.isArray(l)&&l.length>0){const e=b(l,t,r,d,i+1);if(e)return[d,...e]}}return null}function x(e,t,r,n){const i=b(e,t,r);if(!i)return n;const s=new Set(n);for(let o=0;o<i.length-1;o++)s.add(i[o]);return s}function v(e,t){const r=Math.min(t,e.length-1);if(r<0)return 0;let n=r;for(;n>0&&e[n].depth>0;)n--;let i=0;for(let s=0;s<=n;s++)0===e[s].depth&&i++;return i-1}function S(e,t="children"){if(!Array.isArray(e)||0===e.length)return!1;for(const r of e){if(!r)continue;const e=r[t];if(Array.isArray(e)&&e.length>0)return!0;if(null!=e&&!Array.isArray(e)&&e)return!0}return!1}class C extends h{static manifest={modifiesRowStructure:!0,hookPriority:{processRows:10},incompatibleWith:[{name:"groupingRows",reason:"Both plugins transform the entire row model. TreePlugin flattens nested hierarchies while GroupingRowsPlugin groups flat rows with synthetic headers. Use one approach per grid."},{name:"pivot",reason:"PivotPlugin replaces the entire row and column structure with aggregated pivot data. Tree hierarchy cannot coexist with pivot aggregation."}],events:[{type:"tree-expand",description:"Emitted when tree expansion state changes (toggle, expand all, collapse all). Broadcast to both DOM consumers and plugin bus."}],queries:[{type:"canMoveRow",description:"Returns false for rows with children (parent nodes cannot be reordered)"},{type:"datasource:viewport-mapping",description:"Translates flat viewport row indices to top-level node indices for ServerSide pagination."}]};static dependencies=[{name:"multiSort",required:!1,reason:"Queries sort model for coordinated tree sorting"},{name:"serverSide",required:!1,reason:"Consumes datasource events for lazy-loaded tree data"}];name="tree";styles='@layer tbw-plugins{tbw-grid .cell[data-field=__tbw_expander]{border-inline-end:none!important;padding:0;display:flex;align-items:center;justify-content:flex-start}tbw-grid .header-row .cell[data-field=__tbw_expander]{display:none}tbw-grid .header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}tbw-grid .tree-cell-wrapper{display:inline-flex;align-items:center;vertical-align:middle;overflow:visible;padding-inline-start:calc(var(--tbw-tree-depth, 0) * var(--tbw-tree-indent-width, var(--tbw-tree-toggle-size, 1.25em)))}tbw-grid .tree-expander{display:flex;align-items:center;justify-content:flex-start;width:100%;height:100%;box-sizing:border-box}tbw-grid .tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-tree-toggle-size, 1.25em);height:var(--tbw-tree-toggle-size, 1.25em);flex-shrink:0}tbw-grid .tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}tbw-grid .tree-spacer{width:var(--tbw-tree-toggle-size, 1.25em);height:var(--tbw-tree-toggle-size, 1.25em);display:inline-block;flex-shrink:0}tbw-grid .data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}tbw-grid .data-grid-row.tbw-tree-fade-in{animation:tbw-tree-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-tree-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}tbw-grid.tbw-tree-loading .rows-viewport:after{content:"";display:block;height:2px;background:linear-gradient(90deg,transparent,var(--tbw-color-accent, #2563eb),transparent);animation:tbw-tree-loading-bar 1s ease-in-out infinite;position:sticky;bottom:0;left:0;right:0}@keyframes tbw-tree-loading-bar{0%{transform:translate(-100%)}to{transform:translate(100%)}}}';get defaultConfig(){return{childrenField:"children",autoDetect:!0,defaultExpanded:!1,indentWidth:20,showExpandIcons:!0,animation:"slide"}}expandedKeys=/* @__PURE__ */new Set;initialExpansionDone=!1;flattenedRows=[];rowKeyMap=/* @__PURE__ */new Map;previousVisibleKeys=/* @__PURE__ */new Set;keysToAnimate=/* @__PURE__ */new Set;sortState=null;loadingKeys=/* @__PURE__ */new Set;#r=/* @__PURE__ */new WeakMap;#n=/* @__PURE__ */new WeakMap;originalTreeColumnRenderer;wrappedTreeColumnField;detach(){const e=this.gridElement?.querySelector(".rows-body");e?.setAttribute("role","grid"),this.expandedKeys.clear(),this.initialExpansionDone=!1,this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),this.keysToAnimate.clear(),this.sortState=null,this.loadingKeys.clear(),this.originalTreeColumnRenderer=void 0,this.wrappedTreeColumnField=void 0}handleQuery(e){if("canMoveRow"===e.type){const t=e.context,r=this.config.childrenField??"children",n=t?.[r];if(Array.isArray(n)&&n.length>0)return!1}if("datasource:viewport-mapping"===e.type){const{viewportStart:t,viewportEnd:r}=e.context;if(0===this.flattenedRows.length)return;return{startNode:v(this.flattenedRows,t),endNode:v(this.flattenedRows,r)+1,totalLoadedNodes:function(e){let t=0;for(const r of e)0===r.depth&&t++;return t}(this.flattenedRows)}}}attach(e){super.attach(e),this.on("datasource:data",e=>{const t=e;t.claimed||(t.claimed=!0)}),this.on("datasource:children",e=>{const t=e;if("tree"!==t.context?.source)return;t.claimed=!0;const r=t.context.parentNode;if(r){r[this.config.childrenField??"children"]=t.rows;const e=this.#r.get(r)??String(r.id??"?");this.loadingKeys.delete(e),this.requestRender()}})}get animationStyle(){return!!this.isAnimationEnabled&&(this.config.animation??"slide")}detect(e){if(!this.config.autoDetect)return!1;const t=e,r=this.config.childrenField??function(e){if(!Array.isArray(e)||0===e.length)return null;const t=["children","items","nodes","subRows","nested"];for(const r of e)if(r&&"object"==typeof r)for(const e of t){const t=r[e];if(Array.isArray(t)&&t.length>0)return e}return null}(t)??"children";return S(t,r)}processRows(e){const t=this.config.childrenField??"children",r=e;if(0===r.length||!S(r,t))return this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),[...e];const n=this.resolveEffectiveSortState();this.config.defaultExpanded&&!this.initialExpansionDone&&(this.expandedKeys=m(r,this.config),this.initialExpansionDone=!0),this.flattenedRows=this.#i(r,this.expandedKeys,n,null,0),this.#n=/* @__PURE__ */new WeakMap,this.rowKeyMap.clear(),this.keysToAnimate.clear();const i=/* @__PURE__ */new Set;for(const s of this.flattenedRows)this.rowKeyMap.set(s.key,s),this.#n.set(s.data,s),i.add(s.key),!this.previousVisibleKeys.has(s.key)&&s.depth>0&&this.keysToAnimate.add(s.key);return this.previousVisibleKeys=i,this.flattenedRows.map(e=>e.data)}#s(e,t,r){if(void 0!==e.id){const t=String(e.id);return this.#r.set(e,t),t}const n=this.#r.get(e);if(void 0!==n)return n;const i=r?`${r}-${t}`:String(t);return this.#r.set(e,i),i}#i(e,t,r,n,i){const s=this.config.childrenField??"children";for(let d=0;d<e.length;d++)this.#s(e[d],d,n);const o=r?this.#o(e,r.field,r.direction):e,a=[];for(let d=0;d<o.length;d++){const e=o[d],l=this.#s(e,d,n),c=e[s],h=Array.isArray(c)&&c.length>0,u=null!=c&&!Array.isArray(c)&&!!c,f=h||u,g=t.has(l);a.push({key:l,data:e,depth:i,hasChildren:f,isExpanded:g,parentKey:n,posInSet:d+1,setSize:o.length}),h&&g&&a.push(...this.#i(c,t,r,l,i+1))}return a}#o(e,t,r){const n=this.grid,i=n?._columns??[],s={field:t,direction:r},o=[...e],a=(n?.effectiveConfig?.sortHandler??g)(o,s,i);return a&&"function"==typeof a.then?(a.catch(()=>{}),g(o,s,i)):a}requestLazyChildren(e){if(this.loadingKeys.has(e.key))return;const t=this.config.childrenField??"children",r=e.data[t];if(Array.isArray(r)&&r.length>0)return;const n=this.grid?.query?.("datasource:is-active",null);n&&(this.loadingKeys.add(e.key),this.grid.query("datasource:fetch-children",{context:{source:"tree",parentNode:e.data,nodePath:[e.key]}}))}resolveEffectiveSortState(){const e=this.grid?.query?.("sort:get-model",null);if(Array.isArray(e)&&e.length>0){const t=e[0];if(Array.isArray(t)&&t.length>0)return{field:t[0].field,direction:"desc"===t[0].direction?-1:1}}return this.sortState}processColumns(r){if(0===this.flattenedRows.length)return[...r];const n=[...r];if(0===n.length)return n;const{treeColumn:i}=this.config;let s=0;if(i){const e=n.findIndex(e=>e.field===i);e>=0&&(s=e)}const o=n[s],a=o.field;this.wrappedTreeColumnField!==a&&(this.originalTreeColumnRenderer=o.viewRenderer,this.wrappedTreeColumnField=a);const d=this.originalTreeColumnRenderer,l=()=>this.config,c=this.setIcon.bind(this);return n[s]={...o,viewRenderer:r=>{const{row:n,value:i}=r,{showExpandIcons:s=!0,indentWidth:o}=l(),a=this.#n.get(n),h=a?.depth??0,u=document.createElement("span");if(u.className="tree-cell-wrapper",u.style.setProperty("--tbw-tree-depth",String(h)),void 0!==o&&u.style.setProperty("--tbw-tree-indent-width",`${o}px`),s)if(a&&a.hasChildren){const r=document.createElement("span");r.className=`${t}${a.isExpanded?` ${e}`:""}`,c(r,a.isExpanded?"collapse":"expand"),r.setAttribute("data-tree-key",a.key),u.appendChild(r)}else{const e=document.createElement("span");e.className="tree-spacer",u.appendChild(e)}const f=document.createElement("span");if(f.className="tree-content",d){const e=d(r);e instanceof Node?f.appendChild(e):"string"==typeof e&&(f.innerHTML=e)}else f.textContent=null!=i?String(i):"";return u.appendChild(f),u}},n}onCellClick(e){const r=e.originalEvent?.target;if(!r?.classList.contains(t))return!1;const n=r.getAttribute("data-tree-key");if(!n)return!1;const i=this.rowKeyMap.get(n);return!!i&&(this.expandedKeys=w(this.expandedKeys,n),this.expandedKeys.has(n)&&this.requestLazyChildren(i),this.broadcast("tree-expand",{key:n,row:i.data,expanded:this.expandedKeys.has(n),depth:i.depth,expandedKeys:[...this.expandedKeys]}),this.requestRender(),!0)}onKeyDown(e){if(" "!==e.key)return;const t=this.grid._focusRow,r=this.flattenedRows[t];return r?.hasChildren?(e.preventDefault(),this.expandedKeys=w(this.expandedKeys,r.key),this.expandedKeys.has(r.key)&&this.requestLazyChildren(r),this.broadcast("tree-expand",{key:r.key,row:r.data,expanded:this.expandedKeys.has(r.key),depth:r.depth,expandedKeys:[...this.expandedKeys]}),this.requestRenderWithFocus(),!0):void 0}onHeaderClick(e){if(0===this.flattenedRows.length||!e.column.sortable)return!1;const t=this.grid?.query?.("sort:get-model",null);if(Array.isArray(t)&&t.length>0)return!1;const{field:r}=e.column;this.sortState&&this.sortState.field===r?1===this.sortState.direction?this.sortState={field:r,direction:-1}:this.sortState=null:this.sortState={field:r,direction:1};const n=this.grid;return void 0!==n._sortState&&(n._sortState=this.sortState?{...this.sortState}:null),this.broadcast("sort-change",{field:r,direction:this.sortState?.direction??0}),this.requestRender(),!0}afterRender(){const e=this.gridElement?.querySelector(".rows-body");e&&"treegrid"!==e.getAttribute("role")&&e.setAttribute("role","treegrid");const t=this.gridElement?.querySelector(".rows");if(!t)return;const r=this.animationStyle,n=!1!==r&&this.keysToAnimate.size>0,i="fade"===r?"tbw-tree-fade-in":"tbw-tree-slide-in";for(const s of t.querySelectorAll(".data-grid-row")){const e=s.querySelector(".cell[data-row]"),t=e?parseInt(e.getAttribute("data-row")??"-1",10):-1,r=this.flattenedRows[t];r&&(s.setAttribute("aria-level",String(r.depth+1)),s.setAttribute("aria-setsize",String(r.setSize)),s.setAttribute("aria-posinset",String(r.posInSet)),r.hasChildren?s.setAttribute("aria-expanded",String(r.isExpanded)):s.hasAttribute("aria-expanded")&&s.removeAttribute("aria-expanded"),s.classList.toggle("tbw-row-expanded",r.hasChildren&&r.isExpanded),n&&r.key&&this.keysToAnimate.has(r.key)&&(s.classList.add(i),s.addEventListener("animationend",()=>s.classList.remove(i),{once:!0})))}this.keysToAnimate.clear()}expand(e){this.expandedKeys.add(e);const t=this.rowKeyMap.get(e);t&&this.requestLazyChildren(t),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}toggle(e){this.expandedKeys=w(this.expandedKeys,e);const t=this.rowKeyMap.get(e);t?(this.expandedKeys.has(e)&&this.requestLazyChildren(t),this.broadcast("tree-expand",{key:e,row:t.data,expanded:this.expandedKeys.has(e),depth:t.depth,expandedKeys:[...this.expandedKeys]})):this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}expandAll(){this.expandedKeys=m(this.rows,this.config),this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}collapseAll(){this.expandedKeys=/* @__PURE__ */new Set,this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}getExpandedKeys(){return[...this.expandedKeys]}getFlattenedRows(){return[...this.flattenedRows]}getRowMeta(e){return this.#n.get(e)}getRowByKey(e){return this.rowKeyMap.get(e)?.data}expandToKey(e){this.expandedKeys=x(this.rows,e,this.config,this.expandedKeys),this.requestRender()}}export{C as TreePlugin};
1
+ const e="expanded",t="tree-toggle",r={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function n(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function i(e,t,r,i){return`${n(r,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}const s="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${s.slice(3).join("|")}|this\\b`);const o=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".split("|")),a=/^on\w+$/i,d=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),l=/^\s*(javascript|vbscript|data|blob):/i;function c(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],r=e.querySelectorAll("*");for(const n of r){const e=n.tagName.toLowerCase();if(o.has(e)){t.push(n);continue}if("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI){if(Array.from(n.attributes).some(e=>a.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}}const r=[];for(const t of n.attributes){const e=t.name.toLowerCase();a.test(e)?r.push(t.name):(d.has(e)&&l.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&r.push(t.name)}r.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}class h{static dependencies;static manifest;aliases;version="2.17.1";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},r={};for(const n of Object.keys(t))r[n]=this;for(const n of e){const e=n.userConfig;for(const[s,o]of Object.entries(e)){if(void 0===o)continue;if(!(s in t)){t[s]=o,r[s]=n;continue}if(t[s]===o)continue;const e=r[s]?.constructor.name??this.constructor.name,a=n.constructor.name,d=i("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${s}" supplied by both ${e} and ${a}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(d)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig;for(const r of Object.keys(t))delete t[r];Object.assign(t,e.userConfig)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...r,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}setIcon(e,t,r){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,r);void 0!==n?"string"==typeof n?e.innerHTML=c(n):n instanceof HTMLElement&&(e.innerHTML="",e.appendChild(n.cloneNode(!0))):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const r=document.createElement("span");r.setAttribute("part","sort-indicator"),r.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(r,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(r,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(r,n):e.appendChild(r),r}warn(e,t){void 0!==t?console.warn(i(e,t,this.gridElement.id,this.name)):console.warn(`${n(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(i(e,t,this.gridElement.id,this.name))}}const u=/* @__PURE__ */new WeakMap;function f(e,t,r=-1){if(!t.valueAccessor)return e?.[t.field];if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:r});const n=e,i=t.field;let s=u.get(n);if(s){const e=s.get(i);if(void 0!==e)return e.v}else s=/* @__PURE__ */new Map,u.set(n,s);const o=t.valueAccessor({row:e,column:t,rowIndex:r});return s.set(i,{v:o}),o}function g(e,t,r){const n=r.find(e=>e.field===t.field),i=n?.sortComparator,{field:s,direction:o}=t,a=[...e];return i?n?.valueAccessor?a.sort((e,t)=>i(f(e,n),f(t,n),e,t)*o):a.sort((e,t)=>i(e[s],t[s],e,t)*o):n?.valueAccessor?function(e,t,r){e.sort((e,n)=>{const i=p(e,n);if(0!==i)return i;const s=f(e,t),o=f(n,t);return null==s&&null==o?0:null==s?-r:null==o||s>o?r:s<o?-r:0})}(a,n,o):function(e,t,r){e.sort((e,n)=>{const i=p(e,n);if(0!==i)return i;const s=e[t],o=n[t];return null==s&&null==o?0:null==s?-r:null==o||s>o?r:s<o?-r:0})}(a,s,o),a}function p(e,t){const r=!0===e?.__loading;return r===(!0===t?.__loading)?0:r?1:-1}function y(e,t,r){return void 0!==e.id?String(e.id):r?`${r}-${t}`:String(t)}function w(e,t){const r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r}function m(e,t,r=null,n=0){const i=t.childrenField??"children",s=/* @__PURE__ */new Set;for(let o=0;o<e.length;o++){const a=e[o],d=y(a,o,r),l=a[i];if(Array.isArray(l)&&l.length>0){s.add(d);const e=m(l,t,d,n+1);for(const t of e)s.add(t)}}return s}function b(e,t,r,n=null,i=0){const s=r.childrenField??"children";for(let o=0;o<e.length;o++){const a=e[o],d=y(a,o,n);if(d===t)return[d];const l=a[s];if(Array.isArray(l)&&l.length>0){const e=b(l,t,r,d,i+1);if(e)return[d,...e]}}return null}function x(e,t,r,n){const i=b(e,t,r);if(!i)return n;const s=new Set(n);for(let o=0;o<i.length-1;o++)s.add(i[o]);return s}function v(e,t){const r=Math.min(t,e.length-1);if(r<0)return 0;let n=r;for(;n>0&&e[n].depth>0;)n--;let i=0;for(let s=0;s<=n;s++)0===e[s].depth&&i++;return i-1}function S(e,t="children"){if(!Array.isArray(e)||0===e.length)return!1;for(const r of e){if(!r)continue;const e=r[t];if(Array.isArray(e)&&e.length>0)return!0;if(null!=e&&!Array.isArray(e)&&e)return!0}return!1}class C extends h{static manifest={modifiesRowStructure:!0,hookPriority:{processRows:10},incompatibleWith:[{name:"groupingRows",reason:"Both plugins transform the entire row model. TreePlugin flattens nested hierarchies while GroupingRowsPlugin groups flat rows with synthetic headers. Use one approach per grid."},{name:"pivot",reason:"PivotPlugin replaces the entire row and column structure with aggregated pivot data. Tree hierarchy cannot coexist with pivot aggregation."}],events:[{type:"tree-expand",description:"Emitted when tree expansion state changes (toggle, expand all, collapse all). Broadcast to both DOM consumers and plugin bus."}],queries:[{type:"canMoveRow",description:"Returns false for rows with children (parent nodes cannot be reordered)"},{type:"datasource:viewport-mapping",description:"Translates flat viewport row indices to top-level node indices for ServerSide pagination."}]};static dependencies=[{name:"multiSort",required:!1,reason:"Queries sort model for coordinated tree sorting"},{name:"serverSide",required:!1,reason:"Consumes datasource events for lazy-loaded tree data"}];name="tree";styles='@layer tbw-plugins{tbw-grid .cell[data-field=__tbw_expander]{border-inline-end:none!important;padding:0;display:flex;align-items:center;justify-content:flex-start}tbw-grid .header-row .cell[data-field=__tbw_expander]{display:none}tbw-grid .header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}tbw-grid .tree-cell-wrapper{display:inline-flex;align-items:center;vertical-align:middle;overflow:visible;padding-inline-start:calc(var(--tbw-tree-depth, 0) * var(--tbw-tree-indent-width, var(--tbw-tree-toggle-size, 1.25em)))}tbw-grid .tree-expander{display:flex;align-items:center;justify-content:flex-start;width:100%;height:100%;box-sizing:border-box}tbw-grid .tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-tree-toggle-size, 1.25em);height:var(--tbw-tree-toggle-size, 1.25em);flex-shrink:0}tbw-grid .tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}tbw-grid .tree-spacer{width:var(--tbw-tree-toggle-size, 1.25em);height:var(--tbw-tree-toggle-size, 1.25em);display:inline-block;flex-shrink:0}tbw-grid .data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}tbw-grid .data-grid-row.tbw-tree-fade-in{animation:tbw-tree-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-tree-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}tbw-grid.tbw-tree-loading .rows-viewport:after{content:"";display:block;height:2px;background:linear-gradient(90deg,transparent,var(--tbw-color-accent, #2563eb),transparent);animation:tbw-tree-loading-bar 1s ease-in-out infinite;position:sticky;bottom:0;left:0;right:0}@keyframes tbw-tree-loading-bar{0%{transform:translate(-100%)}to{transform:translate(100%)}}}';get defaultConfig(){return{childrenField:"children",autoDetect:!0,defaultExpanded:!1,indentWidth:20,showExpandIcons:!0,animation:"slide"}}expandedKeys=/* @__PURE__ */new Set;initialExpansionDone=!1;flattenedRows=[];rowKeyMap=/* @__PURE__ */new Map;previousVisibleKeys=/* @__PURE__ */new Set;keysToAnimate=/* @__PURE__ */new Set;sortState=null;loadingKeys=/* @__PURE__ */new Set;#r=/* @__PURE__ */new WeakMap;#n=/* @__PURE__ */new WeakMap;originalTreeColumnRenderer;wrappedTreeColumnField;detach(){const e=this.gridElement?.querySelector(".rows-body");e?.setAttribute("role","grid"),this.expandedKeys.clear(),this.initialExpansionDone=!1,this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),this.keysToAnimate.clear(),this.sortState=null,this.loadingKeys.clear(),this.originalTreeColumnRenderer=void 0,this.wrappedTreeColumnField=void 0}handleQuery(e){if("canMoveRow"===e.type){const t=e.context,r=this.config.childrenField??"children",n=t?.[r];if(Array.isArray(n)&&n.length>0)return!1}if("datasource:viewport-mapping"===e.type){const{viewportStart:t,viewportEnd:r}=e.context;if(0===this.flattenedRows.length)return;return{startNode:v(this.flattenedRows,t),endNode:v(this.flattenedRows,r)+1,totalLoadedNodes:function(e){let t=0;for(const r of e)0===r.depth&&t++;return t}(this.flattenedRows)}}}attach(e){super.attach(e),this.on("datasource:data",e=>{const t=e;t.claimed||(t.claimed=!0)}),this.on("datasource:children",e=>{const t=e;if("tree"!==t.context?.source)return;t.claimed=!0;const r=t.context.parentNode;if(r){r[this.config.childrenField??"children"]=t.rows;const e=this.#r.get(r)??String(r.id??"?");this.loadingKeys.delete(e),this.requestRender()}})}get animationStyle(){return!!this.isAnimationEnabled&&(this.config.animation??"slide")}detect(e){if(!this.config.autoDetect)return!1;const t=e,r=this.config.childrenField??function(e){if(!Array.isArray(e)||0===e.length)return null;const t=["children","items","nodes","subRows","nested"];for(const r of e)if(r&&"object"==typeof r)for(const e of t){const t=r[e];if(Array.isArray(t)&&t.length>0)return e}return null}(t)??"children";return S(t,r)}processRows(e){const t=this.config.childrenField??"children",r=e;if(0===r.length||!S(r,t))return this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),[...e];const n=this.resolveEffectiveSortState();this.config.defaultExpanded&&!this.initialExpansionDone&&(this.expandedKeys=m(r,this.config),this.initialExpansionDone=!0),this.flattenedRows=this.#i(r,this.expandedKeys,n,null,0),this.#n=/* @__PURE__ */new WeakMap,this.rowKeyMap.clear(),this.keysToAnimate.clear();const i=/* @__PURE__ */new Set;for(const s of this.flattenedRows)this.rowKeyMap.set(s.key,s),this.#n.set(s.data,s),i.add(s.key),!this.previousVisibleKeys.has(s.key)&&s.depth>0&&this.keysToAnimate.add(s.key);return this.previousVisibleKeys=i,this.flattenedRows.map(e=>e.data)}#s(e,t,r){if(void 0!==e.id){const t=String(e.id);return this.#r.set(e,t),t}const n=this.#r.get(e);if(void 0!==n)return n;const i=r?`${r}-${t}`:String(t);return this.#r.set(e,i),i}#i(e,t,r,n,i){const s=this.config.childrenField??"children";for(let d=0;d<e.length;d++)this.#s(e[d],d,n);const o=r?this.#o(e,r.field,r.direction):e,a=[];for(let d=0;d<o.length;d++){const e=o[d],l=this.#s(e,d,n),c=e[s],h=Array.isArray(c)&&c.length>0,u=null!=c&&!Array.isArray(c)&&!!c,f=h||u,g=t.has(l);a.push({key:l,data:e,depth:i,hasChildren:f,isExpanded:g,parentKey:n,posInSet:d+1,setSize:o.length}),h&&g&&a.push(...this.#i(c,t,r,l,i+1))}return a}#o(e,t,r){const n=this.grid,i=n?._columns??[],s={field:t,direction:r},o=[...e],a=(n?.effectiveConfig?.sortHandler??g)(o,s,i);return a&&"function"==typeof a.then?(a.catch(()=>{}),g(o,s,i)):a}requestLazyChildren(e){if(this.loadingKeys.has(e.key))return;const t=this.config.childrenField??"children",r=e.data[t];if(Array.isArray(r)&&r.length>0)return;const n=this.grid?.query?.("datasource:is-active",null);n&&(this.loadingKeys.add(e.key),this.grid.query("datasource:fetch-children",{context:{source:"tree",parentNode:e.data,nodePath:[e.key]}}))}resolveEffectiveSortState(){const e=this.grid?.query?.("sort:get-model",null);if(Array.isArray(e)&&e.length>0){const t=e[0];if(Array.isArray(t)&&t.length>0)return{field:t[0].field,direction:"desc"===t[0].direction?-1:1}}return this.sortState}processColumns(r){if(0===this.flattenedRows.length)return[...r];const n=[...r];if(0===n.length)return n;const{treeColumn:i}=this.config;let s=0;if(i){const e=n.findIndex(e=>e.field===i);e>=0&&(s=e)}const o=n[s],a=o.field;this.wrappedTreeColumnField!==a&&(this.originalTreeColumnRenderer=o.viewRenderer,this.wrappedTreeColumnField=a);const d=this.originalTreeColumnRenderer,l=()=>this.config,c=this.setIcon.bind(this);return n[s]={...o,viewRenderer:r=>{const{row:n,value:i}=r,{showExpandIcons:s=!0,indentWidth:o}=l(),a=this.#n.get(n),h=a?.depth??0,u=document.createElement("span");if(u.className="tree-cell-wrapper",u.style.setProperty("--tbw-tree-depth",String(h)),void 0!==o&&u.style.setProperty("--tbw-tree-indent-width",`${o}px`),s)if(a&&a.hasChildren){const r=document.createElement("span");r.className=`${t}${a.isExpanded?` ${e}`:""}`,c(r,a.isExpanded?"collapse":"expand"),r.setAttribute("data-tree-key",a.key),u.appendChild(r)}else{const e=document.createElement("span");e.className="tree-spacer",u.appendChild(e)}const f=document.createElement("span");if(f.className="tree-content",d){const e=d(r);e instanceof Node?f.appendChild(e):"string"==typeof e&&(f.innerHTML=e)}else f.textContent=null!=i?String(i):"";return u.appendChild(f),u}},n}onCellClick(e){const r=e.originalEvent?.target;if(!r?.classList.contains(t))return!1;const n=r.getAttribute("data-tree-key");if(!n)return!1;const i=this.rowKeyMap.get(n);return!!i&&(this.expandedKeys=w(this.expandedKeys,n),this.expandedKeys.has(n)&&this.requestLazyChildren(i),this.broadcast("tree-expand",{key:n,row:i.data,expanded:this.expandedKeys.has(n),depth:i.depth,expandedKeys:[...this.expandedKeys]}),this.requestRender(),!0)}onKeyDown(e){if(" "!==e.key)return;const t=this.grid._focusRow,r=this.flattenedRows[t];return r?.hasChildren?(e.preventDefault(),this.expandedKeys=w(this.expandedKeys,r.key),this.expandedKeys.has(r.key)&&this.requestLazyChildren(r),this.broadcast("tree-expand",{key:r.key,row:r.data,expanded:this.expandedKeys.has(r.key),depth:r.depth,expandedKeys:[...this.expandedKeys]}),this.requestRenderWithFocus(),!0):void 0}onHeaderClick(e){if(0===this.flattenedRows.length||!e.column.sortable)return!1;const t=this.grid?.query?.("sort:get-model",null);if(Array.isArray(t)&&t.length>0)return!1;const{field:r}=e.column;this.sortState&&this.sortState.field===r?1===this.sortState.direction?this.sortState={field:r,direction:-1}:this.sortState=null:this.sortState={field:r,direction:1};const n=this.grid;return void 0!==n._sortState&&(n._sortState=this.sortState?{...this.sortState}:null),this.broadcast("sort-change",{field:r,direction:this.sortState?.direction??0}),this.requestRender(),!0}afterRender(){const e=this.gridElement?.querySelector(".rows-body");e&&"treegrid"!==e.getAttribute("role")&&e.setAttribute("role","treegrid");const t=this.gridElement?.querySelector(".rows");if(!t)return;const r=this.animationStyle,n=!1!==r&&this.keysToAnimate.size>0,i="fade"===r?"tbw-tree-fade-in":"tbw-tree-slide-in";for(const s of t.querySelectorAll(".data-grid-row")){const e=s.querySelector(".cell[data-row]"),t=e?parseInt(e.getAttribute("data-row")??"-1",10):-1,r=this.flattenedRows[t];r&&(s.setAttribute("aria-level",String(r.depth+1)),s.setAttribute("aria-setsize",String(r.setSize)),s.setAttribute("aria-posinset",String(r.posInSet)),r.hasChildren?s.setAttribute("aria-expanded",String(r.isExpanded)):s.hasAttribute("aria-expanded")&&s.removeAttribute("aria-expanded"),s.classList.toggle("tbw-row-expanded",r.hasChildren&&r.isExpanded),n&&r.key&&this.keysToAnimate.has(r.key)&&(s.classList.add(i),s.addEventListener("animationend",()=>s.classList.remove(i),{once:!0})))}this.keysToAnimate.clear()}expand(e){this.expandedKeys.add(e);const t=this.rowKeyMap.get(e);t&&this.requestLazyChildren(t),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}toggle(e){this.expandedKeys=w(this.expandedKeys,e);const t=this.rowKeyMap.get(e);t?(this.expandedKeys.has(e)&&this.requestLazyChildren(t),this.broadcast("tree-expand",{key:e,row:t.data,expanded:this.expandedKeys.has(e),depth:t.depth,expandedKeys:[...this.expandedKeys]})):this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}expandAll(){this.expandedKeys=m(this.rows,this.config),this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}collapseAll(){this.expandedKeys=/* @__PURE__ */new Set,this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}getExpandedKeys(){return[...this.expandedKeys]}getFlattenedRows(){return[...this.flattenedRows]}getRowMeta(e){return this.#n.get(e)}getRowByKey(e){return this.rowKeyMap.get(e)?.data}expandToKey(e){this.expandedKeys=x(this.rows,e,this.config,this.expandedKeys),this.requestRender()}}export{C as TreePlugin};
2
2
  //# sourceMappingURL=index.js.map