@ishibashi0112/spreadsheet-grid-core 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/activeRowFollowController.cjs +1 -0
- package/dist/controllers/activeRowFollowController.d.ts +18 -0
- package/dist/controllers/activeRowFollowController.js +68 -0
- package/dist/controllers/autoHeightMeasurer.cjs +1 -1
- package/dist/controllers/autoHeightMeasurer.js +17 -17
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +2 -0
- package/dist/controllers/clipboardController.js +74 -64
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.js +10 -10
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.d.ts +1 -0
- package/dist/controllers/contextMenuController.js +12 -7
- package/dist/controllers/detailRowController.cjs +1 -0
- package/dist/controllers/detailRowController.d.ts +41 -0
- package/dist/controllers/detailRowController.js +96 -0
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +1 -0
- package/dist/controllers/editController.js +106 -99
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +78 -78
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +6 -6
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +16 -15
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +65 -54
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +113 -111
- package/dist/controllers/liveUiState.cjs +1 -0
- package/dist/controllers/liveUiState.d.ts +7 -0
- package/dist/controllers/liveUiState.js +4 -0
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +1 -0
- package/dist/controllers/pointerInteractionsController.js +157 -156
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +117 -104
- package/dist/controllers/scrollSyncController.cjs +1 -1
- package/dist/controllers/scrollSyncController.js +45 -43
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.js +19 -19
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +1 -0
- package/dist/controllers/viewportSyncController.js +1 -1
- package/dist/engine/cellCommands.cjs +1 -0
- package/dist/engine/cellCommands.d.ts +27 -0
- package/dist/engine/cellCommands.js +89 -0
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.js +113 -113
- package/dist/engine/createGridEngine.cjs +3 -3
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +72 -70
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +4 -2
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +6 -6
- package/dist/engine/gridApi.cjs +6 -6
- package/dist/engine/gridApi.d.ts +4 -0
- package/dist/engine/gridApi.js +208 -192
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +4 -0
- package/dist/engine/notifiers.js +7 -7
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +2 -0
- package/dist/logic/cellPlacement.cjs +1 -0
- package/dist/logic/cellPlacement.d.ts +22 -0
- package/dist/logic/cellPlacement.js +44 -0
- package/dist/logic/density.cjs +1 -0
- package/dist/logic/density.d.ts +5 -0
- package/dist/logic/density.js +17 -0
- package/dist/logic/detailRow.cjs +1 -1
- package/dist/logic/detailRow.d.ts +4 -0
- package/dist/logic/detailRow.js +10 -7
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.d.ts +5 -0
- package/dist/logic/domGuards.js +8 -2
- package/dist/logic/editorKeys.cjs +1 -0
- package/dist/logic/editorKeys.d.ts +30 -0
- package/dist/logic/editorKeys.js +34 -0
- package/dist/logic/editorStart.cjs +1 -0
- package/dist/logic/editorStart.d.ts +7 -0
- package/dist/logic/editorStart.js +23 -0
- package/dist/logic/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +2 -1
- package/dist/logic/exportCsv.js +13 -13
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +2 -1
- package/dist/logic/exportData.js +18 -18
- package/dist/logic/geometry.cjs +1 -1
- package/dist/logic/geometry.d.ts +2 -0
- package/dist/logic/geometry.js +41 -20
- package/dist/logic/gridBarSummary.cjs +1 -0
- package/dist/logic/gridBarSummary.d.ts +27 -0
- package/dist/logic/gridBarSummary.js +137 -0
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +3 -2
- package/dist/logic/gridState.js +32 -23
- package/dist/logic/grouping.cjs +1 -1
- package/dist/logic/grouping.js +1 -1
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +6 -4
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +4 -0
- package/dist/logic/localeTextFeatures.js +8 -5
- package/dist/logic/pasteFill.cjs +1 -0
- package/dist/logic/pasteFill.d.ts +2 -0
- package/dist/logic/pasteFill.js +25 -0
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +28 -2
- package/dist/logic/selectEditorState.js +29 -14
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +2 -3
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +21 -21
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +13 -0
- package/dist/model/gridActions.js +11 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +128 -65
- package/dist/model/gridTypes.core.d.ts +172 -26
- package/dist/utils/editorVisibleBounds.cjs +1 -0
- package/dist/utils/editorVisibleBounds.d.ts +10 -0
- package/dist/utils/editorVisibleBounds.js +40 -0
- package/dist/utils/errorBubblePlacement.cjs +1 -0
- package/dist/utils/errorBubblePlacement.d.ts +8 -0
- package/dist/utils/errorBubblePlacement.js +26 -0
- package/dist/utils/gridVisibleBand.cjs +1 -0
- package/dist/utils/gridVisibleBand.d.ts +4 -0
- package/dist/utils/gridVisibleBand.js +24 -0
- package/dist/utils/multilineEditor.cjs +2 -0
- package/dist/utils/multilineEditor.d.ts +7 -0
- package/dist/utils/multilineEditor.js +22 -0
- package/dist/utils/scrollBottom.cjs +1 -0
- package/dist/utils/scrollBottom.d.ts +1 -0
- package/dist/utils/scrollBottom.js +4 -0
- package/dist/utils/topAlignedInput.cjs +1 -0
- package/dist/utils/topAlignedInput.d.ts +3 -0
- package/dist/utils/topAlignedInput.js +23 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/sorting.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/geometry.cjs"),i=require("./liveUiState.cjs"),a=require("../logic/autoScrollGeometry.cjs"),o=require("../logic/elementScale.cjs"),s=require("../logic/verticalGeometry.cjs");var c=10,l=300,u=()=>{let c=null,l=!1,u=!1,d=null,f=null,p=`mouse`,m=null,h=null,g=!1,_=!1,v=()=>c===null?null:i.readLiveUiState(c).dragState??null,y=null,b=e=>{let t=c?.footerHeight??0,n=c?.stickyTopHeight??0,r=c?.scrollContainerRef.current??null;if(t<=0&&n<=0||!r)return e;let i=r.getBoundingClientRect(),s=o.resolveElementScale(r,i);return a.clampClientYBelowHeader(a.clampClientYAboveFooter(e,i.top+(r.clientTop+r.clientHeight)*s.y,t*s.y),i.top+r.clientTop*s.y,n*s.y)},x=(e,t)=>{if(c===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:a,rightPaneScrollRef:l,filteredRowsLength:u,visibleColumnsLength:d,paneLayout:f,leftLeadingWidth:p,centerLeadingWidth:m,rightLeadingWidth:h,headerHeight:g,rowMetrics:_,verticalScaleFactor:v}=c,y=n.current;if(!y||u===0||d===0)return null;let x=y.getBoundingClientRect(),S=o.resolveElementScale(y,x),C=s.clientYToRowIndex(y.scrollTop+(b(t)-x.top)/S.y-g,i.current?.scrollTop??0,v,_),w=null,T=a.current;if(w===null&&T&&f.left.entries.length>0){let t=T.getBoundingClientRect();if(e<t.right){let n=(e-t.left)/S.x-p;w=r.findLogicalIndexFromPaneOffset(f.left,n)}}let E=l.current;if(w===null&&E&&f.right.entries.length>0){let t=E.getBoundingClientRect();if(e>=t.left){let n=(e-t.left)/S.x-h;w=r.findLogicalIndexFromPaneOffset(f.right,n)}}if(w===null&&f.center.entries.length>0){let t=T&&f.left.entries.length===0?Math.max(e,T.getBoundingClientRect().left+p*S.x):e,n=y.scrollLeft+(t-x.left)/S.x-m;w=r.findLogicalIndexFromPaneOffset(f.center,Math.max(n,0))}return w===null?null:{row:C,col:r.clamp(w,0,d-1)}},S=(t,n)=>{let r=v();if(c===null||!r||r.type!==`selection`)return;let i=x(t,n);if(i){if(r.selectionKind===`cell`){c.dispatch(e.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){c.dispatch(e.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&c.dispatch(e.gridActions.updateColumnSelection(i.col))}},C=(t,n)=>{let r=n.timeStamp;if(c===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:o,enableRowSelection:s,onGutterRowSelect:l,onCellDoubleClickRef:u,resolveFirstDataCell:d}=c;i.current?.focus({preventScroll:!0});let{target:p}=t;if(p.kind===`cell`){let t=f;if(t&&t.cell.row===p.cell.row&&t.cell.col===p.cell.col&&r-t.time<300){f=null,u.current(p.cell,n);return}f={cell:p.cell,time:r},a(e.gridActions.activateCell(p.cell)),o&&(a(e.gridActions.startSelection(p.cell)),a(e.gridActions.endSelection()));return}if(f=null,p.kind===`row`){if(s){l(p.rowIndex,{shiftKey:!1});return}a(e.gridActions.startRowSelection(p.rowIndex,d?.().col)),a(e.gridActions.endSelection());return}a(e.gridActions.startColumnSelection(p.colIndex,d?.().row)),a(e.gridActions.endSelection())},w=()=>{c!==null&&(u=!1,c.dispatch(e.gridActions.endSelection()),c.dispatch(e.gridActions.endColumnResize()))},T=t=>{if(c===null)return;c.pointerClientRef.current={x:t.clientX,y:t.clientY};let n=v();if(n?.type===`columnResize`){(y===null||y.drag!==n)&&(y={drag:n,x:o.resolveElementScale(c.scrollContainerRef.current).x});let r=y.x===1?t.clientX:n.startX+(t.clientX-n.startX)/y.x;c.dispatch(e.gridActions.updateColumnResize(r))}},E=e=>{let t=d;t&&(d=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&C(t,e)),w()},D=()=>{d=null,w()},O=()=>{l||(l=!0,window.addEventListener(`pointermove`,T),window.addEventListener(`pointerup`,E),window.addEventListener(`pointercancel`,D))},k=()=>{l&&(l=!1,window.removeEventListener(`pointermove`,T),window.removeEventListener(`pointerup`,E),window.removeEventListener(`pointercancel`,D))},A=()=>{_=!1,c!==null&&c.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(c.autoScrollFrameRef.current),c.autoScrollFrameRef.current=null)},j=()=>{if(c===null||!_)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=c,r=e.current,i=t.current;if(!r||!i){n.current=requestAnimationFrame(j);return}if(!g){let e=h;if(e&&!a.hasPointerLeftActivationRadius(e,i,6)){n.current=requestAnimationFrame(j);return}g=!0}let s=r.getBoundingClientRect(),l=o.resolveElementScale(r,s),u=a.resolveScrollContentBox({rectLeft:s.left,rectTop:s.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight,scale:l}),d=v(),f=d?.type===`selection`&&d.selectionKind===`col`,p=d?.type===`selection`&&d.selectionKind===`row`,m=f?0:a.resolveAutoScrollAxisDirection(i.y,a.resolveTopAutoScrollStart(u.top,(c.stickyTopHeight??0)*l.y,24),u.bottom-(c.footerHeight??0),24),y=p?0:a.resolveAutoScrollAxisDirection(i.x,u.left,u.right,24),b=a.computeNextScrollPosition(r.scrollTop,m,18,r.scrollHeight-r.clientHeight),x=a.computeNextScrollPosition(r.scrollLeft,y,18,r.scrollWidth-r.clientWidth);(b!==r.scrollTop||x!==r.scrollLeft)&&(r.scrollTo({top:b,left:x,behavior:`auto`}),S(i.x,i.y)),n.current=requestAnimationFrame(j)},M=()=>{let e=v()?.type===`selection`;e&&!_?(_=!0,c!==null&&(c.autoScrollFrameRef.current=requestAnimationFrame(j))):!e&&_&&A()},N=()=>{if(m!==null)return;let e=()=>{if(!u||c===null){m=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=c,i=t.current,s=n.current;if(!i||!s){m=requestAnimationFrame(e);return}if(!g){let t=h;if(t&&!a.hasPointerLeftActivationRadius(t,s,6)){m=requestAnimationFrame(e);return}g=!0}let l=i.getBoundingClientRect(),d=o.resolveElementScale(i,l),f=a.resolveScrollContentBox({rectLeft:l.left,rectTop:l.top,clientLeft:i.clientLeft,clientTop:i.clientTop,clientWidth:i.clientWidth,clientHeight:i.clientHeight,scale:d}),p=a.resolveAutoScrollAxisDirection(s.y,a.resolveTopAutoScrollStart(f.top,(c.stickyTopHeight??0)*d.y,24),f.bottom-(c.footerHeight??0),24),_=a.computeNextScrollPosition(i.scrollTop,p,18,i.scrollHeight-i.clientHeight);if(_!==i.scrollTop){i.scrollTo({top:_,left:i.scrollLeft,behavior:`auto`});let e=x(s.x,s.y);e&&r(e.row)}m=requestAnimationFrame(e)};m=requestAnimationFrame(e)},P=(e,t)=>(e.preventDefault(),c===null||e.button!==0?!1:(p=e.pointerType,e.pointerType===`touch`?(d={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(c.gridRootRef.current?.focus({preventScroll:!0}),c.pointerClientRef.current={x:e.clientX,y:e.clientY},h={x:e.clientX,y:e.clientY},g=!1,!0)));return{update:e=>{c=e,O(),M()},getCellCoordFromClientPoint:x,updateSelectionFromPointer:S,handleCellPointerDown:(t,n)=>{if(!(!P(n,{kind:`cell`,cell:t})||c===null)){if(n.shiftKey&&c.enableRangeSelection){let{selection:n,activeCell:r}=i.readLiveUiState(c),a=n?.type===`cell`?n.range.start:r;if(a){c.dispatch(e.gridActions.startSelection(a)),c.dispatch(e.gridActions.updateSelection(t));return}}c.dispatch(e.gridActions.activateCell(t)),c.enableRangeSelection&&c.dispatch(e.gridActions.startSelection(t))}},handleCellDoubleClick:(e,t)=>{p===`touch`||c===null||c.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(t,n)=>{if(c===null||(c.enableRowHover&&c.setHoveredRowIndex(t.row),c.enableColumnHover&&c.setHoveredColumnIndex(t.col),!c.enableRangeSelection))return;let r=v();r?.type!==`selection`||r.selectionKind!==`cell`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateSelection(t)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(t,n)=>{if(!(!P(n,{kind:`row`,rowIndex:t})||c===null)){if(c.enableRowSelection){u=!0,c.onGutterRowSelect(t,{shiftKey:n.shiftKey}),N();return}if(n.shiftKey){let{selection:n,activeCell:r}=i.readLiveUiState(c),a=n?.type===`row`?n.startRow:r?.row;if(a!==void 0){c.dispatch(e.gridActions.startRowSelection(a,c.resolveFirstDataCell?.().col)),c.dispatch(e.gridActions.updateRowSelection(t));return}}c.dispatch(e.gridActions.startRowSelection(t,c.resolveFirstDataCell?.().col))}},handleRowHeaderPointerEnter:(t,n)=>{if(c===null)return;if(c.enableRowHover&&c.setHoveredRowIndex(t),u){c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.onGutterRowSelectDrag(t);return}let r=v();r?.type!==`selection`||r.selectionKind!==`row`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateRowSelection(t)))},handleColumnHeaderPointerDown:(r,a)=>{if(!(!P(a,{kind:`col`,colIndex:r})||c===null)){if(a.shiftKey&&c.enableSorting){let a=c.orderedColumns[r];if(a&&!n.isSyntheticColumnKey(a.key)){let n=i.readLiveUiState(c).sort,r=n.find(e=>e.columnKey===a.key)?.direction?`desc`:`asc`,o=t.nextSortEntries(n,a.key,r,!0);c.dispatch(o.length===0?e.gridActions.clearSort():e.gridActions.setSort(o))}return}c.dispatch(e.gridActions.startColumnSelection(r,c.resolveFirstDataCell?.().row))}},handleColumnHeaderPointerEnter:(t,n)=>{if(c===null)return;c.setHoveredRowIndex(null),c.enableColumnHeaderHover&&c.setHoveredColumnIndex(t);let r=v();r?.type!==`selection`||r.selectionKind!==`col`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateColumnSelection(t)))},dispose:()=>{k(),A(),m!==null&&(cancelAnimationFrame(m),m=null)}}};exports.TOUCH_DOUBLE_TAP_MS=l,exports.TOUCH_TAP_SLOP_PX=c,exports.createPointerInteractionsController=u;
|
|
@@ -31,6 +31,7 @@ export type PointerInteractionsArgs<T> = {
|
|
|
31
31
|
} | null>;
|
|
32
32
|
autoScrollFrameRef: MutableRef<number | null>;
|
|
33
33
|
uiState: GridUiState;
|
|
34
|
+
getUiState?: (() => GridUiState) | undefined;
|
|
34
35
|
dispatch: (action: GridUiAction) => void;
|
|
35
36
|
enableRangeSelection: boolean;
|
|
36
37
|
enableSorting: boolean;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { gridActions as e } from "../model/gridActions.js";
|
|
2
|
+
import { nextSortEntries as t } from "../logic/sorting.js";
|
|
3
|
+
import { isSyntheticColumnKey as n } from "../logic/detailRow.js";
|
|
4
4
|
import { clamp as r, findLogicalIndexFromPaneOffset as i } from "../logic/geometry.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
|
10
|
-
let
|
|
11
|
-
let t =
|
|
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(),
|
|
14
|
-
return o(
|
|
15
|
-
},
|
|
16
|
-
if (
|
|
17
|
-
let { bodyScrollRef: n, scrollContainerRef: a, leftPaneScrollRef: o, rightPaneScrollRef: s, filteredRowsLength: c, visibleColumnsLength: l, paneLayout: u, leftLeadingWidth: d, centerLeadingWidth:
|
|
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 =
|
|
20
|
+
let x = b.getBoundingClientRect(), S = p(b, x), C = m(b.scrollTop + (D(t) - x.top) / S.y - _, a.current?.scrollTop ?? 0, y, v), w = null, T = o.current;
|
|
20
21
|
if (w === null && T && u.left.entries.length > 0) {
|
|
21
22
|
let t = T.getBoundingClientRect();
|
|
22
23
|
if (e < t.right) {
|
|
@@ -24,108 +25,108 @@ var m = 10, h = 300, g = () => {
|
|
|
24
25
|
w = i(u.left, n);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
|
-
let
|
|
28
|
-
if (w === null &&
|
|
29
|
-
let t =
|
|
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 -
|
|
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
|
-
},
|
|
44
|
-
let r =
|
|
45
|
-
if (
|
|
46
|
-
let i =
|
|
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
|
-
|
|
50
|
+
h.dispatch(e.updateSelection(i));
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
53
|
if (r.selectionKind === "row") {
|
|
53
|
-
|
|
54
|
+
h.dispatch(e.updateRowSelection(i.row));
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
|
-
r.selectionKind === "col" &&
|
|
57
|
+
r.selectionKind === "col" && h.dispatch(e.updateColumnSelection(i.col));
|
|
57
58
|
}
|
|
58
|
-
},
|
|
59
|
-
let r =
|
|
60
|
-
if (
|
|
61
|
-
let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l, resolveFirstDataCell: u } =
|
|
59
|
+
}, A = (t, n) => {
|
|
60
|
+
let r = n.timeStamp;
|
|
61
|
+
if (h === null) return;
|
|
62
|
+
let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l, resolveFirstDataCell: u } = h;
|
|
62
63
|
i.current?.focus({ preventScroll: !0 });
|
|
63
|
-
let { target: d } =
|
|
64
|
+
let { target: d } = t;
|
|
64
65
|
if (d.kind === "cell") {
|
|
65
|
-
let
|
|
66
|
-
if (
|
|
67
|
-
|
|
66
|
+
let t = y;
|
|
67
|
+
if (t && t.cell.row === d.cell.row && t.cell.col === d.cell.col && r - t.time < 300) {
|
|
68
|
+
y = null, l.current(d.cell, n);
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
y = {
|
|
71
72
|
cell: d.cell,
|
|
72
73
|
time: r
|
|
73
|
-
}, a(
|
|
74
|
+
}, a(e.activateCell(d.cell)), o && (a(e.startSelection(d.cell)), a(e.endSelection()));
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
76
|
-
if (
|
|
77
|
+
if (y = null, d.kind === "row") {
|
|
77
78
|
if (s) {
|
|
78
79
|
c(d.rowIndex, { shiftKey: !1 });
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
|
-
a(
|
|
82
|
+
a(e.startRowSelection(d.rowIndex, u?.().col)), a(e.endSelection());
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
|
-
a(
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
x:
|
|
91
|
-
y:
|
|
85
|
+
a(e.startColumnSelection(d.colIndex, u?.().row)), a(e.endSelection());
|
|
86
|
+
}, j = () => {
|
|
87
|
+
h !== null && (_ = !1, h.dispatch(e.endSelection()), h.dispatch(e.endColumnResize()));
|
|
88
|
+
}, M = (t) => {
|
|
89
|
+
if (h === null) return;
|
|
90
|
+
h.pointerClientRef.current = {
|
|
91
|
+
x: t.clientX,
|
|
92
|
+
y: t.clientY
|
|
92
93
|
};
|
|
93
|
-
let
|
|
94
|
-
if (
|
|
95
|
-
(
|
|
96
|
-
drag:
|
|
97
|
-
x:
|
|
94
|
+
let n = T();
|
|
95
|
+
if (n?.type === "columnResize") {
|
|
96
|
+
(E === null || E.drag !== n) && (E = {
|
|
97
|
+
drag: n,
|
|
98
|
+
x: p(h.scrollContainerRef.current).x
|
|
98
99
|
});
|
|
99
|
-
let r =
|
|
100
|
-
|
|
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
|
-
},
|
|
103
|
-
let t =
|
|
104
|
-
t && (
|
|
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
|
-
|
|
107
|
+
v = null, j();
|
|
109
108
|
}, F = () => {
|
|
110
|
-
|
|
109
|
+
g || (g = !0, window.addEventListener("pointermove", M), window.addEventListener("pointerup", N), window.addEventListener("pointercancel", P));
|
|
111
110
|
}, I = () => {
|
|
112
|
-
|
|
111
|
+
g && (g = !1, window.removeEventListener("pointermove", M), window.removeEventListener("pointerup", N), window.removeEventListener("pointercancel", P));
|
|
113
112
|
}, L = () => {
|
|
114
|
-
|
|
115
|
-
|
|
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(
|
|
118
|
+
n.current = requestAnimationFrame(R);
|
|
118
119
|
return;
|
|
119
120
|
}
|
|
120
|
-
if (!
|
|
121
|
-
let e =
|
|
122
|
-
if (e && !
|
|
123
|
-
n.current = requestAnimationFrame(
|
|
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
|
-
|
|
127
|
+
C = !0;
|
|
127
128
|
}
|
|
128
|
-
let a = r.getBoundingClientRect(), o =
|
|
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
|
-
}),
|
|
137
|
-
(b !== r.scrollTop ||
|
|
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:
|
|
140
|
+
left: x,
|
|
140
141
|
behavior: "auto"
|
|
141
|
-
}),
|
|
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
|
-
|
|
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 (!
|
|
149
|
-
|
|
149
|
+
if (!_ || h === null) {
|
|
150
|
+
x = null;
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
|
-
let { scrollContainerRef: t, pointerClientRef: n, onGutterRowSelectDrag: r } =
|
|
153
|
+
let { scrollContainerRef: t, pointerClientRef: n, onGutterRowSelectDrag: r } = h, i = t.current, a = n.current;
|
|
153
154
|
if (!i || !a) {
|
|
154
|
-
|
|
155
|
+
x = requestAnimationFrame(e);
|
|
155
156
|
return;
|
|
156
157
|
}
|
|
157
|
-
if (!
|
|
158
|
-
let t =
|
|
159
|
-
if (t && !
|
|
160
|
-
|
|
158
|
+
if (!C) {
|
|
159
|
+
let t = S;
|
|
160
|
+
if (t && !l(t, a, 6)) {
|
|
161
|
+
x = requestAnimationFrame(e);
|
|
161
162
|
return;
|
|
162
163
|
}
|
|
163
|
-
|
|
164
|
+
C = !0;
|
|
164
165
|
}
|
|
165
|
-
let o = i.getBoundingClientRect(),
|
|
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:
|
|
173
|
-
}),
|
|
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 =
|
|
181
|
+
let e = O(a.x, a.y);
|
|
181
182
|
e && r(e.row);
|
|
182
183
|
}
|
|
183
|
-
|
|
184
|
+
x = requestAnimationFrame(e);
|
|
184
185
|
};
|
|
185
|
-
|
|
186
|
-
},
|
|
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) : (
|
|
192
|
+
}, !1) : (h.gridRootRef.current?.focus({ preventScroll: !0 }), h.pointerClientRef.current = {
|
|
192
193
|
x: e.clientX,
|
|
193
194
|
y: e.clientY
|
|
194
|
-
},
|
|
195
|
+
}, S = {
|
|
195
196
|
x: e.clientX,
|
|
196
197
|
y: e.clientY
|
|
197
|
-
},
|
|
198
|
+
}, C = !1, !0)));
|
|
198
199
|
return {
|
|
199
200
|
update: (e) => {
|
|
200
|
-
|
|
201
|
+
h = e, F(), z();
|
|
201
202
|
},
|
|
202
|
-
getCellCoordFromClientPoint:
|
|
203
|
-
updateSelectionFromPointer:
|
|
204
|
-
handleCellPointerDown: (
|
|
205
|
-
if (!(!
|
|
203
|
+
getCellCoordFromClientPoint: O,
|
|
204
|
+
updateSelectionFromPointer: k,
|
|
205
|
+
handleCellPointerDown: (t, n) => {
|
|
206
|
+
if (!(!V(n, {
|
|
206
207
|
kind: "cell",
|
|
207
|
-
cell:
|
|
208
|
-
}) ||
|
|
209
|
-
if (
|
|
210
|
-
let { selection:
|
|
208
|
+
cell: t
|
|
209
|
+
}) || h === null)) {
|
|
210
|
+
if (n.shiftKey && h.enableRangeSelection) {
|
|
211
|
+
let { selection: n, activeCell: r } = a(h), i = n?.type === "cell" ? n.range.start : r;
|
|
211
212
|
if (i) {
|
|
212
|
-
|
|
213
|
+
h.dispatch(e.startSelection(i)), h.dispatch(e.updateSelection(t));
|
|
213
214
|
return;
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
|
-
|
|
217
|
+
h.dispatch(e.activateCell(t)), h.enableRangeSelection && h.dispatch(e.startSelection(t));
|
|
217
218
|
}
|
|
218
219
|
},
|
|
219
220
|
handleCellDoubleClick: (e, t) => {
|
|
220
|
-
|
|
221
|
+
b === "touch" || h === null || h.onCellDoubleClickRef.current(e, t);
|
|
221
222
|
},
|
|
222
|
-
handleCellPointerEnter: (
|
|
223
|
-
if (
|
|
224
|
-
let r =
|
|
225
|
-
r?.type !== "selection" || r.selectionKind !== "cell" || (
|
|
226
|
-
x:
|
|
227
|
-
y:
|
|
228
|
-
},
|
|
223
|
+
handleCellPointerEnter: (t, n) => {
|
|
224
|
+
if (h === null || (h.enableRowHover && h.setHoveredRowIndex(t.row), h.enableColumnHover && h.setHoveredColumnIndex(t.col), !h.enableRangeSelection)) return;
|
|
225
|
+
let r = T();
|
|
226
|
+
r?.type !== "selection" || r.selectionKind !== "cell" || (h.pointerClientRef.current = {
|
|
227
|
+
x: n.clientX,
|
|
228
|
+
y: n.clientY
|
|
229
|
+
}, h.dispatch(e.updateSelection(t)));
|
|
229
230
|
},
|
|
230
231
|
handleNativeDragStart: (e) => {
|
|
231
232
|
e.preventDefault();
|
|
232
233
|
},
|
|
233
|
-
handleRowHeaderPointerDown: (
|
|
234
|
-
if (!(!
|
|
234
|
+
handleRowHeaderPointerDown: (t, n) => {
|
|
235
|
+
if (!(!V(n, {
|
|
235
236
|
kind: "row",
|
|
236
|
-
rowIndex:
|
|
237
|
-
}) ||
|
|
238
|
-
if (
|
|
239
|
-
|
|
237
|
+
rowIndex: t
|
|
238
|
+
}) || h === null)) {
|
|
239
|
+
if (h.enableRowSelection) {
|
|
240
|
+
_ = !0, h.onGutterRowSelect(t, { shiftKey: n.shiftKey }), B();
|
|
240
241
|
return;
|
|
241
242
|
}
|
|
242
|
-
if (
|
|
243
|
-
let { selection:
|
|
243
|
+
if (n.shiftKey) {
|
|
244
|
+
let { selection: n, activeCell: r } = a(h), i = n?.type === "row" ? n.startRow : r?.row;
|
|
244
245
|
if (i !== void 0) {
|
|
245
|
-
|
|
246
|
+
h.dispatch(e.startRowSelection(i, h.resolveFirstDataCell?.().col)), h.dispatch(e.updateRowSelection(t));
|
|
246
247
|
return;
|
|
247
248
|
}
|
|
248
249
|
}
|
|
249
|
-
|
|
250
|
+
h.dispatch(e.startRowSelection(t, h.resolveFirstDataCell?.().col));
|
|
250
251
|
}
|
|
251
252
|
},
|
|
252
|
-
handleRowHeaderPointerEnter: (
|
|
253
|
-
if (
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
x:
|
|
257
|
-
y:
|
|
258
|
-
},
|
|
253
|
+
handleRowHeaderPointerEnter: (t, n) => {
|
|
254
|
+
if (h === null) return;
|
|
255
|
+
if (h.enableRowHover && h.setHoveredRowIndex(t), _) {
|
|
256
|
+
h.pointerClientRef.current = {
|
|
257
|
+
x: n.clientX,
|
|
258
|
+
y: n.clientY
|
|
259
|
+
}, h.onGutterRowSelectDrag(t);
|
|
259
260
|
return;
|
|
260
261
|
}
|
|
261
|
-
let r =
|
|
262
|
-
r?.type !== "selection" || r.selectionKind !== "row" || (
|
|
263
|
-
x:
|
|
264
|
-
y:
|
|
265
|
-
},
|
|
262
|
+
let r = T();
|
|
263
|
+
r?.type !== "selection" || r.selectionKind !== "row" || (h.pointerClientRef.current = {
|
|
264
|
+
x: n.clientX,
|
|
265
|
+
y: n.clientY
|
|
266
|
+
}, h.dispatch(e.updateRowSelection(t)));
|
|
266
267
|
},
|
|
267
268
|
handleColumnHeaderPointerDown: (r, i) => {
|
|
268
|
-
if (!(!
|
|
269
|
+
if (!(!V(i, {
|
|
269
270
|
kind: "col",
|
|
270
271
|
colIndex: r
|
|
271
|
-
}) ||
|
|
272
|
-
if (i.shiftKey &&
|
|
273
|
-
let i =
|
|
274
|
-
if (i && !
|
|
275
|
-
let
|
|
276
|
-
|
|
272
|
+
}) || h === null)) {
|
|
273
|
+
if (i.shiftKey && h.enableSorting) {
|
|
274
|
+
let i = h.orderedColumns[r];
|
|
275
|
+
if (i && !n(i.key)) {
|
|
276
|
+
let n = a(h).sort, r = n.find((e) => e.columnKey === i.key)?.direction ? "desc" : "asc", o = t(n, i.key, r, !0);
|
|
277
|
+
h.dispatch(o.length === 0 ? e.clearSort() : e.setSort(o));
|
|
277
278
|
}
|
|
278
279
|
return;
|
|
279
280
|
}
|
|
280
|
-
|
|
281
|
+
h.dispatch(e.startColumnSelection(r, h.resolveFirstDataCell?.().row));
|
|
281
282
|
}
|
|
282
283
|
},
|
|
283
|
-
handleColumnHeaderPointerEnter: (
|
|
284
|
-
if (
|
|
285
|
-
|
|
286
|
-
let r =
|
|
287
|
-
r?.type !== "selection" || r.selectionKind !== "col" || (
|
|
288
|
-
x:
|
|
289
|
-
y:
|
|
290
|
-
},
|
|
284
|
+
handleColumnHeaderPointerEnter: (t, n) => {
|
|
285
|
+
if (h === null) return;
|
|
286
|
+
h.setHoveredRowIndex(null), h.enableColumnHeaderHover && h.setHoveredColumnIndex(t);
|
|
287
|
+
let r = T();
|
|
288
|
+
r?.type !== "selection" || r.selectionKind !== "col" || (h.pointerClientRef.current = {
|
|
289
|
+
x: n.clientX,
|
|
290
|
+
y: n.clientY
|
|
291
|
+
}, h.dispatch(e.updateColumnSelection(t)));
|
|
291
292
|
},
|
|
292
293
|
dispose: () => {
|
|
293
|
-
|
|
294
|
+
I(), L(), x !== null && (cancelAnimationFrame(x), x = null);
|
|
294
295
|
}
|
|
295
296
|
};
|
|
296
297
|
};
|
|
297
298
|
//#endregion
|
|
298
|
-
export {
|
|
299
|
+
export { g as TOUCH_DOUBLE_TAP_MS, h as TOUCH_TAP_SLOP_PX, _ as createPointerInteractionsController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/rowReorder.cjs"),t=require("../logic/detailRow.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/elementScale.cjs"),i=require("./escapeClaimController.cjs"),a=require("../logic/slotDom.cjs"),o=require("../utils/portalTokens.cjs"),s=require("../utils/popupContainer.cjs");var c=14,l=12,u=`0.5`,d=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="8 6 12 2 16 6"/><polyline points="16 18 12 22 8 18"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,f=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,p=200,m=`cubic-bezier(0.2, 0.7, 0.3, 1)`,h=`transform 160ms ${m}`,g=`data-ssg-row-dragging`,_=e=>e?.closest(`.ssg-motion-off`)!=null,v=/translateY\((-?[\d.]+)px\)/,y=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},b=e=>{let n=[],r=new Map;return e.querySelectorAll(`.ssg-detail-band[data-detail-row-index]`).forEach(i=>{if(t.isInsideDetailCardOf(e,i))return;let a=Number(i.getAttribute(`data-detail-row-index`)),o=r.get(a)??0;r.set(a,o+1),n.push({el:i,index:a,key:`band|${o}|${a}`})}),n},x=e=>{e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.zIndex=``},S=()=>{let S=null,C=null,w=null,T={x:0,y:0},E=null,D=!1,O=null,k=null,A=null,j=null,M=null,N=null,P=0,F=null,I=()=>S?.motion===`live`,L=null,R=null,z=null,B=()=>[S?.leftIndicatorRef.current??null,S?.centerIndicatorRef.current??null,S?.rightIndicatorRef.current??null],V=()=>{for(let e of B())e&&(e.style.display=`none`)},H=e=>{if(L)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),S?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),S?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),S?.scrollContainerRef.current?.closest(`.ssg-motion-off`)!=null&&t.classList.add(`ssg-motion-off`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`max-width:280px`,`overflow:hidden`,`text-overflow:ellipsis`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`),a.applySlotToElement(t,S?.ghostSlot);let n=document.createElement(`span`);n.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let r=document.createElement(`span`);r.style.cssText=`overflow:hidden;text-overflow:ellipsis`,r.textContent=e,t.appendChild(n),t.appendChild(r),s.appendToPopupContainer(t,s.getPopupContainerFor(S?.scrollContainerRef.current)),o.syncPortalTokens(S?.scrollContainerRef.current,t),L=t,R=n,z=null},U=e=>{let t=L;if(!t)return;t.style.transform=`translate(`+(T.x+c)+`px,`+(T.y+l)+`px)`;let n=e?`move`:`out`;if(z===n)return;z=n;let r=R;n===`out`?(t.style.opacity=u,r&&(r.innerHTML=f)):(t.style.opacity=`1`,r&&(r.innerHTML=d))},W=()=>{L&&L.parentNode&&L.parentNode.removeChild(L),L=null,R=null,z=null},G=(e,n)=>{let r=S?.scrollContainerRef.current??null;!r||n&&e===null||r.querySelectorAll(n?`.ssg-body-row[data-row-index="${e}"]`:`.ssg-body-row[${g}]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(g,I()?`live`:``):e.removeAttribute(g))})},K=()=>{let e=S?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e)){let e=v.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},q=t=>{let n=N,r=C;if(!n||r===null||S===null)return;let i=S.scrollContainerRef.current;if(!i)return;for(let e of y(i)){if(n.has(e))continue;let t=v.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=S.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-P)*S.verticalScaleFactor,s=(E?T.y-E.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{let{index:i,baseY:o}=e;if(!t.isConnected){n.delete(t);return}if(i===r){t.style.transition=`none`,t.style.transform=`translateY(${o+s}px)`,t.style.willChange=`transform`,e.applied=t.style.transform;return}let l=0;c!==null&&(r<i&&i<=c?l=-a:c<=i&&i<r&&(l=a)),t.style.transition=h,t.style.transform=`translateY(${o+l}px)`,e.applied=t.style.transform});let l=F??new Set;F=l;for(let{el:e,index:t}of b(i)){if(l.add(e),t===r){e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,e.style.zIndex=`10`;continue}let n=0;c!==null&&(r<t&&t<=c?n=-a:c<=t&&t<r&&(n=a)),e.style.transition=h,e.style.transform=`translateY(${n}px)`,e.style.zIndex=``}},J=(t,r)=>{if(S===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=S,u=i.current,d=a.current;if(!u||!d)return null;let f=u.getBoundingClientRect();if(t<f.left||t>f.right||r<f.top||r>f.bottom)return null;let p=n.clampClientYBelowHeader(n.clampClientYAboveFooter(r,f.top+u.clientTop+u.clientHeight,S.footerHeight??0),f.top+u.clientTop,S.stickyTopHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=C,v=_!==null&&I()?o.detailHeight(_):0;if(_!==null&&v>0){let t=e.resolveRowDropSlot(h+v,o);t>_+1&&(g=t)}let y=e.resolveRowDropSlotTop(g,o);return{slot:g,top:s+y-l}},Y=()=>{let t=J(T.x,T.y),n=C;if(I()){t&&n!==null&&(w=e.resolveMoveTargetIndex(n,t.slot)===null?null:t.slot),V(),q(w);return}if(U(t),!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){w=null,V();return}w=t.slot;for(let e of B())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},X=()=>{if(C===null){A=null;return}let e=S?.scrollContainerRef.current??null;if(e&&(D||(!E||n.hasPointerLeftActivationRadius(E,T,6))&&(D=!0),D)){let t=e.getBoundingClientRect(),i=r.resolveElementScale(e,t),a=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight,scale:i}),o=n.resolveAutoScrollAxisDirection(T.y,n.resolveTopAutoScrollStart(a.top,(S?.stickyTopHeight??0)*i.y,24),a.bottom-(S?.footerHeight??0),24),s=n.computeNextScrollPosition(e.scrollTop,o,18,e.scrollHeight-e.clientHeight);s!==e.scrollTop&&e.scrollTo({top:s,behavior:`auto`})}Y(),A=requestAnimationFrame(X)},Z=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,Q=()=>{let e=S?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e))t.set(Z(n,Number(n.getAttribute(`data-row-index`))),n.getBoundingClientRect().top);for(let n of b(e))t.set(n.key,n.el.getBoundingClientRect().top);return t},$=t=>{A!==null&&(cancelAnimationFrame(A),A=null),document.body.style.cursor=``,V(),W();let n=C,r=w,i=M;G(n,!1),C=null,M=null,w=null,E=null,k=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=t&&n!==null&&a!==null&&S!==null,s=N;N=null;let c=s&&o&&S!==null&&!_(S.scrollContainerRef.current)?Q():null,l=F;if(F=null,l&&(o?l.forEach(x):(l.forEach(e=>{e.isConnected&&(e.style.transition=h,e.style.transform=`translateY(0px)`,e.style.zIndex=``)}),window.setTimeout(()=>{l.forEach(e=>{F?.has(e)||x(e)})},200))),s)if(o)s.forEach(({baseY:e},t)=>{t.style.transition=``,t.style.willChange=``,t.isConnected&&(t.style.transform=`translateY(${e}px)`)});else{let e=[];s.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=h,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}if(!o||n===null||a===null||S===null)return;let u=c??(_(S.scrollContainerRef.current)?null:Q()),d=u?{tops:u,from:n,to:a,row:i}:null;j=d,S.commitRowMove(n,a),d&&requestAnimationFrame(()=>{j===d&&(j=null)})},ee=()=>{let e=j;if(j=null,!e)return;let t=S?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(S?.locateDragRow&&e.row!==null&&S.locateDragRow(e.row,i)!==i)return;let a=e=>e===i?r:r<i&&e>=r&&e<i?e+1:i<r&&e>i&&e<=r?e-1:e,o=[],s=new Map;y(t).forEach(e=>{let t=n.get(Z(e,a(Number(e.getAttribute(`data-row-index`)))));if(t===void 0)return;let r=t-e.getBoundingClientRect().top;if(Math.abs(r)<.5)return;let i=v.exec(e.style.transform);if(!i)return;let c=parseFloat(i[1]);s.set(e,c),e.style.transition=`none`,e.style.transform=`translateY(${c+r}px)`,e.style.willChange=`transform`,o.push(e)});let c=[];if(b(t).forEach(({el:e,index:t,key:r})=>{let i=a(t),o=n.get(r.slice(0,r.lastIndexOf(`|`)+1)+i);if(o===void 0)return;let s=o-e.getBoundingClientRect().top;Math.abs(s)<.5||(e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,c.push(e))}),!(o.length===0&&c.length===0)){t.getBoundingClientRect();for(let e of o)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateY(${s.get(e)??0}px)`;for(let e of c)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateY(0px)`;window.setTimeout(()=>{for(let e of o)e.style.transition=``,e.style.willChange=``;for(let e of c)F?.has(e)||x(e)},280)}},te=(e,t)=>{if(S===null||!S.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),S.gridRootRef?.current?.focus({preventScroll:!0}),C!==null){if(t.pointerId!==k)return;O?.(),$(!1)}C=e,M=S.getDragRow?.(e)??null,k=t.pointerId,w=null,T={x:t.clientX,y:t.clientY},E={x:t.clientX,y:t.clientY},D=!1,document.body.style.cursor=`grabbing`,I()?(N=K(),P=S.scrollContainerRef.current?.scrollTop??0):H(S.getRowDragLabel(e)),G(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&(T={x:e.clientX,y:e.clientY},Y())},o=i.beginEscapeCancelableDrag(),s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,l),window.removeEventListener(`keydown`,u,!0),window.removeEventListener(`blur`,d),o(),O=null;try{n.releasePointerCapture(r)}catch{}};function c(e){e.pointerId===r&&(s(),$(!0))}function l(e){e.pointerId===r&&(s(),$(!1))}function u(e){e.key===`Escape`&&(s(),$(!1))}function d(){s(),$(!1)}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,l),window.addEventListener(`keydown`,u,!0),window.addEventListener(`blur`,d),O=s,Y(),A=requestAnimationFrame(X)},ne=e=>{if(C===null||M==null||S?.locateDragRow===void 0)return;let t=S.locateDragRow(M,C);if(N&&N.forEach((e,t)=>{if(!t.isConnected){N?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`));if(n===e.index&&(e.applied===void 0||t.style.transform===e.applied))return;let r=v.exec(t.style.transform);if(!r){N?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){O?.(),$(!1);return}N&&t!==C&&E!==null&&e!==null&&(E={x:E.x,y:E.y+S.rowMetrics.rowTop(t)-e.rowTop(C)}),t!==C&&(G(null,!1),C=t,G(t,!0)),Y()};return{update:e=>{let t=S;S=e,C!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&ne(t.rowMetrics)},onRowDragHandlePointerDown:te,applyReorderSettle:ee,dispose:()=>{O?.(),O=null,A!==null&&(cancelAnimationFrame(A),A=null),document.body.style.cursor=``,W(),G(C,!1),C=null,M=null,w=null,N=null,F?.forEach(x),F=null,j=null}}};exports.createRowDragController=S;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/rowReorder.cjs"),t=require("../logic/detailRow.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/elementScale.cjs"),i=require("./escapeClaimController.cjs"),a=require("../logic/slotDom.cjs"),o=require("../utils/portalTokens.cjs"),s=require("../utils/popupContainer.cjs");var c=14,l=12,u=`0.5`,d=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="8 6 12 2 16 6"/><polyline points="16 18 12 22 8 18"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,f=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,p=200,m=`cubic-bezier(0.2, 0.7, 0.3, 1)`,h=`transform 160ms ${m}`,g=`data-ssg-row-dragging`,_=e=>e?.closest(`.ssg-motion-off`)!=null,v=/translateY\((-?[\d.]+)px\)/,y=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},b=e=>{let n=[],r=new Map;return e.querySelectorAll(`.ssg-detail-band[data-detail-row-index]`).forEach(i=>{if(t.isInsideDetailCardOf(e,i))return;let a=Number(i.getAttribute(`data-detail-row-index`)),o=r.get(a)??0;r.set(a,o+1),n.push({el:i,index:a,key:`band|${o}|${a}`})}),n},x=e=>{e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.zIndex=``},S=()=>{let S=null,C=null,w=null,T=null,E=(e,t)=>{let n=S?.canDropAt;if(!n)return!0;if(T!==null&&T.from===e&&T.slot===t)return T.allowed;let r=n(e,t);return T={from:e,slot:t,allowed:r},r},D={x:0,y:0},O=null,k=!1,A=null,j=null,M=null,N=null,P=null,F=null,I=0,L=null,R=()=>S?.motion===`live`,z=null,B=null,V=null,H=()=>[S?.leftIndicatorRef.current??null,S?.centerIndicatorRef.current??null,S?.rightIndicatorRef.current??null],U=()=>{for(let e of H())e&&(e.style.display=`none`)},W=e=>{if(z)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),S?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),S?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),S?.scrollContainerRef.current?.closest(`.ssg-motion-off`)!=null&&t.classList.add(`ssg-motion-off`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`max-width:280px`,`overflow:hidden`,`text-overflow:ellipsis`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`),a.applySlotToElement(t,S?.ghostSlot);let n=document.createElement(`span`);n.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let r=document.createElement(`span`);r.style.cssText=`overflow:hidden;text-overflow:ellipsis`,r.textContent=e,t.appendChild(n),t.appendChild(r),s.appendToPopupContainer(t,s.getPopupContainerFor(S?.scrollContainerRef.current)),o.syncPortalTokens(S?.scrollContainerRef.current,t),z=t,B=n,V=null},G=e=>{let t=z;if(!t)return;t.style.transform=`translate(`+(D.x+c)+`px,`+(D.y+l)+`px)`;let n=e?`move`:`out`;if(V===n)return;V=n;let r=B;n===`out`?(t.style.opacity=u,r&&(r.innerHTML=f)):(t.style.opacity=`1`,r&&(r.innerHTML=d))},K=()=>{z&&z.parentNode&&z.parentNode.removeChild(z),z=null,B=null,V=null},q=(e,n)=>{let r=S?.scrollContainerRef.current??null;!r||n&&e===null||r.querySelectorAll(n?`.ssg-body-row[data-row-index="${e}"]`:`.ssg-body-row[${g}]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(g,R()?`live`:``):e.removeAttribute(g))})},J=()=>{let e=S?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e)){let e=v.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},ee=t=>{let n=F,r=C;if(!n||r===null||S===null)return;let i=S.scrollContainerRef.current;if(!i)return;for(let e of y(i)){if(n.has(e))continue;let t=v.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=S.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-I)*S.verticalScaleFactor,s=(O?D.y-O.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{let{index:i,baseY:o}=e;if(!t.isConnected){n.delete(t);return}if(i===r){t.style.transition=`none`,t.style.transform=`translateY(${o+s}px)`,t.style.willChange=`transform`,e.applied=t.style.transform;return}let l=0;c!==null&&(r<i&&i<=c?l=-a:c<=i&&i<r&&(l=a)),t.style.transition=h,t.style.transform=`translateY(${o+l}px)`,e.applied=t.style.transform});let l=L??new Set;L=l;for(let{el:e,index:t}of b(i)){if(l.add(e),t===r){e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,e.style.zIndex=`10`;continue}let n=0;c!==null&&(r<t&&t<=c?n=-a:c<=t&&t<r&&(n=a)),e.style.transition=h,e.style.transform=`translateY(${n}px)`,e.style.zIndex=``}},te=(t,r)=>{if(S===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=S,u=i.current,d=a.current;if(!u||!d)return null;let f=u.getBoundingClientRect();if(t<f.left||t>f.right||r<f.top||r>f.bottom)return null;let p=n.clampClientYBelowHeader(n.clampClientYAboveFooter(r,f.top+u.clientTop+u.clientHeight,S.footerHeight??0),f.top+u.clientTop,S.stickyTopHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=C,v=_!==null&&R()?o.detailHeight(_):0;if(_!==null&&v>0){let t=e.resolveRowDropSlot(h+v,o);t>_+1&&(g=t)}let y=e.resolveRowDropSlotTop(g,o);return{slot:g,top:s+y-l}},Y=()=>{let t=te(D.x,D.y),n=C;if(R()){t&&n!==null&&(e.resolveMoveTargetIndex(n,t.slot)===null?w=null:E(n,t.slot)&&(w=t.slot)),U(),ee(w);return}let r=t!==null&&n!==null&&e.resolveMoveTargetIndex(n,t.slot)!==null&&!E(n,t.slot);if(G(r?null:t),!t||n===null||r||e.resolveMoveTargetIndex(n,t.slot)===null){w=null,U();return}w=t.slot;for(let e of H())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},X=()=>{if(C===null){M=null;return}let e=S?.scrollContainerRef.current??null;if(e&&(k||(!O||n.hasPointerLeftActivationRadius(O,D,6))&&(k=!0),k)){let t=e.getBoundingClientRect(),i=r.resolveElementScale(e,t),a=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight,scale:i}),o=n.resolveAutoScrollAxisDirection(D.y,n.resolveTopAutoScrollStart(a.top,(S?.stickyTopHeight??0)*i.y,24),a.bottom-(S?.footerHeight??0),24),s=n.computeNextScrollPosition(e.scrollTop,o,18,e.scrollHeight-e.clientHeight);s!==e.scrollTop&&e.scrollTo({top:s,behavior:`auto`})}Y(),M=requestAnimationFrame(X)},Z=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,Q=()=>{let e=S?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e))t.set(Z(n,Number(n.getAttribute(`data-row-index`))),n.getBoundingClientRect().top);for(let n of b(e))t.set(n.key,n.el.getBoundingClientRect().top);return t},$=t=>{M!==null&&(cancelAnimationFrame(M),M=null),document.body.style.cursor=``,U(),K();let n=C,r=w,i=P;q(n,!1),C=null,P=null,w=null,O=null,j=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=a!==null&&n!==null&&r!==null&&t&&!E(n,r)?null:a;T=null;let s=t&&n!==null&&o!==null&&S!==null,c=F;F=null;let l=c&&s&&S!==null&&!_(S.scrollContainerRef.current)?Q():null,u=L;if(L=null,u&&(s?u.forEach(x):(u.forEach(e=>{e.isConnected&&(e.style.transition=h,e.style.transform=`translateY(0px)`,e.style.zIndex=``)}),window.setTimeout(()=>{u.forEach(e=>{L?.has(e)||x(e)})},200))),c)if(s)c.forEach(({baseY:e},t)=>{t.style.transition=``,t.style.willChange=``,t.isConnected&&(t.style.transform=`translateY(${e}px)`)});else{let e=[];c.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=h,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}if(!s||n===null||o===null||S===null)return;let d=l??(_(S.scrollContainerRef.current)?null:Q()),f=d?{tops:d,from:n,to:o,row:i}:null;N=f,S.commitRowMove(n,o),f&&requestAnimationFrame(()=>{N===f&&(N=null)})},ne=()=>{let e=N;if(N=null,!e)return;let t=S?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(S?.locateDragRow&&e.row!==null&&S.locateDragRow(e.row,i)!==i)return;let a=e=>e===i?r:r<i&&e>=r&&e<i?e+1:i<r&&e>i&&e<=r?e-1:e,o=[],s=new Map;y(t).forEach(e=>{let t=n.get(Z(e,a(Number(e.getAttribute(`data-row-index`)))));if(t===void 0)return;let r=t-e.getBoundingClientRect().top;if(Math.abs(r)<.5)return;let i=v.exec(e.style.transform);if(!i)return;let c=parseFloat(i[1]);s.set(e,c),e.style.transition=`none`,e.style.transform=`translateY(${c+r}px)`,e.style.willChange=`transform`,o.push(e)});let c=[];if(b(t).forEach(({el:e,index:t,key:r})=>{let i=a(t),o=n.get(r.slice(0,r.lastIndexOf(`|`)+1)+i);if(o===void 0)return;let s=o-e.getBoundingClientRect().top;Math.abs(s)<.5||(e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,c.push(e))}),!(o.length===0&&c.length===0)){t.getBoundingClientRect();for(let e of o)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateY(${s.get(e)??0}px)`;for(let e of c)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateY(0px)`;window.setTimeout(()=>{for(let e of o)e.style.transition=``,e.style.willChange=``;for(let e of c)L?.has(e)||x(e)},280)}},re=(e,t)=>{if(S===null||!S.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),S.gridRootRef?.current?.focus({preventScroll:!0}),C!==null){if(t.pointerId!==j)return;A?.(),$(!1)}C=e,P=S.getDragRow?.(e)??null,j=t.pointerId,w=null,D={x:t.clientX,y:t.clientY},O={x:t.clientX,y:t.clientY},k=!1,document.body.style.cursor=`grabbing`,R()?(F=J(),I=S.scrollContainerRef.current?.scrollTop??0):W(S.getRowDragLabel(e)),q(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&(D={x:e.clientX,y:e.clientY},Y())},o=i.beginEscapeCancelableDrag(),s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,l),window.removeEventListener(`keydown`,u,!0),window.removeEventListener(`blur`,d),o(),A=null;try{n.releasePointerCapture(r)}catch{}};function c(e){e.pointerId===r&&(s(),$(!0))}function l(e){e.pointerId===r&&(s(),$(!1))}function u(e){e.key===`Escape`&&(s(),$(!1))}function d(){s(),$(!1)}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,l),window.addEventListener(`keydown`,u,!0),window.addEventListener(`blur`,d),A=s,Y(),M=requestAnimationFrame(X)},ie=e=>{if(C===null||P==null||S?.locateDragRow===void 0)return;let t=S.locateDragRow(P,C);if(F&&F.forEach((e,t)=>{if(!t.isConnected){F?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`));if(n===e.index&&(e.applied===void 0||t.style.transform===e.applied))return;let r=v.exec(t.style.transform);if(!r){F?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){A?.(),$(!1);return}F&&t!==C&&O!==null&&e!==null&&(O={x:O.x,y:O.y+S.rowMetrics.rowTop(t)-e.rowTop(C)}),t!==C&&(q(null,!1),C=t,q(t,!0)),Y()};return{update:e=>{let t=S;S=e,t?.canDropAt!==e.canDropAt&&(T=null),C!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&ie(t.rowMetrics)},onRowDragHandlePointerDown:re,applyReorderSettle:ne,dispose:()=>{A?.(),A=null,M!==null&&(cancelAnimationFrame(M),M=null),document.body.style.cursor=``,K(),q(C,!1),C=null,P=null,w=null,T=null,F=null,L?.forEach(x),L=null,N=null}}};exports.createRowDragController=S;
|
|
@@ -23,6 +23,7 @@ export type RowDragArgs = {
|
|
|
23
23
|
getDragRow?: (viewIndex: number) => unknown;
|
|
24
24
|
locateDragRow?: (dragRow: unknown, hint: number) => number | null;
|
|
25
25
|
gridRootRef?: ReadonlyRef<HTMLElement | null>;
|
|
26
|
+
canDropAt?: (fromIndex: number, slot: number) => boolean;
|
|
26
27
|
};
|
|
27
28
|
export type RowDragHandlePointerEvent = {
|
|
28
29
|
button: number;
|