@toolbox-web/grid 3.8.2 → 3.9.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 (100) hide show
  1. package/all.d.ts +1 -0
  2. package/all.js +1 -1
  3. package/all.js.map +1 -1
  4. package/index.js +1 -1
  5. package/index.js.map +1 -1
  6. package/lib/core/defaults.d.ts +1 -1
  7. package/lib/core/internal/aria.d.ts +1 -1
  8. package/lib/core/internal/config-manager.d.ts +0 -4
  9. package/lib/core/plugin/base-plugin.d.ts +14 -0
  10. package/lib/core/plugin/plugin-manager.d.ts +5 -1
  11. package/lib/core/plugin/types.d.ts +2 -0
  12. package/lib/core/types.d.ts +6 -0
  13. package/lib/features/registry.js +1 -1
  14. package/lib/plugins/clipboard/clipboard-plugin.d.ts +2 -3
  15. package/lib/plugins/clipboard/index.js +1 -1
  16. package/lib/plugins/clipboard/index.js.map +1 -1
  17. package/lib/plugins/column-virtualization/index.js +1 -1
  18. package/lib/plugins/column-virtualization/index.js.map +1 -1
  19. package/lib/plugins/context-menu/index.js +1 -1
  20. package/lib/plugins/context-menu/index.js.map +1 -1
  21. package/lib/plugins/editing/index.js +1 -1
  22. package/lib/plugins/editing/index.js.map +1 -1
  23. package/lib/plugins/export/index.js +1 -1
  24. package/lib/plugins/export/index.js.map +1 -1
  25. package/lib/plugins/filtering/index.js +1 -1
  26. package/lib/plugins/filtering/index.js.map +1 -1
  27. package/lib/plugins/grouping-columns/index.js +1 -1
  28. package/lib/plugins/grouping-columns/index.js.map +1 -1
  29. package/lib/plugins/grouping-rows/grouping-rows-plugin.d.ts +20 -24
  30. package/lib/plugins/grouping-rows/grouping-rows.d.ts +9 -4
  31. package/lib/plugins/grouping-rows/index.d.ts +1 -1
  32. package/lib/plugins/grouping-rows/index.js +1 -1
  33. package/lib/plugins/grouping-rows/index.js.map +1 -1
  34. package/lib/plugins/grouping-rows/types.d.ts +32 -4
  35. package/lib/plugins/hierarchy/hierarchy-plugin.d.ts +79 -0
  36. package/lib/plugins/hierarchy/hierarchy.d.ts +28 -0
  37. package/lib/plugins/hierarchy/index.d.ts +9 -0
  38. package/lib/plugins/hierarchy/index.js +2 -0
  39. package/lib/plugins/hierarchy/index.js.map +1 -0
  40. package/lib/plugins/hierarchy/types.d.ts +92 -0
  41. package/lib/plugins/master-detail/index.js +1 -1
  42. package/lib/plugins/master-detail/index.js.map +1 -1
  43. package/lib/plugins/multi-sort/index.js +1 -1
  44. package/lib/plugins/multi-sort/index.js.map +1 -1
  45. package/lib/plugins/pinned-columns/index.js +1 -1
  46. package/lib/plugins/pinned-columns/index.js.map +1 -1
  47. package/lib/plugins/pinned-rows/index.js +1 -1
  48. package/lib/plugins/pinned-rows/index.js.map +1 -1
  49. package/lib/plugins/pivot/index.js +1 -1
  50. package/lib/plugins/pivot/index.js.map +1 -1
  51. package/lib/plugins/print/index.js +1 -1
  52. package/lib/plugins/print/index.js.map +1 -1
  53. package/lib/plugins/reorder-columns/index.js +1 -1
  54. package/lib/plugins/reorder-columns/index.js.map +1 -1
  55. package/lib/plugins/responsive/index.js +1 -1
  56. package/lib/plugins/responsive/index.js.map +1 -1
  57. package/lib/plugins/row-drag-drop/index.js +1 -1
  58. package/lib/plugins/row-drag-drop/index.js.map +1 -1
  59. package/lib/plugins/row-drag-drop/row-drag-drop-plugin.d.ts +1 -0
  60. package/lib/plugins/row-drag-drop/types.d.ts +3 -2
  61. package/lib/plugins/selection/index.js +1 -1
  62. package/lib/plugins/selection/index.js.map +1 -1
  63. package/lib/plugins/selection/selection-plugin.d.ts +2 -2
  64. package/lib/plugins/server-side/index.js +1 -1
  65. package/lib/plugins/server-side/index.js.map +1 -1
  66. package/lib/plugins/shell/index.js +1 -1
  67. package/lib/plugins/shell/index.js.map +1 -1
  68. package/lib/plugins/sticky-rows/index.js +1 -1
  69. package/lib/plugins/sticky-rows/index.js.map +1 -1
  70. package/lib/plugins/tooltip/index.js +1 -1
  71. package/lib/plugins/tooltip/index.js.map +1 -1
  72. package/lib/plugins/tree/index.js +1 -1
  73. package/lib/plugins/tree/index.js.map +1 -1
  74. package/lib/plugins/tree/tree-datasource.d.ts +7 -10
  75. package/lib/plugins/tree/tree-plugin.d.ts +23 -3
  76. package/lib/plugins/undo-redo/index.js +1 -1
  77. package/lib/plugins/undo-redo/index.js.map +1 -1
  78. package/lib/plugins/visibility/index.js +1 -1
  79. package/lib/plugins/visibility/index.js.map +1 -1
  80. package/package.json +1 -1
  81. package/umd/grid.all.umd.js +1 -1
  82. package/umd/grid.all.umd.js.map +1 -1
  83. package/umd/grid.umd.js +1 -1
  84. package/umd/grid.umd.js.map +1 -1
  85. package/umd/plugins/clipboard.umd.js +1 -1
  86. package/umd/plugins/clipboard.umd.js.map +1 -1
  87. package/umd/plugins/editing.umd.js +1 -1
  88. package/umd/plugins/editing.umd.js.map +1 -1
  89. package/umd/plugins/grouping-rows.umd.js +1 -1
  90. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  91. package/umd/plugins/hierarchy.umd.js +2 -0
  92. package/umd/plugins/hierarchy.umd.js.map +1 -0
  93. package/umd/plugins/row-drag-drop.umd.js +1 -1
  94. package/umd/plugins/row-drag-drop.umd.js.map +1 -1
  95. package/umd/plugins/selection.umd.js +1 -1
  96. package/umd/plugins/selection.umd.js.map +1 -1
  97. package/umd/plugins/tooltip.umd.js +1 -1
  98. package/umd/plugins/tooltip.umd.js.map +1 -1
  99. package/umd/plugins/tree.umd.js +1 -1
  100. package/umd/plugins/tree.umd.js.map +1 -1
@@ -1,2 +1,2 @@
1
- var t="sticky-left",e="sticky-right";function n(t){try{if("rtl"===getComputedStyle(t).direction)return"rtl"}catch{}try{if("rtl"===t.closest?.("[dir]")?.getAttribute("dir"))return"rtl"}catch{}return"ltr"}var s={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function i(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function r(t,e,n,s){return`${i(n,s)} ${t}: ${e}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(t)}`}var 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("")),l=(new RegExp(`__(proto|defineGetter|defineSetter)|${o.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("|"))),d=/^on\w+$/i,a=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),c=/^\s*(javascript|vbscript|data|blob):/i;function f(t){const e=document.createElement("template");return t&&"string"==typeof t&&(e.innerHTML=t,function(t){const e=[],n=t.querySelectorAll("*");for(const s of n){const t=s.tagName.toLowerCase();if(l.has(t)){e.push(s);continue}if(("svg"===t||"http://www.w3.org/2000/svg"===s.namespaceURI)&&Array.from(s.attributes).some(t=>d.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(s);continue}const n=[];for(const e of s.attributes){const t=e.name.toLowerCase();d.test(t)?n.push(e.name):"is"!==t?(a.has(t)&&c.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&n.push(e.name):n.push(e.name)}n.forEach(t=>s.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content)),e.content}var u=class{static dependencies;static manifest;aliases;version="3.8.2";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},n={};for(const s of Object.keys(e))n[s]=this;for(const s of t){const t=s.userConfig;for(const[i,o]of Object.entries(t)){if(void 0===o)continue;if(!(i in e)){e[i]=o,n[i]=s;continue}if(e[i]===o)continue;const t=n[i]?.constructor.name??this.constructor.name,l=s.constructor.name,d=r("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${i}" supplied by both ${t} and ${l}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(d)}}Object.assign(this.userConfig,e)}refreshUserConfigFrom(t){const e=this.userConfig,n={...t.userConfig};for(const s of Object.keys(e))delete e[s];Object.assign(e,n)}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 n=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(n),n.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 n=this.grid?.query?.(t,e);return Array.isArray(n)?n.some(Boolean):!!n}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{...s,...t}}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(),n=parseInt(e,10);if(!isNaN(n))return n}return 200}setIcon(t,e,n){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const s=this.#e(e,n);var i,r;void 0!==s?"string"==typeof s?(i=t,(r=s)&&"string"==typeof r?-1!==r.indexOf("<")||-1!==r.indexOf("&")?i.replaceChildren(f(r)):i.textContent=r:i.replaceChildren()):s instanceof HTMLElement&&t.replaceChildren(s.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 n=document.createElement("span");n.setAttribute("part","sort-indicator"),n.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(n,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(n,"sortNone"));const s=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return s?t.insertBefore(n,s):t.appendChild(n),n}warn(t,e){void 0!==e?console.warn(r(t,e,this.gridElement.id,this.name)):console.warn(`${i(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(t,e){throw new Error(r(t,e,this.gridElement.id,this.name))}};function h(t){return t.pinned??t.meta?.pinned}function p(t,e){return function(t,e){return"left"===t||"right"===t?t:"rtl"===e?"start"===t?"right":"left":"start"===t?"left":"right"}(t,e)}function g(t,e){const n=h(t);return!!n&&"left"===p(n,e)}function m(t,e){const n=h(t);return!!n&&"right"===p(n,e)}function y(t){for(let e=0;e<t.length;e++)if(null!=t[e].pinned||null!=t[e].meta?.pinned)return!0;return!1}function b(s,i){const r={groupEndAdjustments:{addGroupEnd:/* @__PURE__ */new Set,removeGroupEnd:/* @__PURE__ */new Set},leftOffsets:/* @__PURE__ */new Map,rightOffsets:/* @__PURE__ */new Map,splitGroups:[]},o=Array.from(s.querySelectorAll(".header-row .cell"));if(!o.length)return r;const l=n(s),d=/* @__PURE__ */new Map,a=/* @__PURE__ */new Map;let c=0;for(const e of i)if(g(e,l)){const n=o.find(t=>t.getAttribute("data-field")===e.field);n&&(d.set(e.field,c),n.classList.add(t),n.style.position="sticky",n.style.left=c+"px",s.querySelectorAll(`.data-grid-row .cell[data-field="${e.field}"]`).forEach(e=>{e.classList.add(t),e.style.position="sticky",e.style.left=c+"px"}),c+=n.offsetWidth)}let f=0;for(const t of[...i].reverse())if(m(t,l)){const n=o.find(e=>e.getAttribute("data-field")===t.field);n&&(a.set(t.field,f),n.classList.add(e),n.style.position="sticky",n.style.right=f+"px",s.querySelectorAll(`.data-grid-row .cell[data-field="${t.field}"]`).forEach(t=>{t.classList.add(e),t.style.position="sticky",t.style.right=f+"px"}),f+=n.offsetWidth)}const u=[],h=function(n,s,i,r,o){const l={addGroupEnd:/* @__PURE__ */new Set,removeGroupEnd:/* @__PURE__ */new Set},d=Array.from(n.querySelectorAll(".header-group-row .header-group-cell"));if(!d.length)return l;for(const a of d){const n=a.style.gridColumn;if(!n)continue;const d=n.match(/^(\d+)\s*\/\s*span\s+(\d+)$/);if(!d)continue;const c=parseInt(d[1],10)-1,f=c+parseInt(d[2],10)-1,u=s.slice(c,f+1);if(!u.length)continue;const h=u.every(t=>g(t,r)),p=u.every(t=>m(t,r));if(h){const e=u[0].field,n=i.find(t=>t.getAttribute("data-field")===e);n&&(a.classList.add(t),a.style.position="sticky",a.style.left=n.style.left)}else if(p){const t=u[u.length-1].field,n=i.find(e=>e.getAttribute("data-field")===t);n&&(a.classList.add(e),a.style.position="sticky",a.style.right=n.style.right)}else if(a.classList.contains("implicit-group"))C(a,u,c,i,r,l);else{const t=u.some(t=>g(t,r)),e=u.some(t=>m(t,r));(t||e)&&E(a,u,c,i,r,l,o)}}return l}(s,i,o,l,u);if(h.addGroupEnd.size>0||h.removeGroupEnd.size>0){for(const t of h.addGroupEnd){const e=o.find(e=>e.getAttribute("data-field")===t);e&&e.classList.add("group-end"),s.querySelectorAll(`.data-grid-row .cell[data-field="${t}"]`).forEach(t=>{t.classList.add("group-end")})}for(const t of h.removeGroupEnd){const e=o.find(e=>e.getAttribute("data-field")===t);e&&e.classList.remove("group-end"),s.querySelectorAll(`.data-grid-row .cell[data-field="${t}"]`).forEach(t=>{t.classList.remove("group-end")})}}return{groupEndAdjustments:h,leftOffsets:d,rightOffsets:a,splitGroups:u}}function v(t,e){return g(t,e)?"left":m(t,e)?"right":"none"}function C(n,s,i,r,o,l){const d=[];for(let t=0;t<s.length;t++){const e=v(s[t],o),n=d[d.length-1];n&&n.state===e?n.cols.push(s[t]):d.push({state:e,cols:[s[t]],colStart:i+t})}if(d.length<=1)return;const a=n.parentElement;if(!a)return;const c=n.nextSibling;a.removeChild(n);for(const f of d){const s=document.createElement("div");if(s.className=n.className,s.setAttribute("data-group",n.getAttribute("data-group")||""),s.style.gridColumn=`${f.colStart+1} / span ${f.cols.length}`,"left"===f.state){const e=f.cols[0].field,n=r.find(t=>t.getAttribute("data-field")===e);n&&(s.classList.add(t),s.style.position="sticky",s.style.left=n.style.left)}else if("right"===f.state){const t=f.cols[f.cols.length-1].field,n=r.find(e=>e.getAttribute("data-field")===t);n&&(s.classList.add(e),s.style.position="sticky",s.style.right=n.style.right)}else"none"===f.state&&f.cols.every(t=>String(t.field||"").startsWith("__tbw_"))&&(s.style.borderRightStyle="none");c?a.insertBefore(s,c):a.appendChild(s)}for(let t=0;t<d.length;t++){const e=d[t],n=d[t+1];if("none"!==e.state&&n&&"none"===n.state){const t=e.cols[e.cols.length-1].field;t&&l.addGroupEnd.add(t)}if("none"===e.state&&e.cols.every(t=>String(t.field||"").startsWith("__tbw_"))){const t=e.cols[e.cols.length-1].field;t&&l.removeGroupEnd.add(t)}}}function E(n,s,i,r,o,l,d){const a=[];for(let t=0;t<s.length;t++){const e=v(s[t],o),n=a[a.length-1];n&&n.state===e?n.cols.push(s[t]):a.push({state:e,cols:[s[t]],colStart:i+t})}if(a.length<=1)return;const c=n.parentElement;if(!c)return;const f=n.textContent||"",u=n.getAttribute("data-group")||"",h=n.nextSibling;c.removeChild(n);const p=a.findIndex(t=>"left"===t.state);let g=-1;for(let t=a.length-1;t>=0;t--)if("right"===a[t].state){g=t;break}const m=p>=0?p:g,y=p>=0&&p+1<a.length?p+1:g>=0&&g-1>=0?g-1:-1;let b,C,E,w="";for(let v=0;v<a.length;v++){const s=a[v],i=document.createElement("div");if(i.className=n.className,i.setAttribute("data-group",u),i.style.gridColumn=`${s.colStart+1} / span ${s.cols.length}`,"left"===s.state){const e=s.cols[0].field,n=r.find(t=>t.getAttribute("data-field")===e);n&&(i.classList.add(t),i.style.position="sticky",i.style.left=n.style.left),v===m&&(i.style.borderRightStyle="none",b=i,w=s.cols[s.cols.length-1].field)}else if("right"===s.state){const t=s.cols[s.cols.length-1].field,n=r.find(e=>e.getAttribute("data-field")===t);n&&(i.classList.add(e),i.style.position="sticky",i.style.right=n.style.right),v===m&&(i.style.borderLeftStyle="none",b=i,w=s.cols[0].field)}if(v===y){i.style.overflow="visible";const t=document.createElement("span");t.textContent=f,t.style.position="relative",t.style.zIndex="36",t.style.display="block",t.style.overflow="hidden",t.style.textOverflow="ellipsis",t.style.whiteSpace="nowrap",i.appendChild(t),C=i,E=t}h?c.insertBefore(i,h):c.appendChild(i)}b&&C&&E&&w&&d.push({groupId:u,label:f,pinnedFragment:b,scrollableFragment:C,floatLabel:E,pinnedField:w,isTransferred:!1,floatOffset:0})}function w(n){n.querySelectorAll(`.${t}, .${e}`).forEach(n=>{n.classList.remove(t,e),n.style.position="",n.style.left="",n.style.right=""})}var A="canMoveColumn",S=class extends u{static manifest={hookPriority:{processColumns:-10},ownedProperties:[{property:"pinned",level:"column",description:'the "pinned" column property',isUsed:t=>"left"===t||"right"===t||"start"===t||"end"===t}],queries:[{type:A,description:"Prevents pinned columns from being moved/reordered"},{type:"getStickyOffsets",description:"Returns the offsets for left/right pinned columns"},{type:"getContextMenuItems",description:"Contributes pin/unpin items to the header context menu"}]};name="pinnedColumns";get defaultConfig(){return{}}isApplied=!1;leftOffsets=/* @__PURE__ */new Map;rightOffsets=/* @__PURE__ */new Map;#n={addGroupEnd:/* @__PURE__ */new Set,removeGroupEnd:/* @__PURE__ */new Set};#s=[];#i=[];#r=/* @__PURE__ */new WeakSet;detach(){this.leftOffsets.clear(),this.rightOffsets.clear(),this.isApplied=!1,this.#n={addGroupEnd:/* @__PURE__ */new Set,removeGroupEnd:/* @__PURE__ */new Set},this.#s=[],this.#i=[],this.#r=/* @__PURE__ */new WeakSet}static detect(t,e){const n=e?.columns;return!!Array.isArray(n)&&y(n)}processColumns(t){const e=[...t];for(const n of e){const t=n.__element;if(!t||this.#r.has(t))continue;if(this.#r.add(t),null!=n.pinned)continue;const e=t.getAttribute("pinned");"left"!==e&&"right"!==e&&"start"!==e&&"end"!==e||(n.pinned=e)}if(this.isApplied=y(e),!this.isApplied)return e;const s=this.gridElement;return function(t,e="ltr"){const n=[],s=[],i=[];for(const r of t){const t=h(r);t?"left"===p(t,e)?n.push(r):i.push(r):s.push(r)}return[...n,...s,...i]}(e,s?n(s):"ltr")}afterRender(){if(!this.isApplied)return;const t=this.gridElement,e=[...this.columns];if(!y(e))return w(t),void(this.isApplied=!1);queueMicrotask(()=>{const n=b(t,e);this.#n=n.groupEndAdjustments,this.leftOffsets=n.leftOffsets,this.rightOffsets=n.rightOffsets,this.#s=n.splitGroups,this.#o()})}afterCellRender(n){if(!this.isApplied)return;const s=n.column.field,i=n.cellElement,r=this.leftOffsets.get(s);if(void 0!==r)i.classList.contains(t)||i.classList.add(t),i.style.position="sticky",i.style.left=r+"px";else{const t=this.rightOffsets.get(s);void 0!==t&&(i.classList.contains(e)||i.classList.add(e),i.style.position="sticky",i.style.right=t+"px")}this.#n.addGroupEnd.has(s)?n.cellElement.classList.add("group-end"):this.#n.removeGroupEnd.has(s)&&n.cellElement.classList.remove("group-end")}onScroll(t){this.#o()}#o(){if(!this.isApplied||0===this.#s.length)return;const t=this.gridElement;for(const e of this.#s){const n=e.pinnedFragment.getBoundingClientRect(),s=e.scrollableFragment.getBoundingClientRect().right<=n.right;if(s&&!e.isTransferred?(e.pinnedFragment.textContent=e.label,e.pinnedFragment.style.overflow="hidden",e.pinnedFragment.style.textOverflow="ellipsis",e.pinnedFragment.style.whiteSpace="nowrap",e.pinnedFragment.style.borderRightStyle="",e.floatLabel.style.visibility="hidden",e.floatLabel.style.transform="",e.floatOffset=0,this.#n.addGroupEnd.add(e.pinnedField),t.querySelectorAll(`.header-row .cell[data-field="${e.pinnedField}"], .data-grid-row .cell[data-field="${e.pinnedField}"]`).forEach(t=>t.classList.add("group-end")),e.isTransferred=!0):!s&&e.isTransferred&&(e.pinnedFragment.textContent="",e.pinnedFragment.style.overflow="",e.pinnedFragment.style.textOverflow="",e.pinnedFragment.style.whiteSpace="",e.pinnedFragment.style.borderRightStyle="none",e.floatLabel.style.visibility="",e.floatLabel.style.transform="",e.floatOffset=0,this.#n.addGroupEnd.delete(e.pinnedField),t.querySelectorAll(`.header-row .cell[data-field="${e.pinnedField}"], .data-grid-row .cell[data-field="${e.pinnedField}"]`).forEach(t=>t.classList.remove("group-end")),e.isTransferred=!1),!e.isTransferred){const t=e.floatLabel.getBoundingClientRect().left-e.floatOffset,s=n.left;t<s?(e.floatOffset=s-t,e.floatLabel.style.transform=`translateX(${e.floatOffset}px)`):(e.floatOffset=0,e.floatLabel.style.transform="")}}}handleQuery(t){switch(t.type){case A:return null==h(t.context)&&void 0;case"getStickyOffsets":return{left:Object.fromEntries(this.leftOffsets),right:Object.fromEntries(this.rightOffsets)};case"getContextMenuItems":{const e=t.context;if(!e.isHeader)return;const n=e.column;if(!n?.field)return;if(n.lockPinning||n.meta?.lockPinning)return;const s=[];return null!=h(n)?s.push({id:"pinned/unpin",label:this.t("pinnedColumns.unpin","Unpin Column"),icon:"📌",order:40,action:()=>this.setPinPosition(n.field,void 0)}):(s.push({id:"pinned/pin-left",label:this.t("pinnedColumns.pinLeft","Pin Left"),icon:"⬅",order:40,action:()=>this.setPinPosition(n.field,"left")}),s.push({id:"pinned/pin-right",label:this.t("pinnedColumns.pinRight","Pin Right"),icon:"➡",order:41,action:()=>this.setPinPosition(n.field,"right")})),s}default:return}}setPinPosition(t,e){const n=this.columns;if(!n?.length)return;const s=n.findIndex(e=>e.field===t);if(-1===s)return;const i=this.gridElement;if(e)0===this.#i.length&&(this.#i=n.map(t=>t.field)),i.columns=n.map(n=>{if(n.field!==t)return n;const s={...n};return s.pinned=e,s});else{const e={...n[s]};delete e.pinned;const r=[...n];r.splice(s,1);const o=this.#i.indexOf(t);if(o>=0){let t=r.length;for(let e=0;e<r.length;e++)if(!h(r[e])&&this.#i.indexOf(r[e].field)>o){t=e;break}r.splice(t,0,e)}else r.splice(Math.min(s,r.length),0,e);r.some(t=>null!=h(t))||(this.#i=[]),i.columns=r}}refreshStickyOffsets(){const t=[...this.columns],e=b(this.gridElement,t);this.#n=e.groupEndAdjustments,this.leftOffsets=e.leftOffsets,this.rightOffsets=e.rightOffsets,this.#s=e.splitGroups}getLeftPinnedColumns(){return function(t,e="ltr"){return t.filter(t=>g(t,e))}([...this.columns],n(this.gridElement))}getRightPinnedColumns(){return function(t,e="ltr"){return t.filter(t=>m(t,e))}([...this.columns],n(this.gridElement))}clearStickyPositions(){w(this.gridElement)}getHorizontalScrollOffsets(n,s){if(!this.isApplied)return;let i=0,r=0;if(n){const s=n.querySelectorAll(`.${t}`),o=n.querySelectorAll(`.${e}`);s.forEach(t=>{i+=t.offsetWidth}),o.forEach(t=>{r+=t.offsetWidth})}else this.gridElement.querySelectorAll(".header-row .cell").forEach(n=>{n.classList.contains(t)?i+=n.offsetWidth:n.classList.contains(e)&&(r+=n.offsetWidth)});const o=s?.classList.contains(t)||s?.classList.contains(e);return{left:i,right:r,skipScroll:o}}};export{S as PinnedColumnsPlugin};
1
+ var t="sticky-left",e="sticky-right";function n(t){try{if("rtl"===getComputedStyle(t).direction)return"rtl"}catch{}try{if("rtl"===t.closest?.("[dir]")?.getAttribute("dir"))return"rtl"}catch{}return"ltr"}var s={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function i(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function r(t,e,n,s){return`${i(n,s)} ${t}: ${e}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(t)}`}var 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("")),l=(new RegExp(`__(proto|defineGetter|defineSetter)|${o.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("|"))),d=/^on\w+$/i,a=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),c=/^\s*(javascript|vbscript|data|blob):/i;function f(t){const e=document.createElement("template");return t&&"string"==typeof t&&(e.innerHTML=t,function(t){const e=[],n=t.querySelectorAll("*");for(const s of n){const t=s.tagName.toLowerCase();if(l.has(t)){e.push(s);continue}if(("svg"===t||"http://www.w3.org/2000/svg"===s.namespaceURI)&&Array.from(s.attributes).some(t=>d.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(s);continue}const n=[];for(const e of s.attributes){const t=e.name.toLowerCase();d.test(t)?n.push(e.name):"is"!==t?(a.has(t)&&c.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&n.push(e.name):n.push(e.name)}n.forEach(t=>s.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content)),e.content}var u=class{static dependencies;static manifest;aliases;version="3.9.0";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},n={};for(const s of Object.keys(e))n[s]=this;for(const s of t){const t=s.userConfig;for(const[i,o]of Object.entries(t)){if(void 0===o)continue;if(!(i in e)){e[i]=o,n[i]=s;continue}if(e[i]===o)continue;const t=n[i]?.constructor.name??this.constructor.name,l=s.constructor.name,d=r("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${i}" supplied by both ${t} and ${l}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(d)}}Object.assign(this.userConfig,e)}refreshUserConfigFrom(t){const e=this.userConfig,n={...t.userConfig};for(const s of Object.keys(e))delete e[s];Object.assign(e,n)}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 n=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(n),n.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 n=this.grid?.query?.(t,e);return Array.isArray(n)?n.some(Boolean):!!n}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{...s,...t}}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(),n=parseInt(e,10);if(!isNaN(n))return n}return 200}setIcon(t,e,n){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const s=this.#e(e,n);var i,r;void 0!==s?"string"==typeof s?(i=t,(r=s)&&"string"==typeof r?-1!==r.indexOf("<")||-1!==r.indexOf("&")?i.replaceChildren(f(r)):i.textContent=r:i.replaceChildren()):s instanceof HTMLElement&&t.replaceChildren(s.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 n=document.createElement("span");n.setAttribute("part","sort-indicator"),n.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(n,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(n,"sortNone"));const s=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return s?t.insertBefore(n,s):t.appendChild(n),n}warn(t,e){void 0!==e?console.warn(r(t,e,this.gridElement.id,this.name)):console.warn(`${i(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(t,e){throw new Error(r(t,e,this.gridElement.id,this.name))}};function h(t){return t.pinned??t.meta?.pinned}function p(t,e){return function(t,e){return"left"===t||"right"===t?t:"rtl"===e?"start"===t?"right":"left":"start"===t?"left":"right"}(t,e)}function g(t,e){const n=h(t);return!!n&&"left"===p(n,e)}function m(t,e){const n=h(t);return!!n&&"right"===p(n,e)}function y(t){for(let e=0;e<t.length;e++)if(null!=t[e].pinned||null!=t[e].meta?.pinned)return!0;return!1}function b(s,i){const r={groupEndAdjustments:{addGroupEnd:/* @__PURE__ */new Set,removeGroupEnd:/* @__PURE__ */new Set},leftOffsets:/* @__PURE__ */new Map,rightOffsets:/* @__PURE__ */new Map,splitGroups:[]},o=Array.from(s.querySelectorAll(".header-row .cell"));if(!o.length)return r;const l=n(s),d=/* @__PURE__ */new Map,a=/* @__PURE__ */new Map;let c=0;for(const e of i)if(g(e,l)){const n=o.find(t=>t.getAttribute("data-field")===e.field);n&&(d.set(e.field,c),n.classList.add(t),n.style.position="sticky",n.style.left=c+"px",s.querySelectorAll(`.data-grid-row .cell[data-field="${e.field}"]`).forEach(e=>{e.classList.add(t),e.style.position="sticky",e.style.left=c+"px"}),c+=n.offsetWidth)}let f=0;for(const t of[...i].reverse())if(m(t,l)){const n=o.find(e=>e.getAttribute("data-field")===t.field);n&&(a.set(t.field,f),n.classList.add(e),n.style.position="sticky",n.style.right=f+"px",s.querySelectorAll(`.data-grid-row .cell[data-field="${t.field}"]`).forEach(t=>{t.classList.add(e),t.style.position="sticky",t.style.right=f+"px"}),f+=n.offsetWidth)}const u=[],h=function(n,s,i,r,o){const l={addGroupEnd:/* @__PURE__ */new Set,removeGroupEnd:/* @__PURE__ */new Set},d=Array.from(n.querySelectorAll(".header-group-row .header-group-cell"));if(!d.length)return l;for(const a of d){const n=a.style.gridColumn;if(!n)continue;const d=n.match(/^(\d+)\s*\/\s*span\s+(\d+)$/);if(!d)continue;const c=parseInt(d[1],10)-1,f=c+parseInt(d[2],10)-1,u=s.slice(c,f+1);if(!u.length)continue;const h=u.every(t=>g(t,r)),p=u.every(t=>m(t,r));if(h){const e=u[0].field,n=i.find(t=>t.getAttribute("data-field")===e);n&&(a.classList.add(t),a.style.position="sticky",a.style.left=n.style.left)}else if(p){const t=u[u.length-1].field,n=i.find(e=>e.getAttribute("data-field")===t);n&&(a.classList.add(e),a.style.position="sticky",a.style.right=n.style.right)}else if(a.classList.contains("implicit-group"))C(a,u,c,i,r,l);else{const t=u.some(t=>g(t,r)),e=u.some(t=>m(t,r));(t||e)&&E(a,u,c,i,r,l,o)}}return l}(s,i,o,l,u);if(h.addGroupEnd.size>0||h.removeGroupEnd.size>0){for(const t of h.addGroupEnd){const e=o.find(e=>e.getAttribute("data-field")===t);e&&e.classList.add("group-end"),s.querySelectorAll(`.data-grid-row .cell[data-field="${t}"]`).forEach(t=>{t.classList.add("group-end")})}for(const t of h.removeGroupEnd){const e=o.find(e=>e.getAttribute("data-field")===t);e&&e.classList.remove("group-end"),s.querySelectorAll(`.data-grid-row .cell[data-field="${t}"]`).forEach(t=>{t.classList.remove("group-end")})}}return{groupEndAdjustments:h,leftOffsets:d,rightOffsets:a,splitGroups:u}}function v(t,e){return g(t,e)?"left":m(t,e)?"right":"none"}function C(n,s,i,r,o,l){const d=[];for(let t=0;t<s.length;t++){const e=v(s[t],o),n=d[d.length-1];n&&n.state===e?n.cols.push(s[t]):d.push({state:e,cols:[s[t]],colStart:i+t})}if(d.length<=1)return;const a=n.parentElement;if(!a)return;const c=n.nextSibling;a.removeChild(n);for(const f of d){const s=document.createElement("div");if(s.className=n.className,s.setAttribute("data-group",n.getAttribute("data-group")||""),s.style.gridColumn=`${f.colStart+1} / span ${f.cols.length}`,"left"===f.state){const e=f.cols[0].field,n=r.find(t=>t.getAttribute("data-field")===e);n&&(s.classList.add(t),s.style.position="sticky",s.style.left=n.style.left)}else if("right"===f.state){const t=f.cols[f.cols.length-1].field,n=r.find(e=>e.getAttribute("data-field")===t);n&&(s.classList.add(e),s.style.position="sticky",s.style.right=n.style.right)}else"none"===f.state&&f.cols.every(t=>String(t.field||"").startsWith("__tbw_"))&&(s.style.borderRightStyle="none");c?a.insertBefore(s,c):a.appendChild(s)}for(let t=0;t<d.length;t++){const e=d[t],n=d[t+1];if("none"!==e.state&&n&&"none"===n.state){const t=e.cols[e.cols.length-1].field;t&&l.addGroupEnd.add(t)}if("none"===e.state&&e.cols.every(t=>String(t.field||"").startsWith("__tbw_"))){const t=e.cols[e.cols.length-1].field;t&&l.removeGroupEnd.add(t)}}}function E(n,s,i,r,o,l,d){const a=[];for(let t=0;t<s.length;t++){const e=v(s[t],o),n=a[a.length-1];n&&n.state===e?n.cols.push(s[t]):a.push({state:e,cols:[s[t]],colStart:i+t})}if(a.length<=1)return;const c=n.parentElement;if(!c)return;const f=n.textContent||"",u=n.getAttribute("data-group")||"",h=n.nextSibling;c.removeChild(n);const p=a.findIndex(t=>"left"===t.state);let g=-1;for(let t=a.length-1;t>=0;t--)if("right"===a[t].state){g=t;break}const m=p>=0?p:g,y=p>=0&&p+1<a.length?p+1:g>=0&&g-1>=0?g-1:-1;let b,C,E,w="";for(let v=0;v<a.length;v++){const s=a[v],i=document.createElement("div");if(i.className=n.className,i.setAttribute("data-group",u),i.style.gridColumn=`${s.colStart+1} / span ${s.cols.length}`,"left"===s.state){const e=s.cols[0].field,n=r.find(t=>t.getAttribute("data-field")===e);n&&(i.classList.add(t),i.style.position="sticky",i.style.left=n.style.left),v===m&&(i.style.borderRightStyle="none",b=i,w=s.cols[s.cols.length-1].field)}else if("right"===s.state){const t=s.cols[s.cols.length-1].field,n=r.find(e=>e.getAttribute("data-field")===t);n&&(i.classList.add(e),i.style.position="sticky",i.style.right=n.style.right),v===m&&(i.style.borderLeftStyle="none",b=i,w=s.cols[0].field)}if(v===y){i.style.overflow="visible";const t=document.createElement("span");t.textContent=f,t.style.position="relative",t.style.zIndex="36",t.style.display="block",t.style.overflow="hidden",t.style.textOverflow="ellipsis",t.style.whiteSpace="nowrap",i.appendChild(t),C=i,E=t}h?c.insertBefore(i,h):c.appendChild(i)}b&&C&&E&&w&&d.push({groupId:u,label:f,pinnedFragment:b,scrollableFragment:C,floatLabel:E,pinnedField:w,isTransferred:!1,floatOffset:0})}function w(n){n.querySelectorAll(`.${t}, .${e}`).forEach(n=>{n.classList.remove(t,e),n.style.position="",n.style.left="",n.style.right=""})}var A="canMoveColumn",S=class extends u{static manifest={hookPriority:{processColumns:-10},ownedProperties:[{property:"pinned",level:"column",description:'the "pinned" column property',isUsed:t=>"left"===t||"right"===t||"start"===t||"end"===t}],queries:[{type:A,description:"Prevents pinned columns from being moved/reordered"},{type:"getStickyOffsets",description:"Returns the offsets for left/right pinned columns"},{type:"getContextMenuItems",description:"Contributes pin/unpin items to the header context menu"}]};name="pinnedColumns";get defaultConfig(){return{}}isApplied=!1;leftOffsets=/* @__PURE__ */new Map;rightOffsets=/* @__PURE__ */new Map;#n={addGroupEnd:/* @__PURE__ */new Set,removeGroupEnd:/* @__PURE__ */new Set};#s=[];#i=[];#r=/* @__PURE__ */new WeakSet;detach(){this.leftOffsets.clear(),this.rightOffsets.clear(),this.isApplied=!1,this.#n={addGroupEnd:/* @__PURE__ */new Set,removeGroupEnd:/* @__PURE__ */new Set},this.#s=[],this.#i=[],this.#r=/* @__PURE__ */new WeakSet}static detect(t,e){const n=e?.columns;return!!Array.isArray(n)&&y(n)}processColumns(t){const e=[...t];for(const n of e){const t=n.__element;if(!t||this.#r.has(t))continue;if(this.#r.add(t),null!=n.pinned)continue;const e=t.getAttribute("pinned");"left"!==e&&"right"!==e&&"start"!==e&&"end"!==e||(n.pinned=e)}if(this.isApplied=y(e),!this.isApplied)return e;const s=this.gridElement;return function(t,e="ltr"){const n=[],s=[],i=[];for(const r of t){const t=h(r);t?"left"===p(t,e)?n.push(r):i.push(r):s.push(r)}return[...n,...s,...i]}(e,s?n(s):"ltr")}afterRender(){if(!this.isApplied)return;const t=this.gridElement,e=[...this.columns];if(!y(e))return w(t),void(this.isApplied=!1);queueMicrotask(()=>{const n=b(t,e);this.#n=n.groupEndAdjustments,this.leftOffsets=n.leftOffsets,this.rightOffsets=n.rightOffsets,this.#s=n.splitGroups,this.#o()})}afterCellRender(n){if(!this.isApplied)return;const s=n.column.field,i=n.cellElement,r=this.leftOffsets.get(s);if(void 0!==r)i.classList.contains(t)||i.classList.add(t),i.style.position="sticky",i.style.left=r+"px";else{const t=this.rightOffsets.get(s);void 0!==t&&(i.classList.contains(e)||i.classList.add(e),i.style.position="sticky",i.style.right=t+"px")}this.#n.addGroupEnd.has(s)?n.cellElement.classList.add("group-end"):this.#n.removeGroupEnd.has(s)&&n.cellElement.classList.remove("group-end")}onScroll(t){this.#o()}#o(){if(!this.isApplied||0===this.#s.length)return;const t=this.gridElement;for(const e of this.#s){const n=e.pinnedFragment.getBoundingClientRect(),s=e.scrollableFragment.getBoundingClientRect().right<=n.right;if(s&&!e.isTransferred?(e.pinnedFragment.textContent=e.label,e.pinnedFragment.style.overflow="hidden",e.pinnedFragment.style.textOverflow="ellipsis",e.pinnedFragment.style.whiteSpace="nowrap",e.pinnedFragment.style.borderRightStyle="",e.floatLabel.style.visibility="hidden",e.floatLabel.style.transform="",e.floatOffset=0,this.#n.addGroupEnd.add(e.pinnedField),t.querySelectorAll(`.header-row .cell[data-field="${e.pinnedField}"], .data-grid-row .cell[data-field="${e.pinnedField}"]`).forEach(t=>t.classList.add("group-end")),e.isTransferred=!0):!s&&e.isTransferred&&(e.pinnedFragment.textContent="",e.pinnedFragment.style.overflow="",e.pinnedFragment.style.textOverflow="",e.pinnedFragment.style.whiteSpace="",e.pinnedFragment.style.borderRightStyle="none",e.floatLabel.style.visibility="",e.floatLabel.style.transform="",e.floatOffset=0,this.#n.addGroupEnd.delete(e.pinnedField),t.querySelectorAll(`.header-row .cell[data-field="${e.pinnedField}"], .data-grid-row .cell[data-field="${e.pinnedField}"]`).forEach(t=>t.classList.remove("group-end")),e.isTransferred=!1),!e.isTransferred){const t=e.floatLabel.getBoundingClientRect().left-e.floatOffset,s=n.left;t<s?(e.floatOffset=s-t,e.floatLabel.style.transform=`translateX(${e.floatOffset}px)`):(e.floatOffset=0,e.floatLabel.style.transform="")}}}handleQuery(t){switch(t.type){case A:return null==h(t.context)&&void 0;case"getStickyOffsets":return{left:Object.fromEntries(this.leftOffsets),right:Object.fromEntries(this.rightOffsets)};case"getContextMenuItems":{const e=t.context;if(!e.isHeader)return;const n=e.column;if(!n?.field)return;if(n.lockPinning||n.meta?.lockPinning)return;const s=[];return null!=h(n)?s.push({id:"pinned/unpin",label:this.t("pinnedColumns.unpin","Unpin Column"),icon:"📌",order:40,action:()=>this.setPinPosition(n.field,void 0)}):(s.push({id:"pinned/pin-left",label:this.t("pinnedColumns.pinLeft","Pin Left"),icon:"⬅",order:40,action:()=>this.setPinPosition(n.field,"left")}),s.push({id:"pinned/pin-right",label:this.t("pinnedColumns.pinRight","Pin Right"),icon:"➡",order:41,action:()=>this.setPinPosition(n.field,"right")})),s}default:return}}setPinPosition(t,e){const n=this.columns;if(!n?.length)return;const s=n.findIndex(e=>e.field===t);if(-1===s)return;const i=this.gridElement;if(e)0===this.#i.length&&(this.#i=n.map(t=>t.field)),i.columns=n.map(n=>{if(n.field!==t)return n;const s={...n};return s.pinned=e,s});else{const e={...n[s]};delete e.pinned;const r=[...n];r.splice(s,1);const o=this.#i.indexOf(t);if(o>=0){let t=r.length;for(let e=0;e<r.length;e++)if(!h(r[e])&&this.#i.indexOf(r[e].field)>o){t=e;break}r.splice(t,0,e)}else r.splice(Math.min(s,r.length),0,e);r.some(t=>null!=h(t))||(this.#i=[]),i.columns=r}}refreshStickyOffsets(){const t=[...this.columns],e=b(this.gridElement,t);this.#n=e.groupEndAdjustments,this.leftOffsets=e.leftOffsets,this.rightOffsets=e.rightOffsets,this.#s=e.splitGroups}getLeftPinnedColumns(){return function(t,e="ltr"){return t.filter(t=>g(t,e))}([...this.columns],n(this.gridElement))}getRightPinnedColumns(){return function(t,e="ltr"){return t.filter(t=>m(t,e))}([...this.columns],n(this.gridElement))}clearStickyPositions(){w(this.gridElement)}getHorizontalScrollOffsets(n,s){if(!this.isApplied)return;let i=0,r=0;if(n){const s=n.querySelectorAll(`.${t}`),o=n.querySelectorAll(`.${e}`);s.forEach(t=>{i+=t.offsetWidth}),o.forEach(t=>{r+=t.offsetWidth})}else this.gridElement.querySelectorAll(".header-row .cell").forEach(n=>{n.classList.contains(t)?i+=n.offsetWidth:n.classList.contains(e)&&(r+=n.offsetWidth)});const o=s?.classList.contains(t)||s?.classList.contains(e);return{left:i,right:r,skipScroll:o}}};export{S as PinnedColumnsPlugin};
2
2
  //# sourceMappingURL=index.js.map