@toolbox-web/grid 3.5.2 → 3.5.3
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/README.md +17 -17
- 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/export/index.js +1 -1
- package/lib/plugins/filtering/index.js +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/reorder-columns/index.js +1 -1
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/row-drag-drop/index.js +1 -1
- package/lib/plugins/selection/index.js +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/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
|
@@ -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 i="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join("")),s=(new RegExp(`__(proto|defineGetter|defineSetter)|${i.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|math".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,t){t&&"string"==typeof t?-1!==t.indexOf("<")||-1!==t.indexOf("&")?e.replaceChildren(function(e){const t=document.createElement("template");return e&&"string"==typeof e&&(t.innerHTML=e,p(t.content)),t.content}(t)):e.textContent=t:e.replaceChildren()}function p(e){const t=[],o=e.querySelectorAll("*");for(const n of o){const e=n.tagName.toLowerCase();if(s.has(e)){t.push(n);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI)&&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):"is"!==e?(d.has(e)&&c.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name):o.push(t.name)}o.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}var u={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var g=class{static dependencies;static manifest;aliases;version="3.5.2";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,i]of Object.entries(e)){if(void 0===i)continue;if(!(l in t)){t[l]=i,o[l]=n;continue}if(t[l]===i)continue;const e=o[l]?.constructor.name??this.constructor.name,s=n.constructor.name,a=r("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${l}" supplied by both ${e} and ${s}. 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)}queryBoolean(e,t=null){const o=this.grid?.query?.(e,t);return Array.isArray(o)?o.some(Boolean):!!o}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{...u,...e}}t(e,t){return this.grid?.effectiveConfig?.locale?.[e]??t}get translate(){return(e,t)=>this.t(e,t)}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?h(e,n):n instanceof HTMLElement&&e.replaceChildren(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))}},b=/* @__PURE__ */new WeakMap;function f(e,t,o,n){const{onMove:r,onEnd:l,onCancel:i,onPromote:s}=o,a=n?.threshold??0,d=n?.longPressDuration??0,c=n?.longPressSlop??8,h=e.pointerId;if(!function(e,t){let o=b.get(e);return o||(o=/* @__PURE__ */new Set,b.set(e,o)),!o.has(t)&&(o.add(t),!0)}(t,h))return()=>{};const p=e.clientX,u=e.clientY;let g=0===a&&0===d,f=!1,w=null,C=!1;function v(){return g=!0,function(){try{return t.setPointerCapture(h),!0}catch{return C=!0,!1}}()?(s?.(),!0):(y(),!1)}function m(){if(!f){var e,o;f=!0,null!==w&&(clearTimeout(w),w=null),t.removeEventListener("pointermove",P),t.removeEventListener("pointerup",S),t.removeEventListener("pointercancel",x),t.removeEventListener("lostpointercapture",T),document.removeEventListener("keydown",O,!0),e=t,o=h,b.get(e)?.delete(o);try{t.hasPointerCapture(h)&&t.releasePointerCapture(h)}catch{}}}function y(){f||(m(),i?.())}function P(e){const t=e;if(t.pointerId!==h||f)return;const o=t.clientX-p,n=t.clientY-u,l=Math.sqrt(o*o+n*n);if(!g){if(d>0)return l>c?void y():void 0;if(a>0&&l<a)return;if(!v())return}r(t)}function S(e){const t=e;if(t.pointerId!==h||f)return;const o=g;m(),o?l(t):i?.()}function x(e){e.pointerId!==h||f||y()}function T(e){e.pointerId!==h||f||y()}function O(e){"Escape"!==e.key||f||y()}return t.addEventListener("pointermove",P),t.addEventListener("pointerup",S),t.addEventListener("pointercancel",x),t.addEventListener("lostpointercapture",T),document.addEventListener("keydown",O,!0),g&&(v(),C)?()=>{}:(d>0&&(w=setTimeout(()=>{w=null,f||v()},d)),y)}var w="tbw-grid-root";function C(e,t){if(t)for(const o in t){const n=t[o];null!=n&&e.setAttribute(o,n)}}function v(e,t,o){const n=document.createElement(e);if(C(n,t),o)for(const r of o)null!=r&&("string"==typeof r?n.appendChild(document.createTextNode(r)):n.appendChild(r));return n}function m(e,t){const o=document.createElement("div");return e&&(o.className=e),C(o,t),o}function y(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),C(n,t),o&&("string"==typeof o?n.textContent=o:n.appendChild(o)),n}var P=document.createElement("template");function S(){return P.content.cloneNode(!0)}function x(e){const t=document.createDocumentFragment(),o=m(e.hasShell?`${w} has-shell`:w);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=m("tbw-grid-content");e.appendChild(S()),o.appendChild(e)}return t.appendChild(o),t}function T(e){const t=m("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=m("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=m("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=m("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const i of e.configButtons)i.hasRender&&n.appendChild(m("tbw-toolbar-content-slot",{"data-toolbar-content":i.id}));for(const i of e.apiButtons)i.hasRender&&n.appendChild(m("tbw-toolbar-content-slot",{"data-toolbar-content":i.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(m("tbw-toolbar-separator")),l){const t=y(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&&h(t,e.toolPanelIcon),n.appendChild(t)}return t.appendChild(n),t}function O(e){const t=y(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}function E(){const e=m("tbw-tool-panel-header",{part:"tool-panel-header"});return e.appendChild(O(!1)),e}function D(e,t,o,n){const r=!!e.title||!o,l=n&&r,i=m(`tbw-accordion-section${e.isExpanded?" expanded":""}${o?" single":""}${l?" has-inline-close":""}`,{"data-section":e.id});if(r){const n=function(e,t,o){const n=y("tbw-accordion-header",{"aria-expanded":String(e.isExpanded),"aria-controls":`tbw-section-${e.id}`});if(o&&n.setAttribute("aria-disabled","true"),e.icon){const t=v("span",{class:"tbw-accordion-icon"});h(t,e.icon),n.appendChild(t)}const r=v("span",{class:"tbw-accordion-title"});if(r.textContent=e.title??"",n.appendChild(r),!o){const e=v("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==t.expandIcon&&h(e,t.expandIcon),n.appendChild(e)}return n}(e,t,o);if(l){const e=m("tbw-accordion-header-row");e.appendChild(n),e.appendChild(O(!0)),i.appendChild(e)}else i.appendChild(n)}else n&&i.appendChild(E());return i.appendChild(m("tbw-accordion-content",{id:`tbw-section-${e.id}`,role:"presentation"})),i}function _(e){const t=e.mode??"overlay",o=m("tbw-shell-body",{"data-mode":t}),n=m("tbw-grid-content");n.appendChild(S());const r=e.panels.length>0?function(e,t){const o=1===e.panels.length,n=v("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"}:{}});n.appendChild(m("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":"left"===e.position?"right":"left","aria-hidden":"true"}));const r=!0===e.showCloseButton&&o;e.showCloseButton&&!o&&n.appendChild(E());const l=m("tbw-tool-panel-content",{role:"presentation"}),i=m("tbw-accordion");for(const s of e.panels)i.appendChild(D(s,e,o,r));return l.appendChild(i),n.appendChild(l),n}(e,t):null;return"left"===e.position&&r?(o.appendChild(r),o.appendChild(n)):(o.appendChild(n),r&&o.appendChild(r)),o}function k(e){return e?"string"==typeof e?function(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,p(t.content),t.innerHTML}(e):e.outerHTML:""}function A(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function R(e){return!1!==e?.header?.visible}function L(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function q(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 i of l){const e=t.headerContentCleanups.get(i.id);e&&(e(),t.headerContentCleanups.delete(i.id));let o=r.querySelector(`[data-header-content="${i.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",i.id),r.appendChild(o));const n=i.render(o);n&&t.headerContentCleanups.set(i.id,n)}}function H(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}"]`),i=l?.querySelector(".tbw-accordion-content");if(!l||!i)continue;l.classList.toggle("expanded",o);const s=l.querySelector(".tbw-accordion-header");if(s&&s.setAttribute("aria-expanded",String(o)),o){if(0===i.children.length){const e=r.render(i);e&&t.panelCleanups.set(n,e)}}else{const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n)),i.innerHTML=""}}}function I(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function $(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}P.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 z="--tbw-tool-panel-anchor",B=0;function M(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",z)}function N(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(M()){const e=`${z}-${++B}`;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 j(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 W(e,t,o){const n=void 0!==o?.toolPanel?k(o.toolPanel):void 0,r=void 0!==o?.expand?k(o.expand):void 0,l=void 0!==o?.collapse?k(o.collapse):void 0,i=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),s=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:s.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:n,showToggle:!1!==e.header?.toolPanelToggle&&!0!==e.toolPanel?.locked,configButtons:i.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:s.map(e=>({id:e.id,title:e.title,icon:k(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function F(e,t,o,n){const r=e.querySelector(`.${w}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=A(t),l=[];for(let i=e.firstChild;i;i=i.nextSibling)1===i.nodeType&&i.classList.contains(w)||l.push(i);e.replaceChildren();for(const i of l)e.appendChild(i);if(r){const{headerOptions:r,bodyOptions:l}=W(t,o,n),i=x({hasShell:!0,shellHeader:R(t)?T(r):void 0,shellBody:_(l)});e.appendChild(i)}else{const t=x({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const i=A(t);if(r.replaceChildren(),i){r.className=`${w} has-shell`;const{headerOptions:e,bodyOptions:i}=W(t,o,n),s=R(t)?T(e):void 0,a=_(i),d=a.querySelector(".tbw-grid-content");d&&d.replaceWith(l),s&&r.appendChild(s),r.appendChild(a)}else r.className=w,r.appendChild(l);return i}function X(e,r){let i=!1;const s={get isInitialized(){return i},setInitialized(e){i=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 i;if(void 0!==o&&(e.toolPanels.has(o)?i=o:l(t,`Tool panel "${o}" not found`,r.id)),e.isPanelOpen&&i&&e.expandedSections.has(i))return;if(e.isPanelOpen&&i&&!e.expandedSections.has(i))return void s.toggleToolPanelSection(i);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(i)e.expandedSections.add(i);else{const t=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(i&&!e.expandedSections.has(i)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(i)}const a=r._renderRoot;if(I(a,e),$(a,e),H(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);N(a,e,t,o)}r._emit("tool-panel-open",{sections:s.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;I(t,e),$(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?s.closeToolPanel():s.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&&M()&&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;N(r._renderRoot,e,o,!1)}else t!==r._hostElement||N(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 i=r._renderRoot,s=e.expandedSections.has(o);if(s){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),n.onClose?.(),e.expandedSections.delete(o),V(i,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),V(i,t,!1);const r=i.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),V(i,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)}(i,e,o)}r._emit("tool-panel-section-toggle",{id:o,expanded:!s})},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),(i||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),(i||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),i?q(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),(i||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),i&&r.refreshShellHeader?.()}};return s}function V(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}var G=class extends g{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;touch-action:none;-webkit-user-select:none;user-select:none;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)}@media (pointer:coarse){tbw-grid .tbw-tool-panel-resize{width:var(--tbw-touch-target-min,24px)}}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;#i;#s;#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=X(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.#s=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,i=r.getAttribute("id"),s=r.getAttribute("title")??void 0;if(!i)return void l("TBW070",`Tool panel missing required id attribute: title="${s??""}"`);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=r.innerHTML.trim();p=t=>{const o=document.createElement("div");return h(o,e),t.appendChild(o),()=>o.remove()}}const g=t.toolPanels.get(i);if(g&&!t.lightDomToolPanelIds.has(i))return l(o,`Tool panel "${i}" 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(i),o=g.title!==s||g.order!==c||g.icon!==a||g.tooltip!==d;if(g.render=p,g.title=s,g.order=c,g.icon=a,g.tooltip=d,t.adapterBoundToolPanelIds.add(i),e||o){const e=t.panelCleanups.get(i);e&&(e(),t.panelCleanups.delete(i))}}return}const b={id:i,title:s,icon:a,tooltip:d,order:c,render:p};t.toolPanels.set(i,b),t.lightDomToolPanelIds.add(i),u&&t.adapterBoundToolPanelIds.add(i),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")&&(j(t),this.afterStructuralRender()))}parseLightDom(){const e=this.grid;e&&this.hasState&&this.#c(e)}beforeStructuralRender(){this.hasState&&j(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",i=t.querySelector(".tbw-shell-body")?.dataset.mode??"overlay",s=e.effectiveConfig?.shell;return o!==A(s)||!n&&(s?.toolPanels?.length??0)>0||n&&(s?.toolPanels?.length??0)!==r||n&&l!==(s?.toolPanel?.position??"right")||n&&i!==(s?.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:i,headerContents:s}=e._pluginShellContributions();for(const n of i)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 s)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??[],i=new Set(l.map(e=>e.id)),s=[...l];for(const a of r)i.has(a.id)||s.push(a);s.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=s}afterStructuralRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;F(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&&H(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;q(o,t),function(e,t,o){const n=t?.header?.toolbarContents??[],r=[...o.toolbarContents.values()],l=new Set(n.map(e=>e.id)),i=[...n];for(const s of r)l.has(s.id)||i.push(s);for(const s of i){if(o.toolbarContentCleanups.has(s.id))continue;if(!s.render)continue;const t=e.querySelector(`[data-toolbar-content="${s.id}"]`);if(!t)continue;const n=s.render(t);n&&o.toolbarContentCleanups.set(s.id,n)}}(o,n,t);const r=n?.toolPanel,l=r?.defaultOpen;l&&t.toolPanels.has(l)&&t.expandedSections.add(l);const i=!0===r?.locked||"open"===r?.initialState||void 0===r?.initialState&&void 0!==l&&t.toolPanels.has(l);!t.isPanelOpen&&t.toolPanels.size>0&&i&&this.openToolPanel(),t.isPanelOpen&&($(o,t),H(o,t,(e.effectiveConfig,e.effectiveConfig)),I(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 i=e.querySelector(".tbw-accordion");i&&i.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 i=t?.toolPanel?.position??"right";let s=0,a=0,d=0,c=!1,h=null;const p=e=>{if(!c)return;e.preventDefault();const t="left"===i?e.clientX-s:s-e.clientX,o=Math.min(d,Math.max(200,a+t));n.style.width=`${o}px`},u=e=>{if(c&&(c=!1,h=null,r.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="",e)){const e=n.getBoundingClientRect().width;o(e)}},g=e=>{c||0!==e.button&&"mouse"===e.pointerType||(e.preventDefault(),c=!0,s=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",h=f(e,r,{onMove:p,onEnd:()=>u(!0),onCancel:()=>{n.style.width=`${a}px`,u(!1)}}))};return r.addEventListener("pointerdown",g),()=>{r.removeEventListener("pointerdown",g),h?.(),h=null}}(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]"))&&L(o,e))return}n()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)}(e._hostElement,o,n,()=>this.closeToolPanel()),this.#i?.(),this.#i=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.#i?.(),this.#i=void 0}detach(){super.detach()}disposeShellState(){this.#w(),this.#f(),this.#a=void 0;const e=this.grid;e&&this.#s&&(e._unregisterLightDomHandler("tbw-grid-header"),e._unregisterLightDomHandler("tbw-grid-tool-buttons"),e._unregisterLightDomHandler("tbw-grid-tool-panel"),this.#s=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{G 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 i="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join("")),s=(new RegExp(`__(proto|defineGetter|defineSetter)|${i.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|math".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,t){t&&"string"==typeof t?-1!==t.indexOf("<")||-1!==t.indexOf("&")?e.replaceChildren(function(e){const t=document.createElement("template");return e&&"string"==typeof e&&(t.innerHTML=e,p(t.content)),t.content}(t)):e.textContent=t:e.replaceChildren()}function p(e){const t=[],o=e.querySelectorAll("*");for(const n of o){const e=n.tagName.toLowerCase();if(s.has(e)){t.push(n);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI)&&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):"is"!==e?(d.has(e)&&c.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name):o.push(t.name)}o.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}var u={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var g=class{static dependencies;static manifest;aliases;version="3.5.3";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,i]of Object.entries(e)){if(void 0===i)continue;if(!(l in t)){t[l]=i,o[l]=n;continue}if(t[l]===i)continue;const e=o[l]?.constructor.name??this.constructor.name,s=n.constructor.name,a=r("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${l}" supplied by both ${e} and ${s}. 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)}queryBoolean(e,t=null){const o=this.grid?.query?.(e,t);return Array.isArray(o)?o.some(Boolean):!!o}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{...u,...e}}t(e,t){return this.grid?.effectiveConfig?.locale?.[e]??t}get translate(){return(e,t)=>this.t(e,t)}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?h(e,n):n instanceof HTMLElement&&e.replaceChildren(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))}},b=/* @__PURE__ */new WeakMap;function f(e,t,o,n){const{onMove:r,onEnd:l,onCancel:i,onPromote:s}=o,a=n?.threshold??0,d=n?.longPressDuration??0,c=n?.longPressSlop??8,h=e.pointerId;if(!function(e,t){let o=b.get(e);return o||(o=/* @__PURE__ */new Set,b.set(e,o)),!o.has(t)&&(o.add(t),!0)}(t,h))return()=>{};const p=e.clientX,u=e.clientY;let g=0===a&&0===d,f=!1,w=null,C=!1;function v(){return g=!0,function(){try{return t.setPointerCapture(h),!0}catch{return C=!0,!1}}()?(s?.(),!0):(y(),!1)}function m(){if(!f){var e,o;f=!0,null!==w&&(clearTimeout(w),w=null),t.removeEventListener("pointermove",P),t.removeEventListener("pointerup",S),t.removeEventListener("pointercancel",x),t.removeEventListener("lostpointercapture",T),document.removeEventListener("keydown",O,!0),e=t,o=h,b.get(e)?.delete(o);try{t.hasPointerCapture(h)&&t.releasePointerCapture(h)}catch{}}}function y(){f||(m(),i?.())}function P(e){const t=e;if(t.pointerId!==h||f)return;const o=t.clientX-p,n=t.clientY-u,l=Math.sqrt(o*o+n*n);if(!g){if(d>0)return l>c?void y():void 0;if(a>0&&l<a)return;if(!v())return}r(t)}function S(e){const t=e;if(t.pointerId!==h||f)return;const o=g;m(),o?l(t):i?.()}function x(e){e.pointerId!==h||f||y()}function T(e){e.pointerId!==h||f||y()}function O(e){"Escape"!==e.key||f||y()}return t.addEventListener("pointermove",P),t.addEventListener("pointerup",S),t.addEventListener("pointercancel",x),t.addEventListener("lostpointercapture",T),document.addEventListener("keydown",O,!0),g&&(v(),C)?()=>{}:(d>0&&(w=setTimeout(()=>{w=null,f||v()},d)),y)}var w="tbw-grid-root";function C(e,t){if(t)for(const o in t){const n=t[o];null!=n&&e.setAttribute(o,n)}}function v(e,t,o){const n=document.createElement(e);if(C(n,t),o)for(const r of o)null!=r&&("string"==typeof r?n.appendChild(document.createTextNode(r)):n.appendChild(r));return n}function m(e,t){const o=document.createElement("div");return e&&(o.className=e),C(o,t),o}function y(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),C(n,t),o&&("string"==typeof o?n.textContent=o:n.appendChild(o)),n}var P=document.createElement("template");function S(){return P.content.cloneNode(!0)}function x(e){const t=document.createDocumentFragment(),o=m(e.hasShell?`${w} has-shell`:w);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=m("tbw-grid-content");e.appendChild(S()),o.appendChild(e)}return t.appendChild(o),t}function T(e){const t=m("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=m("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=m("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=m("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const i of e.configButtons)i.hasRender&&n.appendChild(m("tbw-toolbar-content-slot",{"data-toolbar-content":i.id}));for(const i of e.apiButtons)i.hasRender&&n.appendChild(m("tbw-toolbar-content-slot",{"data-toolbar-content":i.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(m("tbw-toolbar-separator")),l){const t=y(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&&h(t,e.toolPanelIcon),n.appendChild(t)}return t.appendChild(n),t}function O(e){const t=y(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}function E(){const e=m("tbw-tool-panel-header",{part:"tool-panel-header"});return e.appendChild(O(!1)),e}function D(e,t,o,n){const r=!!e.title||!o,l=n&&r,i=m(`tbw-accordion-section${e.isExpanded?" expanded":""}${o?" single":""}${l?" has-inline-close":""}`,{"data-section":e.id});if(r){const n=function(e,t,o){const n=y("tbw-accordion-header",{"aria-expanded":String(e.isExpanded),"aria-controls":`tbw-section-${e.id}`});if(o&&n.setAttribute("aria-disabled","true"),e.icon){const t=v("span",{class:"tbw-accordion-icon"});h(t,e.icon),n.appendChild(t)}const r=v("span",{class:"tbw-accordion-title"});if(r.textContent=e.title??"",n.appendChild(r),!o){const e=v("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==t.expandIcon&&h(e,t.expandIcon),n.appendChild(e)}return n}(e,t,o);if(l){const e=m("tbw-accordion-header-row");e.appendChild(n),e.appendChild(O(!0)),i.appendChild(e)}else i.appendChild(n)}else n&&i.appendChild(E());return i.appendChild(m("tbw-accordion-content",{id:`tbw-section-${e.id}`,role:"presentation"})),i}function _(e){const t=e.mode??"overlay",o=m("tbw-shell-body",{"data-mode":t}),n=m("tbw-grid-content");n.appendChild(S());const r=e.panels.length>0?function(e,t){const o=1===e.panels.length,n=v("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"}:{}});n.appendChild(m("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":"left"===e.position?"right":"left","aria-hidden":"true"}));const r=!0===e.showCloseButton&&o;e.showCloseButton&&!o&&n.appendChild(E());const l=m("tbw-tool-panel-content",{role:"presentation"}),i=m("tbw-accordion");for(const s of e.panels)i.appendChild(D(s,e,o,r));return l.appendChild(i),n.appendChild(l),n}(e,t):null;return"left"===e.position&&r?(o.appendChild(r),o.appendChild(n)):(o.appendChild(n),r&&o.appendChild(r)),o}function k(e){return e?"string"==typeof e?function(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,p(t.content),t.innerHTML}(e):e.outerHTML:""}function A(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function R(e){return!1!==e?.header?.visible}function L(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function q(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 i of l){const e=t.headerContentCleanups.get(i.id);e&&(e(),t.headerContentCleanups.delete(i.id));let o=r.querySelector(`[data-header-content="${i.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",i.id),r.appendChild(o));const n=i.render(o);n&&t.headerContentCleanups.set(i.id,n)}}function H(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}"]`),i=l?.querySelector(".tbw-accordion-content");if(!l||!i)continue;l.classList.toggle("expanded",o);const s=l.querySelector(".tbw-accordion-header");if(s&&s.setAttribute("aria-expanded",String(o)),o){if(0===i.children.length){const e=r.render(i);e&&t.panelCleanups.set(n,e)}}else{const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n)),i.innerHTML=""}}}function I(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function $(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}P.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 z="--tbw-tool-panel-anchor",B=0;function M(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",z)}function N(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(M()){const e=`${z}-${++B}`;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 j(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 W(e,t,o){const n=void 0!==o?.toolPanel?k(o.toolPanel):void 0,r=void 0!==o?.expand?k(o.expand):void 0,l=void 0!==o?.collapse?k(o.collapse):void 0,i=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),s=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:s.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:n,showToggle:!1!==e.header?.toolPanelToggle&&!0!==e.toolPanel?.locked,configButtons:i.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:s.map(e=>({id:e.id,title:e.title,icon:k(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function F(e,t,o,n){const r=e.querySelector(`.${w}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=A(t),l=[];for(let i=e.firstChild;i;i=i.nextSibling)1===i.nodeType&&i.classList.contains(w)||l.push(i);e.replaceChildren();for(const i of l)e.appendChild(i);if(r){const{headerOptions:r,bodyOptions:l}=W(t,o,n),i=x({hasShell:!0,shellHeader:R(t)?T(r):void 0,shellBody:_(l)});e.appendChild(i)}else{const t=x({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const i=A(t);if(r.replaceChildren(),i){r.className=`${w} has-shell`;const{headerOptions:e,bodyOptions:i}=W(t,o,n),s=R(t)?T(e):void 0,a=_(i),d=a.querySelector(".tbw-grid-content");d&&d.replaceWith(l),s&&r.appendChild(s),r.appendChild(a)}else r.className=w,r.appendChild(l);return i}function X(e,r){let i=!1;const s={get isInitialized(){return i},setInitialized(e){i=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 i;if(void 0!==o&&(e.toolPanels.has(o)?i=o:l(t,`Tool panel "${o}" not found`,r.id)),e.isPanelOpen&&i&&e.expandedSections.has(i))return;if(e.isPanelOpen&&i&&!e.expandedSections.has(i))return void s.toggleToolPanelSection(i);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(i)e.expandedSections.add(i);else{const t=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(i&&!e.expandedSections.has(i)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(i)}const a=r._renderRoot;if(I(a,e),$(a,e),H(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);N(a,e,t,o)}r._emit("tool-panel-open",{sections:s.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;I(t,e),$(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?s.closeToolPanel():s.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&&M()&&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;N(r._renderRoot,e,o,!1)}else t!==r._hostElement||N(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 i=r._renderRoot,s=e.expandedSections.has(o);if(s){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),n.onClose?.(),e.expandedSections.delete(o),V(i,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),V(i,t,!1);const r=i.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),V(i,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)}(i,e,o)}r._emit("tool-panel-section-toggle",{id:o,expanded:!s})},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),(i||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),(i||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),i?q(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),(i||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),i&&r.refreshShellHeader?.()}};return s}function V(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}var G=class extends g{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;touch-action:none;-webkit-user-select:none;user-select:none;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)}@media (pointer:coarse){tbw-grid .tbw-tool-panel-resize{width:var(--tbw-touch-target-min,24px)}}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;#i;#s;#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=X(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.#s=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,i=r.getAttribute("id"),s=r.getAttribute("title")??void 0;if(!i)return void l("TBW070",`Tool panel missing required id attribute: title="${s??""}"`);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=r.innerHTML.trim();p=t=>{const o=document.createElement("div");return h(o,e),t.appendChild(o),()=>o.remove()}}const g=t.toolPanels.get(i);if(g&&!t.lightDomToolPanelIds.has(i))return l(o,`Tool panel "${i}" 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(i),o=g.title!==s||g.order!==c||g.icon!==a||g.tooltip!==d;if(g.render=p,g.title=s,g.order=c,g.icon=a,g.tooltip=d,t.adapterBoundToolPanelIds.add(i),e||o){const e=t.panelCleanups.get(i);e&&(e(),t.panelCleanups.delete(i))}}return}const b={id:i,title:s,icon:a,tooltip:d,order:c,render:p};t.toolPanels.set(i,b),t.lightDomToolPanelIds.add(i),u&&t.adapterBoundToolPanelIds.add(i),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")&&(j(t),this.afterStructuralRender()))}parseLightDom(){const e=this.grid;e&&this.hasState&&this.#c(e)}beforeStructuralRender(){this.hasState&&j(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",i=t.querySelector(".tbw-shell-body")?.dataset.mode??"overlay",s=e.effectiveConfig?.shell;return o!==A(s)||!n&&(s?.toolPanels?.length??0)>0||n&&(s?.toolPanels?.length??0)!==r||n&&l!==(s?.toolPanel?.position??"right")||n&&i!==(s?.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:i,headerContents:s}=e._pluginShellContributions();for(const n of i)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 s)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??[],i=new Set(l.map(e=>e.id)),s=[...l];for(const a of r)i.has(a.id)||s.push(a);s.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=s}afterStructuralRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;F(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&&H(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;q(o,t),function(e,t,o){const n=t?.header?.toolbarContents??[],r=[...o.toolbarContents.values()],l=new Set(n.map(e=>e.id)),i=[...n];for(const s of r)l.has(s.id)||i.push(s);for(const s of i){if(o.toolbarContentCleanups.has(s.id))continue;if(!s.render)continue;const t=e.querySelector(`[data-toolbar-content="${s.id}"]`);if(!t)continue;const n=s.render(t);n&&o.toolbarContentCleanups.set(s.id,n)}}(o,n,t);const r=n?.toolPanel,l=r?.defaultOpen;l&&t.toolPanels.has(l)&&t.expandedSections.add(l);const i=!0===r?.locked||"open"===r?.initialState||void 0===r?.initialState&&void 0!==l&&t.toolPanels.has(l);!t.isPanelOpen&&t.toolPanels.size>0&&i&&this.openToolPanel(),t.isPanelOpen&&($(o,t),H(o,t,(e.effectiveConfig,e.effectiveConfig)),I(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 i=e.querySelector(".tbw-accordion");i&&i.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 i=t?.toolPanel?.position??"right";let s=0,a=0,d=0,c=!1,h=null;const p=e=>{if(!c)return;e.preventDefault();const t="left"===i?e.clientX-s:s-e.clientX,o=Math.min(d,Math.max(200,a+t));n.style.width=`${o}px`},u=e=>{if(c&&(c=!1,h=null,r.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="",e)){const e=n.getBoundingClientRect().width;o(e)}},g=e=>{c||0!==e.button&&"mouse"===e.pointerType||(e.preventDefault(),c=!0,s=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",h=f(e,r,{onMove:p,onEnd:()=>u(!0),onCancel:()=>{n.style.width=`${a}px`,u(!1)}}))};return r.addEventListener("pointerdown",g),()=>{r.removeEventListener("pointerdown",g),h?.(),h=null}}(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]"))&&L(o,e))return}n()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)}(e._hostElement,o,n,()=>this.closeToolPanel()),this.#i?.(),this.#i=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.#i?.(),this.#i=void 0}detach(){super.detach()}disposeShellState(){this.#w(),this.#f(),this.#a=void 0;const e=this.grid;e&&this.#s&&(e._unregisterLightDomHandler("tbw-grid-header"),e._unregisterLightDomHandler("tbw-grid-tool-buttons"),e._unregisterLightDomHandler("tbw-grid-tool-panel"),this.#s=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{G as ShellPlugin};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=/* @__PURE__ */new WeakMap;function t(e){return"__proto__"===e||"constructor"===e||"prototype"===e}var s=/* @__PURE__ */new Map;function i(e,i){if(null==e)return;const n=function(e){if(-1===e.indexOf("."))return null;let t=s.get(e);return void 0===t&&(t=Object.freeze(e.split(".")),s.set(e,t)),t}(i),r=e;return null===n?t(i)?void 0:r[i]:Object.prototype.hasOwnProperty.call(r,i)?r[i]:function(e,s){let i=e;for(let n=0;n<s.length;n++){if(null==i||"object"!=typeof i)return;const e=s[n];if(t(e))return;i=i[e]}return i}(r,n)}function n(t,s,n=-1){if(!s.valueAccessor)return i(t,s.field);if("object"!=typeof t||null===t)return s.valueAccessor({row:t,column:s,rowIndex:n});const r=t,o=s.field;let c=e.get(r);if(c){const e=c.get(o);if(void 0!==e)return e.v}else c=/* @__PURE__ */new Map,e.set(r,c);const a=s.valueAccessor({row:t,column:s,rowIndex:n});return c.set(o,{v:a}),a}function r(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function o(e,t,s,i){return`${r(s,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}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(e=>e.split("").reverse().join("")),a=(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|math".split("|"))),l=/^on\w+$/i,h=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),d=/^\s*(javascript|vbscript|data|blob):/i;function u(e){const t=document.createElement("template");return e&&"string"==typeof e&&(t.innerHTML=e,function(e){const t=[],s=e.querySelectorAll("*");for(const i of s){const e=i.tagName.toLowerCase();if(a.has(e)){t.push(i);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===i.namespaceURI)&&Array.from(i.attributes).some(e=>l.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(i);continue}const s=[];for(const t of i.attributes){const e=t.name.toLowerCase();l.test(e)?s.push(t.name):"is"!==e?(h.has(e)&&d.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&s.push(t.name):s.push(t.name)}s.forEach(e=>i.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content)),t.content}var f={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var g=class{static dependencies;static manifest;aliases;version="3.5.2";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},s={};for(const i of Object.keys(t))s[i]=this;for(const i of e){const e=i.userConfig;for(const[n,r]of Object.entries(e)){if(void 0===r)continue;if(!(n in t)){t[n]=r,s[n]=i;continue}if(t[n]===r)continue;const e=s[n]?.constructor.name??this.constructor.name,c=i.constructor.name,a=o("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,t)}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)}queryBoolean(e,t=null){const s=this.grid?.query?.(e,t);return Array.isArray(s)?s.some(Boolean):!!s}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{...f,...e}}t(e,t){return this.grid?.effectiveConfig?.locale?.[e]??t}get translate(){return(e,t)=>this.t(e,t)}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);var n,r;void 0!==i?"string"==typeof i?(n=e,(r=i)&&"string"==typeof r?-1!==r.indexOf("<")||-1!==r.indexOf("&")?n.replaceChildren(u(r)):n.textContent=r:n.replaceChildren()):i instanceof HTMLElement&&e.replaceChildren(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(e,t){void 0!==t?console.warn(o(e,t,this.gridElement.id,this.name)):console.warn(`${r(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(o(e,t,this.gridElement.id,this.name))}},p=class extends g{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=[];templateClone=null;lastPushOffset=0;settlePassScheduled=!1;detach(){this.container?.remove(),this.container=null,this.cloneCache.clear(),this.templateClone=null,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 n of this.stickyIndices)if(s.length<t){if(!(this.offsetOf(n)<e+i))break;s.push(n),i+=this.heightOf(n)}else{const t=this.heightOf(s[0]);if(!(this.offsetOf(n)<e+i-t))break;s.shift(),i-=t,s.push(n),i+=this.heightOf(n)}if(s.length===t&&s.length>0){const t=this.findNextSticky(s[s.length-1]);if(null!=t){const n=this.offsetOf(t)-(e+i);if(n<0){const e=this.heightOf(s[0]);return{indices:s,pushOffset:Math.min(-n,e)}}}}return{indices:s,pushOffset:0}}const t=[];for(const r of this.stickyIndices){if(!(this.offsetOf(r)<e))break;t.push(r)}if(0===t.length)return{indices:t,pushOffset:0};const s=t[t.length-1],i=this.findNextSticky(s);let n=0;if(null!=i){const t=this.heightOf(s),r=this.offsetOf(i)-e;r<t&&(n=t-Math.max(0,r))}return{indices:[s],pushOffset:n}}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.templateClone=s.cloneNode(!0),this.cloneCache.set(e,s),s}synthesizeClone(e){const t=this.templateClone,s=this.rows[e];if(!t||null==s)return null;const i=t.cloneNode(!0),r=Array.from(i.querySelectorAll(".cell"));if(r.some(e=>null!=e.firstElementChild))return null;i.dataset.stickyRow=String(e),i.dataset.syntheticStickyRow="",i.removeAttribute("aria-rowindex");const o=this.visibleColumns;for(const c of r){c.setAttribute("data-row",String(e));const t=c.getAttribute("data-field"),i=t?o.find(e=>e.field===t):void 0,r=i?n(s,i,e):null;c.textContent=null==r?"":String(r)}return i}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||(s=this.synthesizeClone(i),s&&this.cloneCache.set(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{p as StickyRowsPlugin};
|
|
1
|
+
var e=/* @__PURE__ */new WeakMap;function t(e){return"__proto__"===e||"constructor"===e||"prototype"===e}var s=/* @__PURE__ */new Map;function i(e,i){if(null==e)return;const n=function(e){if(-1===e.indexOf("."))return null;let t=s.get(e);return void 0===t&&(t=Object.freeze(e.split(".")),s.set(e,t)),t}(i),r=e;return null===n?t(i)?void 0:r[i]:Object.prototype.hasOwnProperty.call(r,i)?r[i]:function(e,s){let i=e;for(let n=0;n<s.length;n++){if(null==i||"object"!=typeof i)return;const e=s[n];if(t(e))return;i=i[e]}return i}(r,n)}function n(t,s,n=-1){if(!s.valueAccessor)return i(t,s.field);if("object"!=typeof t||null===t)return s.valueAccessor({row:t,column:s,rowIndex:n});const r=t,o=s.field;let c=e.get(r);if(c){const e=c.get(o);if(void 0!==e)return e.v}else c=/* @__PURE__ */new Map,e.set(r,c);const a=s.valueAccessor({row:t,column:s,rowIndex:n});return c.set(o,{v:a}),a}function r(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function o(e,t,s,i){return`${r(s,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}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(e=>e.split("").reverse().join("")),a=(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|math".split("|"))),l=/^on\w+$/i,h=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),d=/^\s*(javascript|vbscript|data|blob):/i;function u(e){const t=document.createElement("template");return e&&"string"==typeof e&&(t.innerHTML=e,function(e){const t=[],s=e.querySelectorAll("*");for(const i of s){const e=i.tagName.toLowerCase();if(a.has(e)){t.push(i);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===i.namespaceURI)&&Array.from(i.attributes).some(e=>l.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(i);continue}const s=[];for(const t of i.attributes){const e=t.name.toLowerCase();l.test(e)?s.push(t.name):"is"!==e?(h.has(e)&&d.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&s.push(t.name):s.push(t.name)}s.forEach(e=>i.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content)),t.content}var f={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var g=class{static dependencies;static manifest;aliases;version="3.5.3";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},s={};for(const i of Object.keys(t))s[i]=this;for(const i of e){const e=i.userConfig;for(const[n,r]of Object.entries(e)){if(void 0===r)continue;if(!(n in t)){t[n]=r,s[n]=i;continue}if(t[n]===r)continue;const e=s[n]?.constructor.name??this.constructor.name,c=i.constructor.name,a=o("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,t)}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)}queryBoolean(e,t=null){const s=this.grid?.query?.(e,t);return Array.isArray(s)?s.some(Boolean):!!s}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{...f,...e}}t(e,t){return this.grid?.effectiveConfig?.locale?.[e]??t}get translate(){return(e,t)=>this.t(e,t)}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);var n,r;void 0!==i?"string"==typeof i?(n=e,(r=i)&&"string"==typeof r?-1!==r.indexOf("<")||-1!==r.indexOf("&")?n.replaceChildren(u(r)):n.textContent=r:n.replaceChildren()):i instanceof HTMLElement&&e.replaceChildren(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(e,t){void 0!==t?console.warn(o(e,t,this.gridElement.id,this.name)):console.warn(`${r(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(o(e,t,this.gridElement.id,this.name))}},p=class extends g{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=[];templateClone=null;lastPushOffset=0;settlePassScheduled=!1;detach(){this.container?.remove(),this.container=null,this.cloneCache.clear(),this.templateClone=null,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 n of this.stickyIndices)if(s.length<t){if(!(this.offsetOf(n)<e+i))break;s.push(n),i+=this.heightOf(n)}else{const t=this.heightOf(s[0]);if(!(this.offsetOf(n)<e+i-t))break;s.shift(),i-=t,s.push(n),i+=this.heightOf(n)}if(s.length===t&&s.length>0){const t=this.findNextSticky(s[s.length-1]);if(null!=t){const n=this.offsetOf(t)-(e+i);if(n<0){const e=this.heightOf(s[0]);return{indices:s,pushOffset:Math.min(-n,e)}}}}return{indices:s,pushOffset:0}}const t=[];for(const r of this.stickyIndices){if(!(this.offsetOf(r)<e))break;t.push(r)}if(0===t.length)return{indices:t,pushOffset:0};const s=t[t.length-1],i=this.findNextSticky(s);let n=0;if(null!=i){const t=this.heightOf(s),r=this.offsetOf(i)-e;r<t&&(n=t-Math.max(0,r))}return{indices:[s],pushOffset:n}}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.templateClone=s.cloneNode(!0),this.cloneCache.set(e,s),s}synthesizeClone(e){const t=this.templateClone,s=this.rows[e];if(!t||null==s)return null;const i=t.cloneNode(!0),r=Array.from(i.querySelectorAll(".cell"));if(r.some(e=>null!=e.firstElementChild))return null;i.dataset.stickyRow=String(e),i.dataset.syntheticStickyRow="",i.removeAttribute("aria-rowindex");const o=this.visibleColumns;for(const c of r){c.setAttribute("data-row",String(e));const t=c.getAttribute("data-field"),i=t?o.find(e=>e.field===t):void 0,r=i?n(s,i,e):null;c.textContent=null==r?"":String(r)}return i}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||(s=this.synthesizeClone(i),s&&this.cloneCache.set(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{p 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|math".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){const e=document.createElement("template");return t&&"string"==typeof t&&(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):"is"!==t?(n.has(t)&&s.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&o.push(e.name):o.push(e.name)}o.forEach(t=>l.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content)),e.content}var a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var c=class{static dependencies;static manifest;aliases;version="3.5.2";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)}queryBoolean(t,e=null){const o=this.grid?.query?.(t,e);return Array.isArray(o)?o.some(Boolean):!!o}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}}t(t,e){return this.grid?.effectiveConfig?.locale?.[t]??e}get translate(){return(t,e)=>this.t(t,e)}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);var i,n;void 0!==r?"string"==typeof r?(i=t,(n=r)&&"string"==typeof n?-1!==n.indexOf("<")||-1!==n.indexOf("&")?i.replaceChildren(l(n)):i.textContent=n:i.replaceChildren()):r instanceof HTMLElement&&t.replaceChildren(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,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.#c()}#a(){if(this.#o)return;const t=document.createElement("div");t.className="tbw-tooltip-popover",t.setAttribute("popover","hint"),t.style.overflow="visible",t.style.margin="0",document.body.appendChild(t),this.#o=t}#p(t,e){if(this.#o){if(this.#d(),t.style.setProperty("anchor-name","--tbw-tooltip-anchor"),this.#r=t,this.#o.textContent=e,this.#o.classList.toggle("tbw-tooltip-multiline",e.includes("\n")),d())try{this.#o.showPopover()}catch{}"undefined"!=typeof CSS&&!0===CSS.supports?.("anchor-name","--test")?requestAnimationFrame(()=>this.#h(t)):this.#u(t)}}#l(){if(this.#o){if(d())try{this.#o.hidePopover()}catch{}this.#o.classList.remove("tbw-tooltip-above")}this.#d()}#d(){this.#r&&("--tbw-tooltip-anchor"===this.#r.style.getPropertyValue("anchor-name")&&this.#r.style.removeProperty("anchor-name"),this.#r=null)}#u(t){if(!this.#o)return;const e=t.getBoundingClientRect();this.#o.style.position="fixed",this.#o.style.left=`${e.left}px`,window.innerHeight-e.bottom<80?(this.#o.style.top="",this.#o.style.bottom=window.innerHeight-e.top+11+"px",this.#o.classList.add("tbw-tooltip-above")):(this.#o.style.top=`${e.bottom+11}px`,this.#o.style.bottom="",this.#o.classList.remove("tbw-tooltip-above"))}#h(t){if(!this.#o)return;const e=t.getBoundingClientRect(),o=this.#o.getBoundingClientRect();this.#o.classList.toggle("tbw-tooltip-above",o.bottom<=e.top)}#c(){if(this.#i)return;const t=this.gridElement?.querySelector(".tbw-grid-root");t&&(this.#i=!0,t.addEventListener("mouseover",t=>this.#f(t),{signal:this.disconnectSignal}),t.addEventListener("mouseout",t=>this.#g(t),{signal:this.disconnectSignal}))}#f(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"]');if(o&&this.#n)return void this.#b(o);const r=e.closest("[data-row][data-col]");r&&this.#s&&!r.style.getPropertyValue("anchor-name")&&this.#m(r)}#g(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"], [data-row][data-col]');if(!o)return;const r=t.relatedTarget;r&&o.contains(r)||this.#l()}#b(t){const e=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0)return;const o=this.visibleColumns[e];if(!o)return;const r=function(t,e){const o=t.headerTooltip;if(!1===o)return null;if("string"==typeof o)return o;if("function"==typeof o)return o({column:t,value:t.header??t.field});const r=e.querySelector("span:first-child")??e;return p(r)&&r.textContent?.trim()||null}(o,t);r&&this.#p(t,r)}#m(t){const e=parseInt(t.getAttribute("data-row")??"-1",10),o=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0||o<0)return;const r=this.visibleColumns[o];if(!r)return;const i=this.rows[e],n=i?.[r.field],s=function(t,e,o,r,i){const n=t.cellTooltip;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|math".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){const e=document.createElement("template");return t&&"string"==typeof t&&(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):"is"!==t?(n.has(t)&&s.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&o.push(e.name):o.push(e.name)}o.forEach(t=>l.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content)),e.content}var a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var c=class{static dependencies;static manifest;aliases;version="3.5.3";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)}queryBoolean(t,e=null){const o=this.grid?.query?.(t,e);return Array.isArray(o)?o.some(Boolean):!!o}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}}t(t,e){return this.grid?.effectiveConfig?.locale?.[t]??e}get translate(){return(t,e)=>this.t(t,e)}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);var i,n;void 0!==r?"string"==typeof r?(i=t,(n=r)&&"string"==typeof n?-1!==n.indexOf("<")||-1!==n.indexOf("&")?i.replaceChildren(l(n)):i.textContent=n:i.replaceChildren()):r instanceof HTMLElement&&t.replaceChildren(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,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.#c()}#a(){if(this.#o)return;const t=document.createElement("div");t.className="tbw-tooltip-popover",t.setAttribute("popover","hint"),t.style.overflow="visible",t.style.margin="0",document.body.appendChild(t),this.#o=t}#p(t,e){if(this.#o){if(this.#d(),t.style.setProperty("anchor-name","--tbw-tooltip-anchor"),this.#r=t,this.#o.textContent=e,this.#o.classList.toggle("tbw-tooltip-multiline",e.includes("\n")),d())try{this.#o.showPopover()}catch{}"undefined"!=typeof CSS&&!0===CSS.supports?.("anchor-name","--test")?requestAnimationFrame(()=>this.#h(t)):this.#u(t)}}#l(){if(this.#o){if(d())try{this.#o.hidePopover()}catch{}this.#o.classList.remove("tbw-tooltip-above")}this.#d()}#d(){this.#r&&("--tbw-tooltip-anchor"===this.#r.style.getPropertyValue("anchor-name")&&this.#r.style.removeProperty("anchor-name"),this.#r=null)}#u(t){if(!this.#o)return;const e=t.getBoundingClientRect();this.#o.style.position="fixed",this.#o.style.left=`${e.left}px`,window.innerHeight-e.bottom<80?(this.#o.style.top="",this.#o.style.bottom=window.innerHeight-e.top+11+"px",this.#o.classList.add("tbw-tooltip-above")):(this.#o.style.top=`${e.bottom+11}px`,this.#o.style.bottom="",this.#o.classList.remove("tbw-tooltip-above"))}#h(t){if(!this.#o)return;const e=t.getBoundingClientRect(),o=this.#o.getBoundingClientRect();this.#o.classList.toggle("tbw-tooltip-above",o.bottom<=e.top)}#c(){if(this.#i)return;const t=this.gridElement?.querySelector(".tbw-grid-root");t&&(this.#i=!0,t.addEventListener("mouseover",t=>this.#f(t),{signal:this.disconnectSignal}),t.addEventListener("mouseout",t=>this.#g(t),{signal:this.disconnectSignal}))}#f(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"]');if(o&&this.#n)return void this.#b(o);const r=e.closest("[data-row][data-col]");r&&this.#s&&!r.style.getPropertyValue("anchor-name")&&this.#m(r)}#g(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"], [data-row][data-col]');if(!o)return;const r=t.relatedTarget;r&&o.contains(r)||this.#l()}#b(t){const e=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0)return;const o=this.visibleColumns[e];if(!o)return;const r=function(t,e){const o=t.headerTooltip;if(!1===o)return null;if("string"==typeof o)return o;if("function"==typeof o)return o({column:t,value:t.header??t.field});const r=e.querySelector("span:first-child")??e;return p(r)&&r.textContent?.trim()||null}(o,t);r&&this.#p(t,r)}#m(t){const e=parseInt(t.getAttribute("data-row")??"-1",10),o=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0||o<0)return;const r=this.visibleColumns[o];if(!r)return;const i=this.rows[e],n=i?.[r.field],s=function(t,e,o,r,i){const n=t.cellTooltip;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};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e="expanded",t="tree-toggle",r="__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("")),n=(new RegExp(`__(proto|defineGetter|defineSetter)|${r.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|math".split("|"))),i=/^on\w+$/i,s=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),o=/^\s*(javascript|vbscript|data|blob):/i;function a(e){const t=document.createElement("template");return e&&"string"==typeof e&&(t.innerHTML=e,function(e){const t=[],r=e.querySelectorAll("*");for(const a of r){const e=a.tagName.toLowerCase();if(n.has(e)){t.push(a);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===a.namespaceURI)&&Array.from(a.attributes).some(e=>i.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(a);continue}const r=[];for(const t of a.attributes){const e=t.name.toLowerCase();i.test(e)?r.push(t.name):"is"!==e?(s.has(e)&&o.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&r.push(t.name):r.push(t.name)}r.forEach(e=>a.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content)),t.content}function d(e,t){t&&"string"==typeof t?-1!==t.indexOf("<")||-1!==t.indexOf("&")?e.replaceChildren(a(t)):e.textContent=t:e.replaceChildren()}var l={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"},c=/* @__PURE__ */new WeakMap;function h(e){return"__proto__"===e||"constructor"===e||"prototype"===e}var u=/* @__PURE__ */new Map;function f(e){if(-1===e.indexOf("."))return null;let t=u.get(e);return void 0===t&&(t=Object.freeze(e.split(".")),u.set(e,t)),t}function g(e,t){let r=e;for(let n=0;n<t.length;n++){if(null==r||"object"!=typeof r)return;const e=t[n];if(h(e))return;r=r[e]}return r}function p(e){const t=f(e);return null===t?h(e)?()=>{}:t=>null==t?void 0:t[e]:r=>{if(null==r)return;const n=r;return Object.prototype.hasOwnProperty.call(n,e)?n[e]:g(n,t)}}function y(e,t,r=-1){if(!t.valueAccessor)return function(e,t){if(null==e)return;const r=f(t),n=e;return null===r?h(t)?void 0:n[t]:Object.prototype.hasOwnProperty.call(n,t)?n[t]:g(n,r)}(e,t.field);if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:r});const n=e,i=t.field;let s=c.get(n);if(s){const e=s.get(i);if(void 0!==e)return e.v}else s=/* @__PURE__ */new Map,c.set(n,s);const o=t.valueAccessor({row:e,column:t,rowIndex:r});return s.set(i,{v:o}),o}function w(e,t,r){const n=[...e];return function(e,t,r,n){const i=n.find(e=>e.field===t),s=i?.sortComparator;if(s)if(i?.valueAccessor)e.sort((e,t)=>s(y(e,i),y(t,i),e,t)*r);else{const n=p(t);e.sort((e,t)=>s(n(e),n(t),e,t)*r)}else i?.valueAccessor?function(e,t,r){m(e,e=>y(e,t),r)}(e,i,r):function(e,t,r){if(function(e){return-1===e.indexOf(".")&&!h(e)}(t))return void e.sort((e,n)=>{const i=function(e,t){const r=!0===e?.__loading;return r===(!0===t?.__loading)?0:r?1:-1}(e,n);if(0!==i)return i;const s=e[t],o=n[t];return null==s&&null==o?0:null==s?-r:null==o||s>o?r:s<o?-r:0});m(e,p(t),r)}(e,t,r)}(n,t.field,t.direction,r),n}function m(e,t,r){const n=e.length;if(n<2)return;const i=new Array(n),s=new Uint8Array(n),o=new Array(n);for(let d=0;d<n;d++){const r=e[d];o[d]=d,i[d]=t(r),s[d]=!0===r?.__loading?1:0}o.sort((e,t)=>{const n=s[e];if(n!==s[t])return n?1:-1;const o=i[e],a=i[t];return null==o&&null==a?0:null==o?-r:null==a||o>a?r:o<a?-r:0});const a=new Array(n);for(let d=0;d<n;d++)a[d]=e[o[d]];for(let d=0;d<n;d++)e[d]=a[d]}function b(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function v(e,t,r,n){return`${b(r,n)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}var x=class{static dependencies;static manifest;aliases;version="3.5.2";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},r={};for(const n of Object.keys(t))r[n]=this;for(const n of e){const e=n.userConfig;for(const[i,s]of Object.entries(e)){if(void 0===s)continue;if(!(i in t)){t[i]=s,r[i]=n;continue}if(t[i]===s)continue;const e=r[i]?.constructor.name??this.constructor.name,o=n.constructor.name,a=v("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${i}" supplied by both ${e} and ${o}. 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,r={...e.userConfig};for(const n of Object.keys(t))delete t[n];Object.assign(t,r)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}queryBoolean(e,t=null){const r=this.grid?.query?.(e,t);return Array.isArray(r)?r.some(Boolean):!!r}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{...l,...e}}t(e,t){return this.grid?.effectiveConfig?.locale?.[e]??t}get translate(){return(e,t)=>this.t(e,t)}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(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}setIcon(e,t,r){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,r);void 0!==n?"string"==typeof n?d(e,n):n instanceof HTMLElement&&e.replaceChildren(n.cloneNode(!0)):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const r=document.createElement("span");r.setAttribute("part","sort-indicator"),r.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(r,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(r,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(r,n):e.appendChild(r),r}warn(e,t){void 0!==t?console.warn(v(e,t,this.gridElement.id,this.name)):console.warn(`${b(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(v(e,t,this.gridElement.id,this.name))}};function C(e,t,r){return void 0!==e.id?String(e.id):r?`${r}-${t}`:String(t)}function A(e,t){const r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r}function S(e,t,r=null,n=0){const i=t.childrenField??"children",s=/* @__PURE__ */new Set;for(let o=0;o<e.length;o++){const a=e[o],d=C(a,o,r),l=a[i];if(Array.isArray(l)&&l.length>0){s.add(d);const e=S(l,t,d,n+1);for(const t of e)s.add(t)}}return s}function K(e,t,r,n=null,i=0){const s=r.childrenField??"children";for(let o=0;o<e.length;o++){const a=e[o],d=C(a,o,n);if(d===t)return[d];const l=a[s];if(Array.isArray(l)&&l.length>0){const e=K(l,t,r,d,i+1);if(e)return[d,...e]}}return null}function R(e,t,r,n){const i=K(e,t,r);if(!i)return n;const s=new Set(n);for(let o=0;o<i.length-1;o++)s.add(i[o]);return s}function k(e,t){const r=Math.min(t,e.length-1);if(r<0)return 0;let n=r;for(;n>0&&e[n].depth>0;)n--;let i=0;for(let s=0;s<=n;s++)0===e[s].depth&&i++;return i-1}function E(e){let t=0;for(const r of e)0===r.depth&&t++;return t}function q(e,t="children",r){if(!Array.isArray(e)||0===e.length)return!1;for(const n of e){if(!n)continue;const e=n[t];if(Array.isArray(e)&&e.length>0)return!0;if(null!=e&&!Array.isArray(e)&&e)return!0;if(r?.(n))return!0}return!1}var _=class extends x{static manifest={modifiesRowStructure:!0,hookPriority:{processRows:10},incompatibleWith:[{name:"groupingRows",reason:"Both plugins transform the entire row model. TreePlugin flattens nested hierarchies while GroupingRowsPlugin groups flat rows with synthetic headers. Use one approach per grid."},{name:"pivot",reason:"PivotPlugin replaces the entire row and column structure with aggregated pivot data. Tree hierarchy cannot coexist with pivot aggregation."}],events:[{type:"tree-expand",description:"Emitted when tree expansion state changes (toggle, expand all, collapse all). Broadcast to both DOM consumers and plugin bus."},{type:"tree-load-start",description:"Emitted when lazy child loading starts for a node whose children are not yet loaded."},{type:"tree-load-end",description:"Emitted when lazy child loading completes and children have been merged into the parent row."},{type:"tree-load-error",description:"Emitted when lazy child loading fails. The node leaves its loading state and can be retried."}],queries:[{type:"canMoveRow",description:"Returns false for rows with children (parent nodes cannot be reordered)"},{type:"datasource:viewport-mapping",description:"Translates flat viewport row indices to top-level node indices for ServerSide pagination."}]};static dependencies=[{name:"multiSort",required:!1,reason:"Queries sort model for coordinated tree sorting"},{name:"serverSide",required:!1,reason:"Consumes datasource events for lazy-loaded tree data"}];name="tree";styles="@layer tbw-plugins{tbw-grid .cell[data-field=__tbw_expander]{justify-content:flex-start;align-items:center;padding:0;display:flex;border-inline-end:none!important}tbw-grid .header-row .cell[data-field=__tbw_expander]{display:none}tbw-grid .header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1/3}tbw-grid .tree-cell-wrapper{vertical-align:middle;align-items:center;padding-inline-start:calc(var(--tbw-tree-depth,0) * var(--tbw-tree-indent-width,var(--tbw-tree-toggle-size,1.25em)));display:inline-flex;overflow:visible}tbw-grid .tree-expander{box-sizing:border-box;justify-content:flex-start;align-items:center;width:100%;height:100%;display:flex}tbw-grid .tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;width:var(--tbw-tree-toggle-size,1.25em);height:var(--tbw-tree-toggle-size,1.25em);flex-shrink:0;justify-content:center;align-items:center;display:inline-flex}tbw-grid .tree-toggle:hover{color:var(--tbw-tree-accent,var(--tbw-color-accent))}tbw-grid .tree-spacer{width:var(--tbw-tree-toggle-size,1.25em);height:var(--tbw-tree-toggle-size,1.25em);flex-shrink:0;display:inline-block}@media (pointer:coarse){tbw-grid .tree-toggle,tbw-grid .tree-spacer{min-width:var(--tbw-touch-target-min,24px);min-height:var(--tbw-touch-target-min,24px)}}tbw-grid .tree-loading{--tbw-spinner-size:var(--tbw-tree-toggle-size,1.25em);flex-shrink:0}tbw-grid .data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration,.2s) var(--tbw-animation-easing,ease-out) forwards}tbw-grid .data-grid-row.tbw-tree-fade-in{animation:tbw-tree-fade-in var(--tbw-animation-duration,.2s) var(--tbw-animation-easing,ease-out) forwards}@keyframes tbw-tree-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}}";get defaultConfig(){return{childrenField:"children",autoDetect:!0,defaultExpanded:!1,indentWidth:20,showExpandIcons:!0,animation:"slide"}}expandedKeys=/* @__PURE__ */new Set;initialExpansionDone=!1;flattenedRows=[];rowKeyMap=/* @__PURE__ */new Map;previousVisibleKeys=/* @__PURE__ */new Set;keysToAnimate=/* @__PURE__ */new Set;sortState=null;loadingKeys=/* @__PURE__ */new Set;loadedKeys=/* @__PURE__ */new Set;#r=/* @__PURE__ */new Map;#n=/* @__PURE__ */new WeakMap;#i=/* @__PURE__ */new WeakMap;originalTreeColumnRenderer;wrappedTreeColumnField;detach(){(this.gridElement?.querySelector(".rows-body"))?.setAttribute("role","grid"),this.expandedKeys.clear(),this.initialExpansionDone=!1,this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),this.keysToAnimate.clear(),this.sortState=null,this.loadingKeys.clear(),this.loadedKeys.clear();for(const e of this.#r.values())e.abort();this.#r.clear(),this.originalTreeColumnRenderer=void 0,this.wrappedTreeColumnField=void 0}handleQuery(e){if("canMoveRow"===e.type){const t=e.context,r=this.config.childrenField??"children",n=t?.[r];if(Array.isArray(n)&&n.length>0)return!1}if("datasource:viewport-mapping"===e.type){const{viewportStart:t,viewportEnd:r}=e.context;if(0===this.flattenedRows.length)return;return{startNode:k(this.flattenedRows,t),endNode:k(this.flattenedRows,r)+1,totalLoadedNodes:E(this.flattenedRows)}}}attach(e){super.attach(e),this.on("datasource:data",e=>{const t=e;t.claimed||(t.claimed=!0)}),this.on("datasource:children",e=>{const t=e;if("tree"!==t.context?.source)return;t.claimed=!0;const r=t.context.parentNode;if(r){const e=this.#s(r);this.#o(r,t.rows??[]),this.loadingKeys.delete(e),this.broadcast("tree-load-end",{key:e,row:r,depth:this.rowKeyMap.get(e)?.depth??0,childCount:t.rows?.length??0}),this.requestRender()}}),this.on("datasource:error",e=>{const t=e;if("tree"!==t.context?.source)return;const r=t.context.parentNode;if(!r)return;const n=this.#s(r);this.loadingKeys.delete(n)&&(this.broadcast("tree-load-error",{key:n,row:r,depth:this.rowKeyMap.get(n)?.depth??0,error:t.error}),this.requestRender())})}get animationStyle(){return!!this.isAnimationEnabled&&(this.config.animation??"slide")}detect(e){if(!this.config.autoDetect)return!1;const t=e;return q(t,this.config.childrenField??function(e){if(!Array.isArray(e)||0===e.length)return null;const t=["children","items","nodes","subRows","nested"];for(const r of e)if(r&&"object"==typeof r)for(const e of t){const t=r[e];if(Array.isArray(t)&&t.length>0)return e}return null}(t)??"children")}processRows(e){const t=this.config.childrenField??"children",r=e;if(0===r.length||!q(r,t,this.config.hasChildren))return this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),[...e];const n=this.resolveEffectiveSortState();this.config.defaultExpanded&&!this.initialExpansionDone&&(this.expandedKeys=S(r,this.config),this.initialExpansionDone=!0),this.flattenedRows=this.#a(r,this.expandedKeys,n,null,0),this.#i=/* @__PURE__ */new WeakMap,this.rowKeyMap.clear(),this.keysToAnimate.clear();const i=/* @__PURE__ */new Set;for(const s of this.flattenedRows)this.rowKeyMap.set(s.key,s),this.#i.set(s.data,s),i.add(s.key),!this.previousVisibleKeys.has(s.key)&&s.depth>0&&this.keysToAnimate.add(s.key);return this.previousVisibleKeys=i,this.flattenedRows.map(e=>e.data)}#d(e,t,r){if(void 0!==e.id){const t=String(e.id);return this.#n.set(e,t),t}const n=this.#n.get(e);if(void 0!==n)return n;const i=r?`${r}-${t}`:String(t);return this.#n.set(e,i),i}#a(e,t,r,n,i){const s=this.config.childrenField??"children";for(let l=0;l<e.length;l++)this.#d(e[l],l,n);const o=r?this.#l(e,r.field,r.direction):e,a=[],d=this.config.hasChildren;for(let l=0;l<o.length;l++){const e=o[l],c=this.#d(e,l,n),h=e[s],u=Array.isArray(h)&&h.length>0,f=u||(d?d(e):null!=h&&!Array.isArray(h)&&!!h),g=t.has(c);a.push({key:c,data:e,depth:i,hasChildren:f,isExpanded:g,parentKey:n,posInSet:l+1,setSize:o.length}),u&&g&&a.push(...this.#a(h,t,r,c,i+1))}return a}#l(e,t,r){const n=this.grid,i=n?._columns??[],s={field:t,direction:r},o=[...e],a=(n?.effectiveConfig?.sortHandler??w)(o,s,i);return a&&"function"==typeof a.then?(a.catch(()=>{}),w(o,s,i)):a}#s(e){return this.#n.get(e)??String(e.id??"?")}#o(e,t){e[this.config.childrenField??"children"]=t,this.loadedKeys.add(this.#s(e))}#c(e,t){if(this.loadedKeys.has(t))return!1;const r=e[this.config.childrenField??"children"];if(Array.isArray(r)&&r.length>0)return!1;const n=this.config.hasChildren;return n?n(e):null!=r&&!Array.isArray(r)&&!!r}requestLazyChildren(e){const{key:t,depth:r,data:n}=e;if(this.loadingKeys.has(t))return;if(!this.#c(n,t))return;const i=this.queryBoolean("datasource:is-active"),{loadChildren:s}=this.config;(i||s)&&(this.loadingKeys.add(t),this.broadcast("tree-load-start",{key:t,row:n,depth:r}),i?this.grid.query("datasource:fetch-children",{context:{source:"tree",parentNode:n,nodePath:[t]}}):this.#h(t,n,r))}#h(e,t,r){const n=this.config.loadChildren,i=new AbortController;this.#r.set(e,i);const s=()=>!i.signal.aborted&&(this.#r.delete(e),this.loadingKeys.delete(e),!0),o=n=>{if(!s())return;const i=n??[];this.#o(t,i),this.broadcast("tree-load-end",{key:e,row:t,depth:r,childCount:i.length}),this.requestRender()},a=n=>{s()&&(this.broadcast("tree-load-error",{key:e,row:t,depth:r,error:n}),this.requestRender())};let d;try{d=n({row:t,key:e,depth:r,signal:i.signal})}catch(l){return void a(l)}if(d&&"function"==typeof d.subscribe){let e=!1,t=null;const r=()=>{e=!0,t?.unsubscribe(),t=null},n=d.subscribe({next:e=>{o(e),r()},error:e=>{a(e),r()}});return e?void n.unsubscribe():(t=n,void i.signal.addEventListener("abort",r,{once:!0}))}Promise.resolve(d).then(o,a)}resolveEffectiveSortState(){const e=this.grid?.query?.("sort:get-model",null);if(Array.isArray(e)&&e.length>0){const t=e[0];if(Array.isArray(t)&&t.length>0)return{field:t[0].field,direction:"desc"===t[0].direction?-1:1}}return this.sortState}processColumns(r){if(0===this.flattenedRows.length)return[...r];const n=[...r];if(0===n.length)return n;const{treeColumn:i}=this.config;let s=0;if(i){const e=n.findIndex(e=>e.field===i);e>=0&&(s=e)}const o=n[s],a=o.field;this.wrappedTreeColumnField!==a&&(this.originalTreeColumnRenderer=o.viewRenderer,this.wrappedTreeColumnField=a);const l=this.originalTreeColumnRenderer,c=()=>this.config,h=this.setIcon.bind(this);return n[s]={...o,viewRenderer:r=>{const{row:n,value:i}=r,{showExpandIcons:s=!0,indentWidth:o}=c(),a=this.#i.get(n),u=a?.depth??0,f=document.createElement("span");if(f.className="tree-cell-wrapper",f.style.setProperty("--tbw-tree-depth",String(u)),void 0!==o&&f.style.setProperty("--tbw-tree-indent-width",`${o}px`),s)if(a&&this.loadingKeys.has(a.key)){const e=function(e){const t=document.createElement("div");return t.className=`tbw-spinner tbw-spinner--${e}`,t.setAttribute("role","progressbar"),t.setAttribute("aria-label","Loading"),t}("small");e.classList.add("tree-loading"),f.appendChild(e)}else if(a&&a.hasChildren){const r=document.createElement("span");r.className=`${t}${a.isExpanded?` ${e}`:""}`,h(r,a.isExpanded?"collapse":"expand"),r.setAttribute("data-tree-key",a.key),f.appendChild(r)}else{const e=document.createElement("span");e.className="tree-spacer",f.appendChild(e)}const g=document.createElement("span");if(g.className="tree-content",l){const e=l(r);e instanceof Node?g.appendChild(e):"string"==typeof e&&d(g,e)}else g.textContent=null!=i?String(i):"";return f.appendChild(g),f}},n}onCellClick(e){const r=e.originalEvent?.target;if(!r?.classList.contains(t))return!1;const n=r.getAttribute("data-tree-key");if(!n)return!1;const i=this.rowKeyMap.get(n);return!!i&&(this.expandedKeys=A(this.expandedKeys,n),this.expandedKeys.has(n)&&this.requestLazyChildren(i),this.broadcast("tree-expand",{key:n,row:i.data,expanded:this.expandedKeys.has(n),depth:i.depth,expandedKeys:[...this.expandedKeys]}),this.requestRender(),!0)}onKeyDown(e){if(" "!==e.key)return;const t=this.grid._focusRow,r=this.flattenedRows[t];return r?.hasChildren?(e.preventDefault(),this.expandedKeys=A(this.expandedKeys,r.key),this.expandedKeys.has(r.key)&&this.requestLazyChildren(r),this.broadcast("tree-expand",{key:r.key,row:r.data,expanded:this.expandedKeys.has(r.key),depth:r.depth,expandedKeys:[...this.expandedKeys]}),this.requestRenderWithFocus(),!0):void 0}onHeaderClick(e){if(0===this.flattenedRows.length||!e.column.sortable)return!1;const t=this.grid?.query?.("sort:get-model",null);if(Array.isArray(t)&&t.length>0)return!1;const{field:r}=e.column;this.sortState&&this.sortState.field===r?1===this.sortState.direction?this.sortState={field:r,direction:-1}:this.sortState=null:this.sortState={field:r,direction:1};const n=this.grid;return void 0!==n._sortState&&(n._sortState=this.sortState?{...this.sortState}:null),this.broadcast("sort-change",{field:r,direction:this.sortState?.direction??0}),this.requestRender(),!0}afterRender(){const e=this.gridElement?.querySelector(".rows-body");e&&"treegrid"!==e.getAttribute("role")&&e.setAttribute("role","treegrid");const t=this.gridElement?.querySelector(".rows");if(!t)return;const r=this.animationStyle,n=!1!==r&&this.keysToAnimate.size>0,i="fade"===r?"tbw-tree-fade-in":"tbw-tree-slide-in";for(const s of t.querySelectorAll(".data-grid-row")){const e=s.querySelector(".cell[data-row]"),t=e?parseInt(e.getAttribute("data-row")??"-1",10):-1,r=this.flattenedRows[t];r&&(s.setAttribute("aria-level",String(r.depth+1)),s.setAttribute("aria-setsize",String(r.setSize)),s.setAttribute("aria-posinset",String(r.posInSet)),r.hasChildren?s.setAttribute("aria-expanded",String(r.isExpanded)):s.hasAttribute("aria-expanded")&&s.removeAttribute("aria-expanded"),s.classList.toggle("tbw-row-expanded",r.hasChildren&&r.isExpanded),this.loadingKeys.has(r.key)?s.setAttribute("aria-busy","true"):s.hasAttribute("aria-busy")&&s.removeAttribute("aria-busy"),n&&r.key&&this.keysToAnimate.has(r.key)&&(s.classList.add(i),s.addEventListener("animationend",()=>s.classList.remove(i),{once:!0})))}this.keysToAnimate.clear()}expand(e){this.expandedKeys.add(e);const t=this.rowKeyMap.get(e);t&&this.requestLazyChildren(t),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}toggle(e){this.expandedKeys=A(this.expandedKeys,e);const t=this.rowKeyMap.get(e);t?(this.expandedKeys.has(e)&&this.requestLazyChildren(t),this.broadcast("tree-expand",{key:e,row:t.data,expanded:this.expandedKeys.has(e),depth:t.depth,expandedKeys:[...this.expandedKeys]})):this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}expandAll(){this.expandedKeys=S(this.rows,this.config),this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}collapseAll(){this.expandedKeys=/* @__PURE__ */new Set,this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}getExpandedKeys(){return[...this.expandedKeys]}getFlattenedRows(){return[...this.flattenedRows]}getRowMeta(e){return this.#i.get(e)}getRowByKey(e){return this.rowKeyMap.get(e)?.data}expandToKey(e){this.expandedKeys=R(this.rows,e,this.config,this.expandedKeys),this.requestRender()}};export{_ as TreePlugin};
|
|
1
|
+
var e="expanded",t="tree-toggle",r="__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("")),n=(new RegExp(`__(proto|defineGetter|defineSetter)|${r.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|math".split("|"))),i=/^on\w+$/i,s=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),o=/^\s*(javascript|vbscript|data|blob):/i;function a(e){const t=document.createElement("template");return e&&"string"==typeof e&&(t.innerHTML=e,function(e){const t=[],r=e.querySelectorAll("*");for(const a of r){const e=a.tagName.toLowerCase();if(n.has(e)){t.push(a);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===a.namespaceURI)&&Array.from(a.attributes).some(e=>i.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(a);continue}const r=[];for(const t of a.attributes){const e=t.name.toLowerCase();i.test(e)?r.push(t.name):"is"!==e?(s.has(e)&&o.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&r.push(t.name):r.push(t.name)}r.forEach(e=>a.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content)),t.content}function d(e,t){t&&"string"==typeof t?-1!==t.indexOf("<")||-1!==t.indexOf("&")?e.replaceChildren(a(t)):e.textContent=t:e.replaceChildren()}var l={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"},c=/* @__PURE__ */new WeakMap;function h(e){return"__proto__"===e||"constructor"===e||"prototype"===e}var u=/* @__PURE__ */new Map;function f(e){if(-1===e.indexOf("."))return null;let t=u.get(e);return void 0===t&&(t=Object.freeze(e.split(".")),u.set(e,t)),t}function g(e,t){let r=e;for(let n=0;n<t.length;n++){if(null==r||"object"!=typeof r)return;const e=t[n];if(h(e))return;r=r[e]}return r}function p(e){const t=f(e);return null===t?h(e)?()=>{}:t=>null==t?void 0:t[e]:r=>{if(null==r)return;const n=r;return Object.prototype.hasOwnProperty.call(n,e)?n[e]:g(n,t)}}function y(e,t,r=-1){if(!t.valueAccessor)return function(e,t){if(null==e)return;const r=f(t),n=e;return null===r?h(t)?void 0:n[t]:Object.prototype.hasOwnProperty.call(n,t)?n[t]:g(n,r)}(e,t.field);if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:r});const n=e,i=t.field;let s=c.get(n);if(s){const e=s.get(i);if(void 0!==e)return e.v}else s=/* @__PURE__ */new Map,c.set(n,s);const o=t.valueAccessor({row:e,column:t,rowIndex:r});return s.set(i,{v:o}),o}function w(e,t,r){const n=[...e];return function(e,t,r,n){const i=n.find(e=>e.field===t),s=i?.sortComparator;if(s)if(i?.valueAccessor)e.sort((e,t)=>s(y(e,i),y(t,i),e,t)*r);else{const n=p(t);e.sort((e,t)=>s(n(e),n(t),e,t)*r)}else i?.valueAccessor?function(e,t,r){m(e,e=>y(e,t),r)}(e,i,r):function(e,t,r){if(function(e){return-1===e.indexOf(".")&&!h(e)}(t))return void e.sort((e,n)=>{const i=function(e,t){const r=!0===e?.__loading;return r===(!0===t?.__loading)?0:r?1:-1}(e,n);if(0!==i)return i;const s=e[t],o=n[t];return null==s&&null==o?0:null==s?-r:null==o||s>o?r:s<o?-r:0});m(e,p(t),r)}(e,t,r)}(n,t.field,t.direction,r),n}function m(e,t,r){const n=e.length;if(n<2)return;const i=new Array(n),s=new Uint8Array(n),o=new Array(n);for(let d=0;d<n;d++){const r=e[d];o[d]=d,i[d]=t(r),s[d]=!0===r?.__loading?1:0}o.sort((e,t)=>{const n=s[e];if(n!==s[t])return n?1:-1;const o=i[e],a=i[t];return null==o&&null==a?0:null==o?-r:null==a||o>a?r:o<a?-r:0});const a=new Array(n);for(let d=0;d<n;d++)a[d]=e[o[d]];for(let d=0;d<n;d++)e[d]=a[d]}function b(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function v(e,t,r,n){return`${b(r,n)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}var x=class{static dependencies;static manifest;aliases;version="3.5.3";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},r={};for(const n of Object.keys(t))r[n]=this;for(const n of e){const e=n.userConfig;for(const[i,s]of Object.entries(e)){if(void 0===s)continue;if(!(i in t)){t[i]=s,r[i]=n;continue}if(t[i]===s)continue;const e=r[i]?.constructor.name??this.constructor.name,o=n.constructor.name,a=v("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${i}" supplied by both ${e} and ${o}. 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,r={...e.userConfig};for(const n of Object.keys(t))delete t[n];Object.assign(t,r)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}queryBoolean(e,t=null){const r=this.grid?.query?.(e,t);return Array.isArray(r)?r.some(Boolean):!!r}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{...l,...e}}t(e,t){return this.grid?.effectiveConfig?.locale?.[e]??t}get translate(){return(e,t)=>this.t(e,t)}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(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}setIcon(e,t,r){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,r);void 0!==n?"string"==typeof n?d(e,n):n instanceof HTMLElement&&e.replaceChildren(n.cloneNode(!0)):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const r=document.createElement("span");r.setAttribute("part","sort-indicator"),r.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(r,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(r,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(r,n):e.appendChild(r),r}warn(e,t){void 0!==t?console.warn(v(e,t,this.gridElement.id,this.name)):console.warn(`${b(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(v(e,t,this.gridElement.id,this.name))}};function C(e,t,r){return void 0!==e.id?String(e.id):r?`${r}-${t}`:String(t)}function A(e,t){const r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r}function S(e,t,r=null,n=0){const i=t.childrenField??"children",s=/* @__PURE__ */new Set;for(let o=0;o<e.length;o++){const a=e[o],d=C(a,o,r),l=a[i];if(Array.isArray(l)&&l.length>0){s.add(d);const e=S(l,t,d,n+1);for(const t of e)s.add(t)}}return s}function K(e,t,r,n=null,i=0){const s=r.childrenField??"children";for(let o=0;o<e.length;o++){const a=e[o],d=C(a,o,n);if(d===t)return[d];const l=a[s];if(Array.isArray(l)&&l.length>0){const e=K(l,t,r,d,i+1);if(e)return[d,...e]}}return null}function R(e,t,r,n){const i=K(e,t,r);if(!i)return n;const s=new Set(n);for(let o=0;o<i.length-1;o++)s.add(i[o]);return s}function k(e,t){const r=Math.min(t,e.length-1);if(r<0)return 0;let n=r;for(;n>0&&e[n].depth>0;)n--;let i=0;for(let s=0;s<=n;s++)0===e[s].depth&&i++;return i-1}function E(e){let t=0;for(const r of e)0===r.depth&&t++;return t}function q(e,t="children",r){if(!Array.isArray(e)||0===e.length)return!1;for(const n of e){if(!n)continue;const e=n[t];if(Array.isArray(e)&&e.length>0)return!0;if(null!=e&&!Array.isArray(e)&&e)return!0;if(r?.(n))return!0}return!1}var _=class extends x{static manifest={modifiesRowStructure:!0,hookPriority:{processRows:10},incompatibleWith:[{name:"groupingRows",reason:"Both plugins transform the entire row model. TreePlugin flattens nested hierarchies while GroupingRowsPlugin groups flat rows with synthetic headers. Use one approach per grid."},{name:"pivot",reason:"PivotPlugin replaces the entire row and column structure with aggregated pivot data. Tree hierarchy cannot coexist with pivot aggregation."}],events:[{type:"tree-expand",description:"Emitted when tree expansion state changes (toggle, expand all, collapse all). Broadcast to both DOM consumers and plugin bus."},{type:"tree-load-start",description:"Emitted when lazy child loading starts for a node whose children are not yet loaded."},{type:"tree-load-end",description:"Emitted when lazy child loading completes and children have been merged into the parent row."},{type:"tree-load-error",description:"Emitted when lazy child loading fails. The node leaves its loading state and can be retried."}],queries:[{type:"canMoveRow",description:"Returns false for rows with children (parent nodes cannot be reordered)"},{type:"datasource:viewport-mapping",description:"Translates flat viewport row indices to top-level node indices for ServerSide pagination."}]};static dependencies=[{name:"multiSort",required:!1,reason:"Queries sort model for coordinated tree sorting"},{name:"serverSide",required:!1,reason:"Consumes datasource events for lazy-loaded tree data"}];name="tree";styles="@layer tbw-plugins{tbw-grid .cell[data-field=__tbw_expander]{justify-content:flex-start;align-items:center;padding:0;display:flex;border-inline-end:none!important}tbw-grid .header-row .cell[data-field=__tbw_expander]{display:none}tbw-grid .header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1/3}tbw-grid .tree-cell-wrapper{vertical-align:middle;align-items:center;padding-inline-start:calc(var(--tbw-tree-depth,0) * var(--tbw-tree-indent-width,var(--tbw-tree-toggle-size,1.25em)));display:inline-flex;overflow:visible}tbw-grid .tree-expander{box-sizing:border-box;justify-content:flex-start;align-items:center;width:100%;height:100%;display:flex}tbw-grid .tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;width:var(--tbw-tree-toggle-size,1.25em);height:var(--tbw-tree-toggle-size,1.25em);flex-shrink:0;justify-content:center;align-items:center;display:inline-flex}tbw-grid .tree-toggle:hover{color:var(--tbw-tree-accent,var(--tbw-color-accent))}tbw-grid .tree-spacer{width:var(--tbw-tree-toggle-size,1.25em);height:var(--tbw-tree-toggle-size,1.25em);flex-shrink:0;display:inline-block}@media (pointer:coarse){tbw-grid .tree-toggle,tbw-grid .tree-spacer{min-width:var(--tbw-touch-target-min,24px);min-height:var(--tbw-touch-target-min,24px)}}tbw-grid .tree-loading{--tbw-spinner-size:var(--tbw-tree-toggle-size,1.25em);flex-shrink:0}tbw-grid .data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration,.2s) var(--tbw-animation-easing,ease-out) forwards}tbw-grid .data-grid-row.tbw-tree-fade-in{animation:tbw-tree-fade-in var(--tbw-animation-duration,.2s) var(--tbw-animation-easing,ease-out) forwards}@keyframes tbw-tree-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}}";get defaultConfig(){return{childrenField:"children",autoDetect:!0,defaultExpanded:!1,indentWidth:20,showExpandIcons:!0,animation:"slide"}}expandedKeys=/* @__PURE__ */new Set;initialExpansionDone=!1;flattenedRows=[];rowKeyMap=/* @__PURE__ */new Map;previousVisibleKeys=/* @__PURE__ */new Set;keysToAnimate=/* @__PURE__ */new Set;sortState=null;loadingKeys=/* @__PURE__ */new Set;loadedKeys=/* @__PURE__ */new Set;#r=/* @__PURE__ */new Map;#n=/* @__PURE__ */new WeakMap;#i=/* @__PURE__ */new WeakMap;originalTreeColumnRenderer;wrappedTreeColumnField;detach(){(this.gridElement?.querySelector(".rows-body"))?.setAttribute("role","grid"),this.expandedKeys.clear(),this.initialExpansionDone=!1,this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),this.keysToAnimate.clear(),this.sortState=null,this.loadingKeys.clear(),this.loadedKeys.clear();for(const e of this.#r.values())e.abort();this.#r.clear(),this.originalTreeColumnRenderer=void 0,this.wrappedTreeColumnField=void 0}handleQuery(e){if("canMoveRow"===e.type){const t=e.context,r=this.config.childrenField??"children",n=t?.[r];if(Array.isArray(n)&&n.length>0)return!1}if("datasource:viewport-mapping"===e.type){const{viewportStart:t,viewportEnd:r}=e.context;if(0===this.flattenedRows.length)return;return{startNode:k(this.flattenedRows,t),endNode:k(this.flattenedRows,r)+1,totalLoadedNodes:E(this.flattenedRows)}}}attach(e){super.attach(e),this.on("datasource:data",e=>{const t=e;t.claimed||(t.claimed=!0)}),this.on("datasource:children",e=>{const t=e;if("tree"!==t.context?.source)return;t.claimed=!0;const r=t.context.parentNode;if(r){const e=this.#s(r);this.#o(r,t.rows??[]),this.loadingKeys.delete(e),this.broadcast("tree-load-end",{key:e,row:r,depth:this.rowKeyMap.get(e)?.depth??0,childCount:t.rows?.length??0}),this.requestRender()}}),this.on("datasource:error",e=>{const t=e;if("tree"!==t.context?.source)return;const r=t.context.parentNode;if(!r)return;const n=this.#s(r);this.loadingKeys.delete(n)&&(this.broadcast("tree-load-error",{key:n,row:r,depth:this.rowKeyMap.get(n)?.depth??0,error:t.error}),this.requestRender())})}get animationStyle(){return!!this.isAnimationEnabled&&(this.config.animation??"slide")}detect(e){if(!this.config.autoDetect)return!1;const t=e;return q(t,this.config.childrenField??function(e){if(!Array.isArray(e)||0===e.length)return null;const t=["children","items","nodes","subRows","nested"];for(const r of e)if(r&&"object"==typeof r)for(const e of t){const t=r[e];if(Array.isArray(t)&&t.length>0)return e}return null}(t)??"children")}processRows(e){const t=this.config.childrenField??"children",r=e;if(0===r.length||!q(r,t,this.config.hasChildren))return this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),[...e];const n=this.resolveEffectiveSortState();this.config.defaultExpanded&&!this.initialExpansionDone&&(this.expandedKeys=S(r,this.config),this.initialExpansionDone=!0),this.flattenedRows=this.#a(r,this.expandedKeys,n,null,0),this.#i=/* @__PURE__ */new WeakMap,this.rowKeyMap.clear(),this.keysToAnimate.clear();const i=/* @__PURE__ */new Set;for(const s of this.flattenedRows)this.rowKeyMap.set(s.key,s),this.#i.set(s.data,s),i.add(s.key),!this.previousVisibleKeys.has(s.key)&&s.depth>0&&this.keysToAnimate.add(s.key);return this.previousVisibleKeys=i,this.flattenedRows.map(e=>e.data)}#d(e,t,r){if(void 0!==e.id){const t=String(e.id);return this.#n.set(e,t),t}const n=this.#n.get(e);if(void 0!==n)return n;const i=r?`${r}-${t}`:String(t);return this.#n.set(e,i),i}#a(e,t,r,n,i){const s=this.config.childrenField??"children";for(let l=0;l<e.length;l++)this.#d(e[l],l,n);const o=r?this.#l(e,r.field,r.direction):e,a=[],d=this.config.hasChildren;for(let l=0;l<o.length;l++){const e=o[l],c=this.#d(e,l,n),h=e[s],u=Array.isArray(h)&&h.length>0,f=u||(d?d(e):null!=h&&!Array.isArray(h)&&!!h),g=t.has(c);a.push({key:c,data:e,depth:i,hasChildren:f,isExpanded:g,parentKey:n,posInSet:l+1,setSize:o.length}),u&&g&&a.push(...this.#a(h,t,r,c,i+1))}return a}#l(e,t,r){const n=this.grid,i=n?._columns??[],s={field:t,direction:r},o=[...e],a=(n?.effectiveConfig?.sortHandler??w)(o,s,i);return a&&"function"==typeof a.then?(a.catch(()=>{}),w(o,s,i)):a}#s(e){return this.#n.get(e)??String(e.id??"?")}#o(e,t){e[this.config.childrenField??"children"]=t,this.loadedKeys.add(this.#s(e))}#c(e,t){if(this.loadedKeys.has(t))return!1;const r=e[this.config.childrenField??"children"];if(Array.isArray(r)&&r.length>0)return!1;const n=this.config.hasChildren;return n?n(e):null!=r&&!Array.isArray(r)&&!!r}requestLazyChildren(e){const{key:t,depth:r,data:n}=e;if(this.loadingKeys.has(t))return;if(!this.#c(n,t))return;const i=this.queryBoolean("datasource:is-active"),{loadChildren:s}=this.config;(i||s)&&(this.loadingKeys.add(t),this.broadcast("tree-load-start",{key:t,row:n,depth:r}),i?this.grid.query("datasource:fetch-children",{context:{source:"tree",parentNode:n,nodePath:[t]}}):this.#h(t,n,r))}#h(e,t,r){const n=this.config.loadChildren,i=new AbortController;this.#r.set(e,i);const s=()=>!i.signal.aborted&&(this.#r.delete(e),this.loadingKeys.delete(e),!0),o=n=>{if(!s())return;const i=n??[];this.#o(t,i),this.broadcast("tree-load-end",{key:e,row:t,depth:r,childCount:i.length}),this.requestRender()},a=n=>{s()&&(this.broadcast("tree-load-error",{key:e,row:t,depth:r,error:n}),this.requestRender())};let d;try{d=n({row:t,key:e,depth:r,signal:i.signal})}catch(l){return void a(l)}if(d&&"function"==typeof d.subscribe){let e=!1,t=null;const r=()=>{e=!0,t?.unsubscribe(),t=null},n=d.subscribe({next:e=>{o(e),r()},error:e=>{a(e),r()}});return e?void n.unsubscribe():(t=n,void i.signal.addEventListener("abort",r,{once:!0}))}Promise.resolve(d).then(o,a)}resolveEffectiveSortState(){const e=this.grid?.query?.("sort:get-model",null);if(Array.isArray(e)&&e.length>0){const t=e[0];if(Array.isArray(t)&&t.length>0)return{field:t[0].field,direction:"desc"===t[0].direction?-1:1}}return this.sortState}processColumns(r){if(0===this.flattenedRows.length)return[...r];const n=[...r];if(0===n.length)return n;const{treeColumn:i}=this.config;let s=0;if(i){const e=n.findIndex(e=>e.field===i);e>=0&&(s=e)}const o=n[s],a=o.field;this.wrappedTreeColumnField!==a&&(this.originalTreeColumnRenderer=o.viewRenderer,this.wrappedTreeColumnField=a);const l=this.originalTreeColumnRenderer,c=()=>this.config,h=this.setIcon.bind(this);return n[s]={...o,viewRenderer:r=>{const{row:n,value:i}=r,{showExpandIcons:s=!0,indentWidth:o}=c(),a=this.#i.get(n),u=a?.depth??0,f=document.createElement("span");if(f.className="tree-cell-wrapper",f.style.setProperty("--tbw-tree-depth",String(u)),void 0!==o&&f.style.setProperty("--tbw-tree-indent-width",`${o}px`),s)if(a&&this.loadingKeys.has(a.key)){const e=function(e){const t=document.createElement("div");return t.className=`tbw-spinner tbw-spinner--${e}`,t.setAttribute("role","progressbar"),t.setAttribute("aria-label","Loading"),t}("small");e.classList.add("tree-loading"),f.appendChild(e)}else if(a&&a.hasChildren){const r=document.createElement("span");r.className=`${t}${a.isExpanded?` ${e}`:""}`,h(r,a.isExpanded?"collapse":"expand"),r.setAttribute("data-tree-key",a.key),f.appendChild(r)}else{const e=document.createElement("span");e.className="tree-spacer",f.appendChild(e)}const g=document.createElement("span");if(g.className="tree-content",l){const e=l(r);e instanceof Node?g.appendChild(e):"string"==typeof e&&d(g,e)}else g.textContent=null!=i?String(i):"";return f.appendChild(g),f}},n}onCellClick(e){const r=e.originalEvent?.target;if(!r?.classList.contains(t))return!1;const n=r.getAttribute("data-tree-key");if(!n)return!1;const i=this.rowKeyMap.get(n);return!!i&&(this.expandedKeys=A(this.expandedKeys,n),this.expandedKeys.has(n)&&this.requestLazyChildren(i),this.broadcast("tree-expand",{key:n,row:i.data,expanded:this.expandedKeys.has(n),depth:i.depth,expandedKeys:[...this.expandedKeys]}),this.requestRender(),!0)}onKeyDown(e){if(" "!==e.key)return;const t=this.grid._focusRow,r=this.flattenedRows[t];return r?.hasChildren?(e.preventDefault(),this.expandedKeys=A(this.expandedKeys,r.key),this.expandedKeys.has(r.key)&&this.requestLazyChildren(r),this.broadcast("tree-expand",{key:r.key,row:r.data,expanded:this.expandedKeys.has(r.key),depth:r.depth,expandedKeys:[...this.expandedKeys]}),this.requestRenderWithFocus(),!0):void 0}onHeaderClick(e){if(0===this.flattenedRows.length||!e.column.sortable)return!1;const t=this.grid?.query?.("sort:get-model",null);if(Array.isArray(t)&&t.length>0)return!1;const{field:r}=e.column;this.sortState&&this.sortState.field===r?1===this.sortState.direction?this.sortState={field:r,direction:-1}:this.sortState=null:this.sortState={field:r,direction:1};const n=this.grid;return void 0!==n._sortState&&(n._sortState=this.sortState?{...this.sortState}:null),this.broadcast("sort-change",{field:r,direction:this.sortState?.direction??0}),this.requestRender(),!0}afterRender(){const e=this.gridElement?.querySelector(".rows-body");e&&"treegrid"!==e.getAttribute("role")&&e.setAttribute("role","treegrid");const t=this.gridElement?.querySelector(".rows");if(!t)return;const r=this.animationStyle,n=!1!==r&&this.keysToAnimate.size>0,i="fade"===r?"tbw-tree-fade-in":"tbw-tree-slide-in";for(const s of t.querySelectorAll(".data-grid-row")){const e=s.querySelector(".cell[data-row]"),t=e?parseInt(e.getAttribute("data-row")??"-1",10):-1,r=this.flattenedRows[t];r&&(s.setAttribute("aria-level",String(r.depth+1)),s.setAttribute("aria-setsize",String(r.setSize)),s.setAttribute("aria-posinset",String(r.posInSet)),r.hasChildren?s.setAttribute("aria-expanded",String(r.isExpanded)):s.hasAttribute("aria-expanded")&&s.removeAttribute("aria-expanded"),s.classList.toggle("tbw-row-expanded",r.hasChildren&&r.isExpanded),this.loadingKeys.has(r.key)?s.setAttribute("aria-busy","true"):s.hasAttribute("aria-busy")&&s.removeAttribute("aria-busy"),n&&r.key&&this.keysToAnimate.has(r.key)&&(s.classList.add(i),s.addEventListener("animationend",()=>s.classList.remove(i),{once:!0})))}this.keysToAnimate.clear()}expand(e){this.expandedKeys.add(e);const t=this.rowKeyMap.get(e);t&&this.requestLazyChildren(t),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}toggle(e){this.expandedKeys=A(this.expandedKeys,e);const t=this.rowKeyMap.get(e);t?(this.expandedKeys.has(e)&&this.requestLazyChildren(t),this.broadcast("tree-expand",{key:e,row:t.data,expanded:this.expandedKeys.has(e),depth:t.depth,expandedKeys:[...this.expandedKeys]})):this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}expandAll(){this.expandedKeys=S(this.rows,this.config),this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}collapseAll(){this.expandedKeys=/* @__PURE__ */new Set,this.emitPluginEvent("tree-expand",{expandedKeys:[...this.expandedKeys]}),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}getExpandedKeys(){return[...this.expandedKeys]}getFlattenedRows(){return[...this.flattenedRows]}getRowMeta(e){return this.#i.get(e)}getRowByKey(e){return this.rowKeyMap.get(e)?.data}expandToKey(e){this.expandedKeys=R(this.rows,e,this.config,this.expandedKeys),this.requestRender()}};export{_ as TreePlugin};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t="editing";function e(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function n(t,n,o,r){return`${e(o,r)} ${t}: ${n}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(t)}`}function o(t){return"__proto__"===t||"constructor"===t||"prototype"===t}var r=/* @__PURE__ */new Map;function i(t,e,n){if(null==t||"object"!=typeof t)return!1;const i=function(t){if(-1===t.indexOf("."))return null;let e=r.get(t);return void 0===e&&(e=Object.freeze(t.split(".")),r.set(t,e)),e}(e),s=t;return null===i?!o(e)&&(s[e]=n,!0):Object.prototype.hasOwnProperty.call(s,e)?(s[e]=n,!0):function(t,e,n){if(null==t||"object"!=typeof t)return!1;let r=t;for(let s=0;s<e.length-1;s++){const t=e[s];if(o(t))return!1;const n=r[t];if(null==n||"object"!=typeof n)return!1;r=n}const i=e[e.length-1];return!o(i)&&(r[i]=n,!0)}(s,i,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(t=>t.split("").reverse().join("")),a=(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|math".split("|"))),c=/^on\w+$/i,d=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),u=/^\s*(javascript|vbscript|data|blob):/i;function l(t){const e=document.createElement("template");return t&&"string"==typeof t&&(e.innerHTML=t,function(t){const e=[],n=t.querySelectorAll("*");for(const o of n){const t=o.tagName.toLowerCase();if(a.has(t)){e.push(o);continue}if(("svg"===t||"http://www.w3.org/2000/svg"===o.namespaceURI)&&Array.from(o.attributes).some(t=>c.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(o);continue}const n=[];for(const e of o.attributes){const t=e.name.toLowerCase();c.test(t)?n.push(e.name):"is"!==t?(d.has(t)&&u.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&n.push(e.name):n.push(e.name)}n.forEach(t=>o.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content)),e.content}var h={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var f=class{static dependencies;static manifest;aliases;version="3.5.2";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},o={};for(const n of Object.keys(e))o[n]=this;for(const r of t){const t=r.userConfig;for(const[i,s]of Object.entries(t)){if(void 0===s)continue;if(!(i in e)){e[i]=s,o[i]=r;continue}if(e[i]===s)continue;const t=o[i]?.constructor.name??this.constructor.name,a=r.constructor.name,c=n("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(c)}}Object.assign(this.userConfig,e)}refreshUserConfigFrom(t){const e=this.userConfig,n={...t.userConfig};for(const o of Object.keys(e))delete e[o];Object.assign(e,n)}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 n=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(n),n.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)}queryBoolean(t,e=null){const n=this.grid?.query?.(t,e);return Array.isArray(n)?n.some(Boolean):!!n}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{...h,...t}}t(t,e){return this.grid?.effectiveConfig?.locale?.[t]??e}get translate(){return(t,e)=>this.t(t,e)}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(),n=parseInt(e,10);if(!isNaN(n))return n}return 200}setIcon(t,e,n){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const o=this.#e(e,n);var r,i;void 0!==o?"string"==typeof o?(r=t,(i=o)&&"string"==typeof i?-1!==i.indexOf("<")||-1!==i.indexOf("&")?r.replaceChildren(l(i)):r.textContent=i:r.replaceChildren()):o instanceof HTMLElement&&t.replaceChildren(o.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 n=document.createElement("span");n.setAttribute("part","sort-indicator"),n.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(n,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(n,"sortNone"));const o=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return o?t.insertBefore(n,o):t.appendChild(n),n}warn(t,o){void 0!==o?console.warn(n(t,o,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(t,e){throw new Error(n(t,e,this.gridElement.id,this.name))}};function g(t,e,n){const o=[...t.undoStack,e];for(;o.length>n;)o.shift();return{undoStack:o,redoStack:[]}}function p(t){if(0===t.undoStack.length)return{newState:t,action:null};const e=[...t.undoStack],n=e.pop();return n?{newState:{undoStack:e,redoStack:[...t.redoStack,n]},action:n}:{newState:t,action:null}}function S(t){if(0===t.redoStack.length)return{newState:t,action:null};const e=[...t.redoStack],n=e.pop();return n?{newState:{undoStack:[...t.undoStack,n],redoStack:e},action:n}:{newState:t,action:null}}var m=class extends f{static dependencies=[{name:"editing",required:!0,reason:"UndoRedoPlugin tracks cell edit history"}];name="undoRedo";get defaultConfig(){return{maxHistorySize:100}}undoStack=[];redoStack=[];#n=!1;#o=null;#r=0;#i(t,e){const n=this.rows[t.rowIndex];if(n){try{const o=this.grid.getRowId(n);if(o)return void this.grid.updateRow(o,{[t.field]:e},"history")}catch{}i(n,t.field,e)}}#s(e){const n=this.grid,o=n._visibleColumns?.findIndex(t=>t.field===e.field)??-1;if(o<0)return;n._focusRow=e.rowIndex,n._focusCol=o;const r=n.findRenderedRowElement?.(e.rowIndex);if(!r)return;const i=r.querySelector(`.cell[data-col="${o}"]`);i?.classList.contains(t)&&i.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])')?.focus({preventScroll:!0})}#a(t,e){if(this.#n=!0,"compound"===t.type){const n="undo"===e?[...t.actions].reverse():t.actions;for(const t of n)this.#i(t,"undo"===e?t.oldValue:t.newValue)}else this.#i(t,"undo"===e?t.oldValue:t.newValue);this.#n=!1}#c(t){const e="compound"===t.type?t.actions[t.actions.length-1]:t;e&&this.#s(e)}attach(t){super.attach(t),this.on("cell-edit-committed",t=>{this.#n||this.recordEdit(t.rowIndex,t.field,t.oldValue,t.newValue)})}detach(){this.undoStack=[],this.redoStack=[],this.#o=null,this.#r=0}onKeyDown(t){const e=(t.ctrlKey||t.metaKey)&&"z"===t.key&&!t.shiftKey,n=(t.ctrlKey||t.metaKey)&&("y"===t.key||"z"===t.key&&t.shiftKey);if(!e&&!n)return!1;const o=e?"undo":"redo";return this.#d(t.target)?(this.#u(t.target,o),!0):(t.preventDefault(),this.#l(o),!0)}#l(t){const e={undoStack:this.undoStack,redoStack:this.redoStack},n="undo"===t?p(e):S(e);n.action&&(this.#a(n.action,t),this.undoStack=n.newState.undoStack,this.redoStack=n.newState.redoStack,this.emit(t,{action:n.action,type:t}),this.#c(n.action),this.requestRenderWithFocus())}#d(t){return t instanceof Element&&!!t.closest('input, textarea, [contenteditable=""], [contenteditable="true"]')}#u(t,e){const n="undo"===e?"historyUndo":"historyRedo";let o=!1;const r=t=>{t.inputType===n&&(o=!0)};t.addEventListener("beforeinput",r,{capture:!0}),queueMicrotask(()=>{t.removeEventListener("beforeinput",r,{capture:!0}),o||this.#l(e)})}recordEdit(t,e,n,o){const r=function(t,e,n,o){return{type:"cell-edit",rowIndex:t,field:e,oldValue:n,newValue:o,timestamp:Date.now()}}(t,e,n,o);if(this.#o)return void this.#o.push(r);const i=g({undoStack:this.undoStack,redoStack:this.redoStack},r,this.config.maxHistorySize??100);this.undoStack=i.undoStack,this.redoStack=i.redoStack}beginTransaction(){0===this.#r&&(this.#o=[]),this.#r++}endTransaction(){if(0===this.#r&&function(t,e,o,r){throw new Error(n(t,e,o,r))}("TBW112","No transaction in progress. Call beginTransaction() first."),this.#r--,this.#r>0)return;const t=this.#o;if(this.#o=null,!t||0===t.length)return;const e=1===t.length?t[0]:{type:"compound",actions:t,timestamp:Date.now()};const o=g({undoStack:this.undoStack,redoStack:this.redoStack},e,this.config.maxHistorySize??100);this.undoStack=o.undoStack,this.redoStack=o.redoStack}undo(){const t=p({undoStack:this.undoStack,redoStack:this.redoStack});return t.action&&(this.#a(t.action,"undo"),this.undoStack=t.newState.undoStack,this.redoStack=t.newState.redoStack,this.#c(t.action),this.requestRenderWithFocus()),t.action}redo(){const t=S({undoStack:this.undoStack,redoStack:this.redoStack});return t.action&&(this.#a(t.action,"redo"),this.undoStack=t.newState.undoStack,this.redoStack=t.newState.redoStack,this.#c(t.action),this.requestRenderWithFocus()),t.action}canUndo(){return{undoStack:this.undoStack,redoStack:this.redoStack}.undoStack.length>0}canRedo(){return{undoStack:this.undoStack,redoStack:this.redoStack}.redoStack.length>0}clearHistory(){const t={undoStack:[],redoStack:[]};this.undoStack=t.undoStack,this.redoStack=t.redoStack,this.#o=null,this.#r=0}getUndoStack(){return[...this.undoStack]}getRedoStack(){return[...this.redoStack]}};export{m as UndoRedoPlugin};
|
|
1
|
+
var t="editing";function e(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function n(t,n,o,r){return`${e(o,r)} ${t}: ${n}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(t)}`}function o(t){return"__proto__"===t||"constructor"===t||"prototype"===t}var r=/* @__PURE__ */new Map;function i(t,e,n){if(null==t||"object"!=typeof t)return!1;const i=function(t){if(-1===t.indexOf("."))return null;let e=r.get(t);return void 0===e&&(e=Object.freeze(t.split(".")),r.set(t,e)),e}(e),s=t;return null===i?!o(e)&&(s[e]=n,!0):Object.prototype.hasOwnProperty.call(s,e)?(s[e]=n,!0):function(t,e,n){if(null==t||"object"!=typeof t)return!1;let r=t;for(let s=0;s<e.length-1;s++){const t=e[s];if(o(t))return!1;const n=r[t];if(null==n||"object"!=typeof n)return!1;r=n}const i=e[e.length-1];return!o(i)&&(r[i]=n,!0)}(s,i,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(t=>t.split("").reverse().join("")),a=(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|math".split("|"))),c=/^on\w+$/i,d=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),u=/^\s*(javascript|vbscript|data|blob):/i;function l(t){const e=document.createElement("template");return t&&"string"==typeof t&&(e.innerHTML=t,function(t){const e=[],n=t.querySelectorAll("*");for(const o of n){const t=o.tagName.toLowerCase();if(a.has(t)){e.push(o);continue}if(("svg"===t||"http://www.w3.org/2000/svg"===o.namespaceURI)&&Array.from(o.attributes).some(t=>c.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(o);continue}const n=[];for(const e of o.attributes){const t=e.name.toLowerCase();c.test(t)?n.push(e.name):"is"!==t?(d.has(t)&&u.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&n.push(e.name):n.push(e.name)}n.forEach(t=>o.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content)),e.content}var h={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var f=class{static dependencies;static manifest;aliases;version="3.5.3";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},o={};for(const n of Object.keys(e))o[n]=this;for(const r of t){const t=r.userConfig;for(const[i,s]of Object.entries(t)){if(void 0===s)continue;if(!(i in e)){e[i]=s,o[i]=r;continue}if(e[i]===s)continue;const t=o[i]?.constructor.name??this.constructor.name,a=r.constructor.name,c=n("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(c)}}Object.assign(this.userConfig,e)}refreshUserConfigFrom(t){const e=this.userConfig,n={...t.userConfig};for(const o of Object.keys(e))delete e[o];Object.assign(e,n)}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 n=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(n),n.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)}queryBoolean(t,e=null){const n=this.grid?.query?.(t,e);return Array.isArray(n)?n.some(Boolean):!!n}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{...h,...t}}t(t,e){return this.grid?.effectiveConfig?.locale?.[t]??e}get translate(){return(t,e)=>this.t(t,e)}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(),n=parseInt(e,10);if(!isNaN(n))return n}return 200}setIcon(t,e,n){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const o=this.#e(e,n);var r,i;void 0!==o?"string"==typeof o?(r=t,(i=o)&&"string"==typeof i?-1!==i.indexOf("<")||-1!==i.indexOf("&")?r.replaceChildren(l(i)):r.textContent=i:r.replaceChildren()):o instanceof HTMLElement&&t.replaceChildren(o.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 n=document.createElement("span");n.setAttribute("part","sort-indicator"),n.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(n,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(n,"sortNone"));const o=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return o?t.insertBefore(n,o):t.appendChild(n),n}warn(t,o){void 0!==o?console.warn(n(t,o,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(t,e){throw new Error(n(t,e,this.gridElement.id,this.name))}};function g(t,e,n){const o=[...t.undoStack,e];for(;o.length>n;)o.shift();return{undoStack:o,redoStack:[]}}function p(t){if(0===t.undoStack.length)return{newState:t,action:null};const e=[...t.undoStack],n=e.pop();return n?{newState:{undoStack:e,redoStack:[...t.redoStack,n]},action:n}:{newState:t,action:null}}function S(t){if(0===t.redoStack.length)return{newState:t,action:null};const e=[...t.redoStack],n=e.pop();return n?{newState:{undoStack:[...t.undoStack,n],redoStack:e},action:n}:{newState:t,action:null}}var m=class extends f{static dependencies=[{name:"editing",required:!0,reason:"UndoRedoPlugin tracks cell edit history"}];name="undoRedo";get defaultConfig(){return{maxHistorySize:100}}undoStack=[];redoStack=[];#n=!1;#o=null;#r=0;#i(t,e){const n=this.rows[t.rowIndex];if(n){try{const o=this.grid.getRowId(n);if(o)return void this.grid.updateRow(o,{[t.field]:e},"history")}catch{}i(n,t.field,e)}}#s(e){const n=this.grid,o=n._visibleColumns?.findIndex(t=>t.field===e.field)??-1;if(o<0)return;n._focusRow=e.rowIndex,n._focusCol=o;const r=n.findRenderedRowElement?.(e.rowIndex);if(!r)return;const i=r.querySelector(`.cell[data-col="${o}"]`);i?.classList.contains(t)&&i.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])')?.focus({preventScroll:!0})}#a(t,e){if(this.#n=!0,"compound"===t.type){const n="undo"===e?[...t.actions].reverse():t.actions;for(const t of n)this.#i(t,"undo"===e?t.oldValue:t.newValue)}else this.#i(t,"undo"===e?t.oldValue:t.newValue);this.#n=!1}#c(t){const e="compound"===t.type?t.actions[t.actions.length-1]:t;e&&this.#s(e)}attach(t){super.attach(t),this.on("cell-edit-committed",t=>{this.#n||this.recordEdit(t.rowIndex,t.field,t.oldValue,t.newValue)})}detach(){this.undoStack=[],this.redoStack=[],this.#o=null,this.#r=0}onKeyDown(t){const e=(t.ctrlKey||t.metaKey)&&"z"===t.key&&!t.shiftKey,n=(t.ctrlKey||t.metaKey)&&("y"===t.key||"z"===t.key&&t.shiftKey);if(!e&&!n)return!1;const o=e?"undo":"redo";return this.#d(t.target)?(this.#u(t.target,o),!0):(t.preventDefault(),this.#l(o),!0)}#l(t){const e={undoStack:this.undoStack,redoStack:this.redoStack},n="undo"===t?p(e):S(e);n.action&&(this.#a(n.action,t),this.undoStack=n.newState.undoStack,this.redoStack=n.newState.redoStack,this.emit(t,{action:n.action,type:t}),this.#c(n.action),this.requestRenderWithFocus())}#d(t){return t instanceof Element&&!!t.closest('input, textarea, [contenteditable=""], [contenteditable="true"]')}#u(t,e){const n="undo"===e?"historyUndo":"historyRedo";let o=!1;const r=t=>{t.inputType===n&&(o=!0)};t.addEventListener("beforeinput",r,{capture:!0}),queueMicrotask(()=>{t.removeEventListener("beforeinput",r,{capture:!0}),o||this.#l(e)})}recordEdit(t,e,n,o){const r=function(t,e,n,o){return{type:"cell-edit",rowIndex:t,field:e,oldValue:n,newValue:o,timestamp:Date.now()}}(t,e,n,o);if(this.#o)return void this.#o.push(r);const i=g({undoStack:this.undoStack,redoStack:this.redoStack},r,this.config.maxHistorySize??100);this.undoStack=i.undoStack,this.redoStack=i.redoStack}beginTransaction(){0===this.#r&&(this.#o=[]),this.#r++}endTransaction(){if(0===this.#r&&function(t,e,o,r){throw new Error(n(t,e,o,r))}("TBW112","No transaction in progress. Call beginTransaction() first."),this.#r--,this.#r>0)return;const t=this.#o;if(this.#o=null,!t||0===t.length)return;const e=1===t.length?t[0]:{type:"compound",actions:t,timestamp:Date.now()};const o=g({undoStack:this.undoStack,redoStack:this.redoStack},e,this.config.maxHistorySize??100);this.undoStack=o.undoStack,this.redoStack=o.redoStack}undo(){const t=p({undoStack:this.undoStack,redoStack:this.redoStack});return t.action&&(this.#a(t.action,"undo"),this.undoStack=t.newState.undoStack,this.redoStack=t.newState.redoStack,this.#c(t.action),this.requestRenderWithFocus()),t.action}redo(){const t=S({undoStack:this.undoStack,redoStack:this.redoStack});return t.action&&(this.#a(t.action,"redo"),this.undoStack=t.newState.undoStack,this.redoStack=t.newState.redoStack,this.#c(t.action),this.requestRenderWithFocus()),t.action}canUndo(){return{undoStack:this.undoStack,redoStack:this.redoStack}.undoStack.length>0}canRedo(){return{undoStack:this.undoStack,redoStack:this.redoStack}.redoStack.length>0}clearHistory(){const t={undoStack:[],redoStack:[]};this.undoStack=t.undoStack,this.redoStack=t.redoStack,this.#o=null,this.#r=0}getUndoStack(){return[...this.undoStack]}getRedoStack(){return[...this.redoStack]}};export{m as UndoRedoPlugin};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|