@toolbox-web/grid 2.16.0 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/plugins/shell/ShellPlugin.d.ts +26 -0
- package/lib/plugins/shell/index.js +1 -1
- package/lib/plugins/shell/index.js.map +1 -1
- package/lib/plugins/shell/shell-controller.d.ts +20 -0
- package/lib/plugins/shell/shell.d.ts +21 -0
- 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/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("../../core/plugin/base-plugin"),require("../../core/internal/diagnostics"),require("../../core/internal/sanitize"),require("../../core/constants"),require("../../core/internal/dom-builder")):"function"==typeof define&&define.amd?define(["exports","../../core/plugin/base-plugin","../../core/internal/diagnostics","../../core/internal/sanitize","../../core/constants","../../core/internal/dom-builder"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TbwGridPlugin_shell={},e.TbwGrid,e.TbwGrid,e.TbwGrid,e.TbwGrid,e.TbwGrid)}(this,function(e,t,o,n,l,r){"use strict";function i(e){return e?"string"==typeof e?n.sanitizeHTML(e):e.outerHTML:""}function a(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function s(e){return!1!==e?.header?.visible}function d(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const n=o.querySelectorAll("tbw-grid-header-content");n.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(n)),o.style.display="none"}function c(e,t,o){const n=e.querySelector(":scope > tbw-grid-tool-buttons");if(!n)return;t.hasToolButtonsContainer=!0;const l="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(l))return;const r={id:l,order:0,render:e=>{for(;n.firstChild;)e.appendChild(n.firstChild);return()=>{for(;e.firstChild;)n.appendChild(e.firstChild)}}};t.toolbarContents.set(l,r),t.lightDomToolbarContentIds.add(l),n.style.display="none"}function h(e,t,l){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const r=e,i=r.getAttribute("id"),a=r.getAttribute("title");if(!i||!a)return void o.warnDiagnostic(o.TOOL_PANEL_MISSING_ATTR,`Tool panel missing required id or title attribute: id="${i??""}", 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 p=l?.(r);if(p)h=p;else{const e=n.sanitizeHTML(r.innerHTML.trim());h=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const u=t.toolPanels.get(i);if(u&&!t.lightDomToolPanelIds.has(i))return o.warnDiagnostic(o.TOOL_PANEL_DUPLICATE,`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(u){if(p){const e=!t.adapterBoundToolPanelIds.has(i),o=u.order!==c||u.icon!==s||u.tooltip!==d;if(u.render=h,u.order=c,u.icon=s,u.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),p&&t.adapterBoundToolPanelIds.add(i),r.style.display="none"})}function p(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function u(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,n=t.headerContents.size>0;if(!o&&!n)return;const l=e.querySelector(".tbw-shell-content");if(!l)return;if(o){for(const e of t.lightDomHeaderContent)e.style.display="",l.appendChild(e);t.lightDomContentMoved=!0}const r=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const i of r){const e=t.headerContentCleanups.get(i.id);e&&(e(),t.headerContentCleanups.delete(i.id));let o=l.querySelector(`[data-header-content="${i.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",i.id),l.appendChild(o));const n=i.render(o);n&&t.headerContentCleanups.set(i.id,n)}}function g(e,t,o){if(t.isPanelOpen)for(const[n,l]of t.toolPanels){const o=t.expandedSections.has(n),r=e.querySelector(`[data-section="${n}"]`),i=r?.querySelector(".tbw-accordion-content");if(!r||!i)continue;r.classList.toggle("expanded",o);const a=r.querySelector(".tbw-accordion-header");if(a&&a.setAttribute("aria-expanded",String(o)),o){if(0===i.children.length){const e=l.render(i);e&&t.panelCleanups.set(n,e)}}else{const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n)),i.innerHTML=""}}}function b(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function f(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}const w="--tbw-tool-panel-anchor";let C=0;function v(e,t,o,n){const l=e.querySelector(".tbw-tool-panel");if(l){if(t.dropdownAnchorEl=o,l.dataset.anchor=n?"corner":"below",l.hasAttribute("popover")&&"function"==typeof l.showPopover)try{l.showPopover()}catch{}if("undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",w)){const e=`${w}-${++C}`;t.dropdownAnchorName=e,o.style.setProperty("anchor-name",e),l.style.setProperty("position-anchor",e),l.style.removeProperty("top"),l.style.removeProperty("left"),l.style.removeProperty("right")}else!function(e,t,o){const n=t.getBoundingClientRect(),l=e.getAttribute("data-position")??"right";if(e.style.position="fixed",e.style.top=`${Math.round((o?n.top:n.bottom)+4)}px`,"left"===l)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`}}(l,o,n)}}function m(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 P(e,t,o){const n=void 0!==o?.toolPanel?i(o.toolPanel):void 0,l=void 0!==o?.expand?i(o.expand):void 0,r=void 0!==o?.collapse?i(o.collapse):void 0,a=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),s=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:s.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:n,showToggle:!1!==e.header?.toolPanelToggle&&!0!==e.toolPanel?.locked,configButtons:a.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:l,collapseIcon:r,showCloseButton:!1===e.header?.visible&&!0!==e.toolPanel?.locked&&"dropdown"!==(e.toolPanel?.mode??"overlay"),panels:s.map(e=>({id:e.id,title:e.title,icon:i(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function y(e,t,o,n){const i=e.querySelector(`.${l.GridClasses.ROOT}`),d=i?.querySelector(".tbw-grid-content");if(!i||!d)return function(e,t,o,n){const i=a(t),d=[];for(let r=e.firstChild;r;r=r.nextSibling)1===r.nodeType&&r.classList.contains(l.GridClasses.ROOT)||d.push(r);e.replaceChildren();for(const l of d)e.appendChild(l);if(i){const{headerOptions:l,bodyOptions:i}=P(t,o,n),a=s(t)?r.buildShellHeader(l):void 0,d=r.buildShellBody(i),c=r.buildGridDOM({hasShell:!0,shellHeader:a,shellBody:d});e.appendChild(c)}else{const t=r.buildGridDOM({hasShell:!1});e.appendChild(t)}return i}(e,t,o,n);d.remove();const c=a(t);if(i.replaceChildren(),c){i.className=`${l.GridClasses.ROOT} has-shell`;const{headerOptions:e,bodyOptions:a}=P(t,o,n),c=s(t)?r.buildShellHeader(e):void 0,h=r.buildShellBody(a),p=h.querySelector(".tbw-grid-content");p&&p.replaceWith(d),c&&i.appendChild(c),i.appendChild(h)}else i.className=l.GridClasses.ROOT,i.appendChild(d);return c}function S(e,t){let n=!1;const l={get isInitialized(){return n},setInitialized(e){n=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(n,r){if(0===e.toolPanels.size)return void o.warnDiagnostic(o.NO_TOOL_PANELS,"No tool panels registered",t.id);let i;if(void 0!==n&&(e.toolPanels.has(n)?i=n:o.warnDiagnostic(o.TOOL_PANEL_NOT_FOUND,`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 l.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 a=t._renderRoot;if(b(a,e),f(a,e),g(a,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);v(a,e,o,n)}t._emit("tool-panel-open",{sections:l.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;b(o,e),f(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?l.closeToolPanel():l.openToolPanel(void 0,t)},toggleToolPanelSection(n){const l=e.toolPanels.get(n);if(!l)return void o.warnDiagnostic(o.TOOL_PANEL_NOT_FOUND,`Tool panel section "${n}" not found`,t.id);if(1===e.toolPanels.size)return;const r=t._renderRoot,i=e.expandedSections.has(n);if(i){const t=e.panelCleanups.get(n);t&&(t(),e.panelCleanups.delete(n)),l.onClose?.(),e.expandedSections.delete(n),x(r,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(r,t,!1);const l=r.querySelector(`[data-section="${t}"] .tbw-accordion-content`);l&&(l.innerHTML="")}e.expandedSections.add(n),x(r,n,!0),function(e,t,o){const n=t.toolPanels.get(o);if(!n?.render)return;const l=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!l)return;const r=n.render(l);r&&t.panelCleanups.set(o,r)}(r,e,n)}t._emit("tool-panel-section-toggle",{id:n,expanded:!i})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(l){e.toolPanels.has(l.id)?o.warnDiagnostic(o.TOOL_PANEL_DUPLICATE,`Tool panel "${l.id}" already registered`,t.id):(e.toolPanels.set(l.id,l),n&&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),n&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(l){e.headerContents.has(l.id)?o.warnDiagnostic(o.HEADER_CONTENT_DUPLICATE,`Header content "${l.id}" already registered`,t.id):(e.headerContents.set(l.id,l),n&&u(t._renderRoot,e))},unregisterHeaderContent(o){const n=e.headerContentCleanups.get(o);n&&(n(),e.headerContentCleanups.delete(o));const l=e.headerContents.get(o);l?.onDestroy?.(),e.headerContents.delete(o);const r=t._renderRoot.querySelector(`[data-header-content="${o}"]`);r?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(l){e.toolbarContents.has(l.id)?o.warnDiagnostic(o.TOOLBAR_CONTENT_DUPLICATE,`Toolbar content "${l.id}" already registered`,t.id):(e.toolbarContents.set(l.id,l),n&&t.refreshShellHeader?.())},unregisterToolbarContent(o){const l=e.toolbarContentCleanups.get(o);l&&(l(),e.toolbarContentCleanups.delete(o));const r=e.toolbarContents.get(o);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(o),n&&t.refreshShellHeader?.()}};return l}function x(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}class T extends t.BaseGridPlugin{name="shell";styles="@layer tbw-base{tbw-grid .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden;touch-action:none}}@layer tbw-base{tbw-grid .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:var(--tbw-z-layer-toolpanel, 31);box-shadow:-2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel{position:relative;inset:auto;flex-shrink:0;box-shadow:none;z-index:auto;border-left:none;border-right:none}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel.open{border-left:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel[data-position=left].open{border-left:none;border-right:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel-resize{display:none}tbw-grid .tbw-tool-panel[popover]{position:fixed;inset:auto;width:var(--tbw-tool-panel-width);max-width:calc(100vw - 16px);height:auto;max-height:min(70vh,480px);overflow:hidden auto;margin:4px 0 0;padding:0;border:1px solid var(--tbw-tool-panel-border);border-radius:var(--tbw-border-radius, 6px);box-shadow:0 8px 24px var(--tbw-color-shadow);transition:none;display:none}tbw-grid .tbw-tool-panel[popover]:popover-open,tbw-grid .tbw-tool-panel[popover].open{display:flex;width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel[popover] .tbw-tool-panel-resize{display:none}@supports (anchor-name: --x){tbw-grid .tbw-tool-panel[popover]{top:anchor(bottom);right:anchor(right);left:auto;position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline}tbw-grid .tbw-tool-panel[popover][data-anchor=corner]{top:anchor(top)}tbw-grid .tbw-tool-panel[popover][data-position=left]{left:anchor(left);right:auto}}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:flex-end;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-accordion-header-row{display:flex;align-items:stretch}tbw-grid .tbw-accordion-header-row .tbw-accordion-header{flex:1;min-width:0}tbw-grid .tbw-tool-panel-close--inline{align-self:center;flex-shrink:0;margin-inline-end:8px}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}}";#e;#t;#o;#n;#l;#r;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=S(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);const t=()=>this.#i(e);this.#r=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#a(e){const t=e._hostElement;d(t,this.shellState),c(t,this.shellState),h(t,this.shellState,e._getToolPanelRendererFactory())}#i(e){if(!this.hasState)return;const t=this.shellState,o=t.lightDomTitle,n=t.hasToolButtonsContainer;this.#a(e);const l=t.lightDomTitle,r=t.hasToolButtonsContainer;(l&&!o||r&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(m(t),this.afterStructuralRender()))}_parseLightDomHeader(e){const t=e._hostElement;d(t,this.shellState),c(t,this.shellState)}_parseLightDomToolPanels(e){h(e._hostElement,this.shellState,e._getToolPanelRendererFactory())}_parseLightDomAll(e){this._parseLightDomHeader(e),this._parseLightDomToolPanels(e)}_prepareForRerender(){this.hasState&&m(this.shellState)}_renderOpenPanelContent(e){this.hasState&&g(e._renderRoot,this.shellState)}_shouldRenderHeader(e){return a(e)}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.resolvedConfig;if(e.shell={...o,...e.shell},e.shell.header={...o.header,...e.shell.header},t.lightDomTitle&&!e.shell.header.title&&(e.shell.header.title=t.lightDomTitle),t.lightDomHeaderContent?.length>0&&(e.shell.header.lightDomContent=t.lightDomHeaderContent),t.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0),t.toolPanels.size>0){const o=Array.from(t.toolPanels.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=o}if(t.headerContents.size>0){const o=Array.from(t.headerContents.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=o}const n=Array.from(t.toolbarContents.values()),l=this.grid?._sourceConfig?.shell?.header?.toolbarContents??[],r=new Set(l.map(e=>e.id)),i=[...l];for(const a of n)r.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;y(e._renderRoot,e.effectiveConfig?.shell,{isPanelOpen:t.isPanelOpen,expandedSections:t.expandedSections},e.effectiveConfig?.icons)&&(this.#s(e),this.shellController.setInitialized(!0),this.#d(e))}#d(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;u(o,t),function(e,t,o){const n=t?.header?.toolbarContents??[],l=[...o.toolbarContents.values()],r=new Set(n.map(e=>e.id)),i=[...n];for(const a of l)r.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 l=n?.toolPanel,r=l?.defaultOpen;r&&t.toolPanels.has(r)&&t.expandedSections.add(r);const i=!0===l?.locked||"open"===l?.initialState||void 0===l?.initialState&&void 0!==r&&t.toolPanels.has(r);!t.isPanelOpen&&t.toolPanels.size>0&&i&&this.openToolPanel(),t.isPanelOpen&&(f(o,t),g(o,t,(e.effectiveConfig,e.effectiveConfig)),b(o,t))}#s(e){const t=e._renderRoot,o=e.effectiveConfig?.shell,n=this.shellState;!function(e,t,o,n){const l=e.querySelector(".tbw-shell-toolbar");l&&l.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&n.onPanelToggle()});const r=e.querySelector(".tbw-tool-panel");r&&n.onPanelClose&&r.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]"),o=e?.getAttribute("data-section");o&&n.onSectionToggle(o)}})}(t,0,0,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onPanelClose:()=>this.closeToolPanel()}),this.#o?.(),this.#o=function(e,t,o){const n=e.querySelector(".tbw-tool-panel"),l=e.querySelector("[data-resize-handle]"),r=e.querySelector(".tbw-shell-body");if(!n||!l||!r)return()=>{};const i=t?.toolPanel?.position??"right";let a=0,s=0,d=0,c=!1;const h=e=>{if(!c)return;e.preventDefault();const t="left"===i?e.clientX-a:a-e.clientX,o=Math.min(d,Math.max(200,s+t));n.style.width=`${o}px`},p=()=>{if(!c)return;c=!1,l.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,a=e.clientX,s=n.getBoundingClientRect().width,d=r.getBoundingClientRect().width-20,l.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 l.addEventListener("mousedown",u),()=>{l.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.#n?.(),this.#n=function(e,t,o,n){const l=t?.toolPanel?.mode;if("dropdown"!==l&&!t?.toolPanel?.closeOnClickOutside)return()=>{};if("push"===l)return()=>{};const r=t=>{if(!o.isPanelOpen)return;const l=o.dropdownAnchorEl;for(const o of t.composedPath()){if(null!=l&&o===l)return;if(o instanceof Element&&(o.classList?.contains("tbw-tool-panel")||o.matches?.("[data-panel-toggle]"))&&p(o,e))return}n()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)}(e._hostElement,o,n,()=>this.closeToolPanel()),this.#l?.(),this.#l=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())}#c(){this.#o?.(),this.#o=void 0,this.#n?.(),this.#n=void 0,this.#l?.(),this.#l=void 0}detach(){super.detach()}disposeShellState(){this.#c();const e=this.grid;e&&this.#r&&(e._unregisterLightDomHandler("tbw-grid-header"),e._unregisterLightDomHandler("tbw-grid-tool-buttons"),e._unregisterLightDomHandler("tbw-grid-tool-panel"),this.#r=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){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.#e),this.#t?.setInitialized(!1))}}e.ShellPlugin=T,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("../../core/plugin/base-plugin"),require("../../core/internal/diagnostics"),require("../../core/internal/sanitize"),require("../../core/constants"),require("../../core/internal/dom-builder")):"function"==typeof define&&define.amd?define(["exports","../../core/plugin/base-plugin","../../core/internal/diagnostics","../../core/internal/sanitize","../../core/constants","../../core/internal/dom-builder"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TbwGridPlugin_shell={},e.TbwGrid,e.TbwGrid,e.TbwGrid,e.TbwGrid,e.TbwGrid)}(this,function(e,t,o,n,r,l){"use strict";function i(e){return e?"string"==typeof e?n.sanitizeHTML(e):e.outerHTML:""}function s(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function a(e){return!1!==e?.header?.visible}function d(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const n=o.querySelectorAll("tbw-grid-header-content");n.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(n)),o.style.display="none"}function c(e,t,o){const n=e.querySelector(":scope > tbw-grid-tool-buttons");if(!n)return;t.hasToolButtonsContainer=!0;const r="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(r))return;const l={id:r,order:0,render:e=>{for(;n.firstChild;)e.appendChild(n.firstChild);return()=>{for(;e.firstChild;)n.appendChild(e.firstChild)}}};t.toolbarContents.set(r,l),t.lightDomToolbarContentIds.add(r),n.style.display="none"}function h(e,t,r){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const l=e,i=l.getAttribute("id"),s=l.getAttribute("title");if(!i||!s)return void o.warnDiagnostic(o.TOOL_PANEL_MISSING_ATTR,`Tool panel missing required id or title attribute: id="${i??""}", title="${s??""}"`);const a=l.getAttribute("icon")??void 0,d=l.getAttribute("tooltip")??void 0,c=parseInt(l.getAttribute("order")??"100",10);let h;const p=r?.(l);if(p)h=p;else{const e=n.sanitizeHTML(l.innerHTML.trim());h=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const u=t.toolPanels.get(i);if(u&&!t.lightDomToolPanelIds.has(i))return o.warnDiagnostic(o.TOOL_PANEL_DUPLICATE,`Tool panel "${i}" is already provided by a plugin or the grid API; ignoring the matching light-DOM <tbw-grid-tool-panel>.`),void(l.style.display="none");if(u){if(p){const e=!t.adapterBoundToolPanelIds.has(i),o=u.order!==c||u.icon!==a||u.tooltip!==d;if(u.render=h,u.order=c,u.icon=a,u.tooltip=d,t.adapterBoundToolPanelIds.add(i),e||o){const e=t.panelCleanups.get(i);e&&(e(),t.panelCleanups.delete(i))}}return}const b={id:i,title:s,icon:a,tooltip:d,order:c,render:h};t.toolPanels.set(i,b),t.lightDomToolPanelIds.add(i),p&&t.adapterBoundToolPanelIds.add(i),l.style.display="none"})}function p(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function u(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 b(e,t,o){if(t.isPanelOpen)for(const[n,r]of t.toolPanels){const o=t.expandedSections.has(n),l=e.querySelector(`[data-section="${n}"]`),i=l?.querySelector(".tbw-accordion-content");if(!l||!i)continue;l.classList.toggle("expanded",o);const s=l.querySelector(".tbw-accordion-header");if(s&&s.setAttribute("aria-expanded",String(o)),o){if(0===i.children.length){const e=r.render(i);e&&t.panelCleanups.set(n,e)}}else{const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n)),i.innerHTML=""}}}function g(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function f(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}const w="--tbw-tool-panel-anchor";let C=0;function v(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",w)}function m(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(v()){const e=`${w}-${++C}`;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 y(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 P(e,t,o){const n=void 0!==o?.toolPanel?i(o.toolPanel):void 0,r=void 0!==o?.expand?i(o.expand):void 0,l=void 0!==o?.collapse?i(o.collapse):void 0,s=[...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: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:a.map(e=>({id:e.id,title:e.title,icon:i(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function S(e,t,o,n){const i=e.querySelector(`.${r.GridClasses.ROOT}`),d=i?.querySelector(".tbw-grid-content");if(!i||!d)return function(e,t,o,n){const i=s(t),d=[];for(let l=e.firstChild;l;l=l.nextSibling)1===l.nodeType&&l.classList.contains(r.GridClasses.ROOT)||d.push(l);e.replaceChildren();for(const r of d)e.appendChild(r);if(i){const{headerOptions:r,bodyOptions:i}=P(t,o,n),s=a(t)?l.buildShellHeader(r):void 0,d=l.buildShellBody(i),c=l.buildGridDOM({hasShell:!0,shellHeader:s,shellBody:d});e.appendChild(c)}else{const t=l.buildGridDOM({hasShell:!1});e.appendChild(t)}return i}(e,t,o,n);d.remove();const c=s(t);if(i.replaceChildren(),c){i.className=`${r.GridClasses.ROOT} has-shell`;const{headerOptions:e,bodyOptions:s}=P(t,o,n),c=a(t)?l.buildShellHeader(e):void 0,h=l.buildShellBody(s),p=h.querySelector(".tbw-grid-content");p&&p.replaceWith(d),c&&i.appendChild(c),i.appendChild(h)}else i.className=r.GridClasses.ROOT,i.appendChild(d);return c}function x(e,t){let n=!1;const r={get isInitialized(){return n},setInitialized(e){n=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(n,l){if(0===e.toolPanels.size)return void o.warnDiagnostic(o.NO_TOOL_PANELS,"No tool panels registered",t.id);let i;if(void 0!==n&&(e.toolPanels.has(n)?i=n:o.warnDiagnostic(o.TOOL_PANEL_NOT_FOUND,`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 r.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(g(s,e),f(s,e),b(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}}(l?.anchor);m(s,e,o,n)}t._emit("tool-panel-open",{sections:r.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;g(o,e),f(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?r.closeToolPanel():r.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){const e=t._renderRoot.querySelector(".tbw-tool-panel");if("below"===e?.dataset.anchor)return}const n=t._renderRoot.querySelector("[data-panel-toggle]");if(n&&n!==t._hostElement){if(e.dropdownAnchorName&&v()&&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;m(t._renderRoot,e,n,!1)}else o!==t._hostElement||m(t._renderRoot,e,t._hostElement,!0)},toggleToolPanelSection(n){const r=e.toolPanels.get(n);if(!r)return void o.warnDiagnostic(o.TOOL_PANEL_NOT_FOUND,`Tool panel section "${n}" not found`,t.id);if(1===e.toolPanels.size)return;const l=t._renderRoot,i=e.expandedSections.has(n);if(i){const t=e.panelCleanups.get(n);t&&(t(),e.panelCleanups.delete(n)),r.onClose?.(),e.expandedSections.delete(n),T(l,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),T(l,t,!1);const r=l.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(n),T(l,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)}(l,e,n)}t._emit("tool-panel-section-toggle",{id:n,expanded:!i})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(r){e.toolPanels.has(r.id)?o.warnDiagnostic(o.TOOL_PANEL_DUPLICATE,`Tool panel "${r.id}" already registered`,t.id):(e.toolPanels.set(r.id,r),n&&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),n&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(r){e.headerContents.has(r.id)?o.warnDiagnostic(o.HEADER_CONTENT_DUPLICATE,`Header content "${r.id}" already registered`,t.id):(e.headerContents.set(r.id,r),n&&u(t._renderRoot,e))},unregisterHeaderContent(o){const n=e.headerContentCleanups.get(o);n&&(n(),e.headerContentCleanups.delete(o));const r=e.headerContents.get(o);r?.onDestroy?.(),e.headerContents.delete(o);const l=t._renderRoot.querySelector(`[data-header-content="${o}"]`);l?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(r){e.toolbarContents.has(r.id)?o.warnDiagnostic(o.TOOLBAR_CONTENT_DUPLICATE,`Toolbar content "${r.id}" already registered`,t.id):(e.toolbarContents.set(r.id,r),n&&t.refreshShellHeader?.())},unregisterToolbarContent(o){const r=e.toolbarContentCleanups.get(o);r&&(r(),e.toolbarContentCleanups.delete(o));const l=e.toolbarContents.get(o);l?.onDestroy&&l.onDestroy(),e.toolbarContents.delete(o),n&&t.refreshShellHeader?.()}};return r}function T(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}class O extends t.BaseGridPlugin{name="shell";styles="@layer tbw-base{tbw-grid .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden;touch-action:none}}@layer tbw-base{tbw-grid .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:var(--tbw-z-layer-toolpanel, 31);box-shadow:-2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel{position:relative;inset:auto;flex-shrink:0;box-shadow:none;z-index:auto;border-left:none;border-right:none}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel.open{border-left:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel[data-position=left].open{border-left:none;border-right:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel-resize{display:none}tbw-grid .tbw-tool-panel[popover]{position:fixed;inset:auto;width:var(--tbw-tool-panel-width);max-width:calc(100vw - 16px);height:auto;max-height:min(70vh,480px);overflow:hidden auto;margin:4px 0 0;padding:0;border:1px solid var(--tbw-tool-panel-border);border-radius:var(--tbw-border-radius, 6px);box-shadow:0 8px 24px var(--tbw-color-shadow);transition:none;display:none}tbw-grid .tbw-tool-panel[popover]:popover-open,tbw-grid .tbw-tool-panel[popover].open{display:flex;width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel[popover] .tbw-tool-panel-resize{display:none}@supports (anchor-name: --x){tbw-grid .tbw-tool-panel[popover]{top:anchor(bottom);right:anchor(right);left:auto;position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline}tbw-grid .tbw-tool-panel[popover][data-anchor=corner]{top:anchor(top)}tbw-grid .tbw-tool-panel[popover][data-position=left]{left:anchor(left);right:auto}}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:flex-end;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-accordion-header-row{display:flex;align-items:stretch}tbw-grid .tbw-accordion-header-row .tbw-accordion-header{flex:1;min-width:0}tbw-grid .tbw-tool-panel-close--inline{align-self:center;flex-shrink:0;margin-inline-end:8px}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}}";#e;#t;#o;#n;#r;#l;#i;#s=!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=x(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);const t=()=>this.#a(e);this.#l=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#d(e){const t=e._hostElement;d(t,this.shellState),c(t,this.shellState),h(t,this.shellState,e._getToolPanelRendererFactory())}#a(e){if(!this.hasState)return;const t=this.shellState,o=t.lightDomTitle,n=t.hasToolButtonsContainer;this.#d(e);const r=t.lightDomTitle,l=t.hasToolButtonsContainer;(r&&!o||l&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(y(t),this.afterStructuralRender()))}_parseLightDomHeader(e){const t=e._hostElement;d(t,this.shellState),c(t,this.shellState)}_parseLightDomToolPanels(e){h(e._hostElement,this.shellState,e._getToolPanelRendererFactory())}_parseLightDomAll(e){this._parseLightDomHeader(e),this._parseLightDomToolPanels(e)}_prepareForRerender(){this.hasState&&y(this.shellState)}_renderOpenPanelContent(e){this.hasState&&b(e._renderRoot,this.shellState)}_shouldRenderHeader(e){return s(e)}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.resolvedConfig;if(e.shell={...o,...e.shell},e.shell.header={...o.header,...e.shell.header},t.lightDomTitle&&!e.shell.header.title&&(e.shell.header.title=t.lightDomTitle),t.lightDomHeaderContent?.length>0&&(e.shell.header.lightDomContent=t.lightDomHeaderContent),t.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0),t.toolPanels.size>0){const o=Array.from(t.toolPanels.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=o}if(t.headerContents.size>0){const o=Array.from(t.headerContents.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=o}const n=Array.from(t.toolbarContents.values()),r=this.grid?._sourceConfig?.shell?.header?.toolbarContents??[],l=new Set(r.map(e=>e.id)),i=[...r];for(const s of n)l.has(s.id)||i.push(s);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;S(e._renderRoot,e.effectiveConfig?.shell,{isPanelOpen:t.isPanelOpen,expandedSections:t.expandedSections},e.effectiveConfig?.icons)&&(this.#c(e),this.shellController.setInitialized(!0),this.#h(e))}afterRender(){const e=this.grid;e&&this.hasState&&(this.shellState.isPanelOpen?(this.shellController.reanchorOpenDropdown(),this.#p(e)):this.#u())}#p(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.#u()})),this.#s||(this.#i.observe(e._renderRoot,{childList:!0,subtree:!0}),this.#s=!0)):this.#u()}#u(){this.#i&&this.#s&&(this.#i.disconnect(),this.#s=!1)}#h(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;u(o,t),function(e,t,o){const n=t?.header?.toolbarContents??[],r=[...o.toolbarContents.values()],l=new Set(n.map(e=>e.id)),i=[...n];for(const s of r)l.has(s.id)||i.push(s);for(const s of i){if(o.toolbarContentCleanups.has(s.id))continue;if(!s.render)continue;const t=e.querySelector(`[data-toolbar-content="${s.id}"]`);if(!t)continue;const n=s.render(t);n&&o.toolbarContentCleanups.set(s.id,n)}}(o,n,t);const r=n?.toolPanel,l=r?.defaultOpen;l&&t.toolPanels.has(l)&&t.expandedSections.add(l);const i=!0===r?.locked||"open"===r?.initialState||void 0===r?.initialState&&void 0!==l&&t.toolPanels.has(l);!t.isPanelOpen&&t.toolPanels.size>0&&i&&this.openToolPanel(),t.isPanelOpen&&(f(o,t),b(o,t,(e.effectiveConfig,e.effectiveConfig)),g(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]"),o=e?.getAttribute("data-section");o&&n.onSectionToggle(o)}})}(t,0,0,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onPanelClose:()=>this.closeToolPanel()}),this.#o?.(),this.#o=function(e,t,o){const n=e.querySelector(".tbw-tool-panel"),r=e.querySelector("[data-resize-handle]"),l=e.querySelector(".tbw-shell-body");if(!n||!r||!l)return()=>{};const i=t?.toolPanel?.position??"right";let s=0,a=0,d=0,c=!1;const h=e=>{if(!c)return;e.preventDefault();const t="left"===i?e.clientX-s:s-e.clientX,o=Math.min(d,Math.max(200,a+t));n.style.width=`${o}px`},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,s=e.clientX,a=n.getBoundingClientRect().width,d=l.getBoundingClientRect().width-20,r.classList.add("resizing"),n.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",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.#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]"))&&p(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())}#b(){this.#o?.(),this.#o=void 0,this.#n?.(),this.#n=void 0,this.#r?.(),this.#r=void 0}detach(){super.detach()}disposeShellState(){this.#b(),this.#u(),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){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.#e),this.#t?.setInitialized(!1))}}e.ShellPlugin=O,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=shell.umd.js.map
|