@ishibashi0112/spreadsheet-grid-core 1.14.0 → 1.16.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/README.md +2 -2
- package/dist/controllers/clipboardController.cjs +4 -4
- package/dist/controllers/clipboardController.d.ts +5 -0
- package/dist/controllers/clipboardController.js +211 -139
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +3 -0
- package/dist/controllers/editController.js +104 -85
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +5 -4
- package/dist/controllers/findReplaceController.cjs +1 -1
- package/dist/controllers/findReplaceController.d.ts +1 -0
- package/dist/controllers/findReplaceController.js +1 -1
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +1 -0
- package/dist/controllers/historyController.js +8 -2
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +8 -0
- package/dist/controllers/keyboardController.js +115 -57
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +61 -53
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +2 -1
- package/dist/controllers/viewportSyncController.js +4 -4
- package/dist/engine/cellCommands.cjs +1 -1
- package/dist/engine/cellCommands.d.ts +1 -0
- package/dist/engine/cellCommands.js +19 -9
- package/dist/engine/cellSpanController.cjs +2 -0
- package/dist/engine/cellSpanController.d.ts +42 -0
- package/dist/engine/cellSpanController.js +253 -0
- package/dist/engine/createGridEngine.cjs +3 -3
- package/dist/engine/createGridEngine.d.ts +4 -0
- package/dist/engine/createGridEngine.js +35 -28
- package/dist/engine/exportCommands.cjs +2 -2
- package/dist/engine/exportCommands.js +104 -71
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +12 -0
- package/dist/engine/features.js +35 -1
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +31 -27
- package/dist/engine/gridApi.cjs +10 -10
- package/dist/engine/gridApi.d.ts +10 -0
- package/dist/engine/gridApi.js +504 -333
- package/dist/engine/newRowController.cjs +1 -1
- package/dist/engine/newRowController.js +3 -1
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +4 -0
- package/dist/engine/notifiers.js +39 -27
- package/dist/engine/paginationController.cjs +1 -0
- package/dist/engine/paginationController.d.ts +38 -0
- package/dist/engine/paginationController.js +162 -0
- package/dist/engine/rowSelectionCommands.cjs +1 -1
- package/dist/engine/rowSelectionCommands.d.ts +1 -0
- package/dist/engine/rowSelectionCommands.js +10 -10
- package/dist/engine/verticalLayout.cjs +1 -1
- package/dist/engine/verticalLayout.d.ts +1 -0
- package/dist/engine/verticalLayout.js +1 -0
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +9 -0
- package/dist/logic/cellRef.cjs +1 -1
- package/dist/logic/cellRef.js +1 -1
- package/dist/logic/cellSpanLayout.cjs +1 -0
- package/dist/logic/cellSpanLayout.d.ts +48 -0
- package/dist/logic/cellSpanLayout.js +147 -0
- package/dist/logic/cellSpans.cjs +1 -0
- package/dist/logic/cellSpans.d.ts +49 -0
- package/dist/logic/cellSpans.js +301 -0
- package/dist/logic/changeTracking.cjs +1 -1
- package/dist/logic/changeTracking.d.ts +6 -0
- package/dist/logic/changeTracking.js +23 -9
- package/dist/logic/clipboardHtml.cjs +1 -1
- package/dist/logic/clipboardHtml.d.ts +5 -0
- package/dist/logic/clipboardHtml.js +27 -25
- package/dist/logic/contextMenuTarget.cjs +1 -1
- package/dist/logic/contextMenuTarget.js +72 -48
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +2 -1
- package/dist/logic/exportData.js +35 -35
- package/dist/logic/featureWarnings.cjs +1 -1
- package/dist/logic/featureWarnings.js +2 -1
- package/dist/logic/fillHandle.cjs +1 -1
- package/dist/logic/fillHandle.js +21 -21
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +6 -1
- package/dist/logic/gridState.js +6 -6
- package/dist/logic/localeText.cjs +1 -1
- package/dist/logic/localeText.d.ts +1 -0
- package/dist/logic/localeText.js +1 -0
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +10 -0
- package/dist/logic/localeTextFeatures.js +10 -1
- package/dist/logic/pagination.cjs +1 -0
- package/dist/logic/pagination.d.ts +55 -0
- package/dist/logic/pagination.js +192 -0
- package/dist/logic/rowDragTarget.cjs +1 -1
- package/dist/logic/rowDragTarget.d.ts +1 -1
- package/dist/logic/rowDragTarget.js +10 -10
- package/dist/logic/scrollHint.cjs +1 -1
- package/dist/logic/scrollHint.d.ts +2 -1
- package/dist/logic/scrollHint.js +5 -5
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +10 -0
- package/dist/model/gridActions.js +10 -1
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +32 -0
- package/dist/model/gridStore.cjs +1 -1
- package/dist/model/gridStore.d.ts +1 -0
- package/dist/model/gridStore.js +1 -1
- package/dist/model/gridTypes.core.d.ts +189 -11
- package/dist/utils/pagerFocus.cjs +1 -0
- package/dist/utils/pagerFocus.d.ts +1 -0
- package/dist/utils/pagerFocus.js +15 -0
- package/dist/utils/permissions.cjs +1 -1
- package/dist/utils/permissions.d.ts +1 -1
- package/dist/utils/permissions.js +1 -1
- package/package.json +1 -1
|
@@ -40,11 +40,56 @@ var g = 10, _ = (e, t, n, r) => {
|
|
|
40
40
|
return w(n, n, !1), !0;
|
|
41
41
|
}, E = (e) => {
|
|
42
42
|
let t = i === null ? void 0 : p(i);
|
|
43
|
-
|
|
43
|
+
if (e && t?.selection?.type === "cell") {
|
|
44
|
+
let e = t.selection.range.end;
|
|
45
|
+
return i?.cellSpans?.rawEnd?.(e) ?? e;
|
|
46
|
+
}
|
|
47
|
+
return t?.activeCell ?? {
|
|
44
48
|
row: 0,
|
|
45
49
|
col: 0
|
|
46
50
|
};
|
|
47
51
|
}, D = (e, t, n) => {
|
|
52
|
+
let r = i?.cellSpans, a = r?.current();
|
|
53
|
+
if (!r || !a?.active) return e;
|
|
54
|
+
let o = a.getSpan(e.row, e.col);
|
|
55
|
+
if (o === null) return e;
|
|
56
|
+
let s = r.entryFor({
|
|
57
|
+
row: o.top,
|
|
58
|
+
col: o.left
|
|
59
|
+
}) ?? {
|
|
60
|
+
row: o.top,
|
|
61
|
+
col: o.left
|
|
62
|
+
};
|
|
63
|
+
return t > 0 ? {
|
|
64
|
+
row: o.bottom,
|
|
65
|
+
col: s.col
|
|
66
|
+
} : t < 0 ? {
|
|
67
|
+
row: o.top,
|
|
68
|
+
col: s.col
|
|
69
|
+
} : n > 0 ? {
|
|
70
|
+
row: s.row,
|
|
71
|
+
col: o.right
|
|
72
|
+
} : n < 0 ? {
|
|
73
|
+
row: s.row,
|
|
74
|
+
col: o.left
|
|
75
|
+
} : e;
|
|
76
|
+
}, O = (e, t, n) => {
|
|
77
|
+
let r = i?.cellSpans?.current(), a = i === null ? null : p(i);
|
|
78
|
+
if (!r?.active || a?.selection?.type !== "cell") return t;
|
|
79
|
+
let o = (e, t) => r.expandRect({
|
|
80
|
+
top: Math.min(e.row, t.row),
|
|
81
|
+
bottom: Math.max(e.row, t.row),
|
|
82
|
+
left: Math.min(e.col, t.col),
|
|
83
|
+
right: Math.max(e.col, t.col)
|
|
84
|
+
}), s = o(a.selection.range.start, a.selection.range.end), c = t;
|
|
85
|
+
for (;;) {
|
|
86
|
+
let t = o(e, c);
|
|
87
|
+
if (t.top !== s.top || t.bottom !== s.bottom || t.left !== s.left || t.right !== s.right) return c;
|
|
88
|
+
let r = n(c);
|
|
89
|
+
if (r.row === c.row && r.col === c.col) return c;
|
|
90
|
+
c = r;
|
|
91
|
+
}
|
|
92
|
+
}, k = (e, t, n) => {
|
|
48
93
|
if (i === null) return;
|
|
49
94
|
let { rowModel: r, visibleColumns: o } = i, s = r.getRowCount();
|
|
50
95
|
if (s === 0 || o.length === 0 || T()) return;
|
|
@@ -56,28 +101,38 @@ var g = 10, _ = (e, t, n, r) => {
|
|
|
56
101
|
col: c.col
|
|
57
102
|
});
|
|
58
103
|
}
|
|
59
|
-
let l =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
104
|
+
let l = n ? c : D(c, e, t), u = (n) => {
|
|
105
|
+
let i = a(n.row + e, 0, s - 1);
|
|
106
|
+
return i = e === 0 ? S(r, i) : _(r, i, e > 0 ? 1 : -1, n.row), {
|
|
107
|
+
row: i,
|
|
108
|
+
col: a(n.col + t, 0, o.length - 1)
|
|
109
|
+
};
|
|
110
|
+
}, d = u(l);
|
|
111
|
+
if (n) {
|
|
112
|
+
let e = p(i), t = e.selection?.type === "cell" ? i.cellSpans?.rawStart?.(e.selection.range.start) ?? e.selection.range.start : c;
|
|
113
|
+
d = O(t, d, u);
|
|
114
|
+
} else if (d.row === l.row && d.col === l.col && l !== c) return;
|
|
115
|
+
w(c, d, n);
|
|
116
|
+
}, A = (e, t, n) => {
|
|
67
117
|
if (i === null) return;
|
|
68
118
|
let { rowModel: r, visibleColumns: o } = i, s = p(i);
|
|
69
119
|
if (r.getRowCount() === 0 || o.length === 0) return;
|
|
70
120
|
let c = s.activeCell ? E(t) : {
|
|
71
121
|
row: v(r),
|
|
72
122
|
col: y(o)
|
|
73
|
-
}
|
|
123
|
+
};
|
|
124
|
+
if (!t && s.activeCell !== null) {
|
|
125
|
+
let e = i.cellSpans?.entryFor(s.activeCell) ?? null;
|
|
126
|
+
e !== null && (c = e);
|
|
127
|
+
}
|
|
128
|
+
let l = e(c, r, o), u = a(l.col, 0, o.length - 1);
|
|
74
129
|
w(c, {
|
|
75
130
|
row: S(r, a(l.row, 0, r.getRowCount() - 1)),
|
|
76
131
|
col: u
|
|
77
132
|
}, t && s.activeCell !== null);
|
|
78
133
|
let d = n === void 0 ? null : i.scrollContainerRef?.current ?? null, f = o[u]?.pinned;
|
|
79
134
|
d !== null && (n === "start" ? f === "left" : f === "right") && (d.scrollLeft = n === "start" ? 0 : Math.max(d.scrollWidth - d.clientWidth, 0));
|
|
80
|
-
},
|
|
135
|
+
}, j = (e, t, n) => {
|
|
81
136
|
let r = t.getRowCount(), o = i?.resolvePageRow ? i.resolvePageRow(e.row, n) : e.row + n * g, s = a(n > 0 ? Math.max(o, e.row + 1) : Math.min(o, e.row - 1), 0, r - 1), c = _(t, s, n, -1);
|
|
82
137
|
return c >= 0 ? c : _(t, s, n > 0 ? -1 : 1, e.row);
|
|
83
138
|
};
|
|
@@ -85,7 +140,7 @@ var g = 10, _ = (e, t, n, r) => {
|
|
|
85
140
|
update: x,
|
|
86
141
|
handleKeyDown: async (a) => {
|
|
87
142
|
if (i === null) return;
|
|
88
|
-
let { rowModel: g, visibleColumns: _, readOnly: b, canEditCell: x, setEditorInitialValue: S, dispatch: w, handleCopy: E, openFind:
|
|
143
|
+
let { rowModel: g, visibleColumns: _, readOnly: b, canEditCell: x, setEditorInitialValue: S, dispatch: w, handleCopy: E, openFind: O, handleCellDoubleClick: M, selectEntireGrid: N, onUndo: P, onRedo: F, onClearSelection: I, enableClearOnDelete: L, onToggleCheckboxCell: R, onToggleGroup: z, onToggleDetailRow: B } = i, V = p(i), H = i.getUiState ? m(V.selection, l(g), _.length) : i.isWholeGridSelected;
|
|
89
144
|
if (c(a.target) || f(i) || a.isComposing && o(a.target)) return;
|
|
90
145
|
if ((a.ctrlKey || a.metaKey) && a.key.toLowerCase() === "c") {
|
|
91
146
|
a.preventDefault(), await E();
|
|
@@ -95,8 +150,8 @@ var g = 10, _ = (e, t, n, r) => {
|
|
|
95
150
|
a.preventDefault(), await i.handleCut();
|
|
96
151
|
return;
|
|
97
152
|
}
|
|
98
|
-
if ((a.ctrlKey || a.metaKey) && a.key.toLowerCase() === "f" &&
|
|
99
|
-
a.preventDefault(),
|
|
153
|
+
if ((a.ctrlKey || a.metaKey) && a.key.toLowerCase() === "f" && O) {
|
|
154
|
+
a.preventDefault(), O();
|
|
100
155
|
return;
|
|
101
156
|
}
|
|
102
157
|
if (a.ctrlKey && !a.metaKey && !a.altKey && a.key.toLowerCase() === "h" && i.openFindReplace) {
|
|
@@ -104,50 +159,50 @@ var g = 10, _ = (e, t, n, r) => {
|
|
|
104
159
|
return;
|
|
105
160
|
}
|
|
106
161
|
if ((a.ctrlKey || a.metaKey) && a.key.toLowerCase() === "a") {
|
|
107
|
-
if (a.preventDefault(),
|
|
162
|
+
if (a.preventDefault(), H) {
|
|
108
163
|
w(e.clearSelection()), w(e.activateCell(null));
|
|
109
164
|
return;
|
|
110
165
|
}
|
|
111
|
-
|
|
166
|
+
N();
|
|
112
167
|
return;
|
|
113
168
|
}
|
|
114
169
|
if ((a.ctrlKey || a.metaKey) && !a.isComposing) {
|
|
115
170
|
if (a.key.toLowerCase() === "z") {
|
|
116
|
-
a.preventDefault(), a.shiftKey ?
|
|
171
|
+
a.preventDefault(), a.shiftKey ? F() : P();
|
|
117
172
|
return;
|
|
118
173
|
}
|
|
119
174
|
if (a.key.toLowerCase() === "y" && !a.shiftKey) {
|
|
120
|
-
a.preventDefault(),
|
|
175
|
+
a.preventDefault(), F();
|
|
121
176
|
return;
|
|
122
177
|
}
|
|
123
178
|
}
|
|
124
179
|
if (i.onShortcutKeyDown?.(a)) return;
|
|
125
|
-
let
|
|
126
|
-
if ((a.key === "ContextMenu" || a.key === "F10" && a.shiftKey) && !
|
|
180
|
+
let U = a.ctrlKey || a.metaKey;
|
|
181
|
+
if ((a.key === "ContextMenu" || a.key === "F10" && a.shiftKey) && !U && !a.altKey && V.activeCell && i.openContextMenu?.(V.activeCell)) {
|
|
127
182
|
a.preventDefault();
|
|
128
183
|
return;
|
|
129
184
|
}
|
|
130
|
-
if ((a.key === "ArrowDown" || a.key === "ArrowUp") && a.altKey && a.shiftKey && !
|
|
185
|
+
if ((a.key === "ArrowDown" || a.key === "ArrowUp") && a.altKey && a.shiftKey && !U && V.activeCell && i.onToggleTreeRow?.(V.activeCell, a.key === "ArrowDown")) {
|
|
131
186
|
a.preventDefault();
|
|
132
187
|
return;
|
|
133
188
|
}
|
|
134
|
-
if (a.key === "ArrowDown" && a.altKey && !
|
|
189
|
+
if (a.key === "ArrowDown" && a.altKey && !U && !a.shiftKey && V.activeCell && i.openColumnMenu?.(V.activeCell.col)) {
|
|
135
190
|
a.preventDefault();
|
|
136
191
|
return;
|
|
137
192
|
}
|
|
138
|
-
if (
|
|
193
|
+
if (U && !a.altKey && (a.key === "ArrowUp" || a.key === "ArrowDown")) {
|
|
139
194
|
a.preventDefault();
|
|
140
195
|
let e = a.key === "ArrowDown";
|
|
141
|
-
|
|
196
|
+
A((t, n) => ({
|
|
142
197
|
row: e ? C(n) : v(n),
|
|
143
198
|
col: t.col
|
|
144
199
|
}), a.shiftKey);
|
|
145
200
|
return;
|
|
146
201
|
}
|
|
147
|
-
if (
|
|
202
|
+
if (U && !a.altKey && (a.key === "ArrowLeft" || a.key === "ArrowRight")) {
|
|
148
203
|
a.preventDefault();
|
|
149
204
|
let e = a.key === "ArrowRight";
|
|
150
|
-
|
|
205
|
+
A((t, n, r) => ({
|
|
151
206
|
row: t.row,
|
|
152
207
|
col: e ? r.length - 1 : y(r)
|
|
153
208
|
}), a.shiftKey, e ? "end" : "start");
|
|
@@ -156,93 +211,96 @@ var g = 10, _ = (e, t, n, r) => {
|
|
|
156
211
|
if ((a.key === "Home" || a.key === "End") && !a.altKey) {
|
|
157
212
|
a.preventDefault();
|
|
158
213
|
let e = a.key === "End";
|
|
159
|
-
|
|
160
|
-
row:
|
|
214
|
+
A((t, n, r) => ({
|
|
215
|
+
row: U ? e ? C(n) : v(n) : t.row,
|
|
161
216
|
col: e ? r.length - 1 : y(r)
|
|
162
217
|
}), a.shiftKey, e ? "end" : "start");
|
|
163
218
|
return;
|
|
164
219
|
}
|
|
165
|
-
if ((a.key === "PageDown" || a.key === "PageUp") && !
|
|
220
|
+
if ((a.key === "PageDown" || a.key === "PageUp") && !U && !a.altKey) {
|
|
166
221
|
if (a.preventDefault(), T()) return;
|
|
167
222
|
let e = a.key === "PageDown" ? 1 : -1;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
223
|
+
A((t, n) => {
|
|
224
|
+
let r = a.shiftKey ? t : D(t, e, 0);
|
|
225
|
+
return {
|
|
226
|
+
row: j(r, n, e),
|
|
227
|
+
col: r.col
|
|
228
|
+
};
|
|
229
|
+
}, a.shiftKey);
|
|
172
230
|
return;
|
|
173
231
|
}
|
|
174
232
|
if (a.key === "ArrowUp") {
|
|
175
|
-
a.preventDefault(),
|
|
233
|
+
a.preventDefault(), k(-1, 0, a.shiftKey);
|
|
176
234
|
return;
|
|
177
235
|
}
|
|
178
236
|
if (a.key === "ArrowDown") {
|
|
179
|
-
a.preventDefault(),
|
|
237
|
+
a.preventDefault(), k(1, 0, a.shiftKey);
|
|
180
238
|
return;
|
|
181
239
|
}
|
|
182
240
|
if (a.key === "ArrowLeft") {
|
|
183
|
-
a.preventDefault(),
|
|
241
|
+
a.preventDefault(), k(0, -1, a.shiftKey);
|
|
184
242
|
return;
|
|
185
243
|
}
|
|
186
244
|
if (a.key === "ArrowRight") {
|
|
187
|
-
a.preventDefault(),
|
|
245
|
+
a.preventDefault(), k(0, 1, a.shiftKey);
|
|
188
246
|
return;
|
|
189
247
|
}
|
|
190
248
|
if (a.key === "Tab") {
|
|
191
|
-
if (!
|
|
249
|
+
if (!V.activeCell && !a.shiftKey) {
|
|
192
250
|
if (i.rowModel.getRowCount() === 0 || i.visibleColumns.length === 0) return;
|
|
193
251
|
a.preventDefault(), T();
|
|
194
252
|
return;
|
|
195
253
|
}
|
|
196
|
-
let e =
|
|
197
|
-
if (a.shiftKey ?
|
|
198
|
-
!a.shiftKey &&
|
|
254
|
+
let e = V.activeCell ? i.cellSpans?.current().getSpan(V.activeCell.row, V.activeCell.col) ?? null : null, t = e ? a.shiftKey ? e.left : e.right : V.activeCell?.col ?? 0;
|
|
255
|
+
if (a.shiftKey ? t <= y(i.visibleColumns) : t >= i.visibleColumns.length - 1) {
|
|
256
|
+
!a.shiftKey && V.activeCell && (i.onTabPastLastColumn?.(V.activeCell.row) || i.onTabPastNewRowDraft?.(V.activeCell, d(i.visibleColumns, i.readOnly))) && a.preventDefault();
|
|
199
257
|
return;
|
|
200
258
|
}
|
|
201
|
-
a.preventDefault(),
|
|
259
|
+
a.preventDefault(), k(0, a.shiftKey ? -1 : 1, !1);
|
|
202
260
|
return;
|
|
203
261
|
}
|
|
204
262
|
if (a.key === "Escape") {
|
|
205
|
-
if (
|
|
263
|
+
if (V.activeCell && i.onEscapeNewRow?.(V.activeCell)) {
|
|
206
264
|
a.preventDefault();
|
|
207
265
|
return;
|
|
208
266
|
}
|
|
209
|
-
h(
|
|
267
|
+
h(V.selection) && a.preventDefault(), w(e.clearSelection());
|
|
210
268
|
return;
|
|
211
269
|
}
|
|
212
|
-
if ((a.key === "Delete" || a.key === "Backspace") &&
|
|
213
|
-
a.preventDefault(),
|
|
270
|
+
if ((a.key === "Delete" || a.key === "Backspace") && L) {
|
|
271
|
+
a.preventDefault(), I();
|
|
214
272
|
return;
|
|
215
273
|
}
|
|
216
|
-
if ((a.key === "Enter" || a.key === " ") &&
|
|
217
|
-
let e = g.getGroupRow?.(
|
|
274
|
+
if ((a.key === "Enter" || a.key === " ") && V.activeCell) {
|
|
275
|
+
let e = g.getGroupRow?.(V.activeCell.row);
|
|
218
276
|
if (e) {
|
|
219
|
-
a.preventDefault(),
|
|
277
|
+
a.preventDefault(), z(e.groupKey);
|
|
220
278
|
return;
|
|
221
279
|
}
|
|
222
|
-
if (
|
|
280
|
+
if (B && _[V.activeCell.col]?.key === "__ssg_detail_toggle__" && B(V.activeCell)) {
|
|
223
281
|
a.preventDefault();
|
|
224
282
|
return;
|
|
225
283
|
}
|
|
226
284
|
}
|
|
227
285
|
if (a.key === "Enter" || a.key === "F2") {
|
|
228
|
-
if (a.preventDefault(),
|
|
229
|
-
|
|
286
|
+
if (a.preventDefault(), V.activeCell) {
|
|
287
|
+
M(V.activeCell);
|
|
230
288
|
return;
|
|
231
289
|
}
|
|
232
290
|
a.key === "Enter" && T();
|
|
233
291
|
return;
|
|
234
292
|
}
|
|
235
|
-
if (a.key === " " && !a.ctrlKey && !a.metaKey && !a.altKey && a.preventDefault(), s(a) &&
|
|
236
|
-
let i = _[
|
|
293
|
+
if (a.key === " " && !a.ctrlKey && !a.metaKey && !a.altKey && a.preventDefault(), s(a) && V.activeCell) {
|
|
294
|
+
let i = _[V.activeCell.col], o = u(g, V.activeCell.row, i !== void 0 && t(b, i));
|
|
237
295
|
if (!o || !i || !n({
|
|
238
296
|
readOnly: b,
|
|
239
297
|
canEditCell: x
|
|
240
|
-
}, g,
|
|
298
|
+
}, g, V.activeCell.row, V.activeCell.col, o, i)) return;
|
|
241
299
|
if (r(i, o)?.type === "checkbox") {
|
|
242
|
-
a.preventDefault(), a.key === " " &&
|
|
300
|
+
a.preventDefault(), a.key === " " && R(V.activeCell);
|
|
243
301
|
return;
|
|
244
302
|
}
|
|
245
|
-
a.preventDefault(), S(a.key), w(e.startEdit(
|
|
303
|
+
a.preventDefault(), S(a.key), w(e.startEdit(V.activeCell));
|
|
246
304
|
}
|
|
247
305
|
}
|
|
248
306
|
};
|
|
@@ -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=`data-row-key`,C=(e,t)=>{let n=e.getAttribute(S);if(n===t.key)return!0;let r=v.exec(e.style.transform);return r?(t.index=Number(e.getAttribute(`data-row-index`)),t.baseY=parseFloat(r[1]),t.key=n,t.applied=void 0,!0):!1},w=e=>{let t=v.exec(e.style.transform);return t?{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1]),key:e.getAttribute(S)}:null},T=()=>{let T=null,E=null,D=null,O=null,k=(e,t)=>{let n=T?.canDropAt;if(!n)return!0;if(O!==null&&O.from===e&&O.slot===t)return O.allowed;let r=n(e,t);return O={from:e,slot:t,allowed:r},r},A={x:0,y:0},j=null,M=!1,N=null,P=null,F=null,I=null,L=null,R=null,z=0,B=null,V=()=>T?.motion===`live`,H=null,U=null,W=null,G=()=>[T?.leftIndicatorRef.current??null,T?.centerIndicatorRef.current??null,T?.rightIndicatorRef.current??null],K=()=>{for(let e of G())e&&(e.style.display=`none`)},ee=e=>{if(H)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),T?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),T?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),T?.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,T?.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(T?.scrollContainerRef.current)),o.syncPortalTokens(T?.scrollContainerRef.current,t),H=t,U=n,W=null},te=e=>{let t=H;if(!t)return;t.style.transform=`translate(`+(A.x+c)+`px,`+(A.y+l)+`px)`;let n=e?`move`:`out`;if(W===n)return;W=n;let r=U;n===`out`?(t.style.opacity=u,r&&(r.innerHTML=f)):(t.style.opacity=`1`,r&&(r.innerHTML=d))},q=()=>{H&&H.parentNode&&H.parentNode.removeChild(H),H=null,U=null,W=null},J=(e,n)=>{let r=T?.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,V()?`live`:``):e.removeAttribute(g))})},ne=()=>{let e=T?.scrollContainerRef.current??null;if(!e||E===null)return;let n=String(E),r=V()?`live`:``;e.querySelectorAll(`.ssg-body-row[${g}]`).forEach(r=>{r.getAttribute(`data-row-index`)!==n&&!t.isInsideDetailCardOf(e,r)&&r.removeAttribute(g)}),e.querySelectorAll(`.ssg-body-row[data-row-index="${n}"]`).forEach(n=>{n.getAttribute(g)!==r&&!t.isInsideDetailCardOf(e,n)&&n.setAttribute(g,r)})},re=()=>{let e=T?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e)){let e=w(n);e&&t.set(n,e)}return t},ie=t=>{let n=R,r=E;if(!n||r===null||T===null)return;let i=T.scrollContainerRef.current;if(!i)return;for(let e of y(i)){if(n.has(e))continue;let t=w(e);t&&n.set(e,t)}let a=T.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-z)*T.verticalScaleFactor,s=(j?A.y-j.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{if(!t.isConnected||!C(t,e)){n.delete(t);return}let{index:i,baseY:o}=e;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=B??new Set;B=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=``}},ae=(t,r)=>{if(T===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=T,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,T.footerHeight??0),f.top+u.clientTop,T.stickyTopHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=E,v=_!==null&&V()?o.detailHeight(_):0;if(_!==null&&v>0){let t=e.resolveRowDropSlot(h+v,o);t>_+1&&(g=t)}T.maxDropSlot!==void 0&&g>T.maxDropSlot&&(g=T.maxDropSlot);let y=e.resolveRowDropSlotTop(g,o);return{slot:g,top:s+y-l}},Y=()=>{let t=ae(A.x,A.y),n=E;if(V()){t&&n!==null&&(e.resolveMoveTargetIndex(n,t.slot)===null?D=null:k(n,t.slot)&&(D=t.slot)),K(),ie(D);return}let r=t!==null&&n!==null&&e.resolveMoveTargetIndex(n,t.slot)!==null&&!k(n,t.slot);if(te(r?null:t),!t||n===null||r||e.resolveMoveTargetIndex(n,t.slot)===null){D=null,K();return}D=t.slot;for(let e of G())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},X=()=>{if(E===null){F=null;return}let e=T?.scrollContainerRef.current??null;if(e&&(M||(!j||n.hasPointerLeftActivationRadius(j,A,6))&&(M=!0),M)){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(A.y,n.resolveTopAutoScrollStart(a.top,(T?.stickyTopHeight??0)*i.y,24),a.bottom-(T?.footerHeight??0),24),s=n.computeNextScrollPosition(e.scrollTop,o,18,e.scrollHeight-e.clientHeight);s!==e.scrollTop&&e.scrollTo({top:s,behavior:`auto`})}ne(),Y(),F=requestAnimationFrame(X)},Z=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,Q=()=>{let e=T?.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=>{F!==null&&(cancelAnimationFrame(F),F=null),document.body.style.cursor=``,K(),q();let n=E,r=D,i=L;J(n,!1),E=null,L=null,D=null,j=null,P=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=a!==null&&n!==null&&r!==null&&t&&!k(n,r)?null:a;O=null;let s=t&&n!==null&&o!==null&&T!==null,c=R;R=null,c?.forEach((e,t)=>{t.isConnected&&!C(t,e)&&c.delete(t)});let l=c&&s&&T!==null&&!_(T.scrollContainerRef.current)?Q():null,u=B;if(B=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=>{B?.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||T===null)return;let d=l??(_(T.scrollContainerRef.current)?null:Q()),f=d?{tops:d,from:n,to:o,row:i}:null;I=f,T.commitRowMove(n,o),f&&requestAnimationFrame(()=>{I===f&&(I=null)})},oe=()=>{let e=I;if(I=null,!e)return;let t=T?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(T?.locateDragRow&&e.row!==null&&T.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)B?.has(e)||x(e)},280)}},se=(e,t)=>{if(T===null||!T.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),T.gridRootRef?.current?.focus({preventScroll:!0}),T.endEditLeftOpen?.(),E!==null){if(t.pointerId!==P)return;N?.(),$(!1)}E=e,L=T.getDragRow?.(e)??null,P=t.pointerId,D=null,A={x:t.clientX,y:t.clientY},j={x:t.clientX,y:t.clientY},M=!1,document.body.style.cursor=`grabbing`,V()?(R=re(),z=T.scrollContainerRef.current?.scrollTop??0):ee(T.getRowDragLabel(e)),J(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&(A={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(),N=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),N=s,Y(),F=requestAnimationFrame(X)},ce=e=>{if(E===null||L==null||T?.locateDragRow===void 0)return;let t=T.locateDragRow(L,E);if(R&&R.forEach((e,t)=>{if(!t.isConnected){R?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`)),r=t.getAttribute(S);if(n===e.index&&r===e.key&&(e.applied===void 0||t.style.transform===e.applied))return;let i=v.exec(t.style.transform);if(!i){R?.delete(t);return}e.index=n,e.baseY=parseFloat(i[1]),e.key=r,e.applied=void 0}),t===null){N?.(),$(!1);return}R&&t!==E&&j!==null&&e!==null&&(j={x:j.x,y:j.y+T.rowMetrics.rowTop(t)-e.rowTop(E)}),t!==E&&(J(null,!1),E=t,J(t,!0)),Y()};return{update:e=>{let t=T;T=e,t?.canDropAt!==e.canDropAt&&(O=null),E!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&ce(t.rowMetrics)},onRowDragHandlePointerDown:se,applyReorderSettle:oe,dispose:()=>{N?.(),N=null,F!==null&&(cancelAnimationFrame(F),F=null),document.body.style.cursor=``,q(),J(E,!1),E=null,L=null,D=null,O=null,R=null,B?.forEach(x),B=null,I=null}}};exports.createRowDragController=T;
|
|
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=`data-row-key`,C=(e,t)=>{let n=e.getAttribute(S);if(n===t.key)return!0;let r=v.exec(e.style.transform);return r?(t.index=Number(e.getAttribute(`data-row-index`)),t.baseY=parseFloat(r[1]),t.key=n,t.applied=void 0,!0):!1},w=e=>{let t=v.exec(e.style.transform);return t?{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1]),key:e.getAttribute(S)}:null},T=()=>{let T=null,E=null,D=null,O=null,k=(e,t)=>{let n=T?.canDropAt;if(!n)return!0;if(O!==null&&O.from===e&&O.slot===t)return O.allowed;let r=n(e,t);return O={from:e,slot:t,allowed:r},r},A={x:0,y:0},j=null,M=!1,N=null,P=null,F=null,I=null,L=null,R=0,z=null,B=0,V=null,H=()=>T?.motion===`live`,U=null,W=null,G=null,K=()=>[T?.leftIndicatorRef.current??null,T?.centerIndicatorRef.current??null,T?.rightIndicatorRef.current??null],q=()=>{for(let e of K())e&&(e.style.display=`none`)},ee=e=>{if(U)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),T?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),T?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),T?.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,T?.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(T?.scrollContainerRef.current)),o.syncPortalTokens(T?.scrollContainerRef.current,t),U=t,W=n,G=null},te=e=>{let t=U;if(!t)return;t.style.transform=`translate(`+(A.x+c)+`px,`+(A.y+l)+`px)`;let n=e?`move`:`out`;if(G===n)return;G=n;let r=W;n===`out`?(t.style.opacity=u,r&&(r.innerHTML=f)):(t.style.opacity=`1`,r&&(r.innerHTML=d))},J=()=>{U&&U.parentNode&&U.parentNode.removeChild(U),U=null,W=null,G=null},Y=(e,n)=>{let r=T?.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,H()?`live`:``):e.removeAttribute(g))})},ne=()=>{let e=T?.scrollContainerRef.current??null;if(!e||E===null)return;let n=String(E),r=H()?`live`:``;e.querySelectorAll(`.ssg-body-row[${g}]`).forEach(r=>{r.getAttribute(`data-row-index`)!==n&&!t.isInsideDetailCardOf(e,r)&&r.removeAttribute(g)}),e.querySelectorAll(`.ssg-body-row[data-row-index="${n}"]`).forEach(n=>{n.getAttribute(g)!==r&&!t.isInsideDetailCardOf(e,n)&&n.setAttribute(g,r)})},re=()=>{let e=T?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e)){let e=w(n);e&&t.set(n,e)}return t},ie=t=>{let n=z,r=E;if(!n||r===null||T===null)return;let i=T.scrollContainerRef.current;if(!i)return;for(let e of y(i)){if(n.has(e))continue;let t=w(e);t&&n.set(e,t)}let a=T.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-B)*T.verticalScaleFactor,s=(j?A.y-j.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{if(!t.isConnected||!C(t,e)){n.delete(t);return}let{index:i,baseY:o}=e;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=V??new Set;V=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=``}},ae=(t,r)=>{if(T===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=T,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,T.footerHeight??0),f.top+u.clientTop,T.stickyTopHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=E,v=_!==null&&H()?o.detailHeight(_):0;if(_!==null&&v>0){let t=e.resolveRowDropSlot(h+v,o);t>_+1&&(g=t)}T.maxDropSlot!==void 0&&g>T.maxDropSlot&&(g=T.maxDropSlot);let y=e.resolveRowDropSlotTop(g,o);return{slot:g,top:s+y-l}},X=()=>{let t=ae(A.x,A.y),n=E;if(H()){t&&n!==null&&(e.resolveMoveTargetIndex(n,t.slot)===null?D=null:k(n,t.slot)&&(D=t.slot)),q(),ie(D);return}let r=t!==null&&n!==null&&e.resolveMoveTargetIndex(n,t.slot)!==null&&!k(n,t.slot);if(te(r?null:t),!t||n===null||r||e.resolveMoveTargetIndex(n,t.slot)===null){D=null,q();return}D=t.slot;for(let e of K())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},Z=()=>{if(E===null){F=null;return}let e=T?.scrollContainerRef.current??null;if(e&&(M||(!j||n.hasPointerLeftActivationRadius(j,A,6))&&(M=!0),M)){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(A.y,n.resolveTopAutoScrollStart(a.top,(T?.stickyTopHeight??0)*i.y,24),a.bottom-(T?.footerHeight??0),24),s=n.computeNextScrollPosition(e.scrollTop,o,18,e.scrollHeight-e.clientHeight);s!==e.scrollTop&&e.scrollTo({top:s,behavior:`auto`})}ne(),X(),F=requestAnimationFrame(Z)},Q=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,oe=()=>{let e=T?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e))t.set(Q(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=>{F!==null&&(cancelAnimationFrame(F),F=null),document.body.style.cursor=``,q(),J();let n=E,r=D,i=L;Y(n,!1),E=null,L=null,D=null,j=null,P=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=a!==null&&n!==null&&r!==null&&t&&!k(n,r)?null:a;O=null;let s=t&&n!==null&&o!==null&&T!==null,c=z;z=null,c?.forEach((e,t)=>{t.isConnected&&!C(t,e)&&c.delete(t)});let l=c&&s&&T!==null&&!_(T.scrollContainerRef.current)?oe():null,u=V;if(V=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=>{V?.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)}let d=R,f=()=>{d===R&&E===null&&T?.onDraggingChange?.(!1)};if(!s||n===null||o===null||T===null){f();return}window.setTimeout(f,_(T.scrollContainerRef.current)?0:200);let p=l??(_(T.scrollContainerRef.current)?null:oe()),m=p?{tops:p,from:n,to:o,row:i}:null;I=m,T.commitRowMove(n,o),m&&requestAnimationFrame(()=>{I===m&&(I=null)})},se=()=>{let e=I;if(I=null,!e)return;let t=T?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(T?.locateDragRow&&e.row!==null&&T.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(Q(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)V?.has(e)||x(e)},280)}},ce=(e,t)=>{if(T===null||!T.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),T.gridRootRef?.current?.focus({preventScroll:!0}),T.endEditLeftOpen?.(),E!==null){if(t.pointerId!==P)return;N?.(),$(!1)}if(R+=1,T.onDraggingChange?.(!0),T===null)return;E=e,L=T.getDragRow?.(e)??null,P=t.pointerId,D=null,A={x:t.clientX,y:t.clientY},j={x:t.clientX,y:t.clientY},M=!1,document.body.style.cursor=`grabbing`,H()?(z=re(),B=T.scrollContainerRef.current?.scrollTop??0):ee(T.getRowDragLabel(e)),Y(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&(A={x:e.clientX,y:e.clientY},X())},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(),N=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),N=s,X(),F=requestAnimationFrame(Z)},le=e=>{if(E===null||L==null||T?.locateDragRow===void 0)return;let t=T.locateDragRow(L,E);if(z&&z.forEach((e,t)=>{if(!t.isConnected){z?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`)),r=t.getAttribute(S);if(n===e.index&&r===e.key&&(e.applied===void 0||t.style.transform===e.applied))return;let i=v.exec(t.style.transform);if(!i){z?.delete(t);return}e.index=n,e.baseY=parseFloat(i[1]),e.key=r,e.applied=void 0}),t===null){N?.(),$(!1);return}z&&t!==E&&j!==null&&e!==null&&(j={x:j.x,y:j.y+T.rowMetrics.rowTop(t)-e.rowTop(E)}),t!==E&&(Y(null,!1),E=t,Y(t,!0)),X()};return{update:e=>{let t=T;T=e,t?.canDropAt!==e.canDropAt&&(O=null),E!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&le(t.rowMetrics)},onRowDragHandlePointerDown:ce,applyReorderSettle:se,dispose:()=>{N?.(),N=null,F!==null&&(cancelAnimationFrame(F),F=null),document.body.style.cursor=``,J(),Y(E,!1),E=null,L=null,D=null,O=null,z=null,V?.forEach(x),V=null,I=null}}};exports.createRowDragController=T;
|
|
@@ -26,6 +26,7 @@ export type RowDragArgs = {
|
|
|
26
26
|
endEditLeftOpen?: (() => void) | undefined;
|
|
27
27
|
canDropAt?: (fromIndex: number, slot: number) => boolean;
|
|
28
28
|
maxDropSlot?: number | undefined;
|
|
29
|
+
onDraggingChange?: ((dragging: boolean) => void) | undefined;
|
|
29
30
|
};
|
|
30
31
|
export type RowDragHandlePointerEvent = {
|
|
31
32
|
button: number;
|