@toolbox-web/grid 3.0.0 → 3.0.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.
- package/all.js +1 -1
- package/all.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/features/registry.js +1 -1
- package/lib/plugins/clipboard/index.js +1 -1
- package/lib/plugins/column-virtualization/index.js +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/editing/index.js +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-rows/index.js +1 -1
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/pinned-columns/index.js +1 -1
- package/lib/plugins/pinned-rows/index.js +1 -1
- package/lib/plugins/pivot/index.js +1 -1
- package/lib/plugins/print/index.js +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder-columns/index.js +1 -1
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-drag-drop/index.js +1 -1
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +1 -1
- package/lib/plugins/shell/index.js +1 -1
- package/lib/plugins/sticky-rows/index.js +1 -1
- package/lib/plugins/tooltip/index.js +1 -1
- package/lib/plugins/tooltip/index.js.map +1 -1
- package/lib/plugins/tree/index.js +1 -1
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +1 -1
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -1
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/print.umd.js +1 -1
- package/umd/plugins/print.umd.js.map +1 -1
- package/umd/plugins/responsive.umd.js +1 -1
- package/umd/plugins/responsive.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/tooltip.umd.js +1 -1
- package/umd/plugins/tooltip.umd.js.map +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}var 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))}var i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"},n=/* @__PURE__ */new WeakMap;function a(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=n.get(r);if(i){const t=i.get(s);if(void 0!==t)return t.v}else i=/* @__PURE__ */new Map,n.set(r,i);const a=e.valueAccessor({row:t,column:e,rowIndex:o});return i.set(s,{v:a}),a}function l(t,e,o){const r=o.find(t=>t.field===e.field),s=r?.sortComparator,{field:i,direction:n}=e,l=[...t];return s?r?.valueAccessor?l.sort((t,e)=>s(a(t,r),a(e,r),t,e)*n):l.sort((t,e)=>s(t[i],e[i],t,e)*n):r?.valueAccessor?function(t,e,o){t.sort((t,r)=>{const s=d(t,r);if(0!==s)return s;const i=a(t,e),n=a(r,e);return null==i&&null==n?0:null==i?-o:null==n||i>n?o:i<n?-o:0})}(l,r,n):function(t,e,o){t.sort((t,r)=>{const s=d(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})}(l,i,n),l}function d(t,e){const o=!0===t?.__loading;return o===(!0===e?.__loading)?0:o?1:-1}var c="__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("")),u=(new RegExp(`__(proto|defineGetter|defineSetter)|${c.slice(3).join("|")}|this\\b`),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("|"))),h=/^on\w+$/i,g=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),f=/^\s*(javascript|vbscript|data|blob):/i;function m(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(u.has(t)){e.push(r);continue}if(("svg"===t||"http://www.w3.org/2000/svg"===r.namespaceURI)&&Array.from(r.attributes).some(t=>h.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();h.test(t)?o.push(e.name):(g.has(t)&&f.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}var b=class{static dependencies;static manifest;aliases;version="3.0.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,o={...t.userConfig};for(const r of Object.keys(e))delete e[r];Object.assign(e,o)}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;return!e||"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}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=m(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))}};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(/* @__PURE__ */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 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}}}}var k=class extends b{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{_virtualization:t}=this.grid,o=this.config.pageSize??100,i=this.getViewportMapping(t.start,t.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??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??l)(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??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}isNodeLoaded(t){const e=p(t,this.config.pageSize??100);return this.loadedBlocks.has(e)}getLoadedBlockCount(){return this.loadedBlocks.size}};export{k as ServerSidePlugin};
|
|
1
|
+
function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}var 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))}var i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"},n=/* @__PURE__ */new WeakMap;function a(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=n.get(r);if(i){const t=i.get(s);if(void 0!==t)return t.v}else i=/* @__PURE__ */new Map,n.set(r,i);const a=e.valueAccessor({row:t,column:e,rowIndex:o});return i.set(s,{v:a}),a}function l(t,e,o){const r=o.find(t=>t.field===e.field),s=r?.sortComparator,{field:i,direction:n}=e,l=[...t];return s?r?.valueAccessor?l.sort((t,e)=>s(a(t,r),a(e,r),t,e)*n):l.sort((t,e)=>s(t[i],e[i],t,e)*n):r?.valueAccessor?function(t,e,o){t.sort((t,r)=>{const s=d(t,r);if(0!==s)return s;const i=a(t,e),n=a(r,e);return null==i&&null==n?0:null==i?-o:null==n||i>n?o:i<n?-o:0})}(l,r,n):function(t,e,o){t.sort((t,r)=>{const s=d(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})}(l,i,n),l}function d(t,e){const o=!0===t?.__loading;return o===(!0===e?.__loading)?0:o?1:-1}var c="__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("")),u=(new RegExp(`__(proto|defineGetter|defineSetter)|${c.slice(3).join("|")}|this\\b`),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("|"))),h=/^on\w+$/i,g=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),f=/^\s*(javascript|vbscript|data|blob):/i;function m(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(u.has(t)){e.push(r);continue}if(("svg"===t||"http://www.w3.org/2000/svg"===r.namespaceURI)&&Array.from(r.attributes).some(t=>h.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();h.test(t)?o.push(e.name):(g.has(t)&&f.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}var b=class{static dependencies;static manifest;aliases;version="3.0.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,o={...t.userConfig};for(const r of Object.keys(e))delete e[r];Object.assign(e,o)}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;return!e||"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}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=m(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))}};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(/* @__PURE__ */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 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}}}}var k=class extends b{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{_virtualization:t}=this.grid,o=this.config.pageSize??100,i=this.getViewportMapping(t.start,t.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??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??l)(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??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}isNodeLoaded(t){const e=p(t,this.config.pageSize??100);return this.loadedBlocks.has(e)}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}`:""}]`}var t="TBW072",o="TBW073",n="TBW074";function r(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 l(e,t,o,n){console.warn(r(e,t,o,n))}var 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("")),i=(new RegExp(`__(proto|defineGetter|defineSetter)|${s.slice(3).join("|")}|this\\b`),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("|")),c=/^\s*(javascript|vbscript|data|blob):/i;function h(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(i.has(e)){t.push(n);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI)&&Array.from(n.attributes).some(e=>a.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();a.test(e)?o.push(t.name):(d.has(e)&&c.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}var p={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var u=class{static dependencies;static manifest;aliases;version="3.0.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 n of e){const e=n.userConfig;for(const[l,s]of Object.entries(e)){if(void 0===s)continue;if(!(l in t)){t[l]=s,o[l]=n;continue}if(t[l]===s)continue;const e=o[l]?.constructor.name??this.constructor.name,i=n.constructor.name,a=r("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,o={...e.userConfig};for(const n of Object.keys(t))delete t[n];Object.assign(t,o)}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{...p,...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;return!t||"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}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=h(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(r(t,o,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(e,t){throw new Error(r(e,t,this.gridElement.id,this.name))}},g="tbw-grid-root";function b(e,t){if(t)for(const o in t){const n=t[o];null!=n&&e.setAttribute(o,n)}}function f(e,t,o){const n=document.createElement(e);if(b(n,t),o)for(const r of o)null!=r&&("string"==typeof r?n.appendChild(document.createTextNode(r)):n.appendChild(r));return n}function w(e,t){const o=document.createElement("div");return e&&(o.className=e),b(o,t),o}function C(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),b(n,t),o&&("string"==typeof o?n.textContent=o:n.appendChild(o)),n}var m=document.createElement("template");function v(){return m.content.cloneNode(!0)}function y(e){const t=document.createDocumentFragment(),o=w(e.hasShell?`${g} has-shell`:g);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=w("tbw-grid-content");e.appendChild(v()),o.appendChild(e)}return t.appendChild(o),t}function P(e){const t=w("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=w("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=w("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=w("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const s of e.configButtons)s.hasRender&&n.appendChild(w("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));for(const s of e.apiButtons)s.hasRender&&n.appendChild(w("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(w("tbw-toolbar-separator")),l){const t=C(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=h(e.toolPanelIcon)),n.appendChild(t)}return t.appendChild(n),t}function S(e){const t=e.mode??"overlay",o=w("tbw-shell-body",{"data-mode":t}),n=e.panels.length>0,r=1===e.panels.length,l=w("tbw-grid-content");l.appendChild(v());let s=null;if(n){s=f("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(w("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":o,"aria-hidden":"true"}));const n=e=>{const t=C(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=w("tbw-tool-panel-header",{part:"tool-panel-header"});e.appendChild(n(!1)),s.appendChild(e)}const i=w("tbw-tool-panel-content",{role:"presentation"}),a=w("tbw-accordion");for(const t of e.panels){const o=w(`tbw-accordion-section${t.isExpanded?" expanded":""}${r?" single":""}${l?" has-inline-close":""}`,{"data-section":t.id}),s=C("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=f("span",{class:"tbw-accordion-icon"});e.innerHTML=h(t.icon),s.appendChild(e)}const i=f("span",{class:"tbw-accordion-title"});if(i.textContent=t.title,s.appendChild(i),!r){const t=f("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=h(e.expandIcon)),s.appendChild(t)}if(l){const e=w("tbw-accordion-header-row");e.appendChild(s),e.appendChild(n(!0)),o.appendChild(e)}else o.appendChild(s);o.appendChild(w("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?h(e):e.outerHTML:""}function T(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function O(e){return!1!==e?.header?.visible}function E(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function D(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 _(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 H(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function L(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';var R="--tbw-tool-panel-anchor",A=0;function k(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",R)}function q(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(k()){const e=`${R}-${++A}`;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 $(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 z(e,t,o,n){const r=e.querySelector(`.${g}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=T(t),l=[];for(let s=e.firstChild;s;s=s.nextSibling)1===s.nodeType&&s.classList.contains(g)||l.push(s);e.replaceChildren();for(const s of l)e.appendChild(s);if(r){const{headerOptions:r,bodyOptions:l}=$(t,o,n),s=y({hasShell:!0,shellHeader:O(t)?P(r):void 0,shellBody:S(l)});e.appendChild(s)}else{const t=y({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const s=T(t);if(r.replaceChildren(),s){r.className=`${g} has-shell`;const{headerOptions:e,bodyOptions:s}=$(t,o,n),i=O(t)?P(e):void 0,a=S(s),d=a.querySelector(".tbw-grid-content");d&&d.replaceWith(l),i&&r.appendChild(i),r.appendChild(a)}else r.className=g,r.appendChild(l);return s}function M(e,r){let s=!1;const i={get isInitialized(){return s},setInitialized(e){s=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(o,n){if(0===e.toolPanels.size)return void l("TBW071","No tool panels registered",r.id);let s;if(void 0!==o&&(e.toolPanels.has(o)?s=o:l(t,`Tool panel "${o}" not found`,r.id)),e.isPanelOpen&&s&&e.expandedSections.has(s))return;if(e.isPanelOpen&&s&&!e.expandedSections.has(s))return void i.toggleToolPanelSection(s);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(s)e.expandedSections.add(s);else{const t=r.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(s&&!e.expandedSections.has(s)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(s)}const a=r._renderRoot;if(H(a,e),L(a,e),_(a,e,r._accordionIcons),"dropdown"===r.effectiveConfig?.shell?.toolPanel?.mode){const{el:t,corner:o}=function(e){if(e)return{el:e,corner:!1};const t=r._renderRoot.querySelector("[data-panel-toggle]");return t?{el:t,corner:!1}:{el:r._hostElement,corner:!0}}(n?.anchor);q(a,e,t,o)}r._emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(r.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=r._renderRoot;H(t,e),L(t,e),"dropdown"===r.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),r._emit("tool-panel-close",{})},toggleToolPanel(t){e.isPanelOpen?i.closeToolPanel():i.openToolPanel(void 0,t)},reanchorOpenDropdown(){if(!e.isPanelOpen)return;if("dropdown"!==r.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!==r._hostElement&&"below"===r._renderRoot.querySelector(".tbw-tool-panel")?.dataset.anchor)return;const o=r._renderRoot.querySelector("[data-panel-toggle]");if(o&&o!==r._hostElement){if(e.dropdownAnchorName&&k()&&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}(r._renderRoot,e,o))return;q(r._renderRoot,e,o,!1)}else t!==r._hostElement||q(r._renderRoot,e,r._hostElement,!0)},toggleToolPanelSection(o){const n=e.toolPanels.get(o);if(!n)return void l(t,`Tool panel section "${o}" not found`,r.id);if(1===e.toolPanels.size)return;const s=r._renderRoot,i=e.expandedSections.has(o);if(i){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),n.onClose?.(),e.expandedSections.delete(o),B(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),B(s,t,!1);const r=s.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),B(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)}r._emit("tool-panel-section-toggle",{id:o,expanded:!i})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(t){e.toolPanels.has(t.id)?l(o,`Tool panel "${t.id}" already registered`,r.id):(e.toolPanels.set(t.id,t),(s||r._hostElement.isConnected)&&r.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),(s||r._hostElement.isConnected)&&r.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(t){e.headerContents.has(t.id)?l(n,`Header content "${t.id}" already registered`,r.id):(e.headerContents.set(t.id,t),s?D(r._renderRoot,e):r._hostElement.isConnected&&r.refreshShellHeader?.())},unregisterHeaderContent(t){const o=e.headerContentCleanups.get(t);o&&(o(),e.headerContentCleanups.delete(t)),e.headerContents.get(t)?.onDestroy?.(),e.headerContents.delete(t),r._renderRoot.querySelector(`[data-header-content="${t}"]`)?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(t){e.toolbarContents.has(t.id)?l("TBW075",`Toolbar content "${t.id}" already registered`,r.id):(e.toolbarContents.set(t.id,t),(s||r._hostElement.isConnected)&&r.refreshShellHeader?.())},unregisterToolbarContent(t){const o=e.toolbarContentCleanups.get(t);o&&(o(),e.toolbarContentCleanups.delete(t));const n=e.toolbarContents.get(t);n?.onDestroy&&n.onDestroy(),e.toolbarContents.delete(t),s&&r.refreshShellHeader?.()}};return i}function B(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}var N=class extends u{name="shell";styles="@layer tbw-base{tbw-grid .tbw-shell-header{min-height:var(--tbw-shell-header-height);background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0;align-items:center;gap:8px;padding:0 8px;display:flex}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}tbw-grid .tbw-shell-content{flex:1;align-items:center;gap:12px;min-width:0;display:flex;overflow:hidden}tbw-grid .tbw-shell-toolbar{align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0;display:flex}tbw-grid .tbw-toolbar-btn{width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);border-radius:var(--tbw-border-radius);color:var(--tbw-color-fg);cursor:pointer;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease), border-color var(--tbw-transition-duration) var(--tbw-transition-ease);background:0 0;border:1px solid #0000;justify-content:center;align-items:center;padding:0;font-size:16px;display:inline-flex}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{background:var(--tbw-color-border);width:1px;height:20px;margin:0 4px}tbw-grid .tbw-shell-body{flex:1;min-height:0;display:flex;position:relative;overflow:visible}tbw-grid .tbw-tool-panel{background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);width:0;transition:width var(--tbw-tool-panel-transition);z-index:var(--tbw-z-layer-toolpanel,31);box-shadow:-2px 0 8px var(--tbw-color-shadow);flex-direction:column;display:flex;position:absolute;top:0;bottom:0;right:0;overflow:hidden}tbw-grid .tbw-tool-panel[data-position=left]{border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow);left:0;right:auto}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel{box-shadow:none;z-index:auto;border-left:none;border-right:none;flex-shrink:0;position:relative;inset:auto}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]{width:var(--tbw-tool-panel-width);border:1px solid var(--tbw-tool-panel-border);border-radius:var(--tbw-border-radius,6px);max-width:calc(100vw - 16px);height:auto;max-height:min(70vh,480px);box-shadow:0 8px 24px var(--tbw-color-shadow);margin:4px 0 0;padding:0;transition:none;display:none;position:fixed;inset:auto;overflow:hidden auto}:is(tbw-grid .tbw-tool-panel[popover]:popover-open,tbw-grid .tbw-tool-panel[popover].open){width:var(--tbw-tool-panel-width);display:flex}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);position-try-fallbacks:flip-block, flip-inline, flip-block flip-inline;left:auto}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{cursor:col-resize;z-index:10;width:6px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease);background:0 0;position:absolute;top:0;bottom:0}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{min-height:var(--tbw-tool-panel-header-height);border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0;justify-content:flex-end;align-items:center;padding:0 12px;display:flex}tbw-grid .tbw-tool-panel-title{white-space:nowrap;text-overflow:ellipsis;font-size:13px;font-weight:600;overflow:hidden}tbw-grid .tbw-tool-panel-close{border-radius:var(--tbw-border-radius);width:24px;height:24px;color:var(--tbw-color-fg-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;font-size:14px;display:inline-flex}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-accordion-header-row{align-items:stretch;display:flex}tbw-grid .tbw-accordion-header-row .tbw-accordion-header{flex:1;min-width:0}tbw-grid .tbw-tool-panel-close--inline{flex-shrink:0;align-self:center;margin-inline-end:8px}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{flex-direction:column;gap:0;display:flex}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:0 0}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{width:100%;color:var(--tbw-color-fg);text-align:start;cursor:pointer;-webkit-user-select:none;user-select:none;background:0 0;border:none;align-items:center;gap:8px;padding:10px 12px;font-size:13px;font-weight:600;display:flex}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{width:16px;height:16px;color:var(--tbw-color-fg-muted);flex-shrink:0;justify-content:center;align-items:center;font-size:10px;transition:transform .15s;display:inline-flex}tbw-grid .tbw-accordion-icon{flex-shrink:0;justify-content:center;align-items:center;width:16px;height:16px;font-size:14px;display:inline-flex}tbw-grid .tbw-accordion-title{text-overflow:ellipsis;white-space:nowrap;flex:1;overflow:hidden}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=M(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),this.ensureState(e);const t=()=>this.syncLightDom();this.#i=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#c(e){const t=e._hostElement;!function(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"}(t,this.shellState),function(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:o?.(n)??(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"}(t,this.shellState),function(e,t,n){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const r=e,s=r.getAttribute("id"),i=r.getAttribute("title");if(!s||!i)return void l("TBW070",`Tool panel missing required id or title attribute: id="${s??""}", title="${i??""}"`);const a=r.getAttribute("icon")??void 0,d=r.getAttribute("tooltip")??void 0,c=parseInt(r.getAttribute("order")??"100",10);let p;const u=n?.(r);if(u)p=u;else{const e=h(r.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 l(o,`Tool panel "${s}" is already provided by a plugin or the grid API; ignoring the matching light-DOM <tbw-grid-tool-panel>.`),void(r.style.display="none");if(g){if(u){const e=!t.adapterBoundToolPanelIds.has(s),o=g.order!==c||g.icon!==a||g.tooltip!==d;if(g.render=p,g.order=c,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:c,render:p};t.toolPanels.set(s,b),t.lightDomToolPanelIds.add(s),u&&t.adapterBoundToolPanelIds.add(s),r.style.display="none"})}(t,this.shellState,e._getToolPanelRendererFactory())}syncLightDom(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState,o=t.lightDomTitle,n=t.hasToolButtonsContainer;this.#c(e);const r=t.lightDomTitle,l=t.hasToolButtonsContainer;(r&&!o||l&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(I(t),this.afterStructuralRender()))}parseLightDom(){const e=this.grid;e&&this.hasState&&this.#c(e)}beforeStructuralRender(){this.hasState&&I(this.shellState)}needsStructuralRerender(){const e=this.grid;if(!e||!this.hasState)return!1;const t=e._renderRoot,o=!!t.querySelector(".has-shell"),n=!!t.querySelector(".tbw-tool-panel"),r=t.querySelectorAll(".tbw-accordion-section").length,l=t.querySelector(".tbw-tool-panel")?.dataset.position??"right",s=t.querySelector(".tbw-shell-body")?.dataset.mode??"overlay",i=e.effectiveConfig?.shell;return o!==T(i)||!n&&(i?.toolPanels?.length??0)>0||n&&(i?.toolPanels?.length??0)!==r||n&&l!==(i?.toolPanel?.position??"right")||n&&s!==(i?.toolPanel?.mode??"overlay")}#h(e){const t=this.shellState,r=e._hostElement.id;for(const o of[...t.toolPanels.keys()])t.lightDomToolPanelIds.has(o)||t.apiToolPanelIds.has(o)||(t.panelCleanups.get(o)?.(),t.panelCleanups.delete(o),t.toolPanels.delete(o));for(const o of[...t.headerContents.keys()])t.apiHeaderContentIds.has(o)||(t.headerContentCleanups.get(o)?.(),t.headerContentCleanups.delete(o),t.headerContents.delete(o));const{toolPanels:s,headerContents:i}=e._pluginShellContributions();for(const n of s)t.apiToolPanelIds.has(n.id)||(t.lightDomToolPanelIds.has(n.id)&&(l(o,`Tool panel "${n.id}" is provided by a plugin; ignoring the matching light-DOM <tbw-grid-tool-panel>.`,r),t.panelCleanups.get(n.id)?.(),t.panelCleanups.delete(n.id),t.lightDomToolPanelIds.delete(n.id),t.adapterBoundToolPanelIds.delete(n.id)),t.toolPanels.set(n.id,n));for(const o of i)t.apiHeaderContentIds.has(o.id)||(t.headerContents.has(o.id)&&(l(n,`Header content "${o.id}" is provided by a plugin; ignoring the matching light-DOM definition.`,r),t.headerContentCleanups.get(o.id)?.(),t.headerContentCleanups.delete(o.id)),t.headerContents.set(o.id,o))}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.grid;o&&(this.#c(o),this.#h(o));const n=this.resolvedConfig;if(e.shell={...n,...e.shell},e.shell.header={...n.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 r=Array.from(t.toolbarContents.values()),l=this.grid?._sourceConfig?.shell?.header?.toolbarContents??[],s=new Set(l.map(e=>e.id)),i=[...l];for(const a of r)s.has(a.id)||i.push(a);i.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=i}afterStructuralRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;z(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;if(!e||!this.hasState)return;const t=this.shellState;this.#g(e),t.isPanelOpen&&_(e._renderRoot,t),t.isPanelOpen?(this.shellController.reanchorOpenDropdown(),this.#b(e)):this.#f()}#g(e){const t=e._renderRoot.querySelector(".tbw-shell-header");if(!t)return;const o=e.effectiveConfig?.shell?.header?.title??this.shellState.lightDomTitle;let n=t.querySelector(".tbw-shell-title");o?(n||(n=document.createElement("h2"),n.className="tbw-shell-title",n.setAttribute("part","shell-title"),t.insertBefore(n,t.firstChild)),n.textContent=o):n&&n.remove()}#b(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.#f()})),this.#d||(this.#a.observe(e._renderRoot,{childList:!0,subtree:!0}),this.#d=!0)):this.#f()}#f(){this.#a&&this.#d&&(this.#a.disconnect(),this.#d=!1)}#u(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;D(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&&(L(o,t),_(o,t,(e.effectiveConfig,e.effectiveConfig)),H(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]")?.getAttribute("data-section");e&&n.onSectionToggle(e)}})}(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]"))&&E(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())}#w(){this.#r?.(),this.#r=void 0,this.#l?.(),this.#l=void 0,this.#s?.(),this.#s=void 0}detach(){super.detach()}disposeShellState(){this.#w(),this.#f(),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)e.toolPanels.get(t)?.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{N as ShellPlugin};
|
|
1
|
+
function e(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}var t="TBW072",o="TBW073",n="TBW074";function r(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 l(e,t,o,n){console.warn(r(e,t,o,n))}var 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("")),i=(new RegExp(`__(proto|defineGetter|defineSetter)|${s.slice(3).join("|")}|this\\b`),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("|")),c=/^\s*(javascript|vbscript|data|blob):/i;function h(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(i.has(e)){t.push(n);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI)&&Array.from(n.attributes).some(e=>a.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();a.test(e)?o.push(t.name):(d.has(e)&&c.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}var p={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var u=class{static dependencies;static manifest;aliases;version="3.0.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 n of e){const e=n.userConfig;for(const[l,s]of Object.entries(e)){if(void 0===s)continue;if(!(l in t)){t[l]=s,o[l]=n;continue}if(t[l]===s)continue;const e=o[l]?.constructor.name??this.constructor.name,i=n.constructor.name,a=r("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,o={...e.userConfig};for(const n of Object.keys(t))delete t[n];Object.assign(t,o)}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{...p,...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;return!t||"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}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=h(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(r(t,o,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(e,t){throw new Error(r(e,t,this.gridElement.id,this.name))}},g="tbw-grid-root";function b(e,t){if(t)for(const o in t){const n=t[o];null!=n&&e.setAttribute(o,n)}}function f(e,t,o){const n=document.createElement(e);if(b(n,t),o)for(const r of o)null!=r&&("string"==typeof r?n.appendChild(document.createTextNode(r)):n.appendChild(r));return n}function w(e,t){const o=document.createElement("div");return e&&(o.className=e),b(o,t),o}function C(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),b(n,t),o&&("string"==typeof o?n.textContent=o:n.appendChild(o)),n}var m=document.createElement("template");function v(){return m.content.cloneNode(!0)}function y(e){const t=document.createDocumentFragment(),o=w(e.hasShell?`${g} has-shell`:g);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=w("tbw-grid-content");e.appendChild(v()),o.appendChild(e)}return t.appendChild(o),t}function P(e){const t=w("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=w("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=w("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=w("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const s of e.configButtons)s.hasRender&&n.appendChild(w("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));for(const s of e.apiButtons)s.hasRender&&n.appendChild(w("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(w("tbw-toolbar-separator")),l){const t=C(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=h(e.toolPanelIcon)),n.appendChild(t)}return t.appendChild(n),t}function S(e){const t=e.mode??"overlay",o=w("tbw-shell-body",{"data-mode":t}),n=e.panels.length>0,r=1===e.panels.length,l=w("tbw-grid-content");l.appendChild(v());let s=null;if(n){s=f("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(w("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":o,"aria-hidden":"true"}));const n=e=>{const t=C(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=w("tbw-tool-panel-header",{part:"tool-panel-header"});e.appendChild(n(!1)),s.appendChild(e)}const i=w("tbw-tool-panel-content",{role:"presentation"}),a=w("tbw-accordion");for(const t of e.panels){const o=w(`tbw-accordion-section${t.isExpanded?" expanded":""}${r?" single":""}${l?" has-inline-close":""}`,{"data-section":t.id}),s=C("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=f("span",{class:"tbw-accordion-icon"});e.innerHTML=h(t.icon),s.appendChild(e)}const i=f("span",{class:"tbw-accordion-title"});if(i.textContent=t.title,s.appendChild(i),!r){const t=f("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=h(e.expandIcon)),s.appendChild(t)}if(l){const e=w("tbw-accordion-header-row");e.appendChild(s),e.appendChild(n(!0)),o.appendChild(e)}else o.appendChild(s);o.appendChild(w("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?h(e):e.outerHTML:""}function T(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function O(e){return!1!==e?.header?.visible}function E(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function D(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 _(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 H(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function L(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';var R="--tbw-tool-panel-anchor",A=0;function k(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",R)}function q(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(k()){const e=`${R}-${++A}`;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 $(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 z(e,t,o,n){const r=e.querySelector(`.${g}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=T(t),l=[];for(let s=e.firstChild;s;s=s.nextSibling)1===s.nodeType&&s.classList.contains(g)||l.push(s);e.replaceChildren();for(const s of l)e.appendChild(s);if(r){const{headerOptions:r,bodyOptions:l}=$(t,o,n),s=y({hasShell:!0,shellHeader:O(t)?P(r):void 0,shellBody:S(l)});e.appendChild(s)}else{const t=y({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const s=T(t);if(r.replaceChildren(),s){r.className=`${g} has-shell`;const{headerOptions:e,bodyOptions:s}=$(t,o,n),i=O(t)?P(e):void 0,a=S(s),d=a.querySelector(".tbw-grid-content");d&&d.replaceWith(l),i&&r.appendChild(i),r.appendChild(a)}else r.className=g,r.appendChild(l);return s}function M(e,r){let s=!1;const i={get isInitialized(){return s},setInitialized(e){s=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(o,n){if(0===e.toolPanels.size)return void l("TBW071","No tool panels registered",r.id);let s;if(void 0!==o&&(e.toolPanels.has(o)?s=o:l(t,`Tool panel "${o}" not found`,r.id)),e.isPanelOpen&&s&&e.expandedSections.has(s))return;if(e.isPanelOpen&&s&&!e.expandedSections.has(s))return void i.toggleToolPanelSection(s);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(s)e.expandedSections.add(s);else{const t=r.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(s&&!e.expandedSections.has(s)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(s)}const a=r._renderRoot;if(H(a,e),L(a,e),_(a,e,r._accordionIcons),"dropdown"===r.effectiveConfig?.shell?.toolPanel?.mode){const{el:t,corner:o}=function(e){if(e)return{el:e,corner:!1};const t=r._renderRoot.querySelector("[data-panel-toggle]");return t?{el:t,corner:!1}:{el:r._hostElement,corner:!0}}(n?.anchor);q(a,e,t,o)}r._emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(r.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=r._renderRoot;H(t,e),L(t,e),"dropdown"===r.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),r._emit("tool-panel-close",{})},toggleToolPanel(t){e.isPanelOpen?i.closeToolPanel():i.openToolPanel(void 0,t)},reanchorOpenDropdown(){if(!e.isPanelOpen)return;if("dropdown"!==r.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!==r._hostElement&&"below"===r._renderRoot.querySelector(".tbw-tool-panel")?.dataset.anchor)return;const o=r._renderRoot.querySelector("[data-panel-toggle]");if(o&&o!==r._hostElement){if(e.dropdownAnchorName&&k()&&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}(r._renderRoot,e,o))return;q(r._renderRoot,e,o,!1)}else t!==r._hostElement||q(r._renderRoot,e,r._hostElement,!0)},toggleToolPanelSection(o){const n=e.toolPanels.get(o);if(!n)return void l(t,`Tool panel section "${o}" not found`,r.id);if(1===e.toolPanels.size)return;const s=r._renderRoot,i=e.expandedSections.has(o);if(i){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),n.onClose?.(),e.expandedSections.delete(o),B(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),B(s,t,!1);const r=s.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),B(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)}r._emit("tool-panel-section-toggle",{id:o,expanded:!i})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(t){e.toolPanels.has(t.id)?l(o,`Tool panel "${t.id}" already registered`,r.id):(e.toolPanels.set(t.id,t),(s||r._hostElement.isConnected)&&r.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),(s||r._hostElement.isConnected)&&r.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(t){e.headerContents.has(t.id)?l(n,`Header content "${t.id}" already registered`,r.id):(e.headerContents.set(t.id,t),s?D(r._renderRoot,e):r._hostElement.isConnected&&r.refreshShellHeader?.())},unregisterHeaderContent(t){const o=e.headerContentCleanups.get(t);o&&(o(),e.headerContentCleanups.delete(t)),e.headerContents.get(t)?.onDestroy?.(),e.headerContents.delete(t),r._renderRoot.querySelector(`[data-header-content="${t}"]`)?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(t){e.toolbarContents.has(t.id)?l("TBW075",`Toolbar content "${t.id}" already registered`,r.id):(e.toolbarContents.set(t.id,t),(s||r._hostElement.isConnected)&&r.refreshShellHeader?.())},unregisterToolbarContent(t){const o=e.toolbarContentCleanups.get(t);o&&(o(),e.toolbarContentCleanups.delete(t));const n=e.toolbarContents.get(t);n?.onDestroy&&n.onDestroy(),e.toolbarContents.delete(t),s&&r.refreshShellHeader?.()}};return i}function B(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}var N=class extends u{name="shell";styles="@layer tbw-base{tbw-grid .tbw-shell-header{min-height:var(--tbw-shell-header-height);background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0;align-items:center;gap:8px;padding:0 8px;display:flex}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}tbw-grid .tbw-shell-content{flex:1;align-items:center;gap:12px;min-width:0;display:flex;overflow:hidden}tbw-grid .tbw-shell-toolbar{align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0;display:flex}tbw-grid .tbw-toolbar-btn{width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);border-radius:var(--tbw-border-radius);color:var(--tbw-color-fg);cursor:pointer;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease), border-color var(--tbw-transition-duration) var(--tbw-transition-ease);background:0 0;border:1px solid #0000;justify-content:center;align-items:center;padding:0;font-size:16px;display:inline-flex}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{background:var(--tbw-color-border);width:1px;height:20px;margin:0 4px}tbw-grid .tbw-shell-body{flex:1;min-height:0;display:flex;position:relative;overflow:visible}tbw-grid .tbw-tool-panel{background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);width:0;transition:width var(--tbw-tool-panel-transition);z-index:var(--tbw-z-layer-toolpanel,31);box-shadow:-2px 0 8px var(--tbw-color-shadow);flex-direction:column;display:flex;position:absolute;top:0;bottom:0;right:0;overflow:hidden}tbw-grid .tbw-tool-panel[data-position=left]{border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow);left:0;right:auto}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel{box-shadow:none;z-index:auto;border-left:none;border-right:none;flex-shrink:0;position:relative;inset:auto}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]{width:var(--tbw-tool-panel-width);border:1px solid var(--tbw-tool-panel-border);border-radius:var(--tbw-border-radius,6px);max-width:calc(100vw - 16px);height:auto;max-height:min(70vh,480px);box-shadow:0 8px 24px var(--tbw-color-shadow);margin:4px 0 0;padding:0;transition:none;display:none;position:fixed;inset:auto;overflow:hidden auto}:is(tbw-grid .tbw-tool-panel[popover]:popover-open,tbw-grid .tbw-tool-panel[popover].open){width:var(--tbw-tool-panel-width);display:flex}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);position-try-fallbacks:flip-block, flip-inline, flip-block flip-inline;left:auto}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{cursor:col-resize;z-index:10;width:6px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease);background:0 0;position:absolute;top:0;bottom:0}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{min-height:var(--tbw-tool-panel-header-height);border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0;justify-content:flex-end;align-items:center;padding:0 12px;display:flex}tbw-grid .tbw-tool-panel-title{white-space:nowrap;text-overflow:ellipsis;font-size:13px;font-weight:600;overflow:hidden}tbw-grid .tbw-tool-panel-close{border-radius:var(--tbw-border-radius);width:24px;height:24px;color:var(--tbw-color-fg-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;font-size:14px;display:inline-flex}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-accordion-header-row{align-items:stretch;display:flex}tbw-grid .tbw-accordion-header-row .tbw-accordion-header{flex:1;min-width:0}tbw-grid .tbw-tool-panel-close--inline{flex-shrink:0;align-self:center;margin-inline-end:8px}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{flex-direction:column;gap:0;display:flex}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:0 0}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{width:100%;color:var(--tbw-color-fg);text-align:start;cursor:pointer;-webkit-user-select:none;user-select:none;background:0 0;border:none;align-items:center;gap:8px;padding:10px 12px;font-size:13px;font-weight:600;display:flex}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{width:16px;height:16px;color:var(--tbw-color-fg-muted);flex-shrink:0;justify-content:center;align-items:center;font-size:10px;transition:transform .15s;display:inline-flex}tbw-grid .tbw-accordion-icon{flex-shrink:0;justify-content:center;align-items:center;width:16px;height:16px;font-size:14px;display:inline-flex}tbw-grid .tbw-accordion-title{text-overflow:ellipsis;white-space:nowrap;flex:1;overflow:hidden}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=M(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),this.ensureState(e);const t=()=>this.syncLightDom();this.#i=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#c(e){const t=e._hostElement;!function(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"}(t,this.shellState),function(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:o?.(n)??(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"}(t,this.shellState),function(e,t,n){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const r=e,s=r.getAttribute("id"),i=r.getAttribute("title");if(!s||!i)return void l("TBW070",`Tool panel missing required id or title attribute: id="${s??""}", title="${i??""}"`);const a=r.getAttribute("icon")??void 0,d=r.getAttribute("tooltip")??void 0,c=parseInt(r.getAttribute("order")??"100",10);let p;const u=n?.(r);if(u)p=u;else{const e=h(r.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 l(o,`Tool panel "${s}" is already provided by a plugin or the grid API; ignoring the matching light-DOM <tbw-grid-tool-panel>.`),void(r.style.display="none");if(g){if(u){const e=!t.adapterBoundToolPanelIds.has(s),o=g.order!==c||g.icon!==a||g.tooltip!==d;if(g.render=p,g.order=c,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:c,render:p};t.toolPanels.set(s,b),t.lightDomToolPanelIds.add(s),u&&t.adapterBoundToolPanelIds.add(s),r.style.display="none"})}(t,this.shellState,e._getToolPanelRendererFactory())}syncLightDom(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState,o=t.lightDomTitle,n=t.hasToolButtonsContainer;this.#c(e);const r=t.lightDomTitle,l=t.hasToolButtonsContainer;(r&&!o||l&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(I(t),this.afterStructuralRender()))}parseLightDom(){const e=this.grid;e&&this.hasState&&this.#c(e)}beforeStructuralRender(){this.hasState&&I(this.shellState)}needsStructuralRerender(){const e=this.grid;if(!e||!this.hasState)return!1;const t=e._renderRoot,o=!!t.querySelector(".has-shell"),n=!!t.querySelector(".tbw-tool-panel"),r=t.querySelectorAll(".tbw-accordion-section").length,l=t.querySelector(".tbw-tool-panel")?.dataset.position??"right",s=t.querySelector(".tbw-shell-body")?.dataset.mode??"overlay",i=e.effectiveConfig?.shell;return o!==T(i)||!n&&(i?.toolPanels?.length??0)>0||n&&(i?.toolPanels?.length??0)!==r||n&&l!==(i?.toolPanel?.position??"right")||n&&s!==(i?.toolPanel?.mode??"overlay")}#h(e){const t=this.shellState,r=e._hostElement.id;for(const o of[...t.toolPanels.keys()])t.lightDomToolPanelIds.has(o)||t.apiToolPanelIds.has(o)||(t.panelCleanups.get(o)?.(),t.panelCleanups.delete(o),t.toolPanels.delete(o));for(const o of[...t.headerContents.keys()])t.apiHeaderContentIds.has(o)||(t.headerContentCleanups.get(o)?.(),t.headerContentCleanups.delete(o),t.headerContents.delete(o));const{toolPanels:s,headerContents:i}=e._pluginShellContributions();for(const n of s)t.apiToolPanelIds.has(n.id)||(t.lightDomToolPanelIds.has(n.id)&&(l(o,`Tool panel "${n.id}" is provided by a plugin; ignoring the matching light-DOM <tbw-grid-tool-panel>.`,r),t.panelCleanups.get(n.id)?.(),t.panelCleanups.delete(n.id),t.lightDomToolPanelIds.delete(n.id),t.adapterBoundToolPanelIds.delete(n.id)),t.toolPanels.set(n.id,n));for(const o of i)t.apiHeaderContentIds.has(o.id)||(t.headerContents.has(o.id)&&(l(n,`Header content "${o.id}" is provided by a plugin; ignoring the matching light-DOM definition.`,r),t.headerContentCleanups.get(o.id)?.(),t.headerContentCleanups.delete(o.id)),t.headerContents.set(o.id,o))}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.grid;o&&(this.#c(o),this.#h(o));const n=this.resolvedConfig;if(e.shell={...n,...e.shell},e.shell.header={...n.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 r=Array.from(t.toolbarContents.values()),l=this.grid?._sourceConfig?.shell?.header?.toolbarContents??[],s=new Set(l.map(e=>e.id)),i=[...l];for(const a of r)s.has(a.id)||i.push(a);i.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=i}afterStructuralRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;z(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;if(!e||!this.hasState)return;const t=this.shellState;this.#g(e),t.isPanelOpen&&_(e._renderRoot,t),t.isPanelOpen?(this.shellController.reanchorOpenDropdown(),this.#b(e)):this.#f()}#g(e){const t=e._renderRoot.querySelector(".tbw-shell-header");if(!t)return;const o=e.effectiveConfig?.shell?.header?.title??this.shellState.lightDomTitle;let n=t.querySelector(".tbw-shell-title");o?(n||(n=document.createElement("h2"),n.className="tbw-shell-title",n.setAttribute("part","shell-title"),t.insertBefore(n,t.firstChild)),n.textContent=o):n&&n.remove()}#b(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.#f()})),this.#d||(this.#a.observe(e._renderRoot,{childList:!0,subtree:!0}),this.#d=!0)):this.#f()}#f(){this.#a&&this.#d&&(this.#a.disconnect(),this.#d=!1)}#u(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;D(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&&(L(o,t),_(o,t,(e.effectiveConfig,e.effectiveConfig)),H(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]")?.getAttribute("data-section");e&&n.onSectionToggle(e)}})}(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]"))&&E(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())}#w(){this.#r?.(),this.#r=void 0,this.#l?.(),this.#l=void 0,this.#s?.(),this.#s=void 0}detach(){super.detach()}disposeShellState(){this.#w(),this.#f(),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)e.toolPanels.get(t)?.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{N as ShellPlugin};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function t(t,s,i,r){return`${e(i,r)} ${t}: ${s}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(t)}`}var 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("")),i=(new RegExp(`__(proto|defineGetter|defineSetter)|${s.slice(3).join("|")}|this\\b`),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("|"))),r=/^on\w+$/i,n=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),o=/^\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=[],s=e.querySelectorAll("*");for(const c of s){const e=c.tagName.toLowerCase();if(i.has(e)){t.push(c);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===c.namespaceURI)&&Array.from(c.attributes).some(e=>r.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(c);continue}const s=[];for(const t of c.attributes){const e=t.name.toLowerCase();r.test(e)?s.push(t.name):(n.has(e)&&o.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&s.push(t.name)}s.forEach(e=>c.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}var a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var l=class{static dependencies;static manifest;aliases;version="3.0.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 s={...this.userConfig},i={};for(const t of Object.keys(s))i[t]=this;for(const r of e){const e=r.userConfig;for(const[n,o]of Object.entries(e)){if(void 0===o)continue;if(!(n in s)){s[n]=o,i[n]=r;continue}if(s[n]===o)continue;const e=i[n]?.constructor.name??this.constructor.name,c=r.constructor.name,a=t("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${n}" supplied by both ${e} 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,s)}refreshUserConfigFrom(e){const t=this.userConfig,s={...e.userConfig};for(const i of Object.keys(t))delete t[i];Object.assign(t,s)}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 s=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(s),s.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{...a,...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;return!t||"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),s=parseInt(t,10);if(!isNaN(s))return s}return 200}setIcon(e,t,s){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const i=this.#t(t,s);void 0!==i?"string"==typeof i?e.innerHTML=c(i):i instanceof HTMLElement&&(e.innerHTML="",e.appendChild(i.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 s=document.createElement("span");s.setAttribute("part","sort-indicator"),s.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(s,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(s,"sortNone"));const i=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return i?e.insertBefore(s,i):e.appendChild(s),s}warn(s,i){void 0!==i?console.warn(t(s,i,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${s}`)}throwDiagnostic(e,s){throw new Error(t(e,s,this.gridElement.id,this.name))}},h=class extends l{name="stickyRows";styles="@layer tbw-plugins{.tbw-sticky-rows{z-index:var(--tbw-z-layer-sticky-rows,22);background:var(--tbw-color-bg,var(--tbw-color-panel-bg));width:fit-content;min-width:100%;display:block;position:absolute;top:0;left:0;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;settlePassScheduled=!1;detach(){this.container?.remove(),this.container=null,this.cloneCache.clear(),this.stickyIndices=[],this.displayedIndices=[],this.lastPushOffset=0,this.settlePassScheduled=!1}afterRender(){this.settlePassScheduled=!1,this.recomputeStickyIndices(),this.ensureContainer(),this.primeCloneCache(),this.refreshClonesInWindow(),this.refreshDisplay()}onScrollRender(){this.primeCloneCache(),this.refreshDisplay(),this.maybeScheduleSettlePass()}onScroll(e){this.refreshDisplay(e.scrollTop)}maybeScheduleSettlePass(){this.settlePassScheduled||this.stickyIndices.some(e=>null!=this.findRenderedRow(e))&&(this.settlePassScheduled=!0,this.requestAfterRender())}resolvePredicate(){const e=this.config.isSticky;if("function"==typeof e)return e;if("string"==typeof e){const t=e;return e=>null!=e&&"object"==typeof e&&Boolean(e[t])}return()=>!1}recomputeStickyIndices(){const e=this.rows,t=this.resolvePredicate(),s=[];for(let i=0;i<e.length;i++)t(e[i],i)&&s.push(i);(s.length!==this.stickyIndices.length||s.some((e,t)=>e!==this.stickyIndices[t]))&&this.cloneCache.clear(),this.stickyIndices=s}ensureContainer(){const e=this.gridElement;if(!e)return;const t=e.querySelector(".rows-viewport");t?this.container&&t.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),t.insertBefore(this.container,t.firstChild)):this.container=null}offsetOf(e){const t=this.getVirtualState(),s=t?.positionCache;return s&&s[e]?s[e].offset:e*(t?.rowHeight??28)}heightOf(e){const t=this.getVirtualState(),s=t?.positionCache;return s&&s[e]?s[e].height:t?.rowHeight??28}getVirtualState(){return this.grid?._virtualization}getCurrentScrollTop(){const e=this.getVirtualState(),t=e?.container?.scrollTop;return"number"==typeof t?t:"number"!=typeof e?.start||"number"!=typeof e?.rowHeight||e.positionCache&&e.positionCache.length?e?.positionCache&&"number"==typeof e.start&&e.positionCache[e.start]?e.positionCache[e.start].offset:0:e.start*e.rowHeight}computeDisplay(e){if("stack"===this.config.mode){const t=this.config.maxStacked??1/0,s=[];let i=0;for(const r of this.stickyIndices)if(s.length<t){if(!(this.offsetOf(r)<e+i))break;s.push(r),i+=this.heightOf(r)}else{const t=this.heightOf(s[0]);if(!(this.offsetOf(r)<e+i-t))break;s.shift(),i-=t,s.push(r),i+=this.heightOf(r)}if(s.length===t&&s.length>0){const t=this.findNextSticky(s[s.length-1]);if(null!=t){const r=this.offsetOf(t)-(e+i);if(r<0){const e=this.heightOf(s[0]);return{indices:s,pushOffset:Math.min(-r,e)}}}}return{indices:s,pushOffset:0}}const t=[];for(const n of this.stickyIndices){if(!(this.offsetOf(n)<e))break;t.push(n)}if(0===t.length)return{indices:t,pushOffset:0};const s=t[t.length-1],i=this.findNextSticky(s);let r=0;if(null!=i){const t=this.heightOf(s),n=this.offsetOf(i)-e;n<t&&(r=t-Math.max(0,n))}return{indices:[s],pushOffset:r}}findRenderedRow(e){const t=this.gridElement;return t?t.querySelector(`.rows .data-grid-row .cell[data-row="${e}"]`)?.parentElement??null:null}buildClone(e){const t=this.findRenderedRow(e);if(!t)return this.cloneCache.get(e)??null;const s=t.cloneNode(!0);return s.classList.add("tbw-sticky-row"),s.removeAttribute("aria-rowindex"),s.setAttribute("aria-hidden","true"),s.dataset.stickyRow=String(e),s.classList.remove("row-focus","cell-focus"),s.querySelectorAll(".cell-focus, .row-focus").forEach(e=>e.classList.remove("cell-focus","row-focus")),s.removeAttribute("tabindex"),s.querySelectorAll("[tabindex]").forEach(e=>e.removeAttribute("tabindex")),this.cloneCache.set(e,s),s}refreshClonesInWindow(){if(this.displayedIndices.length)for(const e of this.displayedIndices)if(this.findRenderedRow(e)){const t=this.buildClone(e),s=this.container?.querySelector(`[data-sticky-row="${e}"]`);t&&s&&s!==t&&s.replaceWith(t)}}primeCloneCache(){if(this.stickyIndices.length)for(const e of this.stickyIndices)this.findRenderedRow(e)&&this.buildClone(e)}refreshDisplay(e){if(!this.container)return;const t=e??this.getCurrentScrollTop(),{indices:s,pushOffset:i}=this.computeDisplay(t);if(this.container.dataset.mode!==this.config.mode&&(this.container.dataset.mode=this.config.mode??"push"),s.length!==this.displayedIndices.length||!s.every((e,t)=>e===this.displayedIndices[t])){const e=document.createDocumentFragment(),t=[];for(const i of s){let s=this.cloneCache.get(i)??null;s=this.buildClone(i)??s,s&&(e.appendChild(s),t.push(i))}this.container.replaceChildren(e),this.displayedIndices=t}i!==this.lastPushOffset&&(this.container.style.transform=i>0?`translateY(${-i}px)`:"",this.lastPushOffset=i)}findNextSticky(e){for(const t of this.stickyIndices)if(t>e)return t;return null}};export{h as StickyRowsPlugin};
|
|
1
|
+
function e(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function t(t,s,i,r){return`${e(i,r)} ${t}: ${s}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(t)}`}var 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("")),i=(new RegExp(`__(proto|defineGetter|defineSetter)|${s.slice(3).join("|")}|this\\b`),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("|"))),r=/^on\w+$/i,n=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),o=/^\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=[],s=e.querySelectorAll("*");for(const c of s){const e=c.tagName.toLowerCase();if(i.has(e)){t.push(c);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===c.namespaceURI)&&Array.from(c.attributes).some(e=>r.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(c);continue}const s=[];for(const t of c.attributes){const e=t.name.toLowerCase();r.test(e)?s.push(t.name):(n.has(e)&&o.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&s.push(t.name)}s.forEach(e=>c.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}var a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var l=class{static dependencies;static manifest;aliases;version="3.0.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 s={...this.userConfig},i={};for(const t of Object.keys(s))i[t]=this;for(const r of e){const e=r.userConfig;for(const[n,o]of Object.entries(e)){if(void 0===o)continue;if(!(n in s)){s[n]=o,i[n]=r;continue}if(s[n]===o)continue;const e=i[n]?.constructor.name??this.constructor.name,c=r.constructor.name,a=t("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${n}" supplied by both ${e} 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,s)}refreshUserConfigFrom(e){const t=this.userConfig,s={...e.userConfig};for(const i of Object.keys(t))delete t[i];Object.assign(t,s)}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 s=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(s),s.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{...a,...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;return!t||"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),s=parseInt(t,10);if(!isNaN(s))return s}return 200}setIcon(e,t,s){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const i=this.#t(t,s);void 0!==i?"string"==typeof i?e.innerHTML=c(i):i instanceof HTMLElement&&(e.innerHTML="",e.appendChild(i.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 s=document.createElement("span");s.setAttribute("part","sort-indicator"),s.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(s,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(s,"sortNone"));const i=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return i?e.insertBefore(s,i):e.appendChild(s),s}warn(s,i){void 0!==i?console.warn(t(s,i,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${s}`)}throwDiagnostic(e,s){throw new Error(t(e,s,this.gridElement.id,this.name))}},h=class extends l{name="stickyRows";styles="@layer tbw-plugins{.tbw-sticky-rows{z-index:var(--tbw-z-layer-sticky-rows,22);background:var(--tbw-color-bg,var(--tbw-color-panel-bg));width:fit-content;min-width:100%;display:block;position:absolute;top:0;left:0;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;settlePassScheduled=!1;detach(){this.container?.remove(),this.container=null,this.cloneCache.clear(),this.stickyIndices=[],this.displayedIndices=[],this.lastPushOffset=0,this.settlePassScheduled=!1}afterRender(){this.settlePassScheduled=!1,this.recomputeStickyIndices(),this.ensureContainer(),this.primeCloneCache(),this.refreshClonesInWindow(),this.refreshDisplay()}onScrollRender(){this.primeCloneCache(),this.refreshDisplay(),this.maybeScheduleSettlePass()}onScroll(e){this.refreshDisplay(e.scrollTop)}maybeScheduleSettlePass(){this.settlePassScheduled||this.stickyIndices.some(e=>null!=this.findRenderedRow(e))&&(this.settlePassScheduled=!0,this.requestAfterRender())}resolvePredicate(){const e=this.config.isSticky;if("function"==typeof e)return e;if("string"==typeof e){const t=e;return e=>null!=e&&"object"==typeof e&&Boolean(e[t])}return()=>!1}recomputeStickyIndices(){const e=this.rows,t=this.resolvePredicate(),s=[];for(let i=0;i<e.length;i++)t(e[i],i)&&s.push(i);(s.length!==this.stickyIndices.length||s.some((e,t)=>e!==this.stickyIndices[t]))&&this.cloneCache.clear(),this.stickyIndices=s}ensureContainer(){const e=this.gridElement;if(!e)return;const t=e.querySelector(".rows-viewport");t?this.container&&t.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),t.insertBefore(this.container,t.firstChild)):this.container=null}offsetOf(e){const t=this.getVirtualState(),s=t?.positionCache;return s&&s[e]?s[e].offset:e*(t?.rowHeight??28)}heightOf(e){const t=this.getVirtualState(),s=t?.positionCache;return s&&s[e]?s[e].height:t?.rowHeight??28}getVirtualState(){return this.grid?._virtualization}getCurrentScrollTop(){const e=this.getVirtualState(),t=e?.container?.scrollTop;return"number"==typeof t?t:"number"!=typeof e?.start||"number"!=typeof e?.rowHeight||e.positionCache&&e.positionCache.length?e?.positionCache&&"number"==typeof e.start&&e.positionCache[e.start]?e.positionCache[e.start].offset:0:e.start*e.rowHeight}computeDisplay(e){if("stack"===this.config.mode){const t=this.config.maxStacked??1/0,s=[];let i=0;for(const r of this.stickyIndices)if(s.length<t){if(!(this.offsetOf(r)<e+i))break;s.push(r),i+=this.heightOf(r)}else{const t=this.heightOf(s[0]);if(!(this.offsetOf(r)<e+i-t))break;s.shift(),i-=t,s.push(r),i+=this.heightOf(r)}if(s.length===t&&s.length>0){const t=this.findNextSticky(s[s.length-1]);if(null!=t){const r=this.offsetOf(t)-(e+i);if(r<0){const e=this.heightOf(s[0]);return{indices:s,pushOffset:Math.min(-r,e)}}}}return{indices:s,pushOffset:0}}const t=[];for(const n of this.stickyIndices){if(!(this.offsetOf(n)<e))break;t.push(n)}if(0===t.length)return{indices:t,pushOffset:0};const s=t[t.length-1],i=this.findNextSticky(s);let r=0;if(null!=i){const t=this.heightOf(s),n=this.offsetOf(i)-e;n<t&&(r=t-Math.max(0,n))}return{indices:[s],pushOffset:r}}findRenderedRow(e){const t=this.gridElement;return t?t.querySelector(`.rows .data-grid-row .cell[data-row="${e}"]`)?.parentElement??null:null}buildClone(e){const t=this.findRenderedRow(e);if(!t)return this.cloneCache.get(e)??null;const s=t.cloneNode(!0);return s.classList.add("tbw-sticky-row"),s.removeAttribute("aria-rowindex"),s.setAttribute("aria-hidden","true"),s.dataset.stickyRow=String(e),s.classList.remove("row-focus","cell-focus"),s.querySelectorAll(".cell-focus, .row-focus").forEach(e=>e.classList.remove("cell-focus","row-focus")),s.removeAttribute("tabindex"),s.querySelectorAll("[tabindex]").forEach(e=>e.removeAttribute("tabindex")),this.cloneCache.set(e,s),s}refreshClonesInWindow(){if(this.displayedIndices.length)for(const e of this.displayedIndices)if(this.findRenderedRow(e)){const t=this.buildClone(e),s=this.container?.querySelector(`[data-sticky-row="${e}"]`);t&&s&&s!==t&&s.replaceWith(t)}}primeCloneCache(){if(this.stickyIndices.length)for(const e of this.stickyIndices)this.findRenderedRow(e)&&this.buildClone(e)}refreshDisplay(e){if(!this.container)return;const t=e??this.getCurrentScrollTop(),{indices:s,pushOffset:i}=this.computeDisplay(t);if(this.container.dataset.mode!==this.config.mode&&(this.container.dataset.mode=this.config.mode??"push"),s.length!==this.displayedIndices.length||!s.every((e,t)=>e===this.displayedIndices[t])){const e=document.createDocumentFragment(),t=[];for(const i of s){let s=this.cloneCache.get(i)??null;s=this.buildClone(i)??s,s&&(e.appendChild(s),t.push(i))}this.container.replaceChildren(e),this.displayedIndices=t}i!==this.lastPushOffset&&(this.container.style.transform=i>0?`translateY(${-i}px)`:"",this.lastPushOffset=i)}findNextSticky(e){for(const t of this.stickyIndices)if(t>e)return t;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)}`}var 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("")),r=(new RegExp(`__(proto|defineGetter|defineSetter)|${o.slice(3).join("|")}|this\\b`),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)&&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}var a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var c=class{static dependencies;static manifest;aliases;version="3.0.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,o={...t.userConfig};for(const r of Object.keys(e))delete e[r];Object.assign(e,o)}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;return!e||"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}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}var h=class extends c{name="tooltip";styles='@layer tbw-plugins{.tbw-tooltip-popover{padding:var(--tbw-tooltip-padding,var(--tbw-spacing-sm,.375rem) var(--tbw-spacing-md,.5rem));background:var(--tbw-tooltip-bg,var(--lightningcss-light,#333338)var(--lightningcss-dark,#484850));color:var(--tbw-tooltip-fg,var(--lightningcss-light,#f5f5f5)var(--lightningcss-dark,#f0f0f0));border:1px solid var(--tbw-tooltip-border,var(--lightningcss-light,#222226)var(--lightningcss-dark,#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 #00000073));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;margin:0}.tbw-tooltip-popover.tbw-tooltip-multiline{white-space:pre;word-wrap:normal;overflow-wrap:normal;max-width:none}.tbw-tooltip-popover:after{content:"";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;position:absolute}.tbw-tooltip-popover:not(.tbw-tooltip-above):after{top:calc(var(--tbw-tooltip-arrow-size,14px) / -2);border-top:1px solid var(--tbw-tooltip-border,var(--lightningcss-light,#222226)var(--lightningcss-dark,#6a6a72));border-left:1px solid var(--tbw-tooltip-border,var(--lightningcss-light,#222226)var(--lightningcss-dark,#6a6a72));clip-path:polygon(0 0,100% 0,0 100%);transform:rotate(45deg)}.tbw-tooltip-popover.tbw-tooltip-above:after{bottom:calc(var(--tbw-tooltip-arrow-size,14px) / -2);border-bottom:1px solid var(--tbw-tooltip-border,var(--lightningcss-light,#222226)var(--lightningcss-dark,#6a6a72));border-right:1px solid var(--tbw-tooltip-border,var(--lightningcss-light,#222226)var(--lightningcss-dark,#6a6a72));clip-path:polygon(100% 0,100% 100%,0 100%);transform:rotate(45deg)}@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.#g(t),{signal:this.disconnectSignal}),t.addEventListener("mouseout",t=>this.#f(t),{signal:this.disconnectSignal}))}#g(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.#v(r)}#f(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)}#v(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;return!1===n?null:"string"==typeof n?n:"function"==typeof n?n({value:r,row:o,column:t,field:t.field,grid:i}):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)}`}var 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("")),r=(new RegExp(`__(proto|defineGetter|defineSetter)|${o.slice(3).join("|")}|this\\b`),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)&&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}var a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var p=class{static dependencies;static manifest;aliases;version="3.0.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,o={...t.userConfig};for(const r of Object.keys(e))delete e[r];Object.assign(e,o)}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;return!e||"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}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 c(t){return t.scrollWidth>t.clientWidth}function d(){return"function"==typeof HTMLElement.prototype?.showPopover}var h=class extends p{name="tooltip";styles='@layer tbw-plugins{.tbw-tooltip-popover{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 #00000073));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;margin:0}.tbw-tooltip-popover.tbw-tooltip-multiline{white-space:pre;word-wrap:normal;overflow-wrap:normal;max-width:none}.tbw-tooltip-popover:after{content:"";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;position:absolute}.tbw-tooltip-popover:not(.tbw-tooltip-above):after{top:calc(var(--tbw-tooltip-arrow-size,14px) / -2);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%);transform:rotate(45deg)}.tbw-tooltip-popover.tbw-tooltip-above:after{bottom:calc(var(--tbw-tooltip-arrow-size,14px) / -2);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%);transform:rotate(45deg)}@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.#p()}#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}#c(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)}#p(){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 c(r)&&r.textContent?.trim()||null}(o,t);r&&this.#c(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;return!1===n?null:"string"==typeof n?n:"function"==typeof n?n({value:r,row:o,column:t,field:t.field,grid:i}):c(e)&&e.textContent?.trim()||null}(r,t,i,n,this.grid);s&&this.#c(t,s)}};export{h as TooltipPlugin};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|