@ishibashi0112/spreadsheet-grid-core 0.48.0 → 0.49.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 (106) hide show
  1. package/dist/controllers/autoHeightMeasurer.cjs +1 -1
  2. package/dist/controllers/autoHeightMeasurer.js +4 -2
  3. package/dist/controllers/clipboardController.cjs +1 -1
  4. package/dist/controllers/clipboardController.d.ts +2 -1
  5. package/dist/controllers/clipboardController.js +67 -61
  6. package/dist/controllers/columnAutosizeRunner.cjs +1 -1
  7. package/dist/controllers/columnAutosizeRunner.d.ts +3 -0
  8. package/dist/controllers/columnAutosizeRunner.js +40 -24
  9. package/dist/controllers/columnHeaderDragController.cjs +1 -1
  10. package/dist/controllers/columnHeaderDragController.js +5 -2
  11. package/dist/controllers/editController.cjs +1 -1
  12. package/dist/controllers/editController.js +2 -2
  13. package/dist/controllers/fillHandleController.cjs +1 -0
  14. package/dist/controllers/fillHandleController.d.ts +87 -0
  15. package/dist/controllers/fillHandleController.js +346 -0
  16. package/dist/controllers/filterPopoverController.cjs +1 -1
  17. package/dist/controllers/filterPopoverController.js +55 -46
  18. package/dist/controllers/globalFilteredOrder.cjs +1 -1
  19. package/dist/controllers/globalFilteredOrder.js +5 -5
  20. package/dist/controllers/historyController.cjs +1 -1
  21. package/dist/controllers/historyController.d.ts +1 -0
  22. package/dist/controllers/historyController.js +8 -5
  23. package/dist/controllers/keyboardController.cjs +1 -1
  24. package/dist/controllers/keyboardController.js +2 -2
  25. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  26. package/dist/controllers/pointerInteractionsController.d.ts +2 -0
  27. package/dist/controllers/pointerInteractionsController.js +136 -132
  28. package/dist/controllers/rowDragController.cjs +1 -1
  29. package/dist/controllers/rowDragController.d.ts +1 -0
  30. package/dist/controllers/rowDragController.js +104 -97
  31. package/dist/controllers/scrollSyncController.cjs +1 -1
  32. package/dist/controllers/scrollSyncController.d.ts +1 -0
  33. package/dist/controllers/scrollSyncController.js +32 -21
  34. package/dist/controllers/selectOptionsCollector.cjs +1 -1
  35. package/dist/controllers/selectOptionsCollector.js +5 -5
  36. package/dist/controllers/selectionAggregatesRunner.cjs +1 -0
  37. package/dist/controllers/selectionAggregatesRunner.d.ts +27 -0
  38. package/dist/controllers/selectionAggregatesRunner.js +65 -0
  39. package/dist/controllers/serverSideRowModel.cjs +1 -1
  40. package/dist/controllers/serverSideRowModel.js +75 -69
  41. package/dist/controllers/tooltipController.cjs +1 -1
  42. package/dist/controllers/tooltipController.js +44 -43
  43. package/dist/controllers/viewportSyncController.cjs +1 -1
  44. package/dist/controllers/viewportSyncController.d.ts +3 -2
  45. package/dist/controllers/viewportSyncController.js +6 -4
  46. package/dist/engine/columnCommands.cjs +1 -1
  47. package/dist/engine/columnCommands.js +1 -1
  48. package/dist/engine/columnLayout.cjs +1 -1
  49. package/dist/engine/columnLayout.js +1 -1
  50. package/dist/engine/createGridEngine.cjs +1 -1
  51. package/dist/engine/createGridEngine.d.ts +2 -0
  52. package/dist/engine/createGridEngine.js +43 -41
  53. package/dist/engine/gridApi.cjs +1 -1
  54. package/dist/engine/gridApi.d.ts +6 -0
  55. package/dist/engine/gridApi.js +134 -123
  56. package/dist/logic/aggregation.cjs +1 -1
  57. package/dist/logic/aggregation.d.ts +1 -0
  58. package/dist/logic/aggregation.js +16 -7
  59. package/dist/logic/autoScrollGeometry.cjs +1 -1
  60. package/dist/logic/autoScrollGeometry.d.ts +1 -0
  61. package/dist/logic/autoScrollGeometry.js +3 -3
  62. package/dist/logic/clearCells.cjs +1 -1
  63. package/dist/logic/clearCells.d.ts +1 -1
  64. package/dist/logic/clearCells.js +7 -7
  65. package/dist/logic/columnAutosize.cjs +1 -1
  66. package/dist/logic/columnAutosize.d.ts +6 -0
  67. package/dist/logic/columnAutosize.js +60 -39
  68. package/dist/logic/exportCsv.cjs +2 -2
  69. package/dist/logic/exportCsv.d.ts +5 -1
  70. package/dist/logic/exportCsv.js +16 -15
  71. package/dist/logic/exportData.cjs +1 -1
  72. package/dist/logic/exportData.d.ts +2 -1
  73. package/dist/logic/exportData.js +27 -21
  74. package/dist/logic/fillHandle.cjs +1 -0
  75. package/dist/logic/fillHandle.d.ts +69 -0
  76. package/dist/logic/fillHandle.js +254 -0
  77. package/dist/logic/fillSeries.cjs +1 -0
  78. package/dist/logic/fillSeries.d.ts +11 -0
  79. package/dist/logic/fillSeries.js +239 -0
  80. package/dist/logic/filtering.cjs +1 -1
  81. package/dist/logic/filtering.js +37 -37
  82. package/dist/logic/gridState.cjs +1 -1
  83. package/dist/logic/gridState.js +1 -1
  84. package/dist/logic/imeInput.cjs +1 -1
  85. package/dist/logic/imeInput.js +2 -2
  86. package/dist/logic/labelRows.cjs +1 -1
  87. package/dist/logic/labelRows.js +1 -1
  88. package/dist/logic/selectOptions.cjs +1 -1
  89. package/dist/logic/selectOptions.js +1 -1
  90. package/dist/logic/selectionAggregates.cjs +1 -0
  91. package/dist/logic/selectionAggregates.d.ts +25 -0
  92. package/dist/logic/selectionAggregates.js +74 -0
  93. package/dist/logic/totalRow.cjs +1 -0
  94. package/dist/logic/totalRow.d.ts +25 -0
  95. package/dist/logic/totalRow.js +90 -0
  96. package/dist/model/gridReducer.cjs +1 -1
  97. package/dist/model/gridReducer.js +1 -1
  98. package/dist/model/gridTypes.core.d.ts +202 -16
  99. package/dist/model/gridTypes.unbound.d.ts +4 -0
  100. package/dist/utils/clipboard.cjs +1 -1
  101. package/dist/utils/clipboard.d.ts +1 -1
  102. package/dist/utils/clipboard.js +9 -9
  103. package/dist/utils/permissions.cjs +1 -1
  104. package/dist/utils/permissions.d.ts +6 -2
  105. package/dist/utils/permissions.js +8 -2
  106. 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/verticalGeometry.cjs");var o=10,s=300,c=()=>{let o=null,s=!1,c=!1,l=null,u=null,d=`mouse`,f=null,p=null,m=!1,h=!1,g=()=>o?.uiState.dragState??null,_=(e,t)=>{if(o===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:s,rightPaneScrollRef:c,filteredRowsLength:l,visibleColumnsLength:u,paneLayout:d,leftLeadingWidth:f,centerLeadingWidth:p,rightLeadingWidth:m,headerHeight:h,rowMetrics:g,verticalScaleFactor:_}=o,v=n.current;if(!v||l===0||u===0)return null;let y=v.getBoundingClientRect(),b=a.clientYToRowIndex(v.scrollTop+t-y.top-h,i.current?.scrollTop??0,_,g),x=null,S=s.current;if(x===null&&S&&d.left.entries.length>0){let t=S.getBoundingClientRect();if(e<t.right){let n=e-t.left-f;x=r.findLogicalIndexFromPaneOffset(d.left,n)}}let C=c.current;if(x===null&&C&&d.right.entries.length>0){let t=C.getBoundingClientRect();if(e>=t.left){let n=e-t.left-m;x=r.findLogicalIndexFromPaneOffset(d.right,n)}}if(x===null&&d.center.entries.length>0){let t=v.scrollLeft+e-y.left-p;x=r.findLogicalIndexFromPaneOffset(d.center,Math.max(t,0))}return x===null?null:{row:b,col:r.clamp(x,0,u-1)}},v=(e,t)=>{let r=g();if(o===null||!r||r.type!==`selection`)return;let i=_(e,t);if(i){if(r.selectionKind===`cell`){o.dispatch(n.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){o.dispatch(n.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&o.dispatch(n.gridActions.updateColumnSelection(i.col))}},y=(e,t)=>{let r=t.timeStamp;if(o===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:s,enableRowSelection:c,onGutterRowSelect:l,onCellDoubleClickRef:d}=o;i.current?.focus({preventScroll:!0});let{target:f}=e;if(f.kind===`cell`){let e=u;if(e&&e.cell.row===f.cell.row&&e.cell.col===f.cell.col&&r-e.time<300){u=null,d.current(f.cell,t);return}u={cell:f.cell,time:r},a(n.gridActions.activateCell(f.cell)),s&&(a(n.gridActions.startSelection(f.cell)),a(n.gridActions.endSelection()));return}if(u=null,f.kind===`row`){if(c){l(f.rowIndex,{shiftKey:!1});return}a(n.gridActions.startRowSelection(f.rowIndex)),a(n.gridActions.endSelection());return}a(n.gridActions.startColumnSelection(f.colIndex)),a(n.gridActions.endSelection())},b=()=>{o!==null&&(c=!1,o.dispatch(n.gridActions.endSelection()),o.dispatch(n.gridActions.endColumnResize()))},x=e=>{o!==null&&(o.pointerClientRef.current={x:e.clientX,y:e.clientY},g()?.type===`columnResize`&&o.dispatch(n.gridActions.updateColumnResize(e.clientX)))},S=e=>{let t=l;t&&(l=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&y(t,e)),b()},C=()=>{l=null,b()},w=()=>{s||(s=!0,window.addEventListener(`pointermove`,x),window.addEventListener(`pointerup`,S),window.addEventListener(`pointercancel`,C))},T=()=>{s&&(s=!1,window.removeEventListener(`pointermove`,x),window.removeEventListener(`pointerup`,S),window.removeEventListener(`pointercancel`,C))},E=()=>{h=!1,o!==null&&o.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(o.autoScrollFrameRef.current),o.autoScrollFrameRef.current=null)},D=()=>{if(o===null||!h)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=o,r=e.current,a=t.current;if(!r||!a){n.current=requestAnimationFrame(D);return}if(!m){let e=p;if(e&&!i.hasPointerLeftActivationRadius(e,a,6)){n.current=requestAnimationFrame(D);return}m=!0}let s=r.getBoundingClientRect(),c=i.resolveScrollContentBox({rectLeft:s.left,rectTop:s.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight}),l=g(),u=l?.type===`selection`&&l.selectionKind===`col`,d=l?.type===`selection`&&l.selectionKind===`row`,f=u?0:i.resolveAutoScrollAxisDirection(a.y,c.top,c.bottom,24),_=d?0:i.resolveAutoScrollAxisDirection(a.x,c.left,c.right,24),y=i.computeNextScrollPosition(r.scrollTop,f,18,r.scrollHeight-r.clientHeight),b=i.computeNextScrollPosition(r.scrollLeft,_,18,r.scrollWidth-r.clientWidth);(y!==r.scrollTop||b!==r.scrollLeft)&&(r.scrollTo({top:y,left:b,behavior:`auto`}),v(a.x,a.y)),n.current=requestAnimationFrame(D)},O=()=>{let e=g()?.type===`selection`;e&&!h?(h=!0,o!==null&&(o.autoScrollFrameRef.current=requestAnimationFrame(D))):!e&&h&&E()},k=()=>{if(f!==null)return;let e=()=>{if(!c||o===null){f=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=o,a=t.current,s=n.current;if(!a||!s){f=requestAnimationFrame(e);return}if(!m){let t=p;if(t&&!i.hasPointerLeftActivationRadius(t,s,6)){f=requestAnimationFrame(e);return}m=!0}let l=a.getBoundingClientRect(),u=i.resolveScrollContentBox({rectLeft:l.left,rectTop:l.top,clientLeft:a.clientLeft,clientTop:a.clientTop,clientWidth:a.clientWidth,clientHeight:a.clientHeight}),d=i.resolveAutoScrollAxisDirection(s.y,u.top,u.bottom,24),h=i.computeNextScrollPosition(a.scrollTop,d,18,a.scrollHeight-a.clientHeight);if(h!==a.scrollTop){a.scrollTo({top:h,left:a.scrollLeft,behavior:`auto`});let e=_(s.x,s.y);e&&r(e.row)}f=requestAnimationFrame(e)};f=requestAnimationFrame(e)},A=(e,t)=>(e.preventDefault(),o===null||e.button!==0?!1:(d=e.pointerType,e.pointerType===`touch`?(l={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(o.gridRootRef.current?.focus({preventScroll:!0}),o.pointerClientRef.current={x:e.clientX,y:e.clientY},p={x:e.clientX,y:e.clientY},m=!1,!0)));return{update:e=>{o=e,w(),O()},updateSelectionFromPointer:v,handleCellPointerDown:(e,t)=>{!A(t,{kind:`cell`,cell:e})||o===null||(o.dispatch(n.gridActions.activateCell(e)),o.enableRangeSelection&&o.dispatch(n.gridActions.startSelection(e)))},handleCellDoubleClick:(e,t)=>{d===`touch`||o===null||o.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(e,t)=>{if(o===null||(o.enableRowHover&&o.setHoveredRowIndex(e.row),o.enableColumnHover&&o.setHoveredColumnIndex(e.col),!o.enableRangeSelection))return;let r=g();r?.type!==`selection`||r.selectionKind!==`cell`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateSelection(e)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(e,t)=>{if(!(!A(t,{kind:`row`,rowIndex:e})||o===null)){if(o.enableRowSelection){c=!0,o.onGutterRowSelect(e,{shiftKey:t.shiftKey}),k();return}o.dispatch(n.gridActions.startRowSelection(e))}},handleRowHeaderPointerEnter:(e,t)=>{if(o===null)return;if(o.enableRowHover&&o.setHoveredRowIndex(e),c){o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.onGutterRowSelectDrag(e);return}let r=g();r?.type!==`selection`||r.selectionKind!==`row`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateRowSelection(e)))},handleColumnHeaderPointerDown:(r,i)=>{if(!(!A(i,{kind:`col`,colIndex:r})||o===null)){if(i.shiftKey&&o.enableSorting){let i=o.orderedColumns[r];if(i&&!t.isSyntheticColumnKey(i.key)){let t=o.uiState.sort,r=t.find(e=>e.columnKey===i.key)?.direction?`desc`:`asc`,a=e.nextSortEntries(t,i.key,r,!0);o.dispatch(a.length===0?n.gridActions.clearSort():n.gridActions.setSort(a))}return}o.dispatch(n.gridActions.startColumnSelection(r))}},handleColumnHeaderPointerEnter:(e,t)=>{if(o===null)return;o.setHoveredRowIndex(null),o.enableColumnHeaderHover&&o.setHoveredColumnIndex(e);let r=g();r?.type!==`selection`||r.selectionKind!==`col`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateColumnSelection(e)))},dispose:()=>{T(),E(),f!==null&&(cancelAnimationFrame(f),f=null)}}};exports.TOUCH_DOUBLE_TAP_MS=s,exports.TOUCH_TAP_SLOP_PX=o,exports.createPointerInteractionsController=c;
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/verticalGeometry.cjs");var o=10,s=300,c=()=>{let o=null,s=!1,c=!1,l=null,u=null,d=`mouse`,f=null,p=null,m=!1,h=!1,g=()=>o?.uiState.dragState??null,_=e=>{let t=o?.footerHeight??0,n=o?.scrollContainerRef.current??null;return t<=0||!n?e:i.clampClientYAboveFooter(e,n.getBoundingClientRect().top+n.clientTop+n.clientHeight,t)},v=(e,t)=>{if(o===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:s,rightPaneScrollRef:c,filteredRowsLength:l,visibleColumnsLength:u,paneLayout:d,leftLeadingWidth:f,centerLeadingWidth:p,rightLeadingWidth:m,headerHeight:h,rowMetrics:g,verticalScaleFactor:v}=o,y=n.current;if(!y||l===0||u===0)return null;let b=y.getBoundingClientRect(),x=a.clientYToRowIndex(y.scrollTop+_(t)-b.top-h,i.current?.scrollTop??0,v,g),S=null,C=s.current;if(S===null&&C&&d.left.entries.length>0){let t=C.getBoundingClientRect();if(e<t.right){let n=e-t.left-f;S=r.findLogicalIndexFromPaneOffset(d.left,n)}}let w=c.current;if(S===null&&w&&d.right.entries.length>0){let t=w.getBoundingClientRect();if(e>=t.left){let n=e-t.left-m;S=r.findLogicalIndexFromPaneOffset(d.right,n)}}if(S===null&&d.center.entries.length>0){let t=y.scrollLeft+e-b.left-p;S=r.findLogicalIndexFromPaneOffset(d.center,Math.max(t,0))}return S===null?null:{row:x,col:r.clamp(S,0,u-1)}},y=(e,t)=>{let r=g();if(o===null||!r||r.type!==`selection`)return;let i=v(e,t);if(i){if(r.selectionKind===`cell`){o.dispatch(n.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){o.dispatch(n.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&o.dispatch(n.gridActions.updateColumnSelection(i.col))}},b=(e,t)=>{let r=t.timeStamp;if(o===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:s,enableRowSelection:c,onGutterRowSelect:l,onCellDoubleClickRef:d}=o;i.current?.focus({preventScroll:!0});let{target:f}=e;if(f.kind===`cell`){let e=u;if(e&&e.cell.row===f.cell.row&&e.cell.col===f.cell.col&&r-e.time<300){u=null,d.current(f.cell,t);return}u={cell:f.cell,time:r},a(n.gridActions.activateCell(f.cell)),s&&(a(n.gridActions.startSelection(f.cell)),a(n.gridActions.endSelection()));return}if(u=null,f.kind===`row`){if(c){l(f.rowIndex,{shiftKey:!1});return}a(n.gridActions.startRowSelection(f.rowIndex)),a(n.gridActions.endSelection());return}a(n.gridActions.startColumnSelection(f.colIndex)),a(n.gridActions.endSelection())},x=()=>{o!==null&&(c=!1,o.dispatch(n.gridActions.endSelection()),o.dispatch(n.gridActions.endColumnResize()))},S=e=>{o!==null&&(o.pointerClientRef.current={x:e.clientX,y:e.clientY},g()?.type===`columnResize`&&o.dispatch(n.gridActions.updateColumnResize(e.clientX)))},C=e=>{let t=l;t&&(l=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&b(t,e)),x()},w=()=>{l=null,x()},T=()=>{s||(s=!0,window.addEventListener(`pointermove`,S),window.addEventListener(`pointerup`,C),window.addEventListener(`pointercancel`,w))},E=()=>{s&&(s=!1,window.removeEventListener(`pointermove`,S),window.removeEventListener(`pointerup`,C),window.removeEventListener(`pointercancel`,w))},D=()=>{h=!1,o!==null&&o.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(o.autoScrollFrameRef.current),o.autoScrollFrameRef.current=null)},O=()=>{if(o===null||!h)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=o,r=e.current,a=t.current;if(!r||!a){n.current=requestAnimationFrame(O);return}if(!m){let e=p;if(e&&!i.hasPointerLeftActivationRadius(e,a,6)){n.current=requestAnimationFrame(O);return}m=!0}let s=r.getBoundingClientRect(),c=i.resolveScrollContentBox({rectLeft:s.left,rectTop:s.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight}),l=g(),u=l?.type===`selection`&&l.selectionKind===`col`,d=l?.type===`selection`&&l.selectionKind===`row`,f=u?0:i.resolveAutoScrollAxisDirection(a.y,c.top,c.bottom-(o.footerHeight??0),24),_=d?0:i.resolveAutoScrollAxisDirection(a.x,c.left,c.right,24),v=i.computeNextScrollPosition(r.scrollTop,f,18,r.scrollHeight-r.clientHeight),b=i.computeNextScrollPosition(r.scrollLeft,_,18,r.scrollWidth-r.clientWidth);(v!==r.scrollTop||b!==r.scrollLeft)&&(r.scrollTo({top:v,left:b,behavior:`auto`}),y(a.x,a.y)),n.current=requestAnimationFrame(O)},k=()=>{let e=g()?.type===`selection`;e&&!h?(h=!0,o!==null&&(o.autoScrollFrameRef.current=requestAnimationFrame(O))):!e&&h&&D()},A=()=>{if(f!==null)return;let e=()=>{if(!c||o===null){f=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=o,a=t.current,s=n.current;if(!a||!s){f=requestAnimationFrame(e);return}if(!m){let t=p;if(t&&!i.hasPointerLeftActivationRadius(t,s,6)){f=requestAnimationFrame(e);return}m=!0}let l=a.getBoundingClientRect(),u=i.resolveScrollContentBox({rectLeft:l.left,rectTop:l.top,clientLeft:a.clientLeft,clientTop:a.clientTop,clientWidth:a.clientWidth,clientHeight:a.clientHeight}),d=i.resolveAutoScrollAxisDirection(s.y,u.top,u.bottom-(o.footerHeight??0),24),h=i.computeNextScrollPosition(a.scrollTop,d,18,a.scrollHeight-a.clientHeight);if(h!==a.scrollTop){a.scrollTo({top:h,left:a.scrollLeft,behavior:`auto`});let e=v(s.x,s.y);e&&r(e.row)}f=requestAnimationFrame(e)};f=requestAnimationFrame(e)},j=(e,t)=>(e.preventDefault(),o===null||e.button!==0?!1:(d=e.pointerType,e.pointerType===`touch`?(l={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(o.gridRootRef.current?.focus({preventScroll:!0}),o.pointerClientRef.current={x:e.clientX,y:e.clientY},p={x:e.clientX,y:e.clientY},m=!1,!0)));return{update:e=>{o=e,T(),k()},getCellCoordFromClientPoint:v,updateSelectionFromPointer:y,handleCellPointerDown:(e,t)=>{!j(t,{kind:`cell`,cell:e})||o===null||(o.dispatch(n.gridActions.activateCell(e)),o.enableRangeSelection&&o.dispatch(n.gridActions.startSelection(e)))},handleCellDoubleClick:(e,t)=>{d===`touch`||o===null||o.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(e,t)=>{if(o===null||(o.enableRowHover&&o.setHoveredRowIndex(e.row),o.enableColumnHover&&o.setHoveredColumnIndex(e.col),!o.enableRangeSelection))return;let r=g();r?.type!==`selection`||r.selectionKind!==`cell`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateSelection(e)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(e,t)=>{if(!(!j(t,{kind:`row`,rowIndex:e})||o===null)){if(o.enableRowSelection){c=!0,o.onGutterRowSelect(e,{shiftKey:t.shiftKey}),A();return}o.dispatch(n.gridActions.startRowSelection(e))}},handleRowHeaderPointerEnter:(e,t)=>{if(o===null)return;if(o.enableRowHover&&o.setHoveredRowIndex(e),c){o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.onGutterRowSelectDrag(e);return}let r=g();r?.type!==`selection`||r.selectionKind!==`row`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateRowSelection(e)))},handleColumnHeaderPointerDown:(r,i)=>{if(!(!j(i,{kind:`col`,colIndex:r})||o===null)){if(i.shiftKey&&o.enableSorting){let i=o.orderedColumns[r];if(i&&!t.isSyntheticColumnKey(i.key)){let t=o.uiState.sort,r=t.find(e=>e.columnKey===i.key)?.direction?`desc`:`asc`,a=e.nextSortEntries(t,i.key,r,!0);o.dispatch(a.length===0?n.gridActions.clearSort():n.gridActions.setSort(a))}return}o.dispatch(n.gridActions.startColumnSelection(r))}},handleColumnHeaderPointerEnter:(e,t)=>{if(o===null)return;o.setHoveredRowIndex(null),o.enableColumnHeaderHover&&o.setHoveredColumnIndex(e);let r=g();r?.type!==`selection`||r.selectionKind!==`col`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateColumnSelection(e)))},dispose:()=>{E(),D(),f!==null&&(cancelAnimationFrame(f),f=null)}}};exports.TOUCH_DOUBLE_TAP_MS=s,exports.TOUCH_TAP_SLOP_PX=o,exports.createPointerInteractionsController=c;
@@ -42,6 +42,7 @@ export type PointerInteractionsArgs<T> = {
42
42
  centerLeadingWidth: number;
43
43
  rightLeadingWidth: number;
44
44
  headerHeight: number;
45
+ footerHeight?: number;
45
46
  rowMetrics: RowMetrics;
46
47
  verticalScaleFactor: number;
47
48
  setHoveredRowIndex: (value: number | null) => void;
@@ -58,6 +59,7 @@ export type PointerInteractionsArgs<T> = {
58
59
  };
59
60
  export type PointerInteractionsController<T> = {
60
61
  update: (args: PointerInteractionsArgs<T>) => void;
62
+ getCellCoordFromClientPoint: (clientX: number, clientY: number) => CellCoord | null;
61
63
  updateSelectionFromPointer: (clientX: number, clientY: number) => void;
62
64
  handleCellPointerDown: (cell: CellCoord, event: GridPointerEventLike) => void;
63
65
  handleCellDoubleClick: (cell: CellCoord, event: MouseEvent) => void;
@@ -2,262 +2,266 @@ import { nextSortEntries as e } from "../logic/sorting.js";
2
2
  import { isSyntheticColumnKey as t } from "../logic/detailRow.js";
3
3
  import { gridActions as n } from "../model/gridActions.js";
4
4
  import { clamp as r, findLogicalIndexFromPaneOffset as i } from "../logic/geometry.js";
5
- import { computeNextScrollPosition as a, hasPointerLeftActivationRadius as o, resolveAutoScrollAxisDirection as s, resolveScrollContentBox as c } from "../logic/autoScrollGeometry.js";
6
- import { clientYToRowIndex as l } from "../logic/verticalGeometry.js";
5
+ import { clampClientYAboveFooter as a, computeNextScrollPosition as o, hasPointerLeftActivationRadius as s, resolveAutoScrollAxisDirection as c, resolveScrollContentBox as l } from "../logic/autoScrollGeometry.js";
6
+ import { clientYToRowIndex as u } from "../logic/verticalGeometry.js";
7
7
  //#region src/controllers/pointerInteractionsController.ts
8
- var u = 10, d = 300, f = () => {
9
- let u = null, d = !1, f = !1, p = null, m = null, h = "mouse", g = null, _ = null, v = !1, y = !1, b = () => u?.uiState.dragState ?? null, x = (e, t) => {
10
- if (u === null) return null;
11
- let { bodyScrollRef: n, scrollContainerRef: a, leftPaneScrollRef: o, rightPaneScrollRef: s, filteredRowsLength: c, visibleColumnsLength: d, paneLayout: f, leftLeadingWidth: p, centerLeadingWidth: m, rightLeadingWidth: h, headerHeight: g, rowMetrics: _, verticalScaleFactor: v } = u, y = n.current;
12
- if (!y || c === 0 || d === 0) return null;
13
- let b = y.getBoundingClientRect(), x = l(y.scrollTop + t - b.top - g, a.current?.scrollTop ?? 0, v, _), S = null, C = o.current;
14
- if (S === null && C && f.left.entries.length > 0) {
15
- let t = C.getBoundingClientRect();
8
+ var d = 10, f = 300, p = () => {
9
+ let d = null, f = !1, p = !1, m = null, h = null, g = "mouse", _ = null, v = null, y = !1, b = !1, x = () => d?.uiState.dragState ?? null, S = (e) => {
10
+ let t = d?.footerHeight ?? 0, n = d?.scrollContainerRef.current ?? null;
11
+ return t <= 0 || !n ? e : a(e, n.getBoundingClientRect().top + n.clientTop + n.clientHeight, t);
12
+ }, C = (e, t) => {
13
+ if (d === null) return null;
14
+ let { bodyScrollRef: n, scrollContainerRef: a, leftPaneScrollRef: o, rightPaneScrollRef: s, filteredRowsLength: c, visibleColumnsLength: l, paneLayout: f, leftLeadingWidth: p, centerLeadingWidth: m, rightLeadingWidth: h, headerHeight: g, rowMetrics: _, verticalScaleFactor: v } = d, y = n.current;
15
+ if (!y || c === 0 || l === 0) return null;
16
+ let b = y.getBoundingClientRect(), x = u(y.scrollTop + S(t) - b.top - g, a.current?.scrollTop ?? 0, v, _), C = null, w = o.current;
17
+ if (C === null && w && f.left.entries.length > 0) {
18
+ let t = w.getBoundingClientRect();
16
19
  if (e < t.right) {
17
20
  let n = e - t.left - p;
18
- S = i(f.left, n);
21
+ C = i(f.left, n);
19
22
  }
20
23
  }
21
- let w = s.current;
22
- if (S === null && w && f.right.entries.length > 0) {
23
- let t = w.getBoundingClientRect();
24
+ let T = s.current;
25
+ if (C === null && T && f.right.entries.length > 0) {
26
+ let t = T.getBoundingClientRect();
24
27
  if (e >= t.left) {
25
28
  let n = e - t.left - h;
26
- S = i(f.right, n);
29
+ C = i(f.right, n);
27
30
  }
28
31
  }
29
- if (S === null && f.center.entries.length > 0) {
32
+ if (C === null && f.center.entries.length > 0) {
30
33
  let t = y.scrollLeft + e - b.left - m;
31
- S = i(f.center, Math.max(t, 0));
34
+ C = i(f.center, Math.max(t, 0));
32
35
  }
33
- return S === null ? null : {
36
+ return C === null ? null : {
34
37
  row: x,
35
- col: r(S, 0, d - 1)
38
+ col: r(C, 0, l - 1)
36
39
  };
37
- }, S = (e, t) => {
38
- let r = b();
39
- if (u === null || !r || r.type !== "selection") return;
40
- let i = x(e, t);
40
+ }, w = (e, t) => {
41
+ let r = x();
42
+ if (d === null || !r || r.type !== "selection") return;
43
+ let i = C(e, t);
41
44
  if (i) {
42
45
  if (r.selectionKind === "cell") {
43
- u.dispatch(n.updateSelection(i));
46
+ d.dispatch(n.updateSelection(i));
44
47
  return;
45
48
  }
46
49
  if (r.selectionKind === "row") {
47
- u.dispatch(n.updateRowSelection(i.row));
50
+ d.dispatch(n.updateRowSelection(i.row));
48
51
  return;
49
52
  }
50
- r.selectionKind === "col" && u.dispatch(n.updateColumnSelection(i.col));
53
+ r.selectionKind === "col" && d.dispatch(n.updateColumnSelection(i.col));
51
54
  }
52
- }, C = (e, t) => {
55
+ }, T = (e, t) => {
53
56
  let r = t.timeStamp;
54
- if (u === null) return;
55
- let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l } = u;
57
+ if (d === null) return;
58
+ let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l } = d;
56
59
  i.current?.focus({ preventScroll: !0 });
57
- let { target: d } = e;
58
- if (d.kind === "cell") {
59
- let e = m;
60
- if (e && e.cell.row === d.cell.row && e.cell.col === d.cell.col && r - e.time < 300) {
61
- m = null, l.current(d.cell, t);
60
+ let { target: u } = e;
61
+ if (u.kind === "cell") {
62
+ let e = h;
63
+ if (e && e.cell.row === u.cell.row && e.cell.col === u.cell.col && r - e.time < 300) {
64
+ h = null, l.current(u.cell, t);
62
65
  return;
63
66
  }
64
- m = {
65
- cell: d.cell,
67
+ h = {
68
+ cell: u.cell,
66
69
  time: r
67
- }, a(n.activateCell(d.cell)), o && (a(n.startSelection(d.cell)), a(n.endSelection()));
70
+ }, a(n.activateCell(u.cell)), o && (a(n.startSelection(u.cell)), a(n.endSelection()));
68
71
  return;
69
72
  }
70
- if (m = null, d.kind === "row") {
73
+ if (h = null, u.kind === "row") {
71
74
  if (s) {
72
- c(d.rowIndex, { shiftKey: !1 });
75
+ c(u.rowIndex, { shiftKey: !1 });
73
76
  return;
74
77
  }
75
- a(n.startRowSelection(d.rowIndex)), a(n.endSelection());
78
+ a(n.startRowSelection(u.rowIndex)), a(n.endSelection());
76
79
  return;
77
80
  }
78
- a(n.startColumnSelection(d.colIndex)), a(n.endSelection());
79
- }, w = () => {
80
- u !== null && (f = !1, u.dispatch(n.endSelection()), u.dispatch(n.endColumnResize()));
81
- }, T = (e) => {
82
- u !== null && (u.pointerClientRef.current = {
81
+ a(n.startColumnSelection(u.colIndex)), a(n.endSelection());
82
+ }, E = () => {
83
+ d !== null && (p = !1, d.dispatch(n.endSelection()), d.dispatch(n.endColumnResize()));
84
+ }, D = (e) => {
85
+ d !== null && (d.pointerClientRef.current = {
83
86
  x: e.clientX,
84
87
  y: e.clientY
85
- }, b()?.type === "columnResize" && u.dispatch(n.updateColumnResize(e.clientX)));
86
- }, E = (e) => {
87
- let t = p;
88
- t && (p = null, e.pointerId === t.pointerId && Math.abs(e.clientX - t.x) < 10 && Math.abs(e.clientY - t.y) < 10 && C(t, e)), w();
89
- }, D = () => {
90
- p = null, w();
91
- }, O = () => {
92
- d || (d = !0, window.addEventListener("pointermove", T), window.addEventListener("pointerup", E), window.addEventListener("pointercancel", D));
88
+ }, x()?.type === "columnResize" && d.dispatch(n.updateColumnResize(e.clientX)));
89
+ }, O = (e) => {
90
+ let t = m;
91
+ t && (m = null, e.pointerId === t.pointerId && Math.abs(e.clientX - t.x) < 10 && Math.abs(e.clientY - t.y) < 10 && T(t, e)), E();
93
92
  }, k = () => {
94
- d && (d = !1, window.removeEventListener("pointermove", T), window.removeEventListener("pointerup", E), window.removeEventListener("pointercancel", D));
93
+ m = null, E();
95
94
  }, A = () => {
96
- y = !1, u !== null && u.autoScrollFrameRef.current !== null && (cancelAnimationFrame(u.autoScrollFrameRef.current), u.autoScrollFrameRef.current = null);
95
+ f || (f = !0, window.addEventListener("pointermove", D), window.addEventListener("pointerup", O), window.addEventListener("pointercancel", k));
97
96
  }, j = () => {
98
- if (u === null || !y) return;
99
- let { scrollContainerRef: e, pointerClientRef: t, autoScrollFrameRef: n } = u, r = e.current, i = t.current;
97
+ f && (f = !1, window.removeEventListener("pointermove", D), window.removeEventListener("pointerup", O), window.removeEventListener("pointercancel", k));
98
+ }, M = () => {
99
+ b = !1, d !== null && d.autoScrollFrameRef.current !== null && (cancelAnimationFrame(d.autoScrollFrameRef.current), d.autoScrollFrameRef.current = null);
100
+ }, N = () => {
101
+ if (d === null || !b) return;
102
+ let { scrollContainerRef: e, pointerClientRef: t, autoScrollFrameRef: n } = d, r = e.current, i = t.current;
100
103
  if (!r || !i) {
101
- n.current = requestAnimationFrame(j);
104
+ n.current = requestAnimationFrame(N);
102
105
  return;
103
106
  }
104
- if (!v) {
105
- let e = _;
106
- if (e && !o(e, i, 6)) {
107
- n.current = requestAnimationFrame(j);
107
+ if (!y) {
108
+ let e = v;
109
+ if (e && !s(e, i, 6)) {
110
+ n.current = requestAnimationFrame(N);
108
111
  return;
109
112
  }
110
- v = !0;
113
+ y = !0;
111
114
  }
112
- let l = r.getBoundingClientRect(), d = c({
113
- rectLeft: l.left,
114
- rectTop: l.top,
115
+ let a = r.getBoundingClientRect(), u = l({
116
+ rectLeft: a.left,
117
+ rectTop: a.top,
115
118
  clientLeft: r.clientLeft,
116
119
  clientTop: r.clientTop,
117
120
  clientWidth: r.clientWidth,
118
121
  clientHeight: r.clientHeight
119
- }), f = b(), p = f?.type === "selection" && f.selectionKind === "col", m = f?.type === "selection" && f.selectionKind === "row", h = p ? 0 : s(i.y, d.top, d.bottom, 24), g = m ? 0 : s(i.x, d.left, d.right, 24), x = a(r.scrollTop, h, 18, r.scrollHeight - r.clientHeight), C = a(r.scrollLeft, g, 18, r.scrollWidth - r.clientWidth);
120
- (x !== r.scrollTop || C !== r.scrollLeft) && (r.scrollTo({
121
- top: x,
122
- left: C,
122
+ }), f = x(), p = f?.type === "selection" && f.selectionKind === "col", m = f?.type === "selection" && f.selectionKind === "row", h = p ? 0 : c(i.y, u.top, u.bottom - (d.footerHeight ?? 0), 24), g = m ? 0 : c(i.x, u.left, u.right, 24), _ = o(r.scrollTop, h, 18, r.scrollHeight - r.clientHeight), S = o(r.scrollLeft, g, 18, r.scrollWidth - r.clientWidth);
123
+ (_ !== r.scrollTop || S !== r.scrollLeft) && (r.scrollTo({
124
+ top: _,
125
+ left: S,
123
126
  behavior: "auto"
124
- }), S(i.x, i.y)), n.current = requestAnimationFrame(j);
125
- }, M = () => {
126
- let e = b()?.type === "selection";
127
- e && !y ? (y = !0, u !== null && (u.autoScrollFrameRef.current = requestAnimationFrame(j))) : !e && y && A();
128
- }, N = () => {
129
- if (g !== null) return;
127
+ }), w(i.x, i.y)), n.current = requestAnimationFrame(N);
128
+ }, P = () => {
129
+ let e = x()?.type === "selection";
130
+ e && !b ? (b = !0, d !== null && (d.autoScrollFrameRef.current = requestAnimationFrame(N))) : !e && b && M();
131
+ }, F = () => {
132
+ if (_ !== null) return;
130
133
  let e = () => {
131
- if (!f || u === null) {
132
- g = null;
134
+ if (!p || d === null) {
135
+ _ = null;
133
136
  return;
134
137
  }
135
- let { scrollContainerRef: t, pointerClientRef: n, onGutterRowSelectDrag: r } = u, i = t.current, l = n.current;
136
- if (!i || !l) {
137
- g = requestAnimationFrame(e);
138
+ let { scrollContainerRef: t, pointerClientRef: n, onGutterRowSelectDrag: r } = d, i = t.current, a = n.current;
139
+ if (!i || !a) {
140
+ _ = requestAnimationFrame(e);
138
141
  return;
139
142
  }
140
- if (!v) {
141
- let t = _;
142
- if (t && !o(t, l, 6)) {
143
- g = requestAnimationFrame(e);
143
+ if (!y) {
144
+ let t = v;
145
+ if (t && !s(t, a, 6)) {
146
+ _ = requestAnimationFrame(e);
144
147
  return;
145
148
  }
146
- v = !0;
149
+ y = !0;
147
150
  }
148
- let d = i.getBoundingClientRect(), p = c({
149
- rectLeft: d.left,
150
- rectTop: d.top,
151
+ let u = i.getBoundingClientRect(), f = l({
152
+ rectLeft: u.left,
153
+ rectTop: u.top,
151
154
  clientLeft: i.clientLeft,
152
155
  clientTop: i.clientTop,
153
156
  clientWidth: i.clientWidth,
154
157
  clientHeight: i.clientHeight
155
- }), m = s(l.y, p.top, p.bottom, 24), h = a(i.scrollTop, m, 18, i.scrollHeight - i.clientHeight);
158
+ }), m = c(a.y, f.top, f.bottom - (d.footerHeight ?? 0), 24), h = o(i.scrollTop, m, 18, i.scrollHeight - i.clientHeight);
156
159
  if (h !== i.scrollTop) {
157
160
  i.scrollTo({
158
161
  top: h,
159
162
  left: i.scrollLeft,
160
163
  behavior: "auto"
161
164
  });
162
- let e = x(l.x, l.y);
165
+ let e = C(a.x, a.y);
163
166
  e && r(e.row);
164
167
  }
165
- g = requestAnimationFrame(e);
168
+ _ = requestAnimationFrame(e);
166
169
  };
167
- g = requestAnimationFrame(e);
168
- }, P = (e, t) => (e.preventDefault(), u === null || e.button !== 0 ? !1 : (h = e.pointerType, e.pointerType === "touch" ? (p = {
170
+ _ = requestAnimationFrame(e);
171
+ }, I = (e, t) => (e.preventDefault(), d === null || e.button !== 0 ? !1 : (g = e.pointerType, e.pointerType === "touch" ? (m = {
169
172
  pointerId: e.pointerId,
170
173
  x: e.clientX,
171
174
  y: e.clientY,
172
175
  target: t
173
- }, !1) : (u.gridRootRef.current?.focus({ preventScroll: !0 }), u.pointerClientRef.current = {
176
+ }, !1) : (d.gridRootRef.current?.focus({ preventScroll: !0 }), d.pointerClientRef.current = {
174
177
  x: e.clientX,
175
178
  y: e.clientY
176
- }, _ = {
179
+ }, v = {
177
180
  x: e.clientX,
178
181
  y: e.clientY
179
- }, v = !1, !0)));
182
+ }, y = !1, !0)));
180
183
  return {
181
184
  update: (e) => {
182
- u = e, O(), M();
185
+ d = e, A(), P();
183
186
  },
184
- updateSelectionFromPointer: S,
187
+ getCellCoordFromClientPoint: C,
188
+ updateSelectionFromPointer: w,
185
189
  handleCellPointerDown: (e, t) => {
186
- !P(t, {
190
+ !I(t, {
187
191
  kind: "cell",
188
192
  cell: e
189
- }) || u === null || (u.dispatch(n.activateCell(e)), u.enableRangeSelection && u.dispatch(n.startSelection(e)));
193
+ }) || d === null || (d.dispatch(n.activateCell(e)), d.enableRangeSelection && d.dispatch(n.startSelection(e)));
190
194
  },
191
195
  handleCellDoubleClick: (e, t) => {
192
- h === "touch" || u === null || u.onCellDoubleClickRef.current(e, t);
196
+ g === "touch" || d === null || d.onCellDoubleClickRef.current(e, t);
193
197
  },
194
198
  handleCellPointerEnter: (e, t) => {
195
- if (u === null || (u.enableRowHover && u.setHoveredRowIndex(e.row), u.enableColumnHover && u.setHoveredColumnIndex(e.col), !u.enableRangeSelection)) return;
196
- let r = b();
197
- r?.type !== "selection" || r.selectionKind !== "cell" || (u.pointerClientRef.current = {
199
+ if (d === null || (d.enableRowHover && d.setHoveredRowIndex(e.row), d.enableColumnHover && d.setHoveredColumnIndex(e.col), !d.enableRangeSelection)) return;
200
+ let r = x();
201
+ r?.type !== "selection" || r.selectionKind !== "cell" || (d.pointerClientRef.current = {
198
202
  x: t.clientX,
199
203
  y: t.clientY
200
- }, u.dispatch(n.updateSelection(e)));
204
+ }, d.dispatch(n.updateSelection(e)));
201
205
  },
202
206
  handleNativeDragStart: (e) => {
203
207
  e.preventDefault();
204
208
  },
205
209
  handleRowHeaderPointerDown: (e, t) => {
206
- if (!(!P(t, {
210
+ if (!(!I(t, {
207
211
  kind: "row",
208
212
  rowIndex: e
209
- }) || u === null)) {
210
- if (u.enableRowSelection) {
211
- f = !0, u.onGutterRowSelect(e, { shiftKey: t.shiftKey }), N();
213
+ }) || d === null)) {
214
+ if (d.enableRowSelection) {
215
+ p = !0, d.onGutterRowSelect(e, { shiftKey: t.shiftKey }), F();
212
216
  return;
213
217
  }
214
- u.dispatch(n.startRowSelection(e));
218
+ d.dispatch(n.startRowSelection(e));
215
219
  }
216
220
  },
217
221
  handleRowHeaderPointerEnter: (e, t) => {
218
- if (u === null) return;
219
- if (u.enableRowHover && u.setHoveredRowIndex(e), f) {
220
- u.pointerClientRef.current = {
222
+ if (d === null) return;
223
+ if (d.enableRowHover && d.setHoveredRowIndex(e), p) {
224
+ d.pointerClientRef.current = {
221
225
  x: t.clientX,
222
226
  y: t.clientY
223
- }, u.onGutterRowSelectDrag(e);
227
+ }, d.onGutterRowSelectDrag(e);
224
228
  return;
225
229
  }
226
- let r = b();
227
- r?.type !== "selection" || r.selectionKind !== "row" || (u.pointerClientRef.current = {
230
+ let r = x();
231
+ r?.type !== "selection" || r.selectionKind !== "row" || (d.pointerClientRef.current = {
228
232
  x: t.clientX,
229
233
  y: t.clientY
230
- }, u.dispatch(n.updateRowSelection(e)));
234
+ }, d.dispatch(n.updateRowSelection(e)));
231
235
  },
232
236
  handleColumnHeaderPointerDown: (r, i) => {
233
- if (!(!P(i, {
237
+ if (!(!I(i, {
234
238
  kind: "col",
235
239
  colIndex: r
236
- }) || u === null)) {
237
- if (i.shiftKey && u.enableSorting) {
238
- let i = u.orderedColumns[r];
240
+ }) || d === null)) {
241
+ if (i.shiftKey && d.enableSorting) {
242
+ let i = d.orderedColumns[r];
239
243
  if (i && !t(i.key)) {
240
- let t = u.uiState.sort, r = t.find((e) => e.columnKey === i.key)?.direction ? "desc" : "asc", a = e(t, i.key, r, !0);
241
- u.dispatch(a.length === 0 ? n.clearSort() : n.setSort(a));
244
+ let t = d.uiState.sort, r = t.find((e) => e.columnKey === i.key)?.direction ? "desc" : "asc", a = e(t, i.key, r, !0);
245
+ d.dispatch(a.length === 0 ? n.clearSort() : n.setSort(a));
242
246
  }
243
247
  return;
244
248
  }
245
- u.dispatch(n.startColumnSelection(r));
249
+ d.dispatch(n.startColumnSelection(r));
246
250
  }
247
251
  },
248
252
  handleColumnHeaderPointerEnter: (e, t) => {
249
- if (u === null) return;
250
- u.setHoveredRowIndex(null), u.enableColumnHeaderHover && u.setHoveredColumnIndex(e);
251
- let r = b();
252
- r?.type !== "selection" || r.selectionKind !== "col" || (u.pointerClientRef.current = {
253
+ if (d === null) return;
254
+ d.setHoveredRowIndex(null), d.enableColumnHeaderHover && d.setHoveredColumnIndex(e);
255
+ let r = x();
256
+ r?.type !== "selection" || r.selectionKind !== "col" || (d.pointerClientRef.current = {
253
257
  x: t.clientX,
254
258
  y: t.clientY
255
- }, u.dispatch(n.updateColumnSelection(e)));
259
+ }, d.dispatch(n.updateColumnSelection(e)));
256
260
  },
257
261
  dispose: () => {
258
- k(), A(), g !== null && (cancelAnimationFrame(g), g = null);
262
+ j(), M(), _ !== null && (cancelAnimationFrame(_), _ = null);
259
263
  }
260
264
  };
261
265
  };
262
266
  //#endregion
263
- export { d as TOUCH_DOUBLE_TAP_MS, u as TOUCH_TAP_SLOP_PX, f as createPointerInteractionsController };
267
+ export { f as TOUCH_DOUBLE_TAP_MS, d as TOUCH_TAP_SLOP_PX, p 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/slotDom.cjs");var i=14,a=12,o=`0.5`,s=`<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>`,c=`<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>`,l=200,u=`cubic-bezier(0.2, 0.7, 0.3, 1)`,d=`transform 160ms ${u}`,f=`data-ssg-row-dragging`,p=e=>e?.closest(`.ssg-motion-off`)!=null,m=/translateY\((-?[\d.]+)px\)/,h=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},g=()=>{let g=null,_=null,v=null,y={x:0,y:0},b=null,x=!1,S=null,C=null,w=null,T=null,E=0,D=()=>g?.motion===`live`,O=null,k=null,A=null,j=()=>[g?.leftIndicatorRef.current??null,g?.centerIndicatorRef.current??null,g?.rightIndicatorRef.current??null],M=()=>{for(let e of j())e&&(e.style.display=`none`)},N=e=>{if(O)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),g?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),g?.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(`;`),r.applySlotToElement(t,g?.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 i=document.createElement(`span`);i.style.cssText=`overflow:hidden;text-overflow:ellipsis`,i.textContent=e,t.appendChild(n),t.appendChild(i),document.body.appendChild(t),O=t,k=n,A=null},P=e=>{let t=O;if(!t)return;t.style.transform=`translate(`+(y.x+i)+`px,`+(y.y+a)+`px)`;let n=e?`move`:`out`;if(A===n)return;A=n;let r=k;n===`out`?(t.style.opacity=o,r&&(r.innerHTML=c)):(t.style.opacity=`1`,r&&(r.innerHTML=s))},F=()=>{O&&O.parentNode&&O.parentNode.removeChild(O),O=null,k=null,A=null},I=(e,n)=>{let r=g?.scrollContainerRef.current??null;!r||e===null||r.querySelectorAll(`.ssg-body-row[data-row-index="${e}"]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(f,D()?`live`:``):e.removeAttribute(f))})},L=()=>{let e=g?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of h(e)){let e=m.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},R=t=>{let n=T,r=_;if(!n||r===null||g===null)return;let i=g.scrollContainerRef.current;if(!i)return;for(let e of h(i)){if(n.has(e))continue;let t=m.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=g.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-E)*g.verticalScaleFactor,s=(b?y.y-b.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach(({index:e,baseY:t},i)=>{if(!i.isConnected){n.delete(i);return}if(e===r){i.style.transition=`none`,i.style.transform=`translateY(${t+s}px)`,i.style.willChange=`transform`;return}let o=0;c!==null&&(r<e&&e<=c?o=-a:c<=e&&e<r&&(o=a)),i.style.transition=d,i.style.transform=`translateY(${t+o}px)`})},z=(t,n)=>{if(g===null)return null;let{scrollContainerRef:r,bodyScrollRef:i,rowMetrics:a,headerHeight:o,verticalScaleFactor:s,windowBaseOffsetPx:c}=g,l=r.current,u=i.current;if(!l||!u)return null;let d=l.getBoundingClientRect();if(t<d.left||t>d.right||n<d.top||n>d.bottom)return null;let f=u.getBoundingClientRect(),p=e.resolveRowDropSlot(u.scrollTop+n-f.top-o-l.scrollTop*(1-s),a);return{slot:p,top:o+e.resolveRowDropSlotTop(p,a)-c}},B=()=>{let t=z(y.x,y.y),n=_;if(D()){t&&n!==null&&(v=e.resolveMoveTargetIndex(n,t.slot)===null?null:t.slot),M(),R(v);return}if(P(t),!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){v=null,M();return}v=t.slot;for(let e of j())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},V=()=>{if(_===null){C=null;return}let e=g?.scrollContainerRef.current??null;if(e&&(x||(!b||n.hasPointerLeftActivationRadius(b,y,6))&&(x=!0),x)){let t=e.getBoundingClientRect(),r=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight}),i=n.resolveAutoScrollAxisDirection(y.y,r.top,r.bottom,24),a=n.computeNextScrollPosition(e.scrollTop,i,18,e.scrollHeight-e.clientHeight);a!==e.scrollTop&&e.scrollTo({top:a,behavior:`auto`})}B(),C=requestAnimationFrame(V)},H=()=>{let e=g?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of h(e))t.set(n,n.getBoundingClientRect().top);return t},U=t=>{C!==null&&(cancelAnimationFrame(C),C=null),document.body.style.cursor=``,M(),F();let n=_,r=v;I(n,!1),_=null,v=null,b=null;let i=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),a=t&&n!==null&&i!==null&&g!==null,o=T;if(T=null,o)if(a)o.forEach((e,t)=>{t.style.transition=``,t.style.willChange=``});else{let e=[];o.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=d,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}!a||n===null||i===null||g===null||(w=p(g.scrollContainerRef.current)?null:H(),g.commitRowMove(n,i))};return{update:e=>{g=e},onRowDragHandlePointerDown:(e,t)=>{if(g===null||!g.enabled||t.button!==0)return;t.stopPropagation(),t.preventDefault(),_=e,v=null,y={x:t.clientX,y:t.clientY},b={x:t.clientX,y:t.clientY},x=!1,document.body.style.cursor=`grabbing`,D()?(T=L(),E=g.scrollContainerRef.current?.scrollTop??0):N(g.getRowDragLabel(e)),I(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let i=e=>{e.pointerId===r&&(y={x:e.clientX,y:e.clientY},B())},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s),window.removeEventListener(`keydown`,c),S=null;try{n.releasePointerCapture(r)}catch{}};function o(e){e.pointerId===r&&(a(),U(!0))}function s(e){e.pointerId===r&&(a(),U(!1))}function c(e){e.key===`Escape`&&(a(),U(!1))}window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),window.addEventListener(`keydown`,c),S=a,B(),C=requestAnimationFrame(V)},applyReorderSettle:()=>{let e=w;if(w=null,!e)return;let t=g?.scrollContainerRef.current??null;if(!t)return;let n=[],r=new Map;if(e.forEach((e,t)=>{if(!t.isConnected)return;let i=e-t.getBoundingClientRect().top;if(Math.abs(i)<.5)return;let a=m.exec(t.style.transform);if(!a)return;let o=parseFloat(a[1]);r.set(t,o),t.style.transition=`none`,t.style.transform=`translateY(${o+i}px)`,t.style.willChange=`transform`,n.push(t)}),n.length!==0){t.getBoundingClientRect();for(let e of n)e.style.transition=`transform ${l}ms ${u}`,e.style.transform=`translateY(${r.get(e)??0}px)`;window.setTimeout(()=>{for(let e of n)e.style.transition=``,e.style.willChange=``},280)}},dispose:()=>{S?.(),S=null,C!==null&&(cancelAnimationFrame(C),C=null),document.body.style.cursor=``,F(),I(_,!1),_=null,v=null,T=null}}};exports.createRowDragController=g;
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/slotDom.cjs");var i=14,a=12,o=`0.5`,s=`<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>`,c=`<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>`,l=200,u=`cubic-bezier(0.2, 0.7, 0.3, 1)`,d=`transform 160ms ${u}`,f=`data-ssg-row-dragging`,p=e=>e?.closest(`.ssg-motion-off`)!=null,m=/translateY\((-?[\d.]+)px\)/,h=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},g=()=>{let g=null,_=null,v=null,y={x:0,y:0},b=null,x=!1,S=null,C=null,w=null,T=null,E=null,D=0,O=()=>g?.motion===`live`,k=null,A=null,j=null,M=()=>[g?.leftIndicatorRef.current??null,g?.centerIndicatorRef.current??null,g?.rightIndicatorRef.current??null],N=()=>{for(let e of M())e&&(e.style.display=`none`)},P=e=>{if(k)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),g?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),g?.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(`;`),r.applySlotToElement(t,g?.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 i=document.createElement(`span`);i.style.cssText=`overflow:hidden;text-overflow:ellipsis`,i.textContent=e,t.appendChild(n),t.appendChild(i),document.body.appendChild(t),k=t,A=n,j=null},F=e=>{let t=k;if(!t)return;t.style.transform=`translate(`+(y.x+i)+`px,`+(y.y+a)+`px)`;let n=e?`move`:`out`;if(j===n)return;j=n;let r=A;n===`out`?(t.style.opacity=o,r&&(r.innerHTML=c)):(t.style.opacity=`1`,r&&(r.innerHTML=s))},I=()=>{k&&k.parentNode&&k.parentNode.removeChild(k),k=null,A=null,j=null},L=(e,n)=>{let r=g?.scrollContainerRef.current??null;!r||e===null||r.querySelectorAll(`.ssg-body-row[data-row-index="${e}"]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(f,O()?`live`:``):e.removeAttribute(f))})},R=()=>{let e=g?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of h(e)){let e=m.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},z=t=>{let n=E,r=_;if(!n||r===null||g===null)return;let i=g.scrollContainerRef.current;if(!i)return;for(let e of h(i)){if(n.has(e))continue;let t=m.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=g.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-D)*g.verticalScaleFactor,s=(b?y.y-b.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach(({index:e,baseY:t},i)=>{if(!i.isConnected){n.delete(i);return}if(e===r){i.style.transition=`none`,i.style.transform=`translateY(${t+s}px)`,i.style.willChange=`transform`;return}let o=0;c!==null&&(r<e&&e<=c?o=-a:c<=e&&e<r&&(o=a)),i.style.transition=d,i.style.transform=`translateY(${t+o}px)`})},B=(t,r)=>{if(g===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=g,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,g.footerHeight??0),m=d.getBoundingClientRect(),h=e.resolveRowDropSlot(d.scrollTop+p-m.top-s-u.scrollTop*(1-c),o);return{slot:h,top:s+e.resolveRowDropSlotTop(h,o)-l}},V=()=>{let t=B(y.x,y.y),n=_;if(O()){t&&n!==null&&(v=e.resolveMoveTargetIndex(n,t.slot)===null?null:t.slot),N(),z(v);return}if(F(t),!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){v=null,N();return}v=t.slot;for(let e of M())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},H=()=>{if(_===null){w=null;return}let e=g?.scrollContainerRef.current??null;if(e&&(x||(!b||n.hasPointerLeftActivationRadius(b,y,6))&&(x=!0),x)){let t=e.getBoundingClientRect(),r=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight}),i=n.resolveAutoScrollAxisDirection(y.y,r.top,r.bottom-(g?.footerHeight??0),24),a=n.computeNextScrollPosition(e.scrollTop,i,18,e.scrollHeight-e.clientHeight);a!==e.scrollTop&&e.scrollTo({top:a,behavior:`auto`})}V(),w=requestAnimationFrame(H)},U=()=>{let e=g?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of h(e))t.set(n,n.getBoundingClientRect().top);return t},W=t=>{w!==null&&(cancelAnimationFrame(w),w=null),document.body.style.cursor=``,N(),I();let n=_,r=v;L(n,!1),_=null,v=null,b=null,C=null;let i=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),a=t&&n!==null&&i!==null&&g!==null,o=E;if(E=null,o)if(a)o.forEach((e,t)=>{t.style.transition=``,t.style.willChange=``});else{let e=[];o.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=d,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}!a||n===null||i===null||g===null||(T=p(g.scrollContainerRef.current)?null:U(),g.commitRowMove(n,i))};return{update:e=>{g=e},onRowDragHandlePointerDown:(e,t)=>{if(g===null||!g.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),_!==null){if(t.pointerId!==C)return;S?.(),W(!1)}_=e,C=t.pointerId,v=null,y={x:t.clientX,y:t.clientY},b={x:t.clientX,y:t.clientY},x=!1,document.body.style.cursor=`grabbing`,O()?(E=R(),D=g.scrollContainerRef.current?.scrollTop??0):P(g.getRowDragLabel(e)),L(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let i=e=>{e.pointerId===r&&(y={x:e.clientX,y:e.clientY},V())},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s),window.removeEventListener(`keydown`,c),window.removeEventListener(`blur`,l),S=null;try{n.releasePointerCapture(r)}catch{}};function o(e){e.pointerId===r&&(a(),W(!0))}function s(e){e.pointerId===r&&(a(),W(!1))}function c(e){e.key===`Escape`&&(a(),W(!1))}function l(){a(),W(!1)}window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),window.addEventListener(`keydown`,c),window.addEventListener(`blur`,l),S=a,V(),w=requestAnimationFrame(H)},applyReorderSettle:()=>{let e=T;if(T=null,!e)return;let t=g?.scrollContainerRef.current??null;if(!t)return;let n=[],r=new Map;if(e.forEach((e,t)=>{if(!t.isConnected)return;let i=e-t.getBoundingClientRect().top;if(Math.abs(i)<.5)return;let a=m.exec(t.style.transform);if(!a)return;let o=parseFloat(a[1]);r.set(t,o),t.style.transition=`none`,t.style.transform=`translateY(${o+i}px)`,t.style.willChange=`transform`,n.push(t)}),n.length!==0){t.getBoundingClientRect();for(let e of n)e.style.transition=`transform ${l}ms ${u}`,e.style.transform=`translateY(${r.get(e)??0}px)`;window.setTimeout(()=>{for(let e of n)e.style.transition=``,e.style.willChange=``},280)}},dispose:()=>{S?.(),S=null,w!==null&&(cancelAnimationFrame(w),w=null),document.body.style.cursor=``,I(),L(_,!1),_=null,v=null,E=null}}};exports.createRowDragController=g;
@@ -7,6 +7,7 @@ export type RowDragArgs = {
7
7
  enabled: boolean;
8
8
  rowMetrics: RowMetrics;
9
9
  headerHeight: number;
10
+ footerHeight?: number;
10
11
  verticalScaleFactor: number;
11
12
  windowBaseOffsetPx: number;
12
13
  scrollContainerRef: ReadonlyRef<HTMLElement | null>;