@ishibashi0112/spreadsheet-grid-core 1.0.2 → 1.1.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 (90) hide show
  1. package/dist/controllers/clipboardController.cjs +1 -1
  2. package/dist/controllers/clipboardController.d.ts +3 -0
  3. package/dist/controllers/clipboardController.js +69 -50
  4. package/dist/controllers/columnAutosizeRunner.cjs +1 -1
  5. package/dist/controllers/columnAutosizeRunner.d.ts +1 -0
  6. package/dist/controllers/columnAutosizeRunner.js +10 -9
  7. package/dist/controllers/columnHeaderDragController.cjs +1 -1
  8. package/dist/controllers/columnHeaderDragController.js +169 -168
  9. package/dist/controllers/columnMenuController.cjs +1 -1
  10. package/dist/controllers/columnMenuController.js +71 -69
  11. package/dist/controllers/contextMenuController.cjs +1 -1
  12. package/dist/controllers/contextMenuController.d.ts +4 -1
  13. package/dist/controllers/contextMenuController.js +55 -38
  14. package/dist/controllers/fillHandleController.cjs +1 -1
  15. package/dist/controllers/fillHandleController.d.ts +1 -0
  16. package/dist/controllers/fillHandleController.js +135 -135
  17. package/dist/controllers/historyController.cjs +1 -1
  18. package/dist/controllers/historyController.d.ts +6 -0
  19. package/dist/controllers/historyController.js +79 -37
  20. package/dist/controllers/keyboardController.cjs +1 -1
  21. package/dist/controllers/keyboardController.d.ts +1 -0
  22. package/dist/controllers/keyboardController.js +4 -0
  23. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  24. package/dist/controllers/pointerInteractionsController.d.ts +1 -0
  25. package/dist/controllers/pointerInteractionsController.js +142 -142
  26. package/dist/controllers/popoverSupport.cjs +1 -1
  27. package/dist/controllers/popoverSupport.d.ts +1 -0
  28. package/dist/controllers/popoverSupport.js +9 -4
  29. package/dist/controllers/rowDragController.cjs +1 -1
  30. package/dist/controllers/rowDragController.d.ts +1 -0
  31. package/dist/controllers/rowDragController.js +145 -144
  32. package/dist/controllers/toolPanelController.cjs +1 -1
  33. package/dist/controllers/toolPanelController.js +26 -14
  34. package/dist/controllers/tooltipController.cjs +1 -1
  35. package/dist/controllers/tooltipController.js +74 -72
  36. package/dist/controllers/viewportSyncController.cjs +1 -1
  37. package/dist/controllers/viewportSyncController.d.ts +3 -1
  38. package/dist/controllers/viewportSyncController.js +66 -28
  39. package/dist/engine/exportCommands.cjs +1 -1
  40. package/dist/engine/exportCommands.js +16 -9
  41. package/dist/engine/gridApi.cjs +2 -2
  42. package/dist/engine/gridApi.d.ts +6 -2
  43. package/dist/engine/gridApi.js +5 -5
  44. package/dist/index.cjs +1 -1
  45. package/dist/index.d.ts +3 -1
  46. package/dist/index.js +7 -6
  47. package/dist/locales/en.cjs +1 -1
  48. package/dist/locales/en.js +3 -0
  49. package/dist/logic/autoScrollGeometry.cjs +1 -1
  50. package/dist/logic/autoScrollGeometry.d.ts +2 -0
  51. package/dist/logic/autoScrollGeometry.js +3 -3
  52. package/dist/logic/editorValues.cjs +1 -1
  53. package/dist/logic/editorValues.js +37 -34
  54. package/dist/logic/exportCsv.cjs +3 -3
  55. package/dist/logic/exportCsv.d.ts +3 -1
  56. package/dist/logic/exportCsv.js +22 -20
  57. package/dist/logic/exportData.cjs +1 -1
  58. package/dist/logic/exportData.d.ts +3 -1
  59. package/dist/logic/exportData.js +40 -36
  60. package/dist/logic/filtering.cjs +1 -1
  61. package/dist/logic/filtering.d.ts +2 -1
  62. package/dist/logic/filtering.js +16 -3
  63. package/dist/logic/groupExport.cjs +1 -1
  64. package/dist/logic/groupExport.js +28 -27
  65. package/dist/logic/grouping.cjs +1 -1
  66. package/dist/logic/grouping.d.ts +1 -0
  67. package/dist/logic/grouping.js +52 -41
  68. package/dist/logic/historyRebase.cjs +1 -0
  69. package/dist/logic/historyRebase.d.ts +5 -0
  70. package/dist/logic/historyRebase.js +36 -0
  71. package/dist/logic/localeTextFeatures.cjs +1 -1
  72. package/dist/logic/localeTextFeatures.d.ts +4 -0
  73. package/dist/logic/localeTextFeatures.js +8 -5
  74. package/dist/logic/localeTextPopups.cjs +1 -1
  75. package/dist/logic/localeTextPopups.d.ts +1 -0
  76. package/dist/logic/localeTextPopups.js +1 -0
  77. package/dist/logic/selectLabels.cjs +1 -0
  78. package/dist/logic/selectLabels.d.ts +3 -0
  79. package/dist/logic/selectLabels.js +41 -0
  80. package/dist/logic/valueParsers.cjs +1 -0
  81. package/dist/logic/valueParsers.d.ts +14 -0
  82. package/dist/logic/valueParsers.js +23 -0
  83. package/dist/model/gridTypes.core.d.ts +174 -18
  84. package/dist/utils/clipboard.cjs +4 -4
  85. package/dist/utils/clipboard.d.ts +14 -2
  86. package/dist/utils/clipboard.js +101 -49
  87. package/dist/utils/popupContainer.cjs +1 -0
  88. package/dist/utils/popupContainer.d.ts +8 -0
  89. package/dist/utils/popupContainer.js +60 -0
  90. package/package.json +1 -1
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/rowReorder.cjs"),t=require("../logic/detailRow.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/elementScale.cjs"),i=require("./escapeClaimController.cjs"),a=require("../logic/slotDom.cjs"),o=require("../utils/portalTokens.cjs");var s=14,c=12,l=`0.5`,u=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="8 6 12 2 16 6"/><polyline points="16 18 12 22 8 18"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,d=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,f=200,p=`cubic-bezier(0.2, 0.7, 0.3, 1)`,m=`transform 160ms ${p}`,h=`data-ssg-row-dragging`,g=e=>e?.closest(`.ssg-motion-off`)!=null,_=/translateY\((-?[\d.]+)px\)/,v=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},y=e=>{let n=[],r=new Map;return e.querySelectorAll(`.ssg-detail-band[data-detail-row-index]`).forEach(i=>{if(t.isInsideDetailCardOf(e,i))return;let a=Number(i.getAttribute(`data-detail-row-index`)),o=r.get(a)??0;r.set(a,o+1),n.push({el:i,index:a,key:`band|${o}|${a}`})}),n},b=e=>{e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.zIndex=``},x=()=>{let x=null,S=null,C=null,w={x:0,y:0},T=null,E=!1,D=null,O=null,k=null,A=null,j=null,M=null,N=0,P=null,F=()=>x?.motion===`live`,I=null,L=null,R=null,z=()=>[x?.leftIndicatorRef.current??null,x?.centerIndicatorRef.current??null,x?.rightIndicatorRef.current??null],B=()=>{for(let e of z())e&&(e.style.display=`none`)},V=e=>{if(I)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),x?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),x?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),x?.scrollContainerRef.current?.closest(`.ssg-motion-off`)!=null&&t.classList.add(`ssg-motion-off`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`max-width:280px`,`overflow:hidden`,`text-overflow:ellipsis`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`),a.applySlotToElement(t,x?.ghostSlot);let n=document.createElement(`span`);n.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let r=document.createElement(`span`);r.style.cssText=`overflow:hidden;text-overflow:ellipsis`,r.textContent=e,t.appendChild(n),t.appendChild(r),document.body.appendChild(t),o.syncPortalTokens(x?.scrollContainerRef.current,t),I=t,L=n,R=null},H=e=>{let t=I;if(!t)return;t.style.transform=`translate(`+(w.x+s)+`px,`+(w.y+c)+`px)`;let n=e?`move`:`out`;if(R===n)return;R=n;let r=L;n===`out`?(t.style.opacity=l,r&&(r.innerHTML=d)):(t.style.opacity=`1`,r&&(r.innerHTML=u))},U=()=>{I&&I.parentNode&&I.parentNode.removeChild(I),I=null,L=null,R=null},W=(e,n)=>{let r=x?.scrollContainerRef.current??null;!r||n&&e===null||r.querySelectorAll(n?`.ssg-body-row[data-row-index="${e}"]`:`.ssg-body-row[${h}]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(h,F()?`live`:``):e.removeAttribute(h))})},G=()=>{let e=x?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of v(e)){let e=_.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},K=t=>{let n=M,r=S;if(!n||r===null||x===null)return;let i=x.scrollContainerRef.current;if(!i)return;for(let e of v(i)){if(n.has(e))continue;let t=_.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=x.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-N)*x.verticalScaleFactor,s=(T?w.y-T.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{let{index:i,baseY:o}=e;if(!t.isConnected){n.delete(t);return}if(i===r){t.style.transition=`none`,t.style.transform=`translateY(${o+s}px)`,t.style.willChange=`transform`,e.applied=t.style.transform;return}let l=0;c!==null&&(r<i&&i<=c?l=-a:c<=i&&i<r&&(l=a)),t.style.transition=m,t.style.transform=`translateY(${o+l}px)`,e.applied=t.style.transform});let l=P??new Set;P=l;for(let{el:e,index:t}of y(i)){if(l.add(e),t===r){e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,e.style.zIndex=`10`;continue}let n=0;c!==null&&(r<t&&t<=c?n=-a:c<=t&&t<r&&(n=a)),e.style.transition=m,e.style.transform=`translateY(${n}px)`,e.style.zIndex=``}},q=(t,r)=>{if(x===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=x,u=i.current,d=a.current;if(!u||!d)return null;let f=u.getBoundingClientRect();if(t<f.left||t>f.right||r<f.top||r>f.bottom)return null;let p=n.clampClientYAboveFooter(r,f.top+u.clientTop+u.clientHeight,x.footerHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=S,v=_!==null&&F()?o.detailHeight(_):0;if(_!==null&&v>0){let t=e.resolveRowDropSlot(h+v,o);t>_+1&&(g=t)}let y=e.resolveRowDropSlotTop(g,o);return{slot:g,top:s+y-l}},J=()=>{let t=q(w.x,w.y),n=S;if(F()){t&&n!==null&&(C=e.resolveMoveTargetIndex(n,t.slot)===null?null:t.slot),B(),K(C);return}if(H(t),!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){C=null,B();return}C=t.slot;for(let e of z())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},Y=()=>{if(S===null){k=null;return}let e=x?.scrollContainerRef.current??null;if(e&&(E||(!T||n.hasPointerLeftActivationRadius(T,w,6))&&(E=!0),E)){let t=e.getBoundingClientRect(),i=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight,scale:r.resolveElementScale(e,t)}),a=n.resolveAutoScrollAxisDirection(w.y,i.top,i.bottom-(x?.footerHeight??0),24),o=n.computeNextScrollPosition(e.scrollTop,a,18,e.scrollHeight-e.clientHeight);o!==e.scrollTop&&e.scrollTo({top:o,behavior:`auto`})}J(),k=requestAnimationFrame(Y)},X=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,Z=()=>{let e=x?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of v(e))t.set(X(n,Number(n.getAttribute(`data-row-index`))),n.getBoundingClientRect().top);for(let n of y(e))t.set(n.key,n.el.getBoundingClientRect().top);return t},Q=t=>{k!==null&&(cancelAnimationFrame(k),k=null),document.body.style.cursor=``,B(),U();let n=S,r=C,i=j;W(n,!1),S=null,j=null,C=null,T=null,O=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=t&&n!==null&&a!==null&&x!==null,s=M;M=null;let c=s&&o&&x!==null&&!g(x.scrollContainerRef.current)?Z():null,l=P;if(P=null,l&&(o?l.forEach(b):(l.forEach(e=>{e.isConnected&&(e.style.transition=m,e.style.transform=`translateY(0px)`,e.style.zIndex=``)}),window.setTimeout(()=>{l.forEach(e=>{P?.has(e)||b(e)})},200))),s)if(o)s.forEach(({baseY:e},t)=>{t.style.transition=``,t.style.willChange=``,t.isConnected&&(t.style.transform=`translateY(${e}px)`)});else{let e=[];s.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=m,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}if(!o||n===null||a===null||x===null)return;let u=c??(g(x.scrollContainerRef.current)?null:Z()),d=u?{tops:u,from:n,to:a,row:i}:null;A=d,x.commitRowMove(n,a),d&&requestAnimationFrame(()=>{A===d&&(A=null)})},$=()=>{let e=A;if(A=null,!e)return;let t=x?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(x?.locateDragRow&&e.row!==null&&x.locateDragRow(e.row,i)!==i)return;let a=e=>e===i?r:r<i&&e>=r&&e<i?e+1:i<r&&e>i&&e<=r?e-1:e,o=[],s=new Map;v(t).forEach(e=>{let t=n.get(X(e,a(Number(e.getAttribute(`data-row-index`)))));if(t===void 0)return;let r=t-e.getBoundingClientRect().top;if(Math.abs(r)<.5)return;let i=_.exec(e.style.transform);if(!i)return;let c=parseFloat(i[1]);s.set(e,c),e.style.transition=`none`,e.style.transform=`translateY(${c+r}px)`,e.style.willChange=`transform`,o.push(e)});let c=[];if(y(t).forEach(({el:e,index:t,key:r})=>{let i=a(t),o=n.get(r.slice(0,r.lastIndexOf(`|`)+1)+i);if(o===void 0)return;let s=o-e.getBoundingClientRect().top;Math.abs(s)<.5||(e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,c.push(e))}),!(o.length===0&&c.length===0)){t.getBoundingClientRect();for(let e of o)e.style.transition=`transform ${f}ms ${p}`,e.style.transform=`translateY(${s.get(e)??0}px)`;for(let e of c)e.style.transition=`transform ${f}ms ${p}`,e.style.transform=`translateY(0px)`;window.setTimeout(()=>{for(let e of o)e.style.transition=``,e.style.willChange=``;for(let e of c)P?.has(e)||b(e)},280)}},ee=(e,t)=>{if(x===null||!x.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),x.gridRootRef?.current?.focus({preventScroll:!0}),S!==null){if(t.pointerId!==O)return;D?.(),Q(!1)}S=e,j=x.getDragRow?.(e)??null,O=t.pointerId,C=null,w={x:t.clientX,y:t.clientY},T={x:t.clientX,y:t.clientY},E=!1,document.body.style.cursor=`grabbing`,F()?(M=G(),N=x.scrollContainerRef.current?.scrollTop??0):V(x.getRowDragLabel(e)),W(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&(w={x:e.clientX,y:e.clientY},J())},o=i.beginEscapeCancelableDrag(),s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,l),window.removeEventListener(`keydown`,u,!0),window.removeEventListener(`blur`,d),o(),D=null;try{n.releasePointerCapture(r)}catch{}};function c(e){e.pointerId===r&&(s(),Q(!0))}function l(e){e.pointerId===r&&(s(),Q(!1))}function u(e){e.key===`Escape`&&(s(),Q(!1))}function d(){s(),Q(!1)}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,l),window.addEventListener(`keydown`,u,!0),window.addEventListener(`blur`,d),D=s,J(),k=requestAnimationFrame(Y)},te=e=>{if(S===null||j==null||x?.locateDragRow===void 0)return;let t=x.locateDragRow(j,S);if(M&&M.forEach((e,t)=>{if(!t.isConnected){M?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`));if(n===e.index&&(e.applied===void 0||t.style.transform===e.applied))return;let r=_.exec(t.style.transform);if(!r){M?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){D?.(),Q(!1);return}M&&t!==S&&T!==null&&e!==null&&(T={x:T.x,y:T.y+x.rowMetrics.rowTop(t)-e.rowTop(S)}),t!==S&&(W(null,!1),S=t,W(t,!0)),J()};return{update:e=>{let t=x;x=e,S!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&te(t.rowMetrics)},onRowDragHandlePointerDown:ee,applyReorderSettle:$,dispose:()=>{D?.(),D=null,k!==null&&(cancelAnimationFrame(k),k=null),document.body.style.cursor=``,U(),W(S,!1),S=null,j=null,C=null,M=null,P?.forEach(b),P=null,A=null}}};exports.createRowDragController=x;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/rowReorder.cjs"),t=require("../logic/detailRow.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/elementScale.cjs"),i=require("./escapeClaimController.cjs"),a=require("../logic/slotDom.cjs"),o=require("../utils/portalTokens.cjs"),s=require("../utils/popupContainer.cjs");var c=14,l=12,u=`0.5`,d=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="8 6 12 2 16 6"/><polyline points="16 18 12 22 8 18"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,f=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,p=200,m=`cubic-bezier(0.2, 0.7, 0.3, 1)`,h=`transform 160ms ${m}`,g=`data-ssg-row-dragging`,_=e=>e?.closest(`.ssg-motion-off`)!=null,v=/translateY\((-?[\d.]+)px\)/,y=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},b=e=>{let n=[],r=new Map;return e.querySelectorAll(`.ssg-detail-band[data-detail-row-index]`).forEach(i=>{if(t.isInsideDetailCardOf(e,i))return;let a=Number(i.getAttribute(`data-detail-row-index`)),o=r.get(a)??0;r.set(a,o+1),n.push({el:i,index:a,key:`band|${o}|${a}`})}),n},x=e=>{e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.zIndex=``},S=()=>{let S=null,C=null,w=null,T={x:0,y:0},E=null,D=!1,O=null,k=null,A=null,j=null,M=null,N=null,P=0,F=null,I=()=>S?.motion===`live`,L=null,R=null,z=null,B=()=>[S?.leftIndicatorRef.current??null,S?.centerIndicatorRef.current??null,S?.rightIndicatorRef.current??null],V=()=>{for(let e of B())e&&(e.style.display=`none`)},H=e=>{if(L)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),S?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),S?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),S?.scrollContainerRef.current?.closest(`.ssg-motion-off`)!=null&&t.classList.add(`ssg-motion-off`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`max-width:280px`,`overflow:hidden`,`text-overflow:ellipsis`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`),a.applySlotToElement(t,S?.ghostSlot);let n=document.createElement(`span`);n.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let r=document.createElement(`span`);r.style.cssText=`overflow:hidden;text-overflow:ellipsis`,r.textContent=e,t.appendChild(n),t.appendChild(r),s.appendToPopupContainer(t,s.getPopupContainerFor(S?.scrollContainerRef.current)),o.syncPortalTokens(S?.scrollContainerRef.current,t),L=t,R=n,z=null},U=e=>{let t=L;if(!t)return;t.style.transform=`translate(`+(T.x+c)+`px,`+(T.y+l)+`px)`;let n=e?`move`:`out`;if(z===n)return;z=n;let r=R;n===`out`?(t.style.opacity=u,r&&(r.innerHTML=f)):(t.style.opacity=`1`,r&&(r.innerHTML=d))},W=()=>{L&&L.parentNode&&L.parentNode.removeChild(L),L=null,R=null,z=null},G=(e,n)=>{let r=S?.scrollContainerRef.current??null;!r||n&&e===null||r.querySelectorAll(n?`.ssg-body-row[data-row-index="${e}"]`:`.ssg-body-row[${g}]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(g,I()?`live`:``):e.removeAttribute(g))})},K=()=>{let e=S?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e)){let e=v.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},q=t=>{let n=N,r=C;if(!n||r===null||S===null)return;let i=S.scrollContainerRef.current;if(!i)return;for(let e of y(i)){if(n.has(e))continue;let t=v.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=S.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-P)*S.verticalScaleFactor,s=(E?T.y-E.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{let{index:i,baseY:o}=e;if(!t.isConnected){n.delete(t);return}if(i===r){t.style.transition=`none`,t.style.transform=`translateY(${o+s}px)`,t.style.willChange=`transform`,e.applied=t.style.transform;return}let l=0;c!==null&&(r<i&&i<=c?l=-a:c<=i&&i<r&&(l=a)),t.style.transition=h,t.style.transform=`translateY(${o+l}px)`,e.applied=t.style.transform});let l=F??new Set;F=l;for(let{el:e,index:t}of b(i)){if(l.add(e),t===r){e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,e.style.zIndex=`10`;continue}let n=0;c!==null&&(r<t&&t<=c?n=-a:c<=t&&t<r&&(n=a)),e.style.transition=h,e.style.transform=`translateY(${n}px)`,e.style.zIndex=``}},J=(t,r)=>{if(S===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=S,u=i.current,d=a.current;if(!u||!d)return null;let f=u.getBoundingClientRect();if(t<f.left||t>f.right||r<f.top||r>f.bottom)return null;let p=n.clampClientYBelowHeader(n.clampClientYAboveFooter(r,f.top+u.clientTop+u.clientHeight,S.footerHeight??0),f.top+u.clientTop,S.stickyTopHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=C,v=_!==null&&I()?o.detailHeight(_):0;if(_!==null&&v>0){let t=e.resolveRowDropSlot(h+v,o);t>_+1&&(g=t)}let y=e.resolveRowDropSlotTop(g,o);return{slot:g,top:s+y-l}},Y=()=>{let t=J(T.x,T.y),n=C;if(I()){t&&n!==null&&(w=e.resolveMoveTargetIndex(n,t.slot)===null?null:t.slot),V(),q(w);return}if(U(t),!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){w=null,V();return}w=t.slot;for(let e of B())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},X=()=>{if(C===null){A=null;return}let e=S?.scrollContainerRef.current??null;if(e&&(D||(!E||n.hasPointerLeftActivationRadius(E,T,6))&&(D=!0),D)){let t=e.getBoundingClientRect(),i=r.resolveElementScale(e,t),a=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight,scale:i}),o=n.resolveAutoScrollAxisDirection(T.y,n.resolveTopAutoScrollStart(a.top,(S?.stickyTopHeight??0)*i.y,24),a.bottom-(S?.footerHeight??0),24),s=n.computeNextScrollPosition(e.scrollTop,o,18,e.scrollHeight-e.clientHeight);s!==e.scrollTop&&e.scrollTo({top:s,behavior:`auto`})}Y(),A=requestAnimationFrame(X)},Z=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,Q=()=>{let e=S?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e))t.set(Z(n,Number(n.getAttribute(`data-row-index`))),n.getBoundingClientRect().top);for(let n of b(e))t.set(n.key,n.el.getBoundingClientRect().top);return t},$=t=>{A!==null&&(cancelAnimationFrame(A),A=null),document.body.style.cursor=``,V(),W();let n=C,r=w,i=M;G(n,!1),C=null,M=null,w=null,E=null,k=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=t&&n!==null&&a!==null&&S!==null,s=N;N=null;let c=s&&o&&S!==null&&!_(S.scrollContainerRef.current)?Q():null,l=F;if(F=null,l&&(o?l.forEach(x):(l.forEach(e=>{e.isConnected&&(e.style.transition=h,e.style.transform=`translateY(0px)`,e.style.zIndex=``)}),window.setTimeout(()=>{l.forEach(e=>{F?.has(e)||x(e)})},200))),s)if(o)s.forEach(({baseY:e},t)=>{t.style.transition=``,t.style.willChange=``,t.isConnected&&(t.style.transform=`translateY(${e}px)`)});else{let e=[];s.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=h,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}if(!o||n===null||a===null||S===null)return;let u=c??(_(S.scrollContainerRef.current)?null:Q()),d=u?{tops:u,from:n,to:a,row:i}:null;j=d,S.commitRowMove(n,a),d&&requestAnimationFrame(()=>{j===d&&(j=null)})},ee=()=>{let e=j;if(j=null,!e)return;let t=S?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(S?.locateDragRow&&e.row!==null&&S.locateDragRow(e.row,i)!==i)return;let a=e=>e===i?r:r<i&&e>=r&&e<i?e+1:i<r&&e>i&&e<=r?e-1:e,o=[],s=new Map;y(t).forEach(e=>{let t=n.get(Z(e,a(Number(e.getAttribute(`data-row-index`)))));if(t===void 0)return;let r=t-e.getBoundingClientRect().top;if(Math.abs(r)<.5)return;let i=v.exec(e.style.transform);if(!i)return;let c=parseFloat(i[1]);s.set(e,c),e.style.transition=`none`,e.style.transform=`translateY(${c+r}px)`,e.style.willChange=`transform`,o.push(e)});let c=[];if(b(t).forEach(({el:e,index:t,key:r})=>{let i=a(t),o=n.get(r.slice(0,r.lastIndexOf(`|`)+1)+i);if(o===void 0)return;let s=o-e.getBoundingClientRect().top;Math.abs(s)<.5||(e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,c.push(e))}),!(o.length===0&&c.length===0)){t.getBoundingClientRect();for(let e of o)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateY(${s.get(e)??0}px)`;for(let e of c)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateY(0px)`;window.setTimeout(()=>{for(let e of o)e.style.transition=``,e.style.willChange=``;for(let e of c)F?.has(e)||x(e)},280)}},te=(e,t)=>{if(S===null||!S.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),S.gridRootRef?.current?.focus({preventScroll:!0}),C!==null){if(t.pointerId!==k)return;O?.(),$(!1)}C=e,M=S.getDragRow?.(e)??null,k=t.pointerId,w=null,T={x:t.clientX,y:t.clientY},E={x:t.clientX,y:t.clientY},D=!1,document.body.style.cursor=`grabbing`,I()?(N=K(),P=S.scrollContainerRef.current?.scrollTop??0):H(S.getRowDragLabel(e)),G(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&(T={x:e.clientX,y:e.clientY},Y())},o=i.beginEscapeCancelableDrag(),s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,l),window.removeEventListener(`keydown`,u,!0),window.removeEventListener(`blur`,d),o(),O=null;try{n.releasePointerCapture(r)}catch{}};function c(e){e.pointerId===r&&(s(),$(!0))}function l(e){e.pointerId===r&&(s(),$(!1))}function u(e){e.key===`Escape`&&(s(),$(!1))}function d(){s(),$(!1)}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,l),window.addEventListener(`keydown`,u,!0),window.addEventListener(`blur`,d),O=s,Y(),A=requestAnimationFrame(X)},ne=e=>{if(C===null||M==null||S?.locateDragRow===void 0)return;let t=S.locateDragRow(M,C);if(N&&N.forEach((e,t)=>{if(!t.isConnected){N?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`));if(n===e.index&&(e.applied===void 0||t.style.transform===e.applied))return;let r=v.exec(t.style.transform);if(!r){N?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){O?.(),$(!1);return}N&&t!==C&&E!==null&&e!==null&&(E={x:E.x,y:E.y+S.rowMetrics.rowTop(t)-e.rowTop(C)}),t!==C&&(G(null,!1),C=t,G(t,!0)),Y()};return{update:e=>{let t=S;S=e,C!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&ne(t.rowMetrics)},onRowDragHandlePointerDown:te,applyReorderSettle:ee,dispose:()=>{O?.(),O=null,A!==null&&(cancelAnimationFrame(A),A=null),document.body.style.cursor=``,W(),G(C,!1),C=null,M=null,w=null,N=null,F?.forEach(x),F=null,j=null}}};exports.createRowDragController=S;
@@ -8,6 +8,7 @@ export type RowDragArgs = {
8
8
  rowMetrics: RowMetrics;
9
9
  headerHeight: number;
10
10
  footerHeight?: number;
11
+ stickyTopHeight?: number;
11
12
  verticalScaleFactor: number;
12
13
  windowBaseOffsetPx: number;
13
14
  scrollContainerRef: ReadonlyRef<HTMLElement | null>;
@@ -1,17 +1,18 @@
1
1
  import { resolveMoveTargetIndex as e, resolveRowDropSlot as t, resolveRowDropSlotTop as n } from "../logic/rowReorder.js";
2
2
  import { isInsideDetailCardOf as r } from "../logic/detailRow.js";
3
- import { clampClientYAboveFooter as i, computeNextScrollPosition as a, hasPointerLeftActivationRadius as o, resolveAutoScrollAxisDirection as s, resolveScrollContentBox as c } from "../logic/autoScrollGeometry.js";
4
- import { resolveElementScale as l } from "../logic/elementScale.js";
5
- import { beginEscapeCancelableDrag as u } from "./escapeClaimController.js";
6
- import { applySlotToElement as d } from "../logic/slotDom.js";
7
- import { syncPortalTokens as f } from "../utils/portalTokens.js";
3
+ import { clampClientYAboveFooter as i, clampClientYBelowHeader as a, computeNextScrollPosition as o, hasPointerLeftActivationRadius as s, resolveAutoScrollAxisDirection as c, resolveScrollContentBox as l, resolveTopAutoScrollStart as u } from "../logic/autoScrollGeometry.js";
4
+ import { resolveElementScale as d } from "../logic/elementScale.js";
5
+ import { beginEscapeCancelableDrag as f } from "./escapeClaimController.js";
6
+ import { applySlotToElement as p } from "../logic/slotDom.js";
7
+ import { syncPortalTokens as m } from "../utils/portalTokens.js";
8
+ import { appendToPopupContainer as h, getPopupContainerFor as g } from "../utils/popupContainer.js";
8
9
  //#region src/controllers/rowDragController.ts
9
- var p = 14, m = 12, h = "0.5", g = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"8 6 12 2 16 6\"/><polyline points=\"16 18 12 22 8 18\"/><line x1=\"12\" y1=\"2\" x2=\"12\" y2=\"22\"/></svg>", _ = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"4.9\" y1=\"4.9\" x2=\"19.1\" y2=\"19.1\"/></svg>", v = 200, y = "cubic-bezier(0.2, 0.7, 0.3, 1)", b = `transform 160ms ${y}`, x = "data-ssg-row-dragging", S = (e) => e?.closest(".ssg-motion-off") != null, C = /translateY\((-?[\d.]+)px\)/, w = (e) => {
10
+ var _ = 14, v = 12, y = "0.5", b = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"8 6 12 2 16 6\"/><polyline points=\"16 18 12 22 8 18\"/><line x1=\"12\" y1=\"2\" x2=\"12\" y2=\"22\"/></svg>", ee = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"4.9\" y1=\"4.9\" x2=\"19.1\" y2=\"19.1\"/></svg>", x = 200, S = "cubic-bezier(0.2, 0.7, 0.3, 1)", C = `transform 160ms ${S}`, w = "data-ssg-row-dragging", T = (e) => e?.closest(".ssg-motion-off") != null, E = /translateY\((-?[\d.]+)px\)/, D = (e) => {
10
11
  let t = [];
11
12
  return e.querySelectorAll(".ssg-body-row[data-row-index]").forEach((n) => {
12
13
  r(e, n) || t.push(n);
13
14
  }), t;
14
- }, T = (e) => {
15
+ }, O = (e) => {
15
16
  let t = [], n = /* @__PURE__ */ new Map();
16
17
  return e.querySelectorAll(".ssg-detail-band[data-detail-row-index]").forEach((i) => {
17
18
  if (r(e, i)) return;
@@ -22,22 +23,22 @@ var p = 14, m = 12, h = "0.5", g = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
22
23
  key: `band|${o}|${a}`
23
24
  });
24
25
  }), t;
25
- }, E = (e) => {
26
+ }, k = (e) => {
26
27
  e.style.transition = "", e.style.transform = "", e.style.willChange = "", e.style.zIndex = "";
27
- }, D = () => {
28
- let D = null, O = null, k = null, A = {
28
+ }, A = () => {
29
+ let A = null, j = null, M = null, N = {
29
30
  x: 0,
30
31
  y: 0
31
- }, j = null, M = !1, N = null, P = null, F = null, I = null, L = null, R = null, z = 0, B = null, V = () => D?.motion === "live", H = null, U = null, W = null, G = () => [
32
- D?.leftIndicatorRef.current ?? null,
33
- D?.centerIndicatorRef.current ?? null,
34
- D?.rightIndicatorRef.current ?? null
35
- ], K = () => {
36
- for (let e of G()) e && (e.style.display = "none");
37
- }, ee = (e) => {
38
- if (H) return;
32
+ }, P = null, F = !1, I = null, L = null, R = null, z = null, B = null, V = null, H = 0, U = null, W = () => A?.motion === "live", G = null, K = null, q = null, J = () => [
33
+ A?.leftIndicatorRef.current ?? null,
34
+ A?.centerIndicatorRef.current ?? null,
35
+ A?.rightIndicatorRef.current ?? null
36
+ ], Y = () => {
37
+ for (let e of J()) e && (e.style.display = "none");
38
+ }, te = (e) => {
39
+ if (G) return;
39
40
  let t = document.createElement("div");
40
- t.setAttribute("data-grid-drag-ghost", ""), D?.scrollContainerRef.current?.closest(".ssg-theme-dark") != null && t.classList.add("ssg-theme-dark"), D?.scrollContainerRef.current?.closest(".ssg-theme-class") != null && t.classList.add("ssg-theme-class"), D?.scrollContainerRef.current?.closest(".ssg-motion-off") != null && t.classList.add("ssg-motion-off"), t.style.cssText = [
41
+ t.setAttribute("data-grid-drag-ghost", ""), A?.scrollContainerRef.current?.closest(".ssg-theme-dark") != null && t.classList.add("ssg-theme-dark"), A?.scrollContainerRef.current?.closest(".ssg-theme-class") != null && t.classList.add("ssg-theme-class"), A?.scrollContainerRef.current?.closest(".ssg-motion-off") != null && t.classList.add("ssg-motion-off"), t.style.cssText = [
41
42
  "position:fixed",
42
43
  "top:0",
43
44
  "left:0",
@@ -62,53 +63,53 @@ var p = 14, m = 12, h = "0.5", g = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
62
63
  "z-index:9999",
63
64
  "will-change:transform",
64
65
  "transform:translate(-9999px,-9999px)"
65
- ].join(";"), d(t, D?.ghostSlot);
66
+ ].join(";"), p(t, A?.ghostSlot);
66
67
  let n = document.createElement("span");
67
68
  n.style.cssText = "display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none";
68
69
  let r = document.createElement("span");
69
- r.style.cssText = "overflow:hidden;text-overflow:ellipsis", r.textContent = e, t.appendChild(n), t.appendChild(r), document.body.appendChild(t), f(D?.scrollContainerRef.current, t), H = t, U = n, W = null;
70
- }, te = (e) => {
71
- let t = H;
70
+ r.style.cssText = "overflow:hidden;text-overflow:ellipsis", r.textContent = e, t.appendChild(n), t.appendChild(r), h(t, g(A?.scrollContainerRef.current)), m(A?.scrollContainerRef.current, t), G = t, K = n, q = null;
71
+ }, ne = (e) => {
72
+ let t = G;
72
73
  if (!t) return;
73
- t.style.transform = "translate(" + (A.x + p) + "px," + (A.y + m) + "px)";
74
+ t.style.transform = "translate(" + (N.x + _) + "px," + (N.y + v) + "px)";
74
75
  let n = e ? "move" : "out";
75
- if (W === n) return;
76
- W = n;
77
- let r = U;
78
- n === "out" ? (t.style.opacity = h, r && (r.innerHTML = _)) : (t.style.opacity = "1", r && (r.innerHTML = g));
79
- }, q = () => {
80
- H && H.parentNode && H.parentNode.removeChild(H), H = null, U = null, W = null;
81
- }, J = (e, t) => {
82
- let n = D?.scrollContainerRef.current ?? null;
83
- !n || t && e === null || n.querySelectorAll(t ? `.ssg-body-row[data-row-index="${e}"]` : `.ssg-body-row[${x}]`).forEach((e) => {
84
- r(n, e) || (t ? e.setAttribute(x, V() ? "live" : "") : e.removeAttribute(x));
76
+ if (q === n) return;
77
+ q = n;
78
+ let r = K;
79
+ n === "out" ? (t.style.opacity = y, r && (r.innerHTML = ee)) : (t.style.opacity = "1", r && (r.innerHTML = b));
80
+ }, X = () => {
81
+ G && G.parentNode && G.parentNode.removeChild(G), G = null, K = null, q = null;
82
+ }, Z = (e, t) => {
83
+ let n = A?.scrollContainerRef.current ?? null;
84
+ !n || t && e === null || n.querySelectorAll(t ? `.ssg-body-row[data-row-index="${e}"]` : `.ssg-body-row[${w}]`).forEach((e) => {
85
+ r(n, e) || (t ? e.setAttribute(w, W() ? "live" : "") : e.removeAttribute(w));
85
86
  });
86
- }, ne = () => {
87
- let e = D?.scrollContainerRef.current ?? null;
87
+ }, re = () => {
88
+ let e = A?.scrollContainerRef.current ?? null;
88
89
  if (!e) return null;
89
90
  let t = /* @__PURE__ */ new Map();
90
- for (let n of w(e)) {
91
- let e = C.exec(n.style.transform);
91
+ for (let n of D(e)) {
92
+ let e = E.exec(n.style.transform);
92
93
  e && t.set(n, {
93
94
  index: Number(n.getAttribute("data-row-index")),
94
95
  baseY: parseFloat(e[1])
95
96
  });
96
97
  }
97
98
  return t;
98
- }, re = (t) => {
99
- let n = R, r = O;
100
- if (!n || r === null || D === null) return;
101
- let i = D.scrollContainerRef.current;
99
+ }, ie = (t) => {
100
+ let n = V, r = j;
101
+ if (!n || r === null || A === null) return;
102
+ let i = A.scrollContainerRef.current;
102
103
  if (!i) return;
103
- for (let e of w(i)) {
104
+ for (let e of D(i)) {
104
105
  if (n.has(e)) continue;
105
- let t = C.exec(e.style.transform);
106
+ let t = E.exec(e.style.transform);
106
107
  t && n.set(e, {
107
108
  index: Number(e.getAttribute("data-row-index")),
108
109
  baseY: parseFloat(t[1])
109
110
  });
110
111
  }
111
- let a = D.rowMetrics.rowsHeight(r, r), o = (i.scrollTop - z) * D.verticalScaleFactor, s = (j ? A.y - j.y : 0) + o, c = t === null ? null : e(r, t);
112
+ let a = A.rowMetrics.rowsHeight(r, r), o = (i.scrollTop - H) * A.verticalScaleFactor, s = (P ? N.y - P.y : 0) + o, c = t === null ? null : e(r, t);
112
113
  n.forEach((e, t) => {
113
114
  let { index: i, baseY: o } = e;
114
115
  if (!t.isConnected) {
@@ -120,87 +121,87 @@ var p = 14, m = 12, h = "0.5", g = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
120
121
  return;
121
122
  }
122
123
  let l = 0;
123
- c !== null && (r < i && i <= c ? l = -a : c <= i && i < r && (l = a)), t.style.transition = b, t.style.transform = `translateY(${o + l}px)`, e.applied = t.style.transform;
124
+ c !== null && (r < i && i <= c ? l = -a : c <= i && i < r && (l = a)), t.style.transition = C, t.style.transform = `translateY(${o + l}px)`, e.applied = t.style.transform;
124
125
  });
125
- let l = B ?? /* @__PURE__ */ new Set();
126
- B = l;
127
- for (let { el: e, index: t } of T(i)) {
126
+ let l = U ?? /* @__PURE__ */ new Set();
127
+ U = l;
128
+ for (let { el: e, index: t } of O(i)) {
128
129
  if (l.add(e), t === r) {
129
130
  e.style.transition = "none", e.style.transform = `translateY(${s}px)`, e.style.willChange = "transform", e.style.zIndex = "10";
130
131
  continue;
131
132
  }
132
133
  let n = 0;
133
- c !== null && (r < t && t <= c ? n = -a : c <= t && t < r && (n = a)), e.style.transition = b, e.style.transform = `translateY(${n}px)`, e.style.zIndex = "";
134
+ c !== null && (r < t && t <= c ? n = -a : c <= t && t < r && (n = a)), e.style.transition = C, e.style.transform = `translateY(${n}px)`, e.style.zIndex = "";
134
135
  }
135
- }, ie = (e, r) => {
136
- if (D === null) return null;
137
- let { scrollContainerRef: a, bodyScrollRef: o, rowMetrics: s, headerHeight: c, verticalScaleFactor: l, windowBaseOffsetPx: u } = D, d = a.current, f = o.current;
138
- if (!d || !f) return null;
139
- let p = d.getBoundingClientRect();
140
- if (e < p.left || e > p.right || r < p.top || r > p.bottom) return null;
141
- let m = i(r, p.top + d.clientTop + d.clientHeight, D.footerHeight ?? 0), h = f.getBoundingClientRect(), g = f.scrollTop + m - h.top - c - d.scrollTop * (1 - l), _ = t(g, s), v = O, y = v !== null && V() ? s.detailHeight(v) : 0;
142
- if (v !== null && y > 0) {
143
- let e = t(g + y, s);
144
- e > v + 1 && (_ = e);
136
+ }, ae = (e, r) => {
137
+ if (A === null) return null;
138
+ let { scrollContainerRef: o, bodyScrollRef: s, rowMetrics: c, headerHeight: l, verticalScaleFactor: u, windowBaseOffsetPx: d } = A, f = o.current, p = s.current;
139
+ if (!f || !p) return null;
140
+ let m = f.getBoundingClientRect();
141
+ if (e < m.left || e > m.right || r < m.top || r > m.bottom) return null;
142
+ let h = a(i(r, m.top + f.clientTop + f.clientHeight, A.footerHeight ?? 0), m.top + f.clientTop, A.stickyTopHeight ?? 0), g = p.getBoundingClientRect(), _ = p.scrollTop + h - g.top - l - f.scrollTop * (1 - u), v = t(_, c), y = j, b = y !== null && W() ? c.detailHeight(y) : 0;
143
+ if (y !== null && b > 0) {
144
+ let e = t(_ + b, c);
145
+ e > y + 1 && (v = e);
145
146
  }
146
- let b = n(_, s);
147
+ let ee = n(v, c);
147
148
  return {
148
- slot: _,
149
- top: c + b - u
149
+ slot: v,
150
+ top: l + ee - d
150
151
  };
151
- }, Y = () => {
152
- let t = ie(A.x, A.y), n = O;
153
- if (V()) {
154
- t && n !== null && (k = e(n, t.slot) === null ? null : t.slot), K(), re(k);
152
+ }, Q = () => {
153
+ let t = ae(N.x, N.y), n = j;
154
+ if (W()) {
155
+ t && n !== null && (M = e(n, t.slot) === null ? null : t.slot), Y(), ie(M);
155
156
  return;
156
157
  }
157
- if (te(t), !t || n === null || e(n, t.slot) === null) {
158
- k = null, K();
158
+ if (ne(t), !t || n === null || e(n, t.slot) === null) {
159
+ M = null, Y();
159
160
  return;
160
161
  }
161
- k = t.slot;
162
- for (let e of G()) e && (e.style.top = `${t.top}px`, e.style.display = "block");
163
- }, X = () => {
164
- if (O === null) {
165
- F = null;
162
+ M = t.slot;
163
+ for (let e of J()) e && (e.style.top = `${t.top}px`, e.style.display = "block");
164
+ }, oe = () => {
165
+ if (j === null) {
166
+ R = null;
166
167
  return;
167
168
  }
168
- let e = D?.scrollContainerRef.current ?? null;
169
- if (e && (M || (!j || o(j, A, 6)) && (M = !0), M)) {
170
- let t = e.getBoundingClientRect(), n = c({
169
+ let e = A?.scrollContainerRef.current ?? null;
170
+ if (e && (F || (!P || s(P, N, 6)) && (F = !0), F)) {
171
+ let t = e.getBoundingClientRect(), n = d(e, t), r = l({
171
172
  rectLeft: t.left,
172
173
  rectTop: t.top,
173
174
  clientLeft: e.clientLeft,
174
175
  clientTop: e.clientTop,
175
176
  clientWidth: e.clientWidth,
176
177
  clientHeight: e.clientHeight,
177
- scale: l(e, t)
178
- }), r = s(A.y, n.top, n.bottom - (D?.footerHeight ?? 0), 24), i = a(e.scrollTop, r, 18, e.scrollHeight - e.clientHeight);
179
- i !== e.scrollTop && e.scrollTo({
180
- top: i,
178
+ scale: n
179
+ }), i = c(N.y, u(r.top, (A?.stickyTopHeight ?? 0) * n.y, 24), r.bottom - (A?.footerHeight ?? 0), 24), a = o(e.scrollTop, i, 18, e.scrollHeight - e.clientHeight);
180
+ a !== e.scrollTop && e.scrollTo({
181
+ top: a,
181
182
  behavior: "auto"
182
183
  });
183
184
  }
184
- Y(), F = requestAnimationFrame(X);
185
- }, Z = (e, t) => `${e.getAttribute("data-pane") ?? ""}|${t}`, Q = () => {
186
- let e = D?.scrollContainerRef.current ?? null;
185
+ Q(), R = requestAnimationFrame(oe);
186
+ }, se = (e, t) => `${e.getAttribute("data-pane") ?? ""}|${t}`, ce = () => {
187
+ let e = A?.scrollContainerRef.current ?? null;
187
188
  if (!e) return null;
188
189
  let t = /* @__PURE__ */ new Map();
189
- for (let n of w(e)) t.set(Z(n, Number(n.getAttribute("data-row-index"))), n.getBoundingClientRect().top);
190
- for (let n of T(e)) t.set(n.key, n.el.getBoundingClientRect().top);
190
+ for (let n of D(e)) t.set(se(n, Number(n.getAttribute("data-row-index"))), n.getBoundingClientRect().top);
191
+ for (let n of O(e)) t.set(n.key, n.el.getBoundingClientRect().top);
191
192
  return t;
192
193
  }, $ = (t) => {
193
- F !== null && (cancelAnimationFrame(F), F = null), document.body.style.cursor = "", K(), q();
194
- let n = O, r = k, i = L;
195
- J(n, !1), O = null, L = null, k = null, j = null, P = null;
196
- let a = n === null || r === null ? null : e(n, r), o = t && n !== null && a !== null && D !== null, s = R;
197
- R = null;
198
- let c = s && o && D !== null && !S(D.scrollContainerRef.current) ? Q() : null, l = B;
199
- if (B = null, l && (o ? l.forEach(E) : (l.forEach((e) => {
200
- e.isConnected && (e.style.transition = b, e.style.transform = "translateY(0px)", e.style.zIndex = "");
194
+ R !== null && (cancelAnimationFrame(R), R = null), document.body.style.cursor = "", Y(), X();
195
+ let n = j, r = M, i = B;
196
+ Z(n, !1), j = null, B = null, M = null, P = null, L = null;
197
+ let a = n === null || r === null ? null : e(n, r), o = t && n !== null && a !== null && A !== null, s = V;
198
+ V = null;
199
+ let c = s && o && A !== null && !T(A.scrollContainerRef.current) ? ce() : null, l = U;
200
+ if (U = null, l && (o ? l.forEach(k) : (l.forEach((e) => {
201
+ e.isConnected && (e.style.transition = C, e.style.transform = "translateY(0px)", e.style.zIndex = "");
201
202
  }), window.setTimeout(() => {
202
203
  l.forEach((e) => {
203
- B?.has(e) || E(e);
204
+ U?.has(e) || k(e);
204
205
  });
205
206
  }, 200))), s) if (o) s.forEach(({ baseY: e }, t) => {
206
207
  t.style.transition = "", t.style.willChange = "", t.isConnected && (t.style.transform = `translateY(${e}px)`);
@@ -208,78 +209,78 @@ var p = 14, m = 12, h = "0.5", g = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
208
209
  else {
209
210
  let e = [];
210
211
  s.forEach(({ baseY: t }, n) => {
211
- n.isConnected && (n.style.transition = b, n.style.transform = `translateY(${t}px)`, e.push(n));
212
+ n.isConnected && (n.style.transition = C, n.style.transform = `translateY(${t}px)`, e.push(n));
212
213
  }), window.setTimeout(() => {
213
214
  for (let t of e) t.style.transition = "", t.style.willChange = "";
214
215
  }, 200);
215
216
  }
216
- if (!o || n === null || a === null || D === null) return;
217
- let u = c ?? (S(D.scrollContainerRef.current) ? null : Q()), d = u ? {
217
+ if (!o || n === null || a === null || A === null) return;
218
+ let u = c ?? (T(A.scrollContainerRef.current) ? null : ce()), d = u ? {
218
219
  tops: u,
219
220
  from: n,
220
221
  to: a,
221
222
  row: i
222
223
  } : null;
223
- I = d, D.commitRowMove(n, a), d && requestAnimationFrame(() => {
224
- I === d && (I = null);
224
+ z = d, A.commitRowMove(n, a), d && requestAnimationFrame(() => {
225
+ z === d && (z = null);
225
226
  });
226
- }, ae = () => {
227
- let e = I;
228
- if (I = null, !e) return;
229
- let t = D?.scrollContainerRef.current ?? null;
227
+ }, le = () => {
228
+ let e = z;
229
+ if (z = null, !e) return;
230
+ let t = A?.scrollContainerRef.current ?? null;
230
231
  if (!t) return;
231
232
  let { tops: n, from: r, to: i } = e;
232
- if (D?.locateDragRow && e.row !== null && D.locateDragRow(e.row, i) !== i) return;
233
+ if (A?.locateDragRow && e.row !== null && A.locateDragRow(e.row, i) !== i) return;
233
234
  let a = (e) => e === i ? r : r < i && e >= r && e < i ? e + 1 : i < r && e > i && e <= r ? e - 1 : e, o = [], s = /* @__PURE__ */ new Map();
234
- w(t).forEach((e) => {
235
- let t = n.get(Z(e, a(Number(e.getAttribute("data-row-index")))));
235
+ D(t).forEach((e) => {
236
+ let t = n.get(se(e, a(Number(e.getAttribute("data-row-index")))));
236
237
  if (t === void 0) return;
237
238
  let r = t - e.getBoundingClientRect().top;
238
239
  if (Math.abs(r) < .5) return;
239
- let i = C.exec(e.style.transform);
240
+ let i = E.exec(e.style.transform);
240
241
  if (!i) return;
241
242
  let c = parseFloat(i[1]);
242
243
  s.set(e, c), e.style.transition = "none", e.style.transform = `translateY(${c + r}px)`, e.style.willChange = "transform", o.push(e);
243
244
  });
244
245
  let c = [];
245
- if (T(t).forEach(({ el: e, index: t, key: r }) => {
246
+ if (O(t).forEach(({ el: e, index: t, key: r }) => {
246
247
  let i = a(t), o = n.get(r.slice(0, r.lastIndexOf("|") + 1) + i);
247
248
  if (o === void 0) return;
248
249
  let s = o - e.getBoundingClientRect().top;
249
250
  Math.abs(s) < .5 || (e.style.transition = "none", e.style.transform = `translateY(${s}px)`, e.style.willChange = "transform", c.push(e));
250
251
  }), !(o.length === 0 && c.length === 0)) {
251
252
  t.getBoundingClientRect();
252
- for (let e of o) e.style.transition = `transform ${v}ms ${y}`, e.style.transform = `translateY(${s.get(e) ?? 0}px)`;
253
- for (let e of c) e.style.transition = `transform ${v}ms ${y}`, e.style.transform = "translateY(0px)";
253
+ for (let e of o) e.style.transition = `transform ${x}ms ${S}`, e.style.transform = `translateY(${s.get(e) ?? 0}px)`;
254
+ for (let e of c) e.style.transition = `transform ${x}ms ${S}`, e.style.transform = "translateY(0px)";
254
255
  window.setTimeout(() => {
255
256
  for (let e of o) e.style.transition = "", e.style.willChange = "";
256
- for (let e of c) B?.has(e) || E(e);
257
+ for (let e of c) U?.has(e) || k(e);
257
258
  }, 280);
258
259
  }
259
- }, oe = (e, t) => {
260
- if (D === null || !D.enabled || t.button !== 0) return;
261
- if (t.stopPropagation(), t.preventDefault(), D.gridRootRef?.current?.focus({ preventScroll: !0 }), O !== null) {
262
- if (t.pointerId !== P) return;
263
- N?.(), $(!1);
260
+ }, ue = (e, t) => {
261
+ if (A === null || !A.enabled || t.button !== 0) return;
262
+ if (t.stopPropagation(), t.preventDefault(), A.gridRootRef?.current?.focus({ preventScroll: !0 }), j !== null) {
263
+ if (t.pointerId !== L) return;
264
+ I?.(), $(!1);
264
265
  }
265
- O = e, L = D.getDragRow?.(e) ?? null, P = t.pointerId, k = null, A = {
266
+ j = e, B = A.getDragRow?.(e) ?? null, L = t.pointerId, M = null, N = {
266
267
  x: t.clientX,
267
268
  y: t.clientY
268
- }, j = {
269
+ }, P = {
269
270
  x: t.clientX,
270
271
  y: t.clientY
271
- }, M = !1, document.body.style.cursor = "grabbing", V() ? (R = ne(), z = D.scrollContainerRef.current?.scrollTop ?? 0) : ee(D.getRowDragLabel(e)), J(e, !0);
272
+ }, F = !1, document.body.style.cursor = "grabbing", W() ? (V = re(), H = A.scrollContainerRef.current?.scrollTop ?? 0) : te(A.getRowDragLabel(e)), Z(e, !0);
272
273
  let n = t.currentTarget, r = t.pointerId;
273
274
  try {
274
275
  n.setPointerCapture(r);
275
276
  } catch {}
276
277
  let i = (e) => {
277
- e.pointerId === r && (A = {
278
+ e.pointerId === r && (N = {
278
279
  x: e.clientX,
279
280
  y: e.clientY
280
- }, Y());
281
- }, a = u(), o = () => {
282
- window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", s), window.removeEventListener("pointercancel", c), window.removeEventListener("keydown", l, !0), window.removeEventListener("blur", d), a(), N = null;
281
+ }, Q());
282
+ }, a = f(), o = () => {
283
+ window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", s), window.removeEventListener("pointercancel", c), window.removeEventListener("keydown", l, !0), window.removeEventListener("blur", u), a(), I = null;
283
284
  try {
284
285
  n.releasePointerCapture(r);
285
286
  } catch {}
@@ -293,46 +294,46 @@ var p = 14, m = 12, h = "0.5", g = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
293
294
  function l(e) {
294
295
  e.key === "Escape" && (o(), $(!1));
295
296
  }
296
- function d() {
297
+ function u() {
297
298
  o(), $(!1);
298
299
  }
299
- window.addEventListener("pointermove", i), window.addEventListener("pointerup", s), window.addEventListener("pointercancel", c), window.addEventListener("keydown", l, !0), window.addEventListener("blur", d), N = o, Y(), F = requestAnimationFrame(X);
300
- }, se = (e) => {
301
- if (O === null || L == null || D?.locateDragRow === void 0) return;
302
- let t = D.locateDragRow(L, O);
303
- if (R && R.forEach((e, t) => {
300
+ window.addEventListener("pointermove", i), window.addEventListener("pointerup", s), window.addEventListener("pointercancel", c), window.addEventListener("keydown", l, !0), window.addEventListener("blur", u), I = o, Q(), R = requestAnimationFrame(oe);
301
+ }, de = (e) => {
302
+ if (j === null || B == null || A?.locateDragRow === void 0) return;
303
+ let t = A.locateDragRow(B, j);
304
+ if (V && V.forEach((e, t) => {
304
305
  if (!t.isConnected) {
305
- R?.delete(t);
306
+ V?.delete(t);
306
307
  return;
307
308
  }
308
309
  let n = Number(t.getAttribute("data-row-index"));
309
310
  if (n === e.index && (e.applied === void 0 || t.style.transform === e.applied)) return;
310
- let r = C.exec(t.style.transform);
311
+ let r = E.exec(t.style.transform);
311
312
  if (!r) {
312
- R?.delete(t);
313
+ V?.delete(t);
313
314
  return;
314
315
  }
315
316
  e.index = n, e.baseY = parseFloat(r[1]), e.applied = void 0;
316
317
  }), t === null) {
317
- N?.(), $(!1);
318
+ I?.(), $(!1);
318
319
  return;
319
320
  }
320
- R && t !== O && j !== null && e !== null && (j = {
321
- x: j.x,
322
- y: j.y + D.rowMetrics.rowTop(t) - e.rowTop(O)
323
- }), t !== O && (J(null, !1), O = t, J(t, !0)), Y();
321
+ V && t !== j && P !== null && e !== null && (P = {
322
+ x: P.x,
323
+ y: P.y + A.rowMetrics.rowTop(t) - e.rowTop(j)
324
+ }), t !== j && (Z(null, !1), j = t, Z(t, !0)), Q();
324
325
  };
325
326
  return {
326
327
  update: (e) => {
327
- let t = D;
328
- D = e, O !== null && t !== null && t.locateDragRow !== e.locateDragRow && se(t.rowMetrics);
328
+ let t = A;
329
+ A = e, j !== null && t !== null && t.locateDragRow !== e.locateDragRow && de(t.rowMetrics);
329
330
  },
330
- onRowDragHandlePointerDown: oe,
331
- applyReorderSettle: ae,
331
+ onRowDragHandlePointerDown: ue,
332
+ applyReorderSettle: le,
332
333
  dispose: () => {
333
- N?.(), N = null, F !== null && (cancelAnimationFrame(F), F = null), document.body.style.cursor = "", q(), J(O, !1), O = null, L = null, k = null, R = null, B?.forEach(E), B = null, I = null;
334
+ I?.(), I = null, R !== null && (cancelAnimationFrame(R), R = null), document.body.style.cursor = "", X(), Z(j, !1), j = null, B = null, M = null, V = null, U?.forEach(k), U = null, z = null;
334
335
  }
335
336
  };
336
337
  };
337
338
  //#endregion
338
- export { D as createRowDragController };
339
+ export { A as createRowDragController };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs"),n=require("../logic/panelDragGeometry.cjs");var r=360,i=420,a=336,o=8,s=12,c=[`filter`,`columns`,`sort`],l=(e,t,n)=>{let r=Math.max(0,Math.min(420,t-o*2)),i=n?Math.min(a,r):r,s=e;s+i>t-o&&(s=Math.max(o,t-o-i));let c=Math.max(0,Math.min(420,t-o-s));return{top:s,maxHeight:c}},u=e=>{let t={filter:e.canUseFilterTab,columns:e.canUseColumnsTab,sort:e.canUseSortTab};return c.filter(e=>t[e])},d=(e,t)=>e===null?null:t.includes(e)?e:t[0]??null,f=()=>{let i=null,a=e.createValueStore({requestedTab:null,layout:null,flashTick:0}),c={current:null},f=null,p=e=>{a.setSnapshot({...a.getSnapshot(),...e})},m=e=>{let t=a.getSnapshot().layout;t===e||t!==null&&e!==null&&t.top===e.top&&t.left===e.left&&t.width===e.width&&t.maxHeight===e.maxHeight||p({layout:e})},h=e=>n.clampPanelDragPosition({top:e.top,left:e.left,panelWidth:r,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}),g=e=>{let t=l(e.top,window.innerHeight,!0);return{top:t.top,left:e.left,width:r,maxHeight:t.maxHeight}},_=()=>{if(f){m(g(h(f)));return}let e=i?.gridRootRef.current??null;if(!e){m(null);return}let t=e.getBoundingClientRect(),n=t.right-r-s,a=t.top+s;n=Math.max(o,n),n=Math.min(n,window.innerWidth-r-o),a=Math.max(o,a);let c=l(a,window.innerHeight,!1);m({top:c.top,left:n,width:r,maxHeight:c.maxHeight})},v=()=>i!==null&&d(a.getSnapshot().requestedTab,u(i))!==null,y=e=>{p({requestedTab:null,layout:null}),S(),i!==null&&e&&t.restoreGridFocus(i.gridRootRef)},b=()=>y(!0),x=t.createPopoverWindowBindings({onResize:_,onScroll:_,isInside:e=>c.current?.contains(e)===!0||i?.alliedRef?.current?.contains(e)===!0,onOutsidePointerDown:e=>y(i!==null&&t.isInsideGridRoot(i.gridRootRef,e)),getGridRoot:()=>i?.gridRootRef.current??null,onGridHidden:()=>y(!1),onKeyDown:e=>{if(e.key===`Escape`){if(i?.suppressEscape){i.onSuppressedEscape?.();return}e.preventDefault(),b()}}}),S=()=>{let e=v();e&&!x.isAttached()?(_(),x.attach()):!e&&x.isAttached()&&x.detach()};return{update:e=>{i=e,S()},subscribe:a.subscribe,getSnapshot:a.getSnapshot,panelRef:c,open:e=>{if(i===null||!u(i).includes(e))return;let n=a.getSnapshot();t.blurForPopover(i.gridRootRef.current),p({requestedTab:e,flashTick:n.requestedTab===null?n.flashTick:n.flashTick+1}),S()},close:b,move:(e,t)=>{let n=h({top:e,left:t});f=n,p({layout:g(n)})},dispose:()=>{x.detach()}}};exports.TOOL_PANEL_MAX_HEIGHT=i,exports.createToolPanelController=f,exports.resolveActiveToolPanelTab=d,exports.resolveAvailableToolPanelTabs=u,exports.resolveToolPanelVerticalPlacement=l;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs");require("./escapeClaimController.cjs");const t=require("./popoverSupport.cjs"),n=require("../logic/panelDragGeometry.cjs");var r=360,i=420,a=336,o=8,s=12,c=[`filter`,`columns`,`sort`],l=(e,t,n)=>{let r=Math.max(0,Math.min(420,t-o*2)),i=n?Math.min(a,r):r,s=e;s+i>t-o&&(s=Math.max(o,t-o-i));let c=Math.max(0,Math.min(420,t-o-s));return{top:s,maxHeight:c}},u=e=>{let t={filter:e.canUseFilterTab,columns:e.canUseColumnsTab,sort:e.canUseSortTab};return c.filter(e=>t[e])},d=(e,t)=>e===null?null:t.includes(e)?e:t[0]??null,f=()=>{let i=null,a=e.createValueStore({requestedTab:null,layout:null,flashTick:0}),c={current:null},f=null,p=e=>{a.setSnapshot({...a.getSnapshot(),...e})},m=e=>{let t=a.getSnapshot().layout;t===e||t!==null&&e!==null&&t.top===e.top&&t.left===e.left&&t.width===e.width&&t.maxHeight===e.maxHeight||p({layout:e})},h=e=>n.clampPanelDragPosition({top:e.top,left:e.left,panelWidth:r,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}),g=e=>{let t=l(e.top,window.innerHeight,!0);return{top:t.top,left:e.left,width:r,maxHeight:t.maxHeight}},_=()=>{if(f){m(g(h(f)));return}let e=i?.gridRootRef.current??null;if(!e){m(null);return}let t=e.getBoundingClientRect(),n=t.right-r-s,a=t.top+s;n=Math.max(o,n),n=Math.min(n,window.innerWidth-r-o),a=Math.max(o,a);let c=l(a,window.innerHeight,!1);m({top:c.top,left:n,width:r,maxHeight:c.maxHeight})},v=()=>i!==null&&d(a.getSnapshot().requestedTab,u(i))!==null,y=null,b=(e,n=!1)=>{let r=y;if(y=null,p({requestedTab:null,layout:null}),C(),!(i===null||!e)){if(n&&r!==null&&r.isConnected&&r!==i.gridRootRef.current){let e=document.activeElement;if(e===r||(e===null||e===document.body||c.current?.contains(e)===!0)&&(r.focus({preventScroll:!0}),document.activeElement===r))return}t.restoreGridFocus(i.gridRootRef)}},x=()=>b(!0,!0),S=t.createPopoverWindowBindings({onResize:_,onScroll:_,isInside:e=>c.current?.contains(e)===!0||i?.alliedRef?.current?.contains(e)===!0,onOutsidePointerDown:e=>b(i!==null&&t.isInsideGridRoot(i.gridRootRef,e)),getGridRoot:()=>i?.gridRootRef.current??null,onGridHidden:()=>b(!1),onKeyDown:e=>{if(e.key===`Escape`){if(i?.suppressEscape){i.onSuppressedEscape?.();return}e.preventDefault(),x()}}}),C=()=>{let e=v();e&&!S.isAttached()?(_(),S.attach()):!e&&S.isAttached()&&S.detach()};return{update:e=>{i=e,C()},subscribe:a.subscribe,getSnapshot:a.getSnapshot,panelRef:c,open:e=>{if(i===null||!u(i).includes(e))return;let n=a.getSnapshot();if(n.requestedTab===null){let e=document.activeElement;y=e instanceof HTMLElement&&e!==document.body&&e.closest(`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover`)===null?e:null}c.current?.contains(document.activeElement)!==!0&&t.blurForPopover(i.gridRootRef.current),p({requestedTab:e,flashTick:n.requestedTab===null?n.flashTick:n.flashTick+1}),C()},close:x,move:(e,t)=>{let n=h({top:e,left:t});f=n,p({layout:g(n)})},dispose:()=>{S.detach()}}};exports.TOOL_PANEL_MAX_HEIGHT=i,exports.createToolPanelController=f,exports.resolveActiveToolPanelTab=d,exports.resolveAvailableToolPanelTabs=u,exports.resolveToolPanelVerticalPlacement=l;