@toolbox-web/grid 1.27.2 → 1.28.0

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 (68) hide show
  1. package/all.d.ts +1 -0
  2. package/all.js +2 -2
  3. package/all.js.map +1 -1
  4. package/index.js +1 -1
  5. package/index.js.map +1 -1
  6. package/lib/core/types.d.ts +0 -2
  7. package/lib/features/tooltip.d.ts +7 -0
  8. package/lib/features/tooltip.js +2 -0
  9. package/lib/features/tooltip.js.map +1 -0
  10. package/lib/plugins/clipboard/index.js +1 -1
  11. package/lib/plugins/clipboard/index.js.map +1 -1
  12. package/lib/plugins/column-virtualization/index.js +1 -1
  13. package/lib/plugins/column-virtualization/index.js.map +1 -1
  14. package/lib/plugins/context-menu/index.js +1 -1
  15. package/lib/plugins/context-menu/index.js.map +1 -1
  16. package/lib/plugins/editing/index.js +1 -1
  17. package/lib/plugins/editing/index.js.map +1 -1
  18. package/lib/plugins/editing/types.d.ts +2 -0
  19. package/lib/plugins/export/index.js +1 -1
  20. package/lib/plugins/export/index.js.map +1 -1
  21. package/lib/plugins/filtering/index.js +1 -1
  22. package/lib/plugins/filtering/index.js.map +1 -1
  23. package/lib/plugins/grouping-columns/index.js +1 -1
  24. package/lib/plugins/grouping-columns/index.js.map +1 -1
  25. package/lib/plugins/grouping-rows/index.js +2 -2
  26. package/lib/plugins/grouping-rows/index.js.map +1 -1
  27. package/lib/plugins/master-detail/index.js +1 -1
  28. package/lib/plugins/master-detail/index.js.map +1 -1
  29. package/lib/plugins/multi-sort/index.js +1 -1
  30. package/lib/plugins/multi-sort/index.js.map +1 -1
  31. package/lib/plugins/pinned-columns/index.js +1 -1
  32. package/lib/plugins/pinned-columns/index.js.map +1 -1
  33. package/lib/plugins/pinned-rows/index.js +1 -1
  34. package/lib/plugins/pinned-rows/index.js.map +1 -1
  35. package/lib/plugins/pivot/index.js +1 -1
  36. package/lib/plugins/pivot/index.js.map +1 -1
  37. package/lib/plugins/print/index.js +1 -1
  38. package/lib/plugins/print/index.js.map +1 -1
  39. package/lib/plugins/reorder-columns/index.js +1 -1
  40. package/lib/plugins/reorder-columns/index.js.map +1 -1
  41. package/lib/plugins/reorder-rows/index.js +1 -1
  42. package/lib/plugins/reorder-rows/index.js.map +1 -1
  43. package/lib/plugins/responsive/index.js +1 -1
  44. package/lib/plugins/responsive/index.js.map +1 -1
  45. package/lib/plugins/selection/index.js +1 -1
  46. package/lib/plugins/selection/index.js.map +1 -1
  47. package/lib/plugins/server-side/index.js +1 -1
  48. package/lib/plugins/server-side/index.js.map +1 -1
  49. package/lib/plugins/tooltip/TooltipPlugin.d.ts +52 -0
  50. package/lib/plugins/tooltip/index.d.ts +8 -0
  51. package/lib/plugins/tooltip/index.js +2 -0
  52. package/lib/plugins/tooltip/index.js.map +1 -0
  53. package/lib/plugins/tooltip/types.d.ts +78 -0
  54. package/lib/plugins/tree/index.js +1 -1
  55. package/lib/plugins/tree/index.js.map +1 -1
  56. package/lib/plugins/undo-redo/index.js +1 -1
  57. package/lib/plugins/undo-redo/index.js.map +1 -1
  58. package/lib/plugins/visibility/index.js +1 -1
  59. package/lib/plugins/visibility/index.js.map +1 -1
  60. package/package.json +1 -1
  61. package/umd/grid.all.umd.js +1 -1
  62. package/umd/grid.all.umd.js.map +1 -1
  63. package/umd/grid.umd.js +1 -1
  64. package/umd/grid.umd.js.map +1 -1
  65. package/umd/plugins/context-menu.umd.js +1 -1
  66. package/umd/plugins/context-menu.umd.js.map +1 -1
  67. package/umd/plugins/tooltip.umd.js +2 -0
  68. package/umd/plugins/tooltip.umd.js.map +1 -0
@@ -0,0 +1,52 @@
1
+ import { GridElement, PluginManifest, BaseGridPlugin } from '../../core/plugin/base-plugin';
2
+ import { TooltipConfig } from './types';
3
+ /**
4
+ * Tooltip Plugin for tbw-grid
5
+ *
6
+ * Shows styled popover tooltips when header or cell text overflows its
7
+ * container. Uses the Popover API with CSS anchor positioning for
8
+ * consistent themed appearance across light and dark modes.
9
+ *
10
+ * ## Installation
11
+ *
12
+ * ```ts
13
+ * import { TooltipPlugin } from '@toolbox-web/grid/plugins/tooltip';
14
+ * ```
15
+ *
16
+ * @example Default — auto-tooltip on overflow
17
+ * ```ts
18
+ * grid.gridConfig = {
19
+ * plugins: [new TooltipPlugin()],
20
+ * };
21
+ * ```
22
+ *
23
+ * @example Header-only tooltips
24
+ * ```ts
25
+ * grid.gridConfig = {
26
+ * plugins: [new TooltipPlugin({ cell: false })],
27
+ * };
28
+ * ```
29
+ *
30
+ * @example Per-column overrides
31
+ * ```ts
32
+ * grid.gridConfig = {
33
+ * columns: [
34
+ * { field: 'name', cellTooltip: (ctx) => `${ctx.row.first} ${ctx.row.last}` },
35
+ * { field: 'actions', cellTooltip: false },
36
+ * { field: 'revenue', headerTooltip: 'Total revenue in USD (before tax)' },
37
+ * ],
38
+ * plugins: [new TooltipPlugin()],
39
+ * };
40
+ * ```
41
+ *
42
+ * @category Plugins
43
+ */
44
+ export declare class TooltipPlugin extends BaseGridPlugin<TooltipConfig> {
45
+ #private;
46
+ readonly name = "tooltip";
47
+ readonly styles: string;
48
+ static readonly manifest: PluginManifest<TooltipConfig>;
49
+ attach(grid: GridElement): void;
50
+ detach(): void;
51
+ afterRender(): void;
52
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Tooltip Plugin Entry Point
3
+ * Re-exports plugin class and types for tree-shakeable imports.
4
+ *
5
+ * @module Plugins/Tooltip
6
+ */
7
+ export { TooltipPlugin } from './TooltipPlugin';
8
+ export type { TooltipConfig } from './types';
@@ -0,0 +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=/* @__PURE__ */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"]),r=/^on\w+$/i,i=/* @__PURE__ */new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),n=/^\s*(javascript|vbscript|data|blob):/i;function s(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=[],s=t.querySelectorAll("*");for(const l of s){const t=l.tagName.toLowerCase();if(o.has(t)){e.push(l);continue}if("svg"===t||"http://www.w3.org/2000/svg"===l.namespaceURI){if(Array.from(l.attributes).some(t=>r.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(l);continue}}const s=[];for(const e of l.attributes){const t=e.name.toLowerCase();r.test(t)?s.push(e.name):(i.has(t)&&n.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&s.push(e.name)}s.forEach(t=>l.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content),e.innerHTML}const l='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',a={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:l,filterActive:l,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}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)}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}resolveIcon(t,e){return void 0!==e?e:this.gridIcons[t]}setIcon(t,e){"string"==typeof e?t.innerHTML=s(e):e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}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-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:[]};#e=null;#o=null;#r=!1;get#i(){return!1!==this.config.header}get#n(){return!1!==this.config.cell}attach(t){super.attach(t)}detach(){this.#s(),this.#e?.remove(),this.#e=null,this.#r=!1,super.detach()}afterRender(){this.#l(),this.#a()}#l(){if(this.#e)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.#e=t}#p(t,e){if(this.#e){if(this.#c(),t.style.setProperty("anchor-name","--tbw-tooltip-anchor"),this.#o=t,this.#e.textContent=e,d())try{this.#e.showPopover()}catch{}"undefined"!=typeof CSS&&!0===CSS.supports?.("anchor-name","--test")?requestAnimationFrame(()=>this.#d(t)):this.#h(t)}}#s(){if(this.#e){if(d())try{this.#e.hidePopover()}catch{}this.#e.classList.remove("tbw-tooltip-above")}this.#c()}#c(){this.#o&&(this.#o.style.removeProperty("anchor-name"),this.#o=null)}#h(t){if(!this.#e)return;const e=t.getBoundingClientRect();this.#e.style.position="fixed",this.#e.style.left=`${e.left}px`;window.innerHeight-e.bottom<80?(this.#e.style.top="",this.#e.style.bottom=window.innerHeight-e.top+11+"px",this.#e.classList.add("tbw-tooltip-above")):(this.#e.style.top=`${e.bottom+11}px`,this.#e.style.bottom="",this.#e.classList.remove("tbw-tooltip-above"))}#d(t){if(!this.#e)return;const e=t.getBoundingClientRect(),o=this.#e.getBoundingClientRect();this.#e.classList.toggle("tbw-tooltip-above",o.bottom<=e.top)}#a(){if(this.#r)return;const t=this.gridElement?.querySelector(".tbw-grid-root");t&&(this.#r=!0,t.addEventListener("mouseover",t=>this.#u(t),{signal:this.disconnectSignal}),t.addEventListener("mouseout",t=>this.#f(t),{signal:this.disconnectSignal}))}#u(t){const e=t.target;if(!e?.closest)return;const o=e.closest('[part~="header-cell"]');if(o&&this.#i)return void this.#b(o);const r=e.closest("[data-row][data-col]");r&&this.#n&&this.#g(r)}#f(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.#s()}#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.#p(t,r)}#g(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){const i=t.cellTooltip;if(!1===i)return null;if("string"==typeof i)return i;if("function"==typeof i)return i({value:r,row:o,column:t,field:t.field});return c(e)&&e.textContent?.trim()||null}(r,t,i,n);s&&this.#p(t,s)}}export{h as TooltipPlugin};
2
+ //# sourceMappingURL=index.js.map