@ishibashi0112/spreadsheet-grid-core 1.8.0 → 1.10.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 -1
- package/dist/controllers/activeRowFollowController.d.ts +1 -0
- package/dist/controllers/activeRowFollowController.js +33 -24
- package/dist/controllers/changeTracker.cjs +1 -1
- package/dist/controllers/changeTracker.d.ts +6 -0
- package/dist/controllers/changeTracker.js +338 -160
- package/dist/controllers/clipboardController.cjs +2 -1
- package/dist/controllers/clipboardController.d.ts +5 -1
- package/dist/controllers/clipboardController.js +217 -91
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +3 -1
- package/dist/controllers/columnAutosizeRunner.js +12 -11
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +231 -159
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +114 -113
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +3 -1
- package/dist/controllers/findController.js +80 -75
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +25 -1
- package/dist/controllers/historyController.js +115 -64
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +5 -0
- package/dist/controllers/keyboardController.js +154 -140
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +1 -0
- package/dist/engine/cellCommands.cjs +1 -1
- package/dist/engine/cellCommands.js +81 -62
- package/dist/engine/columnLayout.cjs +1 -1
- package/dist/engine/columnLayout.d.ts +1 -0
- package/dist/engine/columnLayout.js +10 -10
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +6 -1
- package/dist/engine/createGridEngine.js +58 -50
- package/dist/engine/excelShortcutCommands.cjs +1 -0
- package/dist/engine/excelShortcutCommands.d.ts +29 -0
- package/dist/engine/excelShortcutCommands.js +256 -0
- package/dist/engine/exportCommands.cjs +2 -2
- package/dist/engine/exportCommands.js +82 -34
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +21 -0
- package/dist/engine/features.js +23 -2
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +24 -10
- package/dist/engine/gridApi.cjs +10 -9
- package/dist/engine/gridApi.d.ts +21 -2
- package/dist/engine/gridApi.js +239 -101
- package/dist/engine/memo.cjs +1 -1
- package/dist/engine/memo.d.ts +1 -1
- package/dist/engine/memo.js +12 -11
- package/dist/engine/newRowController.cjs +1 -0
- package/dist/engine/newRowController.d.ts +31 -0
- package/dist/engine/newRowController.js +157 -0
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +9 -1
- package/dist/engine/notifiers.js +23 -8
- package/dist/engine/rowPipeline.cjs +1 -1
- package/dist/engine/rowPipeline.d.ts +29 -2
- package/dist/engine/rowPipeline.js +76 -50
- package/dist/engine/treeStage.cjs +1 -0
- package/dist/engine/treeStage.d.ts +46 -0
- package/dist/engine/treeStage.js +171 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +12 -0
- package/dist/logic/cellPlacement.cjs +1 -1
- package/dist/logic/cellPlacement.d.ts +1 -1
- package/dist/logic/cellPlacement.js +1 -1
- package/dist/logic/changeTracking.cjs +1 -1
- package/dist/logic/changeTracking.d.ts +26 -1
- package/dist/logic/changeTracking.js +139 -32
- package/dist/logic/clearCells.cjs +1 -1
- package/dist/logic/clearCells.d.ts +4 -2
- package/dist/logic/clearCells.js +24 -24
- package/dist/logic/columnAutosize.cjs +1 -1
- package/dist/logic/columnAutosize.d.ts +4 -1
- package/dist/logic/columnAutosize.js +89 -72
- package/dist/logic/conditionalFormat.cjs +1 -1
- package/dist/logic/conditionalFormat.js +8 -5
- package/dist/logic/editorKeys.cjs +1 -1
- package/dist/logic/editorKeys.d.ts +9 -1
- package/dist/logic/editorKeys.js +23 -17
- package/dist/logic/excelShortcuts.cjs +1 -0
- package/dist/logic/excelShortcuts.d.ts +13 -0
- package/dist/logic/excelShortcuts.js +36 -0
- package/dist/logic/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +11 -1
- package/dist/logic/exportCsv.js +30 -22
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +3 -2
- package/dist/logic/exportData.js +40 -28
- package/dist/logic/featureWarnings.cjs +1 -1
- package/dist/logic/featureWarnings.js +16 -6
- package/dist/logic/fillHandle.cjs +1 -1
- package/dist/logic/fillHandle.js +1 -1
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.d.ts +1 -1
- package/dist/logic/find.js +11 -9
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +3 -2
- package/dist/logic/gridState.js +6 -6
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +22 -21
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +16 -0
- package/dist/logic/localeTextFeatures.js +22 -8
- package/dist/logic/newRow.cjs +1 -0
- package/dist/logic/newRow.d.ts +9 -0
- package/dist/logic/newRow.js +69 -0
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +3 -2
- package/dist/logic/sorting.cjs +1 -1
- package/dist/logic/sorting.d.ts +1 -1
- package/dist/logic/sorting.js +32 -32
- package/dist/logic/treeData.cjs +7 -0
- package/dist/logic/treeData.d.ts +83 -0
- package/dist/logic/treeData.js +438 -0
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +10 -9
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +15 -0
- package/dist/model/gridActions.js +15 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +175 -156
- package/dist/model/gridStore.cjs +1 -1
- package/dist/model/gridStore.d.ts +17 -1
- package/dist/model/gridStore.js +4 -4
- package/dist/model/gridTypes.core.d.ts +325 -25
- package/dist/model/gridTypes.unbound.d.ts +1 -0
- package/dist/utils/clipboard.cjs +1 -1
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.js +13 -10
- package/dist/utils/permissions.cjs +1 -1
- package/dist/utils/permissions.d.ts +2 -2
- package/dist/utils/permissions.js +1 -1
- package/package.json +1 -1
|
@@ -1,224 +1,238 @@
|
|
|
1
1
|
import { gridActions as e } from "../model/gridActions.js";
|
|
2
|
-
import {
|
|
3
|
-
import { resolveFirstDataColIndex as
|
|
4
|
-
import { clamp as
|
|
5
|
-
import { isImeInputTarget as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { isColumnEditable as t, isViewCellEditable as n } from "../utils/permissions.js";
|
|
3
|
+
import { resolveFirstDataColIndex as r } from "../logic/detailRow.js";
|
|
4
|
+
import { clamp as i } from "../logic/geometry.js";
|
|
5
|
+
import { isImeInputTarget as a, isPrintableKey as o, shouldIgnoreGridKeydown as s } from "../logic/domGuards.js";
|
|
6
|
+
import { getSelectableRowCount as c, resolveEditRow as l, resolveFirstEditableColIndex as u } from "../logic/newRow.js";
|
|
7
|
+
import { isEditingAtEvent as d, readLiveUiState as f } from "./liveUiState.js";
|
|
8
|
+
import { computeIsWholeGridSelected as p } from "./clipboardController.js";
|
|
9
|
+
import { isClearableSelection as m } from "./escapeClaimController.js";
|
|
9
10
|
//#region src/controllers/keyboardController.ts
|
|
10
|
-
var
|
|
11
|
+
var h = 10, g = (e, t, n, r) => {
|
|
11
12
|
if (!e.getLabelRow) return t;
|
|
12
13
|
let i = e.getRowCount(), a = t;
|
|
13
14
|
for (; a >= 0 && a < i && e.getLabelRow(a);) a += n;
|
|
14
15
|
return a >= 0 && a < i ? a : r;
|
|
15
|
-
},
|
|
16
|
-
row:
|
|
17
|
-
col:
|
|
18
|
-
}),
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
let t = e.getRowCount() - 1;
|
|
23
|
-
return
|
|
24
|
-
},
|
|
25
|
-
if (
|
|
26
|
-
let { dispatch: a } =
|
|
16
|
+
}, _ = (e) => g(e, 0, 1, 0), v = (e) => r(e), y = (e, t) => ({
|
|
17
|
+
row: _(e),
|
|
18
|
+
col: v(t)
|
|
19
|
+
}), b = () => {
|
|
20
|
+
let r = null, b = (e) => {
|
|
21
|
+
r = e;
|
|
22
|
+
}, x = (e, t) => g(e, t, -1, g(e, t, 1, t)), S = (e) => {
|
|
23
|
+
let t = c(e), n = (t > 0 ? t : e.getRowCount()) - 1;
|
|
24
|
+
return g(e, n, -1, n);
|
|
25
|
+
}, C = (t, n, i) => {
|
|
26
|
+
if (r === null) return;
|
|
27
|
+
let { dispatch: a } = r, o = f(r);
|
|
27
28
|
if (i) {
|
|
28
|
-
let
|
|
29
|
-
a(e.startSelection(
|
|
29
|
+
let r = o.selection?.type === "cell" ? o.selection.range.start : t;
|
|
30
|
+
a(e.startSelection(r)), a(e.updateSelection(n)), a(e.endSelection()), a(e.activateCell(n));
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
|
-
a(e.startSelection(
|
|
33
|
-
},
|
|
34
|
-
if (
|
|
35
|
-
let { rowModel: e, visibleColumns: t } =
|
|
33
|
+
a(e.startSelection(n)), a(e.endSelection()), a(e.activateCell(n));
|
|
34
|
+
}, w = () => {
|
|
35
|
+
if (r === null || f(r).activeCell) return !1;
|
|
36
|
+
let { rowModel: e, visibleColumns: t } = r;
|
|
36
37
|
if (e.getRowCount() === 0 || t.length === 0) return !0;
|
|
37
|
-
let
|
|
38
|
-
return
|
|
39
|
-
},
|
|
40
|
-
let t =
|
|
38
|
+
let n = y(e, t);
|
|
39
|
+
return C(n, n, !1), !0;
|
|
40
|
+
}, T = (e) => {
|
|
41
|
+
let t = r === null ? void 0 : f(r);
|
|
41
42
|
return e && t?.selection?.type === "cell" ? t.selection.range.end : t?.activeCell ?? {
|
|
42
43
|
row: 0,
|
|
43
44
|
col: 0
|
|
44
45
|
};
|
|
45
|
-
},
|
|
46
|
-
if (
|
|
47
|
-
let { rowModel: a, visibleColumns: o } =
|
|
48
|
-
if (s === 0 || o.length === 0 ||
|
|
49
|
-
let c =
|
|
50
|
-
l = e === 0 ?
|
|
46
|
+
}, E = (e, t, n) => {
|
|
47
|
+
if (r === null) return;
|
|
48
|
+
let { rowModel: a, visibleColumns: o } = r, s = a.getRowCount();
|
|
49
|
+
if (s === 0 || o.length === 0 || w()) return;
|
|
50
|
+
let c = T(n), l = i(c.row + e, 0, s - 1);
|
|
51
|
+
l = e === 0 ? x(a, l) : g(a, l, e > 0 ? 1 : -1, c.row);
|
|
51
52
|
let u = {
|
|
52
53
|
row: l,
|
|
53
|
-
col:
|
|
54
|
+
col: i(c.col + t, 0, o.length - 1)
|
|
54
55
|
};
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
if (
|
|
58
|
-
let { rowModel: a, visibleColumns: o } =
|
|
56
|
+
C(c, u, n);
|
|
57
|
+
}, D = (e, t, n) => {
|
|
58
|
+
if (r === null) return;
|
|
59
|
+
let { rowModel: a, visibleColumns: o } = r, s = f(r);
|
|
59
60
|
if (a.getRowCount() === 0 || o.length === 0) return;
|
|
60
|
-
let
|
|
61
|
-
row:
|
|
62
|
-
col:
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
row:
|
|
66
|
-
col:
|
|
61
|
+
let c = s.activeCell ? T(t) : {
|
|
62
|
+
row: _(a),
|
|
63
|
+
col: v(o)
|
|
64
|
+
}, l = e(c, a, o), u = i(l.col, 0, o.length - 1);
|
|
65
|
+
C(c, {
|
|
66
|
+
row: x(a, i(l.row, 0, a.getRowCount() - 1)),
|
|
67
|
+
col: u
|
|
67
68
|
}, t && s.activeCell !== null);
|
|
68
|
-
let
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
let a = t.getRowCount(), o =
|
|
72
|
-
return c >= 0 ? c :
|
|
69
|
+
let d = n === void 0 ? null : r.scrollContainerRef?.current ?? null, p = o[u]?.pinned;
|
|
70
|
+
d !== null && (n === "start" ? p === "left" : p === "right") && (d.scrollLeft = n === "start" ? 0 : Math.max(d.scrollWidth - d.clientWidth, 0));
|
|
71
|
+
}, O = (e, t, n) => {
|
|
72
|
+
let a = t.getRowCount(), o = r?.resolvePageRow ? r.resolvePageRow(e.row, n) : e.row + n * h, s = i(n > 0 ? Math.max(o, e.row + 1) : Math.min(o, e.row - 1), 0, a - 1), c = g(t, s, n, -1);
|
|
73
|
+
return c >= 0 ? c : g(t, s, n > 0 ? -1 : 1, e.row);
|
|
73
74
|
};
|
|
74
75
|
return {
|
|
75
|
-
update:
|
|
76
|
-
handleKeyDown: async (
|
|
77
|
-
if (
|
|
78
|
-
let { rowModel:
|
|
79
|
-
if (
|
|
80
|
-
if ((
|
|
81
|
-
|
|
76
|
+
update: b,
|
|
77
|
+
handleKeyDown: async (i) => {
|
|
78
|
+
if (r === null) return;
|
|
79
|
+
let { rowModel: h, visibleColumns: g, readOnly: y, canEditCell: b, setEditorInitialValue: x, dispatch: C, handleCopy: T, openFind: k, handleCellDoubleClick: A, selectEntireGrid: j, onUndo: M, onRedo: N, onClearSelection: P, enableClearOnDelete: F, onToggleCheckboxCell: I, onToggleGroup: L, onToggleDetailRow: R } = r, z = f(r), B = r.getUiState ? p(z.selection, c(h), g.length) : r.isWholeGridSelected;
|
|
80
|
+
if (s(i.target) || d(r) || i.isComposing && a(i.target)) return;
|
|
81
|
+
if ((i.ctrlKey || i.metaKey) && i.key.toLowerCase() === "c") {
|
|
82
|
+
i.preventDefault(), await T();
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
|
-
if ((
|
|
85
|
-
|
|
85
|
+
if ((i.ctrlKey || i.metaKey) && !i.altKey && i.key.toLowerCase() === "x" && r.handleCut) {
|
|
86
|
+
i.preventDefault(), await r.handleCut();
|
|
86
87
|
return;
|
|
87
88
|
}
|
|
88
|
-
if ((
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
if ((i.ctrlKey || i.metaKey) && i.key.toLowerCase() === "f" && k) {
|
|
90
|
+
i.preventDefault(), k();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if ((i.ctrlKey || i.metaKey) && i.key.toLowerCase() === "a") {
|
|
94
|
+
if (i.preventDefault(), B) {
|
|
95
|
+
C(e.clearSelection()), C(e.activateCell(null));
|
|
91
96
|
return;
|
|
92
97
|
}
|
|
93
|
-
|
|
98
|
+
j();
|
|
94
99
|
return;
|
|
95
100
|
}
|
|
96
|
-
if ((
|
|
97
|
-
if (
|
|
98
|
-
|
|
101
|
+
if ((i.ctrlKey || i.metaKey) && !i.isComposing) {
|
|
102
|
+
if (i.key.toLowerCase() === "z") {
|
|
103
|
+
i.preventDefault(), i.shiftKey ? N() : M();
|
|
99
104
|
return;
|
|
100
105
|
}
|
|
101
|
-
if (
|
|
102
|
-
|
|
106
|
+
if (i.key.toLowerCase() === "y" && !i.shiftKey) {
|
|
107
|
+
i.preventDefault(), N();
|
|
103
108
|
return;
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
if (r.onShortcutKeyDown?.(i)) return;
|
|
112
|
+
let V = i.ctrlKey || i.metaKey;
|
|
113
|
+
if ((i.key === "ContextMenu" || i.key === "F10" && i.shiftKey) && !V && !i.altKey && z.activeCell && r.openContextMenu?.(z.activeCell)) {
|
|
114
|
+
i.preventDefault();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if ((i.key === "ArrowDown" || i.key === "ArrowUp") && i.altKey && i.shiftKey && !V && z.activeCell && r.onToggleTreeRow?.(z.activeCell, i.key === "ArrowDown")) {
|
|
118
|
+
i.preventDefault();
|
|
109
119
|
return;
|
|
110
120
|
}
|
|
111
|
-
if (
|
|
112
|
-
|
|
121
|
+
if (i.key === "ArrowDown" && i.altKey && !V && !i.shiftKey && z.activeCell && r.openColumnMenu?.(z.activeCell.col)) {
|
|
122
|
+
i.preventDefault();
|
|
113
123
|
return;
|
|
114
124
|
}
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
let e =
|
|
118
|
-
|
|
119
|
-
row: e ?
|
|
125
|
+
if (V && !i.altKey && (i.key === "ArrowUp" || i.key === "ArrowDown")) {
|
|
126
|
+
i.preventDefault();
|
|
127
|
+
let e = i.key === "ArrowDown";
|
|
128
|
+
D((t, n) => ({
|
|
129
|
+
row: e ? S(n) : _(n),
|
|
120
130
|
col: t.col
|
|
121
|
-
}),
|
|
131
|
+
}), i.shiftKey);
|
|
122
132
|
return;
|
|
123
133
|
}
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
let e =
|
|
127
|
-
|
|
134
|
+
if (V && !i.altKey && (i.key === "ArrowLeft" || i.key === "ArrowRight")) {
|
|
135
|
+
i.preventDefault();
|
|
136
|
+
let e = i.key === "ArrowRight";
|
|
137
|
+
D((t, n, r) => ({
|
|
128
138
|
row: t.row,
|
|
129
|
-
col: e ? r.length - 1 :
|
|
130
|
-
}),
|
|
139
|
+
col: e ? r.length - 1 : v(r)
|
|
140
|
+
}), i.shiftKey, e ? "end" : "start");
|
|
131
141
|
return;
|
|
132
142
|
}
|
|
133
|
-
if ((
|
|
134
|
-
|
|
135
|
-
let e =
|
|
136
|
-
|
|
137
|
-
row:
|
|
138
|
-
col: e ? r.length - 1 :
|
|
139
|
-
}),
|
|
143
|
+
if ((i.key === "Home" || i.key === "End") && !i.altKey) {
|
|
144
|
+
i.preventDefault();
|
|
145
|
+
let e = i.key === "End";
|
|
146
|
+
D((t, n, r) => ({
|
|
147
|
+
row: V ? e ? S(n) : _(n) : t.row,
|
|
148
|
+
col: e ? r.length - 1 : v(r)
|
|
149
|
+
}), i.shiftKey, e ? "end" : "start");
|
|
140
150
|
return;
|
|
141
151
|
}
|
|
142
|
-
if ((
|
|
143
|
-
if (
|
|
144
|
-
let e =
|
|
145
|
-
|
|
146
|
-
row:
|
|
152
|
+
if ((i.key === "PageDown" || i.key === "PageUp") && !V && !i.altKey) {
|
|
153
|
+
if (i.preventDefault(), w()) return;
|
|
154
|
+
let e = i.key === "PageDown" ? 1 : -1;
|
|
155
|
+
D((t, n) => ({
|
|
156
|
+
row: O(t, n, e),
|
|
147
157
|
col: t.col
|
|
148
|
-
}),
|
|
158
|
+
}), i.shiftKey);
|
|
149
159
|
return;
|
|
150
160
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
161
|
+
if (i.key === "ArrowUp") {
|
|
162
|
+
i.preventDefault(), E(-1, 0, i.shiftKey);
|
|
153
163
|
return;
|
|
154
164
|
}
|
|
155
|
-
if (
|
|
156
|
-
|
|
165
|
+
if (i.key === "ArrowDown") {
|
|
166
|
+
i.preventDefault(), E(1, 0, i.shiftKey);
|
|
157
167
|
return;
|
|
158
168
|
}
|
|
159
|
-
if (
|
|
160
|
-
|
|
169
|
+
if (i.key === "ArrowLeft") {
|
|
170
|
+
i.preventDefault(), E(0, -1, i.shiftKey);
|
|
161
171
|
return;
|
|
162
172
|
}
|
|
163
|
-
if (
|
|
164
|
-
|
|
173
|
+
if (i.key === "ArrowRight") {
|
|
174
|
+
i.preventDefault(), E(0, 1, i.shiftKey);
|
|
165
175
|
return;
|
|
166
176
|
}
|
|
167
|
-
if (
|
|
168
|
-
if (!
|
|
169
|
-
if (
|
|
170
|
-
|
|
177
|
+
if (i.key === "Tab") {
|
|
178
|
+
if (!z.activeCell && !i.shiftKey) {
|
|
179
|
+
if (r.rowModel.getRowCount() === 0 || r.visibleColumns.length === 0) return;
|
|
180
|
+
i.preventDefault(), w();
|
|
171
181
|
return;
|
|
172
182
|
}
|
|
173
|
-
let e =
|
|
174
|
-
if (
|
|
175
|
-
!
|
|
183
|
+
let e = z.activeCell?.col ?? 0;
|
|
184
|
+
if (i.shiftKey ? e <= v(r.visibleColumns) : e >= r.visibleColumns.length - 1) {
|
|
185
|
+
!i.shiftKey && z.activeCell && (r.onTabPastLastColumn?.(z.activeCell.row) || r.onTabPastNewRowDraft?.(z.activeCell, u(r.visibleColumns, r.readOnly))) && i.preventDefault();
|
|
176
186
|
return;
|
|
177
187
|
}
|
|
178
|
-
|
|
188
|
+
i.preventDefault(), E(0, i.shiftKey ? -1 : 1, !1);
|
|
179
189
|
return;
|
|
180
190
|
}
|
|
181
|
-
if (
|
|
182
|
-
|
|
191
|
+
if (i.key === "Escape") {
|
|
192
|
+
if (z.activeCell && r.onEscapeNewRow?.(z.activeCell)) {
|
|
193
|
+
i.preventDefault();
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
m(z.selection) && i.preventDefault(), C(e.clearSelection());
|
|
183
197
|
return;
|
|
184
198
|
}
|
|
185
|
-
if ((
|
|
186
|
-
|
|
199
|
+
if ((i.key === "Delete" || i.key === "Backspace") && F) {
|
|
200
|
+
i.preventDefault(), P();
|
|
187
201
|
return;
|
|
188
202
|
}
|
|
189
|
-
if ((
|
|
190
|
-
let e =
|
|
203
|
+
if ((i.key === "Enter" || i.key === " ") && z.activeCell) {
|
|
204
|
+
let e = h.getGroupRow?.(z.activeCell.row);
|
|
191
205
|
if (e) {
|
|
192
|
-
|
|
206
|
+
i.preventDefault(), L(e.groupKey);
|
|
193
207
|
return;
|
|
194
208
|
}
|
|
195
|
-
if (
|
|
196
|
-
|
|
209
|
+
if (R && g[z.activeCell.col]?.key === "__ssg_detail_toggle__" && R(z.activeCell)) {
|
|
210
|
+
i.preventDefault();
|
|
197
211
|
return;
|
|
198
212
|
}
|
|
199
213
|
}
|
|
200
|
-
if (
|
|
201
|
-
if (
|
|
202
|
-
|
|
214
|
+
if (i.key === "Enter" || i.key === "F2") {
|
|
215
|
+
if (i.preventDefault(), z.activeCell) {
|
|
216
|
+
A(z.activeCell);
|
|
203
217
|
return;
|
|
204
218
|
}
|
|
205
|
-
|
|
219
|
+
i.key === "Enter" && w();
|
|
206
220
|
return;
|
|
207
221
|
}
|
|
208
|
-
if (
|
|
209
|
-
let
|
|
210
|
-
if (!
|
|
211
|
-
readOnly:
|
|
212
|
-
canEditCell:
|
|
213
|
-
},
|
|
214
|
-
if (
|
|
215
|
-
|
|
222
|
+
if (i.key === " " && !i.ctrlKey && !i.metaKey && !i.altKey && i.preventDefault(), o(i) && z.activeCell) {
|
|
223
|
+
let r = g[z.activeCell.col], a = l(h, z.activeCell.row, r !== void 0 && t(y, r));
|
|
224
|
+
if (!a || !r || !n({
|
|
225
|
+
readOnly: y,
|
|
226
|
+
canEditCell: b
|
|
227
|
+
}, h, z.activeCell.row, z.activeCell.col, a, r)) return;
|
|
228
|
+
if (r.editor?.type === "checkbox") {
|
|
229
|
+
i.preventDefault(), i.key === " " && I(z.activeCell);
|
|
216
230
|
return;
|
|
217
231
|
}
|
|
218
|
-
|
|
232
|
+
i.preventDefault(), x(i.key), C(e.startEdit(z.activeCell));
|
|
219
233
|
}
|
|
220
234
|
}
|
|
221
235
|
};
|
|
222
236
|
};
|
|
223
237
|
//#endregion
|
|
224
|
-
export {
|
|
238
|
+
export { b as createKeyboardController, y as resolveFirstDataCell };
|
|
@@ -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)}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=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;
|
|
@@ -25,6 +25,7 @@ export type RowDragArgs = {
|
|
|
25
25
|
gridRootRef?: ReadonlyRef<HTMLElement | null>;
|
|
26
26
|
endEditLeftOpen?: (() => void) | undefined;
|
|
27
27
|
canDropAt?: (fromIndex: number, slot: number) => boolean;
|
|
28
|
+
maxDropSlot?: number | undefined;
|
|
28
29
|
};
|
|
29
30
|
export type RowDragHandlePointerEvent = {
|
|
30
31
|
button: number;
|
|
@@ -169,6 +169,7 @@ var h = 14, g = 12, _ = "0.5", v = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
|
|
|
169
169
|
let e = t(h + v, c);
|
|
170
170
|
e > _ + 1 && (g = e);
|
|
171
171
|
}
|
|
172
|
+
A.maxDropSlot !== void 0 && g > A.maxDropSlot && (g = A.maxDropSlot);
|
|
172
173
|
let y = n(g, c);
|
|
173
174
|
return {
|
|
174
175
|
slot: g,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/checkboxEditor.cjs"),r=require("../logic/editorValues.cjs"),i=require("../logic/validation.cjs"),a=require("../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/checkboxEditor.cjs"),r=require("../logic/editorValues.cjs"),i=require("../logic/validation.cjs"),a=require("../logic/newRow.cjs"),o=require("../logic/clearCells.cjs"),s=require("../controllers/liveUiState.cjs"),c=require("../controllers/keyboardController.cjs");var l=e=>e==null||e===``,u=(e,n,a,o,s)=>{let{rows:c,rowModel:l,handleRowsChange:u,applyServerSideCellEdits:d}=e;if(i.decideCellWrite(o,a,s).action===`reject`)return;let f=l.newRow;if(f!==void 0&&f.index===n){let e=f.peekRow()??a;Object.is(t.getCellValue(e,o),s)||f.writeRow(t.setCellValue(e,o,s));return}if(d){d([{viewIndex:n,column:o,value:s}]);return}if(!u)return;let p=l.getSourceIndex(n);p!==void 0&&u(r.writeRowsCell(c,p,o,s))},d=()=>{let d=null,f=e=>{d=e},p=(e,n,r,i,a)=>t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},e.rowModel,n,r,i,a),m=e=>{if(d===null)return!1;let n=d.orderedColumns[e.col];if(!n||n.editor?.type===`checkbox`)return!1;let r=a.resolveEditRow(d.rowModel,e.row,t.isColumnEditable(d.readOnly,n));return!r||!p(d,e.row,e.col,r,n)?!1:(d.startEditWithValue(e,String(t.getCellValue(r,n)??``)),!0)},h=(e,t,n,r)=>{d!==null&&u(d,e,t,n,r)};return{update:f,tryStartEdit:m,toggleCheckbox:e=>{if(d===null)return;let{rowModel:r,orderedColumns:i,handleRowsChange:o,applyServerSideCellEdits:s}=d;if(!o&&!s)return;let c=i[e.col];if(!c||c.editor?.type!==`checkbox`)return;let l=a.resolveEditRow(r,e.row,t.isColumnEditable(d.readOnly,c));!l||!p(d,e.row,e.col,l,c)||h(e.row,l,c,n.toggleCheckboxValue(t.getCellValue(l,c),c.editor))},writeCellValue:h,clearSelectedCells:()=>{if(d===null)return;let e=d,{rows:n,rowModel:c,orderedColumns:u,handleRowsChange:f,applyServerSideCellEdits:m}=e,{selection:h,activeCell:g}=s.readLiveUiState(e),_=c.getRowCount();if(g!==null&&a.isNewRowAt(c,g.row)&&h?.type!==`col`){let n=u[g.col],a=c.newRow?.hasDraft()?c.newRow.peekRow():void 0;if(n===void 0||a===void 0||!p(e,g.row,g.col,a,n))return;let o=r.resolveCellParser(n)(``,a),s=t.getCellValue(a,n);if(Object.is(s,o)||l(s)&&l(o))return;i.decideCellWrite(n,a,o).action!==`reject`&&c.newRow?.writeRow(t.setCellValue(a,n,o));return}if(m){let t=o.buildClearCellEdits({getRow:e=>c.getRow(e),columns:u,selection:h,activeCell:g,viewRowCount:_,canWriteCell:(t,n,r,i)=>p(e,t,n,r,i)});t.length>0&&m(t);return}if(!f)return;let{nextRows:v,changed:y}=o.clearCellsInSelection({rows:n,resolveSourceIndex:e=>c.getSourceIndex(e),columns:u,selection:h,activeCell:g,viewRowCount:_,canWriteCell:(t,n,r,i,a)=>p(e,a,n,r,i)});y&&f(v)},selectEntireGrid:()=>{if(d===null)return;let{rowModel:t,orderedColumns:n,dispatch:r}=d,i=a.getSelectableRowCount(t);i===0||n.length===0||(r(e.gridActions.startSelection({row:0,col:0})),r(e.gridActions.updateSelection({row:i-1,col:n.length-1})),r(e.gridActions.endSelection()),r(e.gridActions.activateCell(c.resolveFirstDataCell(t,n))))}}};exports.createCellCommands=d,exports.writeCellValueTo=u;
|