@ishibashi0112/spreadsheet-grid-core 1.0.1 → 1.0.2
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/autoHeightMeasurer.cjs +1 -1
- package/dist/controllers/autoHeightMeasurer.js +4 -2
- package/dist/controllers/clipboardController.cjs +1 -2
- package/dist/controllers/clipboardController.js +26 -26
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +2 -1
- package/dist/controllers/columnAutosizeRunner.js +11 -10
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.js +176 -171
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.js +1 -1
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +78 -78
- package/dist/controllers/escapeClaimController.cjs +1 -1
- package/dist/controllers/escapeClaimController.d.ts +1 -0
- package/dist/controllers/escapeClaimController.js +11 -5
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +141 -140
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +81 -77
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +36 -29
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.js +112 -116
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.js +10 -5
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.js +128 -127
- package/dist/controllers/rowEnterController.cjs +1 -1
- package/dist/controllers/rowEnterController.d.ts +1 -0
- package/dist/controllers/rowEnterController.js +47 -42
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +64 -47
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +1 -0
- package/dist/controllers/viewportSyncController.js +29 -8
- package/dist/engine/filterPopoverCommands.cjs +1 -1
- package/dist/engine/filterPopoverCommands.d.ts +2 -0
- package/dist/engine/filterPopoverCommands.js +15 -15
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +17 -17
- package/dist/engine/gridApi.cjs +2 -2
- package/dist/engine/gridApi.d.ts +1 -0
- package/dist/engine/gridApi.js +11 -11
- package/dist/engine/rowSelectionCommands.cjs +1 -1
- package/dist/engine/rowSelectionCommands.d.ts +1 -0
- package/dist/engine/rowSelectionCommands.js +21 -12
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +7 -4
- package/dist/logic/columnAutosize.cjs +1 -1
- package/dist/logic/columnAutosize.d.ts +8 -2
- package/dist/logic/columnAutosize.js +102 -87
- package/dist/logic/detailRow.cjs +1 -1
- package/dist/logic/detailRow.d.ts +4 -0
- package/dist/logic/detailRow.js +18 -15
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.d.ts +1 -0
- package/dist/logic/editorValues.js +29 -29
- package/dist/logic/filterSummary.cjs +1 -1
- package/dist/logic/filterSummary.js +9 -2
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.d.ts +4 -3
- package/dist/logic/find.js +27 -13
- package/dist/logic/gridAsk.cjs +2 -2
- package/dist/logic/gridAsk.d.ts +7 -7
- package/dist/logic/gridAsk.js +140 -122
- package/dist/logic/gridAskLocaleText.cjs +1 -1
- package/dist/logic/gridAskLocaleText.d.ts +2 -0
- package/dist/logic/gridAskLocaleText.js +1 -0
- package/dist/logic/gridState.d.ts +2 -2
- package/dist/logic/localeText.cjs +1 -1
- package/dist/logic/localeText.d.ts +2 -0
- package/dist/logic/localeText.js +1 -0
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.js +2 -2
- package/dist/logic/localeTextFilters.cjs +1 -1
- package/dist/logic/localeTextFilters.d.ts +1 -0
- package/dist/logic/localeTextFilters.js +1 -0
- package/dist/logic/localeTextPopups.cjs +1 -1
- package/dist/logic/localeTextPopups.js +2 -2
- package/dist/logic/numberFilterCondition.cjs +1 -1
- package/dist/logic/numberFilterCondition.d.ts +1 -1
- package/dist/logic/numberFilterCondition.js +5 -5
- package/dist/logic/scrollTargets.cjs +1 -1
- package/dist/logic/scrollTargets.js +2 -2
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +1 -0
- package/dist/logic/selectEditorState.js +8 -1
- package/dist/logic/valueFormatters.d.ts +5 -5
- package/dist/logic/verticalGeometry.cjs +1 -1
- package/dist/logic/verticalGeometry.d.ts +1 -0
- package/dist/logic/verticalGeometry.js +12 -8
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +2 -1
- package/dist/model/gridActions.js +3 -2
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +145 -62
- package/dist/model/gridTypes.core.d.ts +319 -298
- package/dist/utils/clipboard.cjs +3 -5
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.js +25 -22
- package/package.json +1 -1
|
@@ -1,217 +1,213 @@
|
|
|
1
1
|
import { isViewCellEditable as e } from "../utils/permissions.js";
|
|
2
|
-
import "../logic/
|
|
3
|
-
import "../
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { isClearableSelection as o } from "./escapeClaimController.js";
|
|
2
|
+
import { resolveFirstDataColIndex as t } from "../logic/detailRow.js";
|
|
3
|
+
import { gridActions as n } from "../model/gridActions.js";
|
|
4
|
+
import { clamp as r } from "../logic/geometry.js";
|
|
5
|
+
import { isImeInputTarget as i, isPrintableKey as a, shouldIgnoreGridKeydown as o } from "../logic/domGuards.js";
|
|
6
|
+
import { isClearableSelection as s } from "./escapeClaimController.js";
|
|
8
7
|
//#region src/controllers/keyboardController.ts
|
|
9
|
-
var
|
|
8
|
+
var c = 10, l = (e, t, n, r) => {
|
|
10
9
|
if (!e.getLabelRow) return t;
|
|
11
10
|
let i = e.getRowCount(), a = t;
|
|
12
11
|
for (; a >= 0 && a < i && e.getLabelRow(a);) a += n;
|
|
13
12
|
return a >= 0 && a < i ? a : r;
|
|
14
|
-
}, u = (e) => l(e, 0, 1, 0), d = (e) => {
|
|
15
|
-
let t = e.findIndex((e) => !s(e.key));
|
|
16
|
-
return t < 0 ? 0 : t;
|
|
17
|
-
}, f = (e, t) => ({
|
|
13
|
+
}, u = (e) => l(e, 0, 1, 0), d = (e) => t(e), f = (e, t) => ({
|
|
18
14
|
row: u(e),
|
|
19
15
|
col: d(t)
|
|
20
16
|
}), p = () => {
|
|
21
|
-
let
|
|
22
|
-
|
|
17
|
+
let t = null, p = (e) => {
|
|
18
|
+
t = e;
|
|
23
19
|
}, m = (e, t) => l(e, t, -1, l(e, t, 1, t)), h = (e) => {
|
|
24
20
|
let t = e.getRowCount() - 1;
|
|
25
21
|
return l(e, t, -1, t);
|
|
26
|
-
}, g = (e,
|
|
27
|
-
if (
|
|
28
|
-
let { uiState:
|
|
29
|
-
if (
|
|
30
|
-
let
|
|
31
|
-
|
|
22
|
+
}, g = (e, r, i) => {
|
|
23
|
+
if (t === null) return;
|
|
24
|
+
let { uiState: a, dispatch: o } = t;
|
|
25
|
+
if (i) {
|
|
26
|
+
let t = a.selection?.type === "cell" ? a.selection.range.start : e;
|
|
27
|
+
o(n.startSelection(t)), o(n.updateSelection(r)), o(n.endSelection()), o(n.activateCell(r));
|
|
32
28
|
return;
|
|
33
29
|
}
|
|
34
|
-
|
|
30
|
+
o(n.startSelection(r)), o(n.endSelection()), o(n.activateCell(r));
|
|
35
31
|
}, _ = () => {
|
|
36
|
-
if (
|
|
37
|
-
let { rowModel: e, visibleColumns:
|
|
38
|
-
if (e.getRowCount() === 0 ||
|
|
39
|
-
let
|
|
40
|
-
return g(
|
|
32
|
+
if (t === null || t.uiState.activeCell) return !1;
|
|
33
|
+
let { rowModel: e, visibleColumns: n } = t;
|
|
34
|
+
if (e.getRowCount() === 0 || n.length === 0) return !0;
|
|
35
|
+
let r = f(e, n);
|
|
36
|
+
return g(r, r, !1), !0;
|
|
41
37
|
}, v = (e) => {
|
|
42
|
-
let
|
|
43
|
-
return e &&
|
|
38
|
+
let n = t?.uiState;
|
|
39
|
+
return e && n?.selection?.type === "cell" ? n.selection.range.end : n?.activeCell ?? {
|
|
44
40
|
row: 0,
|
|
45
41
|
col: 0
|
|
46
42
|
};
|
|
47
|
-
}, y = (e,
|
|
48
|
-
if (
|
|
49
|
-
let { rowModel:
|
|
50
|
-
if (
|
|
51
|
-
let c = v(
|
|
52
|
-
u = e === 0 ? m(
|
|
43
|
+
}, y = (e, n, i) => {
|
|
44
|
+
if (t === null) return;
|
|
45
|
+
let { rowModel: a, visibleColumns: o } = t, s = a.getRowCount();
|
|
46
|
+
if (s === 0 || o.length === 0 || _()) return;
|
|
47
|
+
let c = v(i), u = r(c.row + e, 0, s - 1);
|
|
48
|
+
u = e === 0 ? m(a, u) : l(a, u, e > 0 ? 1 : -1, c.row);
|
|
53
49
|
let d = {
|
|
54
50
|
row: u,
|
|
55
|
-
col:
|
|
51
|
+
col: r(c.col + n, 0, o.length - 1)
|
|
56
52
|
};
|
|
57
|
-
g(c, d,
|
|
58
|
-
}, b = (e,
|
|
59
|
-
if (
|
|
60
|
-
let { uiState:
|
|
61
|
-
if (
|
|
62
|
-
let
|
|
63
|
-
row: u(
|
|
64
|
-
col: d(
|
|
65
|
-
}, c = e(
|
|
66
|
-
g(
|
|
67
|
-
row: m(
|
|
68
|
-
col:
|
|
69
|
-
},
|
|
70
|
-
}, x = (e,
|
|
71
|
-
let
|
|
72
|
-
return u >= 0 ? u : l(
|
|
53
|
+
g(c, d, i);
|
|
54
|
+
}, b = (e, n) => {
|
|
55
|
+
if (t === null) return;
|
|
56
|
+
let { uiState: i, rowModel: a, visibleColumns: o } = t;
|
|
57
|
+
if (a.getRowCount() === 0 || o.length === 0) return;
|
|
58
|
+
let s = i.activeCell ? v(n) : {
|
|
59
|
+
row: u(a),
|
|
60
|
+
col: d(o)
|
|
61
|
+
}, c = e(s, a, o);
|
|
62
|
+
g(s, {
|
|
63
|
+
row: m(a, r(c.row, 0, a.getRowCount() - 1)),
|
|
64
|
+
col: r(c.col, 0, o.length - 1)
|
|
65
|
+
}, n && i.activeCell !== null);
|
|
66
|
+
}, x = (e, n, i) => {
|
|
67
|
+
let a = n.getRowCount(), o = t?.resolvePageRow ? t.resolvePageRow(e.row, i) : e.row + i * c, s = r(i > 0 ? Math.max(o, e.row + 1) : Math.min(o, e.row - 1), 0, a - 1), u = l(n, s, i, -1);
|
|
68
|
+
return u >= 0 ? u : l(n, s, i > 0 ? -1 : 1, e.row);
|
|
73
69
|
};
|
|
74
70
|
return {
|
|
75
71
|
update: p,
|
|
76
|
-
handleKeyDown: async (
|
|
77
|
-
if (
|
|
78
|
-
let { uiState: c, rowModel: l, visibleColumns: f, readOnly: p, canEditCell: m, setEditorInitialValue: g, dispatch: v, handleCopy: S, openFind: C, handleCellDoubleClick: w, isWholeGridSelected: T, selectEntireGrid: E, onUndo: D, onRedo: O, onClearSelection: k, enableClearOnDelete: A, onToggleCheckboxCell: j, onToggleGroup: M, onToggleDetailRow: N } =
|
|
79
|
-
if (
|
|
80
|
-
if ((
|
|
81
|
-
|
|
72
|
+
handleKeyDown: async (r) => {
|
|
73
|
+
if (t === null) return;
|
|
74
|
+
let { uiState: c, rowModel: l, visibleColumns: f, readOnly: p, canEditCell: m, setEditorInitialValue: g, dispatch: v, handleCopy: S, openFind: C, handleCellDoubleClick: w, isWholeGridSelected: T, selectEntireGrid: E, onUndo: D, onRedo: O, onClearSelection: k, enableClearOnDelete: A, onToggleCheckboxCell: j, onToggleGroup: M, onToggleDetailRow: N } = t;
|
|
75
|
+
if (o(r.target) || c.editingCell || r.isComposing && i(r.target)) return;
|
|
76
|
+
if ((r.ctrlKey || r.metaKey) && r.key.toLowerCase() === "c") {
|
|
77
|
+
r.preventDefault(), await S();
|
|
82
78
|
return;
|
|
83
79
|
}
|
|
84
|
-
if ((
|
|
85
|
-
|
|
80
|
+
if ((r.ctrlKey || r.metaKey) && r.key.toLowerCase() === "f" && C) {
|
|
81
|
+
r.preventDefault(), C();
|
|
86
82
|
return;
|
|
87
83
|
}
|
|
88
|
-
if ((
|
|
89
|
-
if (
|
|
90
|
-
v(
|
|
84
|
+
if ((r.ctrlKey || r.metaKey) && r.key.toLowerCase() === "a") {
|
|
85
|
+
if (r.preventDefault(), T) {
|
|
86
|
+
v(n.clearSelection()), v(n.activateCell(null));
|
|
91
87
|
return;
|
|
92
88
|
}
|
|
93
89
|
E();
|
|
94
90
|
return;
|
|
95
91
|
}
|
|
96
|
-
if ((
|
|
97
|
-
if (
|
|
98
|
-
|
|
92
|
+
if ((r.ctrlKey || r.metaKey) && !r.isComposing) {
|
|
93
|
+
if (r.key.toLowerCase() === "z") {
|
|
94
|
+
r.preventDefault(), r.shiftKey ? O() : D();
|
|
99
95
|
return;
|
|
100
96
|
}
|
|
101
|
-
if (
|
|
102
|
-
|
|
97
|
+
if (r.key.toLowerCase() === "y" && !r.shiftKey) {
|
|
98
|
+
r.preventDefault(), O();
|
|
103
99
|
return;
|
|
104
100
|
}
|
|
105
101
|
}
|
|
106
|
-
let P =
|
|
107
|
-
if (
|
|
108
|
-
|
|
102
|
+
let P = r.ctrlKey || r.metaKey;
|
|
103
|
+
if (r.key === "ArrowDown" && r.altKey && !P && !r.shiftKey && c.activeCell && t.openColumnMenu?.(c.activeCell.col)) {
|
|
104
|
+
r.preventDefault();
|
|
109
105
|
return;
|
|
110
106
|
}
|
|
111
|
-
if (P && !
|
|
112
|
-
|
|
113
|
-
let e =
|
|
107
|
+
if (P && !r.altKey && (r.key === "ArrowUp" || r.key === "ArrowDown")) {
|
|
108
|
+
r.preventDefault();
|
|
109
|
+
let e = r.key === "ArrowDown";
|
|
114
110
|
b((t, n) => ({
|
|
115
111
|
row: e ? h(n) : u(n),
|
|
116
112
|
col: t.col
|
|
117
|
-
}),
|
|
113
|
+
}), r.shiftKey);
|
|
118
114
|
return;
|
|
119
115
|
}
|
|
120
|
-
if (P && !
|
|
121
|
-
|
|
122
|
-
let e =
|
|
116
|
+
if (P && !r.altKey && (r.key === "ArrowLeft" || r.key === "ArrowRight")) {
|
|
117
|
+
r.preventDefault();
|
|
118
|
+
let e = r.key === "ArrowRight";
|
|
123
119
|
b((t, n, r) => ({
|
|
124
120
|
row: t.row,
|
|
125
121
|
col: e ? r.length - 1 : d(r)
|
|
126
|
-
}),
|
|
122
|
+
}), r.shiftKey);
|
|
127
123
|
return;
|
|
128
124
|
}
|
|
129
|
-
if ((
|
|
130
|
-
|
|
131
|
-
let e =
|
|
125
|
+
if ((r.key === "Home" || r.key === "End") && !r.altKey) {
|
|
126
|
+
r.preventDefault();
|
|
127
|
+
let e = r.key === "End";
|
|
132
128
|
b((t, n, r) => ({
|
|
133
129
|
row: P ? e ? h(n) : u(n) : t.row,
|
|
134
130
|
col: e ? r.length - 1 : d(r)
|
|
135
|
-
}),
|
|
131
|
+
}), r.shiftKey);
|
|
136
132
|
return;
|
|
137
133
|
}
|
|
138
|
-
if ((
|
|
139
|
-
if (
|
|
140
|
-
let e =
|
|
134
|
+
if ((r.key === "PageDown" || r.key === "PageUp") && !P && !r.altKey) {
|
|
135
|
+
if (r.preventDefault(), _()) return;
|
|
136
|
+
let e = r.key === "PageDown" ? 1 : -1;
|
|
141
137
|
b((t, n) => ({
|
|
142
138
|
row: x(t, n, e),
|
|
143
139
|
col: t.col
|
|
144
|
-
}),
|
|
140
|
+
}), r.shiftKey);
|
|
145
141
|
return;
|
|
146
142
|
}
|
|
147
|
-
if (
|
|
148
|
-
|
|
143
|
+
if (r.key === "ArrowUp") {
|
|
144
|
+
r.preventDefault(), y(-1, 0, r.shiftKey);
|
|
149
145
|
return;
|
|
150
146
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
147
|
+
if (r.key === "ArrowDown") {
|
|
148
|
+
r.preventDefault(), y(1, 0, r.shiftKey);
|
|
153
149
|
return;
|
|
154
150
|
}
|
|
155
|
-
if (
|
|
156
|
-
|
|
151
|
+
if (r.key === "ArrowLeft") {
|
|
152
|
+
r.preventDefault(), y(0, -1, r.shiftKey);
|
|
157
153
|
return;
|
|
158
154
|
}
|
|
159
|
-
if (
|
|
160
|
-
|
|
155
|
+
if (r.key === "ArrowRight") {
|
|
156
|
+
r.preventDefault(), y(0, 1, r.shiftKey);
|
|
161
157
|
return;
|
|
162
158
|
}
|
|
163
|
-
if (
|
|
164
|
-
if (!c.activeCell && !
|
|
165
|
-
if (
|
|
166
|
-
|
|
159
|
+
if (r.key === "Tab") {
|
|
160
|
+
if (!c.activeCell && !r.shiftKey) {
|
|
161
|
+
if (t.rowModel.getRowCount() === 0 || t.visibleColumns.length === 0) return;
|
|
162
|
+
r.preventDefault(), _();
|
|
167
163
|
return;
|
|
168
164
|
}
|
|
169
165
|
let e = c.activeCell?.col ?? 0;
|
|
170
|
-
if (
|
|
171
|
-
!
|
|
166
|
+
if (r.shiftKey ? e <= d(t.visibleColumns) : e >= t.visibleColumns.length - 1) {
|
|
167
|
+
!r.shiftKey && c.activeCell && t.onTabPastLastColumn?.(c.activeCell.row) && r.preventDefault();
|
|
172
168
|
return;
|
|
173
169
|
}
|
|
174
|
-
|
|
170
|
+
r.preventDefault(), y(0, r.shiftKey ? -1 : 1, !1);
|
|
175
171
|
return;
|
|
176
172
|
}
|
|
177
|
-
if (
|
|
178
|
-
|
|
173
|
+
if (r.key === "Escape") {
|
|
174
|
+
s(c.selection) && r.preventDefault(), v(n.clearSelection());
|
|
179
175
|
return;
|
|
180
176
|
}
|
|
181
|
-
if ((
|
|
182
|
-
|
|
177
|
+
if ((r.key === "Delete" || r.key === "Backspace") && A) {
|
|
178
|
+
r.preventDefault(), k();
|
|
183
179
|
return;
|
|
184
180
|
}
|
|
185
|
-
if ((
|
|
181
|
+
if ((r.key === "Enter" || r.key === " ") && c.activeCell) {
|
|
186
182
|
let e = l.getGroupRow?.(c.activeCell.row);
|
|
187
183
|
if (e) {
|
|
188
|
-
|
|
184
|
+
r.preventDefault(), M(e.groupKey);
|
|
189
185
|
return;
|
|
190
186
|
}
|
|
191
187
|
if (N && f[c.activeCell.col]?.key === "__ssg_detail_toggle__" && N(c.activeCell)) {
|
|
192
|
-
|
|
188
|
+
r.preventDefault();
|
|
193
189
|
return;
|
|
194
190
|
}
|
|
195
191
|
}
|
|
196
|
-
if (
|
|
197
|
-
if (
|
|
192
|
+
if (r.key === "Enter" || r.key === "F2") {
|
|
193
|
+
if (r.preventDefault(), c.activeCell) {
|
|
198
194
|
w(c.activeCell);
|
|
199
195
|
return;
|
|
200
196
|
}
|
|
201
|
-
|
|
197
|
+
r.key === "Enter" && _();
|
|
202
198
|
return;
|
|
203
199
|
}
|
|
204
|
-
if (
|
|
205
|
-
let
|
|
206
|
-
if (!
|
|
200
|
+
if (r.key === " " && !r.ctrlKey && !r.metaKey && !r.altKey && r.preventDefault(), a(r) && c.activeCell) {
|
|
201
|
+
let t = l.getRow(c.activeCell.row), i = f[c.activeCell.col];
|
|
202
|
+
if (!t || !i || !e({
|
|
207
203
|
readOnly: p,
|
|
208
204
|
canEditCell: m
|
|
209
|
-
}, l, c.activeCell.row, c.activeCell.col,
|
|
205
|
+
}, l, c.activeCell.row, c.activeCell.col, t, i)) return;
|
|
210
206
|
if (i.editor?.type === "checkbox") {
|
|
211
|
-
|
|
207
|
+
r.preventDefault(), r.key === " " && j(c.activeCell);
|
|
212
208
|
return;
|
|
213
209
|
}
|
|
214
|
-
|
|
210
|
+
r.preventDefault(), g(r.key), v(n.startEdit(c.activeCell));
|
|
215
211
|
}
|
|
216
212
|
}
|
|
217
213
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs");var t=e=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e?.blur()},n=t=>{requestAnimationFrame(()=>{let n=t.current;if(n===null||e.isFocusInsideDetailCard())return;let r=n.ownerDocument.activeElement;r!==null&&r!==n&&n.contains(r)&&r.closest(`.ssg-cell-editor`)!==null||n.focus()})},
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs");require("./escapeClaimController.cjs");var t=e=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e?.blur()},n=`input, textarea, select, [contenteditable]:not([contenteditable="false"])`,r=t=>{let r=t.current,i=r?.ownerDocument.activeElement??null;r!==null&&i!==null&&!r.contains(i)&&i.closest(`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover`)!==null&&(i.matches(n)?queueMicrotask(()=>{let e=t.current,n=e?.ownerDocument.activeElement??null;e!==null&&(n===null||n===e.ownerDocument.body)&&e.focus({preventScroll:!0})}):r.focus({preventScroll:!0})),requestAnimationFrame(()=>{let n=t.current;if(n===null||e.isFocusInsideDetailCard())return;let r=n.ownerDocument.activeElement;r!==null&&r!==n&&n.contains(r)&&r.closest(`.ssg-cell-editor`)!==null||n.focus()})},i=(e,t)=>e.current?.contains(t)===!0,a=(e,t,n=`[role="menuitem"]`)=>{let r=document.activeElement,i=r instanceof HTMLElement&&e.contains(r);if(i&&!r.matches(n))return!1;let a=t.key;if(a===`ArrowDown`||a===`ArrowUp`||a===`Home`||a===`End`){t.preventDefault();let o=Array.from(e.querySelectorAll(`${n}:not(:disabled):not([aria-disabled="true"])`));if(o.length===0)return!0;let s=i?o.indexOf(r):-1,c;return c=a===`Home`?0:a===`End`?o.length-1:a===`ArrowDown`?s<0?0:(s+1)%o.length:s<0?o.length-1:(s-1+o.length)%o.length,o[c]?.focus(),!0}return!i&&(a===`PageUp`||a===`PageDown`||a===` `||a===`ArrowLeft`||a===`ArrowRight`)?(t.preventDefault(),!0):!1},o=e=>{let t=!1,n=()=>e.onResize?.(),r=t=>e.onScroll?.(t),i=t=>{let n=t.target;n&&(e.isInside(n)||e.onOutsidePointerDown(n))},a=t=>e.onKeyDown?.(t),o=null,s=()=>{let n=e.getGridRoot?.()??null,r=e.onGridHidden;!n||!r||typeof ResizeObserver>`u`||(o=new ResizeObserver(e=>{let i=e[e.length-1];if(!t||!i||i.contentRect.width!==0||i.contentRect.height!==0)return;let a=n.getBoundingClientRect();a.width===0&&a.height===0&&r()}),o.observe(n))};return{attach:()=>{t||(t=!0,window.addEventListener(`resize`,n),window.addEventListener(`scroll`,r,!0),window.addEventListener(`pointerdown`,i),window.addEventListener(`keydown`,a,!0),s())},detach:()=>{t&&(t=!1,o?.disconnect(),o=null,window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`pointerdown`,i),window.removeEventListener(`keydown`,a,!0))},isAttached:()=>t}};exports.blurForPopover=t,exports.createPopoverWindowBindings=o,exports.handleMenuKeyNavigation=a,exports.isInsideGridRoot=i,exports.restoreGridFocus=r;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { isFocusInsideDetailCard as e } from "../logic/detailRow.js";
|
|
2
|
+
import "./escapeClaimController.js";
|
|
2
3
|
//#region src/controllers/popoverSupport.ts
|
|
3
4
|
var t = (e) => {
|
|
4
5
|
document.activeElement instanceof HTMLElement && document.activeElement.blur(), e?.blur();
|
|
5
|
-
}, n = (t) => {
|
|
6
|
-
|
|
6
|
+
}, n = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])", r = (t) => {
|
|
7
|
+
let r = t.current, i = r?.ownerDocument.activeElement ?? null;
|
|
8
|
+
r !== null && i !== null && !r.contains(i) && i.closest(".ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover") !== null && (i.matches(n) ? queueMicrotask(() => {
|
|
9
|
+
let e = t.current, n = e?.ownerDocument.activeElement ?? null;
|
|
10
|
+
e !== null && (n === null || n === e.ownerDocument.body) && e.focus({ preventScroll: !0 });
|
|
11
|
+
}) : r.focus({ preventScroll: !0 })), requestAnimationFrame(() => {
|
|
7
12
|
let n = t.current;
|
|
8
13
|
if (n === null || e()) return;
|
|
9
14
|
let r = n.ownerDocument.activeElement;
|
|
10
15
|
r !== null && r !== n && n.contains(r) && r.closest(".ssg-cell-editor") !== null || n.focus();
|
|
11
16
|
});
|
|
12
|
-
},
|
|
17
|
+
}, i = (e, t) => e.current?.contains(t) === !0, a = (e, t, n = "[role=\"menuitem\"]") => {
|
|
13
18
|
let r = document.activeElement, i = r instanceof HTMLElement && e.contains(r);
|
|
14
19
|
if (i && !r.matches(n)) return !1;
|
|
15
20
|
let a = t.key;
|
|
@@ -21,7 +26,7 @@ var t = (e) => {
|
|
|
21
26
|
return c = a === "Home" ? 0 : a === "End" ? o.length - 1 : a === "ArrowDown" ? s < 0 ? 0 : (s + 1) % o.length : s < 0 ? o.length - 1 : (s - 1 + o.length) % o.length, o[c]?.focus(), !0;
|
|
22
27
|
}
|
|
23
28
|
return !i && (a === "PageUp" || a === "PageDown" || a === " " || a === "ArrowLeft" || a === "ArrowRight") ? (t.preventDefault(), !0) : !1;
|
|
24
|
-
},
|
|
29
|
+
}, o = (e) => {
|
|
25
30
|
let t = !1, n = () => e.onResize?.(), r = (t) => e.onScroll?.(t), i = (t) => {
|
|
26
31
|
let n = t.target;
|
|
27
32
|
n && (e.isInside(n) || e.onOutsidePointerDown(n));
|
|
@@ -45,4 +50,4 @@ var t = (e) => {
|
|
|
45
50
|
};
|
|
46
51
|
};
|
|
47
52
|
//#endregion
|
|
48
|
-
export { t as blurForPopover,
|
|
53
|
+
export { t as blurForPopover, o as createPopoverWindowBindings, a as handleMenuKeyNavigation, i as isInsideGridRoot, r as restoreGridFocus };
|
|
@@ -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("../logic/slotDom.cjs"),a=require("../utils/portalTokens.cjs");var o=14,s=12,c=`0.5`,l=`<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>`,u=`<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>`,d=200,f=`cubic-bezier(0.2, 0.7, 0.3, 1)`,p=`transform 160ms ${f}`,m=`data-ssg-row-dragging`,h=e=>e?.closest(`.ssg-motion-off`)!=null,g=/translateY\((-?[\d.]+)px\)/,_=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},v=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},y=e=>{e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.zIndex=``},b=()=>{let b=null,x=null,S=null,C={x:0,y:0},w=null,T=!1,E=null,D=null,O=null,k=null,A=null,j=null,M=0,N=null,P=()=>b?.motion===`live`,F=null,I=null,L=null,R=()=>[b?.leftIndicatorRef.current??null,b?.centerIndicatorRef.current??null,b?.rightIndicatorRef.current??null],z=()=>{for(let e of R())e&&(e.style.display=`none`)},B=e=>{if(F)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),b?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),b?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),b?.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(`;`),i.applySlotToElement(t,b?.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),document.body.appendChild(t),a.syncPortalTokens(b?.scrollContainerRef.current,t),F=t,I=n,L=null},V=e=>{let t=F;if(!t)return;t.style.transform=`translate(`+(C.x+o)+`px,`+(C.y+s)+`px)`;let n=e?`move`:`out`;if(L===n)return;L=n;let r=I;n===`out`?(t.style.opacity=c,r&&(r.innerHTML=u)):(t.style.opacity=`1`,r&&(r.innerHTML=l))},H=()=>{F&&F.parentNode&&F.parentNode.removeChild(F),F=null,I=null,L=null},U=(e,n)=>{let r=b?.scrollContainerRef.current??null;!r||n&&e===null||r.querySelectorAll(n?`.ssg-body-row[data-row-index="${e}"]`:`.ssg-body-row[${m}]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(m,P()?`live`:``):e.removeAttribute(m))})},W=()=>{let e=b?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of _(e)){let e=g.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},G=t=>{let n=j,r=x;if(!n||r===null||b===null)return;let i=b.scrollContainerRef.current;if(!i)return;for(let e of _(i)){if(n.has(e))continue;let t=g.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=b.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-M)*b.verticalScaleFactor,s=(w?C.y-w.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{let{index:i,baseY:o}=e;if(!t.isConnected){n.delete(t);return}if(i===r){t.style.transition=`none`,t.style.transform=`translateY(${o+s}px)`,t.style.willChange=`transform`,e.applied=t.style.transform;return}let l=0;c!==null&&(r<i&&i<=c?l=-a:c<=i&&i<r&&(l=a)),t.style.transition=p,t.style.transform=`translateY(${o+l}px)`,e.applied=t.style.transform});let l=N??new Set;N=l;for(let{el:e,index:t}of v(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=p,e.style.transform=`translateY(${n}px)`,e.style.zIndex=``}},K=(t,r)=>{if(b===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=b,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.clampClientYAboveFooter(r,f.top+u.clientTop+u.clientHeight,b.footerHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=x,v=_!==null&&P()?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}},q=()=>{let t=K(C.x,C.y),n=x;if(P()){t&&n!==null&&(S=e.resolveMoveTargetIndex(n,t.slot)===null?null:t.slot),z(),G(S);return}if(V(t),!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){S=null,z();return}S=t.slot;for(let e of R())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},J=()=>{if(x===null){O=null;return}let e=b?.scrollContainerRef.current??null;if(e&&(T||(!w||n.hasPointerLeftActivationRadius(w,C,6))&&(T=!0),T)){let t=e.getBoundingClientRect(),i=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight,scale:r.resolveElementScale(e,t)}),a=n.resolveAutoScrollAxisDirection(C.y,i.top,i.bottom-(b?.footerHeight??0),24),o=n.computeNextScrollPosition(e.scrollTop,a,18,e.scrollHeight-e.clientHeight);o!==e.scrollTop&&e.scrollTo({top:o,behavior:`auto`})}q(),O=requestAnimationFrame(J)},Y=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,X=()=>{let e=b?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of _(e))t.set(Y(n,Number(n.getAttribute(`data-row-index`))),n.getBoundingClientRect().top);for(let n of v(e))t.set(n.key,n.el.getBoundingClientRect().top);return t},Z=t=>{O!==null&&(cancelAnimationFrame(O),O=null),document.body.style.cursor=``,z(),H();let n=x,r=S,i=A;U(n,!1),x=null,A=null,S=null,w=null,D=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=t&&n!==null&&a!==null&&b!==null,s=j;j=null;let c=s&&o&&b!==null&&!h(b.scrollContainerRef.current)?X():null,l=N;if(N=null,l&&(o?l.forEach(y):(l.forEach(e=>{e.isConnected&&(e.style.transition=p,e.style.transform=`translateY(0px)`,e.style.zIndex=``)}),window.setTimeout(()=>{l.forEach(e=>{N?.has(e)||y(e)})},200))),s)if(o)s.forEach(({baseY:e},t)=>{t.style.transition=``,t.style.willChange=``,t.isConnected&&(t.style.transform=`translateY(${e}px)`)});else{let e=[];s.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=p,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}if(!o||n===null||a===null||b===null)return;let u=c??(h(b.scrollContainerRef.current)?null:X()),d=u?{tops:u,from:n,to:a,row:i}:null;k=d,b.commitRowMove(n,a),d&&requestAnimationFrame(()=>{k===d&&(k=null)})},Q=()=>{let e=k;if(k=null,!e)return;let t=b?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(b?.locateDragRow&&e.row!==null&&b.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;_(t).forEach(e=>{let t=n.get(Y(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=g.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(v(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 ${d}ms ${f}`,e.style.transform=`translateY(${s.get(e)??0}px)`;for(let e of c)e.style.transition=`transform ${d}ms ${f}`,e.style.transform=`translateY(0px)`;window.setTimeout(()=>{for(let e of o)e.style.transition=``,e.style.willChange=``;for(let e of c)N?.has(e)||y(e)},280)}},$=(e,t)=>{if(b===null||!b.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),b.gridRootRef?.current?.focus({preventScroll:!0}),x!==null){if(t.pointerId!==D)return;E?.(),Z(!1)}x=e,A=b.getDragRow?.(e)??null,D=t.pointerId,S=null,C={x:t.clientX,y:t.clientY},w={x:t.clientX,y:t.clientY},T=!1,document.body.style.cursor=`grabbing`,P()?(j=W(),M=b.scrollContainerRef.current?.scrollTop??0):B(b.getRowDragLabel(e)),U(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let i=e=>{e.pointerId===r&&(C={x:e.clientX,y:e.clientY},q())},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s),window.removeEventListener(`keydown`,c),window.removeEventListener(`blur`,l),E=null;try{n.releasePointerCapture(r)}catch{}};function o(e){e.pointerId===r&&(a(),Z(!0))}function s(e){e.pointerId===r&&(a(),Z(!1))}function c(e){e.key===`Escape`&&(a(),Z(!1))}function l(){a(),Z(!1)}window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),window.addEventListener(`keydown`,c),window.addEventListener(`blur`,l),E=a,q(),O=requestAnimationFrame(J)},ee=e=>{if(x===null||A==null||b?.locateDragRow===void 0)return;let t=b.locateDragRow(A,x);if(j&&j.forEach((e,t)=>{if(!t.isConnected){j?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`));if(n===e.index&&(e.applied===void 0||t.style.transform===e.applied))return;let r=g.exec(t.style.transform);if(!r){j?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){E?.(),Z(!1);return}j&&t!==x&&w!==null&&e!==null&&(w={x:w.x,y:w.y+b.rowMetrics.rowTop(t)-e.rowTop(x)}),t!==x&&(U(null,!1),x=t,U(t,!0)),q()};return{update:e=>{let t=b;b=e,x!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&ee(t.rowMetrics)},onRowDragHandlePointerDown:$,applyReorderSettle:Q,dispose:()=>{E?.(),E=null,O!==null&&(cancelAnimationFrame(O),O=null),document.body.style.cursor=``,H(),U(x,!1),x=null,A=null,S=null,j=null,N?.forEach(y),N=null,k=null}}};exports.createRowDragController=b;
|
|
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");var s=14,c=12,l=`0.5`,u=`<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>`,d=`<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>`,f=200,p=`cubic-bezier(0.2, 0.7, 0.3, 1)`,m=`transform 160ms ${p}`,h=`data-ssg-row-dragging`,g=e=>e?.closest(`.ssg-motion-off`)!=null,_=/translateY\((-?[\d.]+)px\)/,v=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},y=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},b=e=>{e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.zIndex=``},x=()=>{let x=null,S=null,C=null,w={x:0,y:0},T=null,E=!1,D=null,O=null,k=null,A=null,j=null,M=null,N=0,P=null,F=()=>x?.motion===`live`,I=null,L=null,R=null,z=()=>[x?.leftIndicatorRef.current??null,x?.centerIndicatorRef.current??null,x?.rightIndicatorRef.current??null],B=()=>{for(let e of z())e&&(e.style.display=`none`)},V=e=>{if(I)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),x?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),x?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),x?.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,x?.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),document.body.appendChild(t),o.syncPortalTokens(x?.scrollContainerRef.current,t),I=t,L=n,R=null},H=e=>{let t=I;if(!t)return;t.style.transform=`translate(`+(w.x+s)+`px,`+(w.y+c)+`px)`;let n=e?`move`:`out`;if(R===n)return;R=n;let r=L;n===`out`?(t.style.opacity=l,r&&(r.innerHTML=d)):(t.style.opacity=`1`,r&&(r.innerHTML=u))},U=()=>{I&&I.parentNode&&I.parentNode.removeChild(I),I=null,L=null,R=null},W=(e,n)=>{let r=x?.scrollContainerRef.current??null;!r||n&&e===null||r.querySelectorAll(n?`.ssg-body-row[data-row-index="${e}"]`:`.ssg-body-row[${h}]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(h,F()?`live`:``):e.removeAttribute(h))})},G=()=>{let e=x?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of v(e)){let e=_.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},K=t=>{let n=M,r=S;if(!n||r===null||x===null)return;let i=x.scrollContainerRef.current;if(!i)return;for(let e of v(i)){if(n.has(e))continue;let t=_.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=x.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-N)*x.verticalScaleFactor,s=(T?w.y-T.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{let{index:i,baseY:o}=e;if(!t.isConnected){n.delete(t);return}if(i===r){t.style.transition=`none`,t.style.transform=`translateY(${o+s}px)`,t.style.willChange=`transform`,e.applied=t.style.transform;return}let l=0;c!==null&&(r<i&&i<=c?l=-a:c<=i&&i<r&&(l=a)),t.style.transition=m,t.style.transform=`translateY(${o+l}px)`,e.applied=t.style.transform});let l=P??new Set;P=l;for(let{el:e,index:t}of y(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=m,e.style.transform=`translateY(${n}px)`,e.style.zIndex=``}},q=(t,r)=>{if(x===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=x,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.clampClientYAboveFooter(r,f.top+u.clientTop+u.clientHeight,x.footerHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=S,v=_!==null&&F()?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}},J=()=>{let t=q(w.x,w.y),n=S;if(F()){t&&n!==null&&(C=e.resolveMoveTargetIndex(n,t.slot)===null?null:t.slot),B(),K(C);return}if(H(t),!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){C=null,B();return}C=t.slot;for(let e of z())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},Y=()=>{if(S===null){k=null;return}let e=x?.scrollContainerRef.current??null;if(e&&(E||(!T||n.hasPointerLeftActivationRadius(T,w,6))&&(E=!0),E)){let t=e.getBoundingClientRect(),i=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight,scale:r.resolveElementScale(e,t)}),a=n.resolveAutoScrollAxisDirection(w.y,i.top,i.bottom-(x?.footerHeight??0),24),o=n.computeNextScrollPosition(e.scrollTop,a,18,e.scrollHeight-e.clientHeight);o!==e.scrollTop&&e.scrollTo({top:o,behavior:`auto`})}J(),k=requestAnimationFrame(Y)},X=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,Z=()=>{let e=x?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of v(e))t.set(X(n,Number(n.getAttribute(`data-row-index`))),n.getBoundingClientRect().top);for(let n of y(e))t.set(n.key,n.el.getBoundingClientRect().top);return t},Q=t=>{k!==null&&(cancelAnimationFrame(k),k=null),document.body.style.cursor=``,B(),U();let n=S,r=C,i=j;W(n,!1),S=null,j=null,C=null,T=null,O=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=t&&n!==null&&a!==null&&x!==null,s=M;M=null;let c=s&&o&&x!==null&&!g(x.scrollContainerRef.current)?Z():null,l=P;if(P=null,l&&(o?l.forEach(b):(l.forEach(e=>{e.isConnected&&(e.style.transition=m,e.style.transform=`translateY(0px)`,e.style.zIndex=``)}),window.setTimeout(()=>{l.forEach(e=>{P?.has(e)||b(e)})},200))),s)if(o)s.forEach(({baseY:e},t)=>{t.style.transition=``,t.style.willChange=``,t.isConnected&&(t.style.transform=`translateY(${e}px)`)});else{let e=[];s.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=m,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}if(!o||n===null||a===null||x===null)return;let u=c??(g(x.scrollContainerRef.current)?null:Z()),d=u?{tops:u,from:n,to:a,row:i}:null;A=d,x.commitRowMove(n,a),d&&requestAnimationFrame(()=>{A===d&&(A=null)})},$=()=>{let e=A;if(A=null,!e)return;let t=x?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(x?.locateDragRow&&e.row!==null&&x.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;v(t).forEach(e=>{let t=n.get(X(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=_.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(y(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 ${f}ms ${p}`,e.style.transform=`translateY(${s.get(e)??0}px)`;for(let e of c)e.style.transition=`transform ${f}ms ${p}`,e.style.transform=`translateY(0px)`;window.setTimeout(()=>{for(let e of o)e.style.transition=``,e.style.willChange=``;for(let e of c)P?.has(e)||b(e)},280)}},ee=(e,t)=>{if(x===null||!x.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),x.gridRootRef?.current?.focus({preventScroll:!0}),S!==null){if(t.pointerId!==O)return;D?.(),Q(!1)}S=e,j=x.getDragRow?.(e)??null,O=t.pointerId,C=null,w={x:t.clientX,y:t.clientY},T={x:t.clientX,y:t.clientY},E=!1,document.body.style.cursor=`grabbing`,F()?(M=G(),N=x.scrollContainerRef.current?.scrollTop??0):V(x.getRowDragLabel(e)),W(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&(w={x:e.clientX,y:e.clientY},J())},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(),D=null;try{n.releasePointerCapture(r)}catch{}};function c(e){e.pointerId===r&&(s(),Q(!0))}function l(e){e.pointerId===r&&(s(),Q(!1))}function u(e){e.key===`Escape`&&(s(),Q(!1))}function d(){s(),Q(!1)}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,l),window.addEventListener(`keydown`,u,!0),window.addEventListener(`blur`,d),D=s,J(),k=requestAnimationFrame(Y)},te=e=>{if(S===null||j==null||x?.locateDragRow===void 0)return;let t=x.locateDragRow(j,S);if(M&&M.forEach((e,t)=>{if(!t.isConnected){M?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`));if(n===e.index&&(e.applied===void 0||t.style.transform===e.applied))return;let r=_.exec(t.style.transform);if(!r){M?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){D?.(),Q(!1);return}M&&t!==S&&T!==null&&e!==null&&(T={x:T.x,y:T.y+x.rowMetrics.rowTop(t)-e.rowTop(S)}),t!==S&&(W(null,!1),S=t,W(t,!0)),J()};return{update:e=>{let t=x;x=e,S!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&te(t.rowMetrics)},onRowDragHandlePointerDown:ee,applyReorderSettle:$,dispose:()=>{D?.(),D=null,k!==null&&(cancelAnimationFrame(k),k=null),document.body.style.cursor=``,U(),W(S,!1),S=null,j=null,C=null,M=null,P?.forEach(b),P=null,A=null}}};exports.createRowDragController=x;
|