@toolbox-web/grid 3.8.1 → 3.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +1 -1
- package/all.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/core/defaults.d.ts +1 -1
- package/lib/core/internal/aria.d.ts +1 -1
- package/lib/core/internal/config-manager.d.ts +0 -4
- package/lib/core/types.d.ts +6 -0
- package/lib/features/registry.js +1 -1
- package/lib/plugins/clipboard/clipboard-plugin.d.ts +2 -3
- package/lib/plugins/clipboard/index.js +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/context-menu/index.js.map +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/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-columns/index.js.map +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/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/multi-sort/index.js.map +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/pinned-rows/index.js.map +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/print/index.js.map +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/row-drag-drop/row-drag-drop-plugin.d.ts +1 -0
- package/lib/plugins/row-drag-drop/types.d.ts +3 -2
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/selection-plugin.d.ts +2 -2
- 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/sticky-rows/index.js +1 -1
- package/lib/plugins/sticky-rows/index.js.map +1 -1
- package/lib/plugins/tooltip/index.js +1 -1
- package/lib/plugins/tooltip/index.js.map +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/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/row-drag-drop.umd.js +1 -1
- package/umd/plugins/row-drag-drop.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/tooltip.umd.js +1 -1
- package/umd/plugins/tooltip.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function e(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function o(t,o,r,i){return`${e(r,i)} ${t}: ${o}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(t)}`}var r="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join("")),i=(new RegExp(`__(proto|defineGetter|defineSetter)|${r.slice(3).join("|")}|this\\b`),new Set("script|iframe|object|embed|form|input|button|textarea|select|link|meta|base|style|template|slot|portal|frame|frameset|applet|noscript|noembed|plaintext|xmp|listing|math".split("|"))),n=/^on\w+$/i,s=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),l=/^\s*(javascript|vbscript|data|blob):/i;function a(t){const e=document.createElement("template");return t&&"string"==typeof t&&(e.innerHTML=t,function(t){const e=[],o=t.querySelectorAll("*");for(const r of o){const t=r.tagName.toLowerCase();if(i.has(t)){e.push(r);continue}if(("svg"===t||"http://www.w3.org/2000/svg"===r.namespaceURI)&&Array.from(r.attributes).some(t=>n.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(r);continue}const o=[];for(const e of r.attributes){const t=e.name.toLowerCase();n.test(t)?o.push(e.name):"is"!==t?(s.has(t)&&l.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&o.push(e.name):o.push(e.name)}o.forEach(t=>r.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content)),e.content}var c=class{static dependencies;static manifest;aliases;version="3.8.1";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}get resolvedConfig(){return this.#t?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(t){if(0===t.length)return;const e={...this.userConfig},r={};for(const o of Object.keys(e))r[o]=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 e)){e[n]=s,r[n]=i;continue}if(e[n]===s)continue;const t=r[n]?.constructor.name??this.constructor.name,l=i.constructor.name,a=o("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,e)}refreshUserConfigFrom(t){const e=this.userConfig,o={...t.userConfig};for(const r of Object.keys(e))delete e[r];Object.assign(e,o)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const o=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}queryBoolean(t,e=null){const o=this.grid?.query?.(t,e);return Array.isArray(o)?o.some(Boolean):!!o}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...t,...e}}t(t,e){return this.grid?.effectiveConfig?.locale?.[t]??e}get translate(){return(t,e)=>this.t(t,e)}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;return!e||"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(e,10);if(!isNaN(o))return o}return 200}setIcon(t,e,o){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const r=this.#e(e,o);var i,n;void 0!==r?"string"==typeof r?(i=t,(n=r)&&"string"==typeof n?-1!==n.indexOf("<")||-1!==n.indexOf("&")?i.replaceChildren(a(n)):i.textContent=n:i.replaceChildren()):r instanceof HTMLElement&&t.replaceChildren(r.cloneNode(!0)):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(o,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const r=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return r?t.insertBefore(o,r):t.appendChild(o),o}warn(t,r){void 0!==r?console.warn(o(t,r,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(t,e){throw new Error(o(t,e,this.gridElement.id,this.name))}};function d(t){return t.scrollWidth>t.clientWidth}function h(t,e){const o=e;return!!o&&t.contains(o)}function p(){return"function"==typeof HTMLElement.prototype?.showPopover}var u=/* @__PURE__ */new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown","Tab"]),g="tbw-tooltip-popover",f=class extends c{name="tooltip";styles='@layer tbw-plugins{.tbw-tooltip-popover{padding:var(--tbw-tooltip-padding,var(--tbw-spacing-sm,.375rem) var(--tbw-spacing-md,.5rem));background:var(--tbw-tooltip-bg,light-dark(#333338,#484850));color:var(--tbw-tooltip-fg,light-dark(#f5f5f5,#f0f0f0));border:1px solid var(--tbw-tooltip-border,light-dark(#222226,#6a6a72));border-radius:var(--tbw-tooltip-radius,var(--tbw-border-radius,.25rem));box-shadow:none;filter:var(--tbw-tooltip-shadow,drop-shadow(0 4px 4px #00000073));font-family:var(--tbw-font-family,system-ui, sans-serif);font-size:var(--tbw-tooltip-font-size,var(--tbw-font-size-sm,.9285em));max-width:var(--tbw-tooltip-max-width,300px);white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word;pointer-events:auto;-webkit-user-select:text;user-select:text;z-index:10001;margin:0}.tbw-tooltip-popover.tbw-tooltip-multiline{white-space:pre;word-wrap:normal;overflow-wrap:normal;max-width:none}.tbw-tooltip-popover:after{content:"";width:var(--tbw-tooltip-arrow-size,14px);height:var(--tbw-tooltip-arrow-size,14px);left:var(--tbw-tooltip-arrow-offset,16px);background:inherit;pointer-events:none;position:absolute}.tbw-tooltip-popover:not(.tbw-tooltip-above):after{top:calc(var(--tbw-tooltip-arrow-size,14px) / -2);border-top:1px solid var(--tbw-tooltip-border,light-dark(#222226,#6a6a72));border-left:1px solid var(--tbw-tooltip-border,light-dark(#222226,#6a6a72));clip-path:polygon(0 0,100% 0,0 100%);transform:rotate(45deg)}.tbw-tooltip-popover.tbw-tooltip-above:after{bottom:calc(var(--tbw-tooltip-arrow-size,14px) / -2);border-bottom:1px solid var(--tbw-tooltip-border,light-dark(#222226,#6a6a72));border-right:1px solid var(--tbw-tooltip-border,light-dark(#222226,#6a6a72));clip-path:polygon(100% 0,100% 100%,0 100%);transform:rotate(45deg)}@supports (anchor-name:--test){.tbw-tooltip-popover{position-anchor:--tbw-tooltip-anchor;top:calc(anchor(bottom) + 11px);bottom:auto;left:anchor(left)}.tbw-tooltip-popover.tbw-tooltip-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;#n=null;#s=null;get#l(){return!1!==this.config.header}get#a(){return!1!==this.config.cell}get#c(){return!1!==this.config.focus}get#d(){return this.config.hideDelay??120}attach(t){super.attach(t)}detach(){this.#h(),null!==this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),this.#p(),this.#o?.remove(),this.#o=null,this.#i=!1,super.detach()}afterRender(){this.#u(),this.#g()}#u(){if(this.#o)return;const t=document.createElement("div");t.className="tbw-tooltip-popover",t.setAttribute("popover","hint"),t.id=g,t.setAttribute("role","tooltip"),t.style.overflow="visible",t.style.margin="0",document.body.appendChild(t),this.#o=t,t.addEventListener("mouseenter",()=>this.#h(),{signal:this.disconnectSignal}),t.addEventListener("mouseleave",()=>this.#f(),{signal:this.disconnectSignal})}#b(t,e){if(this.#o){if(this.#h(),this.#m(),t.style.setProperty("anchor-name","--tbw-tooltip-anchor"),t.setAttribute("aria-describedby",g),this.#r=t,this.#o.textContent=e,this.#o.classList.toggle("tbw-tooltip-multiline",e.includes("\n")),p())try{this.#o.showPopover()}catch{}"undefined"!=typeof CSS&&!0===CSS.supports?.("anchor-name","--test")?this.#o.classList.toggle("tbw-tooltip-above",this.#v(t)):this.#w(t)}}#p(){if(this.#h(),this.#o){if(p())try{this.#o.hidePopover()}catch{}this.#o.classList.remove("tbw-tooltip-above")}this.#m()}get#y(){return null!==this.#r}#f(){this.#h(),this.#d<=0?this.#p():this.#n=setTimeout(()=>{this.#n=null,this.#p()},this.#d)}#h(){null!==this.#n&&(clearTimeout(this.#n),this.#n=null)}#m(){this.#r&&("--tbw-tooltip-anchor"===this.#r.style.getPropertyValue("anchor-name")&&this.#r.style.removeProperty("anchor-name"),this.#r.getAttribute("aria-describedby")===g&&this.#r.removeAttribute("aria-describedby"),this.#r=null)}#v(t){if(!this.#o)return!1;const e=t.getBoundingClientRect(),o=e.top-11,r=window.innerHeight-e.bottom-11;return this.#o.offsetHeight<=o||o>=r}#w(t){if(!this.#o)return;const e=t.getBoundingClientRect(),o=this.#v(t);this.#o.style.position="fixed",this.#o.style.left=`${e.left}px`,o?(this.#o.style.top="",this.#o.style.bottom=window.innerHeight-e.top+11+"px"):(this.#o.style.top=`${e.bottom+11}px`,this.#o.style.bottom=""),this.#o.classList.toggle("tbw-tooltip-above",o)}#g(){if(this.#i)return;const t=this.gridElement?.querySelector(".tbw-grid-root");t&&(this.#i=!0,t.addEventListener("mouseover",t=>this.#C(t),{signal:this.disconnectSignal}),t.addEventListener("mouseout",t=>this.#E(t),{signal:this.disconnectSignal}),document.addEventListener("keydown",t=>this.#x(t),{capture:!0,signal:this.disconnectSignal}),this.gridElement.addEventListener("keydown",t=>this.#T(t),{signal:this.disconnectSignal}))}#C(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"]');if(o&&this.#l)return void(h(o,t.relatedTarget)||this.#A(o));const r=e.closest("[data-row][data-col]");if(r&&this.#a&&!r.style.getPropertyValue("anchor-name")){if(h(r,t.relatedTarget))return;this.#S(r)}}#E(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"], [data-row][data-col]');o&&(h(o,t.relatedTarget)||this.#f())}#x(t){"Escape"===t.key&&this.#y&&this.#p()}#T(t){this.#c&&this.#a&&"Escape"!==t.key&&(u.has(t.key)?(null!==this.#s&&cancelAnimationFrame(this.#s),this.#s=requestAnimationFrame(()=>{this.#s=null,this.#P()})):this.#p())}#P(){const t=this.gridElement?.querySelector(".cell-focus");if(!t||!t.hasAttribute("data-row"))return void this.#p();if(t===this.#r)return;if(t.style.getPropertyValue("anchor-name"))return void this.#p();const e=this.#r;this.#S(t),this.#r===e&&this.#p()}#A(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 d(r)&&r.textContent?.trim()||null}(o,t);r&&this.#b(t,r)}#S(t){const e=parseInt(t.getAttribute("data-row")??"-1",10),o=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0||o<0)return;const r=this.visibleColumns[o];if(!r)return;const i=this.rows[e],n=i?.[r.field],s=function(t,e,o,r,i){const n=t.cellTooltip;return!1===n?null:"string"==typeof n?n:"function"==typeof n?n({value:r,row:o,column:t,field:t.field,grid:i}):d(e)&&e.textContent?.trim()||null}(r,t,i,n,this.grid);s&&this.#b(t,s)}};export{f as TooltipPlugin};
|
|
1
|
+
var t={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function e(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function o(t,o,r,i){return`${e(r,i)} ${t}: ${o}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(t)}`}var r="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join("")),i=(new RegExp(`__(proto|defineGetter|defineSetter)|${r.slice(3).join("|")}|this\\b`),new Set("script|iframe|object|embed|form|input|button|textarea|select|link|meta|base|style|template|slot|portal|frame|frameset|applet|noscript|noembed|plaintext|xmp|listing|math".split("|"))),n=/^on\w+$/i,s=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),l=/^\s*(javascript|vbscript|data|blob):/i;function a(t){const e=document.createElement("template");return t&&"string"==typeof t&&(e.innerHTML=t,function(t){const e=[],o=t.querySelectorAll("*");for(const r of o){const t=r.tagName.toLowerCase();if(i.has(t)){e.push(r);continue}if(("svg"===t||"http://www.w3.org/2000/svg"===r.namespaceURI)&&Array.from(r.attributes).some(t=>n.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(r);continue}const o=[];for(const e of r.attributes){const t=e.name.toLowerCase();n.test(t)?o.push(e.name):"is"!==t?(s.has(t)&&l.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&o.push(e.name):o.push(e.name)}o.forEach(t=>r.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content)),e.content}var c=class{static dependencies;static manifest;aliases;version="3.8.3";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}get resolvedConfig(){return this.#t?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(t){if(0===t.length)return;const e={...this.userConfig},r={};for(const o of Object.keys(e))r[o]=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 e)){e[n]=s,r[n]=i;continue}if(e[n]===s)continue;const t=r[n]?.constructor.name??this.constructor.name,l=i.constructor.name,a=o("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,e)}refreshUserConfigFrom(t){const e=this.userConfig,o={...t.userConfig};for(const r of Object.keys(e))delete e[r];Object.assign(e,o)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const o=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}queryBoolean(t,e=null){const o=this.grid?.query?.(t,e);return Array.isArray(o)?o.some(Boolean):!!o}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...t,...e}}t(t,e){return this.grid?.effectiveConfig?.locale?.[t]??e}get translate(){return(t,e)=>this.t(t,e)}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;return!e||"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(e,10);if(!isNaN(o))return o}return 200}setIcon(t,e,o){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const r=this.#e(e,o);var i,n;void 0!==r?"string"==typeof r?(i=t,(n=r)&&"string"==typeof n?-1!==n.indexOf("<")||-1!==n.indexOf("&")?i.replaceChildren(a(n)):i.textContent=n:i.replaceChildren()):r instanceof HTMLElement&&t.replaceChildren(r.cloneNode(!0)):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(o,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const r=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return r?t.insertBefore(o,r):t.appendChild(o),o}warn(t,r){void 0!==r?console.warn(o(t,r,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(t,e){throw new Error(o(t,e,this.gridElement.id,this.name))}};function d(t){return t.scrollWidth>t.clientWidth}function h(t,e){const o=e;return!!o&&t.contains(o)}function p(){return"function"==typeof HTMLElement.prototype?.showPopover}var u=/* @__PURE__ */new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown","Tab"]),f="tbw-tooltip-popover",g=class extends c{name="tooltip";styles='@layer tbw-plugins{.tbw-tooltip-popover{padding:var(--tbw-tooltip-padding,var(--tbw-spacing-sm,.375rem) var(--tbw-spacing-md,.5rem));background:var(--tbw-tooltip-bg,light-dark(#333338,#484850));color:var(--tbw-tooltip-fg,light-dark(#f5f5f5,#f0f0f0));border:1px solid var(--tbw-tooltip-border,light-dark(#222226,#6a6a72));border-radius:var(--tbw-tooltip-radius,var(--tbw-border-radius,.25rem));box-shadow:none;filter:var(--tbw-tooltip-shadow,drop-shadow(0 4px 4px #00000073));font-family:var(--tbw-font-family,system-ui, sans-serif);font-size:var(--tbw-tooltip-font-size,var(--tbw-font-size-sm,.9285em));max-width:var(--tbw-tooltip-max-width,300px);white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word;pointer-events:auto;-webkit-user-select:text;user-select:text;z-index:10001;margin:0}.tbw-tooltip-popover.tbw-tooltip-multiline{white-space:pre;word-wrap:normal;overflow-wrap:normal;max-width:none}.tbw-tooltip-popover:after{content:"";width:var(--tbw-tooltip-arrow-size,14px);height:var(--tbw-tooltip-arrow-size,14px);left:var(--tbw-tooltip-arrow-offset,16px);background:inherit;pointer-events:none;position:absolute}.tbw-tooltip-popover:not(.tbw-tooltip-above):after{top:calc(var(--tbw-tooltip-arrow-size,14px) / -2);border-top:1px solid var(--tbw-tooltip-border,light-dark(#222226,#6a6a72));border-left:1px solid var(--tbw-tooltip-border,light-dark(#222226,#6a6a72));clip-path:polygon(0 0,100% 0,0 100%);transform:rotate(45deg)}.tbw-tooltip-popover.tbw-tooltip-above:after{bottom:calc(var(--tbw-tooltip-arrow-size,14px) / -2);border-bottom:1px solid var(--tbw-tooltip-border,light-dark(#222226,#6a6a72));border-right:1px solid var(--tbw-tooltip-border,light-dark(#222226,#6a6a72));clip-path:polygon(100% 0,100% 100%,0 100%);transform:rotate(45deg)}@supports (anchor-name:--test){.tbw-tooltip-popover{position-anchor:--tbw-tooltip-anchor;top:calc(anchor(bottom) + 11px);bottom:auto;left:anchor(left)}.tbw-tooltip-popover.tbw-tooltip-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;#n=null;#s=null;get#l(){return!1!==this.config.header}get#a(){return!1!==this.config.cell}get#c(){return!1!==this.config.focus}get#d(){return this.config.hideDelay??120}attach(t){super.attach(t)}detach(){this.#h(),null!==this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),this.#p(),this.#o?.remove(),this.#o=null,this.#i=!1,super.detach()}afterRender(){this.#u(),this.#f()}#u(){if(this.#o)return;const t=document.createElement("div");t.className="tbw-tooltip-popover",t.setAttribute("popover","hint"),t.id=f,t.setAttribute("role","tooltip"),t.style.overflow="visible",t.style.margin="0",document.body.appendChild(t),this.#o=t,t.addEventListener("mouseenter",()=>this.#h(),{signal:this.disconnectSignal}),t.addEventListener("mouseleave",()=>this.#g(),{signal:this.disconnectSignal}),t.addEventListener("wheel",t=>this.#b(t),{passive:!1,signal:this.disconnectSignal})}#b(t){const e=this.#r;if(this.#p(),!e?.isConnected)return;const o=new WheelEvent("wheel",{deltaX:t.deltaX,deltaY:t.deltaY,deltaZ:t.deltaZ,deltaMode:t.deltaMode,clientX:t.clientX,clientY:t.clientY,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey,bubbles:!0,cancelable:!0,composed:!0});e.dispatchEvent(o)||t.preventDefault()}#m(t,e){if(this.#o){if(this.#h(),this.#v(),t.style.setProperty("anchor-name","--tbw-tooltip-anchor"),t.setAttribute("aria-describedby",f),this.#r=t,this.#o.textContent=e,this.#o.classList.toggle("tbw-tooltip-multiline",e.includes("\n")),p())try{this.#o.showPopover()}catch{}"undefined"!=typeof CSS&&!0===CSS.supports?.("anchor-name","--test")?this.#o.classList.toggle("tbw-tooltip-above",this.#w(t)):this.#y(t)}}#p(){if(this.#h(),this.#o){if(p())try{this.#o.hidePopover()}catch{}this.#o.classList.remove("tbw-tooltip-above")}this.#v()}get#C(){return null!==this.#r}#g(){this.#h(),this.#d<=0?this.#p():this.#n=setTimeout(()=>{this.#n=null,this.#p()},this.#d)}#h(){null!==this.#n&&(clearTimeout(this.#n),this.#n=null)}#v(){this.#r&&("--tbw-tooltip-anchor"===this.#r.style.getPropertyValue("anchor-name")&&this.#r.style.removeProperty("anchor-name"),this.#r.getAttribute("aria-describedby")===f&&this.#r.removeAttribute("aria-describedby"),this.#r=null)}#w(t){if(!this.#o)return!1;const e=t.getBoundingClientRect(),o=e.top-11,r=window.innerHeight-e.bottom-11;return this.#o.offsetHeight<=o||o>=r}#y(t){if(!this.#o)return;const e=t.getBoundingClientRect(),o=this.#w(t);this.#o.style.position="fixed",this.#o.style.left=`${e.left}px`,o?(this.#o.style.top="",this.#o.style.bottom=window.innerHeight-e.top+11+"px"):(this.#o.style.top=`${e.bottom+11}px`,this.#o.style.bottom=""),this.#o.classList.toggle("tbw-tooltip-above",o)}#f(){if(this.#i)return;const t=this.gridElement?.querySelector(".tbw-grid-root");t&&(this.#i=!0,t.addEventListener("mouseover",t=>this.#E(t),{signal:this.disconnectSignal}),t.addEventListener("mouseout",t=>this.#x(t),{signal:this.disconnectSignal}),document.addEventListener("keydown",t=>this.#T(t),{capture:!0,signal:this.disconnectSignal}),this.gridElement.addEventListener("keydown",t=>this.#A(t),{signal:this.disconnectSignal}))}#E(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"]');if(o&&this.#l)return void(h(o,t.relatedTarget)||this.#S(o));const r=e.closest("[data-row][data-col]");if(r&&this.#a&&!r.style.getPropertyValue("anchor-name")){if(h(r,t.relatedTarget))return;this.#P(r)}}#x(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"], [data-row][data-col]');o&&(h(o,t.relatedTarget)||this.#g())}#T(t){"Escape"===t.key&&this.#C&&this.#p()}#A(t){this.#c&&this.#a&&"Escape"!==t.key&&(u.has(t.key)?(null!==this.#s&&cancelAnimationFrame(this.#s),this.#s=requestAnimationFrame(()=>{this.#s=null,this.#k()})):this.#p())}#k(){const t=this.gridElement?.querySelector(".cell-focus");if(!t||!t.hasAttribute("data-row"))return void this.#p();if(t===this.#r)return;if(t.style.getPropertyValue("anchor-name"))return void this.#p();const e=this.#r;this.#P(t),this.#r===e&&this.#p()}#S(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 d(r)&&r.textContent?.trim()||null}(o,t);r&&this.#m(t,r)}#P(t){const e=parseInt(t.getAttribute("data-row")??"-1",10),o=parseInt(t.getAttribute("data-col")??"-1",10);if(e<0||o<0)return;const r=this.visibleColumns[o];if(!r)return;const i=this.rows[e],n=i?.[r.field],s=function(t,e,o,r,i){const n=t.cellTooltip;return!1===n?null:"string"==typeof n?n:"function"==typeof n?n({value:r,row:o,column:t,field:t.field,grid:i}):d(e)&&e.textContent?.trim()||null}(r,t,i,n,this.grid);s&&this.#m(t,s)}};export{g as TooltipPlugin};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|