@toolbox-web/grid 3.0.0-beta.2 → 3.0.0-beta.4
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/custom-elements.json +7 -6
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/core/constants.d.ts +7 -0
- package/lib/core/grid.d.ts +5 -1
- package/lib/core/internal/rows.d.ts +2 -5
- package/lib/core/internal/tag-registry.d.ts +23 -0
- package/lib/features/registry.js +1 -1
- package/lib/plugins/clipboard/clipboard-payload.d.ts +47 -0
- package/lib/plugins/clipboard/copy.d.ts +9 -2
- package/lib/plugins/clipboard/index.js +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +18 -0
- package/lib/plugins/column-virtualization/index.js +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/editing/index.js +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-rows/index.js +1 -1
- package/lib/plugins/grouping-rows/index.js.map +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-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +1 -1
- package/lib/plugins/pivot/index.js +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js +1 -1
- package/lib/plugins/reorder-columns/index.js +1 -1
- package/lib/plugins/reorder-columns/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-drag-drop/index.js +1 -1
- package/lib/plugins/row-drag-drop/index.js.map +1 -1
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/shell/index.js +1 -1
- package/lib/plugins/shell/index.js.map +1 -1
- package/lib/plugins/shell/shell.d.ts +0 -33
- 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/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +1 -1
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -1
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +1 -1
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/shell.umd.js.map +1 -1
- package/lib/plugins/selection/row-selection.d.ts +0 -47
- package/lib/plugins/visibility/visibility.d.ts +0 -31
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const 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))}const s="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${s.slice(3).join("|")}|this\\b`);const i=new Set("script|iframe|object|embed|form|input|button|textarea|select|link|meta|base|style|template|slot|portal|frame|frameset|applet|noscript|noembed|plaintext|xmp|listing".split("|")),a=/^on\w+$/i,d=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),c=/^\s*(javascript|vbscript|data|blob):/i;function h(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],o=e.querySelectorAll("*");for(const n of o){const e=n.tagName.toLowerCase();if(i.has(e)){t.push(n);continue}if("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI){if(Array.from(n.attributes).some(e=>a.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}}const o=[];for(const t of n.attributes){const e=t.name.toLowerCase();a.test(e)?o.push(t.name):(d.has(e)&&c.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}const p={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class u{static dependencies;static manifest;aliases;version="3.0.0-beta.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,s]of Object.entries(e)){if(void 0===s)continue;if(!(l in t)){t[l]=s,o[l]=n;continue}if(t[l]===s)continue;const e=o[l]?.constructor.name??this.constructor.name,i=n.constructor.name,a=r("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${l}" supplied by both ${e} and ${i}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig,o={...e.userConfig};for(const n of Object.keys(t))delete t[n];Object.assign(t,o)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const o=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...p,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(t,10);if(!isNaN(o))return o}return 200}setIcon(e,t,o){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,o);void 0!==n?"string"==typeof n?e.innerHTML=h(n):n instanceof HTMLElement&&(e.innerHTML="",e.appendChild(n.cloneNode(!0))):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(o,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(o,n):e.appendChild(o),o}warn(t,o){void 0!==o?console.warn(r(t,o,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(e,t){throw new Error(r(e,t,this.gridElement.id,this.name))}}const g="tbw-grid-root";function b(e,t){if(t)for(const o in t){const n=t[o];null!=n&&e.setAttribute(o,n)}}function f(e,t,o){const n=document.createElement(e);return b(n,t),n}function w(e,t){const o=document.createElement("div");return e&&(o.className=e),b(o,t),o}function C(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),b(n,t),n}const m=document.createElement("template");function v(){return m.content.cloneNode(!0)}function y(e){const t=document.createDocumentFragment(),o=w(e.hasShell?`${g} has-shell`:g);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=w("tbw-grid-content");e.appendChild(v()),o.appendChild(e)}return t.appendChild(o),t}function P(e){const t=w("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=w("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=w("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=w("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const s of e.configButtons)s.hasRender&&n.appendChild(w("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));for(const s of e.apiButtons)s.hasRender&&n.appendChild(w("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));const r=e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender),l=e.hasPanels&&!1!==e.showToggle;if(r&&l&&n.appendChild(w("tbw-toolbar-separator")),l){const t=C(e.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(e.isPanelOpen),"aria-controls":"tbw-tool-panel"});t.dataset.icon="tool-panel",void 0!==e.toolPanelIcon&&(t.innerHTML=h(e.toolPanelIcon)),n.appendChild(t)}return t.appendChild(n),t}function S(e){const t=e.mode??"overlay",o=w("tbw-shell-body",{"data-mode":t}),n=e.panels.length>0,r=1===e.panels.length,l=w("tbw-grid-content");l.appendChild(v());let s=null;if(n){s=f("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel",..."dropdown"===t?{popover:"manual"}:{}});const o="left"===e.position?"right":"left";s.appendChild(w("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":o,"aria-hidden":"true"}));const n=e=>{const t=C(e?"tbw-tool-panel-close tbw-tool-panel-close--inline":"tbw-tool-panel-close",{part:"tool-panel-close","data-panel-close":"",title:"Close panel","aria-label":"Close panel","aria-controls":"tbw-tool-panel"});return t.textContent="✕",t},l=!0===e.showCloseButton&&r;if(e.showCloseButton&&!r){const e=w("tbw-tool-panel-header",{part:"tool-panel-header"});e.appendChild(n(!1)),s.appendChild(e)}const i=w("tbw-tool-panel-content",{role:"presentation"}),a=w("tbw-accordion");for(const t of e.panels){const o=w(`tbw-accordion-section${t.isExpanded?" expanded":""}${r?" single":""}${l?" has-inline-close":""}`,{"data-section":t.id}),s=C("tbw-accordion-header",{"aria-expanded":String(t.isExpanded),"aria-controls":`tbw-section-${t.id}`});if(r&&s.setAttribute("aria-disabled","true"),t.icon){const e=f("span",{class:"tbw-accordion-icon"});e.innerHTML=h(t.icon),s.appendChild(e)}const i=f("span",{class:"tbw-accordion-title"});if(i.textContent=t.title,s.appendChild(i),!r){const t=f("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=h(e.expandIcon)),s.appendChild(t)}if(l){const e=w("tbw-accordion-header-row");e.appendChild(s),e.appendChild(n(!0)),o.appendChild(e)}else o.appendChild(s);o.appendChild(w("tbw-accordion-content",{id:`tbw-section-${t.id}`,role:"presentation"})),a.appendChild(o)}i.appendChild(a),s.appendChild(i)}return"left"===e.position&&s?(o.appendChild(s),o.appendChild(l)):(o.appendChild(l),s&&o.appendChild(s)),o}function x(e){return e?"string"==typeof e?h(e):e.outerHTML:""}function T(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function O(e){return!1!==e?.header?.visible}function E(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function D(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,n=t.headerContents.size>0;if(!o&&!n)return;const r=e.querySelector(".tbw-shell-content");if(!r)return;if(o){for(const e of t.lightDomHeaderContent)e.style.display="",r.appendChild(e);t.lightDomContentMoved=!0}const l=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of l){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let o=r.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),r.appendChild(o));const n=s.render(o);n&&t.headerContentCleanups.set(s.id,n)}}function _(e,t,o){if(t.isPanelOpen)for(const[n,r]of t.toolPanels){const o=t.expandedSections.has(n),l=e.querySelector(`[data-section="${n}"]`),s=l?.querySelector(".tbw-accordion-content");if(!l||!s)continue;l.classList.toggle("expanded",o);const i=l.querySelector(".tbw-accordion-header");if(i&&i.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=r.render(s);e&&t.panelCleanups.set(n,e)}}else{const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n)),s.innerHTML=""}}}function H(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function L(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}m.innerHTML='\n <div class="tbw-scroll-area">\n <div class="rows-body-wrapper">\n <div class="rows-body" role="grid">\n <div class="header" role="rowgroup">\n <div class="header-row" role="row" part="header-row"></div>\n </div>\n <div class="rows-container" role="presentation">\n <div class="rows-viewport" role="presentation">\n <div class="rows"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class="faux-vscroll">\n <div class="faux-vscroll-spacer"></div>\n </div>\n <div class="tbw-sr-only" aria-live="polite" aria-atomic="true"></div>\n';const R="--tbw-tool-panel-anchor";let A=0;function k(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",R)}function q(e,t,o,n){const r=e.querySelector(".tbw-tool-panel");if(r){if(t.dropdownAnchorEl=o,r.dataset.anchor=n?"corner":"below",r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}if(k()){const e=`${R}-${++A}`;t.dropdownAnchorName=e,o.style.setProperty("anchor-name",e),r.style.setProperty("position-anchor",e),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right")}else!function(e,t,o){const n=t.getBoundingClientRect(),r=e.getAttribute("data-position")??"right";if(e.style.position="fixed",e.style.top=`${Math.round((o?n.top:n.bottom)+4)}px`,"left"===r)e.style.left=`${Math.round(n.left)}px`,e.style.right="auto";else{const t="undefined"!=typeof window?window.innerWidth:0;e.style.left="auto",e.style.right=`${Math.round(t-n.right)}px`}}(r,o,n)}}function I(e){for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear(),e.lightDomContentMoved=!1}function $(e,t,o){const n=void 0!==o?.toolPanel?x(o.toolPanel):void 0,r=void 0!==o?.expand?x(o.expand):void 0,l=void 0!==o?.collapse?x(o.collapse):void 0,s=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),i=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:i.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:n,showToggle:!1!==e.header?.toolPanelToggle&&!0!==e.toolPanel?.locked,configButtons:s.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},bodyOptions:{position:e.toolPanel?.position??"right",mode:e.toolPanel?.mode??"overlay",isPanelOpen:t.isPanelOpen,expandIcon:r,collapseIcon:l,showCloseButton:!1===e.header?.visible&&!0!==e.toolPanel?.locked&&"dropdown"!==(e.toolPanel?.mode??"overlay"),panels:i.map(e=>({id:e.id,title:e.title,icon:x(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function z(e,t,o,n){const r=e.querySelector(`.${g}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=T(t),l=[];for(let s=e.firstChild;s;s=s.nextSibling)1===s.nodeType&&s.classList.contains(g)||l.push(s);e.replaceChildren();for(const s of l)e.appendChild(s);if(r){const{headerOptions:r,bodyOptions:l}=$(t,o,n),s=y({hasShell:!0,shellHeader:O(t)?P(r):void 0,shellBody:S(l)});e.appendChild(s)}else{const t=y({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const s=T(t);if(r.replaceChildren(),s){r.className=`${g} has-shell`;const{headerOptions:e,bodyOptions:s}=$(t,o,n),i=O(t)?P(e):void 0,a=S(s),d=a.querySelector(".tbw-grid-content");d&&d.replaceWith(l),i&&r.appendChild(i),r.appendChild(a)}else r.className=g,r.appendChild(l);return s}function M(e,r){let s=!1;const i={get isInitialized(){return s},setInitialized(e){s=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(o,n){if(0===e.toolPanels.size)return void l("TBW071","No tool panels registered",r.id);let s;if(void 0!==o&&(e.toolPanels.has(o)?s=o:l(t,`Tool panel "${o}" not found`,r.id)),e.isPanelOpen&&s&&e.expandedSections.has(s))return;if(e.isPanelOpen&&s&&!e.expandedSections.has(s))return void i.toggleToolPanelSection(s);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(s)e.expandedSections.add(s);else{const t=r.effectiveConfig?.shell?.toolPanel?.defaultOpen;if(t&&e.toolPanels.has(t))e.expandedSections.add(t);else{const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}}else if(s&&!e.expandedSections.has(s)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(s)}const a=r._renderRoot;if(H(a,e),L(a,e),_(a,e,r._accordionIcons),"dropdown"===r.effectiveConfig?.shell?.toolPanel?.mode){const{el:t,corner:o}=function(e){if(e)return{el:e,corner:!1};const t=r._renderRoot.querySelector("[data-panel-toggle]");return t?{el:t,corner:!1}:{el:r._hostElement,corner:!0}}(n?.anchor);q(a,e,t,o)}r._emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(r.effectiveConfig?.shell?.toolPanel?.locked)return;for(const o of e.panelCleanups.values())o();e.panelCleanups.clear();for(const o of e.toolPanels.values())o.onClose?.();e.isPanelOpen=!1;const t=r._renderRoot;H(t,e),L(t,e),"dropdown"===r.effectiveConfig?.shell?.toolPanel?.mode&&function(e,t){const o=e.querySelector(".tbw-tool-panel");if(o){if(o.hasAttribute("popover")&&"function"==typeof o.hidePopover)try{o.hidePopover()}catch{}o.style.removeProperty("position-anchor"),o.style.removeProperty("position"),o.style.removeProperty("top"),o.style.removeProperty("left"),o.style.removeProperty("right"),delete o.dataset.anchor}t.dropdownAnchorEl&&(t.dropdownAnchorEl.style.removeProperty("anchor-name"),t.dropdownAnchorEl=null),t.dropdownAnchorName=null}(t,e),r._emit("tool-panel-close",{})},toggleToolPanel(t){e.isPanelOpen?i.closeToolPanel():i.openToolPanel(void 0,t)},reanchorOpenDropdown(){if(!e.isPanelOpen)return;if("dropdown"!==r.effectiveConfig?.shell?.toolPanel?.mode)return;const t=e.dropdownAnchorEl;if(t&&t.isConnected&&e.dropdownAnchorName&&t.style.getPropertyValue("anchor-name")===e.dropdownAnchorName)return;if(!e.dropdownAnchorName&&t&&t.isConnected&&t!==r._hostElement){const e=r._renderRoot.querySelector(".tbw-tool-panel");if("below"===e?.dataset.anchor)return}const o=r._renderRoot.querySelector("[data-panel-toggle]");if(o&&o!==r._hostElement){if(e.dropdownAnchorName&&k()&&function(e,t,o){const n=t.dropdownAnchorName;if(!n)return!1;const r=e.querySelector(".tbw-tool-panel");if(!r)return!1;const l=t.dropdownAnchorEl;if(l&&l!==o&&l.style.removeProperty("anchor-name"),o.style.setProperty("anchor-name",n),r.style.setProperty("position-anchor",n),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right"),r.dataset.anchor="below",t.dropdownAnchorEl=o,r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}return!0}(r._renderRoot,e,o))return;q(r._renderRoot,e,o,!1)}else t!==r._hostElement||q(r._renderRoot,e,r._hostElement,!0)},toggleToolPanelSection(o){const n=e.toolPanels.get(o);if(!n)return void l(t,`Tool panel section "${o}" not found`,r.id);if(1===e.toolPanels.size)return;const s=r._renderRoot,i=e.expandedSections.has(o);if(i){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),n.onClose?.(),e.expandedSections.delete(o),B(s,o,!1)}else{for(const[t,n]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),n.onClose?.(),e.expandedSections.delete(t),B(s,t,!1);const r=s.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),B(s,o,!0),function(e,t,o){const n=t.toolPanels.get(o);if(!n?.render)return;const r=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!r)return;const l=n.render(r);l&&t.panelCleanups.set(o,l)}(s,e,o)}r._emit("tool-panel-section-toggle",{id:o,expanded:!i})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(t){e.toolPanels.has(t.id)?l(o,`Tool panel "${t.id}" already registered`,r.id):(e.toolPanels.set(t.id,t),(s||r._hostElement.isConnected)&&r.refreshShellHeader?.())},unregisterToolPanel(t){if(e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),e.expandedSections.delete(t)}e.toolPanels.delete(t),(s||r._hostElement.isConnected)&&r.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(t){e.headerContents.has(t.id)?l(n,`Header content "${t.id}" already registered`,r.id):(e.headerContents.set(t.id,t),s?D(r._renderRoot,e):r._hostElement.isConnected&&r.refreshShellHeader?.())},unregisterHeaderContent(t){const o=e.headerContentCleanups.get(t);o&&(o(),e.headerContentCleanups.delete(t));const n=e.headerContents.get(t);n?.onDestroy?.(),e.headerContents.delete(t);const l=r._renderRoot.querySelector(`[data-header-content="${t}"]`);l?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(t){e.toolbarContents.has(t.id)?l("TBW075",`Toolbar content "${t.id}" already registered`,r.id):(e.toolbarContents.set(t.id,t),(s||r._hostElement.isConnected)&&r.refreshShellHeader?.())},unregisterToolbarContent(t){const o=e.toolbarContentCleanups.get(t);o&&(o(),e.toolbarContentCleanups.delete(t));const n=e.toolbarContents.get(t);n?.onDestroy&&n.onDestroy(),e.toolbarContents.delete(t),s&&r.refreshShellHeader?.()}};return i}function B(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}class N extends u{name="shell";styles="@layer tbw-base{tbw-grid .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}}@layer tbw-base{tbw-grid .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:var(--tbw-z-layer-toolpanel, 31);box-shadow:-2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel{position:relative;inset:auto;flex-shrink:0;box-shadow:none;z-index:auto;border-left:none;border-right:none}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel.open{border-left:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel[data-position=left].open{border-left:none;border-right:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel-resize{display:none}tbw-grid .tbw-tool-panel[popover]{position:fixed;inset:auto;width:var(--tbw-tool-panel-width);max-width:calc(100vw - 16px);height:auto;max-height:min(70vh,480px);overflow:hidden auto;margin:4px 0 0;padding:0;border:1px solid var(--tbw-tool-panel-border);border-radius:var(--tbw-border-radius, 6px);box-shadow:0 8px 24px var(--tbw-color-shadow);transition:none;display:none}tbw-grid .tbw-tool-panel[popover]:popover-open,tbw-grid .tbw-tool-panel[popover].open{display:flex;width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel[popover] .tbw-tool-panel-resize{display:none}@supports (anchor-name: --x){tbw-grid .tbw-tool-panel[popover]{top:anchor(bottom);right:anchor(right);left:auto;position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline}tbw-grid .tbw-tool-panel[popover][data-anchor=corner]{top:anchor(top)}tbw-grid .tbw-tool-panel[popover][data-position=left]{left:anchor(left);right:auto}}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:flex-end;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-accordion-header-row{display:flex;align-items:stretch}tbw-grid .tbw-accordion-header-row .tbw-accordion-header{flex:1;min-width:0}tbw-grid .tbw-tool-panel-close--inline{align-self:center;flex-shrink:0;margin-inline-end:8px}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}}";#o;#n;#r;#l;#s;#i;#a;#d=!1;get hasState(){return void 0!==this.#o}ensureState(e){if(this.#o)return;const t={toolPanels:/* @__PURE__ */new Map,headerContents:/* @__PURE__ */new Map,toolbarContents:/* @__PURE__ */new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:/* @__PURE__ */new Set,adapterBoundToolPanelIds:/* @__PURE__ */new Set,lightDomToolbarContentIds:/* @__PURE__ */new Set,apiToolPanelIds:/* @__PURE__ */new Set,apiHeaderContentIds:/* @__PURE__ */new Set,isPanelOpen:!1,expandedSections:/* @__PURE__ */new Set,headerContentCleanups:/* @__PURE__ */new Map,panelCleanups:/* @__PURE__ */new Map,toolbarContentCleanups:/* @__PURE__ */new Map,lightDomContentMoved:!1,dropdownAnchorEl:null,dropdownAnchorName:null};this.#o=t,this.#n=M(t,e)}get shellState(){return this.#o}get shellController(){return this.#n}get isToolPanelOpen(){return!!this.hasState&&this.shellController.isPanelOpen}get expandedToolPanelSections(){return this.hasState?this.shellController.expandedSections:[]}openToolPanel(e,t){this.shellController?.openToolPanel(e,t)}closeToolPanel(){this.shellController?.closeToolPanel()}toggleToolPanel(e){this.shellController?.toggleToolPanel(e)}toggleToolPanelSection(e){this.shellController?.toggleToolPanelSection(e)}getToolPanels(){return this.hasState?this.shellController.getToolPanels():[]}registerToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.add(e.id),this.shellController.registerToolPanel(e))}unregisterToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.delete(e),this.shellController.unregisterToolPanel(e))}getHeaderContents(){return this.hasState?this.shellController.getHeaderContents():[]}registerHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.add(e.id),this.shellController.registerHeaderContent(e))}unregisterHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.delete(e),this.shellController.unregisterHeaderContent(e))}getToolbarContents(){return this.hasState?this.shellController.getToolbarContents():[]}registerToolbarContent(e){this.shellController?.registerToolbarContent(e)}unregisterToolbarContent(e){this.shellController?.unregisterToolbarContent(e)}attach(e){super.attach(e),this.ensureState(e);const t=()=>this.syncLightDom();this.#i=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#c(e){const t=e._hostElement;!function(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const n=o.querySelectorAll("tbw-grid-header-content");n.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(n)),o.style.display="none"}(t,this.shellState),function(e,t){const o=e.querySelector(":scope > tbw-grid-tool-buttons");if(!o)return;t.hasToolButtonsContainer=!0;const n="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(n))return;const r={id:n,order:0,render:e=>{for(;o.firstChild;)e.appendChild(o.firstChild);return()=>{for(;e.firstChild;)o.appendChild(e.firstChild)}}};t.toolbarContents.set(n,r),t.lightDomToolbarContentIds.add(n),o.style.display="none"}(t,this.shellState),function(e,t,n){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const r=e,s=r.getAttribute("id"),i=r.getAttribute("title");if(!s||!i)return void l("TBW070",`Tool panel missing required id or title attribute: id="${s??""}", title="${i??""}"`);const a=r.getAttribute("icon")??void 0,d=r.getAttribute("tooltip")??void 0,c=parseInt(r.getAttribute("order")??"100",10);let p;const u=n?.(r);if(u)p=u;else{const e=h(r.innerHTML.trim());p=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const g=t.toolPanels.get(s);if(g&&!t.lightDomToolPanelIds.has(s))return l(o,`Tool panel "${s}" is already provided by a plugin or the grid API; ignoring the matching light-DOM <tbw-grid-tool-panel>.`),void(r.style.display="none");if(g){if(u){const e=!t.adapterBoundToolPanelIds.has(s),o=g.order!==c||g.icon!==a||g.tooltip!==d;if(g.render=p,g.order=c,g.icon=a,g.tooltip=d,t.adapterBoundToolPanelIds.add(s),e||o){const e=t.panelCleanups.get(s);e&&(e(),t.panelCleanups.delete(s))}}return}const b={id:s,title:i,icon:a,tooltip:d,order:c,render:p};t.toolPanels.set(s,b),t.lightDomToolPanelIds.add(s),u&&t.adapterBoundToolPanelIds.add(s),r.style.display="none"})}(t,this.shellState,e._getToolPanelRendererFactory())}syncLightDom(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState,o=t.lightDomTitle,n=t.hasToolButtonsContainer;this.#c(e);const r=t.lightDomTitle,l=t.hasToolButtonsContainer;(r&&!o||l&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(I(t),this.afterStructuralRender()))}parseLightDom(){const e=this.grid;e&&this.hasState&&this.#c(e)}beforeStructuralRender(){this.hasState&&I(this.shellState)}needsStructuralRerender(){const e=this.grid;if(!e||!this.hasState)return!1;const t=e._renderRoot,o=!!t.querySelector(".has-shell"),n=!!t.querySelector(".tbw-tool-panel"),r=t.querySelectorAll(".tbw-accordion-section").length,l=t.querySelector(".tbw-tool-panel")?.dataset.position??"right",s=t.querySelector(".tbw-shell-body")?.dataset.mode??"overlay",i=e.effectiveConfig?.shell;return o!==T(i)||!n&&(i?.toolPanels?.length??0)>0||n&&(i?.toolPanels?.length??0)!==r||n&&l!==(i?.toolPanel?.position??"right")||n&&s!==(i?.toolPanel?.mode??"overlay")}#h(e){const t=this.shellState,r=e._hostElement.id;for(const o of[...t.toolPanels.keys()])t.lightDomToolPanelIds.has(o)||t.apiToolPanelIds.has(o)||(t.panelCleanups.get(o)?.(),t.panelCleanups.delete(o),t.toolPanels.delete(o));for(const o of[...t.headerContents.keys()])t.apiHeaderContentIds.has(o)||(t.headerContentCleanups.get(o)?.(),t.headerContentCleanups.delete(o),t.headerContents.delete(o));const{toolPanels:s,headerContents:i}=e._pluginShellContributions();for(const n of s)t.apiToolPanelIds.has(n.id)||(t.lightDomToolPanelIds.has(n.id)&&(l(o,`Tool panel "${n.id}" is provided by a plugin; ignoring the matching light-DOM <tbw-grid-tool-panel>.`,r),t.panelCleanups.get(n.id)?.(),t.panelCleanups.delete(n.id),t.lightDomToolPanelIds.delete(n.id),t.adapterBoundToolPanelIds.delete(n.id)),t.toolPanels.set(n.id,n));for(const o of i)t.apiHeaderContentIds.has(o.id)||(t.headerContents.has(o.id)&&(l(n,`Header content "${o.id}" is provided by a plugin; ignoring the matching light-DOM definition.`,r),t.headerContentCleanups.get(o.id)?.(),t.headerContentCleanups.delete(o.id)),t.headerContents.set(o.id,o))}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.grid;o&&(this.#c(o),this.#h(o));const n=this.resolvedConfig;if(e.shell={...n,...e.shell},e.shell.header={...n.header,...e.shell.header},t.lightDomTitle&&!e.shell.header.title&&(e.shell.header.title=t.lightDomTitle),t.lightDomHeaderContent?.length>0&&(e.shell.header.lightDomContent=t.lightDomHeaderContent),t.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0),t.toolPanels.size>0){const o=Array.from(t.toolPanels.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=o}if(t.headerContents.size>0){const o=Array.from(t.headerContents.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=o}const r=Array.from(t.toolbarContents.values()),l=this.grid?._sourceConfig?.shell?.header?.toolbarContents??[],s=new Set(l.map(e=>e.id)),i=[...l];for(const a of r)s.has(a.id)||i.push(a);i.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=i}afterStructuralRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;z(e._renderRoot,e.effectiveConfig?.shell,{isPanelOpen:t.isPanelOpen,expandedSections:t.expandedSections},e.effectiveConfig?.icons)&&(this.#p(e),this.shellController.setInitialized(!0),this.#u(e))}afterRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;this.#g(e),t.isPanelOpen&&_(e._renderRoot,t),t.isPanelOpen?(this.shellController.reanchorOpenDropdown(),this.#b(e)):this.#f()}#g(e){const t=e._renderRoot.querySelector(".tbw-shell-header");if(!t)return;const o=e.effectiveConfig?.shell?.header?.title??this.shellState.lightDomTitle;let n=t.querySelector(".tbw-shell-title");o?(n||(n=document.createElement("h2"),n.className="tbw-shell-title",n.setAttribute("part","shell-title"),t.insertBefore(n,t.firstChild)),n.textContent=o):n&&n.remove()}#b(e){"dropdown"===e.effectiveConfig?.shell?.toolPanel?.mode?"undefined"!=typeof MutationObserver&&(this.#a||(this.#a=new MutationObserver(()=>{this.grid&&this.hasState&&this.shellState.isPanelOpen?this.shellController.reanchorOpenDropdown():this.#f()})),this.#d||(this.#a.observe(e._renderRoot,{childList:!0,subtree:!0}),this.#d=!0)):this.#f()}#f(){this.#a&&this.#d&&(this.#a.disconnect(),this.#d=!1)}#u(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;D(o,t),function(e,t,o){const n=t?.header?.toolbarContents??[],r=[...o.toolbarContents.values()],l=new Set(n.map(e=>e.id)),s=[...n];for(const i of r)l.has(i.id)||s.push(i);for(const i of s){if(o.toolbarContentCleanups.has(i.id))continue;if(!i.render)continue;const t=e.querySelector(`[data-toolbar-content="${i.id}"]`);if(!t)continue;const n=i.render(t);n&&o.toolbarContentCleanups.set(i.id,n)}}(o,n,t);const r=n?.toolPanel,l=r?.defaultOpen;l&&t.toolPanels.has(l)&&t.expandedSections.add(l);const s=!0===r?.locked||"open"===r?.initialState||void 0===r?.initialState&&void 0!==l&&t.toolPanels.has(l);!t.isPanelOpen&&t.toolPanels.size>0&&s&&this.openToolPanel(),t.isPanelOpen&&(L(o,t),_(o,t,(e.effectiveConfig,e.effectiveConfig)),H(o,t),this.shellController.reanchorOpenDropdown())}#p(e){const t=e._renderRoot,o=e.effectiveConfig?.shell,n=this.shellState;!function(e,t,o,n){const r=e.querySelector(".tbw-shell-toolbar");r&&r.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&n.onPanelToggle()});const l=e.querySelector(".tbw-tool-panel");l&&n.onPanelClose&&l.addEventListener("click",e=>{e.target.closest("[data-panel-close]")&&n.onPanelClose()});const s=e.querySelector(".tbw-accordion");s&&s.addEventListener("click",e=>{const t=e.target.closest(".tbw-accordion-header");if(t){const e=t.closest("[data-section]"),o=e?.getAttribute("data-section");o&&n.onSectionToggle(o)}})}(t,0,0,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onPanelClose:()=>this.closeToolPanel()}),this.#r?.(),this.#r=function(e,t,o){const n=e.querySelector(".tbw-tool-panel"),r=e.querySelector("[data-resize-handle]"),l=e.querySelector(".tbw-shell-body");if(!n||!r||!l)return()=>{};const s=t?.toolPanel?.position??"right";let i=0,a=0,d=0,c=!1;const h=e=>{if(!c)return;e.preventDefault();const t="left"===s?e.clientX-i:i-e.clientX,o=Math.min(d,Math.max(200,a+t));n.style.width=`${o}px`},p=()=>{if(!c)return;c=!1,r.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=n.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)},u=e=>{e.preventDefault(),c=!0,i=e.clientX,a=n.getBoundingClientRect().width,d=l.getBoundingClientRect().width-20,r.classList.add("resizing"),n.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)};return r.addEventListener("mousedown",u),()=>{r.removeEventListener("mousedown",u),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)}}(t,o,t=>{e._hostElement.style.setProperty("--tbw-tool-panel-width",`${t}px`)}),this.#l?.(),this.#l=function(e,t,o,n){const r=t?.toolPanel?.mode;if("dropdown"!==r&&!t?.toolPanel?.closeOnClickOutside)return()=>{};if("push"===r)return()=>{};const l=t=>{if(!o.isPanelOpen)return;const r=o.dropdownAnchorEl;for(const o of t.composedPath()){if(null!=r&&o===r)return;if(o instanceof Element&&(o.classList?.contains("tbw-tool-panel")||o.matches?.("[data-panel-toggle]"))&&E(o,e))return}n()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)}(e._hostElement,o,n,()=>this.closeToolPanel()),this.#s?.(),this.#s=function(e,t,o){if("push"===e?.toolPanel?.mode)return()=>{};const n=e=>{"Escape"!==e.key||e.defaultPrevented||t.isPanelOpen&&o()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}(o,n,()=>this.closeToolPanel())}#w(){this.#r?.(),this.#r=void 0,this.#l?.(),this.#l=void 0,this.#s?.(),this.#s=void 0}detach(){super.detach()}disposeShellState(){this.#w(),this.#f(),this.#a=void 0;const e=this.grid;e&&this.#i&&(e._unregisterLightDomHandler("tbw-grid-header"),e._unregisterLightDomHandler("tbw-grid-tool-buttons"),e._unregisterLightDomHandler("tbw-grid-tool-panel"),this.#i=void 0),this.#o&&(!function(e){for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.toolbarContents.values())t.onDestroy?.();if(e.isPanelOpen)for(const t of e.expandedSections){const o=e.toolPanels.get(t);o?.onClose?.()}e.isPanelOpen=!1,e.expandedSections.clear(),e.toolPanels.clear(),e.headerContents.clear(),e.toolbarContents.clear(),e.lightDomHeaderContent=[],e.lightDomToolPanelIds.clear(),e.adapterBoundToolPanelIds.clear(),e.lightDomToolbarContentIds.clear(),e.lightDomContentMoved=!1}(this.#o),this.#n?.setInitialized(!1))}}export{N as ShellPlugin};
|
|
1
|
+
function e(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const 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))}const s="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${s.slice(3).join("|")}|this\\b`);const i=new Set("script|iframe|object|embed|form|input|button|textarea|select|link|meta|base|style|template|slot|portal|frame|frameset|applet|noscript|noembed|plaintext|xmp|listing".split("|")),a=/^on\w+$/i,d=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),c=/^\s*(javascript|vbscript|data|blob):/i;function h(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],o=e.querySelectorAll("*");for(const n of o){const e=n.tagName.toLowerCase();if(i.has(e)){t.push(n);continue}if("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI){if(Array.from(n.attributes).some(e=>a.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}}const o=[];for(const t of n.attributes){const e=t.name.toLowerCase();a.test(e)?o.push(t.name):(d.has(e)&&c.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}const p={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class u{static dependencies;static manifest;aliases;version="3.0.0-beta.4";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},o={};for(const n of Object.keys(t))o[n]=this;for(const n of e){const e=n.userConfig;for(const[l,s]of Object.entries(e)){if(void 0===s)continue;if(!(l in t)){t[l]=s,o[l]=n;continue}if(t[l]===s)continue;const e=o[l]?.constructor.name??this.constructor.name,i=n.constructor.name,a=r("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${l}" supplied by both ${e} and ${i}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig,o={...e.userConfig};for(const n of Object.keys(t))delete t[n];Object.assign(t,o)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const o=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...p,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(t,10);if(!isNaN(o))return o}return 200}setIcon(e,t,o){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,o);void 0!==n?"string"==typeof n?e.innerHTML=h(n):n instanceof HTMLElement&&(e.innerHTML="",e.appendChild(n.cloneNode(!0))):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(o,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(o,n):e.appendChild(o),o}warn(t,o){void 0!==o?console.warn(r(t,o,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(e,t){throw new Error(r(e,t,this.gridElement.id,this.name))}}const g="tbw-grid-root";function b(e,t){if(t)for(const o in t){const n=t[o];null!=n&&e.setAttribute(o,n)}}function f(e,t,o){const n=document.createElement(e);return b(n,t),n}function w(e,t){const o=document.createElement("div");return e&&(o.className=e),b(o,t),o}function C(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),b(n,t),n}const m=document.createElement("template");function v(){return m.content.cloneNode(!0)}function y(e){const t=document.createDocumentFragment(),o=w(e.hasShell?`${g} has-shell`:g);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=w("tbw-grid-content");e.appendChild(v()),o.appendChild(e)}return t.appendChild(o),t}function P(e){const t=w("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=w("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=w("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=w("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const s of e.configButtons)s.hasRender&&n.appendChild(w("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));for(const s of e.apiButtons)s.hasRender&&n.appendChild(w("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));const r=e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender),l=e.hasPanels&&!1!==e.showToggle;if(r&&l&&n.appendChild(w("tbw-toolbar-separator")),l){const t=C(e.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(e.isPanelOpen),"aria-controls":"tbw-tool-panel"});t.dataset.icon="tool-panel",void 0!==e.toolPanelIcon&&(t.innerHTML=h(e.toolPanelIcon)),n.appendChild(t)}return t.appendChild(n),t}function S(e){const t=e.mode??"overlay",o=w("tbw-shell-body",{"data-mode":t}),n=e.panels.length>0,r=1===e.panels.length,l=w("tbw-grid-content");l.appendChild(v());let s=null;if(n){s=f("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel",..."dropdown"===t?{popover:"manual"}:{}});const o="left"===e.position?"right":"left";s.appendChild(w("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":o,"aria-hidden":"true"}));const n=e=>{const t=C(e?"tbw-tool-panel-close tbw-tool-panel-close--inline":"tbw-tool-panel-close",{part:"tool-panel-close","data-panel-close":"",title:"Close panel","aria-label":"Close panel","aria-controls":"tbw-tool-panel"});return t.textContent="✕",t},l=!0===e.showCloseButton&&r;if(e.showCloseButton&&!r){const e=w("tbw-tool-panel-header",{part:"tool-panel-header"});e.appendChild(n(!1)),s.appendChild(e)}const i=w("tbw-tool-panel-content",{role:"presentation"}),a=w("tbw-accordion");for(const t of e.panels){const o=w(`tbw-accordion-section${t.isExpanded?" expanded":""}${r?" single":""}${l?" has-inline-close":""}`,{"data-section":t.id}),s=C("tbw-accordion-header",{"aria-expanded":String(t.isExpanded),"aria-controls":`tbw-section-${t.id}`});if(r&&s.setAttribute("aria-disabled","true"),t.icon){const e=f("span",{class:"tbw-accordion-icon"});e.innerHTML=h(t.icon),s.appendChild(e)}const i=f("span",{class:"tbw-accordion-title"});if(i.textContent=t.title,s.appendChild(i),!r){const t=f("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=h(e.expandIcon)),s.appendChild(t)}if(l){const e=w("tbw-accordion-header-row");e.appendChild(s),e.appendChild(n(!0)),o.appendChild(e)}else o.appendChild(s);o.appendChild(w("tbw-accordion-content",{id:`tbw-section-${t.id}`,role:"presentation"})),a.appendChild(o)}i.appendChild(a),s.appendChild(i)}return"left"===e.position&&s?(o.appendChild(s),o.appendChild(l)):(o.appendChild(l),s&&o.appendChild(s)),o}function x(e){return e?"string"==typeof e?h(e):e.outerHTML:""}function T(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function O(e){return!1!==e?.header?.visible}function E(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function D(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,n=t.headerContents.size>0;if(!o&&!n)return;const r=e.querySelector(".tbw-shell-content");if(!r)return;if(o){for(const e of t.lightDomHeaderContent)e.style.display="",r.appendChild(e);t.lightDomContentMoved=!0}const l=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of l){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let o=r.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),r.appendChild(o));const n=s.render(o);n&&t.headerContentCleanups.set(s.id,n)}}function _(e,t,o){if(t.isPanelOpen)for(const[n,r]of t.toolPanels){const o=t.expandedSections.has(n),l=e.querySelector(`[data-section="${n}"]`),s=l?.querySelector(".tbw-accordion-content");if(!l||!s)continue;l.classList.toggle("expanded",o);const i=l.querySelector(".tbw-accordion-header");if(i&&i.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=r.render(s);e&&t.panelCleanups.set(n,e)}}else{const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n)),s.innerHTML=""}}}function H(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function L(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}m.innerHTML='\n <div class="tbw-scroll-area">\n <div class="rows-body-wrapper">\n <div class="rows-body" role="grid">\n <div class="header" role="rowgroup">\n <div class="header-row" role="row" part="header-row"></div>\n </div>\n <div class="rows-container" role="presentation">\n <div class="rows-viewport" role="presentation">\n <div class="rows"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class="faux-vscroll">\n <div class="faux-vscroll-spacer"></div>\n </div>\n <div class="tbw-sr-only" aria-live="polite" aria-atomic="true"></div>\n';const R="--tbw-tool-panel-anchor";let A=0;function k(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",R)}function q(e,t,o,n){const r=e.querySelector(".tbw-tool-panel");if(r){if(t.dropdownAnchorEl=o,r.dataset.anchor=n?"corner":"below",r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}if(k()){const e=`${R}-${++A}`;t.dropdownAnchorName=e,o.style.setProperty("anchor-name",e),r.style.setProperty("position-anchor",e),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right")}else!function(e,t,o){const n=t.getBoundingClientRect(),r=e.getAttribute("data-position")??"right";if(e.style.position="fixed",e.style.top=`${Math.round((o?n.top:n.bottom)+4)}px`,"left"===r)e.style.left=`${Math.round(n.left)}px`,e.style.right="auto";else{const t="undefined"!=typeof window?window.innerWidth:0;e.style.left="auto",e.style.right=`${Math.round(t-n.right)}px`}}(r,o,n)}}function I(e){for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear(),e.lightDomContentMoved=!1}function $(e,t,o){const n=void 0!==o?.toolPanel?x(o.toolPanel):void 0,r=void 0!==o?.expand?x(o.expand):void 0,l=void 0!==o?.collapse?x(o.collapse):void 0,s=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),i=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:i.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:n,showToggle:!1!==e.header?.toolPanelToggle&&!0!==e.toolPanel?.locked,configButtons:s.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},bodyOptions:{position:e.toolPanel?.position??"right",mode:e.toolPanel?.mode??"overlay",isPanelOpen:t.isPanelOpen,expandIcon:r,collapseIcon:l,showCloseButton:!1===e.header?.visible&&!0!==e.toolPanel?.locked&&"dropdown"!==(e.toolPanel?.mode??"overlay"),panels:i.map(e=>({id:e.id,title:e.title,icon:x(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function z(e,t,o,n){const r=e.querySelector(`.${g}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=T(t),l=[];for(let s=e.firstChild;s;s=s.nextSibling)1===s.nodeType&&s.classList.contains(g)||l.push(s);e.replaceChildren();for(const s of l)e.appendChild(s);if(r){const{headerOptions:r,bodyOptions:l}=$(t,o,n),s=y({hasShell:!0,shellHeader:O(t)?P(r):void 0,shellBody:S(l)});e.appendChild(s)}else{const t=y({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const s=T(t);if(r.replaceChildren(),s){r.className=`${g} has-shell`;const{headerOptions:e,bodyOptions:s}=$(t,o,n),i=O(t)?P(e):void 0,a=S(s),d=a.querySelector(".tbw-grid-content");d&&d.replaceWith(l),i&&r.appendChild(i),r.appendChild(a)}else r.className=g,r.appendChild(l);return s}function M(e,r){let s=!1;const i={get isInitialized(){return s},setInitialized(e){s=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(o,n){if(0===e.toolPanels.size)return void l("TBW071","No tool panels registered",r.id);let s;if(void 0!==o&&(e.toolPanels.has(o)?s=o:l(t,`Tool panel "${o}" not found`,r.id)),e.isPanelOpen&&s&&e.expandedSections.has(s))return;if(e.isPanelOpen&&s&&!e.expandedSections.has(s))return void i.toggleToolPanelSection(s);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(s)e.expandedSections.add(s);else{const t=r.effectiveConfig?.shell?.toolPanel?.defaultOpen;if(t&&e.toolPanels.has(t))e.expandedSections.add(t);else{const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}}else if(s&&!e.expandedSections.has(s)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(s)}const a=r._renderRoot;if(H(a,e),L(a,e),_(a,e,r._accordionIcons),"dropdown"===r.effectiveConfig?.shell?.toolPanel?.mode){const{el:t,corner:o}=function(e){if(e)return{el:e,corner:!1};const t=r._renderRoot.querySelector("[data-panel-toggle]");return t?{el:t,corner:!1}:{el:r._hostElement,corner:!0}}(n?.anchor);q(a,e,t,o)}r._emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(r.effectiveConfig?.shell?.toolPanel?.locked)return;for(const o of e.panelCleanups.values())o();e.panelCleanups.clear();for(const o of e.toolPanels.values())o.onClose?.();e.isPanelOpen=!1;const t=r._renderRoot;H(t,e),L(t,e),"dropdown"===r.effectiveConfig?.shell?.toolPanel?.mode&&function(e,t){const o=e.querySelector(".tbw-tool-panel");if(o){if(o.hasAttribute("popover")&&"function"==typeof o.hidePopover)try{o.hidePopover()}catch{}o.style.removeProperty("position-anchor"),o.style.removeProperty("position"),o.style.removeProperty("top"),o.style.removeProperty("left"),o.style.removeProperty("right"),delete o.dataset.anchor}t.dropdownAnchorEl&&(t.dropdownAnchorEl.style.removeProperty("anchor-name"),t.dropdownAnchorEl=null),t.dropdownAnchorName=null}(t,e),r._emit("tool-panel-close",{})},toggleToolPanel(t){e.isPanelOpen?i.closeToolPanel():i.openToolPanel(void 0,t)},reanchorOpenDropdown(){if(!e.isPanelOpen)return;if("dropdown"!==r.effectiveConfig?.shell?.toolPanel?.mode)return;const t=e.dropdownAnchorEl;if(t&&t.isConnected&&e.dropdownAnchorName&&t.style.getPropertyValue("anchor-name")===e.dropdownAnchorName)return;if(!e.dropdownAnchorName&&t&&t.isConnected&&t!==r._hostElement){const e=r._renderRoot.querySelector(".tbw-tool-panel");if("below"===e?.dataset.anchor)return}const o=r._renderRoot.querySelector("[data-panel-toggle]");if(o&&o!==r._hostElement){if(e.dropdownAnchorName&&k()&&function(e,t,o){const n=t.dropdownAnchorName;if(!n)return!1;const r=e.querySelector(".tbw-tool-panel");if(!r)return!1;const l=t.dropdownAnchorEl;if(l&&l!==o&&l.style.removeProperty("anchor-name"),o.style.setProperty("anchor-name",n),r.style.setProperty("position-anchor",n),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right"),r.dataset.anchor="below",t.dropdownAnchorEl=o,r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}return!0}(r._renderRoot,e,o))return;q(r._renderRoot,e,o,!1)}else t!==r._hostElement||q(r._renderRoot,e,r._hostElement,!0)},toggleToolPanelSection(o){const n=e.toolPanels.get(o);if(!n)return void l(t,`Tool panel section "${o}" not found`,r.id);if(1===e.toolPanels.size)return;const s=r._renderRoot,i=e.expandedSections.has(o);if(i){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),n.onClose?.(),e.expandedSections.delete(o),B(s,o,!1)}else{for(const[t,n]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),n.onClose?.(),e.expandedSections.delete(t),B(s,t,!1);const r=s.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),B(s,o,!0),function(e,t,o){const n=t.toolPanels.get(o);if(!n?.render)return;const r=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!r)return;const l=n.render(r);l&&t.panelCleanups.set(o,l)}(s,e,o)}r._emit("tool-panel-section-toggle",{id:o,expanded:!i})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(t){e.toolPanels.has(t.id)?l(o,`Tool panel "${t.id}" already registered`,r.id):(e.toolPanels.set(t.id,t),(s||r._hostElement.isConnected)&&r.refreshShellHeader?.())},unregisterToolPanel(t){if(e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),e.expandedSections.delete(t)}e.toolPanels.delete(t),(s||r._hostElement.isConnected)&&r.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(t){e.headerContents.has(t.id)?l(n,`Header content "${t.id}" already registered`,r.id):(e.headerContents.set(t.id,t),s?D(r._renderRoot,e):r._hostElement.isConnected&&r.refreshShellHeader?.())},unregisterHeaderContent(t){const o=e.headerContentCleanups.get(t);o&&(o(),e.headerContentCleanups.delete(t));const n=e.headerContents.get(t);n?.onDestroy?.(),e.headerContents.delete(t);const l=r._renderRoot.querySelector(`[data-header-content="${t}"]`);l?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(t){e.toolbarContents.has(t.id)?l("TBW075",`Toolbar content "${t.id}" already registered`,r.id):(e.toolbarContents.set(t.id,t),(s||r._hostElement.isConnected)&&r.refreshShellHeader?.())},unregisterToolbarContent(t){const o=e.toolbarContentCleanups.get(t);o&&(o(),e.toolbarContentCleanups.delete(t));const n=e.toolbarContents.get(t);n?.onDestroy&&n.onDestroy(),e.toolbarContents.delete(t),s&&r.refreshShellHeader?.()}};return i}function B(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}class N extends u{name="shell";styles="@layer tbw-base{tbw-grid .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}}@layer tbw-base{tbw-grid .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:var(--tbw-z-layer-toolpanel, 31);box-shadow:-2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel{position:relative;inset:auto;flex-shrink:0;box-shadow:none;z-index:auto;border-left:none;border-right:none}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel.open{border-left:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel[data-position=left].open{border-left:none;border-right:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel-resize{display:none}tbw-grid .tbw-tool-panel[popover]{position:fixed;inset:auto;width:var(--tbw-tool-panel-width);max-width:calc(100vw - 16px);height:auto;max-height:min(70vh,480px);overflow:hidden auto;margin:4px 0 0;padding:0;border:1px solid var(--tbw-tool-panel-border);border-radius:var(--tbw-border-radius, 6px);box-shadow:0 8px 24px var(--tbw-color-shadow);transition:none;display:none}tbw-grid .tbw-tool-panel[popover]:popover-open,tbw-grid .tbw-tool-panel[popover].open{display:flex;width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel[popover] .tbw-tool-panel-resize{display:none}@supports (anchor-name: --x){tbw-grid .tbw-tool-panel[popover]{top:anchor(bottom);right:anchor(right);left:auto;position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline}tbw-grid .tbw-tool-panel[popover][data-anchor=corner]{top:anchor(top)}tbw-grid .tbw-tool-panel[popover][data-position=left]{left:anchor(left);right:auto}}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:flex-end;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-accordion-header-row{display:flex;align-items:stretch}tbw-grid .tbw-accordion-header-row .tbw-accordion-header{flex:1;min-width:0}tbw-grid .tbw-tool-panel-close--inline{align-self:center;flex-shrink:0;margin-inline-end:8px}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}}";#o;#n;#r;#l;#s;#i;#a;#d=!1;get hasState(){return void 0!==this.#o}ensureState(e){if(this.#o)return;const t={toolPanels:/* @__PURE__ */new Map,headerContents:/* @__PURE__ */new Map,toolbarContents:/* @__PURE__ */new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:/* @__PURE__ */new Set,adapterBoundToolPanelIds:/* @__PURE__ */new Set,lightDomToolbarContentIds:/* @__PURE__ */new Set,apiToolPanelIds:/* @__PURE__ */new Set,apiHeaderContentIds:/* @__PURE__ */new Set,isPanelOpen:!1,expandedSections:/* @__PURE__ */new Set,headerContentCleanups:/* @__PURE__ */new Map,panelCleanups:/* @__PURE__ */new Map,toolbarContentCleanups:/* @__PURE__ */new Map,lightDomContentMoved:!1,dropdownAnchorEl:null,dropdownAnchorName:null};this.#o=t,this.#n=M(t,e)}get shellState(){return this.#o}get shellController(){return this.#n}get isToolPanelOpen(){return!!this.hasState&&this.shellController.isPanelOpen}get expandedToolPanelSections(){return this.hasState?this.shellController.expandedSections:[]}openToolPanel(e,t){this.shellController?.openToolPanel(e,t)}closeToolPanel(){this.shellController?.closeToolPanel()}toggleToolPanel(e){this.shellController?.toggleToolPanel(e)}toggleToolPanelSection(e){this.shellController?.toggleToolPanelSection(e)}getToolPanels(){return this.hasState?this.shellController.getToolPanels():[]}registerToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.add(e.id),this.shellController.registerToolPanel(e))}unregisterToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.delete(e),this.shellController.unregisterToolPanel(e))}getHeaderContents(){return this.hasState?this.shellController.getHeaderContents():[]}registerHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.add(e.id),this.shellController.registerHeaderContent(e))}unregisterHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.delete(e),this.shellController.unregisterHeaderContent(e))}getToolbarContents(){return this.hasState?this.shellController.getToolbarContents():[]}registerToolbarContent(e){this.shellController?.registerToolbarContent(e)}unregisterToolbarContent(e){this.shellController?.unregisterToolbarContent(e)}attach(e){super.attach(e),this.ensureState(e);const t=()=>this.syncLightDom();this.#i=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#c(e){const t=e._hostElement;!function(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const n=o.querySelectorAll("tbw-grid-header-content");n.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(n)),o.style.display="none"}(t,this.shellState),function(e,t){const o=e.querySelector(":scope > tbw-grid-tool-buttons");if(!o)return;t.hasToolButtonsContainer=!0;const n="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(n))return;const r={id:n,order:0,render:e=>{for(;o.firstChild;)e.appendChild(o.firstChild);return()=>{for(;e.firstChild;)o.appendChild(e.firstChild)}}};t.toolbarContents.set(n,r),t.lightDomToolbarContentIds.add(n),o.style.display="none"}(t,this.shellState),function(e,t,n){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const r=e,s=r.getAttribute("id"),i=r.getAttribute("title");if(!s||!i)return void l("TBW070",`Tool panel missing required id or title attribute: id="${s??""}", title="${i??""}"`);const a=r.getAttribute("icon")??void 0,d=r.getAttribute("tooltip")??void 0,c=parseInt(r.getAttribute("order")??"100",10);let p;const u=n?.(r);if(u)p=u;else{const e=h(r.innerHTML.trim());p=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const g=t.toolPanels.get(s);if(g&&!t.lightDomToolPanelIds.has(s))return l(o,`Tool panel "${s}" is already provided by a plugin or the grid API; ignoring the matching light-DOM <tbw-grid-tool-panel>.`),void(r.style.display="none");if(g){if(u){const e=!t.adapterBoundToolPanelIds.has(s),o=g.order!==c||g.icon!==a||g.tooltip!==d;if(g.render=p,g.order=c,g.icon=a,g.tooltip=d,t.adapterBoundToolPanelIds.add(s),e||o){const e=t.panelCleanups.get(s);e&&(e(),t.panelCleanups.delete(s))}}return}const b={id:s,title:i,icon:a,tooltip:d,order:c,render:p};t.toolPanels.set(s,b),t.lightDomToolPanelIds.add(s),u&&t.adapterBoundToolPanelIds.add(s),r.style.display="none"})}(t,this.shellState,e._getToolPanelRendererFactory())}syncLightDom(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState,o=t.lightDomTitle,n=t.hasToolButtonsContainer;this.#c(e);const r=t.lightDomTitle,l=t.hasToolButtonsContainer;(r&&!o||l&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(I(t),this.afterStructuralRender()))}parseLightDom(){const e=this.grid;e&&this.hasState&&this.#c(e)}beforeStructuralRender(){this.hasState&&I(this.shellState)}needsStructuralRerender(){const e=this.grid;if(!e||!this.hasState)return!1;const t=e._renderRoot,o=!!t.querySelector(".has-shell"),n=!!t.querySelector(".tbw-tool-panel"),r=t.querySelectorAll(".tbw-accordion-section").length,l=t.querySelector(".tbw-tool-panel")?.dataset.position??"right",s=t.querySelector(".tbw-shell-body")?.dataset.mode??"overlay",i=e.effectiveConfig?.shell;return o!==T(i)||!n&&(i?.toolPanels?.length??0)>0||n&&(i?.toolPanels?.length??0)!==r||n&&l!==(i?.toolPanel?.position??"right")||n&&s!==(i?.toolPanel?.mode??"overlay")}#h(e){const t=this.shellState,r=e._hostElement.id;for(const o of[...t.toolPanels.keys()])t.lightDomToolPanelIds.has(o)||t.apiToolPanelIds.has(o)||(t.panelCleanups.get(o)?.(),t.panelCleanups.delete(o),t.toolPanels.delete(o));for(const o of[...t.headerContents.keys()])t.apiHeaderContentIds.has(o)||(t.headerContentCleanups.get(o)?.(),t.headerContentCleanups.delete(o),t.headerContents.delete(o));const{toolPanels:s,headerContents:i}=e._pluginShellContributions();for(const n of s)t.apiToolPanelIds.has(n.id)||(t.lightDomToolPanelIds.has(n.id)&&(l(o,`Tool panel "${n.id}" is provided by a plugin; ignoring the matching light-DOM <tbw-grid-tool-panel>.`,r),t.panelCleanups.get(n.id)?.(),t.panelCleanups.delete(n.id),t.lightDomToolPanelIds.delete(n.id),t.adapterBoundToolPanelIds.delete(n.id)),t.toolPanels.set(n.id,n));for(const o of i)t.apiHeaderContentIds.has(o.id)||(t.headerContents.has(o.id)&&(l(n,`Header content "${o.id}" is provided by a plugin; ignoring the matching light-DOM definition.`,r),t.headerContentCleanups.get(o.id)?.(),t.headerContentCleanups.delete(o.id)),t.headerContents.set(o.id,o))}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.grid;o&&(this.#c(o),this.#h(o));const n=this.resolvedConfig;if(e.shell={...n,...e.shell},e.shell.header={...n.header,...e.shell.header},t.lightDomTitle&&!e.shell.header.title&&(e.shell.header.title=t.lightDomTitle),t.lightDomHeaderContent?.length>0&&(e.shell.header.lightDomContent=t.lightDomHeaderContent),t.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0),t.toolPanels.size>0){const o=Array.from(t.toolPanels.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=o}if(t.headerContents.size>0){const o=Array.from(t.headerContents.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=o}const r=Array.from(t.toolbarContents.values()),l=this.grid?._sourceConfig?.shell?.header?.toolbarContents??[],s=new Set(l.map(e=>e.id)),i=[...l];for(const a of r)s.has(a.id)||i.push(a);i.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=i}afterStructuralRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;z(e._renderRoot,e.effectiveConfig?.shell,{isPanelOpen:t.isPanelOpen,expandedSections:t.expandedSections},e.effectiveConfig?.icons)&&(this.#p(e),this.shellController.setInitialized(!0),this.#u(e))}afterRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;this.#g(e),t.isPanelOpen&&_(e._renderRoot,t),t.isPanelOpen?(this.shellController.reanchorOpenDropdown(),this.#b(e)):this.#f()}#g(e){const t=e._renderRoot.querySelector(".tbw-shell-header");if(!t)return;const o=e.effectiveConfig?.shell?.header?.title??this.shellState.lightDomTitle;let n=t.querySelector(".tbw-shell-title");o?(n||(n=document.createElement("h2"),n.className="tbw-shell-title",n.setAttribute("part","shell-title"),t.insertBefore(n,t.firstChild)),n.textContent=o):n&&n.remove()}#b(e){"dropdown"===e.effectiveConfig?.shell?.toolPanel?.mode?"undefined"!=typeof MutationObserver&&(this.#a||(this.#a=new MutationObserver(()=>{this.grid&&this.hasState&&this.shellState.isPanelOpen?this.shellController.reanchorOpenDropdown():this.#f()})),this.#d||(this.#a.observe(e._renderRoot,{childList:!0,subtree:!0}),this.#d=!0)):this.#f()}#f(){this.#a&&this.#d&&(this.#a.disconnect(),this.#d=!1)}#u(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;D(o,t),function(e,t,o){const n=t?.header?.toolbarContents??[],r=[...o.toolbarContents.values()],l=new Set(n.map(e=>e.id)),s=[...n];for(const i of r)l.has(i.id)||s.push(i);for(const i of s){if(o.toolbarContentCleanups.has(i.id))continue;if(!i.render)continue;const t=e.querySelector(`[data-toolbar-content="${i.id}"]`);if(!t)continue;const n=i.render(t);n&&o.toolbarContentCleanups.set(i.id,n)}}(o,n,t);const r=n?.toolPanel,l=r?.defaultOpen;l&&t.toolPanels.has(l)&&t.expandedSections.add(l);const s=!0===r?.locked||"open"===r?.initialState||void 0===r?.initialState&&void 0!==l&&t.toolPanels.has(l);!t.isPanelOpen&&t.toolPanels.size>0&&s&&this.openToolPanel(),t.isPanelOpen&&(L(o,t),_(o,t,(e.effectiveConfig,e.effectiveConfig)),H(o,t),this.shellController.reanchorOpenDropdown())}#p(e){const t=e._renderRoot,o=e.effectiveConfig?.shell,n=this.shellState;!function(e,t,o,n){const r=e.querySelector(".tbw-shell-toolbar");r&&r.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&n.onPanelToggle()});const l=e.querySelector(".tbw-tool-panel");l&&n.onPanelClose&&l.addEventListener("click",e=>{e.target.closest("[data-panel-close]")&&n.onPanelClose()});const s=e.querySelector(".tbw-accordion");s&&s.addEventListener("click",e=>{const t=e.target.closest(".tbw-accordion-header");if(t){const e=t.closest("[data-section]"),o=e?.getAttribute("data-section");o&&n.onSectionToggle(o)}})}(t,0,0,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onPanelClose:()=>this.closeToolPanel()}),this.#r?.(),this.#r=function(e,t,o){const n=e.querySelector(".tbw-tool-panel"),r=e.querySelector("[data-resize-handle]"),l=e.querySelector(".tbw-shell-body");if(!n||!r||!l)return()=>{};const s=t?.toolPanel?.position??"right";let i=0,a=0,d=0,c=!1;const h=e=>{if(!c)return;e.preventDefault();const t="left"===s?e.clientX-i:i-e.clientX,o=Math.min(d,Math.max(200,a+t));n.style.width=`${o}px`},p=()=>{if(!c)return;c=!1,r.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=n.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)},u=e=>{e.preventDefault(),c=!0,i=e.clientX,a=n.getBoundingClientRect().width,d=l.getBoundingClientRect().width-20,r.classList.add("resizing"),n.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)};return r.addEventListener("mousedown",u),()=>{r.removeEventListener("mousedown",u),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)}}(t,o,t=>{e._hostElement.style.setProperty("--tbw-tool-panel-width",`${t}px`)}),this.#l?.(),this.#l=function(e,t,o,n){const r=t?.toolPanel?.mode;if("dropdown"!==r&&!t?.toolPanel?.closeOnClickOutside)return()=>{};if("push"===r)return()=>{};const l=t=>{if(!o.isPanelOpen)return;const r=o.dropdownAnchorEl;for(const o of t.composedPath()){if(null!=r&&o===r)return;if(o instanceof Element&&(o.classList?.contains("tbw-tool-panel")||o.matches?.("[data-panel-toggle]"))&&E(o,e))return}n()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)}(e._hostElement,o,n,()=>this.closeToolPanel()),this.#s?.(),this.#s=function(e,t,o){if("push"===e?.toolPanel?.mode)return()=>{};const n=e=>{"Escape"!==e.key||e.defaultPrevented||t.isPanelOpen&&o()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}(o,n,()=>this.closeToolPanel())}#w(){this.#r?.(),this.#r=void 0,this.#l?.(),this.#l=void 0,this.#s?.(),this.#s=void 0}detach(){super.detach()}disposeShellState(){this.#w(),this.#f(),this.#a=void 0;const e=this.grid;e&&this.#i&&(e._unregisterLightDomHandler("tbw-grid-header"),e._unregisterLightDomHandler("tbw-grid-tool-buttons"),e._unregisterLightDomHandler("tbw-grid-tool-panel"),this.#i=void 0),this.#o&&(!function(e){for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.toolbarContents.values())t.onDestroy?.();if(e.isPanelOpen)for(const t of e.expandedSections){const o=e.toolPanels.get(t);o?.onClose?.()}e.isPanelOpen=!1,e.expandedSections.clear(),e.toolPanels.clear(),e.headerContents.clear(),e.toolbarContents.clear(),e.lightDomHeaderContent=[],e.lightDomToolPanelIds.clear(),e.adapterBoundToolPanelIds.clear(),e.lightDomToolbarContentIds.clear(),e.lightDomContentMoved=!1}(this.#o),this.#n?.setInitialized(!1))}}export{N as ShellPlugin};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|