@ishibashi0112/spreadsheet-grid-core 1.1.0 → 1.2.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.
- 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 +1 -0
- package/dist/controllers/clipboardController.js +58 -49
- 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/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.js +43 -43
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.js +64 -64
- 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/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 +2 -0
- package/dist/engine/gridApi.js +193 -183
- 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/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/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 +4 -1
- package/dist/logic/selectEditorState.js +14 -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/gridVisibleBand.cjs +1 -0
- package/dist/utils/gridVisibleBand.d.ts +4 -0
- package/dist/utils/gridVisibleBand.js +24 -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,6 +1,6 @@
|
|
|
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
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
6
|
import { resolveElementScale as f } from "../logic/elementScale.js";
|
|
@@ -40,37 +40,37 @@ var m = 10, h = 300, g = () => {
|
|
|
40
40
|
row: C,
|
|
41
41
|
col: r(w, 0, l - 1)
|
|
42
42
|
};
|
|
43
|
-
}, O = (
|
|
43
|
+
}, O = (t, n) => {
|
|
44
44
|
let r = w();
|
|
45
45
|
if (m === null || !r || r.type !== "selection") return;
|
|
46
|
-
let i = D(
|
|
46
|
+
let i = D(t, n);
|
|
47
47
|
if (i) {
|
|
48
48
|
if (r.selectionKind === "cell") {
|
|
49
|
-
m.dispatch(
|
|
49
|
+
m.dispatch(e.updateSelection(i));
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
if (r.selectionKind === "row") {
|
|
53
|
-
m.dispatch(
|
|
53
|
+
m.dispatch(e.updateRowSelection(i.row));
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
r.selectionKind === "col" && m.dispatch(
|
|
56
|
+
r.selectionKind === "col" && m.dispatch(e.updateColumnSelection(i.col));
|
|
57
57
|
}
|
|
58
|
-
}, k = (
|
|
59
|
-
let r =
|
|
58
|
+
}, k = (t, n) => {
|
|
59
|
+
let r = n.timeStamp;
|
|
60
60
|
if (m === null) return;
|
|
61
61
|
let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l, resolveFirstDataCell: u } = m;
|
|
62
62
|
i.current?.focus({ preventScroll: !0 });
|
|
63
|
-
let { target: d } =
|
|
63
|
+
let { target: d } = t;
|
|
64
64
|
if (d.kind === "cell") {
|
|
65
|
-
let
|
|
66
|
-
if (
|
|
67
|
-
v = null, l.current(d.cell,
|
|
65
|
+
let t = v;
|
|
66
|
+
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
68
|
return;
|
|
69
69
|
}
|
|
70
70
|
v = {
|
|
71
71
|
cell: d.cell,
|
|
72
72
|
time: r
|
|
73
|
-
}, a(
|
|
73
|
+
}, a(e.activateCell(d.cell)), o && (a(e.startSelection(d.cell)), a(e.endSelection()));
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
if (v = null, d.kind === "row") {
|
|
@@ -78,26 +78,26 @@ var m = 10, h = 300, g = () => {
|
|
|
78
78
|
c(d.rowIndex, { shiftKey: !1 });
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
a(
|
|
81
|
+
a(e.startRowSelection(d.rowIndex, u?.().col)), a(e.endSelection());
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
a(
|
|
84
|
+
a(e.startColumnSelection(d.colIndex, u?.().row)), a(e.endSelection());
|
|
85
85
|
}, A = () => {
|
|
86
|
-
m !== null && (g = !1, m.dispatch(
|
|
87
|
-
}, j = (
|
|
86
|
+
m !== null && (g = !1, m.dispatch(e.endSelection()), m.dispatch(e.endColumnResize()));
|
|
87
|
+
}, j = (t) => {
|
|
88
88
|
if (m === null) return;
|
|
89
89
|
m.pointerClientRef.current = {
|
|
90
|
-
x:
|
|
91
|
-
y:
|
|
90
|
+
x: t.clientX,
|
|
91
|
+
y: t.clientY
|
|
92
92
|
};
|
|
93
|
-
let
|
|
94
|
-
if (
|
|
95
|
-
(T === null || T.drag !==
|
|
96
|
-
drag:
|
|
93
|
+
let n = w();
|
|
94
|
+
if (n?.type === "columnResize") {
|
|
95
|
+
(T === null || T.drag !== n) && (T = {
|
|
96
|
+
drag: n,
|
|
97
97
|
x: f(m.scrollContainerRef.current).x
|
|
98
98
|
});
|
|
99
|
-
let r = T.x === 1 ?
|
|
100
|
-
m.dispatch(
|
|
99
|
+
let r = T.x === 1 ? t.clientX : n.startX + (t.clientX - n.startX) / T.x;
|
|
100
|
+
m.dispatch(e.updateColumnResize(r));
|
|
101
101
|
}
|
|
102
102
|
}, M = (e) => {
|
|
103
103
|
let t = _;
|
|
@@ -201,68 +201,68 @@ var m = 10, h = 300, g = () => {
|
|
|
201
201
|
},
|
|
202
202
|
getCellCoordFromClientPoint: D,
|
|
203
203
|
updateSelectionFromPointer: O,
|
|
204
|
-
handleCellPointerDown: (
|
|
205
|
-
if (!(!B(
|
|
204
|
+
handleCellPointerDown: (t, n) => {
|
|
205
|
+
if (!(!B(n, {
|
|
206
206
|
kind: "cell",
|
|
207
|
-
cell:
|
|
207
|
+
cell: t
|
|
208
208
|
}) || m === null)) {
|
|
209
|
-
if (
|
|
210
|
-
let { selection:
|
|
209
|
+
if (n.shiftKey && m.enableRangeSelection) {
|
|
210
|
+
let { selection: n, activeCell: r } = m.uiState, i = n?.type === "cell" ? n.range.start : r;
|
|
211
211
|
if (i) {
|
|
212
|
-
m.dispatch(
|
|
212
|
+
m.dispatch(e.startSelection(i)), m.dispatch(e.updateSelection(t));
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
m.dispatch(
|
|
216
|
+
m.dispatch(e.activateCell(t)), m.enableRangeSelection && m.dispatch(e.startSelection(t));
|
|
217
217
|
}
|
|
218
218
|
},
|
|
219
219
|
handleCellDoubleClick: (e, t) => {
|
|
220
220
|
y === "touch" || m === null || m.onCellDoubleClickRef.current(e, t);
|
|
221
221
|
},
|
|
222
|
-
handleCellPointerEnter: (
|
|
223
|
-
if (m === null || (m.enableRowHover && m.setHoveredRowIndex(
|
|
222
|
+
handleCellPointerEnter: (t, n) => {
|
|
223
|
+
if (m === null || (m.enableRowHover && m.setHoveredRowIndex(t.row), m.enableColumnHover && m.setHoveredColumnIndex(t.col), !m.enableRangeSelection)) return;
|
|
224
224
|
let r = w();
|
|
225
225
|
r?.type !== "selection" || r.selectionKind !== "cell" || (m.pointerClientRef.current = {
|
|
226
|
-
x:
|
|
227
|
-
y:
|
|
228
|
-
}, m.dispatch(
|
|
226
|
+
x: n.clientX,
|
|
227
|
+
y: n.clientY
|
|
228
|
+
}, m.dispatch(e.updateSelection(t)));
|
|
229
229
|
},
|
|
230
230
|
handleNativeDragStart: (e) => {
|
|
231
231
|
e.preventDefault();
|
|
232
232
|
},
|
|
233
|
-
handleRowHeaderPointerDown: (
|
|
234
|
-
if (!(!B(
|
|
233
|
+
handleRowHeaderPointerDown: (t, n) => {
|
|
234
|
+
if (!(!B(n, {
|
|
235
235
|
kind: "row",
|
|
236
|
-
rowIndex:
|
|
236
|
+
rowIndex: t
|
|
237
237
|
}) || m === null)) {
|
|
238
238
|
if (m.enableRowSelection) {
|
|
239
|
-
g = !0, m.onGutterRowSelect(
|
|
239
|
+
g = !0, m.onGutterRowSelect(t, { shiftKey: n.shiftKey }), z();
|
|
240
240
|
return;
|
|
241
241
|
}
|
|
242
|
-
if (
|
|
243
|
-
let { selection:
|
|
242
|
+
if (n.shiftKey) {
|
|
243
|
+
let { selection: n, activeCell: r } = m.uiState, i = n?.type === "row" ? n.startRow : r?.row;
|
|
244
244
|
if (i !== void 0) {
|
|
245
|
-
m.dispatch(
|
|
245
|
+
m.dispatch(e.startRowSelection(i, m.resolveFirstDataCell?.().col)), m.dispatch(e.updateRowSelection(t));
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
m.dispatch(
|
|
249
|
+
m.dispatch(e.startRowSelection(t, m.resolveFirstDataCell?.().col));
|
|
250
250
|
}
|
|
251
251
|
},
|
|
252
|
-
handleRowHeaderPointerEnter: (
|
|
252
|
+
handleRowHeaderPointerEnter: (t, n) => {
|
|
253
253
|
if (m === null) return;
|
|
254
|
-
if (m.enableRowHover && m.setHoveredRowIndex(
|
|
254
|
+
if (m.enableRowHover && m.setHoveredRowIndex(t), g) {
|
|
255
255
|
m.pointerClientRef.current = {
|
|
256
|
-
x:
|
|
257
|
-
y:
|
|
258
|
-
}, m.onGutterRowSelectDrag(
|
|
256
|
+
x: n.clientX,
|
|
257
|
+
y: n.clientY
|
|
258
|
+
}, m.onGutterRowSelectDrag(t);
|
|
259
259
|
return;
|
|
260
260
|
}
|
|
261
261
|
let r = w();
|
|
262
262
|
r?.type !== "selection" || r.selectionKind !== "row" || (m.pointerClientRef.current = {
|
|
263
|
-
x:
|
|
264
|
-
y:
|
|
265
|
-
}, m.dispatch(
|
|
263
|
+
x: n.clientX,
|
|
264
|
+
y: n.clientY
|
|
265
|
+
}, m.dispatch(e.updateRowSelection(t)));
|
|
266
266
|
},
|
|
267
267
|
handleColumnHeaderPointerDown: (r, i) => {
|
|
268
268
|
if (!(!B(i, {
|
|
@@ -271,23 +271,23 @@ var m = 10, h = 300, g = () => {
|
|
|
271
271
|
}) || m === null)) {
|
|
272
272
|
if (i.shiftKey && m.enableSorting) {
|
|
273
273
|
let i = m.orderedColumns[r];
|
|
274
|
-
if (i && !
|
|
275
|
-
let
|
|
276
|
-
m.dispatch(a.length === 0 ?
|
|
274
|
+
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));
|
|
277
277
|
}
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
280
|
-
m.dispatch(
|
|
280
|
+
m.dispatch(e.startColumnSelection(r, m.resolveFirstDataCell?.().row));
|
|
281
281
|
}
|
|
282
282
|
},
|
|
283
|
-
handleColumnHeaderPointerEnter: (
|
|
283
|
+
handleColumnHeaderPointerEnter: (t, n) => {
|
|
284
284
|
if (m === null) return;
|
|
285
|
-
m.setHoveredRowIndex(null), m.enableColumnHeaderHover && m.setHoveredColumnIndex(
|
|
285
|
+
m.setHoveredRowIndex(null), m.enableColumnHeaderHover && m.setHoveredColumnIndex(t);
|
|
286
286
|
let r = w();
|
|
287
287
|
r?.type !== "selection" || r.selectionKind !== "col" || (m.pointerClientRef.current = {
|
|
288
|
-
x:
|
|
289
|
-
y:
|
|
290
|
-
}, m.dispatch(
|
|
288
|
+
x: n.clientX,
|
|
289
|
+
y: n.clientY
|
|
290
|
+
}, m.dispatch(e.updateColumnSelection(t)));
|
|
291
291
|
},
|
|
292
292
|
dispose: () => {
|
|
293
293
|
F(), I(), b !== null && (cancelAnimationFrame(b), b = null);
|
|
@@ -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;
|