@toolbox-web/grid 3.10.2 → 3.10.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/all.js +2 -2
- package/all.js.map +1 -1
- package/index.js +1 -1
- package/lib/features/registry.js +1 -1
- package/lib/plugins/shell/index.js +1 -1
- package/lib/plugins/shell/index.js.map +1 -1
- package/lib/plugins/shell/types.d.ts +9 -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/plugins/shell.umd.js +1 -1
- package/umd/plugins/shell.umd.js.map +1 -1
package/umd/plugins/shell.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@toolbox-web/grid")):"function"==typeof define&&define.amd?define(["exports","@toolbox-web/grid"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TbwGridPlugin_shell={},e.TbwGrid)}(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var o="TBW072",n="TBW073",r="TBW074";function l(e,t,o,n){console.warn(function(e,t,o,n){return`${function(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}(o,n)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}(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("")),a=(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("|"))),s=/^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 p(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,h(t.content)),t.content}(t)):e.textContent=t:e.replaceChildren()}function h(e){const t=[],o=e.querySelectorAll("*");for(const n of o){const e=n.tagName.toLowerCase();if(a.has(e)){t.push(n);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI)&&Array.from(n.attributes).some(e=>s.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();s.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())}function u(){return"function"==typeof HTMLElement.prototype?.showPopover}function b(e,t){const o=document.createElement("button");return o.type="button",o.className="tbw-size-popover-btn",o.setAttribute("aria-label",e),o.textContent=t,o}function g(e){const t=e.step??16;let o,n=null,r=null,l=null,i=!1,a=!1;const s=new AbortController;function d(){i&&n&&(i=!1,u()&&n.hidePopover(),n.hidden=!0,l?.removeAttribute("data-tbw-size-open"),l=null)}function c(){r&&(r.value=String(Math.round(e.getSize(o))))}function p(t){Number.isFinite(t)&&(e.setSize(o,t),c())}return document.addEventListener("pointerdown",e=>{i&&n&&!e.composedPath().includes(n)&&d()},{capture:!0,signal:s.signal}),document.addEventListener("keydown",e=>{"Escape"===e.key&&d()},{capture:!0,signal:s.signal}),{get element(){return n},open(h,g){if(a)return;o=h,l?.removeAttribute("data-tbw-size-open"),l=g,g.setAttribute("data-tbw-size-open",""),n||(n=function(){const n=document.createElement("div");n.id=e.id,n.className="tbw-size-popover",n.setAttribute("popover","manual"),n.setAttribute("role","group"),n.hidden=!0;const l=b("Narrower","−"),i=b("Wider","+"),a=b("Reset size","Reset"),h=document.createElement("input");return h.type="number",h.className="tbw-size-popover-input",h.min="0",h.step="any",h.setAttribute("aria-label","Size in pixels"),l.addEventListener("click",()=>p(e.getSize(o)-t),{signal:s.signal}),i.addEventListener("click",()=>p(e.getSize(o)+t),{signal:s.signal}),a.addEventListener("click",()=>{e.reset(o),c()},{signal:s.signal}),h.addEventListener("change",()=>p(h.valueAsNumber),{signal:s.signal}),n.addEventListener("focusout",e=>{const t=e.relatedTarget;t instanceof Node&&!n.contains(t)&&d()},{signal:s.signal}),n.append(l,h,i,a),r=h,n}());const f=e.getHost(h)??document.body;n.parentNode!==f&&f.appendChild(n),n.setAttribute("aria-label",e.getLabel(h)),c(),n.hidden=!1,!i&&u()&&n.showPopover(),i=!0,function(e){if(!n)return;const t=e.getBoundingClientRect(),o=n.getBoundingClientRect(),r=(e,t)=>Math.max(4,Math.min(e,t-4)),l=r(t.left+t.width/2-o.width/2,window.innerWidth-o.width),i=t.bottom+6,a=t.top-6-o.height,s=t.height>3*o.height;let d;d=!s&&i+o.height<=window.innerHeight?i:!s&&a>=4?a:r(t.top+t.height/2-o.height/2,window.innerHeight-o.height),n.style.left=`${Math.round(l)}px`,n.style.top=`${Math.round(d)}px`}(g),r?.focus()},close:d,dispose(){a=!0,d(),s.abort(),n?.remove(),n=null,r=null}}}var f="tbw-grid-root";function w(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(w(n,t),o)for(const r of o)null!=r&&("string"==typeof r?n.appendChild(document.createTextNode(r)):n.appendChild(r));return n}function C(e,t){const o=document.createElement("div");return e&&(o.className=e),w(o,t),o}function m(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),w(n,t),o&&("string"==typeof o?n.textContent=o:n.appendChild(o)),n}var y=document.createElement("template");function x(){return y.content.cloneNode(!0)}function P(e){const t=document.createDocumentFragment(),o=C(e.hasShell?`${f} has-shell`:f);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=C("tbw-grid-content");e.appendChild(x()),o.appendChild(e)}return t.appendChild(o),t}function S(e){const t=C("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=C("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=C("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=C("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const i of e.configButtons)i.hasRender&&n.appendChild(C("tbw-toolbar-content-slot",{"data-toolbar-content":i.id}));for(const i of e.apiButtons)i.hasRender&&n.appendChild(C("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(C("tbw-toolbar-separator")),l){const t=m(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&&p(t,e.toolPanelIcon),n.appendChild(t)}return t.appendChild(n),t}function T(e){const t=m(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 O(){const e=C("tbw-tool-panel-header",{part:"tool-panel-header"});return e.appendChild(T(!1)),e}function z(e,t,o,n){const r=!!e.title||!o,l=n&&r,i=C(`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=m("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"});p(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&&p(e,t.expandIcon),n.appendChild(e)}return n}(e,t,o);if(l){const e=C("tbw-accordion-header-row");e.appendChild(n),e.appendChild(T(!0)),i.appendChild(e)}else i.appendChild(n)}else n&&i.appendChild(O());return i.appendChild(C("tbw-accordion-content",{id:`tbw-section-${e.id}`,role:"presentation"})),i}function D(e){const t=e.mode??"overlay",o=C("tbw-shell-body",{"data-mode":t}),n=C("tbw-grid-content");n.appendChild(x());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(C("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":"left"===e.position?"right":"left",role:"button",tabindex:"-1","aria-label":"Tool panel width — drag, or activate to set a width"}));const r=!0===e.showCloseButton&&o;e.showCloseButton&&!o&&n.appendChild(O());const l=C("tbw-tool-panel-content",{role:"presentation"}),i=C("tbw-accordion");for(const a of e.panels)i.appendChild(z(a,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}y.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';function E(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,h(t.content),t.innerHTML}(e):e.outerHTML:""}function k(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function _(e){return!1!==e?.header?.visible}function H(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function L(e,o,n){const r=e.querySelector(".tbw-tool-panel"),l=e.querySelector("[data-resize-handle]"),i=e.querySelector(".tbw-shell-body");if(!r||!l||!i)return()=>{};const a=o?.toolPanel?.position??"right";let s=0,d=0,c=0,p=!1,h=!1,u=null,b=null;const f=()=>i.getBoundingClientRect().width-20,w=e=>{if(!p)return;e.preventDefault(),h=!0;const t="left"===a?e.clientX-s:s-e.clientX,o=Math.min(c,Math.max(200,d+t));r.style.width=`${o}px`},v=e=>{if(p&&(p=!1,u=null,l.classList.remove("resizing"),r.style.transition="",document.body.style.cursor="",document.body.style.userSelect="",e)){const e=r.getBoundingClientRect().width;n(e)}},C=e=>{p||0!==e.button&&"mouse"===e.pointerType||(e.preventDefault(),p=!0,h=!1,s=e.clientX,d=r.getBoundingClientRect().width,c=f(),l.classList.add("resizing"),r.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",u=(0,t.startPointerDrag)(e,l,{onMove:w,onEnd:()=>{const e=!h;v(!e),e&&(b??=g({id:"tbw-tool-panel-width-popover",step:32,getSize:e=>e.getBoundingClientRect().width,setSize:(e,t)=>{const o=Math.min(f(),Math.max(200,t));e.style.width=`${o}px`,n(o)},reset:e=>{e.style.width="",n(e.getBoundingClientRect().width)},getLabel:()=>"Tool panel width",getHost:e=>e.closest("tbw-grid, [data-tbw-grid]")}),b.open(r,l))},onCancel:()=>{r.style.width=`${d}px`,v(!1)}}))};return l.addEventListener("pointerdown",C),()=>{l.removeEventListener("pointerdown",C),u?.(),u=null,b?.dispose(),b=null}}function A(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 R(e,t,o){if(t.isPanelOpen)for(const[n,r]of t.toolPanels){const o=t.expandedSections.has(n),l=e.querySelector(`[data-section="${n}"]`),i=l?.querySelector(".tbw-accordion-content");if(!l||!i)continue;l.classList.toggle("expanded",o);const a=l.querySelector(".tbw-accordion-header");if(a&&a.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 $(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function q(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}var B="--tbw-tool-panel-anchor",I=0;function M(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",B)}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=`${B}-${++I}`;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 W(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 j(e,t,o){const n=void 0!==o?.toolPanel?E(o.toolPanel):void 0,r=void 0!==o?.expand?E(o.expand):void 0,l=void 0!==o?.collapse?E(o.collapse):void 0,i=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),a=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:a.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:a.map(e=>({id:e.id,title:e.title,icon:E(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function G(e,t,o,n){const r=e.querySelector(`.${f}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=k(t),l=[];for(let i=e.firstChild;i;i=i.nextSibling)1===i.nodeType&&i.classList.contains(f)||l.push(i);e.replaceChildren();for(const i of l)e.appendChild(i);if(r){const{headerOptions:r,bodyOptions:l}=j(t,o,n),i=P({hasShell:!0,shellHeader:_(t)?S(r):void 0,shellBody:D(l)});e.appendChild(i)}else{const t=P({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const i=k(t);if(r.replaceChildren(),i){r.className=`${f} has-shell`;const{headerOptions:e,bodyOptions:i}=j(t,o,n),a=_(t)?S(e):void 0,s=D(i),d=s.querySelector(".tbw-grid-content");d&&d.replaceWith(l),a&&r.appendChild(a),r.appendChild(s)}else r.className=f,r.appendChild(l);return i}function F(e,t){let i=!1;const a={get isInitialized(){return i},setInitialized(e){i=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(n,r){if(0===e.toolPanels.size)return void l("TBW071","No tool panels registered",t.id);let i;if(void 0!==n&&(e.toolPanels.has(n)?i=n:l(o,`Tool panel "${n}" not found`,t.id)),e.isPanelOpen&&i&&e.expandedSections.has(i))return;if(e.isPanelOpen&&i&&!e.expandedSections.has(i))return void a.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 o=t.effectiveConfig?.shell?.toolPanel?.defaultOpen;if(o&&e.toolPanels.has(o))e.expandedSections.add(o);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 s=t._renderRoot;if($(s,e),q(s,e),R(s,e,t._accordionIcons),"dropdown"===t.effectiveConfig?.shell?.toolPanel?.mode){const{el:o,corner:n}=function(e){if(e)return{el:e,corner:!1};const o=t._renderRoot.querySelector("[data-panel-toggle]");return o?{el:o,corner:!1}:{el:t._hostElement,corner:!0}}(r?.anchor);N(s,e,o,n)}t._emit("tool-panel-open",{sections:a.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(t.effectiveConfig?.shell?.toolPanel?.locked)return;for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolPanels.values())t.onClose?.();e.isPanelOpen=!1;const o=t._renderRoot;$(o,e),q(o,e),"dropdown"===t.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}(o,e),t._emit("tool-panel-close",{})},toggleToolPanel(t){e.isPanelOpen?a.closeToolPanel():a.openToolPanel(void 0,t)},reanchorOpenDropdown(){if(!e.isPanelOpen)return;if("dropdown"!==t.effectiveConfig?.shell?.toolPanel?.mode)return;const o=e.dropdownAnchorEl;if(o&&o.isConnected&&e.dropdownAnchorName&&o.style.getPropertyValue("anchor-name")===e.dropdownAnchorName)return;if(!e.dropdownAnchorName&&o&&o.isConnected&&o!==t._hostElement&&"below"===t._renderRoot.querySelector(".tbw-tool-panel")?.dataset.anchor)return;const n=t._renderRoot.querySelector("[data-panel-toggle]");if(n&&n!==t._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}(t._renderRoot,e,n))return;N(t._renderRoot,e,n,!1)}else o!==t._hostElement||N(t._renderRoot,e,t._hostElement,!0)},toggleToolPanelSection(n){const r=e.toolPanels.get(n);if(!r)return void l(o,`Tool panel section "${n}" not found`,t.id);if(1===e.toolPanels.size)return;const i=t._renderRoot,a=e.expandedSections.has(n);if(a){const t=e.panelCleanups.get(n);t&&(t(),e.panelCleanups.delete(n)),r.onClose?.(),e.expandedSections.delete(n),X(i,n,!1)}else{for(const[t,o]of e.toolPanels)if(t!==n&&e.expandedSections.has(t)){const n=e.panelCleanups.get(t);n&&(n(),e.panelCleanups.delete(t)),o.onClose?.(),e.expandedSections.delete(t),X(i,t,!1);const r=i.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(n),X(i,n,!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,n)}t._emit("tool-panel-section-toggle",{id:n,expanded:!a})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(o){e.toolPanels.has(o.id)?l(n,`Tool panel "${o.id}" already registered`,t.id):(e.toolPanels.set(o.id,o),(i||t._hostElement.isConnected)&&t.refreshShellHeader?.())},unregisterToolPanel(o){if(e.expandedSections.has(o)){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),e.expandedSections.delete(o)}e.toolPanels.delete(o),(i||t._hostElement.isConnected)&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(o){e.headerContents.has(o.id)?l(r,`Header content "${o.id}" already registered`,t.id):(e.headerContents.set(o.id,o),i?A(t._renderRoot,e):t._hostElement.isConnected&&t.refreshShellHeader?.())},unregisterHeaderContent(o){const n=e.headerContentCleanups.get(o);n&&(n(),e.headerContentCleanups.delete(o)),e.headerContents.get(o)?.onDestroy?.(),e.headerContents.delete(o),t._renderRoot.querySelector(`[data-header-content="${o}"]`)?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(o){e.toolbarContents.has(o.id)?l("TBW075",`Toolbar content "${o.id}" already registered`,t.id):(e.toolbarContents.set(o.id,o),(i||t._hostElement.isConnected)&&t.refreshShellHeader?.())},unregisterToolbarContent(o){const n=e.toolbarContentCleanups.get(o);n&&(n(),e.toolbarContentCleanups.delete(o));const r=e.toolbarContents.get(o);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(o),i&&t.refreshShellHeader?.()}};return a}function X(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}var U=class extends t.BaseGridPlugin{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{overflow-clip-margin:var(--tbw-tool-panel-resize-overhang,12px);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:clip}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:min(var(--tbw-tool-panel-width), 100% - 20px);max-width:calc(100% - 20px)}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{width:calc(var(--tbw-tool-panel-resize-overhang,12px) * 2);cursor:col-resize;z-index:10;touch-action:none;-webkit-user-select:none;user-select:none;background:0 0;position:absolute;top:0;bottom:0}tbw-grid .tbw-tool-panel-resize:before{content:"";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:calc(3px - var(--tbw-tool-panel-resize-overhang,12px))}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]:before{left:calc(var(--tbw-tool-panel-resize-overhang,12px) - 3px)}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:calc(3px - var(--tbw-tool-panel-resize-overhang,12px))}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]:before{right:calc(var(--tbw-tool-panel-resize-overhang,12px) - 3px)}tbw-grid .tbw-tool-panel-resize:hover:before,tbw-grid .tbw-tool-panel-resize.resizing:before,tbw-grid .tbw-tool-panel-resize[data-tbw-size-open]:before{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel:not(.open) .tbw-tool-panel-resize{display:none}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}}';#e;#t;#o;#n;#r;#l;#i;#a=!1;get hasState(){return void 0!==this.#e}ensureState(e){if(this.#e)return;const t={toolPanels:new Map,headerContents:new Map,toolbarContents:new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:new Set,adapterBoundToolPanelIds:new Set,lightDomToolbarContentIds:new Set,apiToolPanelIds:new Set,apiHeaderContentIds:new Set,isPanelOpen:!1,expandedSections:new Set,headerContentCleanups:new Map,panelCleanups:new Map,toolbarContentCleanups:new Map,lightDomContentMoved:!1,dropdownAnchorEl:null,dropdownAnchorName:null};this.#e=t,this.#t=F(t,e)}get shellState(){return this.#e}get shellController(){return this.#t}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.#l=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#s(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,o){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const r=e,i=r.getAttribute("id"),a=r.getAttribute("title")??void 0;if(!i)return void l("TBW070",`Tool panel missing required id attribute: title="${a??""}"`);const s=r.getAttribute("icon")??void 0,d=r.getAttribute("tooltip")??void 0,c=parseInt(r.getAttribute("order")??"100",10);let h;const u=o?.(r);if(u)h=u;else{const e=r.innerHTML.trim();h=t=>{const o=document.createElement("div");return p(o,e),t.appendChild(o),()=>o.remove()}}const b=t.toolPanels.get(i);if(b&&!t.lightDomToolPanelIds.has(i))return l(n,`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(b){if(u){const e=!t.adapterBoundToolPanelIds.has(i),o=b.title!==a||b.order!==c||b.icon!==s||b.tooltip!==d;if(b.render=h,b.title=a,b.order=c,b.icon=s,b.tooltip=d,t.adapterBoundToolPanelIds.add(i),e||o){const e=t.panelCleanups.get(i);e&&(e(),t.panelCleanups.delete(i))}}return}const g={id:i,title:a,icon:s,tooltip:d,order:c,render:h};t.toolPanels.set(i,g),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.#s(e);const r=t.lightDomTitle,l=t.hasToolButtonsContainer;(r&&!o||l&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(W(t),this.afterStructuralRender()))}parseLightDom(){const e=this.grid;e&&this.hasState&&this.#s(e)}beforeStructuralRender(){this.hasState&&W(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",a=e.effectiveConfig?.shell;return o!==k(a)||!n&&(a?.toolPanels?.length??0)>0||n&&(a?.toolPanels?.length??0)!==r||n&&l!==(a?.toolPanel?.position??"right")||n&&i!==(a?.toolPanel?.mode??"overlay")}#d(e){const t=this.shellState,o=e._hostElement.id;for(const n of[...t.toolPanels.keys()])t.lightDomToolPanelIds.has(n)||t.apiToolPanelIds.has(n)||(t.panelCleanups.get(n)?.(),t.panelCleanups.delete(n),t.toolPanels.delete(n));for(const n of[...t.headerContents.keys()])t.apiHeaderContentIds.has(n)||(t.headerContentCleanups.get(n)?.(),t.headerContentCleanups.delete(n),t.headerContents.delete(n));const{toolPanels:i,headerContents:a}=e._pluginShellContributions();for(const r of i)t.apiToolPanelIds.has(r.id)||(t.lightDomToolPanelIds.has(r.id)&&(l(n,`Tool panel "${r.id}" is provided by a plugin; ignoring the matching light-DOM <tbw-grid-tool-panel>.`,o),t.panelCleanups.get(r.id)?.(),t.panelCleanups.delete(r.id),t.lightDomToolPanelIds.delete(r.id),t.adapterBoundToolPanelIds.delete(r.id)),t.toolPanels.set(r.id,r));for(const n of a)t.apiHeaderContentIds.has(n.id)||(t.headerContents.has(n.id)&&(l(r,`Header content "${n.id}" is provided by a plugin; ignoring the matching light-DOM definition.`,o),t.headerContentCleanups.get(n.id)?.(),t.headerContentCleanups.delete(n.id)),t.headerContents.set(n.id,n))}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.grid;o&&(this.#s(o),this.#d(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)),a=[...l];for(const s of r)i.has(s.id)||a.push(s);a.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=a}afterStructuralRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;G(e._renderRoot,e.effectiveConfig?.shell,{isPanelOpen:t.isPanelOpen,expandedSections:t.expandedSections},e.effectiveConfig?.icons)&&(this.#c(e),this.shellController.setInitialized(!0),this.#p(e))}afterRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;this.#h(e),t.isPanelOpen&&R(e._renderRoot,t),t.isPanelOpen?(this.shellController.reanchorOpenDropdown(),this.#u(e)):this.#b()}#h(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()}#u(e){"dropdown"===e.effectiveConfig?.shell?.toolPanel?.mode?"undefined"!=typeof MutationObserver&&(this.#i||(this.#i=new MutationObserver(()=>{this.grid&&this.hasState&&this.shellState.isPanelOpen?this.shellController.reanchorOpenDropdown():this.#b()})),this.#a||(this.#i.observe(e._renderRoot,{childList:!0,subtree:!0}),this.#a=!0)):this.#b()}#b(){this.#i&&this.#a&&(this.#i.disconnect(),this.#a=!1)}#p(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;A(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 a of r)l.has(a.id)||i.push(a);for(const a of i){if(o.toolbarContentCleanups.has(a.id))continue;if(!a.render)continue;const t=e.querySelector(`[data-toolbar-content="${a.id}"]`);if(!t)continue;const n=a.render(t);n&&o.toolbarContentCleanups.set(a.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&&(q(o,t),R(o,t,(e.effectiveConfig,e.effectiveConfig)),$(o,t),this.shellController.reanchorOpenDropdown())}#c(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.#o?.(),this.#o=L(t,o,t=>{e._hostElement.style.setProperty("--tbw-tool-panel-width",`${t}px`)}),this.#n?.(),this.#n=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]"))&&H(o,e))return}n()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)}(e._hostElement,o,n,()=>this.closeToolPanel()),this.#r?.(),this.#r=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())}#g(){this.#o?.(),this.#o=void 0,this.#n?.(),this.#n=void 0,this.#r?.(),this.#r=void 0}detach(){super.detach()}disposeShellState(){this.#g(),this.#b(),this.#i=void 0;const e=this.grid;e&&this.#l&&(e._unregisterLightDomHandler("tbw-grid-header"),e._unregisterLightDomHandler("tbw-grid-tool-buttons"),e._unregisterLightDomHandler("tbw-grid-tool-panel"),this.#l=void 0),this.#e&&(!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.#e),this.#t?.setInitialized(!1))}};e.ShellPlugin=U});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@toolbox-web/grid")):"function"==typeof define&&define.amd?define(["exports","@toolbox-web/grid"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TbwGridPlugin_shell={},e.TbwGrid)}(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var o="TBW072",n="TBW073",r="TBW074";function l(e,t,o,n){console.warn(function(e,t,o,n){return`${function(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}(o,n)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}(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("")),a=(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("|"))),s=/^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 p(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,h(t.content)),t.content}(t)):e.textContent=t:e.replaceChildren()}function h(e){const t=[],o=e.querySelectorAll("*");for(const n of o){const e=n.tagName.toLowerCase();if(a.has(e)){t.push(n);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI)&&Array.from(n.attributes).some(e=>s.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();s.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())}function u(){return"function"==typeof HTMLElement.prototype?.showPopover}function b(e,t){const o=document.createElement("button");return o.type="button",o.className="tbw-size-popover-btn",o.setAttribute("aria-label",e),o.textContent=t,o}function g(e){const t=e.step??16;let o,n=null,r=null,l=null,i=!1,a=!1;const s=new AbortController;function d(){i&&n&&(i=!1,u()&&n.hidePopover(),n.hidden=!0,l?.removeAttribute("data-tbw-size-open"),l=null)}function c(){r&&(r.value=String(Math.round(e.getSize(o))))}function p(t){Number.isFinite(t)&&(e.setSize(o,t),c())}return document.addEventListener("pointerdown",e=>{i&&n&&!e.composedPath().includes(n)&&d()},{capture:!0,signal:s.signal}),document.addEventListener("keydown",e=>{"Escape"===e.key&&d()},{capture:!0,signal:s.signal}),{get element(){return n},open(h,g){if(a)return;o=h,l?.removeAttribute("data-tbw-size-open"),l=g,g.setAttribute("data-tbw-size-open",""),n||(n=function(){const n=document.createElement("div");n.id=e.id,n.className="tbw-size-popover",n.setAttribute("popover","manual"),n.setAttribute("role","group"),n.hidden=!0;const l=b("Narrower","−"),i=b("Wider","+"),a=b("Reset size","Reset"),h=document.createElement("input");return h.type="number",h.className="tbw-size-popover-input",h.min="0",h.step="any",h.setAttribute("aria-label","Size in pixels"),l.addEventListener("click",()=>p(e.getSize(o)-t),{signal:s.signal}),i.addEventListener("click",()=>p(e.getSize(o)+t),{signal:s.signal}),a.addEventListener("click",()=>{e.reset(o),c()},{signal:s.signal}),h.addEventListener("change",()=>p(h.valueAsNumber),{signal:s.signal}),n.addEventListener("focusout",e=>{const t=e.relatedTarget;t instanceof Node&&!n.contains(t)&&d()},{signal:s.signal}),n.append(l,h,i,a),r=h,n}());const f=e.getHost(h)??document.body;n.parentNode!==f&&f.appendChild(n),n.setAttribute("aria-label",e.getLabel(h)),c(),n.hidden=!1,!i&&u()&&n.showPopover(),i=!0,function(e){if(!n)return;const t=e.getBoundingClientRect(),o=n.getBoundingClientRect(),r=(e,t)=>Math.max(4,Math.min(e,t-4)),l=r(t.left+t.width/2-o.width/2,window.innerWidth-o.width),i=t.bottom+6,a=t.top-6-o.height,s=t.height>3*o.height;let d;d=!s&&i+o.height<=window.innerHeight?i:!s&&a>=4?a:r(t.top+t.height/2-o.height/2,window.innerHeight-o.height),n.style.left=`${Math.round(l)}px`,n.style.top=`${Math.round(d)}px`}(g),r?.focus()},close:d,dispose(){a=!0,d(),s.abort(),n?.remove(),n=null,r=null}}}var f="tbw-grid-root";function w(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(w(n,t),o)for(const r of o)null!=r&&("string"==typeof r?n.appendChild(document.createTextNode(r)):n.appendChild(r));return n}function C(e,t){const o=document.createElement("div");return e&&(o.className=e),w(o,t),o}function m(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),w(n,t),o&&("string"==typeof o?n.textContent=o:n.appendChild(o)),n}var y=document.createElement("template");function P(){return y.content.cloneNode(!0)}function x(e){const t=document.createDocumentFragment(),o=C(e.hasShell?`${f} has-shell`:f);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=C("tbw-grid-content");e.appendChild(P()),o.appendChild(e)}return t.appendChild(o),t}function S(e){const t=C("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=C("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=C("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=C("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const i of e.configButtons)i.hasRender&&n.appendChild(C("tbw-toolbar-content-slot",{"data-toolbar-content":i.id}));for(const i of e.apiButtons)i.hasRender&&n.appendChild(C("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(C("tbw-toolbar-separator")),l){const t=m(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&&p(t,e.toolPanelIcon),n.appendChild(t)}return t.appendChild(n),t}function T(e){const t=m(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 O(){const e=C("tbw-tool-panel-header",{part:"tool-panel-header"});return e.appendChild(T(!1)),e}function z(e,t,o,n){const r=!!e.title||!o,l=n&&r,i=C(`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=m("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"});p(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&&p(e,t.expandIcon),n.appendChild(e)}return n}(e,t,o);if(l){const e=C("tbw-accordion-header-row");e.appendChild(n),e.appendChild(T(!0)),i.appendChild(e)}else i.appendChild(n)}else n&&i.appendChild(O());return i.appendChild(C("tbw-accordion-content",{id:`tbw-section-${e.id}`,role:"presentation"})),i}function D(e){const t=e.mode??"overlay",o=C("tbw-shell-body",{"data-mode":t}),n=C("tbw-grid-content");n.appendChild(P());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(C("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":"left"===e.position?"right":"left",role:"button",tabindex:"-1","aria-label":"Tool panel width — drag, or activate to set a width"}));const r=!0===e.showCloseButton&&o;e.showCloseButton&&!o&&n.appendChild(O());const l=C("tbw-tool-panel-content",{role:"presentation"}),i=C("tbw-accordion");for(const a of e.panels)i.appendChild(z(a,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}y.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';function E(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,h(t.content),t.innerHTML}(e):e.outerHTML:""}function _(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function k(e){return!1!==e?.header?.visible}function H(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function L(e,o,n){const r=e.querySelector(".tbw-tool-panel"),l=e.querySelector("[data-resize-handle]"),i=e.querySelector(".tbw-shell-body");if(!r||!l||!i)return()=>{};const a=o?.toolPanel?.position??"right";let s=0,d=0,c=0,p=!1,h=!1,u=null,b=null;const f=()=>i.getBoundingClientRect().width-20,w=e=>{if(!p)return;e.preventDefault(),h=!0;const t="left"===a?e.clientX-s:s-e.clientX,o=Math.min(c,Math.max(200,d+t));r.style.width=`${o}px`},v=e=>{if(p&&(p=!1,u=null,l.classList.remove("resizing"),r.style.transition="",document.body.style.cursor="",document.body.style.userSelect="",e)){const e=r.getBoundingClientRect().width;n(e)}},C=e=>{p||0!==e.button&&"mouse"===e.pointerType||(e.preventDefault(),p=!0,h=!1,s=e.clientX,d=r.getBoundingClientRect().width,c=f(),l.classList.add("resizing"),r.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",u=(0,t.startPointerDrag)(e,l,{onMove:w,onEnd:()=>{const e=!h;v(!e),e&&(b??=g({id:"tbw-tool-panel-width-popover",step:32,getSize:e=>e.getBoundingClientRect().width,setSize:(e,t)=>{const o=Math.min(f(),Math.max(200,t));e.style.width=`${o}px`,n(o)},reset:e=>{e.style.width="",n(e.getBoundingClientRect().width)},getLabel:()=>"Tool panel width",getHost:e=>e.closest("tbw-grid, [data-tbw-grid]")}),b.open(r,l))},onCancel:()=>{r.style.width=`${d}px`,v(!1)}}))};return l.addEventListener("pointerdown",C),()=>{l.removeEventListener("pointerdown",C),u?.(),u=null,b?.dispose(),b=null}}function A(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 R(e,t,o){if(t.isPanelOpen)for(const[n,r]of t.toolPanels){const o=t.expandedSections.has(n),l=e.querySelector(`[data-section="${n}"]`),i=l?.querySelector(".tbw-accordion-content");if(!l||!i)continue;l.classList.toggle("expanded",o);const a=l.querySelector(".tbw-accordion-header");if(a&&a.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 $(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function q(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}var B="--tbw-tool-panel-anchor",I=0;function M(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",B)}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=`${B}-${++I}`;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 W(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 j(e,t,o){const n=void 0!==o?.toolPanel?E(o.toolPanel):void 0,r=void 0!==o?.expand?E(o.expand):void 0,l=void 0!==o?.collapse?E(o.collapse):void 0,i=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),a=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:a.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:a.map(e=>({id:e.id,title:e.title,icon:E(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function F(e,t,o,n){const r=e.querySelector(`.${f}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=_(t),l=[];for(let i=e.firstChild;i;i=i.nextSibling)1===i.nodeType&&i.classList.contains(f)||l.push(i);e.replaceChildren();for(const i of l)e.appendChild(i);if(r){const{headerOptions:r,bodyOptions:l}=j(t,o,n),i=x({hasShell:!0,shellHeader:k(t)?S(r):void 0,shellBody:D(l)});e.appendChild(i)}else{const t=x({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const i=_(t);if(r.replaceChildren(),i){r.className=`${f} has-shell`;const{headerOptions:e,bodyOptions:i}=j(t,o,n),a=k(t)?S(e):void 0,s=D(i),d=s.querySelector(".tbw-grid-content");d&&d.replaceWith(l),a&&r.appendChild(a),r.appendChild(s)}else r.className=f,r.appendChild(l);return i}function G(e,t){let i=!1;const a={get isInitialized(){return i},setInitialized(e){i=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(n,r){if(0===e.toolPanels.size)return void l("TBW071","No tool panels registered",t.id);let i;if(void 0!==n&&(e.toolPanels.has(n)?i=n:l(o,`Tool panel "${n}" not found`,t.id)),e.isPanelOpen&&i&&e.expandedSections.has(i))return;if(e.isPanelOpen&&i&&!e.expandedSections.has(i))return void a.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 o=t.effectiveConfig?.shell?.toolPanel?.defaultOpen;if(o&&e.toolPanels.has(o))e.expandedSections.add(o);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 s=t._renderRoot;if($(s,e),q(s,e),R(s,e,t._accordionIcons),"dropdown"===t.effectiveConfig?.shell?.toolPanel?.mode){const{el:o,corner:n}=function(e){if(e)return{el:e,corner:!1};const o=t._renderRoot.querySelector("[data-panel-toggle]");return o?{el:o,corner:!1}:{el:t._hostElement,corner:!0}}(r?.anchor);N(s,e,o,n)}t._emit("tool-panel-open",{sections:a.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(t.effectiveConfig?.shell?.toolPanel?.locked)return;for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolPanels.values())t.onClose?.();e.isPanelOpen=!1;const o=t._renderRoot;$(o,e),q(o,e),"dropdown"===t.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}(o,e),t._emit("tool-panel-close",{})},toggleToolPanel(t){e.isPanelOpen?a.closeToolPanel():a.openToolPanel(void 0,t)},reanchorOpenDropdown(){if(!e.isPanelOpen)return;if("dropdown"!==t.effectiveConfig?.shell?.toolPanel?.mode)return;const o=e.dropdownAnchorEl;if(o&&o.isConnected&&e.dropdownAnchorName&&o.style.getPropertyValue("anchor-name")===e.dropdownAnchorName)return;if(!e.dropdownAnchorName&&o&&o.isConnected&&o!==t._hostElement&&"below"===t._renderRoot.querySelector(".tbw-tool-panel")?.dataset.anchor)return;const n=t._renderRoot.querySelector("[data-panel-toggle]");if(n&&n!==t._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}(t._renderRoot,e,n))return;N(t._renderRoot,e,n,!1)}else o!==t._hostElement||N(t._renderRoot,e,t._hostElement,!0)},toggleToolPanelSection(n){const r=e.toolPanels.get(n);if(!r)return void l(o,`Tool panel section "${n}" not found`,t.id);if(1===e.toolPanels.size)return;const i=t._renderRoot,a=e.expandedSections.has(n);if(a){const t=e.panelCleanups.get(n);t&&(t(),e.panelCleanups.delete(n)),r.onClose?.(),e.expandedSections.delete(n),X(i,n,!1)}else{for(const[t,o]of e.toolPanels)if(t!==n&&e.expandedSections.has(t)){const n=e.panelCleanups.get(t);n&&(n(),e.panelCleanups.delete(t)),o.onClose?.(),e.expandedSections.delete(t),X(i,t,!1);const r=i.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(n),X(i,n,!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,n)}t._emit("tool-panel-section-toggle",{id:n,expanded:!a})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(o){e.toolPanels.has(o.id)?l(n,`Tool panel "${o.id}" already registered`,t.id):(e.toolPanels.set(o.id,o),(i||t._hostElement.isConnected)&&t.refreshShellHeader?.())},unregisterToolPanel(o){if(e.expandedSections.has(o)){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),e.expandedSections.delete(o)}e.toolPanels.delete(o),(i||t._hostElement.isConnected)&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(o){e.headerContents.has(o.id)?l(r,`Header content "${o.id}" already registered`,t.id):(e.headerContents.set(o.id,o),i?A(t._renderRoot,e):t._hostElement.isConnected&&t.refreshShellHeader?.())},unregisterHeaderContent(o){const n=e.headerContentCleanups.get(o);n&&(n(),e.headerContentCleanups.delete(o)),e.headerContents.get(o)?.onDestroy?.(),e.headerContents.delete(o),t._renderRoot.querySelector(`[data-header-content="${o}"]`)?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(o){e.toolbarContents.has(o.id)?l("TBW075",`Toolbar content "${o.id}" already registered`,t.id):(e.toolbarContents.set(o.id,o),(i||t._hostElement.isConnected)&&t.refreshShellHeader?.())},unregisterToolbarContent(o){const n=e.toolbarContentCleanups.get(o);n&&(n(),e.toolbarContentCleanups.delete(o));const r=e.toolbarContents.get(o);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(o),i&&t.refreshShellHeader?.()}};return a}function X(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}var V=Symbol.for("@toolbox-web/grid:shell-configured-panel-width"),U=class extends t.BaseGridPlugin{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{overflow-clip-margin:var(--tbw-tool-panel-resize-overhang,12px);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:clip}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:min(var(--tbw-tool-panel-width), 100% - 20px);max-width:calc(100% - 20px)}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{width:calc(var(--tbw-tool-panel-resize-overhang,12px) * 2);cursor:col-resize;z-index:10;touch-action:none;-webkit-user-select:none;user-select:none;background:0 0;position:absolute;top:0;bottom:0}tbw-grid .tbw-tool-panel-resize:before{content:"";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:calc(3px - var(--tbw-tool-panel-resize-overhang,12px))}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]:before{left:calc(var(--tbw-tool-panel-resize-overhang,12px) - 3px)}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:calc(3px - var(--tbw-tool-panel-resize-overhang,12px))}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]:before{right:calc(var(--tbw-tool-panel-resize-overhang,12px) - 3px)}tbw-grid .tbw-tool-panel-resize:hover:before,tbw-grid .tbw-tool-panel-resize.resizing:before,tbw-grid .tbw-tool-panel-resize[data-tbw-size-open]:before{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel:not(.open) .tbw-tool-panel-resize{display:none}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}}';#e;#t;#o;#n;#r;#l;#i;#a=!1;get hasState(){return void 0!==this.#e}ensureState(e){if(this.#e)return;const t={toolPanels:new Map,headerContents:new Map,toolbarContents:new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:new Set,adapterBoundToolPanelIds:new Set,lightDomToolbarContentIds:new Set,apiToolPanelIds:new Set,apiHeaderContentIds:new Set,isPanelOpen:!1,expandedSections:new Set,headerContentCleanups:new Map,panelCleanups:new Map,toolbarContentCleanups:new Map,lightDomContentMoved:!1,dropdownAnchorEl:null,dropdownAnchorName:null};this.#e=t,this.#t=G(t,e)}get shellState(){return this.#e}get shellController(){return this.#t}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.#l=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#s(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,o){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const r=e,i=r.getAttribute("id"),a=r.getAttribute("title")??void 0;if(!i)return void l("TBW070",`Tool panel missing required id attribute: title="${a??""}"`);const s=r.getAttribute("icon")??void 0,d=r.getAttribute("tooltip")??void 0,c=parseInt(r.getAttribute("order")??"100",10);let h;const u=o?.(r);if(u)h=u;else{const e=r.innerHTML.trim();h=t=>{const o=document.createElement("div");return p(o,e),t.appendChild(o),()=>o.remove()}}const b=t.toolPanels.get(i);if(b&&!t.lightDomToolPanelIds.has(i))return l(n,`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(b){if(u){const e=!t.adapterBoundToolPanelIds.has(i),o=b.title!==a||b.order!==c||b.icon!==s||b.tooltip!==d;if(b.render=h,b.title=a,b.order=c,b.icon=s,b.tooltip=d,t.adapterBoundToolPanelIds.add(i),e||o){const e=t.panelCleanups.get(i);e&&(e(),t.panelCleanups.delete(i))}}return}const g={id:i,title:a,icon:s,tooltip:d,order:c,render:h};t.toolPanels.set(i,g),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.#s(e);const r=t.lightDomTitle,l=t.hasToolButtonsContainer;(r&&!o||l&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(W(t),this.afterStructuralRender()))}parseLightDom(){const e=this.grid;e&&this.hasState&&this.#s(e)}beforeStructuralRender(){this.hasState&&W(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",a=e.effectiveConfig?.shell;return o!==_(a)||!n&&(a?.toolPanels?.length??0)>0||n&&(a?.toolPanels?.length??0)!==r||n&&l!==(a?.toolPanel?.position??"right")||n&&i!==(a?.toolPanel?.mode??"overlay")}#d(e){const t=this.shellState,o=e._hostElement.id;for(const n of[...t.toolPanels.keys()])t.lightDomToolPanelIds.has(n)||t.apiToolPanelIds.has(n)||(t.panelCleanups.get(n)?.(),t.panelCleanups.delete(n),t.toolPanels.delete(n));for(const n of[...t.headerContents.keys()])t.apiHeaderContentIds.has(n)||(t.headerContentCleanups.get(n)?.(),t.headerContentCleanups.delete(n),t.headerContents.delete(n));const{toolPanels:i,headerContents:a}=e._pluginShellContributions();for(const r of i)t.apiToolPanelIds.has(r.id)||(t.lightDomToolPanelIds.has(r.id)&&(l(n,`Tool panel "${r.id}" is provided by a plugin; ignoring the matching light-DOM <tbw-grid-tool-panel>.`,o),t.panelCleanups.get(r.id)?.(),t.panelCleanups.delete(r.id),t.lightDomToolPanelIds.delete(r.id),t.adapterBoundToolPanelIds.delete(r.id)),t.toolPanels.set(r.id,r));for(const n of a)t.apiHeaderContentIds.has(n.id)||(t.headerContents.has(n.id)&&(l(r,`Header content "${n.id}" is provided by a plugin; ignoring the matching light-DOM definition.`,o),t.headerContentCleanups.get(n.id)?.(),t.headerContentCleanups.delete(n.id)),t.headerContents.set(n.id,n))}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.grid;o&&(this.#s(o),this.#d(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)),a=[...l];for(const s of r)i.has(s.id)||a.push(s);a.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=a,o&&this.#c(o,e.shell.toolPanel?.width)}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.#h(e))}afterRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;this.#u(e),t.isPanelOpen&&R(e._renderRoot,t),t.isPanelOpen?(this.shellController.reanchorOpenDropdown(),this.#b(e)):this.#g()}#u(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()}#c(e,t){const o=e._hostElement,n="number"==typeof t&&Number.isFinite(t)&&t>0?`${t}px`:void 0,r=o[V];if(n===r)return;o[V]=n;const l=o.style;n?(l.setProperty("--tbw-tool-panel-width",n),e._renderRoot.querySelector(".tbw-tool-panel")?.style.removeProperty("width")):l.getPropertyValue("--tbw-tool-panel-width")===r&&l.removeProperty("--tbw-tool-panel-width")}#b(e){"dropdown"===e.effectiveConfig?.shell?.toolPanel?.mode?"undefined"!=typeof MutationObserver&&(this.#i||(this.#i=new MutationObserver(()=>{this.grid&&this.hasState&&this.shellState.isPanelOpen?this.shellController.reanchorOpenDropdown():this.#g()})),this.#a||(this.#i.observe(e._renderRoot,{childList:!0,subtree:!0}),this.#a=!0)):this.#g()}#g(){this.#i&&this.#a&&(this.#i.disconnect(),this.#a=!1)}#h(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;A(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 a of r)l.has(a.id)||i.push(a);for(const a of i){if(o.toolbarContentCleanups.has(a.id))continue;if(!a.render)continue;const t=e.querySelector(`[data-toolbar-content="${a.id}"]`);if(!t)continue;const n=a.render(t);n&&o.toolbarContentCleanups.set(a.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&&(q(o,t),R(o,t,(e.effectiveConfig,e.effectiveConfig)),$(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.#o?.(),this.#o=L(t,o,t=>{e._hostElement.style.setProperty("--tbw-tool-panel-width",`${t}px`)}),this.#n?.(),this.#n=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]"))&&H(o,e))return}n()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)}(e._hostElement,o,n,()=>this.closeToolPanel()),this.#r?.(),this.#r=function(e,t,o){if("push"===e?.toolPanel?.mode)return()=>{};const n=e=>{"Escape"!==e.key||e.defaultPrevented||t.isPanelOpen&&o()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}(o,n,()=>this.closeToolPanel())}#f(){this.#o?.(),this.#o=void 0,this.#n?.(),this.#n=void 0,this.#r?.(),this.#r=void 0}detach(){super.detach()}disposeShellState(){this.#f(),this.#g(),this.#i=void 0;const e=this.grid;e&&this.#l&&(e._unregisterLightDomHandler("tbw-grid-header"),e._unregisterLightDomHandler("tbw-grid-tool-buttons"),e._unregisterLightDomHandler("tbw-grid-tool-panel"),this.#l=void 0),this.#e&&(!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.#e),this.#t?.setInitialized(!1))}};e.ShellPlugin=U});
|
|
2
2
|
//# sourceMappingURL=shell.umd.js.map
|