@ishibashi0112/spreadsheet-grid-core 1.2.0 → 1.3.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 (118) hide show
  1. package/dist/controllers/clipboardController.cjs +1 -1
  2. package/dist/controllers/clipboardController.d.ts +1 -0
  3. package/dist/controllers/clipboardController.js +79 -70
  4. package/dist/controllers/columnMenuController.cjs +1 -1
  5. package/dist/controllers/columnMenuController.js +75 -73
  6. package/dist/controllers/contextMenuController.cjs +1 -1
  7. package/dist/controllers/contextMenuController.js +63 -61
  8. package/dist/controllers/detailRowController.cjs +1 -0
  9. package/dist/controllers/detailRowController.d.ts +41 -0
  10. package/dist/controllers/detailRowController.js +97 -0
  11. package/dist/controllers/detailTabOrder.cjs +1 -1
  12. package/dist/controllers/detailTabOrder.js +17 -16
  13. package/dist/controllers/editController.cjs +1 -1
  14. package/dist/controllers/editController.d.ts +4 -1
  15. package/dist/controllers/editController.js +163 -91
  16. package/dist/controllers/escapeClaimController.cjs +1 -1
  17. package/dist/controllers/escapeClaimController.js +23 -19
  18. package/dist/controllers/fillHandleController.cjs +1 -1
  19. package/dist/controllers/fillHandleController.js +107 -106
  20. package/dist/controllers/filterPopoverController.cjs +1 -1
  21. package/dist/controllers/filterPopoverController.js +1 -0
  22. package/dist/controllers/imeInputController.cjs +1 -1
  23. package/dist/controllers/imeInputController.js +87 -76
  24. package/dist/controllers/keyboardController.cjs +1 -1
  25. package/dist/controllers/keyboardController.d.ts +4 -0
  26. package/dist/controllers/keyboardController.js +101 -97
  27. package/dist/controllers/liveUiState.cjs +1 -0
  28. package/dist/controllers/liveUiState.d.ts +7 -0
  29. package/dist/controllers/liveUiState.js +4 -0
  30. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  31. package/dist/controllers/pointerInteractionsController.d.ts +1 -0
  32. package/dist/controllers/pointerInteractionsController.js +127 -126
  33. package/dist/controllers/popoverSupport.cjs +1 -1
  34. package/dist/controllers/popoverSupport.d.ts +3 -0
  35. package/dist/controllers/popoverSupport.js +62 -41
  36. package/dist/controllers/toolPanelController.cjs +1 -1
  37. package/dist/controllers/toolPanelController.js +74 -73
  38. package/dist/controllers/tooltipController.cjs +1 -1
  39. package/dist/controllers/tooltipController.d.ts +1 -1
  40. package/dist/controllers/tooltipController.js +122 -97
  41. package/dist/controllers/viewportSyncController.cjs +1 -1
  42. package/dist/controllers/viewportSyncController.js +55 -54
  43. package/dist/engine/cellCommands.cjs +1 -0
  44. package/dist/engine/cellCommands.d.ts +27 -0
  45. package/dist/engine/cellCommands.js +89 -0
  46. package/dist/engine/columnCommands.cjs +1 -1
  47. package/dist/engine/columnCommands.d.ts +2 -1
  48. package/dist/engine/columnCommands.js +98 -67
  49. package/dist/engine/exportCommands.cjs +1 -1
  50. package/dist/engine/exportCommands.js +2 -2
  51. package/dist/engine/gridApi.cjs +6 -5
  52. package/dist/engine/gridApi.d.ts +3 -0
  53. package/dist/engine/gridApi.js +158 -144
  54. package/dist/engine/rowSelectionCommands.cjs +1 -1
  55. package/dist/engine/rowSelectionCommands.d.ts +5 -0
  56. package/dist/engine/rowSelectionCommands.js +73 -38
  57. package/dist/locales/en.cjs +1 -1
  58. package/dist/locales/en.js +2 -2
  59. package/dist/logic/cellPlacement.cjs +1 -0
  60. package/dist/logic/cellPlacement.d.ts +22 -0
  61. package/dist/logic/cellPlacement.js +44 -0
  62. package/dist/logic/contextMenuTarget.cjs +1 -1
  63. package/dist/logic/contextMenuTarget.d.ts +20 -2
  64. package/dist/logic/contextMenuTarget.js +62 -3
  65. package/dist/logic/dateFilterCondition.cjs +1 -1
  66. package/dist/logic/dateFilterCondition.d.ts +1 -0
  67. package/dist/logic/dateFilterCondition.js +17 -13
  68. package/dist/logic/density.cjs +1 -0
  69. package/dist/logic/density.d.ts +5 -0
  70. package/dist/logic/density.js +17 -0
  71. package/dist/logic/detailRow.cjs +1 -1
  72. package/dist/logic/detailRow.d.ts +6 -1
  73. package/dist/logic/detailRow.js +21 -17
  74. package/dist/logic/domGuards.cjs +1 -1
  75. package/dist/logic/domGuards.d.ts +10 -0
  76. package/dist/logic/domGuards.js +18 -2
  77. package/dist/logic/editorKeys.cjs +1 -0
  78. package/dist/logic/editorKeys.d.ts +30 -0
  79. package/dist/logic/editorKeys.js +34 -0
  80. package/dist/logic/editorStart.cjs +1 -0
  81. package/dist/logic/editorStart.d.ts +7 -0
  82. package/dist/logic/editorStart.js +23 -0
  83. package/dist/logic/editorValues.cjs +1 -1
  84. package/dist/logic/editorValues.d.ts +1 -0
  85. package/dist/logic/editorValues.js +10 -7
  86. package/dist/logic/gridBarSummary.cjs +1 -0
  87. package/dist/logic/gridBarSummary.d.ts +27 -0
  88. package/dist/logic/gridBarSummary.js +137 -0
  89. package/dist/logic/gridState.cjs +1 -1
  90. package/dist/logic/gridState.d.ts +1 -0
  91. package/dist/logic/gridState.js +19 -16
  92. package/dist/logic/localeText.cjs +1 -1
  93. package/dist/logic/localeText.js +2 -2
  94. package/dist/logic/rowDragTarget.cjs +1 -0
  95. package/dist/logic/rowDragTarget.d.ts +14 -0
  96. package/dist/logic/rowDragTarget.js +47 -0
  97. package/dist/logic/selectEditorState.cjs +1 -1
  98. package/dist/logic/selectEditorState.d.ts +27 -4
  99. package/dist/logic/selectEditorState.js +29 -14
  100. package/dist/logic/valueFormatters.d.ts +8 -3
  101. package/dist/model/gridTypes.core.d.ts +31 -12
  102. package/dist/utils/clipboard.cjs +4 -4
  103. package/dist/utils/clipboard.js +60 -59
  104. package/dist/utils/editorVisibleBounds.cjs +1 -0
  105. package/dist/utils/editorVisibleBounds.d.ts +10 -0
  106. package/dist/utils/editorVisibleBounds.js +40 -0
  107. package/dist/utils/errorBubblePlacement.cjs +1 -0
  108. package/dist/utils/errorBubblePlacement.d.ts +8 -0
  109. package/dist/utils/errorBubblePlacement.js +26 -0
  110. package/dist/utils/multilineEditor.cjs +2 -0
  111. package/dist/utils/multilineEditor.d.ts +7 -0
  112. package/dist/utils/multilineEditor.js +22 -0
  113. package/dist/utils/popupContainer.cjs +1 -1
  114. package/dist/utils/popupContainer.js +35 -28
  115. package/dist/utils/shadowDom.cjs +1 -0
  116. package/dist/utils/shadowDom.d.ts +5 -0
  117. package/dist/utils/shadowDom.js +33 -0
  118. package/package.json +1 -1
@@ -1 +1 @@
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("../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=(t,n)=>{let r=_();if(s===null||!r||r.type!==`selection`)return;let i=b(t,n);if(i){if(r.selectionKind===`cell`){s.dispatch(e.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){s.dispatch(e.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&s.dispatch(e.gridActions.updateColumnSelection(i.col))}},S=(t,n)=>{let r=n.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}=t;if(p.kind===`cell`){let t=d;if(t&&t.cell.row===p.cell.row&&t.cell.col===p.cell.col&&r-t.time<300){d=null,u.current(p.cell,n);return}d={cell:p.cell,time:r},a(e.gridActions.activateCell(p.cell)),o&&(a(e.gridActions.startSelection(p.cell)),a(e.gridActions.endSelection()));return}if(d=null,p.kind===`row`){if(c){l(p.rowIndex,{shiftKey:!1});return}a(e.gridActions.startRowSelection(p.rowIndex,f?.().col)),a(e.gridActions.endSelection());return}a(e.gridActions.startColumnSelection(p.colIndex,f?.().row)),a(e.gridActions.endSelection())},C=()=>{s!==null&&(l=!1,s.dispatch(e.gridActions.endSelection()),s.dispatch(e.gridActions.endColumnResize()))},w=t=>{if(s===null)return;s.pointerClientRef.current={x:t.clientX,y:t.clientY};let n=_();if(n?.type===`columnResize`){(v===null||v.drag!==n)&&(v={drag:n,x:a.resolveElementScale(s.scrollContainerRef.current).x});let r=v.x===1?t.clientX:n.startX+(t.clientX-n.startX)/v.x;s.dispatch(e.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:(t,n)=>{if(!(!N(n,{kind:`cell`,cell:t})||s===null)){if(n.shiftKey&&s.enableRangeSelection){let{selection:n,activeCell:r}=s.uiState,i=n?.type===`cell`?n.range.start:r;if(i){s.dispatch(e.gridActions.startSelection(i)),s.dispatch(e.gridActions.updateSelection(t));return}}s.dispatch(e.gridActions.activateCell(t)),s.enableRangeSelection&&s.dispatch(e.gridActions.startSelection(t))}},handleCellDoubleClick:(e,t)=>{f===`touch`||s===null||s.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(t,n)=>{if(s===null||(s.enableRowHover&&s.setHoveredRowIndex(t.row),s.enableColumnHover&&s.setHoveredColumnIndex(t.col),!s.enableRangeSelection))return;let r=_();r?.type!==`selection`||r.selectionKind!==`cell`||(s.pointerClientRef.current={x:n.clientX,y:n.clientY},s.dispatch(e.gridActions.updateSelection(t)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(t,n)=>{if(!(!N(n,{kind:`row`,rowIndex:t})||s===null)){if(s.enableRowSelection){l=!0,s.onGutterRowSelect(t,{shiftKey:n.shiftKey}),M();return}if(n.shiftKey){let{selection:n,activeCell:r}=s.uiState,i=n?.type===`row`?n.startRow:r?.row;if(i!==void 0){s.dispatch(e.gridActions.startRowSelection(i,s.resolveFirstDataCell?.().col)),s.dispatch(e.gridActions.updateRowSelection(t));return}}s.dispatch(e.gridActions.startRowSelection(t,s.resolveFirstDataCell?.().col))}},handleRowHeaderPointerEnter:(t,n)=>{if(s===null)return;if(s.enableRowHover&&s.setHoveredRowIndex(t),l){s.pointerClientRef.current={x:n.clientX,y:n.clientY},s.onGutterRowSelectDrag(t);return}let r=_();r?.type!==`selection`||r.selectionKind!==`row`||(s.pointerClientRef.current={x:n.clientX,y:n.clientY},s.dispatch(e.gridActions.updateRowSelection(t)))},handleColumnHeaderPointerDown:(r,i)=>{if(!(!N(i,{kind:`col`,colIndex:r})||s===null)){if(i.shiftKey&&s.enableSorting){let i=s.orderedColumns[r];if(i&&!n.isSyntheticColumnKey(i.key)){let n=s.uiState.sort,r=n.find(e=>e.columnKey===i.key)?.direction?`desc`:`asc`,a=t.nextSortEntries(n,i.key,r,!0);s.dispatch(a.length===0?e.gridActions.clearSort():e.gridActions.setSort(a))}return}s.dispatch(e.gridActions.startColumnSelection(r,s.resolveFirstDataCell?.().row))}},handleColumnHeaderPointerEnter:(t,n)=>{if(s===null)return;s.setHoveredRowIndex(null),s.enableColumnHeaderHover&&s.setHoveredColumnIndex(t);let r=_();r?.type!==`selection`||r.selectionKind!==`col`||(s.pointerClientRef.current={x:n.clientX,y:n.clientY},s.dispatch(e.gridActions.updateColumnSelection(t)))},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;
@@ -2,21 +2,22 @@ import { gridActions as e } from "../model/gridActions.js";
2
2
  import { nextSortEntries as t } from "../logic/sorting.js";
3
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,56 +25,56 @@ 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 = (t, n) => {
44
- let r = w();
45
- if (m === null || !r || r.type !== "selection") return;
46
- let i = D(t, n);
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(e.updateSelection(i));
50
+ h.dispatch(e.updateSelection(i));
50
51
  return;
51
52
  }
52
53
  if (r.selectionKind === "row") {
53
- m.dispatch(e.updateRowSelection(i.row));
54
+ h.dispatch(e.updateRowSelection(i.row));
54
55
  return;
55
56
  }
56
- r.selectionKind === "col" && m.dispatch(e.updateColumnSelection(i.col));
57
+ r.selectionKind === "col" && h.dispatch(e.updateColumnSelection(i.col));
57
58
  }
58
- }, k = (t, n) => {
59
+ }, A = (t, n) => {
59
60
  let r = n.timeStamp;
60
- if (m === null) return;
61
- let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l, resolveFirstDataCell: u } = m;
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
64
  let { target: d } = t;
64
65
  if (d.kind === "cell") {
65
- let t = v;
66
+ let t = y;
66
67
  if (t && t.cell.row === d.cell.row && t.cell.col === d.cell.col && r - t.time < 300) {
67
- v = null, l.current(d.cell, n);
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
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;
@@ -82,50 +83,50 @@ var m = 10, h = 300, g = () => {
82
83
  return;
83
84
  }
84
85
  a(e.startColumnSelection(d.colIndex, u?.().row)), a(e.endSelection());
85
- }, A = () => {
86
- m !== null && (g = !1, m.dispatch(e.endSelection()), m.dispatch(e.endColumnResize()));
87
- }, j = (t) => {
88
- if (m === null) return;
89
- m.pointerClientRef.current = {
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 = {
90
91
  x: t.clientX,
91
92
  y: t.clientY
92
93
  };
93
- let n = w();
94
+ let n = T();
94
95
  if (n?.type === "columnResize") {
95
- (T === null || T.drag !== n) && (T = {
96
+ (E === null || E.drag !== n) && (E = {
96
97
  drag: n,
97
- x: f(m.scrollContainerRef.current).x
98
+ x: p(h.scrollContainerRef.current).x
98
99
  });
99
- let r = T.x === 1 ? t.clientX : n.startX + (t.clientX - n.startX) / T.x;
100
- m.dispatch(e.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,
203
+ getCellCoordFromClientPoint: O,
204
+ updateSelectionFromPointer: k,
204
205
  handleCellPointerDown: (t, n) => {
205
- if (!(!B(n, {
206
+ if (!(!V(n, {
206
207
  kind: "cell",
207
208
  cell: t
208
- }) || m === null)) {
209
- if (n.shiftKey && m.enableRangeSelection) {
210
- let { selection: n, activeCell: r } = m.uiState, i = n?.type === "cell" ? n.range.start : r;
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(e.startSelection(i)), m.dispatch(e.updateSelection(t));
213
+ h.dispatch(e.startSelection(i)), h.dispatch(e.updateSelection(t));
213
214
  return;
214
215
  }
215
216
  }
216
- m.dispatch(e.activateCell(t)), m.enableRangeSelection && m.dispatch(e.startSelection(t));
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
223
  handleCellPointerEnter: (t, n) => {
223
- if (m === null || (m.enableRowHover && m.setHoveredRowIndex(t.row), m.enableColumnHover && m.setHoveredColumnIndex(t.col), !m.enableRangeSelection)) return;
224
- let r = w();
225
- r?.type !== "selection" || r.selectionKind !== "cell" || (m.pointerClientRef.current = {
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 = {
226
227
  x: n.clientX,
227
228
  y: n.clientY
228
- }, m.dispatch(e.updateSelection(t)));
229
+ }, h.dispatch(e.updateSelection(t)));
229
230
  },
230
231
  handleNativeDragStart: (e) => {
231
232
  e.preventDefault();
232
233
  },
233
234
  handleRowHeaderPointerDown: (t, n) => {
234
- if (!(!B(n, {
235
+ if (!(!V(n, {
235
236
  kind: "row",
236
237
  rowIndex: t
237
- }) || m === null)) {
238
- if (m.enableRowSelection) {
239
- g = !0, m.onGutterRowSelect(t, { shiftKey: n.shiftKey }), z();
238
+ }) || h === null)) {
239
+ if (h.enableRowSelection) {
240
+ _ = !0, h.onGutterRowSelect(t, { shiftKey: n.shiftKey }), B();
240
241
  return;
241
242
  }
242
243
  if (n.shiftKey) {
243
- let { selection: n, activeCell: r } = m.uiState, i = n?.type === "row" ? n.startRow : r?.row;
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(e.startRowSelection(i, m.resolveFirstDataCell?.().col)), m.dispatch(e.updateRowSelection(t));
246
+ h.dispatch(e.startRowSelection(i, h.resolveFirstDataCell?.().col)), h.dispatch(e.updateRowSelection(t));
246
247
  return;
247
248
  }
248
249
  }
249
- m.dispatch(e.startRowSelection(t, m.resolveFirstDataCell?.().col));
250
+ h.dispatch(e.startRowSelection(t, h.resolveFirstDataCell?.().col));
250
251
  }
251
252
  },
252
253
  handleRowHeaderPointerEnter: (t, n) => {
253
- if (m === null) return;
254
- if (m.enableRowHover && m.setHoveredRowIndex(t), g) {
255
- m.pointerClientRef.current = {
254
+ if (h === null) return;
255
+ if (h.enableRowHover && h.setHoveredRowIndex(t), _) {
256
+ h.pointerClientRef.current = {
256
257
  x: n.clientX,
257
258
  y: n.clientY
258
- }, m.onGutterRowSelectDrag(t);
259
+ }, h.onGutterRowSelectDrag(t);
259
260
  return;
260
261
  }
261
- let r = w();
262
- r?.type !== "selection" || r.selectionKind !== "row" || (m.pointerClientRef.current = {
262
+ let r = T();
263
+ r?.type !== "selection" || r.selectionKind !== "row" || (h.pointerClientRef.current = {
263
264
  x: n.clientX,
264
265
  y: n.clientY
265
- }, m.dispatch(e.updateRowSelection(t)));
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];
272
+ }) || h === null)) {
273
+ if (i.shiftKey && h.enableSorting) {
274
+ let i = h.orderedColumns[r];
274
275
  if (i && !n(i.key)) {
275
- let n = m.uiState.sort, r = n.find((e) => e.columnKey === i.key)?.direction ? "desc" : "asc", a = t(n, i.key, r, !0);
276
- m.dispatch(a.length === 0 ? e.clearSort() : e.setSort(a));
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(e.startColumnSelection(r, m.resolveFirstDataCell?.().row));
281
+ h.dispatch(e.startColumnSelection(r, h.resolveFirstDataCell?.().row));
281
282
  }
282
283
  },
283
284
  handleColumnHeaderPointerEnter: (t, n) => {
284
- if (m === null) return;
285
- m.setHoveredRowIndex(null), m.enableColumnHeaderHover && m.setHoveredColumnIndex(t);
286
- let r = w();
287
- r?.type !== "selection" || r.selectionKind !== "col" || (m.pointerClientRef.current = {
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 = {
288
289
  x: n.clientX,
289
290
  y: n.clientY
290
- }, m.dispatch(e.updateColumnSelection(t)));
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/detailRow.cjs");require("../logic/domGuards.cjs"),require("./escapeClaimController.cjs");var t=e=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e?.blur()},n=`input, textarea, select, [contenteditable]:not([contenteditable="false"])`,r=t=>{let r=t.current,i=r?.ownerDocument.activeElement??null;r!==null&&i!==null&&!r.contains(i)&&i.closest(`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover`)!==null&&(i.matches(n)?queueMicrotask(()=>{let e=t.current,n=e?.ownerDocument.activeElement??null;e!==null&&(n===null||n===e.ownerDocument.body)&&e.focus({preventScroll:!0})}):r.focus({preventScroll:!0})),requestAnimationFrame(()=>{let n=t.current;if(n===null||e.isFocusInsideDetailCard())return;let r=n.ownerDocument.activeElement;r!==null&&r!==n&&n.contains(r)&&r.closest(`.ssg-cell-editor`)!==null||r!==null&&!n.contains(r)&&r.closest(`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover`)!==null||n.focus()})},i=(e,t)=>e.current?.contains(t)===!0,a=(e,t,n=`[role="menuitem"]`)=>{let r=document.activeElement,i=r instanceof HTMLElement&&r!==e&&e.contains(r);if(i&&!r.matches(n))return!1;let a=t.key;if(a===`ArrowDown`||a===`ArrowUp`||a===`Home`||a===`End`){t.preventDefault();let o=Array.from(e.querySelectorAll(`${n}:not(:disabled):not([aria-disabled="true"])`));if(o.length===0)return!0;let s=i?o.indexOf(r):-1,c;return c=a===`Home`?0:a===`End`?o.length-1:a===`ArrowDown`?s<0?0:(s+1)%o.length:s<0?o.length-1:(s-1+o.length)%o.length,o[c]?.focus(),!0}return!i&&(a===`PageUp`||a===`PageDown`||a===` `||a===`ArrowLeft`||a===`ArrowRight`)?(t.preventDefault(),!0):!1},o=(e,t)=>{if(e===null||!e.isConnected)return;let n=e.ownerDocument.activeElement,r=n!==null&&t!=null&&(n===t||t.contains(n)&&n.hasAttribute(`data-ssg-ime-input`));(n===null||n===e.ownerDocument.body||r)&&e.focus({preventScroll:!0})},s=e=>{let t=!1,n=()=>e.onResize?.(),r=t=>e.onScroll?.(t),i=t=>{let n=t.target;n&&(e.isInside(n)||e.onOutsidePointerDown(n))},a=t=>e.onKeyDown?.(t),o=null,s=()=>{let n=e.getGridRoot?.()??null,r=e.onGridHidden;!n||!r||typeof ResizeObserver>`u`||(o=new ResizeObserver(e=>{let i=e[e.length-1];if(!t||!i||i.contentRect.width!==0||i.contentRect.height!==0)return;let a=n.getBoundingClientRect();a.width===0&&a.height===0&&r()}),o.observe(n))};return{attach:()=>{t||(t=!0,window.addEventListener(`resize`,n),window.addEventListener(`scroll`,r,!0),window.addEventListener(`pointerdown`,i),window.addEventListener(`keydown`,a,!0),s())},detach:()=>{t&&(t=!1,o?.disconnect(),o=null,window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`pointerdown`,i),window.removeEventListener(`keydown`,a,!0))},isAttached:()=>t}};exports.blurForPopover=t,exports.createPopoverWindowBindings=s,exports.focusPanelIfIdle=o,exports.handleMenuKeyNavigation=a,exports.isInsideGridRoot=i,exports.restoreGridFocus=r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/shadowDom.cjs"),t=require("../logic/detailRow.cjs");require("../logic/domGuards.cjs"),require("./escapeClaimController.cjs");var n=t=>{let n=e.getActiveElement(t);n instanceof HTMLElement&&n.blur(),t?.blur()},r=`input, textarea, select, [contenteditable]:not([contenteditable="false"])`,i=n=>{let i=n.current,a=i===null?null:e.getActiveElement(i);i!==null&&a!==null&&!i.contains(a)&&a.closest(`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover`)!==null&&(a.matches(r)?queueMicrotask(()=>{let t=n.current,r=t===null?null:e.getActiveElement(t);t!==null&&(r===null||r===t.ownerDocument.body)&&t.focus({preventScroll:!0})}):i.focus({preventScroll:!0})),requestAnimationFrame(()=>{let r=n.current;if(r===null||t.isFocusInsideDetailCard(r))return;let i=e.getActiveElement(r);i!==null&&i!==r&&r.contains(i)&&i.closest(`.ssg-cell-editor`)!==null||i!==null&&!r.contains(i)&&i.closest(`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover`)!==null||r.focus()})},a=`.ssg-toolpanel, .ssg-filter-popover`,o=t=>{let n=t.current,r=n===null?null:e.getActiveElement(n);return r!==null&&typeof r.closest==`function`&&r.closest(a)!==null},s=(e,t)=>e.current?.contains(t)===!0,c=(t,n,r=`[role="menuitem"]`)=>{let i=e.getActiveElement(t),a=i instanceof HTMLElement&&i!==t&&t.contains(i);if(a&&!i.matches(r))return!1;let o=n.key;if(o===`ArrowDown`||o===`ArrowUp`||o===`Home`||o===`End`){n.preventDefault();let e=Array.from(t.querySelectorAll(`${r}:not(:disabled):not([aria-disabled="true"])`));if(e.length===0)return!0;let s=a?e.indexOf(i):-1,c;return c=o===`Home`?0:o===`End`?e.length-1:o===`ArrowDown`?s<0?0:(s+1)%e.length:s<0?e.length-1:(s-1+e.length)%e.length,e[c]?.focus(),!0}return!a&&(o===`PageUp`||o===`PageDown`||o===` `||o===`ArrowLeft`||o===`ArrowRight`)?(n.preventDefault(),!0):!1},l=(t,n)=>{if(t===null||!t.isConnected)return;let r=e.getActiveElement(t),i=r!==null&&n!=null&&(r===n||n.contains(r)&&r.hasAttribute(`data-ssg-ime-input`));(r===null||r===t.ownerDocument.body||i)&&t.focus({preventScroll:!0})},u=t=>{let n=t.ownerDocument.defaultView;n!==null&&n.requestAnimationFrame(()=>{if(!t.isConnected)return;let n=e.getActiveElement(t);(n===null||n===t.ownerDocument.body||n===t.ownerDocument.documentElement)&&t.focus({preventScroll:!0})})},d=new Set,f=t=>{let n=!1,r=()=>t.onResize?.(),i=e=>t.onScroll?.(e),a=n=>{let r=e.getEventTarget(n,t.getGridRoot?.()??null);r&&(t.isInside(r)||t.onOutsidePointerDown(r))},o=e=>t.onKeyDown?.(e),s=null,c=null,l=()=>{let e=t.onOtherGridPopupOpen,n=t.getGridRoot?.()??null;if(!(!e||!n)){for(let e of Array.from(d))e.owner!==n&&(d.delete(e),e.close());c={owner:n,close:e},d.add(c)}},u=()=>{let e=t.getGridRoot?.()??null,r=t.onGridHidden;!e||!r||typeof ResizeObserver>`u`||(s=new ResizeObserver(t=>{let i=t[t.length-1];if(!n||!i||i.contentRect.width!==0||i.contentRect.height!==0)return;let a=e.getBoundingClientRect();a.width===0&&a.height===0&&r()}),s.observe(e))};return{attach:()=>{n||(n=!0,window.addEventListener(`resize`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`pointerdown`,a),window.addEventListener(`keydown`,o,!0),u(),l())},detach:()=>{n&&(n=!1,c!==null&&(d.delete(c),c=null),s?.disconnect(),s=null,window.removeEventListener(`resize`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`pointerdown`,a),window.removeEventListener(`keydown`,o,!0))},isAttached:()=>n}};exports.blurForPopover=n,exports.createPopoverWindowBindings=f,exports.focusPanelIfIdle=l,exports.handleMenuKeyNavigation=c,exports.isFocusInPopupOpenedFromMenu=o,exports.isInsideGridRoot=s,exports.keepFocusAfterPress=u,exports.restoreGridFocus=i;
@@ -3,9 +3,11 @@ export type ReadonlyElementRef<E extends HTMLElement = HTMLElement> = {
3
3
  };
4
4
  export declare const blurForPopover: (gridRoot: HTMLElement | null) => void;
5
5
  export declare const restoreGridFocus: (gridRootRef: ReadonlyElementRef) => void;
6
+ export declare const isFocusInPopupOpenedFromMenu: (gridRootRef: ReadonlyElementRef) => boolean;
6
7
  export declare const isInsideGridRoot: (gridRootRef: ReadonlyElementRef, target: Node) => boolean;
7
8
  export declare const handleMenuKeyNavigation: (panel: HTMLElement, event: KeyboardEvent, itemSelector?: string) => boolean;
8
9
  export declare const focusPanelIfIdle: (panel: HTMLElement | null, gridRoot?: HTMLElement | null) => void;
10
+ export declare const keepFocusAfterPress: (trigger: HTMLElement) => void;
9
11
  export type PopoverWindowHandlers = {
10
12
  onResize?: () => void;
11
13
  onScroll?: (event: Event) => void;
@@ -14,6 +16,7 @@ export type PopoverWindowHandlers = {
14
16
  onKeyDown?: (event: KeyboardEvent) => void;
15
17
  getGridRoot?: () => HTMLElement | null;
16
18
  onGridHidden?: () => void;
19
+ onOtherGridPopupOpen?: () => void;
17
20
  };
18
21
  export type PopoverWindowBindings = {
19
22
  attach: () => void;