@toolbox-web/grid 2.13.0 → 2.13.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.
Files changed (43) hide show
  1. package/all.js +1 -1
  2. package/all.js.map +1 -1
  3. package/index.js +1 -1
  4. package/index.js.map +1 -1
  5. package/lib/core/types.d.ts +32 -0
  6. package/lib/plugins/clipboard/index.js.map +1 -1
  7. package/lib/plugins/column-virtualization/index.js.map +1 -1
  8. package/lib/plugins/context-menu/index.js.map +1 -1
  9. package/lib/plugins/editing/index.js.map +1 -1
  10. package/lib/plugins/export/index.js.map +1 -1
  11. package/lib/plugins/filtering/index.js.map +1 -1
  12. package/lib/plugins/grouping-columns/index.js.map +1 -1
  13. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +53 -2
  14. package/lib/plugins/grouping-rows/index.js +2 -2
  15. package/lib/plugins/grouping-rows/index.js.map +1 -1
  16. package/lib/plugins/grouping-rows/types.d.ts +10 -8
  17. package/lib/plugins/master-detail/index.js.map +1 -1
  18. package/lib/plugins/multi-sort/index.js.map +1 -1
  19. package/lib/plugins/pinned-columns/index.js.map +1 -1
  20. package/lib/plugins/pinned-rows/index.js.map +1 -1
  21. package/lib/plugins/pivot/index.js.map +1 -1
  22. package/lib/plugins/print/index.js.map +1 -1
  23. package/lib/plugins/reorder-columns/index.js.map +1 -1
  24. package/lib/plugins/reorder-rows/index.js.map +1 -1
  25. package/lib/plugins/responsive/index.js.map +1 -1
  26. package/lib/plugins/row-drag-drop/index.js.map +1 -1
  27. package/lib/plugins/selection/index.js.map +1 -1
  28. package/lib/plugins/server-side/index.js.map +1 -1
  29. package/lib/plugins/sticky-rows/index.js.map +1 -1
  30. package/lib/plugins/tooltip/index.js +1 -1
  31. package/lib/plugins/tooltip/index.js.map +1 -1
  32. package/lib/plugins/tree/index.js.map +1 -1
  33. package/lib/plugins/undo-redo/index.js.map +1 -1
  34. package/lib/plugins/visibility/index.js.map +1 -1
  35. package/package.json +1 -1
  36. package/umd/grid.all.umd.js +1 -1
  37. package/umd/grid.all.umd.js.map +1 -1
  38. package/umd/grid.umd.js +1 -1
  39. package/umd/grid.umd.js.map +1 -1
  40. package/umd/plugins/grouping-rows.umd.js +1 -1
  41. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  42. package/umd/plugins/tooltip.umd.js +1 -1
  43. package/umd/plugins/tooltip.umd.js.map +1 -1
@@ -1,2 +1,2 @@
1
- function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function e(e,o,r,i){return`${t(r,i)} ${e}: ${o}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}const o="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${o.slice(3).join("|")}|this\\b`);const r=new Set("script|iframe|object|embed|form|input|button|textarea|select|link|meta|base|style|template|slot|portal|frame|frameset|applet|noscript|noembed|plaintext|xmp|listing".split("|")),i=/^on\w+$/i,n=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),s=/^\s*(javascript|vbscript|data|blob):/i;function a(t){if(!t||"string"!=typeof t)return"";if(-1===t.indexOf("<"))return t;const e=document.createElement("template");return e.innerHTML=t,function(t){const e=[],o=t.querySelectorAll("*");for(const a of o){const t=a.tagName.toLowerCase();if(r.has(t)){e.push(a);continue}if("svg"===t||"http://www.w3.org/2000/svg"===a.namespaceURI){if(Array.from(a.attributes).some(t=>i.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(a);continue}}const o=[];for(const e of a.attributes){const t=e.name.toLowerCase();i.test(t)?o.push(e.name):(n.has(t)&&s.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&o.push(e.name)}o.forEach(t=>a.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content),e.innerHTML}const l={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class c{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}mergeConfigsFrom(t){if(0===t.length)return;const o={...this.userConfig},r={};for(const e of Object.keys(o))r[e]=this;for(const i of t){const t=i.userConfig;for(const[n,s]of Object.entries(t)){if(void 0===s)continue;if(!(n in o)){o[n]=s,r[n]=i;continue}if(o[n]===s)continue;const t=r[n]?.constructor.name??this.constructor.name,a=i.constructor.name,l=e("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${n}" supplied by both ${t} and ${a}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(l)}}Object.assign(this.userConfig,o)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const o=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...l,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(e,10);if(!isNaN(o))return o}return 200}setIcon(t,e,o){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const r=this.#e(e,o);void 0!==r?"string"==typeof r?t.innerHTML=a(r):r instanceof HTMLElement&&(t.innerHTML="",t.appendChild(r.cloneNode(!0))):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(o,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const r=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return r?t.insertBefore(o,r):t.appendChild(o),o}warn(o,r){void 0!==r?console.warn(e(o,r,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${o}`)}throwDiagnostic(t,o){throw new Error(e(t,o,this.gridElement.id,this.name))}}function p(t){return t.scrollWidth>t.clientWidth}function d(){return"function"==typeof HTMLElement.prototype?.showPopover}class h extends c{name="tooltip";styles='@layer tbw-plugins{.tbw-tooltip-popover{margin:0;padding:var(--tbw-tooltip-padding, var(--tbw-spacing-sm, .375rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-tooltip-bg, light-dark(#333338, #484850));color:var(--tbw-tooltip-fg, light-dark(#f5f5f5, #f0f0f0));border:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-radius:var(--tbw-tooltip-radius, var(--tbw-border-radius, .25rem));box-shadow:none;filter:var(--tbw-tooltip-shadow, drop-shadow(0 4px 4px rgba(0, 0, 0, .45)));font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-tooltip-font-size, var(--tbw-font-size-sm, .9285em));max-width:var(--tbw-tooltip-max-width, 300px);white-space:pre-line;word-wrap:break-word;overflow-wrap:break-word;pointer-events:none;z-index:10001}.tbw-tooltip-popover:after{content:"";position:absolute;width:var(--tbw-tooltip-arrow-size, 14px);height:var(--tbw-tooltip-arrow-size, 14px);left:var(--tbw-tooltip-arrow-offset, 16px);background:inherit;pointer-events:none}.tbw-tooltip-popover:not(.tbw-tooltip-above):after{top:calc(var(--tbw-tooltip-arrow-size, 14px) / -2);transform:rotate(45deg);border-top:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-left:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72))}.tbw-tooltip-popover.tbw-tooltip-above:after{bottom:calc(var(--tbw-tooltip-arrow-size, 14px) / -2);transform:rotate(45deg);border-bottom:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-right:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72))}@supports (anchor-name: --test){.tbw-tooltip-popover{position-anchor:--tbw-tooltip-anchor;top:calc(anchor(bottom) + 11px);left:anchor(left);position-try-fallbacks:--tbw-tooltip-flip-above}@position-try --tbw-tooltip-flip-above{top:auto;bottom:calc(anchor(top) + 11px)}}}';static manifest={ownedProperties:[{property:"cellTooltip",level:"column",description:'the "cellTooltip" column property'},{property:"headerTooltip",level:"column",description:'the "headerTooltip" column property'}],configRules:[]};#o=null;#r=null;#i=!1;get#n(){return!1!==this.config.header}get#s(){return!1!==this.config.cell}attach(t){super.attach(t)}detach(){this.#a(),this.#o?.remove(),this.#o=null,this.#i=!1,super.detach()}afterRender(){this.#l(),this.#c()}#l(){if(this.#o)return;const t=document.createElement("div");t.className="tbw-tooltip-popover",t.setAttribute("popover","hint"),t.style.overflow="visible",t.style.margin="0",document.body.appendChild(t),this.#o=t}#p(t,e){if(this.#o){if(this.#d(),t.style.setProperty("anchor-name","--tbw-tooltip-anchor"),this.#r=t,this.#o.textContent=e,d())try{this.#o.showPopover()}catch{}"undefined"!=typeof CSS&&!0===CSS.supports?.("anchor-name","--test")?requestAnimationFrame(()=>this.#h(t)):this.#u(t)}}#a(){if(this.#o){if(d())try{this.#o.hidePopover()}catch{}this.#o.classList.remove("tbw-tooltip-above")}this.#d()}#d(){this.#r&&("--tbw-tooltip-anchor"===this.#r.style.getPropertyValue("anchor-name")&&this.#r.style.removeProperty("anchor-name"),this.#r=null)}#u(t){if(!this.#o)return;const e=t.getBoundingClientRect();this.#o.style.position="fixed",this.#o.style.left=`${e.left}px`;window.innerHeight-e.bottom<80?(this.#o.style.top="",this.#o.style.bottom=window.innerHeight-e.top+11+"px",this.#o.classList.add("tbw-tooltip-above")):(this.#o.style.top=`${e.bottom+11}px`,this.#o.style.bottom="",this.#o.classList.remove("tbw-tooltip-above"))}#h(t){if(!this.#o)return;const e=t.getBoundingClientRect(),o=this.#o.getBoundingClientRect();this.#o.classList.toggle("tbw-tooltip-above",o.bottom<=e.top)}#c(){if(this.#i)return;const t=this.gridElement?.querySelector(".tbw-grid-root");t&&(this.#i=!0,t.addEventListener("mouseover",t=>this.#f(t),{signal:this.disconnectSignal}),t.addEventListener("mouseout",t=>this.#g(t),{signal:this.disconnectSignal}))}#f(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"]');if(o&&this.#n)return void this.#b(o);const r=e.closest("[data-row][data-col]");r&&this.#s&&!r.style.getPropertyValue("anchor-name")&&this.#m(r)}#g(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"], [data-row][data-col]');if(!o)return;const r=t.relatedTarget;r&&o.contains(r)||this.#a()}#b(t){const e=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0)return;const o=this.visibleColumns[e];if(!o)return;const r=function(t,e){const o=t.headerTooltip;if(!1===o)return null;if("string"==typeof o)return o;if("function"==typeof o)return o({column:t,value:t.header??t.field});const r=e.querySelector("span:first-child")??e;return p(r)&&r.textContent?.trim()||null}(o,t);r&&this.#p(t,r)}#m(t){const e=parseInt(t.getAttribute("data-row")??"-1",10),o=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0||o<0)return;const r=this.visibleColumns[o];if(!r)return;const i=this.rows[e],n=i?.[r.field],s=function(t,e,o,r,i){const n=t.cellTooltip;if(!1===n)return null;if("string"==typeof n)return n;if("function"==typeof n)return n({value:r,row:o,column:t,field:t.field,grid:i});return p(e)&&e.textContent?.trim()||null}(r,t,i,n,this.grid);s&&this.#p(t,s)}}export{h as TooltipPlugin};
1
+ function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function e(e,o,r,i){return`${t(r,i)} ${e}: ${o}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}const o="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join(""));new RegExp(`__(proto|defineGetter|defineSetter)|${o.slice(3).join("|")}|this\\b`);const r=new Set("script|iframe|object|embed|form|input|button|textarea|select|link|meta|base|style|template|slot|portal|frame|frameset|applet|noscript|noembed|plaintext|xmp|listing".split("|")),i=/^on\w+$/i,n=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),s=/^\s*(javascript|vbscript|data|blob):/i;function l(t){if(!t||"string"!=typeof t)return"";if(-1===t.indexOf("<"))return t;const e=document.createElement("template");return e.innerHTML=t,function(t){const e=[],o=t.querySelectorAll("*");for(const l of o){const t=l.tagName.toLowerCase();if(r.has(t)){e.push(l);continue}if("svg"===t||"http://www.w3.org/2000/svg"===l.namespaceURI){if(Array.from(l.attributes).some(t=>i.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(l);continue}}const o=[];for(const e of l.attributes){const t=e.name.toLowerCase();i.test(t)?o.push(e.name):(n.has(t)&&s.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&o.push(e.name)}o.forEach(t=>l.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content),e.innerHTML}const a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class p{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}mergeConfigsFrom(t){if(0===t.length)return;const o={...this.userConfig},r={};for(const e of Object.keys(o))r[e]=this;for(const i of t){const t=i.userConfig;for(const[n,s]of Object.entries(t)){if(void 0===s)continue;if(!(n in o)){o[n]=s,r[n]=i;continue}if(o[n]===s)continue;const t=r[n]?.constructor.name??this.constructor.name,l=i.constructor.name,a=e("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${n}" supplied by both ${t} and ${l}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,o)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const o=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...a,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(e,10);if(!isNaN(o))return o}return 200}setIcon(t,e,o){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const r=this.#e(e,o);void 0!==r?"string"==typeof r?t.innerHTML=l(r):r instanceof HTMLElement&&(t.innerHTML="",t.appendChild(r.cloneNode(!0))):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(o,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const r=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return r?t.insertBefore(o,r):t.appendChild(o),o}warn(o,r){void 0!==r?console.warn(e(o,r,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${o}`)}throwDiagnostic(t,o){throw new Error(e(t,o,this.gridElement.id,this.name))}}function c(t){return t.scrollWidth>t.clientWidth}function d(){return"function"==typeof HTMLElement.prototype?.showPopover}class h extends p{name="tooltip";styles='@layer tbw-plugins{.tbw-tooltip-popover{margin:0;padding:var(--tbw-tooltip-padding, var(--tbw-spacing-sm, .375rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-tooltip-bg, light-dark(#333338, #484850));color:var(--tbw-tooltip-fg, light-dark(#f5f5f5, #f0f0f0));border:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-radius:var(--tbw-tooltip-radius, var(--tbw-border-radius, .25rem));box-shadow:none;filter:var(--tbw-tooltip-shadow, drop-shadow(0 4px 4px rgba(0, 0, 0, .45)));font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-tooltip-font-size, var(--tbw-font-size-sm, .9285em));max-width:var(--tbw-tooltip-max-width, 300px);white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word;pointer-events:none;z-index:10001}.tbw-tooltip-popover.tbw-tooltip-multiline{white-space:pre;max-width:none;word-wrap:normal;overflow-wrap:normal}.tbw-tooltip-popover:after{content:"";position:absolute;width:var(--tbw-tooltip-arrow-size, 14px);height:var(--tbw-tooltip-arrow-size, 14px);left:var(--tbw-tooltip-arrow-offset, 16px);background:inherit;pointer-events:none}.tbw-tooltip-popover:not(.tbw-tooltip-above):after{top:calc(var(--tbw-tooltip-arrow-size, 14px) / -2);transform:rotate(45deg);border-top:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-left:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));clip-path:polygon(0 0,100% 0,0 100%)}.tbw-tooltip-popover.tbw-tooltip-above:after{bottom:calc(var(--tbw-tooltip-arrow-size, 14px) / -2);transform:rotate(45deg);border-bottom:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));border-right:1px solid var(--tbw-tooltip-border, light-dark(#222226, #6a6a72));clip-path:polygon(100% 0,100% 100%,0 100%)}@supports (anchor-name: --test){.tbw-tooltip-popover{position-anchor:--tbw-tooltip-anchor;top:calc(anchor(bottom) + 11px);left:anchor(left);position-try-fallbacks:--tbw-tooltip-flip-above}@position-try --tbw-tooltip-flip-above{top:auto;bottom:calc(anchor(top) + 11px)}}}';static manifest={ownedProperties:[{property:"cellTooltip",level:"column",description:'the "cellTooltip" column property'},{property:"headerTooltip",level:"column",description:'the "headerTooltip" column property'}],configRules:[]};#o=null;#r=null;#i=!1;get#n(){return!1!==this.config.header}get#s(){return!1!==this.config.cell}attach(t){super.attach(t)}detach(){this.#l(),this.#o?.remove(),this.#o=null,this.#i=!1,super.detach()}afterRender(){this.#a(),this.#p()}#a(){if(this.#o)return;const t=document.createElement("div");t.className="tbw-tooltip-popover",t.setAttribute("popover","hint"),t.style.overflow="visible",t.style.margin="0",document.body.appendChild(t),this.#o=t}#c(t,e){if(this.#o){if(this.#d(),t.style.setProperty("anchor-name","--tbw-tooltip-anchor"),this.#r=t,this.#o.textContent=e,this.#o.classList.toggle("tbw-tooltip-multiline",e.includes("\n")),d())try{this.#o.showPopover()}catch{}"undefined"!=typeof CSS&&!0===CSS.supports?.("anchor-name","--test")?requestAnimationFrame(()=>this.#h(t)):this.#u(t)}}#l(){if(this.#o){if(d())try{this.#o.hidePopover()}catch{}this.#o.classList.remove("tbw-tooltip-above")}this.#d()}#d(){this.#r&&("--tbw-tooltip-anchor"===this.#r.style.getPropertyValue("anchor-name")&&this.#r.style.removeProperty("anchor-name"),this.#r=null)}#u(t){if(!this.#o)return;const e=t.getBoundingClientRect();this.#o.style.position="fixed",this.#o.style.left=`${e.left}px`;window.innerHeight-e.bottom<80?(this.#o.style.top="",this.#o.style.bottom=window.innerHeight-e.top+11+"px",this.#o.classList.add("tbw-tooltip-above")):(this.#o.style.top=`${e.bottom+11}px`,this.#o.style.bottom="",this.#o.classList.remove("tbw-tooltip-above"))}#h(t){if(!this.#o)return;const e=t.getBoundingClientRect(),o=this.#o.getBoundingClientRect();this.#o.classList.toggle("tbw-tooltip-above",o.bottom<=e.top)}#p(){if(this.#i)return;const t=this.gridElement?.querySelector(".tbw-grid-root");t&&(this.#i=!0,t.addEventListener("mouseover",t=>this.#f(t),{signal:this.disconnectSignal}),t.addEventListener("mouseout",t=>this.#g(t),{signal:this.disconnectSignal}))}#f(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"]');if(o&&this.#n)return void this.#b(o);const r=e.closest("[data-row][data-col]");r&&this.#s&&!r.style.getPropertyValue("anchor-name")&&this.#m(r)}#g(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"], [data-row][data-col]');if(!o)return;const r=t.relatedTarget;r&&o.contains(r)||this.#l()}#b(t){const e=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0)return;const o=this.visibleColumns[e];if(!o)return;const r=function(t,e){const o=t.headerTooltip;if(!1===o)return null;if("string"==typeof o)return o;if("function"==typeof o)return o({column:t,value:t.header??t.field});const r=e.querySelector("span:first-child")??e;return c(r)&&r.textContent?.trim()||null}(o,t);r&&this.#c(t,r)}#m(t){const e=parseInt(t.getAttribute("data-row")??"-1",10),o=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0||o<0)return;const r=this.visibleColumns[o];if(!r)return;const i=this.rows[e],n=i?.[r.field],s=function(t,e,o,r,i){const n=t.cellTooltip;if(!1===n)return null;if("string"==typeof n)return n;if("function"==typeof n)return n({value:r,row:o,column:t,field:t.field,grid:i});return c(e)&&e.textContent?.trim()||null}(r,t,i,n,this.grid);s&&this.#c(t,s)}}export{h as TooltipPlugin};
2
2
  //# sourceMappingURL=index.js.map