@ishibashi0112/spreadsheet-grid-core 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/controllers/activeRowFollowController.cjs +1 -0
  2. package/dist/controllers/activeRowFollowController.d.ts +18 -0
  3. package/dist/controllers/activeRowFollowController.js +68 -0
  4. package/dist/controllers/autoHeightMeasurer.cjs +1 -1
  5. package/dist/controllers/autoHeightMeasurer.js +17 -17
  6. package/dist/controllers/clipboardController.cjs +1 -1
  7. package/dist/controllers/clipboardController.d.ts +2 -0
  8. package/dist/controllers/clipboardController.js +74 -64
  9. package/dist/controllers/columnAutosizeRunner.cjs +1 -1
  10. package/dist/controllers/columnAutosizeRunner.js +10 -10
  11. package/dist/controllers/contextMenuController.cjs +1 -1
  12. package/dist/controllers/contextMenuController.d.ts +1 -0
  13. package/dist/controllers/contextMenuController.js +12 -7
  14. package/dist/controllers/detailRowController.cjs +1 -0
  15. package/dist/controllers/detailRowController.d.ts +41 -0
  16. package/dist/controllers/detailRowController.js +96 -0
  17. package/dist/controllers/editController.cjs +1 -1
  18. package/dist/controllers/editController.d.ts +1 -0
  19. package/dist/controllers/editController.js +106 -99
  20. package/dist/controllers/fillHandleController.cjs +1 -1
  21. package/dist/controllers/fillHandleController.js +78 -78
  22. package/dist/controllers/filterPopoverController.cjs +1 -1
  23. package/dist/controllers/filterPopoverController.js +6 -6
  24. package/dist/controllers/findController.cjs +1 -1
  25. package/dist/controllers/findController.d.ts +1 -0
  26. package/dist/controllers/findController.js +16 -15
  27. package/dist/controllers/imeInputController.cjs +1 -1
  28. package/dist/controllers/imeInputController.js +65 -54
  29. package/dist/controllers/keyboardController.cjs +1 -1
  30. package/dist/controllers/keyboardController.d.ts +1 -0
  31. package/dist/controllers/keyboardController.js +113 -111
  32. package/dist/controllers/liveUiState.cjs +1 -0
  33. package/dist/controllers/liveUiState.d.ts +7 -0
  34. package/dist/controllers/liveUiState.js +4 -0
  35. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  36. package/dist/controllers/pointerInteractionsController.d.ts +1 -0
  37. package/dist/controllers/pointerInteractionsController.js +157 -156
  38. package/dist/controllers/rowDragController.cjs +1 -1
  39. package/dist/controllers/rowDragController.d.ts +1 -0
  40. package/dist/controllers/rowDragController.js +117 -104
  41. package/dist/controllers/scrollSyncController.cjs +1 -1
  42. package/dist/controllers/scrollSyncController.js +45 -43
  43. package/dist/controllers/serverSideRowModel.cjs +1 -1
  44. package/dist/controllers/serverSideRowModel.js +19 -19
  45. package/dist/controllers/viewportSyncController.cjs +1 -1
  46. package/dist/controllers/viewportSyncController.d.ts +1 -0
  47. package/dist/controllers/viewportSyncController.js +1 -1
  48. package/dist/engine/cellCommands.cjs +1 -0
  49. package/dist/engine/cellCommands.d.ts +27 -0
  50. package/dist/engine/cellCommands.js +89 -0
  51. package/dist/engine/columnCommands.cjs +1 -1
  52. package/dist/engine/columnCommands.js +113 -113
  53. package/dist/engine/createGridEngine.cjs +3 -3
  54. package/dist/engine/createGridEngine.d.ts +2 -0
  55. package/dist/engine/createGridEngine.js +72 -70
  56. package/dist/engine/exportCommands.cjs +1 -1
  57. package/dist/engine/exportCommands.js +4 -2
  58. package/dist/engine/fullFeatures.cjs +1 -1
  59. package/dist/engine/fullFeatures.js +6 -6
  60. package/dist/engine/gridApi.cjs +6 -6
  61. package/dist/engine/gridApi.d.ts +4 -0
  62. package/dist/engine/gridApi.js +208 -192
  63. package/dist/engine/notifiers.cjs +1 -1
  64. package/dist/engine/notifiers.d.ts +4 -0
  65. package/dist/engine/notifiers.js +7 -7
  66. package/dist/index.cjs +1 -1
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.js +4 -4
  69. package/dist/locales/en.cjs +1 -1
  70. package/dist/locales/en.js +2 -0
  71. package/dist/logic/cellPlacement.cjs +1 -0
  72. package/dist/logic/cellPlacement.d.ts +22 -0
  73. package/dist/logic/cellPlacement.js +44 -0
  74. package/dist/logic/density.cjs +1 -0
  75. package/dist/logic/density.d.ts +5 -0
  76. package/dist/logic/density.js +17 -0
  77. package/dist/logic/detailRow.cjs +1 -1
  78. package/dist/logic/detailRow.d.ts +4 -0
  79. package/dist/logic/detailRow.js +10 -7
  80. package/dist/logic/domGuards.cjs +1 -1
  81. package/dist/logic/domGuards.d.ts +5 -0
  82. package/dist/logic/domGuards.js +8 -2
  83. package/dist/logic/editorKeys.cjs +1 -0
  84. package/dist/logic/editorKeys.d.ts +30 -0
  85. package/dist/logic/editorKeys.js +34 -0
  86. package/dist/logic/editorStart.cjs +1 -0
  87. package/dist/logic/editorStart.d.ts +7 -0
  88. package/dist/logic/editorStart.js +23 -0
  89. package/dist/logic/exportCsv.cjs +2 -2
  90. package/dist/logic/exportCsv.d.ts +2 -1
  91. package/dist/logic/exportCsv.js +13 -13
  92. package/dist/logic/exportData.cjs +1 -1
  93. package/dist/logic/exportData.d.ts +2 -1
  94. package/dist/logic/exportData.js +18 -18
  95. package/dist/logic/geometry.cjs +1 -1
  96. package/dist/logic/geometry.d.ts +2 -0
  97. package/dist/logic/geometry.js +41 -20
  98. package/dist/logic/gridBarSummary.cjs +1 -0
  99. package/dist/logic/gridBarSummary.d.ts +27 -0
  100. package/dist/logic/gridBarSummary.js +137 -0
  101. package/dist/logic/gridState.cjs +1 -1
  102. package/dist/logic/gridState.d.ts +3 -2
  103. package/dist/logic/gridState.js +32 -23
  104. package/dist/logic/grouping.cjs +1 -1
  105. package/dist/logic/grouping.js +1 -1
  106. package/dist/logic/imeInput.cjs +1 -1
  107. package/dist/logic/imeInput.js +6 -4
  108. package/dist/logic/localeTextFeatures.cjs +1 -1
  109. package/dist/logic/localeTextFeatures.d.ts +4 -0
  110. package/dist/logic/localeTextFeatures.js +8 -5
  111. package/dist/logic/pasteFill.cjs +1 -0
  112. package/dist/logic/pasteFill.d.ts +2 -0
  113. package/dist/logic/pasteFill.js +25 -0
  114. package/dist/logic/selectEditorState.cjs +1 -1
  115. package/dist/logic/selectEditorState.d.ts +28 -2
  116. package/dist/logic/selectEditorState.js +29 -14
  117. package/dist/logic/selectionAggregates.cjs +1 -1
  118. package/dist/logic/selectionAggregates.js +2 -3
  119. package/dist/logic/validation.cjs +1 -1
  120. package/dist/logic/validation.d.ts +1 -1
  121. package/dist/logic/validation.js +21 -21
  122. package/dist/model/gridActions.cjs +1 -1
  123. package/dist/model/gridActions.d.ts +13 -0
  124. package/dist/model/gridActions.js +11 -0
  125. package/dist/model/gridReducer.cjs +1 -1
  126. package/dist/model/gridReducer.js +128 -65
  127. package/dist/model/gridTypes.core.d.ts +172 -26
  128. package/dist/utils/editorVisibleBounds.cjs +1 -0
  129. package/dist/utils/editorVisibleBounds.d.ts +10 -0
  130. package/dist/utils/editorVisibleBounds.js +40 -0
  131. package/dist/utils/errorBubblePlacement.cjs +1 -0
  132. package/dist/utils/errorBubblePlacement.d.ts +8 -0
  133. package/dist/utils/errorBubblePlacement.js +26 -0
  134. package/dist/utils/gridVisibleBand.cjs +1 -0
  135. package/dist/utils/gridVisibleBand.d.ts +4 -0
  136. package/dist/utils/gridVisibleBand.js +24 -0
  137. package/dist/utils/multilineEditor.cjs +2 -0
  138. package/dist/utils/multilineEditor.d.ts +7 -0
  139. package/dist/utils/multilineEditor.js +22 -0
  140. package/dist/utils/scrollBottom.cjs +1 -0
  141. package/dist/utils/scrollBottom.d.ts +1 -0
  142. package/dist/utils/scrollBottom.js +4 -0
  143. package/dist/utils/topAlignedInput.cjs +1 -0
  144. package/dist/utils/topAlignedInput.d.ts +3 -0
  145. package/dist/utils/topAlignedInput.js +23 -0
  146. package/package.json +1 -1
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/sorting.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/autoScrollGeometry.cjs"),a=require("../logic/elementScale.cjs"),o=require("../logic/verticalGeometry.cjs");var s=10,c=300,l=()=>{let s=null,c=!1,l=!1,u=null,d=null,f=`mouse`,p=null,m=null,h=!1,g=!1,_=()=>s?.uiState.dragState??null,v=null,y=e=>{let t=s?.footerHeight??0,n=s?.stickyTopHeight??0,r=s?.scrollContainerRef.current??null;if(t<=0&&n<=0||!r)return e;let o=r.getBoundingClientRect(),c=a.resolveElementScale(r,o);return i.clampClientYBelowHeader(i.clampClientYAboveFooter(e,o.top+(r.clientTop+r.clientHeight)*c.y,t*c.y),o.top+r.clientTop*c.y,n*c.y)},b=(e,t)=>{if(s===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:c,rightPaneScrollRef:l,filteredRowsLength:u,visibleColumnsLength:d,paneLayout:f,leftLeadingWidth:p,centerLeadingWidth:m,rightLeadingWidth:h,headerHeight:g,rowMetrics:_,verticalScaleFactor:v}=s,b=n.current;if(!b||u===0||d===0)return null;let x=b.getBoundingClientRect(),S=a.resolveElementScale(b,x),C=o.clientYToRowIndex(b.scrollTop+(y(t)-x.top)/S.y-g,i.current?.scrollTop??0,v,_),w=null,T=c.current;if(w===null&&T&&f.left.entries.length>0){let t=T.getBoundingClientRect();if(e<t.right){let n=(e-t.left)/S.x-p;w=r.findLogicalIndexFromPaneOffset(f.left,n)}}let E=l.current;if(w===null&&E&&f.right.entries.length>0){let t=E.getBoundingClientRect();if(e>=t.left){let n=(e-t.left)/S.x-h;w=r.findLogicalIndexFromPaneOffset(f.right,n)}}if(w===null&&f.center.entries.length>0){let t=T&&f.left.entries.length===0?Math.max(e,T.getBoundingClientRect().left+p*S.x):e,n=b.scrollLeft+(t-x.left)/S.x-m;w=r.findLogicalIndexFromPaneOffset(f.center,Math.max(n,0))}return w===null?null:{row:C,col:r.clamp(w,0,d-1)}},x=(e,t)=>{let r=_();if(s===null||!r||r.type!==`selection`)return;let i=b(e,t);if(i){if(r.selectionKind===`cell`){s.dispatch(n.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){s.dispatch(n.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&s.dispatch(n.gridActions.updateColumnSelection(i.col))}},S=(e,t)=>{let r=t.timeStamp;if(s===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:o,enableRowSelection:c,onGutterRowSelect:l,onCellDoubleClickRef:u,resolveFirstDataCell:f}=s;i.current?.focus({preventScroll:!0});let{target:p}=e;if(p.kind===`cell`){let e=d;if(e&&e.cell.row===p.cell.row&&e.cell.col===p.cell.col&&r-e.time<300){d=null,u.current(p.cell,t);return}d={cell:p.cell,time:r},a(n.gridActions.activateCell(p.cell)),o&&(a(n.gridActions.startSelection(p.cell)),a(n.gridActions.endSelection()));return}if(d=null,p.kind===`row`){if(c){l(p.rowIndex,{shiftKey:!1});return}a(n.gridActions.startRowSelection(p.rowIndex,f?.().col)),a(n.gridActions.endSelection());return}a(n.gridActions.startColumnSelection(p.colIndex,f?.().row)),a(n.gridActions.endSelection())},C=()=>{s!==null&&(l=!1,s.dispatch(n.gridActions.endSelection()),s.dispatch(n.gridActions.endColumnResize()))},w=e=>{if(s===null)return;s.pointerClientRef.current={x:e.clientX,y:e.clientY};let t=_();if(t?.type===`columnResize`){(v===null||v.drag!==t)&&(v={drag:t,x:a.resolveElementScale(s.scrollContainerRef.current).x});let r=v.x===1?e.clientX:t.startX+(e.clientX-t.startX)/v.x;s.dispatch(n.gridActions.updateColumnResize(r))}},T=e=>{let t=u;t&&(u=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&S(t,e)),C()},E=()=>{u=null,C()},D=()=>{c||(c=!0,window.addEventListener(`pointermove`,w),window.addEventListener(`pointerup`,T),window.addEventListener(`pointercancel`,E))},O=()=>{c&&(c=!1,window.removeEventListener(`pointermove`,w),window.removeEventListener(`pointerup`,T),window.removeEventListener(`pointercancel`,E))},k=()=>{g=!1,s!==null&&s.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(s.autoScrollFrameRef.current),s.autoScrollFrameRef.current=null)},A=()=>{if(s===null||!g)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=s,r=e.current,o=t.current;if(!r||!o){n.current=requestAnimationFrame(A);return}if(!h){let e=m;if(e&&!i.hasPointerLeftActivationRadius(e,o,6)){n.current=requestAnimationFrame(A);return}h=!0}let c=r.getBoundingClientRect(),l=a.resolveElementScale(r,c),u=i.resolveScrollContentBox({rectLeft:c.left,rectTop:c.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight,scale:l}),d=_(),f=d?.type===`selection`&&d.selectionKind===`col`,p=d?.type===`selection`&&d.selectionKind===`row`,v=f?0:i.resolveAutoScrollAxisDirection(o.y,i.resolveTopAutoScrollStart(u.top,(s.stickyTopHeight??0)*l.y,24),u.bottom-(s.footerHeight??0),24),y=p?0:i.resolveAutoScrollAxisDirection(o.x,u.left,u.right,24),b=i.computeNextScrollPosition(r.scrollTop,v,18,r.scrollHeight-r.clientHeight),S=i.computeNextScrollPosition(r.scrollLeft,y,18,r.scrollWidth-r.clientWidth);(b!==r.scrollTop||S!==r.scrollLeft)&&(r.scrollTo({top:b,left:S,behavior:`auto`}),x(o.x,o.y)),n.current=requestAnimationFrame(A)},j=()=>{let e=_()?.type===`selection`;e&&!g?(g=!0,s!==null&&(s.autoScrollFrameRef.current=requestAnimationFrame(A))):!e&&g&&k()},M=()=>{if(p!==null)return;let e=()=>{if(!l||s===null){p=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=s,o=t.current,c=n.current;if(!o||!c){p=requestAnimationFrame(e);return}if(!h){let t=m;if(t&&!i.hasPointerLeftActivationRadius(t,c,6)){p=requestAnimationFrame(e);return}h=!0}let u=o.getBoundingClientRect(),d=a.resolveElementScale(o,u),f=i.resolveScrollContentBox({rectLeft:u.left,rectTop:u.top,clientLeft:o.clientLeft,clientTop:o.clientTop,clientWidth:o.clientWidth,clientHeight:o.clientHeight,scale:d}),g=i.resolveAutoScrollAxisDirection(c.y,i.resolveTopAutoScrollStart(f.top,(s.stickyTopHeight??0)*d.y,24),f.bottom-(s.footerHeight??0),24),_=i.computeNextScrollPosition(o.scrollTop,g,18,o.scrollHeight-o.clientHeight);if(_!==o.scrollTop){o.scrollTo({top:_,left:o.scrollLeft,behavior:`auto`});let e=b(c.x,c.y);e&&r(e.row)}p=requestAnimationFrame(e)};p=requestAnimationFrame(e)},N=(e,t)=>(e.preventDefault(),s===null||e.button!==0?!1:(f=e.pointerType,e.pointerType===`touch`?(u={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(s.gridRootRef.current?.focus({preventScroll:!0}),s.pointerClientRef.current={x:e.clientX,y:e.clientY},m={x:e.clientX,y:e.clientY},h=!1,!0)));return{update:e=>{s=e,D(),j()},getCellCoordFromClientPoint:b,updateSelectionFromPointer:x,handleCellPointerDown:(e,t)=>{if(!(!N(t,{kind:`cell`,cell:e})||s===null)){if(t.shiftKey&&s.enableRangeSelection){let{selection:t,activeCell:r}=s.uiState,i=t?.type===`cell`?t.range.start:r;if(i){s.dispatch(n.gridActions.startSelection(i)),s.dispatch(n.gridActions.updateSelection(e));return}}s.dispatch(n.gridActions.activateCell(e)),s.enableRangeSelection&&s.dispatch(n.gridActions.startSelection(e))}},handleCellDoubleClick:(e,t)=>{f===`touch`||s===null||s.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(e,t)=>{if(s===null||(s.enableRowHover&&s.setHoveredRowIndex(e.row),s.enableColumnHover&&s.setHoveredColumnIndex(e.col),!s.enableRangeSelection))return;let r=_();r?.type!==`selection`||r.selectionKind!==`cell`||(s.pointerClientRef.current={x:t.clientX,y:t.clientY},s.dispatch(n.gridActions.updateSelection(e)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(e,t)=>{if(!(!N(t,{kind:`row`,rowIndex:e})||s===null)){if(s.enableRowSelection){l=!0,s.onGutterRowSelect(e,{shiftKey:t.shiftKey}),M();return}if(t.shiftKey){let{selection:t,activeCell:r}=s.uiState,i=t?.type===`row`?t.startRow:r?.row;if(i!==void 0){s.dispatch(n.gridActions.startRowSelection(i,s.resolveFirstDataCell?.().col)),s.dispatch(n.gridActions.updateRowSelection(e));return}}s.dispatch(n.gridActions.startRowSelection(e,s.resolveFirstDataCell?.().col))}},handleRowHeaderPointerEnter:(e,t)=>{if(s===null)return;if(s.enableRowHover&&s.setHoveredRowIndex(e),l){s.pointerClientRef.current={x:t.clientX,y:t.clientY},s.onGutterRowSelectDrag(e);return}let r=_();r?.type!==`selection`||r.selectionKind!==`row`||(s.pointerClientRef.current={x:t.clientX,y:t.clientY},s.dispatch(n.gridActions.updateRowSelection(e)))},handleColumnHeaderPointerDown:(r,i)=>{if(!(!N(i,{kind:`col`,colIndex:r})||s===null)){if(i.shiftKey&&s.enableSorting){let i=s.orderedColumns[r];if(i&&!t.isSyntheticColumnKey(i.key)){let t=s.uiState.sort,r=t.find(e=>e.columnKey===i.key)?.direction?`desc`:`asc`,a=e.nextSortEntries(t,i.key,r,!0);s.dispatch(a.length===0?n.gridActions.clearSort():n.gridActions.setSort(a))}return}s.dispatch(n.gridActions.startColumnSelection(r,s.resolveFirstDataCell?.().row))}},handleColumnHeaderPointerEnter:(e,t)=>{if(s===null)return;s.setHoveredRowIndex(null),s.enableColumnHeaderHover&&s.setHoveredColumnIndex(e);let r=_();r?.type!==`selection`||r.selectionKind!==`col`||(s.pointerClientRef.current={x:t.clientX,y:t.clientY},s.dispatch(n.gridActions.updateColumnSelection(e)))},dispose:()=>{O(),k(),p!==null&&(cancelAnimationFrame(p),p=null)}}};exports.TOUCH_DOUBLE_TAP_MS=c,exports.TOUCH_TAP_SLOP_PX=s,exports.createPointerInteractionsController=l;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/sorting.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/geometry.cjs"),i=require("./liveUiState.cjs"),a=require("../logic/autoScrollGeometry.cjs"),o=require("../logic/elementScale.cjs"),s=require("../logic/verticalGeometry.cjs");var c=10,l=300,u=()=>{let c=null,l=!1,u=!1,d=null,f=null,p=`mouse`,m=null,h=null,g=!1,_=!1,v=()=>c===null?null:i.readLiveUiState(c).dragState??null,y=null,b=e=>{let t=c?.footerHeight??0,n=c?.stickyTopHeight??0,r=c?.scrollContainerRef.current??null;if(t<=0&&n<=0||!r)return e;let i=r.getBoundingClientRect(),s=o.resolveElementScale(r,i);return a.clampClientYBelowHeader(a.clampClientYAboveFooter(e,i.top+(r.clientTop+r.clientHeight)*s.y,t*s.y),i.top+r.clientTop*s.y,n*s.y)},x=(e,t)=>{if(c===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:a,rightPaneScrollRef:l,filteredRowsLength:u,visibleColumnsLength:d,paneLayout:f,leftLeadingWidth:p,centerLeadingWidth:m,rightLeadingWidth:h,headerHeight:g,rowMetrics:_,verticalScaleFactor:v}=c,y=n.current;if(!y||u===0||d===0)return null;let x=y.getBoundingClientRect(),S=o.resolveElementScale(y,x),C=s.clientYToRowIndex(y.scrollTop+(b(t)-x.top)/S.y-g,i.current?.scrollTop??0,v,_),w=null,T=a.current;if(w===null&&T&&f.left.entries.length>0){let t=T.getBoundingClientRect();if(e<t.right){let n=(e-t.left)/S.x-p;w=r.findLogicalIndexFromPaneOffset(f.left,n)}}let E=l.current;if(w===null&&E&&f.right.entries.length>0){let t=E.getBoundingClientRect();if(e>=t.left){let n=(e-t.left)/S.x-h;w=r.findLogicalIndexFromPaneOffset(f.right,n)}}if(w===null&&f.center.entries.length>0){let t=T&&f.left.entries.length===0?Math.max(e,T.getBoundingClientRect().left+p*S.x):e,n=y.scrollLeft+(t-x.left)/S.x-m;w=r.findLogicalIndexFromPaneOffset(f.center,Math.max(n,0))}return w===null?null:{row:C,col:r.clamp(w,0,d-1)}},S=(t,n)=>{let r=v();if(c===null||!r||r.type!==`selection`)return;let i=x(t,n);if(i){if(r.selectionKind===`cell`){c.dispatch(e.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){c.dispatch(e.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&c.dispatch(e.gridActions.updateColumnSelection(i.col))}},C=(t,n)=>{let r=n.timeStamp;if(c===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:o,enableRowSelection:s,onGutterRowSelect:l,onCellDoubleClickRef:u,resolveFirstDataCell:d}=c;i.current?.focus({preventScroll:!0});let{target:p}=t;if(p.kind===`cell`){let t=f;if(t&&t.cell.row===p.cell.row&&t.cell.col===p.cell.col&&r-t.time<300){f=null,u.current(p.cell,n);return}f={cell:p.cell,time:r},a(e.gridActions.activateCell(p.cell)),o&&(a(e.gridActions.startSelection(p.cell)),a(e.gridActions.endSelection()));return}if(f=null,p.kind===`row`){if(s){l(p.rowIndex,{shiftKey:!1});return}a(e.gridActions.startRowSelection(p.rowIndex,d?.().col)),a(e.gridActions.endSelection());return}a(e.gridActions.startColumnSelection(p.colIndex,d?.().row)),a(e.gridActions.endSelection())},w=()=>{c!==null&&(u=!1,c.dispatch(e.gridActions.endSelection()),c.dispatch(e.gridActions.endColumnResize()))},T=t=>{if(c===null)return;c.pointerClientRef.current={x:t.clientX,y:t.clientY};let n=v();if(n?.type===`columnResize`){(y===null||y.drag!==n)&&(y={drag:n,x:o.resolveElementScale(c.scrollContainerRef.current).x});let r=y.x===1?t.clientX:n.startX+(t.clientX-n.startX)/y.x;c.dispatch(e.gridActions.updateColumnResize(r))}},E=e=>{let t=d;t&&(d=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&C(t,e)),w()},D=()=>{d=null,w()},O=()=>{l||(l=!0,window.addEventListener(`pointermove`,T),window.addEventListener(`pointerup`,E),window.addEventListener(`pointercancel`,D))},k=()=>{l&&(l=!1,window.removeEventListener(`pointermove`,T),window.removeEventListener(`pointerup`,E),window.removeEventListener(`pointercancel`,D))},A=()=>{_=!1,c!==null&&c.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(c.autoScrollFrameRef.current),c.autoScrollFrameRef.current=null)},j=()=>{if(c===null||!_)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=c,r=e.current,i=t.current;if(!r||!i){n.current=requestAnimationFrame(j);return}if(!g){let e=h;if(e&&!a.hasPointerLeftActivationRadius(e,i,6)){n.current=requestAnimationFrame(j);return}g=!0}let s=r.getBoundingClientRect(),l=o.resolveElementScale(r,s),u=a.resolveScrollContentBox({rectLeft:s.left,rectTop:s.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight,scale:l}),d=v(),f=d?.type===`selection`&&d.selectionKind===`col`,p=d?.type===`selection`&&d.selectionKind===`row`,m=f?0:a.resolveAutoScrollAxisDirection(i.y,a.resolveTopAutoScrollStart(u.top,(c.stickyTopHeight??0)*l.y,24),u.bottom-(c.footerHeight??0),24),y=p?0:a.resolveAutoScrollAxisDirection(i.x,u.left,u.right,24),b=a.computeNextScrollPosition(r.scrollTop,m,18,r.scrollHeight-r.clientHeight),x=a.computeNextScrollPosition(r.scrollLeft,y,18,r.scrollWidth-r.clientWidth);(b!==r.scrollTop||x!==r.scrollLeft)&&(r.scrollTo({top:b,left:x,behavior:`auto`}),S(i.x,i.y)),n.current=requestAnimationFrame(j)},M=()=>{let e=v()?.type===`selection`;e&&!_?(_=!0,c!==null&&(c.autoScrollFrameRef.current=requestAnimationFrame(j))):!e&&_&&A()},N=()=>{if(m!==null)return;let e=()=>{if(!u||c===null){m=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=c,i=t.current,s=n.current;if(!i||!s){m=requestAnimationFrame(e);return}if(!g){let t=h;if(t&&!a.hasPointerLeftActivationRadius(t,s,6)){m=requestAnimationFrame(e);return}g=!0}let l=i.getBoundingClientRect(),d=o.resolveElementScale(i,l),f=a.resolveScrollContentBox({rectLeft:l.left,rectTop:l.top,clientLeft:i.clientLeft,clientTop:i.clientTop,clientWidth:i.clientWidth,clientHeight:i.clientHeight,scale:d}),p=a.resolveAutoScrollAxisDirection(s.y,a.resolveTopAutoScrollStart(f.top,(c.stickyTopHeight??0)*d.y,24),f.bottom-(c.footerHeight??0),24),_=a.computeNextScrollPosition(i.scrollTop,p,18,i.scrollHeight-i.clientHeight);if(_!==i.scrollTop){i.scrollTo({top:_,left:i.scrollLeft,behavior:`auto`});let e=x(s.x,s.y);e&&r(e.row)}m=requestAnimationFrame(e)};m=requestAnimationFrame(e)},P=(e,t)=>(e.preventDefault(),c===null||e.button!==0?!1:(p=e.pointerType,e.pointerType===`touch`?(d={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(c.gridRootRef.current?.focus({preventScroll:!0}),c.pointerClientRef.current={x:e.clientX,y:e.clientY},h={x:e.clientX,y:e.clientY},g=!1,!0)));return{update:e=>{c=e,O(),M()},getCellCoordFromClientPoint:x,updateSelectionFromPointer:S,handleCellPointerDown:(t,n)=>{if(!(!P(n,{kind:`cell`,cell:t})||c===null)){if(n.shiftKey&&c.enableRangeSelection){let{selection:n,activeCell:r}=i.readLiveUiState(c),a=n?.type===`cell`?n.range.start:r;if(a){c.dispatch(e.gridActions.startSelection(a)),c.dispatch(e.gridActions.updateSelection(t));return}}c.dispatch(e.gridActions.activateCell(t)),c.enableRangeSelection&&c.dispatch(e.gridActions.startSelection(t))}},handleCellDoubleClick:(e,t)=>{p===`touch`||c===null||c.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(t,n)=>{if(c===null||(c.enableRowHover&&c.setHoveredRowIndex(t.row),c.enableColumnHover&&c.setHoveredColumnIndex(t.col),!c.enableRangeSelection))return;let r=v();r?.type!==`selection`||r.selectionKind!==`cell`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateSelection(t)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(t,n)=>{if(!(!P(n,{kind:`row`,rowIndex:t})||c===null)){if(c.enableRowSelection){u=!0,c.onGutterRowSelect(t,{shiftKey:n.shiftKey}),N();return}if(n.shiftKey){let{selection:n,activeCell:r}=i.readLiveUiState(c),a=n?.type===`row`?n.startRow:r?.row;if(a!==void 0){c.dispatch(e.gridActions.startRowSelection(a,c.resolveFirstDataCell?.().col)),c.dispatch(e.gridActions.updateRowSelection(t));return}}c.dispatch(e.gridActions.startRowSelection(t,c.resolveFirstDataCell?.().col))}},handleRowHeaderPointerEnter:(t,n)=>{if(c===null)return;if(c.enableRowHover&&c.setHoveredRowIndex(t),u){c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.onGutterRowSelectDrag(t);return}let r=v();r?.type!==`selection`||r.selectionKind!==`row`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateRowSelection(t)))},handleColumnHeaderPointerDown:(r,a)=>{if(!(!P(a,{kind:`col`,colIndex:r})||c===null)){if(a.shiftKey&&c.enableSorting){let a=c.orderedColumns[r];if(a&&!n.isSyntheticColumnKey(a.key)){let n=i.readLiveUiState(c).sort,r=n.find(e=>e.columnKey===a.key)?.direction?`desc`:`asc`,o=t.nextSortEntries(n,a.key,r,!0);c.dispatch(o.length===0?e.gridActions.clearSort():e.gridActions.setSort(o))}return}c.dispatch(e.gridActions.startColumnSelection(r,c.resolveFirstDataCell?.().row))}},handleColumnHeaderPointerEnter:(t,n)=>{if(c===null)return;c.setHoveredRowIndex(null),c.enableColumnHeaderHover&&c.setHoveredColumnIndex(t);let r=v();r?.type!==`selection`||r.selectionKind!==`col`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateColumnSelection(t)))},dispose:()=>{k(),A(),m!==null&&(cancelAnimationFrame(m),m=null)}}};exports.TOUCH_DOUBLE_TAP_MS=l,exports.TOUCH_TAP_SLOP_PX=c,exports.createPointerInteractionsController=u;
@@ -31,6 +31,7 @@ export type PointerInteractionsArgs<T> = {
31
31
  } | null>;
32
32
  autoScrollFrameRef: MutableRef<number | null>;
33
33
  uiState: GridUiState;
34
+ getUiState?: (() => GridUiState) | undefined;
34
35
  dispatch: (action: GridUiAction) => void;
35
36
  enableRangeSelection: boolean;
36
37
  enableSorting: boolean;
@@ -1,22 +1,23 @@
1
- import { nextSortEntries as e } from "../logic/sorting.js";
2
- import { isSyntheticColumnKey as t } from "../logic/detailRow.js";
3
- import { gridActions as n } from "../model/gridActions.js";
1
+ import { gridActions as e } from "../model/gridActions.js";
2
+ import { nextSortEntries as t } from "../logic/sorting.js";
3
+ import { isSyntheticColumnKey as n } from "../logic/detailRow.js";
4
4
  import { clamp as r, findLogicalIndexFromPaneOffset as i } from "../logic/geometry.js";
5
- import { clampClientYAboveFooter as a, clampClientYBelowHeader as o, computeNextScrollPosition as s, hasPointerLeftActivationRadius as c, resolveAutoScrollAxisDirection as l, resolveScrollContentBox as u, resolveTopAutoScrollStart as d } from "../logic/autoScrollGeometry.js";
6
- import { resolveElementScale as f } from "../logic/elementScale.js";
7
- import { clientYToRowIndex as p } from "../logic/verticalGeometry.js";
5
+ import { readLiveUiState as a } from "./liveUiState.js";
6
+ import { clampClientYAboveFooter as o, clampClientYBelowHeader as s, computeNextScrollPosition as c, hasPointerLeftActivationRadius as l, resolveAutoScrollAxisDirection as u, resolveScrollContentBox as d, resolveTopAutoScrollStart as f } from "../logic/autoScrollGeometry.js";
7
+ import { resolveElementScale as p } from "../logic/elementScale.js";
8
+ import { clientYToRowIndex as m } from "../logic/verticalGeometry.js";
8
9
  //#region src/controllers/pointerInteractionsController.ts
9
- var m = 10, h = 300, g = () => {
10
- let m = null, h = !1, g = !1, _ = null, v = null, y = "mouse", b = null, x = null, S = !1, C = !1, w = () => m?.uiState.dragState ?? null, T = null, E = (e) => {
11
- let t = m?.footerHeight ?? 0, n = m?.stickyTopHeight ?? 0, r = m?.scrollContainerRef.current ?? null;
10
+ var h = 10, g = 300, _ = () => {
11
+ let h = null, g = !1, _ = !1, v = null, y = null, b = "mouse", x = null, S = null, C = !1, w = !1, T = () => h === null ? null : a(h).dragState ?? null, E = null, D = (e) => {
12
+ let t = h?.footerHeight ?? 0, n = h?.stickyTopHeight ?? 0, r = h?.scrollContainerRef.current ?? null;
12
13
  if (t <= 0 && n <= 0 || !r) return e;
13
- let i = r.getBoundingClientRect(), s = f(r, i);
14
- return o(a(e, i.top + (r.clientTop + r.clientHeight) * s.y, t * s.y), i.top + r.clientTop * s.y, n * s.y);
15
- }, D = (e, t) => {
16
- if (m === null) return null;
17
- let { bodyScrollRef: n, scrollContainerRef: a, leftPaneScrollRef: o, rightPaneScrollRef: s, filteredRowsLength: c, visibleColumnsLength: l, paneLayout: u, leftLeadingWidth: d, centerLeadingWidth: h, rightLeadingWidth: g, headerHeight: _, rowMetrics: v, verticalScaleFactor: y } = m, b = n.current;
14
+ let i = r.getBoundingClientRect(), a = p(r, i);
15
+ return s(o(e, i.top + (r.clientTop + r.clientHeight) * a.y, t * a.y), i.top + r.clientTop * a.y, n * a.y);
16
+ }, O = (e, t) => {
17
+ if (h === null) return null;
18
+ let { bodyScrollRef: n, scrollContainerRef: a, leftPaneScrollRef: o, rightPaneScrollRef: s, filteredRowsLength: c, visibleColumnsLength: l, paneLayout: u, leftLeadingWidth: d, centerLeadingWidth: f, rightLeadingWidth: g, headerHeight: _, rowMetrics: v, verticalScaleFactor: y } = h, b = n.current;
18
19
  if (!b || c === 0 || l === 0) return null;
19
- let x = b.getBoundingClientRect(), S = f(b, x), C = p(b.scrollTop + (E(t) - x.top) / S.y - _, a.current?.scrollTop ?? 0, y, v), w = null, T = o.current;
20
+ let x = b.getBoundingClientRect(), S = p(b, x), C = m(b.scrollTop + (D(t) - x.top) / S.y - _, a.current?.scrollTop ?? 0, y, v), w = null, T = o.current;
20
21
  if (w === null && T && u.left.entries.length > 0) {
21
22
  let t = T.getBoundingClientRect();
22
23
  if (e < t.right) {
@@ -24,108 +25,108 @@ var m = 10, h = 300, g = () => {
24
25
  w = i(u.left, n);
25
26
  }
26
27
  }
27
- let D = s.current;
28
- if (w === null && D && u.right.entries.length > 0) {
29
- let t = D.getBoundingClientRect();
28
+ let E = s.current;
29
+ if (w === null && E && u.right.entries.length > 0) {
30
+ let t = E.getBoundingClientRect();
30
31
  if (e >= t.left) {
31
32
  let n = (e - t.left) / S.x - g;
32
33
  w = i(u.right, n);
33
34
  }
34
35
  }
35
36
  if (w === null && u.center.entries.length > 0) {
36
- let t = T && u.left.entries.length === 0 ? Math.max(e, T.getBoundingClientRect().left + d * S.x) : e, n = b.scrollLeft + (t - x.left) / S.x - h;
37
+ let t = T && u.left.entries.length === 0 ? Math.max(e, T.getBoundingClientRect().left + d * S.x) : e, n = b.scrollLeft + (t - x.left) / S.x - f;
37
38
  w = i(u.center, Math.max(n, 0));
38
39
  }
39
40
  return w === null ? null : {
40
41
  row: C,
41
42
  col: r(w, 0, l - 1)
42
43
  };
43
- }, O = (e, t) => {
44
- let r = w();
45
- if (m === null || !r || r.type !== "selection") return;
46
- let i = D(e, t);
44
+ }, k = (t, n) => {
45
+ let r = T();
46
+ if (h === null || !r || r.type !== "selection") return;
47
+ let i = O(t, n);
47
48
  if (i) {
48
49
  if (r.selectionKind === "cell") {
49
- m.dispatch(n.updateSelection(i));
50
+ h.dispatch(e.updateSelection(i));
50
51
  return;
51
52
  }
52
53
  if (r.selectionKind === "row") {
53
- m.dispatch(n.updateRowSelection(i.row));
54
+ h.dispatch(e.updateRowSelection(i.row));
54
55
  return;
55
56
  }
56
- r.selectionKind === "col" && m.dispatch(n.updateColumnSelection(i.col));
57
+ r.selectionKind === "col" && h.dispatch(e.updateColumnSelection(i.col));
57
58
  }
58
- }, k = (e, t) => {
59
- let r = t.timeStamp;
60
- if (m === null) return;
61
- let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l, resolveFirstDataCell: u } = m;
59
+ }, A = (t, n) => {
60
+ let r = n.timeStamp;
61
+ if (h === null) return;
62
+ let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l, resolveFirstDataCell: u } = h;
62
63
  i.current?.focus({ preventScroll: !0 });
63
- let { target: d } = e;
64
+ let { target: d } = t;
64
65
  if (d.kind === "cell") {
65
- let e = v;
66
- if (e && e.cell.row === d.cell.row && e.cell.col === d.cell.col && r - e.time < 300) {
67
- v = null, l.current(d.cell, t);
66
+ let t = y;
67
+ if (t && t.cell.row === d.cell.row && t.cell.col === d.cell.col && r - t.time < 300) {
68
+ y = null, l.current(d.cell, n);
68
69
  return;
69
70
  }
70
- v = {
71
+ y = {
71
72
  cell: d.cell,
72
73
  time: r
73
- }, a(n.activateCell(d.cell)), o && (a(n.startSelection(d.cell)), a(n.endSelection()));
74
+ }, a(e.activateCell(d.cell)), o && (a(e.startSelection(d.cell)), a(e.endSelection()));
74
75
  return;
75
76
  }
76
- if (v = null, d.kind === "row") {
77
+ if (y = null, d.kind === "row") {
77
78
  if (s) {
78
79
  c(d.rowIndex, { shiftKey: !1 });
79
80
  return;
80
81
  }
81
- a(n.startRowSelection(d.rowIndex, u?.().col)), a(n.endSelection());
82
+ a(e.startRowSelection(d.rowIndex, u?.().col)), a(e.endSelection());
82
83
  return;
83
84
  }
84
- a(n.startColumnSelection(d.colIndex, u?.().row)), a(n.endSelection());
85
- }, A = () => {
86
- m !== null && (g = !1, m.dispatch(n.endSelection()), m.dispatch(n.endColumnResize()));
87
- }, j = (e) => {
88
- if (m === null) return;
89
- m.pointerClientRef.current = {
90
- x: e.clientX,
91
- y: e.clientY
85
+ a(e.startColumnSelection(d.colIndex, u?.().row)), a(e.endSelection());
86
+ }, j = () => {
87
+ h !== null && (_ = !1, h.dispatch(e.endSelection()), h.dispatch(e.endColumnResize()));
88
+ }, M = (t) => {
89
+ if (h === null) return;
90
+ h.pointerClientRef.current = {
91
+ x: t.clientX,
92
+ y: t.clientY
92
93
  };
93
- let t = w();
94
- if (t?.type === "columnResize") {
95
- (T === null || T.drag !== t) && (T = {
96
- drag: t,
97
- x: f(m.scrollContainerRef.current).x
94
+ let n = T();
95
+ if (n?.type === "columnResize") {
96
+ (E === null || E.drag !== n) && (E = {
97
+ drag: n,
98
+ x: p(h.scrollContainerRef.current).x
98
99
  });
99
- let r = T.x === 1 ? e.clientX : t.startX + (e.clientX - t.startX) / T.x;
100
- m.dispatch(n.updateColumnResize(r));
100
+ let r = E.x === 1 ? t.clientX : n.startX + (t.clientX - n.startX) / E.x;
101
+ h.dispatch(e.updateColumnResize(r));
101
102
  }
102
- }, M = (e) => {
103
- let t = _;
104
- t && (_ = null, e.pointerId === t.pointerId && Math.abs(e.clientX - t.x) < 10 && Math.abs(e.clientY - t.y) < 10 && k(t, e)), A();
105
- }, N = () => {
106
- _ = null, A();
103
+ }, N = (e) => {
104
+ let t = v;
105
+ t && (v = null, e.pointerId === t.pointerId && Math.abs(e.clientX - t.x) < 10 && Math.abs(e.clientY - t.y) < 10 && A(t, e)), j();
107
106
  }, P = () => {
108
- h || (h = !0, window.addEventListener("pointermove", j), window.addEventListener("pointerup", M), window.addEventListener("pointercancel", N));
107
+ v = null, j();
109
108
  }, F = () => {
110
- h && (h = !1, window.removeEventListener("pointermove", j), window.removeEventListener("pointerup", M), window.removeEventListener("pointercancel", N));
109
+ g || (g = !0, window.addEventListener("pointermove", M), window.addEventListener("pointerup", N), window.addEventListener("pointercancel", P));
111
110
  }, I = () => {
112
- C = !1, m !== null && m.autoScrollFrameRef.current !== null && (cancelAnimationFrame(m.autoScrollFrameRef.current), m.autoScrollFrameRef.current = null);
111
+ g && (g = !1, window.removeEventListener("pointermove", M), window.removeEventListener("pointerup", N), window.removeEventListener("pointercancel", P));
113
112
  }, L = () => {
114
- if (m === null || !C) return;
115
- let { scrollContainerRef: e, pointerClientRef: t, autoScrollFrameRef: n } = m, r = e.current, i = t.current;
113
+ w = !1, h !== null && h.autoScrollFrameRef.current !== null && (cancelAnimationFrame(h.autoScrollFrameRef.current), h.autoScrollFrameRef.current = null);
114
+ }, R = () => {
115
+ if (h === null || !w) return;
116
+ let { scrollContainerRef: e, pointerClientRef: t, autoScrollFrameRef: n } = h, r = e.current, i = t.current;
116
117
  if (!r || !i) {
117
- n.current = requestAnimationFrame(L);
118
+ n.current = requestAnimationFrame(R);
118
119
  return;
119
120
  }
120
- if (!S) {
121
- let e = x;
122
- if (e && !c(e, i, 6)) {
123
- n.current = requestAnimationFrame(L);
121
+ if (!C) {
122
+ let e = S;
123
+ if (e && !l(e, i, 6)) {
124
+ n.current = requestAnimationFrame(R);
124
125
  return;
125
126
  }
126
- S = !0;
127
+ C = !0;
127
128
  }
128
- let a = r.getBoundingClientRect(), o = f(r, a), p = u({
129
+ let a = r.getBoundingClientRect(), o = p(r, a), s = d({
129
130
  rectLeft: a.left,
130
131
  rectTop: a.top,
131
132
  clientLeft: r.clientLeft,
@@ -133,166 +134,166 @@ var m = 10, h = 300, g = () => {
133
134
  clientWidth: r.clientWidth,
134
135
  clientHeight: r.clientHeight,
135
136
  scale: o
136
- }), h = w(), g = h?.type === "selection" && h.selectionKind === "col", _ = h?.type === "selection" && h.selectionKind === "row", v = g ? 0 : l(i.y, d(p.top, (m.stickyTopHeight ?? 0) * o.y, 24), p.bottom - (m.footerHeight ?? 0), 24), y = _ ? 0 : l(i.x, p.left, p.right, 24), b = s(r.scrollTop, v, 18, r.scrollHeight - r.clientHeight), T = s(r.scrollLeft, y, 18, r.scrollWidth - r.clientWidth);
137
- (b !== r.scrollTop || T !== r.scrollLeft) && (r.scrollTo({
137
+ }), m = T(), g = m?.type === "selection" && m.selectionKind === "col", _ = m?.type === "selection" && m.selectionKind === "row", v = g ? 0 : u(i.y, f(s.top, (h.stickyTopHeight ?? 0) * o.y, 24), s.bottom - (h.footerHeight ?? 0), 24), y = _ ? 0 : u(i.x, s.left, s.right, 24), b = c(r.scrollTop, v, 18, r.scrollHeight - r.clientHeight), x = c(r.scrollLeft, y, 18, r.scrollWidth - r.clientWidth);
138
+ (b !== r.scrollTop || x !== r.scrollLeft) && (r.scrollTo({
138
139
  top: b,
139
- left: T,
140
+ left: x,
140
141
  behavior: "auto"
141
- }), O(i.x, i.y)), n.current = requestAnimationFrame(L);
142
- }, R = () => {
143
- let e = w()?.type === "selection";
144
- e && !C ? (C = !0, m !== null && (m.autoScrollFrameRef.current = requestAnimationFrame(L))) : !e && C && I();
142
+ }), k(i.x, i.y)), n.current = requestAnimationFrame(R);
145
143
  }, z = () => {
146
- if (b !== null) return;
144
+ let e = T()?.type === "selection";
145
+ e && !w ? (w = !0, h !== null && (h.autoScrollFrameRef.current = requestAnimationFrame(R))) : !e && w && L();
146
+ }, B = () => {
147
+ if (x !== null) return;
147
148
  let e = () => {
148
- if (!g || m === null) {
149
- b = null;
149
+ if (!_ || h === null) {
150
+ x = null;
150
151
  return;
151
152
  }
152
- let { scrollContainerRef: t, pointerClientRef: n, onGutterRowSelectDrag: r } = m, i = t.current, a = n.current;
153
+ let { scrollContainerRef: t, pointerClientRef: n, onGutterRowSelectDrag: r } = h, i = t.current, a = n.current;
153
154
  if (!i || !a) {
154
- b = requestAnimationFrame(e);
155
+ x = requestAnimationFrame(e);
155
156
  return;
156
157
  }
157
- if (!S) {
158
- let t = x;
159
- if (t && !c(t, a, 6)) {
160
- b = requestAnimationFrame(e);
158
+ if (!C) {
159
+ let t = S;
160
+ if (t && !l(t, a, 6)) {
161
+ x = requestAnimationFrame(e);
161
162
  return;
162
163
  }
163
- S = !0;
164
+ C = !0;
164
165
  }
165
- let o = i.getBoundingClientRect(), p = f(i, o), h = u({
166
+ let o = i.getBoundingClientRect(), s = p(i, o), m = d({
166
167
  rectLeft: o.left,
167
168
  rectTop: o.top,
168
169
  clientLeft: i.clientLeft,
169
170
  clientTop: i.clientTop,
170
171
  clientWidth: i.clientWidth,
171
172
  clientHeight: i.clientHeight,
172
- scale: p
173
- }), _ = l(a.y, d(h.top, (m.stickyTopHeight ?? 0) * p.y, 24), h.bottom - (m.footerHeight ?? 0), 24), v = s(i.scrollTop, _, 18, i.scrollHeight - i.clientHeight);
173
+ scale: s
174
+ }), g = u(a.y, f(m.top, (h.stickyTopHeight ?? 0) * s.y, 24), m.bottom - (h.footerHeight ?? 0), 24), v = c(i.scrollTop, g, 18, i.scrollHeight - i.clientHeight);
174
175
  if (v !== i.scrollTop) {
175
176
  i.scrollTo({
176
177
  top: v,
177
178
  left: i.scrollLeft,
178
179
  behavior: "auto"
179
180
  });
180
- let e = D(a.x, a.y);
181
+ let e = O(a.x, a.y);
181
182
  e && r(e.row);
182
183
  }
183
- b = requestAnimationFrame(e);
184
+ x = requestAnimationFrame(e);
184
185
  };
185
- b = requestAnimationFrame(e);
186
- }, B = (e, t) => (e.preventDefault(), m === null || e.button !== 0 ? !1 : (y = e.pointerType, e.pointerType === "touch" ? (_ = {
186
+ x = requestAnimationFrame(e);
187
+ }, V = (e, t) => (e.preventDefault(), h === null || e.button !== 0 ? !1 : (b = e.pointerType, e.pointerType === "touch" ? (v = {
187
188
  pointerId: e.pointerId,
188
189
  x: e.clientX,
189
190
  y: e.clientY,
190
191
  target: t
191
- }, !1) : (m.gridRootRef.current?.focus({ preventScroll: !0 }), m.pointerClientRef.current = {
192
+ }, !1) : (h.gridRootRef.current?.focus({ preventScroll: !0 }), h.pointerClientRef.current = {
192
193
  x: e.clientX,
193
194
  y: e.clientY
194
- }, x = {
195
+ }, S = {
195
196
  x: e.clientX,
196
197
  y: e.clientY
197
- }, S = !1, !0)));
198
+ }, C = !1, !0)));
198
199
  return {
199
200
  update: (e) => {
200
- m = e, P(), R();
201
+ h = e, F(), z();
201
202
  },
202
- getCellCoordFromClientPoint: D,
203
- updateSelectionFromPointer: O,
204
- handleCellPointerDown: (e, t) => {
205
- if (!(!B(t, {
203
+ getCellCoordFromClientPoint: O,
204
+ updateSelectionFromPointer: k,
205
+ handleCellPointerDown: (t, n) => {
206
+ if (!(!V(n, {
206
207
  kind: "cell",
207
- cell: e
208
- }) || m === null)) {
209
- if (t.shiftKey && m.enableRangeSelection) {
210
- let { selection: t, activeCell: r } = m.uiState, i = t?.type === "cell" ? t.range.start : r;
208
+ cell: t
209
+ }) || h === null)) {
210
+ if (n.shiftKey && h.enableRangeSelection) {
211
+ let { selection: n, activeCell: r } = a(h), i = n?.type === "cell" ? n.range.start : r;
211
212
  if (i) {
212
- m.dispatch(n.startSelection(i)), m.dispatch(n.updateSelection(e));
213
+ h.dispatch(e.startSelection(i)), h.dispatch(e.updateSelection(t));
213
214
  return;
214
215
  }
215
216
  }
216
- m.dispatch(n.activateCell(e)), m.enableRangeSelection && m.dispatch(n.startSelection(e));
217
+ h.dispatch(e.activateCell(t)), h.enableRangeSelection && h.dispatch(e.startSelection(t));
217
218
  }
218
219
  },
219
220
  handleCellDoubleClick: (e, t) => {
220
- y === "touch" || m === null || m.onCellDoubleClickRef.current(e, t);
221
+ b === "touch" || h === null || h.onCellDoubleClickRef.current(e, t);
221
222
  },
222
- handleCellPointerEnter: (e, t) => {
223
- if (m === null || (m.enableRowHover && m.setHoveredRowIndex(e.row), m.enableColumnHover && m.setHoveredColumnIndex(e.col), !m.enableRangeSelection)) return;
224
- let r = w();
225
- r?.type !== "selection" || r.selectionKind !== "cell" || (m.pointerClientRef.current = {
226
- x: t.clientX,
227
- y: t.clientY
228
- }, m.dispatch(n.updateSelection(e)));
223
+ handleCellPointerEnter: (t, n) => {
224
+ if (h === null || (h.enableRowHover && h.setHoveredRowIndex(t.row), h.enableColumnHover && h.setHoveredColumnIndex(t.col), !h.enableRangeSelection)) return;
225
+ let r = T();
226
+ r?.type !== "selection" || r.selectionKind !== "cell" || (h.pointerClientRef.current = {
227
+ x: n.clientX,
228
+ y: n.clientY
229
+ }, h.dispatch(e.updateSelection(t)));
229
230
  },
230
231
  handleNativeDragStart: (e) => {
231
232
  e.preventDefault();
232
233
  },
233
- handleRowHeaderPointerDown: (e, t) => {
234
- if (!(!B(t, {
234
+ handleRowHeaderPointerDown: (t, n) => {
235
+ if (!(!V(n, {
235
236
  kind: "row",
236
- rowIndex: e
237
- }) || m === null)) {
238
- if (m.enableRowSelection) {
239
- g = !0, m.onGutterRowSelect(e, { shiftKey: t.shiftKey }), z();
237
+ rowIndex: t
238
+ }) || h === null)) {
239
+ if (h.enableRowSelection) {
240
+ _ = !0, h.onGutterRowSelect(t, { shiftKey: n.shiftKey }), B();
240
241
  return;
241
242
  }
242
- if (t.shiftKey) {
243
- let { selection: t, activeCell: r } = m.uiState, i = t?.type === "row" ? t.startRow : r?.row;
243
+ if (n.shiftKey) {
244
+ let { selection: n, activeCell: r } = a(h), i = n?.type === "row" ? n.startRow : r?.row;
244
245
  if (i !== void 0) {
245
- m.dispatch(n.startRowSelection(i, m.resolveFirstDataCell?.().col)), m.dispatch(n.updateRowSelection(e));
246
+ h.dispatch(e.startRowSelection(i, h.resolveFirstDataCell?.().col)), h.dispatch(e.updateRowSelection(t));
246
247
  return;
247
248
  }
248
249
  }
249
- m.dispatch(n.startRowSelection(e, m.resolveFirstDataCell?.().col));
250
+ h.dispatch(e.startRowSelection(t, h.resolveFirstDataCell?.().col));
250
251
  }
251
252
  },
252
- handleRowHeaderPointerEnter: (e, t) => {
253
- if (m === null) return;
254
- if (m.enableRowHover && m.setHoveredRowIndex(e), g) {
255
- m.pointerClientRef.current = {
256
- x: t.clientX,
257
- y: t.clientY
258
- }, m.onGutterRowSelectDrag(e);
253
+ handleRowHeaderPointerEnter: (t, n) => {
254
+ if (h === null) return;
255
+ if (h.enableRowHover && h.setHoveredRowIndex(t), _) {
256
+ h.pointerClientRef.current = {
257
+ x: n.clientX,
258
+ y: n.clientY
259
+ }, h.onGutterRowSelectDrag(t);
259
260
  return;
260
261
  }
261
- let r = w();
262
- r?.type !== "selection" || r.selectionKind !== "row" || (m.pointerClientRef.current = {
263
- x: t.clientX,
264
- y: t.clientY
265
- }, m.dispatch(n.updateRowSelection(e)));
262
+ let r = T();
263
+ r?.type !== "selection" || r.selectionKind !== "row" || (h.pointerClientRef.current = {
264
+ x: n.clientX,
265
+ y: n.clientY
266
+ }, h.dispatch(e.updateRowSelection(t)));
266
267
  },
267
268
  handleColumnHeaderPointerDown: (r, i) => {
268
- if (!(!B(i, {
269
+ if (!(!V(i, {
269
270
  kind: "col",
270
271
  colIndex: r
271
- }) || m === null)) {
272
- if (i.shiftKey && m.enableSorting) {
273
- let i = m.orderedColumns[r];
274
- if (i && !t(i.key)) {
275
- let t = m.uiState.sort, r = t.find((e) => e.columnKey === i.key)?.direction ? "desc" : "asc", a = e(t, i.key, r, !0);
276
- m.dispatch(a.length === 0 ? n.clearSort() : n.setSort(a));
272
+ }) || h === null)) {
273
+ if (i.shiftKey && h.enableSorting) {
274
+ let i = h.orderedColumns[r];
275
+ if (i && !n(i.key)) {
276
+ let n = a(h).sort, r = n.find((e) => e.columnKey === i.key)?.direction ? "desc" : "asc", o = t(n, i.key, r, !0);
277
+ h.dispatch(o.length === 0 ? e.clearSort() : e.setSort(o));
277
278
  }
278
279
  return;
279
280
  }
280
- m.dispatch(n.startColumnSelection(r, m.resolveFirstDataCell?.().row));
281
+ h.dispatch(e.startColumnSelection(r, h.resolveFirstDataCell?.().row));
281
282
  }
282
283
  },
283
- handleColumnHeaderPointerEnter: (e, t) => {
284
- if (m === null) return;
285
- m.setHoveredRowIndex(null), m.enableColumnHeaderHover && m.setHoveredColumnIndex(e);
286
- let r = w();
287
- r?.type !== "selection" || r.selectionKind !== "col" || (m.pointerClientRef.current = {
288
- x: t.clientX,
289
- y: t.clientY
290
- }, m.dispatch(n.updateColumnSelection(e)));
284
+ handleColumnHeaderPointerEnter: (t, n) => {
285
+ if (h === null) return;
286
+ h.setHoveredRowIndex(null), h.enableColumnHeaderHover && h.setHoveredColumnIndex(t);
287
+ let r = T();
288
+ r?.type !== "selection" || r.selectionKind !== "col" || (h.pointerClientRef.current = {
289
+ x: n.clientX,
290
+ y: n.clientY
291
+ }, h.dispatch(e.updateColumnSelection(t)));
291
292
  },
292
293
  dispose: () => {
293
- F(), I(), b !== null && (cancelAnimationFrame(b), b = null);
294
+ I(), L(), x !== null && (cancelAnimationFrame(x), x = null);
294
295
  }
295
296
  };
296
297
  };
297
298
  //#endregion
298
- export { h as TOUCH_DOUBLE_TAP_MS, m as TOUCH_TAP_SLOP_PX, g as createPointerInteractionsController };
299
+ export { g as TOUCH_DOUBLE_TAP_MS, h as TOUCH_TAP_SLOP_PX, _ as createPointerInteractionsController };
@@ -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"),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;
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=null,E=(e,t)=>{let n=S?.canDropAt;if(!n)return!0;if(T!==null&&T.from===e&&T.slot===t)return T.allowed;let r=n(e,t);return T={from:e,slot:t,allowed:r},r},D={x:0,y:0},O=null,k=!1,A=null,j=null,M=null,N=null,P=null,F=null,I=0,L=null,R=()=>S?.motion===`live`,z=null,B=null,V=null,H=()=>[S?.leftIndicatorRef.current??null,S?.centerIndicatorRef.current??null,S?.rightIndicatorRef.current??null],U=()=>{for(let e of H())e&&(e.style.display=`none`)},W=e=>{if(z)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),z=t,B=n,V=null},G=e=>{let t=z;if(!t)return;t.style.transform=`translate(`+(D.x+c)+`px,`+(D.y+l)+`px)`;let n=e?`move`:`out`;if(V===n)return;V=n;let r=B;n===`out`?(t.style.opacity=u,r&&(r.innerHTML=f)):(t.style.opacity=`1`,r&&(r.innerHTML=d))},K=()=>{z&&z.parentNode&&z.parentNode.removeChild(z),z=null,B=null,V=null},q=(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,R()?`live`:``):e.removeAttribute(g))})},J=()=>{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},ee=t=>{let n=F,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-I)*S.verticalScaleFactor,s=(O?D.y-O.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=L??new Set;L=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=``}},te=(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&&R()?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=te(D.x,D.y),n=C;if(R()){t&&n!==null&&(e.resolveMoveTargetIndex(n,t.slot)===null?w=null:E(n,t.slot)&&(w=t.slot)),U(),ee(w);return}let r=t!==null&&n!==null&&e.resolveMoveTargetIndex(n,t.slot)!==null&&!E(n,t.slot);if(G(r?null:t),!t||n===null||r||e.resolveMoveTargetIndex(n,t.slot)===null){w=null,U();return}w=t.slot;for(let e of H())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},X=()=>{if(C===null){M=null;return}let e=S?.scrollContainerRef.current??null;if(e&&(k||(!O||n.hasPointerLeftActivationRadius(O,D,6))&&(k=!0),k)){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(D.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(),M=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=>{M!==null&&(cancelAnimationFrame(M),M=null),document.body.style.cursor=``,U(),K();let n=C,r=w,i=P;q(n,!1),C=null,P=null,w=null,O=null,j=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=a!==null&&n!==null&&r!==null&&t&&!E(n,r)?null:a;T=null;let s=t&&n!==null&&o!==null&&S!==null,c=F;F=null;let l=c&&s&&S!==null&&!_(S.scrollContainerRef.current)?Q():null,u=L;if(L=null,u&&(s?u.forEach(x):(u.forEach(e=>{e.isConnected&&(e.style.transition=h,e.style.transform=`translateY(0px)`,e.style.zIndex=``)}),window.setTimeout(()=>{u.forEach(e=>{L?.has(e)||x(e)})},200))),c)if(s)c.forEach(({baseY:e},t)=>{t.style.transition=``,t.style.willChange=``,t.isConnected&&(t.style.transform=`translateY(${e}px)`)});else{let e=[];c.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(!s||n===null||o===null||S===null)return;let d=l??(_(S.scrollContainerRef.current)?null:Q()),f=d?{tops:d,from:n,to:o,row:i}:null;N=f,S.commitRowMove(n,o),f&&requestAnimationFrame(()=>{N===f&&(N=null)})},ne=()=>{let e=N;if(N=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)L?.has(e)||x(e)},280)}},re=(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!==j)return;A?.(),$(!1)}C=e,P=S.getDragRow?.(e)??null,j=t.pointerId,w=null,D={x:t.clientX,y:t.clientY},O={x:t.clientX,y:t.clientY},k=!1,document.body.style.cursor=`grabbing`,R()?(F=J(),I=S.scrollContainerRef.current?.scrollTop??0):W(S.getRowDragLabel(e)),q(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&(D={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(),A=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),A=s,Y(),M=requestAnimationFrame(X)},ie=e=>{if(C===null||P==null||S?.locateDragRow===void 0)return;let t=S.locateDragRow(P,C);if(F&&F.forEach((e,t)=>{if(!t.isConnected){F?.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){F?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){A?.(),$(!1);return}F&&t!==C&&O!==null&&e!==null&&(O={x:O.x,y:O.y+S.rowMetrics.rowTop(t)-e.rowTop(C)}),t!==C&&(q(null,!1),C=t,q(t,!0)),Y()};return{update:e=>{let t=S;S=e,t?.canDropAt!==e.canDropAt&&(T=null),C!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&ie(t.rowMetrics)},onRowDragHandlePointerDown:re,applyReorderSettle:ne,dispose:()=>{A?.(),A=null,M!==null&&(cancelAnimationFrame(M),M=null),document.body.style.cursor=``,K(),q(C,!1),C=null,P=null,w=null,T=null,F=null,L?.forEach(x),L=null,N=null}}};exports.createRowDragController=S;
@@ -23,6 +23,7 @@ export type RowDragArgs = {
23
23
  getDragRow?: (viewIndex: number) => unknown;
24
24
  locateDragRow?: (dragRow: unknown, hint: number) => number | null;
25
25
  gridRootRef?: ReadonlyRef<HTMLElement | null>;
26
+ canDropAt?: (fromIndex: number, slot: number) => boolean;
26
27
  };
27
28
  export type RowDragHandlePointerEvent = {
28
29
  button: number;