@ishibashi0112/spreadsheet-grid-core 1.2.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.js +79 -71
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.js +75 -73
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.js +63 -61
- package/dist/controllers/detailRowController.cjs +1 -1
- package/dist/controllers/detailRowController.js +60 -59
- package/dist/controllers/detailTabOrder.cjs +1 -1
- package/dist/controllers/detailTabOrder.js +17 -16
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +4 -1
- package/dist/controllers/editController.js +163 -91
- package/dist/controllers/escapeClaimController.cjs +1 -1
- package/dist/controllers/escapeClaimController.js +23 -19
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +107 -106
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +1 -0
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +87 -76
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +3 -0
- package/dist/controllers/keyboardController.js +15 -13
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +3 -0
- package/dist/controllers/popoverSupport.js +62 -41
- package/dist/controllers/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.js +74 -73
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.d.ts +1 -1
- package/dist/controllers/tooltipController.js +122 -97
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.js +55 -54
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.d.ts +2 -1
- package/dist/engine/columnCommands.js +98 -67
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +2 -2
- package/dist/engine/gridApi.cjs +6 -5
- package/dist/engine/gridApi.d.ts +1 -0
- package/dist/engine/gridApi.js +151 -143
- package/dist/engine/rowSelectionCommands.cjs +1 -1
- package/dist/engine/rowSelectionCommands.d.ts +5 -0
- package/dist/engine/rowSelectionCommands.js +73 -38
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +2 -2
- package/dist/logic/contextMenuTarget.cjs +1 -1
- package/dist/logic/contextMenuTarget.d.ts +20 -2
- package/dist/logic/contextMenuTarget.js +62 -3
- package/dist/logic/dateFilterCondition.cjs +1 -1
- package/dist/logic/dateFilterCondition.d.ts +1 -0
- package/dist/logic/dateFilterCondition.js +17 -13
- package/dist/logic/detailRow.cjs +1 -1
- package/dist/logic/detailRow.d.ts +2 -1
- package/dist/logic/detailRow.js +19 -18
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.d.ts +5 -0
- package/dist/logic/domGuards.js +11 -1
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.d.ts +1 -0
- package/dist/logic/editorValues.js +10 -7
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +1 -0
- package/dist/logic/gridState.js +19 -16
- package/dist/logic/localeText.cjs +1 -1
- package/dist/logic/localeText.js +2 -2
- package/dist/logic/rowDragTarget.cjs +1 -0
- package/dist/logic/rowDragTarget.d.ts +14 -0
- package/dist/logic/rowDragTarget.js +47 -0
- package/dist/logic/selectEditorState.d.ts +4 -4
- package/dist/logic/valueFormatters.d.ts +8 -3
- package/dist/model/gridTypes.core.d.ts +31 -12
- package/dist/utils/clipboard.cjs +4 -4
- package/dist/utils/clipboard.js +60 -59
- package/dist/utils/popupContainer.cjs +1 -1
- package/dist/utils/popupContainer.js +35 -28
- package/dist/utils/shadowDom.cjs +1 -0
- package/dist/utils/shadowDom.d.ts +5 -0
- package/dist/utils/shadowDom.js +33 -0
- package/package.json +1 -1
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { gridActions as e } from "../model/gridActions.js";
|
|
2
|
-
import { getCellValue as t,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { getCellValue as t, isCellEditable as n, isViewCellEditable as r } from "../utils/permissions.js";
|
|
3
|
+
import { getActiveElement as i } from "../utils/shadowDom.js";
|
|
4
|
+
import { findViewRowIndexByKey as a, isFocusInsideDetailCard as o, resolveFirstDataColIndex as s } from "../logic/detailRow.js";
|
|
5
|
+
import { clamp as c } from "../logic/geometry.js";
|
|
6
|
+
import { isUnchangedEditorCommit as l, parseCommittedValue as u, writeRowsCell as d } from "../logic/editorValues.js";
|
|
7
|
+
import { decideCellWrite as f } from "../logic/validation.js";
|
|
7
8
|
//#region src/controllers/editController.ts
|
|
8
|
-
var
|
|
9
|
-
if (
|
|
10
|
-
let t = e.ownerDocument, n =
|
|
9
|
+
var p = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection, m = (e) => {
|
|
10
|
+
if (o(e)) return !1;
|
|
11
|
+
let t = e.ownerDocument, n = i(e);
|
|
11
12
|
return n === null || n === t.body || n === t.documentElement || e.contains(n);
|
|
12
|
-
},
|
|
13
|
+
}, h = (e) => {
|
|
14
|
+
let t = e.ownerDocument, n = i(e);
|
|
15
|
+
return n === null || n === t.body || n === t.documentElement;
|
|
16
|
+
}, g = (e) => {
|
|
13
17
|
if (e === null) return !1;
|
|
14
|
-
let t = e
|
|
15
|
-
return t !== null && t !== e && e.contains(t) && typeof t.closest == "function" && t.closest(".ssg-cell-editor") !== null && !
|
|
16
|
-
},
|
|
17
|
-
let i = null,
|
|
18
|
+
let t = i(e);
|
|
19
|
+
return t !== null && t !== e && e.contains(t) && typeof t.closest == "function" && t.closest(".ssg-cell-editor") !== null && !o(e);
|
|
20
|
+
}, _ = () => {
|
|
21
|
+
let i = null, o = null, _ = null, v = null, y = !1, b = !1, x = null, S = (e, t) => {
|
|
18
22
|
let n = e.visibleColumns[t.col];
|
|
19
23
|
return !n || t.row < 0 || t.row >= e.rowModel.getRowCount() || e.rowModel.getRow(t.row) === void 0 ? null : {
|
|
20
24
|
rowKey: e.rowModel.getRowKey(t.row),
|
|
21
25
|
columnKey: n.key
|
|
22
26
|
};
|
|
23
|
-
},
|
|
27
|
+
}, C = (e, t) => {
|
|
24
28
|
let n = e.visibleColumns.findIndex((e) => e.key === t.columnKey);
|
|
25
29
|
if (n < 0) return null;
|
|
26
30
|
let r = e.rowModel.getRowCount();
|
|
@@ -29,131 +33,199 @@ var d = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection,
|
|
|
29
33
|
col: n
|
|
30
34
|
};
|
|
31
35
|
return null;
|
|
32
|
-
},
|
|
36
|
+
}, w = (t) => {
|
|
33
37
|
i = t;
|
|
34
38
|
let n = t.uiState.editingCell;
|
|
35
39
|
if (!n) {
|
|
36
|
-
|
|
40
|
+
o = null, x = null;
|
|
37
41
|
return;
|
|
38
42
|
}
|
|
39
|
-
let r =
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
...
|
|
43
|
+
let r = S(t, n);
|
|
44
|
+
if (o !== null && r !== null && Object.is(r.rowKey, o.rowKey) && r.columnKey === o.columnKey) {
|
|
45
|
+
o = {
|
|
46
|
+
...o,
|
|
43
47
|
cell: n
|
|
44
48
|
};
|
|
45
49
|
return;
|
|
46
50
|
}
|
|
47
|
-
let a =
|
|
48
|
-
if (
|
|
49
|
-
|
|
51
|
+
let a = o !== null && o.cell.row === n.row && o.cell.col === n.col;
|
|
52
|
+
if (o === null || !a) {
|
|
53
|
+
o = r ? {
|
|
50
54
|
...r,
|
|
51
55
|
cell: n
|
|
52
|
-
} : null;
|
|
56
|
+
} : null, _ !== null && (_.superseded = !0, _ = null, t.editorActionGuardRef.current = !1);
|
|
53
57
|
return;
|
|
54
58
|
}
|
|
55
|
-
let
|
|
56
|
-
|
|
57
|
-
...
|
|
58
|
-
cell:
|
|
59
|
-
}, t.dispatch(e.retargetEdit(
|
|
60
|
-
|
|
59
|
+
let s = C(t, o);
|
|
60
|
+
if (s) o = {
|
|
61
|
+
...o,
|
|
62
|
+
cell: s
|
|
63
|
+
}, t.dispatch(e.retargetEdit(s, t.rowModel.getRowCount()));
|
|
64
|
+
else {
|
|
65
|
+
let e = o;
|
|
66
|
+
o = null, T(t, e);
|
|
67
|
+
}
|
|
68
|
+
}, T = (t, n) => {
|
|
69
|
+
if (t.editorActionGuardRef.current) {
|
|
70
|
+
t.dispatch(e.stopEdit());
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
let r = t.visibleColumns.find((e) => e.key === n.columnKey), i = r === void 0 || t.applyServerSideCellEdits !== void 0 || t.onRowsChange === void 0 ? -1 : E(t, n.rowKey);
|
|
74
|
+
v = r !== void 0 && i >= 0 ? {
|
|
75
|
+
sourceIndex: i,
|
|
76
|
+
column: r,
|
|
77
|
+
cell: n.cell,
|
|
78
|
+
rowKey: n.rowKey
|
|
79
|
+
} : null, y = !1;
|
|
80
|
+
let a = x;
|
|
81
|
+
x = null, b = !0;
|
|
82
|
+
let o;
|
|
83
|
+
try {
|
|
84
|
+
a !== null && (a(), v = null), o = M();
|
|
85
|
+
} finally {
|
|
86
|
+
b = !1, v = null;
|
|
87
|
+
}
|
|
88
|
+
let s = t.gridRootRef.current;
|
|
89
|
+
if (!o && s !== null && s.isConnected && h(s) && (s.focus({ preventScroll: !0 }), o = !0), y && t.editorActionGuardRef.current) {
|
|
90
|
+
y = !1;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
y = !1, t.editorActionGuardRef.current = !0, t.dispatch(e.stopEdit()), j(null, null, void 0, o);
|
|
94
|
+
}, E = (e, t) => {
|
|
95
|
+
let { rows: n, rowKeyGetter: r } = e;
|
|
96
|
+
for (let e = 0; e < n.length; e += 1) {
|
|
97
|
+
let i = n[e];
|
|
98
|
+
if (i !== void 0 && Object.is(r ? r(i, e) : e, t)) return e;
|
|
99
|
+
}
|
|
100
|
+
return -1;
|
|
101
|
+
}, D = (e, r, i) => {
|
|
102
|
+
let { rows: a, onRowsChange: o } = e, s = a[r.sourceIndex];
|
|
103
|
+
if (s === void 0 || o === void 0 || !n({
|
|
104
|
+
readOnly: e.readOnly,
|
|
105
|
+
canEditCell: e.canEditCell
|
|
106
|
+
}, r.cell.row, r.cell.col, s, r.column, {
|
|
107
|
+
sourceRowIndex: r.sourceIndex,
|
|
108
|
+
rowKey: r.rowKey
|
|
109
|
+
})) return { status: "noop" };
|
|
110
|
+
if (l(r.column, t(s, r.column), i)) return { status: "committed" };
|
|
111
|
+
let c = u(r.column, i, s);
|
|
112
|
+
return f(r.column, s, c, e.localeTexts).action === "reject" ? { status: "noop" } : (o(d(a, r.sourceIndex, r.column, c)), { status: "committed" });
|
|
113
|
+
}, O = (t) => {
|
|
61
114
|
i !== null && (i.dispatch(e.startSelection(t)), i.dispatch(e.endSelection()), i.dispatch(e.activateCell(t)));
|
|
62
|
-
},
|
|
115
|
+
}, k = (t, n) => {
|
|
63
116
|
i !== null && (i.setEditorInitialValue(n), i.dispatch(e.startEdit(t)));
|
|
64
|
-
},
|
|
65
|
-
let r = e.getRowCount(), i =
|
|
117
|
+
}, A = (e, t, n) => {
|
|
118
|
+
let r = e.getRowCount(), i = c(t, 0, Math.max(r - 1, 0)), { getLabelRow: a } = e;
|
|
66
119
|
if (a && n !== void 0 && i !== n) {
|
|
67
120
|
let e = i > n ? 1 : -1;
|
|
68
121
|
for (; i >= 0 && i < r && a(i);) i += e;
|
|
69
|
-
(i < 0 || i >= r) && (i =
|
|
122
|
+
(i < 0 || i >= r) && (i = c(n, 0, Math.max(r - 1, 0)));
|
|
70
123
|
}
|
|
71
124
|
return i;
|
|
72
|
-
},
|
|
73
|
-
let
|
|
74
|
-
if (
|
|
75
|
-
let l = !1, u =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (u
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
125
|
+
}, j = (e, t = null, n, r = !1, o) => {
|
|
126
|
+
let s = i;
|
|
127
|
+
if (s === null) return;
|
|
128
|
+
let l = !1, u = { superseded: !1 };
|
|
129
|
+
_ = u;
|
|
130
|
+
let d = s.uiState.editingCell, f = (r) => {
|
|
131
|
+
if (l) return;
|
|
132
|
+
if (u.superseded) {
|
|
133
|
+
l = !0;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
let f = i === null ? null : i.getUiState?.() ?? null;
|
|
137
|
+
if (f !== null && f.editingCell !== null && f.editingCell !== d) {
|
|
138
|
+
l = !0, _ === u && (_ = null), s.editorActionGuardRef.current = !1;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (!r && (i === null || i.uiState.editingCell !== null)) return;
|
|
142
|
+
l = !0, _ === u && (_ = null);
|
|
143
|
+
let h = s.gridRootRef.current;
|
|
144
|
+
if (h !== null && m(h) && h.focus(), e !== null && i !== null && !(t !== null && p(t, i.uiState))) {
|
|
145
|
+
let t = i.visibleColumns.length, r = o === void 0 ? -1 : a(i.rowModel, o, /* @__PURE__ */ new Map()), s = r >= 0 ? r : A(i.rowModel, e.row, n);
|
|
146
|
+
O({
|
|
147
|
+
row: s,
|
|
148
|
+
col: c(e.col, 0, Math.max(t - 1, 0))
|
|
84
149
|
});
|
|
85
150
|
}
|
|
86
|
-
|
|
151
|
+
s.editorActionGuardRef.current = !1;
|
|
87
152
|
};
|
|
88
|
-
|
|
89
|
-
},
|
|
153
|
+
r && queueMicrotask(() => f(!1)), requestAnimationFrame(() => f(!0));
|
|
154
|
+
}, M = () => {
|
|
90
155
|
let e = i?.gridRootRef.current ?? null;
|
|
91
|
-
return
|
|
156
|
+
return g(e) ? (e.focus({ preventScroll: !0 }), !0) : !1;
|
|
92
157
|
};
|
|
93
158
|
return {
|
|
94
|
-
update:
|
|
95
|
-
activateSingleCell:
|
|
96
|
-
startEditWithValue:
|
|
97
|
-
commitEdit: (
|
|
159
|
+
update: w,
|
|
160
|
+
activateSingleCell: O,
|
|
161
|
+
startEditWithValue: k,
|
|
162
|
+
commitEdit: (n, a) => {
|
|
98
163
|
if (i === null) return { status: "noop" };
|
|
99
|
-
let { uiState:
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
164
|
+
let { uiState: o, visibleColumns: c, rowModel: p, rows: m, applyServerSideCellEdits: h, onRowsChange: g, dispatch: _, editorActionGuardRef: y } = i;
|
|
165
|
+
if (y.current || !o.editingCell) return { status: "noop" };
|
|
166
|
+
if (b) {
|
|
167
|
+
let e = v;
|
|
168
|
+
return v = null, e === null ? { status: "noop" } : D(i, e, n);
|
|
169
|
+
}
|
|
170
|
+
let x = o.editingCell, S = a === "down" ? {
|
|
171
|
+
row: x.row + 1,
|
|
172
|
+
col: x.col
|
|
173
|
+
} : a === "up" ? {
|
|
174
|
+
row: x.row - 1,
|
|
175
|
+
col: x.col
|
|
176
|
+
} : a === "right" ? {
|
|
177
|
+
row: x.row,
|
|
178
|
+
col: x.col + 1
|
|
179
|
+
} : a === "left" ? {
|
|
180
|
+
row: x.row,
|
|
181
|
+
col: Math.max(x.col - 1, s(c))
|
|
182
|
+
} : x, C = c[x.col], w = p.getSourceIndex(x.row), T = h ? p.getRow(x.row) : m[w];
|
|
183
|
+
if (!C || !T) return _(e.stopEdit()), { status: "noop" };
|
|
184
|
+
if (!r({
|
|
116
185
|
readOnly: i.readOnly,
|
|
117
186
|
canEditCell: i.canEditCell
|
|
118
|
-
}, p,
|
|
119
|
-
let
|
|
120
|
-
if (!
|
|
121
|
-
let e =
|
|
187
|
+
}, p, x.row, x.col, T, C)) return y.current = !0, _(e.stopEdit()), j(null), { status: "noop" };
|
|
188
|
+
let E = l(C, t(T, C), n);
|
|
189
|
+
if (!E && h) {
|
|
190
|
+
let e = u(C, n, T), t = f(C, T, e, i.localeTexts);
|
|
122
191
|
if (t.action === "reject") return {
|
|
123
192
|
status: "rejected",
|
|
124
193
|
message: t.message
|
|
125
194
|
};
|
|
126
195
|
h([{
|
|
127
|
-
viewIndex:
|
|
128
|
-
column:
|
|
196
|
+
viewIndex: x.row,
|
|
197
|
+
column: C,
|
|
129
198
|
value: e
|
|
130
199
|
}]);
|
|
131
|
-
} else if (!
|
|
132
|
-
let e =
|
|
200
|
+
} else if (!E && g) {
|
|
201
|
+
let e = u(C, n, T), t = f(C, T, e, i.localeTexts);
|
|
133
202
|
if (t.action === "reject") return {
|
|
134
203
|
status: "rejected",
|
|
135
204
|
message: t.message
|
|
136
205
|
};
|
|
137
|
-
g(
|
|
206
|
+
g(d(m, w, C, e));
|
|
138
207
|
}
|
|
139
|
-
|
|
140
|
-
let O =
|
|
208
|
+
y.current = !0;
|
|
209
|
+
let O = M(), k;
|
|
141
210
|
if (i.followsRow === !0) {
|
|
142
|
-
let e =
|
|
211
|
+
let e = A(p, S.row, x.row);
|
|
143
212
|
(p.getRow(e) != null || p.getLabelRow?.(e) !== void 0) && (k = p.getRowKey(e));
|
|
144
213
|
}
|
|
145
|
-
return
|
|
146
|
-
activeCell:
|
|
147
|
-
selection:
|
|
148
|
-
} : null,
|
|
214
|
+
return j(S, a === void 0 ? {
|
|
215
|
+
activeCell: o.activeCell,
|
|
216
|
+
selection: o.selection
|
|
217
|
+
} : null, x.row, O, k), _(e.stopEdit()), { status: "committed" };
|
|
149
218
|
},
|
|
150
219
|
cancelEdit: () => {
|
|
151
220
|
if (i === null || i.editorActionGuardRef.current) return;
|
|
152
|
-
i.editorActionGuardRef.current = !0;
|
|
153
|
-
let t =
|
|
154
|
-
i.dispatch(e.stopEdit()),
|
|
221
|
+
y = !0, v = null, i.editorActionGuardRef.current = !0;
|
|
222
|
+
let t = M();
|
|
223
|
+
i.dispatch(e.stopEdit()), j(null, null, void 0, t);
|
|
224
|
+
},
|
|
225
|
+
registerDraftFlush: (e) => {
|
|
226
|
+
x = e;
|
|
155
227
|
}
|
|
156
228
|
};
|
|
157
229
|
};
|
|
158
230
|
//#endregion
|
|
159
|
-
export {
|
|
231
|
+
export { _ as createEditController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/shadowDom.cjs");var t=`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover`,n=e=>{if(e===null)return!1;if(e.type!==`cell`)return!0;let{start:t,end:n}=e.range;return t.row!==n.row||t.col!==n.col},r=new WeakSet,i=new WeakSet,a=e=>r.has(e),o=e=>r.has(e)?i.has(e):e.defaultPrevented,s=`data-mantine-stop-propagation`,c=0,l=()=>{c+=1;let e=!1;return()=>{e||(e=!0,--c)}},u=()=>{let t=null,n=!1,a=n=>{if(n.key!==`Escape`||n.isComposing||n.keyCode===229||t===null||r.has(n))return;let a=t.gridRootRef.current,o=e.getEventTarget(n,a);if(a===null||!(o instanceof Element)||c===0&&!t.isClaimedTarget(o,a))return;r.add(n),n.preventDefault();let l=n.preventDefault.bind(n);n.preventDefault=()=>{i.add(n),l()};let u=new Set([o]);n.target instanceof Element&&u.add(n.target);for(let e of u)e.hasAttribute(s)||(e.setAttribute(s,`true`),setTimeout(()=>{e.removeAttribute(s)},0))};return{update:e=>{t=e,!n&&typeof window<`u`&&(window.addEventListener(`keydown`,a,!0),n=!0)},dispose:()=>{n&&=(window.removeEventListener(`keydown`,a,!0),!1)}}};exports.GRID_POPUP_SELECTOR=t,exports.beginEscapeCancelableDrag=l,exports.createEscapeClaimController=u,exports.isClearableSelection=n,exports.isEscapeClaimedByGrid=a,exports.isEscapePreventedInside=o;
|
|
@@ -1,36 +1,40 @@
|
|
|
1
|
+
import { getEventTarget as e } from "../utils/shadowDom.js";
|
|
1
2
|
//#region src/controllers/escapeClaimController.ts
|
|
2
|
-
var
|
|
3
|
+
var t = ".ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover", n = (e) => {
|
|
3
4
|
if (e === null) return !1;
|
|
4
5
|
if (e.type !== "cell") return !0;
|
|
5
6
|
let { start: t, end: n } = e.range;
|
|
6
7
|
return t.row !== n.row || t.col !== n.col;
|
|
7
|
-
},
|
|
8
|
-
|
|
8
|
+
}, r = /* @__PURE__ */ new WeakSet(), i = /* @__PURE__ */ new WeakSet(), a = (e) => r.has(e), o = (e) => r.has(e) ? i.has(e) : e.defaultPrevented, s = "data-mantine-stop-propagation", c = 0, l = () => {
|
|
9
|
+
c += 1;
|
|
9
10
|
let e = !1;
|
|
10
11
|
return () => {
|
|
11
|
-
e || (e = !0, --
|
|
12
|
+
e || (e = !0, --c);
|
|
12
13
|
};
|
|
13
|
-
},
|
|
14
|
-
let
|
|
15
|
-
if (
|
|
16
|
-
let
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
14
|
+
}, u = () => {
|
|
15
|
+
let t = null, n = !1, a = (n) => {
|
|
16
|
+
if (n.key !== "Escape" || n.isComposing || n.keyCode === 229 || t === null || r.has(n)) return;
|
|
17
|
+
let a = t.gridRootRef.current, o = e(n, a);
|
|
18
|
+
if (a === null || !(o instanceof Element) || c === 0 && !t.isClaimedTarget(o, a)) return;
|
|
19
|
+
r.add(n), n.preventDefault();
|
|
20
|
+
let l = n.preventDefault.bind(n);
|
|
21
|
+
n.preventDefault = () => {
|
|
22
|
+
i.add(n), l();
|
|
23
|
+
};
|
|
24
|
+
let u = /* @__PURE__ */ new Set([o]);
|
|
25
|
+
n.target instanceof Element && u.add(n.target);
|
|
26
|
+
for (let e of u) e.hasAttribute(s) || (e.setAttribute(s, "true"), setTimeout(() => {
|
|
27
|
+
e.removeAttribute(s);
|
|
24
28
|
}, 0));
|
|
25
29
|
};
|
|
26
30
|
return {
|
|
27
|
-
update: (
|
|
28
|
-
|
|
31
|
+
update: (e) => {
|
|
32
|
+
t = e, !n && typeof window < "u" && (window.addEventListener("keydown", a, !0), n = !0);
|
|
29
33
|
},
|
|
30
34
|
dispose: () => {
|
|
31
|
-
|
|
35
|
+
n &&= (window.removeEventListener("keydown", a, !0), !1);
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
};
|
|
35
39
|
//#endregion
|
|
36
|
-
export {
|
|
40
|
+
export { t as GRID_POPUP_SELECTOR, l as beginEscapeCancelableDrag, u as createEscapeClaimController, n as isClearableSelection, a as isEscapeClaimedByGrid, o as isEscapePreventedInside };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/valueStore.cjs"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../utils/shadowDom.cjs"),r=require("../logic/valueStore.cjs"),i=require("../logic/autoScrollGeometry.cjs"),a=require("../logic/elementScale.cjs"),o=require("./escapeClaimController.cjs"),s=require("./popoverSupport.cjs"),c=require("../logic/fillHandle.cjs");var l=168,u=84,d=106,f=()=>typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches?d:u,p=8,m={status:`idle`},h=(e,t,n)=>{if(e.valueFormatter)try{return e.valueFormatter({value:n,row:t,column:e})}catch{return String(n??``)}return String(n??``)},g=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e.key===t[n].key),_=500,v=6,y=2,b=e=>{let t=e.currentTarget;if(!(t instanceof Element))return!0;let n=t.getBoundingClientRect();return e.clientX>=n.left-y&&e.clientX<=n.right+y&&e.clientY>=n.top-y&&e.clientY<=n.bottom+y},x=(e,t)=>e===t||e!==void 0&&t!==void 0&&e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),S=(e,t)=>Object.is(e,t)||e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime(),C=(e,t)=>e.length===t.length&&e.every((e,n)=>e.viewIndex===t[n].viewIndex&&e.column.key===t[n].column.key&&S(e.value,t[n].value)),w=()=>{let u=null,d=r.createValueStore(m),y=r.createValueStore(null),S={current:null},w={current:null},T=null,E=null,D=null,O=e=>e?`toggled`:`auto`,k=e=>(n,r,i,a)=>t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},e.rowModel,n,r,i,a),A=()=>{if(D===null||u===null)return;let e=d.getSnapshot();if(e.status===`dragging`&&e.toggled===D.toggled&&(e.target===D.target||e.target!==null&&D.target!==null&&e.target.direction===D.target.direction&&c.isSameFillRange(e.target.range,D.target.range)))return;let t=null;if(D.target!==null){let e=c.previewFillValue({rowModel:u.rowModel,columns:u.columns,source:D.source,target:D.target,request:O(D.toggled),canWriteCell:k(u),getFillValue:u.getFillValue});t=e&&h(e.column,e.row,e.value)||null}d.setSnapshot({status:`dragging`,source:D.source,target:D.target,toggled:D.toggled,previewText:t})},j=()=>{if(D===null||u===null)return;let e=c.resolveFillColumnBounds(u.columns),t=u.hitTest(D.pointer.x,D.pointer.y);e===null||t===null||(D.target=c.resolveFillTarget(D.source,t,u.rowModel.getRowCount(),e),A())},M=()=>{if(D===null||u===null)return;let e=D;e.rafId=requestAnimationFrame(M);let t=u.scrollContainerRef.current;if(!t)return;if(!e.armed){if(!i.hasPointerLeftActivationRadius(e.origin,e.pointer,6))return;e.armed=!0}let n=t.getBoundingClientRect(),r=a.resolveElementScale(t,n),o=i.resolveScrollContentBox({rectLeft:n.left,rectTop:n.top,clientLeft:t.clientLeft,clientTop:t.clientTop,clientWidth:t.clientWidth,clientHeight:t.clientHeight,scale:r}),s=i.computeNextScrollPosition(t.scrollTop,i.resolveAutoScrollAxisDirection(e.pointer.y,i.resolveTopAutoScrollStart(o.top,(u.stickyTopHeight??0)*r.y,24),o.bottom-(u.footerHeight??0),24),18,t.scrollHeight-t.clientHeight),c=i.computeNextScrollPosition(t.scrollLeft,i.resolveAutoScrollAxisDirection(e.pointer.x,o.left,o.right,24),18,t.scrollWidth-t.clientWidth);(s!==t.scrollTop||c!==t.scrollLeft)&&(t.scrollTo({top:s,left:c,behavior:`auto`}),j())},N=(e,t)=>{let n=D;if(n!==null){if(D=null,n.cleanup(),n.rafId!==null&&cancelAnimationFrame(n.rafId),y.setSnapshot(null),d.setSnapshot(m),e&&n.target!==null){E=null,I(n.source,n.target,O(n.toggled),n.activeCell);return}E=e&&t!==void 0&&n.onSquare?{time:t,x:n.origin.x,y:n.origin.y}:null}},P=(t,n)=>{if(u===null)return;let{dispatch:r}=u;r(e.gridActions.startSelection({row:t.startRow,col:t.startCol})),r(e.gridActions.updateSelection({row:t.endRow,col:t.endCol})),r(e.gridActions.endSelection()),r(e.gridActions.activateCell(n??{row:t.startRow,col:t.startCol}))},F=(e,t)=>{let n=[];for(let r=t.startRow;r<=t.endRow;r+=1)n.push(e.getRowKey(r));return n},I=(e,t,n,r)=>{if(u===null||!u.enabled)return;let i=u,a=c.buildFillEdits({rowModel:i.rowModel,columns:i.columns,source:e,target:t,request:n,canWriteCell:k(i),getFillValue:i.getFillValue});if(a.edits.length===0)return;let o=c.unionFillRange(e,t),s=null,l=[],f=null;if(i.isServerSide){if(!i.applyServerSideCellEdits)return;f=F(i.rowModel,o),i.applyServerSideCellEdits(a.edits)}else{if(!i.applyRowsChange)return;let e=c.applyFillEditsToRows(i.rows,i.rowModel,a.edits);if(e===i.rows)return;s=i.rows,l.push(e),i.applyRowsChange(e)}T={source:e,target:t,range:o,previousSource:e,selectionConfirmed:!1,columns:i.columns,viewKey:i.viewKey,request:n,edits:a.edits,baseRows:s,baseRowModel:i.isServerSide?null:i.rowModel,emittedRows:l,rowKeys:f},P(o,r),d.setSnapshot({status:`filled`,range:o,kind:a.kind,seriesAvailable:a.seriesAvailable,menu:null})},L=s.createPopoverWindowBindings({onScroll:e=>{e.target instanceof Node&&S.current?.contains(e.target)||z(!1)},onResize:()=>z(!1),isInside:e=>S.current?.contains(e)===!0||w.current?.contains(e)===!0,onOutsidePointerDown:e=>z(u!==null&&s.isInsideGridRoot(u.gridRootRef,e)),getGridRoot:()=>u?.gridRootRef.current??null,onGridHidden:()=>z(!1),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),z(!0))}}),R=e=>{let t=d.getSnapshot();t.status!==`filled`||t.menu===e||d.setSnapshot({...t,menu:e})},z=e=>{L.detach(),R(null),e&&u!==null&&s.restoreGridFocus(u.gridRootRef)},B=()=>{let e=typeof document<`u`&&S.current?.contains(n.getActiveElement(S.current))===!0;T=null,L.detach(),d.getSnapshot().status===`filled`&&d.setSnapshot(m),e&&u!==null&&s.restoreGridFocus(u.gridRootRef)},V=e=>{let t=d.getSnapshot();if(t.status!==`filled`)return;if(t.menu!==null){z(!0);return}let n=Math.min(e.left,window.innerWidth-l-p);n=Math.max(p,n);let r=e.bottom+4,i=f();r+i>window.innerHeight-p&&(r=Math.max(p,e.top-4-i)),R({top:r,left:n}),L.attach()},H=(e,t)=>{let n=t.rowKeys;if(n===null)return!1;for(let r=0;r<n.length;r+=1)if(e.getRowKey(t.range.startRow+r)!==n[r])return!1;return!0},U=e=>{let n=d.getSnapshot(),r=T;if(z(!0),u===null||r===null||n.status!==`filled`||r.request===e)return;let i=u;if(i.isServerSide){if(!i.applyServerSideCellEdits||!H(i.rowModel,r)){B();return}let t=c.buildFillEdits({rowModel:i.rowModel,columns:r.columns,source:r.source,target:r.target,request:e,canWriteCell:k(i),getFillValue:i.getFillValue});r.request=e,t.edits.length>0&&!C(t.edits,r.edits)&&i.applyServerSideCellEdits(t.edits),r.edits=t.edits,d.setSnapshot({...n,kind:t.kind,menu:null});return}if(!i.amendRowsChange||r.baseRows===null||r.baseRowModel===null){B();return}let a=r.baseRowModel,o=c.buildFillEdits({rowModel:a,columns:r.columns,source:r.source,target:r.target,request:e,canWriteCell:(e,n,r,o)=>t.isViewCellEditable({readOnly:i.readOnly,canEditCell:i.canEditCell},a,e,n,r,o),getFillValue:i.getFillValue});if(r.request=e,!C(o.edits,r.edits)){let e=c.applyFillEditsToRows(r.baseRows,a,o.edits);r.emittedRows.push(e),r.edits=o.edits,i.amendRowsChange(e)}d.setSnapshot({...n,kind:o.kind,menu:null})},W=(e,t)=>{if(e?.type!==`cell`)return!1;let{start:n,end:r}=e.range;return c.isSameFillRange(t,{startRow:Math.min(n.row,r.row),endRow:Math.max(n.row,r.row),startCol:Math.min(n.col,r.col),endCol:Math.max(n.col,r.col)})},G=e=>{let t=T;if(t!==null){if(!e.enabled||e.editing||!g(e.columns,t.columns)||!x(e.viewKey,t.viewKey)){B();return}if(!e.isServerSide&&e.rows!==t.baseRows&&!t.emittedRows.includes(e.rows)){B();return}if(W(e.selection,t.range)){t.selectionConfirmed=!0;return}!t.selectionConfirmed&&W(e.selection,t.previousSource)||B()}},K=e=>{if(u===null||e.button!==0||(e.preventDefault(),D!==null||!u.enabled||u.editing))return;let t=c.resolveFillSource(u.selection,u.activeCell,u.rowModel.getRowCount(),u.columns.length);if(t===null)return;let n=E;E=null;let r=b(e);if(n!==null&&r&&e.timeStamp-n.time<=_&&Math.abs(e.clientX-n.x)<=v&&Math.abs(e.clientY-n.y)<=v){u.gridRootRef.current?.focus({preventScroll:!0}),q();return}B(),u.gridRootRef.current?.focus({preventScroll:!0});let i=e.pointerId,a=e=>{D===null||e.pointerId!==i||(D.pointer={x:e.clientX,y:e.clientY},D.toggled=e.ctrlKey||e.metaKey,y.setSnapshot(D.pointer),j())},s=e=>{D===null||e.pointerId!==i||(D.toggled=e.ctrlKey||e.metaKey,N(!0,e.timeStamp))},l=e=>{e.pointerId===i&&N(!1)},d=e=>{if(D===null)return;if(e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&e.key===`Escape`){N(!1);return}let t=e.ctrlKey||e.metaKey;t!==D.toggled&&(D.toggled=t,A())},f=()=>N(!1);window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,l),window.addEventListener(`keydown`,d,!0),window.addEventListener(`keyup`,d,!0),window.addEventListener(`blur`,f);let p=o.beginEscapeCancelableDrag(),m={x:e.clientX,y:e.clientY};D={pointerId:i,source:t,activeCell:u.activeCell,origin:m,onSquare:r,pointer:m,toggled:e.ctrlKey||e.metaKey,target:null,armed:!1,rafId:null,cleanup:()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,l),window.removeEventListener(`keydown`,d,!0),window.removeEventListener(`keyup`,d,!0),window.removeEventListener(`blur`,f),p()}},y.setSnapshot(m),A(),D.rafId=requestAnimationFrame(M)},q=()=>{if(u===null||D!==null||!u.enabled||u.editing)return;let e=c.resolveFillSource(u.selection,u.activeCell,u.rowModel.getRowCount(),u.columns.length);if(e===null)return;let t=c.resolveFillDoubleClickTarget(e,u.rowModel,u.columns);t!==null&&(B(),I(e,t,`auto`,u.activeCell))};return{update:e=>{u=e,D!==null&&(!e.enabled||e.editing)&&N(!1),G(e)},subscribe:d.subscribe,getSnapshot:d.getSnapshot,subscribePointer:y.subscribe,getPointerSnapshot:y.getSnapshot,handlePointerDown:K,handleDoubleClick:q,toggleMenu:V,closeMenu:()=>z(!0),chooseKind:U,menuPanel:S,chipElement:w,dispose:()=>{N(!1),L.detach(),T=null}}};exports.createFillHandleController=w;
|