@ishibashi0112/spreadsheet-grid-core 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/controllers/clipboardController.cjs +4 -4
- package/dist/controllers/clipboardController.d.ts +5 -0
- package/dist/controllers/clipboardController.js +211 -139
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +3 -0
- package/dist/controllers/editController.js +104 -85
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +5 -4
- package/dist/controllers/findReplaceController.cjs +1 -1
- package/dist/controllers/findReplaceController.d.ts +1 -0
- package/dist/controllers/findReplaceController.js +1 -1
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +1 -0
- package/dist/controllers/historyController.js +8 -2
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +8 -0
- package/dist/controllers/keyboardController.js +115 -57
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +61 -53
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +2 -1
- package/dist/controllers/viewportSyncController.js +4 -4
- package/dist/engine/cellCommands.cjs +1 -1
- package/dist/engine/cellCommands.d.ts +1 -0
- package/dist/engine/cellCommands.js +19 -9
- package/dist/engine/cellSpanController.cjs +2 -0
- package/dist/engine/cellSpanController.d.ts +42 -0
- package/dist/engine/cellSpanController.js +253 -0
- package/dist/engine/createGridEngine.cjs +3 -3
- package/dist/engine/createGridEngine.d.ts +4 -0
- package/dist/engine/createGridEngine.js +35 -28
- package/dist/engine/exportCommands.cjs +2 -2
- package/dist/engine/exportCommands.js +104 -71
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +12 -0
- package/dist/engine/features.js +35 -1
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +31 -27
- package/dist/engine/gridApi.cjs +10 -10
- package/dist/engine/gridApi.d.ts +10 -0
- package/dist/engine/gridApi.js +504 -333
- package/dist/engine/newRowController.cjs +1 -1
- package/dist/engine/newRowController.js +3 -1
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +4 -0
- package/dist/engine/notifiers.js +39 -27
- package/dist/engine/paginationController.cjs +1 -0
- package/dist/engine/paginationController.d.ts +38 -0
- package/dist/engine/paginationController.js +162 -0
- package/dist/engine/rowSelectionCommands.cjs +1 -1
- package/dist/engine/rowSelectionCommands.d.ts +1 -0
- package/dist/engine/rowSelectionCommands.js +10 -10
- package/dist/engine/verticalLayout.cjs +1 -1
- package/dist/engine/verticalLayout.d.ts +1 -0
- package/dist/engine/verticalLayout.js +1 -0
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +9 -0
- package/dist/logic/cellRef.cjs +1 -1
- package/dist/logic/cellRef.js +1 -1
- package/dist/logic/cellSpanLayout.cjs +1 -0
- package/dist/logic/cellSpanLayout.d.ts +48 -0
- package/dist/logic/cellSpanLayout.js +147 -0
- package/dist/logic/cellSpans.cjs +1 -0
- package/dist/logic/cellSpans.d.ts +49 -0
- package/dist/logic/cellSpans.js +301 -0
- package/dist/logic/changeTracking.cjs +1 -1
- package/dist/logic/changeTracking.d.ts +6 -0
- package/dist/logic/changeTracking.js +23 -9
- package/dist/logic/clipboardHtml.cjs +1 -1
- package/dist/logic/clipboardHtml.d.ts +5 -0
- package/dist/logic/clipboardHtml.js +27 -25
- package/dist/logic/contextMenuTarget.cjs +1 -1
- package/dist/logic/contextMenuTarget.js +72 -48
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +2 -1
- package/dist/logic/exportData.js +35 -35
- package/dist/logic/featureWarnings.cjs +1 -1
- package/dist/logic/featureWarnings.js +2 -1
- package/dist/logic/fillHandle.cjs +1 -1
- package/dist/logic/fillHandle.js +21 -21
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +6 -1
- package/dist/logic/gridState.js +6 -6
- package/dist/logic/localeText.cjs +1 -1
- package/dist/logic/localeText.d.ts +1 -0
- package/dist/logic/localeText.js +1 -0
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +10 -0
- package/dist/logic/localeTextFeatures.js +10 -1
- package/dist/logic/pagination.cjs +1 -0
- package/dist/logic/pagination.d.ts +55 -0
- package/dist/logic/pagination.js +192 -0
- package/dist/logic/rowDragTarget.cjs +1 -1
- package/dist/logic/rowDragTarget.d.ts +1 -1
- package/dist/logic/rowDragTarget.js +10 -10
- package/dist/logic/scrollHint.cjs +1 -1
- package/dist/logic/scrollHint.d.ts +2 -1
- package/dist/logic/scrollHint.js +5 -5
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +10 -0
- package/dist/model/gridActions.js +10 -1
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +32 -0
- package/dist/model/gridStore.cjs +1 -1
- package/dist/model/gridStore.d.ts +1 -0
- package/dist/model/gridStore.js +1 -1
- package/dist/model/gridTypes.core.d.ts +189 -11
- package/dist/utils/pagerFocus.cjs +1 -0
- package/dist/utils/pagerFocus.d.ts +1 -0
- package/dist/utils/pagerFocus.js +15 -0
- package/dist/utils/permissions.cjs +1 -1
- package/dist/utils/permissions.d.ts +1 -1
- package/dist/utils/permissions.js +1 -1
- package/package.json +1 -1
|
@@ -8,25 +8,29 @@ import { formatCellClipboardText as d } from "../logic/selectLabels.js";
|
|
|
8
8
|
import { clamp as f } from "../logic/geometry.js";
|
|
9
9
|
import { shouldIgnoreGridKeydown as p } from "../logic/domGuards.js";
|
|
10
10
|
import { resolveCellParser as m } from "../logic/editorValues.js";
|
|
11
|
-
import { applyClipboardMatrixToRows as h, buildClipboardCellEdits as g, buildClipboardHeaderText as _, filterClipboardColumns as v, formatClipboardCell as y, joinTsvLines as b, joinTsvRow as x, parseClipboardText as ee, resolveClipboardHeaderLayout as S, resolvePasteColumnIndexes as te, serializeSelectionToTsv as C, writeTextToClipboard as
|
|
12
|
-
import { findFirstPasteRow as
|
|
13
|
-
import { getSelectableRowCount as
|
|
14
|
-
import { expandPasteMatrixToSelection as
|
|
15
|
-
import { buildClearCellEdits as
|
|
16
|
-
import { isEditingAtEvent as
|
|
11
|
+
import { applyClipboardMatrixToRows as h, buildClipboardCellEdits as g, buildClipboardHeaderText as _, filterClipboardColumns as v, formatClipboardCell as y, joinTsvLines as b, joinTsvRow as x, parseClipboardText as ee, resolveClipboardHeaderLayout as S, resolvePasteColumnIndexes as te, serializeSelectionToTsv as C, writeTextToClipboard as ne } from "../utils/clipboard.js";
|
|
12
|
+
import { findFirstPasteRow as re, resolvePasteTargetViewIndexes as ie } from "../logic/labelRows.js";
|
|
13
|
+
import { getSelectableRowCount as ae } from "../logic/newRow.js";
|
|
14
|
+
import { expandPasteMatrixToSelection as oe } from "../logic/pasteFill.js";
|
|
15
|
+
import { buildClearCellEdits as se, clearCellsInSelection as ce, resolveClearTarget as w } from "../logic/clearCells.js";
|
|
16
|
+
import { isEditingAtEvent as le, readLiveUiState as ue } from "./liveUiState.js";
|
|
17
17
|
//#region src/controllers/clipboardController.ts
|
|
18
|
-
var
|
|
18
|
+
var T = (e, t) => {
|
|
19
|
+
if (!e?.active || t === null || t.type !== "cell") return !1;
|
|
20
|
+
let { start: n, end: r } = t.range, i = Math.min(n.row, r.row), a = Math.min(n.col, r.col), o = e.getSpan(i, a);
|
|
21
|
+
return o !== null && o.top === i && o.left === a && o.bottom === Math.max(n.row, r.row) && o.right === Math.max(n.col, r.col);
|
|
22
|
+
}, E = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), D = (e) => {
|
|
19
23
|
let t = 2166136261;
|
|
20
24
|
for (let n = 0; n < e.length; n += 1) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
21
25
|
return t >>> 0;
|
|
22
|
-
},
|
|
26
|
+
}, de = (e) => {
|
|
23
27
|
let t = o(e instanceof Node ? e : null);
|
|
24
28
|
return t instanceof HTMLElement && t !== t.ownerDocument.body ? t : e;
|
|
25
|
-
},
|
|
29
|
+
}, O = (e, t, n) => {
|
|
26
30
|
if (t === 0 || n === 0 || e?.type !== "cell") return !1;
|
|
27
31
|
let { start: r, end: i } = e.range, a = Math.min(r.row, i.row), o = Math.min(r.col, i.col), s = Math.max(r.row, i.row), c = Math.max(r.col, i.col);
|
|
28
32
|
return a === 0 && o === 0 && s === t - 1 && c === n - 1;
|
|
29
|
-
},
|
|
33
|
+
}, fe = (e, t) => {
|
|
30
34
|
if (e?.type === "cell") {
|
|
31
35
|
let n = c(e.range);
|
|
32
36
|
return t.row >= n.start.row && t.row <= n.end.row && t.col >= n.start.col && t.col <= n.end.col ? n.start : t;
|
|
@@ -38,7 +42,34 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
38
42
|
row: Math.min(e.startRow, e.endRow),
|
|
39
43
|
col: 0
|
|
40
44
|
} : t;
|
|
41
|
-
},
|
|
45
|
+
}, pe = (e, n, r, i, a, o) => {
|
|
46
|
+
let s = e.cellSpans?.current();
|
|
47
|
+
if (!s?.active) return null;
|
|
48
|
+
let { rowModel: c, visibleColumns: l } = e, u = e.localeTexts?.multiSelectSeparator, f = /* @__PURE__ */ new Map();
|
|
49
|
+
for (let e = 0; e < n.length; e += 1) f.set(a(r + e), e);
|
|
50
|
+
let p = (e, n) => {
|
|
51
|
+
let r = c.getRow(e), i = l[n];
|
|
52
|
+
return r == null || i === void 0 ? "" : d(i, t(r, i), r, u);
|
|
53
|
+
}, m = null;
|
|
54
|
+
for (let e = 0; e < n.length; e += 1) {
|
|
55
|
+
let t = a(r + e);
|
|
56
|
+
if (t >= o) continue;
|
|
57
|
+
let c = n[e];
|
|
58
|
+
for (let e = 0; e < c.length; e += 1) {
|
|
59
|
+
let r = i[e];
|
|
60
|
+
if (r === void 0) continue;
|
|
61
|
+
let a = s.getSpan(t, r);
|
|
62
|
+
if (a === null || a.top === t && a.left === r) continue;
|
|
63
|
+
let o;
|
|
64
|
+
if (a.left === a.right) {
|
|
65
|
+
let t = f.get(a.top);
|
|
66
|
+
o = (t === void 0 ? void 0 : n[t][e]) ?? p(a.top, a.left);
|
|
67
|
+
} else o = p(t, r);
|
|
68
|
+
(m ??= /* @__PURE__ */ new Map()).set(`${t}:${r}`, o);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return m;
|
|
72
|
+
}, me = (e, t) => {
|
|
42
73
|
let n, r;
|
|
43
74
|
if (e?.type === "cell") n = Math.min(e.range.start.row, e.range.end.row), r = Math.max(e.range.start.row, e.range.end.row);
|
|
44
75
|
else if (e?.type === "row") n = Math.min(e.startRow, e.endRow), r = Math.max(e.startRow, e.endRow);
|
|
@@ -46,30 +77,30 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
46
77
|
r = Math.min(r, t.getRowCount() - 1);
|
|
47
78
|
for (let e = Math.max(n, 0); e <= r; e += 1) if (t.getRow(e) == null && t.getLabelRow?.(e) === void 0) return !0;
|
|
48
79
|
return !1;
|
|
49
|
-
},
|
|
50
|
-
let
|
|
80
|
+
}, he = (e, t, n, r) => {
|
|
81
|
+
let i = {
|
|
51
82
|
row: e.row,
|
|
52
83
|
rowKey: n,
|
|
53
|
-
rowIndex: t,
|
|
84
|
+
rowIndex: t + (r ?? 0),
|
|
54
85
|
columnKey: e.column.key,
|
|
55
86
|
colIndex: e.colIndex,
|
|
56
87
|
text: e.text,
|
|
57
88
|
reason: e.reason
|
|
58
89
|
};
|
|
59
|
-
return e.reason === "invalid" && (
|
|
60
|
-
},
|
|
61
|
-
let o = null,
|
|
90
|
+
return e.reason === "invalid" && (i.value = e.value, i.message = e.message), i;
|
|
91
|
+
}, k = () => {
|
|
92
|
+
let o = null, k = (e) => {
|
|
62
93
|
o = e;
|
|
63
|
-
},
|
|
94
|
+
}, A = (e) => {
|
|
64
95
|
let { isRowExportable: t, rowModel: n } = e;
|
|
65
96
|
if (t) return (e, r) => t(e, {
|
|
66
97
|
viewRowIndex: r,
|
|
67
98
|
rowKey: n.getRowKey(r) ?? r
|
|
68
99
|
});
|
|
69
|
-
},
|
|
100
|
+
}, ge = (e) => {
|
|
70
101
|
let { rowModel: t } = e, n = v(e.visibleColumns), r = t.getRowCount();
|
|
71
102
|
if (r === 0 || n.length === 0) return "";
|
|
72
|
-
let i =
|
|
103
|
+
let i = A(e), a = e.localeTexts?.multiSelectSeparator, o = [];
|
|
73
104
|
for (let e = 0; e < r; e += 1) {
|
|
74
105
|
let r = t.getRow(e);
|
|
75
106
|
if (!r || i && !i(r, e)) continue;
|
|
@@ -77,10 +108,10 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
77
108
|
o.push(x(n.map((e) => s !== void 0 && e.key in s ? d(e, s[e.key], r, a) : y(r, e, a))));
|
|
78
109
|
}
|
|
79
110
|
return b(o);
|
|
80
|
-
},
|
|
111
|
+
}, j = (e, t) => {
|
|
81
112
|
if (!t) return null;
|
|
82
113
|
let { rowModel: n, visibleColumns: r } = e, i = n.getRowCount() - 1;
|
|
83
|
-
if (
|
|
114
|
+
if (O(t, ae(n), r.length)) return {
|
|
84
115
|
columns: v(r),
|
|
85
116
|
startRow: 0,
|
|
86
117
|
endRow: i
|
|
@@ -107,13 +138,13 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
107
138
|
startRow: 0,
|
|
108
139
|
endRow: i
|
|
109
140
|
};
|
|
110
|
-
},
|
|
111
|
-
let r =
|
|
141
|
+
}, M = (e, t, n = !1) => {
|
|
142
|
+
let r = N(e, t);
|
|
112
143
|
if (!n || r === "") return {
|
|
113
144
|
text: r,
|
|
114
145
|
header: null
|
|
115
146
|
};
|
|
116
|
-
let i =
|
|
147
|
+
let i = j(e, t);
|
|
117
148
|
if (i === null || i.columns.length === 0) return {
|
|
118
149
|
text: r,
|
|
119
150
|
header: null
|
|
@@ -123,13 +154,13 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
123
154
|
text: `${a}\n${r}`,
|
|
124
155
|
header: a
|
|
125
156
|
};
|
|
126
|
-
},
|
|
157
|
+
}, N = (e, t) => {
|
|
127
158
|
let { rowModel: n, visibleColumns: r } = e;
|
|
128
|
-
return
|
|
129
|
-
},
|
|
159
|
+
return O(t, ae(n), r.length) ? ge(e) : C(n.getRow, n.getRowCount(), r, t, A(e), n.getTreeRow ? (e) => n.getTreeRow?.(e)?.aggregates : void 0, e.localeTexts?.multiSelectSeparator);
|
|
160
|
+
}, P = (e, t, n) => {
|
|
130
161
|
let { rowModel: r, visibleColumns: i, readOnly: a, onRowsChange: o, applyServerSideCellEdits: s } = e;
|
|
131
162
|
if (a || !o && !s) return;
|
|
132
|
-
let c =
|
|
163
|
+
let c = w(t, null, r.getRowCount(), i.length);
|
|
133
164
|
if (c === null) return;
|
|
134
165
|
let l = [];
|
|
135
166
|
for (let e = c.startRow; e <= c.endRow; e += 1) l.push(r.getRow(e) == null ? void 0 : r.getRowKey(e));
|
|
@@ -141,10 +172,10 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
141
172
|
rowKeys: l,
|
|
142
173
|
columnKeys: u
|
|
143
174
|
};
|
|
144
|
-
},
|
|
145
|
-
let i =
|
|
175
|
+
}, F = (e, t, n, r) => {
|
|
176
|
+
let i = j(e, n);
|
|
146
177
|
if (i === null || i.columns.length === 0 || i.endRow < i.startRow || (i.endRow - i.startRow + 1) * i.columns.length > 2e4) return null;
|
|
147
|
-
let { rowModel: a, visibleColumns: o } = e, s =
|
|
178
|
+
let { rowModel: a, visibleColumns: o } = e, s = A(e), c = [];
|
|
148
179
|
for (let e = i.startRow; e <= i.endRow; e += 1) {
|
|
149
180
|
let t = a.getRow(e);
|
|
150
181
|
!t || s && !s(t, e) || c.push({
|
|
@@ -154,7 +185,22 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
154
185
|
});
|
|
155
186
|
}
|
|
156
187
|
if (c.length === 0) return null;
|
|
157
|
-
let l = e.columnGroupTree ?? null, u = e.getConditionalFormatStats?.(), d =
|
|
188
|
+
let l = e.columnGroupTree ?? null, u = e.getConditionalFormatStats?.(), d, f = e.cellSpans?.current();
|
|
189
|
+
if (f?.active) {
|
|
190
|
+
let e = f.spansIn(c.map((e) => e.viewIndex), i.columns.map((e) => o.indexOf(e)));
|
|
191
|
+
if (e.length > 0) {
|
|
192
|
+
let t = i.columns.length, n = /* @__PURE__ */ new Map();
|
|
193
|
+
for (let r of e) {
|
|
194
|
+
for (let e = r.row; e < r.row + r.rowSpan; e += 1) for (let i = r.col; i < r.col + r.colSpan; i += 1) n.set(e * t + i, "covered");
|
|
195
|
+
n.set(r.row * t + r.col, {
|
|
196
|
+
rowSpan: r.rowSpan,
|
|
197
|
+
colSpan: r.colSpan
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
d = (e, r) => n.get(e * t + r) ?? null;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
let p = t.createClipboardColorResolver(e.getCopyColorHost?.() ?? null);
|
|
158
204
|
try {
|
|
159
205
|
return t.buildClipboardHtml({
|
|
160
206
|
columns: i.columns,
|
|
@@ -165,7 +211,7 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
165
211
|
stats: u,
|
|
166
212
|
chipContext: (t, n, r) => ({
|
|
167
213
|
row: t.row,
|
|
168
|
-
rowIndex: t.viewIndex,
|
|
214
|
+
rowIndex: t.viewIndex + (a.pageStart ?? 0),
|
|
169
215
|
sourceRowIndex: a.getSourceIndex(t.viewIndex) ?? t.viewIndex,
|
|
170
216
|
rowKey: a.getRowKey(t.viewIndex) ?? t.viewIndex,
|
|
171
217
|
colIndex: o.indexOf(n),
|
|
@@ -178,46 +224,59 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
178
224
|
})
|
|
179
225
|
} : void 0,
|
|
180
226
|
separator: e.localeTexts?.multiSelectSeparator,
|
|
181
|
-
|
|
227
|
+
spans: d,
|
|
228
|
+
colors: p
|
|
182
229
|
});
|
|
183
230
|
} finally {
|
|
184
|
-
|
|
231
|
+
p.dispose();
|
|
185
232
|
}
|
|
186
|
-
}, L = null,
|
|
233
|
+
}, I = null, L = null, _e = (e, t) => {
|
|
234
|
+
let n = L;
|
|
235
|
+
if (n === null || t.length === 0) return t;
|
|
236
|
+
let r = E(e);
|
|
237
|
+
return r.length !== n.length || D(r) !== n.fingerprint ? t : [[t[0]?.[0] ?? ""]];
|
|
238
|
+
}, R = async (e) => {
|
|
187
239
|
if (o === null) return;
|
|
188
|
-
let t = o, n =
|
|
240
|
+
let t = o, n = ue(t), r = n.selection ?? (n.activeCell ? {
|
|
189
241
|
type: "cell",
|
|
190
242
|
range: {
|
|
191
243
|
start: n.activeCell,
|
|
192
244
|
end: n.activeCell
|
|
193
245
|
}
|
|
194
|
-
} : null), i = r !== null && r.type === "cell" && r.range.start.row === r.range.end.row && r.range.start.col === r.range.end.col,
|
|
195
|
-
if (!
|
|
196
|
-
let
|
|
246
|
+
} : null), i = T(t.cellSpans?.current(), r), a = r !== null && r.type === "cell" && r.range.start.row === r.range.end.row && r.range.start.col === r.range.end.col || i, s = !e && t.copyHeaders === !0 && !a, { text: c, header: l } = M(t, r, s);
|
|
247
|
+
if (!c) return;
|
|
248
|
+
let u = null;
|
|
197
249
|
if (t.richCopy) try {
|
|
198
|
-
|
|
250
|
+
u = F(t, t.richCopy, r, s);
|
|
199
251
|
} catch (e) {
|
|
200
252
|
process.env.NODE_ENV !== "production" && console.error("[SpreadsheetGrid] 書式つきのコピー(copyFormat=\"rich\")の表を作れなかったため、文字だけをコピーしました。\n[SpreadsheetGrid] Could not build the rich copy (copyFormat=\"rich\"); copied the text only.", e);
|
|
201
253
|
}
|
|
202
|
-
if ((t.richCopy &&
|
|
203
|
-
if (
|
|
254
|
+
if ((t.richCopy && u !== null ? await t.richCopy.writeRichToClipboard(c, u) : await ne(c)) && r) {
|
|
255
|
+
if (l === null) I = null;
|
|
204
256
|
else {
|
|
205
|
-
let e =
|
|
206
|
-
|
|
257
|
+
let e = E(c);
|
|
258
|
+
I = {
|
|
207
259
|
selection: r,
|
|
208
|
-
header:
|
|
260
|
+
header: l,
|
|
209
261
|
length: e.length,
|
|
210
|
-
fingerprint:
|
|
262
|
+
fingerprint: D(e)
|
|
211
263
|
};
|
|
212
264
|
}
|
|
213
|
-
|
|
265
|
+
if (i) {
|
|
266
|
+
let e = E(c);
|
|
267
|
+
L = {
|
|
268
|
+
length: e.length,
|
|
269
|
+
fingerprint: D(e)
|
|
270
|
+
};
|
|
271
|
+
} else L = null;
|
|
272
|
+
let n = e ? P(t, r, c) : void 0;
|
|
214
273
|
n === void 0 ? t.onCopied?.(r) : t.onCopied?.(r, n);
|
|
215
274
|
}
|
|
216
|
-
}, z = () => R(!1), B = () => R(!0),
|
|
275
|
+
}, z = () => R(!1), B = () => R(!0), ve = (e, t) => {
|
|
217
276
|
let n = e.getLiveCopiedRange?.() ?? null, r = n?.cut;
|
|
218
277
|
if (n === null || r === void 0) return null;
|
|
219
|
-
let i =
|
|
220
|
-
if (i !==
|
|
278
|
+
let i = E(t);
|
|
279
|
+
if (i !== E(r.text)) return null;
|
|
221
280
|
let { rowModel: a, visibleColumns: o } = e;
|
|
222
281
|
if (r.endRow >= a.getRowCount() || r.endCol >= o.length) return null;
|
|
223
282
|
for (let e = 0; e < r.rowKeys.length; e += 1) {
|
|
@@ -225,15 +284,15 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
225
284
|
if ((a.getRow(t) == null ? void 0 : a.getRowKey(t)) !== r.rowKeys[e]) return null;
|
|
226
285
|
}
|
|
227
286
|
for (let e = 0; e < r.columnKeys.length; e += 1) if (o[r.startCol + e]?.key !== r.columnKeys[e]) return null;
|
|
228
|
-
return
|
|
229
|
-
},
|
|
230
|
-
let t =
|
|
287
|
+
return E(M(e, n.selection).text) === i ? r : null;
|
|
288
|
+
}, ye = (e) => {
|
|
289
|
+
let t = I;
|
|
231
290
|
if (t === null) return e;
|
|
232
|
-
let n =
|
|
233
|
-
if (n.length !== t.length ||
|
|
291
|
+
let n = E(e);
|
|
292
|
+
if (n.length !== t.length || D(n) !== t.fingerprint) return e;
|
|
234
293
|
let r = e.replace(/\r\n?/g, "\n"), i = `${t.header}\n`;
|
|
235
294
|
return r.startsWith(i) ? r.slice(i.length) : e;
|
|
236
|
-
},
|
|
295
|
+
}, be = (e, n, o) => {
|
|
237
296
|
let { rowModel: s, visibleColumns: c, readOnly: l, canEditCell: u } = e;
|
|
238
297
|
for (let f = n.startRow; f <= n.endRow; f += 1) {
|
|
239
298
|
let p = s.getRow(f);
|
|
@@ -258,44 +317,44 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
258
317
|
return !0;
|
|
259
318
|
};
|
|
260
319
|
return {
|
|
261
|
-
update:
|
|
320
|
+
update: k,
|
|
262
321
|
handleCopy: z,
|
|
263
322
|
handleCut: B,
|
|
264
323
|
handlePaste: (t) => {
|
|
265
324
|
if (o === null) return;
|
|
266
|
-
let i = o, { rows: a, rowModel: c, columns: l, visibleColumns: u, readOnly: d, canEditCell: m, rowKeyGetter: _, createRow: v, createOverflowColumn: y, onRowsChange: b, onColumnsChange: x, applyServerSideCellEdits: S, onPasteSkipped: C, localeTexts:
|
|
267
|
-
if (
|
|
268
|
-
let
|
|
269
|
-
if (!
|
|
325
|
+
let i = o, { rows: a, rowModel: c, columns: l, visibleColumns: u, readOnly: d, canEditCell: m, rowKeyGetter: _, createRow: v, createOverflowColumn: y, onRowsChange: b, onColumnsChange: x, applyServerSideCellEdits: S, onPasteSkipped: C, localeTexts: ne, pasteFillsSelection: ae = !0, dispatch: w } = o, T = ue(o);
|
|
326
|
+
if (le(o) || p(de(t.target ?? null)) || d || !b && !S || !T.activeCell) return;
|
|
327
|
+
let E = t.clipboardData?.getData("text/plain") ?? "";
|
|
328
|
+
if (!E) return;
|
|
270
329
|
t.preventDefault();
|
|
271
|
-
let
|
|
272
|
-
if (
|
|
273
|
-
let
|
|
274
|
-
let e =
|
|
330
|
+
let D = ye(E), O = _e(D, ee(D));
|
|
331
|
+
if (O.length === 0) return;
|
|
332
|
+
let k = ve(i, D), ge = ae && k === null ? oe(O, T.selection, T.activeCell, c, u) : null, j = ge !== null && S && me(T.selection, c) ? O : ge ?? O, M = C ? [] : null, N = () => {
|
|
333
|
+
let e = M?.filter((e) => !(e.reason === "readOnly" && e.text === ""));
|
|
275
334
|
e !== void 0 && e.length > 0 && C?.({ cells: e });
|
|
276
|
-
},
|
|
277
|
-
if (
|
|
278
|
-
let
|
|
279
|
-
row:
|
|
280
|
-
col: te(u,
|
|
281
|
-
},
|
|
335
|
+
}, P = j.reduce((e, t) => Math.max(e, t.length), 0);
|
|
336
|
+
if (P === 0) return;
|
|
337
|
+
let F = fe(T.selection, T.activeCell), I = {
|
|
338
|
+
row: re(c, F.row),
|
|
339
|
+
col: te(u, F.col, 1)[0] ?? F.col
|
|
340
|
+
}, L = I.row, R = I.col, z = te(u, R, P), B = z[z.length - 1] ?? R, V = c.getLabelRow !== void 0 || c.getGroupRow !== void 0 ? ie(c, L, j.length) : null, H = (e) => V ? V[e - L] : e, U = V ? V[V.length - 1] : I.row + Math.max(j.length - 1, 0), W = k === null ? null : {
|
|
282
341
|
type: "cell",
|
|
283
342
|
range: {
|
|
284
343
|
start: {
|
|
285
|
-
row:
|
|
286
|
-
col:
|
|
344
|
+
row: k.startRow,
|
|
345
|
+
col: k.startCol
|
|
287
346
|
},
|
|
288
347
|
end: {
|
|
289
|
-
row:
|
|
290
|
-
col:
|
|
348
|
+
row: k.endRow,
|
|
349
|
+
col: k.endCol
|
|
291
350
|
}
|
|
292
351
|
}
|
|
293
|
-
},
|
|
294
|
-
if (
|
|
352
|
+
}, G;
|
|
353
|
+
if (k !== null) {
|
|
295
354
|
let e = /* @__PURE__ */ new Set();
|
|
296
|
-
for (let t = 0; t <
|
|
297
|
-
let t = new Set(
|
|
298
|
-
|
|
355
|
+
for (let t = 0; t < j.length; t += 1) e.add(H(L + t));
|
|
356
|
+
let t = new Set(z), n = A(i);
|
|
357
|
+
G = (r, i) => {
|
|
299
358
|
if (e.has(r) && t.has(i)) return !0;
|
|
300
359
|
let a = u[i];
|
|
301
360
|
if (a === void 0 || s(a.key)) return !0;
|
|
@@ -305,100 +364,113 @@ var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
|
305
364
|
return l !== void 0 && a.key in l ? !0 : n !== void 0 && !n(o, r);
|
|
306
365
|
};
|
|
307
366
|
}
|
|
308
|
-
let
|
|
309
|
-
|
|
310
|
-
},
|
|
367
|
+
let K = k !== null && G !== void 0 && !be(i, k, G), xe = (e) => {
|
|
368
|
+
k !== null && e !== "" && (K = !0);
|
|
369
|
+
}, Se = (e, t) => j.some((n, r) => n.some((n, i) => n !== "" && (e(r) || (z[i] ?? t) >= t)));
|
|
311
370
|
if (S) {
|
|
312
|
-
let t = g((e) => c.getRow(
|
|
371
|
+
let t = g((e) => c.getRow(H(e)), u, j, L, R, (e, t, n, i) => r({
|
|
313
372
|
readOnly: d,
|
|
314
373
|
canEditCell: m
|
|
315
|
-
}, c,
|
|
316
|
-
if (
|
|
317
|
-
let t =
|
|
318
|
-
|
|
319
|
-
} : void 0,
|
|
374
|
+
}, c, H(e), t, n, i), M !== null || k !== null ? (e) => {
|
|
375
|
+
if (xe(e.text), M === null) return;
|
|
376
|
+
let t = H(e.rowIndex);
|
|
377
|
+
M.push(he(e, t, c.getRowKey(t) ?? t, c.pageStart));
|
|
378
|
+
} : void 0, ne).map((e) => ({
|
|
320
379
|
...e,
|
|
321
|
-
viewIndex:
|
|
380
|
+
viewIndex: H(e.viewIndex)
|
|
322
381
|
}));
|
|
323
|
-
|
|
324
|
-
let t =
|
|
382
|
+
k !== null && Se((e) => {
|
|
383
|
+
let t = H(L + e);
|
|
325
384
|
return t >= c.getRowCount() || c.getRow(t) == null;
|
|
326
|
-
}, u.length) && (
|
|
327
|
-
let n =
|
|
385
|
+
}, u.length) && (K = !0);
|
|
386
|
+
let n = W === null || K ? [] : se({
|
|
328
387
|
getRow: (e) => c.getRow(e),
|
|
329
388
|
columns: u,
|
|
330
|
-
selection:
|
|
389
|
+
selection: W,
|
|
331
390
|
activeCell: null,
|
|
332
391
|
viewRowCount: c.getRowCount(),
|
|
333
392
|
canWriteCell: (e, t, n, i) => r({
|
|
334
393
|
readOnly: d,
|
|
335
394
|
canEditCell: m
|
|
336
395
|
}, c, e, t, n, i),
|
|
337
|
-
skipCell:
|
|
396
|
+
skipCell: G
|
|
338
397
|
});
|
|
339
398
|
(t.length > 0 || n.length > 0) && S([...n, ...t]);
|
|
340
|
-
let a = f(
|
|
341
|
-
|
|
399
|
+
let a = f(U, 0, Math.max(c.getRowCount() - 1, 0)), o = f(B, 0, Math.max(u.length - 1, 0));
|
|
400
|
+
w(e.startSelection(I)), w(e.updateSelection({
|
|
342
401
|
row: a,
|
|
343
402
|
col: o
|
|
344
|
-
})),
|
|
403
|
+
})), w(e.endSelection()), w(e.activateCell(I)), k !== null && i.onCutPasted?.(), N();
|
|
345
404
|
return;
|
|
346
405
|
}
|
|
347
406
|
if (!b) return;
|
|
348
|
-
let
|
|
349
|
-
if (c.getSourceIndex(
|
|
350
|
-
let
|
|
351
|
-
let t =
|
|
352
|
-
return t <
|
|
353
|
-
},
|
|
354
|
-
if (
|
|
355
|
-
let
|
|
356
|
-
if (
|
|
357
|
-
let e = y(
|
|
358
|
-
|
|
407
|
+
let q = c.newRow, Ce = q !== void 0 && L >= q.index;
|
|
408
|
+
if (c.getSourceIndex(L) === void 0 && !Ce) return;
|
|
409
|
+
let we = I.col, J = [...a], Y = [...u], X = q === void 0 ? c.getRowCount() : q.index, Te = J.length, Ee = (e) => {
|
|
410
|
+
let t = H(e);
|
|
411
|
+
return t < X ? c.getSourceIndex(t) : Te + (t - X);
|
|
412
|
+
}, De = c.pageHasMore === !0 ? 0 : Math.max(U + 1 - X, 0), Oe = J.length + De, ke = Ce && De > 0 ? q?.peekRow() : void 0;
|
|
413
|
+
if (Oe > J.length && v) for (ke !== void 0 && J.push(ke); J.length < Oe;) J.push(v());
|
|
414
|
+
let Ae = B + 1, je = [];
|
|
415
|
+
if (Ae > Y.length && x && y) for (; Y.length < Ae;) {
|
|
416
|
+
let e = y(Y.length);
|
|
417
|
+
Y.push(e), je.push(e);
|
|
359
418
|
}
|
|
360
|
-
let
|
|
361
|
-
let o =
|
|
362
|
-
return n({
|
|
419
|
+
let Me = (e, t, n) => (e < X ? c.getRowKey(e) : _?.(t, n) ?? n) ?? n, Ne = pe(i, j, L, z, H, X), Pe = h(J, Ee, Y, j, L, we, (e, t, r, i, a) => {
|
|
420
|
+
let o = H(a);
|
|
421
|
+
return Ne !== null && Ne.has(`${o}:${t}`) ? !1 : n({
|
|
363
422
|
readOnly: d,
|
|
364
423
|
canEditCell: m
|
|
365
|
-
}, o, t, r, i, {
|
|
424
|
+
}, o + (c.pageStart ?? 0), t, r, i, {
|
|
366
425
|
sourceRowIndex: e,
|
|
367
|
-
rowKey:
|
|
426
|
+
rowKey: Me(o, r, e)
|
|
368
427
|
});
|
|
369
|
-
},
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
428
|
+
}, M !== null || k !== null ? (e) => {
|
|
429
|
+
let t = Ne?.get(`${H(e.rowIndex)}:${e.colIndex}`);
|
|
430
|
+
if (t !== void 0 && (e.text === "" || e.text === t) || (xe(e.text), M === null)) return;
|
|
431
|
+
let n = H(e.rowIndex), r = e.sourceRowIndex ?? n;
|
|
432
|
+
M.push(he(e, n, Me(n, e.row, r), c.pageStart));
|
|
433
|
+
} : void 0, ne), Z = Pe !== J;
|
|
434
|
+
k !== null && Se((e) => {
|
|
435
|
+
let t = Ee(L + e);
|
|
436
|
+
return t === void 0 || t >= J.length;
|
|
437
|
+
}, Y.length) && (K = !0);
|
|
438
|
+
let Fe = Z ? Pe : a, Ie = W === null || K ? Fe : ce({
|
|
439
|
+
rows: Fe,
|
|
380
440
|
resolveSourceIndex: (e) => c.getSourceIndex(e),
|
|
381
441
|
columns: u,
|
|
382
|
-
selection:
|
|
442
|
+
selection: W,
|
|
383
443
|
activeCell: null,
|
|
384
444
|
viewRowCount: c.getRowCount(),
|
|
385
445
|
canWriteCell: (e, t, n, i, a) => r({
|
|
386
446
|
readOnly: d,
|
|
387
447
|
canEditCell: m
|
|
388
448
|
}, c, a, t, n, i),
|
|
389
|
-
skipCell:
|
|
449
|
+
skipCell: G
|
|
390
450
|
}).nextRows;
|
|
391
|
-
if (
|
|
392
|
-
let e =
|
|
393
|
-
|
|
451
|
+
if (!Z && M !== null) {
|
|
452
|
+
let e = M.filter((e) => e.rowIndex < X && e.colIndex < u.length);
|
|
453
|
+
M.length = 0, M.push(...e);
|
|
394
454
|
}
|
|
395
|
-
let
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
455
|
+
let Le = f(U, 0, Math.max(Z && J.length > a.length ? U : X - 1, 0)), Re = f(B, 0, Math.max((Z ? Y : u).length - 1, 0)), Q = T.selection, $ = {
|
|
456
|
+
top: I.row,
|
|
457
|
+
bottom: Le,
|
|
458
|
+
left: I.col,
|
|
459
|
+
right: Re
|
|
460
|
+
};
|
|
461
|
+
if (Q?.type === "cell") {
|
|
462
|
+
let { start: e, end: t } = Q.range;
|
|
463
|
+
$.top = Math.min($.top, e.row, t.row), $.bottom = Math.max($.bottom, e.row, t.row), $.left = Math.min($.left, e.col, t.col), $.right = Math.max($.right, e.col, t.col);
|
|
464
|
+
} else Q?.type === "row" ? ($.top = Math.min($.top, Q.startRow, Q.endRow), $.bottom = Math.max($.bottom, Q.startRow, Q.endRow), $.left = 0, $.right = Math.max($.right, u.length - 1)) : Q?.type === "col" && ($.top = 0, $.bottom = Math.max($.bottom, c.getRowCount() - 1), $.left = Math.min($.left, Q.startCol, Q.endCol), $.right = Math.max($.right, Q.startCol, Q.endCol));
|
|
465
|
+
let ze = i.cellSpans?.scopeWrites, Be = (e) => {
|
|
466
|
+
ze ? ze($, () => b(e)) : b(e);
|
|
467
|
+
};
|
|
468
|
+
Z ? (q !== void 0 && J.length > a.length && (ke !== void 0 && q.takeRow(), q.noteAppended(J.length - a.length)), je.length > 0 && x?.(l ? [...l, ...je] : Y), Be(Ie)) : Ie !== a && Be(Ie), w(e.startSelection(I)), w(e.updateSelection({
|
|
469
|
+
row: Le,
|
|
470
|
+
col: Re
|
|
471
|
+
})), w(e.endSelection()), w(e.activateCell(I)), k !== null && i.onCutPasted?.(), N();
|
|
400
472
|
}
|
|
401
473
|
};
|
|
402
474
|
};
|
|
403
475
|
//#endregion
|
|
404
|
-
export {
|
|
476
|
+
export { O as computeIsWholeGridSelected, k as createClipboardController, fe as resolvePasteAnchor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/columnEditor.cjs"),r=require("../utils/shadowDom.cjs"),i=require("../logic/detailRow.cjs"),a=require("../logic/geometry.cjs"),o=require("../logic/editorValues.cjs"),s=require("../logic/validation.cjs"),c=require("../logic/newRow.cjs"),l=require("./liveUiState.cjs"),u=require("../logic/selectFillRow.cjs");var d=(e,t)=>{let r=e.visibleColumns[t.col];if(!(!r||!n.hasRowEditor(r)||c.isNewRowAt(e.rowModel,t.row)))return n.editorKindOf(n.resolveColumnEditor(r,e.rowModel.getRow(t.row)))},f=(e,n)=>{let r=e.visibleColumns[n.col];if(!r||c.isNewRowAt(e.rowModel,n.row))return;let i=e.rowModel.getRow(n.row);return i==null?void 0:{value:t.getCellValue(i,r)}},p=(e,t)=>t.activeCell!==e.activeCell||t.selection!==e.selection,m=e=>{if(i.isFocusInsideDetailCard(e))return!1;let t=e.ownerDocument,n=r.getActiveElement(e);return n===null||n===t.body||n===t.documentElement||e.contains(n)},h=e=>{let t=e.ownerDocument,n=r.getActiveElement(e);return n===null||n===t.body||n===t.documentElement},g=e=>{if(e===null)return!1;let t=r.getActiveElement(e);return t!==null&&t!==e&&e.contains(t)&&typeof t.closest==`function`&&t.closest(`.ssg-cell-editor`)!==null&&!i.isFocusInsideDetailCard(e)},_=(e,n,r,i,a)=>e.map((e,o)=>o===n?{...t.setCellValue(e,r,i),...a}:e),v=(e,t)=>e===null?[]:Object.keys(e).map(n=>({viewIndex:t,column:u.toFillRowColumn(n),value:e[n]})),y=()=>{let r=null,y=null,b=null,x=null,S=!1,C=!1,w=null,T=null,E=null,D=(e,t)=>{let n=e.visibleColumns[t.col];return!n||t.row<0||t.row>=e.rowModel.getRowCount()?null:c.isNewRowAt(e.rowModel,t.row)?{rowKey:c.NEW_ROW_KEY,columnKey:n.key}:e.rowModel.getRow(t.row)===void 0?null:{rowKey:e.rowModel.getRowKey(t.row),columnKey:n.key}},O=(e,t)=>{let n=e.visibleColumns.findIndex(e=>e.key===t.columnKey);if(n<0)return null;if(Object.is(t.rowKey,`__ssg_new_row__`)){let t=e.rowModel.newRow;return t===void 0?null:{row:t.index,col:n}}let r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1)if(e.rowModel.getRow(i)!==void 0&&Object.is(e.rowModel.getRowKey(i),t.rowKey))return{row:i,col:n};return null},k=t=>{r=t;let n=t.uiState.editingCell;if(!n){y=null,w=null;return}let i=D(t,n);if(y!==null&&i!==null&&Object.is(i.rowKey,y.rowKey)&&i.columnKey===y.columnKey){y={...y,cell:n},A(t,n);return}let a=y!==null&&y.cell.row===n.row&&y.cell.col===n.col;if(y===null||!a){y=i?{...i,cell:n,editorKind:d(t,n),startValue:f(t,n)}:null,b!==null&&(b.superseded=!0,b=null,t.editorActionGuardRef.current=!1);return}let o=O(t,y);if(o)y={...y,cell:o},t.dispatch(e.gridActions.retargetEdit(o,t.rowModel.getRowCount())),A(t,o);else{let e=y;y=null,j(t,e)}},A=(e,t)=>{y===null||y.editorKind===void 0||d(e,t)===y.editorKind||(y=null,w=null,H())},j=(t,n)=>{if(t.editorActionGuardRef.current){t.dispatch(e.gridActions.stopEdit());return}x=n,S=!1;let r=w;w=null,C=!0;let i;try{r!==null&&(r(),x=null),i=R()}finally{C=!1,x=null}let a=t.gridRootRef.current;if(!i&&a!==null&&a.isConnected&&h(a)&&(a.focus({preventScroll:!0}),i=!0),S&&t.editorActionGuardRef.current){S=!1;return}S=!1,t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),L(null,null,void 0,i)},M=(e,t)=>{let{rows:n,rowKeyGetter:r}=e;for(let e=0;e<n.length;e+=1){let i=n[e];if(i!==void 0&&Object.is(r?r(i,e):e,t))return e}return-1},N=t=>{r!==null&&(r.dispatch(e.gridActions.startSelection(t)),r.dispatch(e.gridActions.endSelection()),r.dispatch(e.gridActions.activateCell(t)))},P=(t,n)=>{r!==null&&(r.setEditorInitialValue(n),r.dispatch(e.gridActions.startEdit(t)))},F=(e,i)=>{if(r===null)return;let a=c.resolveEditRow(r.rowModel,e.row),o=r.visibleColumns[e.col];!a||!o||n.resolveColumnEditor(o,a)?.type===`checkbox`||!t.isViewCellEditable({readOnly:r.readOnly,canEditCell:r.canEditCell},r.rowModel,e.row,e.col,a,o)||P(e,i)},I=(e,t,n)=>{let r=e.getRowCount(),i=a.clamp(t,0,Math.max(r-1,0)),{getLabelRow:o}=e;if(o&&n!==void 0&&i!==n){let e=i>n?1:-1;for(;i>=0&&i<r&&o(i);)i+=e;(i<0||i>=r)&&(i=a.clamp(n,0,Math.max(r-1,0)))}return i},L=(e,t=null,n,o=!1,s,c)=>{let l=r;if(l===null)return;let u=!1,d={superseded:!1};b=d;let f=l.uiState.editingCell,h=o=>{if(u)return;if(d.superseded){u=!0;return}let h=r===null?null:r.getUiState?.()??null;if(h!==null&&h.editingCell!==null&&h.editingCell!==f){u=!0,b===d&&(b=null),l.editorActionGuardRef.current=!1;return}if(!o&&(r===null||r.uiState.editingCell!==null))return;u=!0,b===d&&(b=null);let g=l.gridRootRef.current;if(g!==null&&m(g)&&g.focus(),e!==null&&r!==null&&!(t!==null&&p(t,r.uiState))){let t=r.visibleColumns.length,o=s===void 0?-1:Object.is(s,`__ssg_new_row__`)?r.rowModel.newRow?.index??-1:i.findViewRowIndexByKey(r.rowModel,s,new Map),u={row:o>=0?o:I(r.rowModel,e.row,n),col:a.clamp(e.col,0,Math.max(t-1,0))};N(u),l.editorActionGuardRef.current=!1,c!==void 0&&c!==``&&F(u,c);return}l.editorActionGuardRef.current=!1};o&&queueMicrotask(()=>h(!1)),requestAnimationFrame(()=>h(!0))},R=()=>{let e=r?.gridRootRef.current??null;return g(e)?(e.focus({preventScroll:!0}),!0):!1},z=(e,t,n,r,i)=>i===void 0?null:u.resolveSelectFillRow(t,n,e.rowModel.getRowKey(r),i,e.columns??e.visibleColumns,e.localeTexts),B=(n,r,i,a,l,d,f)=>{let{rowModel:p,visibleColumns:m,uiState:h,dispatch:g,editorActionGuardRef:_}=n,v=p.newRow,y=m[r.col],b=v?.ensureRow();if(!v||!y||!b)return g(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:n.readOnly,canEditCell:n.canEditCell},p,r.row,r.col,b,y))return _.current=!0,g(e.gridActions.stopEdit()),L(null),{status:`noop`};if(!o.isUnchangedEditorCommit(y,t.getCellValue(b,y),a,b)){let e=o.parseCommittedValue(y,a,b,n.localeTexts?.multiSelectSeparator),i=s.decideCellWrite(y,b,e,n.localeTexts);if(i.action===`reject`)return{status:`rejected`,message:i.message};let c=d===void 0?null:u.resolveSelectFillRow(y,b,n.rowModel.getRowKey(r.row)??`__ssg_new_row__`,d,n.columns??m,n.localeTexts),l=c===null?t.setCellValue(b,y,e):{...t.setCellValue(b,y,e),...c};v.writeRow(l)}let x=l===`right`&&(i.col>m.length-1||!(()=>{let e=v.peekRow()??b;for(let i=r.col+1;i<m.length;i+=1){let a=m[i];if(a!==void 0&&t.isViewCellEditable({readOnly:n.readOnly,canEditCell:n.canEditCell},p,r.row,i,e,a))return!0}return!1})()),S=i,C=i.row===r.row?c.NEW_ROW_KEY:void 0;if((l===`down`||x)&&v.hasDraft()){v.commit();let e=c.resolveFirstEditableColIndex(m,n.readOnly);S={row:r.row,col:x&&e>=0?e:r.col},C=c.NEW_ROW_KEY}else l===`down`&&(C=c.NEW_ROW_KEY);_.current=!0;let w=R();return L(S,l===void 0?{activeCell:h.activeCell,selection:h.selection}:null,r.row,w,C,l===void 0?void 0:f),g(e.gridActions.stopEdit()),{status:`committed`}},V=(n,a,l,u)=>{if(r===null)return{status:`noop`};let{uiState:d,visibleColumns:f,rowModel:p,rows:m,applyServerSideCellEdits:h,onRowsChange:g,dispatch:b,editorActionGuardRef:S}=r;if(S.current||!d.editingCell)return{status:`noop`};if(C){let e=x;return x=null,e===null?{status:`noop`}:W(r,e,n,!0,l)}let w=d.editingCell,T=a===`down`?{row:w.row+1,col:w.col}:a===`up`?{row:w.row-1,col:w.col}:a===`right`?{row:w.row,col:w.col+1}:a===`left`?{row:w.row,col:Math.max(w.col-1,i.resolveFirstDataColIndex(f))}:w;if(c.isNewRowAt(p,w.row))return B(r,w,T,n,a,l,u);let E=f[w.col],D=p.getSourceIndex(w.row),O=h?p.getRow(w.row):m[D];if(!E||!O)return b(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:r.readOnly,canEditCell:r.canEditCell},p,w.row,w.col,O,E))return S.current=!0,b(e.gridActions.stopEdit()),L(null),{status:`noop`};let k=t.getCellValue(O,E),A=y!==null&&y.cell.row===w.row&&y.cell.col===w.col?y.startValue:void 0,j=o.isUnchangedEditorCommit(E,k,n,O)||A!==void 0&&!Object.is(A.value,k)&&o.isUnchangedEditorCommit(E,A.value,n,O);if(!j&&h){let e=o.parseCommittedValue(E,n,O,r.localeTexts?.multiSelectSeparator),t=s.decideCellWrite(E,O,e,r.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};let i=z(r,E,O,w.row,l);h([{viewIndex:w.row,column:E,value:e},...v(i,w.row)])}else if(!j&&g){let e=o.parseCommittedValue(E,n,O,r.localeTexts?.multiSelectSeparator),t=s.decideCellWrite(E,O,e,r.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};let i=z(r,E,O,w.row,l);g(i===null?o.writeRowsCell(m,D,E,e):_(m,D,E,e,i))}S.current=!0;let M=R(),N;if(r.followsRow===!0){let e=I(p,T.row,w.row);(p.getRow(e)!=null||p.getLabelRow?.(e)!==void 0)&&(N=p.getRowKey(e))}return L(T,a===void 0?{activeCell:d.activeCell,selection:d.selection}:null,w.row,M,N,a===void 0?void 0:u),b(e.gridActions.stopEdit()),{status:`committed`}},H=()=>{if(r===null||r.editorActionGuardRef.current)return;S=!0,x=null,r.editorActionGuardRef.current=!0;let t=R();r.dispatch(e.gridActions.stopEdit()),L(null,null,void 0,t)},U=e=>{w=e},W=(e,n,r,i,a)=>{let c=e.visibleColumns.find(e=>e.key===n.columnKey),d=i?null:l.readLiveUiState(e).editingCell,f=d&&D(e,d);if(c===void 0||f&&Object.is(f.rowKey,n.rowKey)&&f.columnKey===n.columnKey)return{status:`noop`};if(Object.is(n.rowKey,`__ssg_new_row__`)){let n=e.rowModel.newRow,a=n?.peekRow();if(!n||a===void 0)return{status:`noop`};let l=e.visibleColumns.indexOf(c);if(!t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},e.rowModel,n.index,l,a,c))return{status:`noop`};if(o.isUnchangedEditorCommit(c,t.getCellValue(a,c),r,a))return{status:`committed`};let u=o.parseCommittedValue(c,r,a,e.localeTexts?.multiSelectSeparator),d=s.decideCellWrite(c,a,u,e.localeTexts);return d.action===`reject`?i?{status:`noop`}:{status:`rejected`,message:d.message}:(n.writeRow(t.setCellValue(a,c,u)),{status:`committed`})}let p=O(e,n),m,h=-1,g=E!==null&&E.from===e.rows?E.rows:e.rows;e.applyServerSideCellEdits===void 0?e.onRowsChange!==void 0&&(h=M(e,n.rowKey),m=h<0?void 0:g[h]):m=p===null?void 0:e.rowModel.getRow(p.row);let y=p??n.cell;if(m===void 0||!t.isCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},y.row,y.col,m,c,{sourceRowIndex:h>=0?h:e.rowModel.getSourceIndex(y.row),rowKey:n.rowKey}))return{status:`noop`};if(o.isUnchangedEditorCommit(c,t.getCellValue(m,c),r,m))return{status:`committed`};let b=o.parseCommittedValue(c,r,m,e.localeTexts?.multiSelectSeparator),x=s.decideCellWrite(c,m,b,e.localeTexts);if(x.action===`reject`)return i?{status:`noop`}:{status:`rejected`,message:x.message};let S=a===void 0?null:u.resolveSelectFillRow(c,m,n.rowKey,a,e.columns??e.visibleColumns,e.localeTexts);if(e.applyServerSideCellEdits!==void 0&&p!==null)e.applyServerSideCellEdits([{viewIndex:p.row,column:c,value:b},...v(S,p.row)]);else if(e.onRowsChange!==void 0&&h>=0){let t=S===null?o.writeRowsCell(g,h,c,b):_(g,h,c,b,S);E={from:e.rows,rows:t},e.onRowsChange(t)}return{status:`committed`}};return{update:k,activateSingleCell:N,startEditWithValue:P,commitEdit:V,cancelEdit:H,registerDraftFlush:U,endEditLeftOpen:()=>{let t=r;if(t===null||t.editorActionGuardRef.current)return;let i=l.readLiveUiState(t).editingCell;if(i===null)return;let a=t.visibleColumns[i.col];if(a===void 0||n.resolveColumnEditor(a,c.peekEditRow(t.rowModel,i.row))?.type!==`custom`)return;let o=y??D(t,i),s=T;if(o!==null&&s!==null){let e={...o,cell:i},t=!1;s(n=>t||r===null?{status:`noop`}:(t=!0,W(r,e,n)))}t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),L(null)},registerLateCommitReceiver:e=>(T=e,()=>{T===e&&(T=null)}),dispose:()=>{r=null,T=null}}};exports.createEditController=y;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/columnEditor.cjs"),r=require("../utils/shadowDom.cjs"),i=require("../logic/detailRow.cjs"),a=require("../logic/geometry.cjs"),o=require("../logic/editorValues.cjs"),s=require("../logic/validation.cjs"),c=require("../logic/newRow.cjs"),l=require("./liveUiState.cjs"),u=require("../logic/selectFillRow.cjs");var d=(e,t)=>{let r=e.visibleColumns[t.col];if(!(!r||!n.hasRowEditor(r)||c.isNewRowAt(e.rowModel,t.row)))return n.editorKindOf(n.resolveColumnEditor(r,e.rowModel.getRow(t.row)))},f=(e,n)=>{let r=e.visibleColumns[n.col];if(!r||c.isNewRowAt(e.rowModel,n.row))return;let i=e.rowModel.getRow(n.row);return i==null?void 0:{value:t.getCellValue(i,r)}},p=(e,t)=>t.activeCell!==e.activeCell||t.selection!==e.selection,m=e=>{if(i.isFocusInsideDetailCard(e))return!1;let t=e.ownerDocument,n=r.getActiveElement(e);return n===null||n===t.body||n===t.documentElement||e.contains(n)},h=e=>{let t=e.ownerDocument,n=r.getActiveElement(e);return n===null||n===t.body||n===t.documentElement},g=e=>{if(e===null)return!1;let t=r.getActiveElement(e);return t!==null&&t!==e&&e.contains(t)&&typeof t.closest==`function`&&t.closest(`.ssg-cell-editor`)!==null&&!i.isFocusInsideDetailCard(e)},_=(e,n,r,i,a)=>e.map((e,o)=>o===n?{...t.setCellValue(e,r,i),...a}:e),v=(e,n,r,i,a,o)=>{let c=e.cellSpans?.current().getSpan(r.row,r.col)??null;if(c===null||c.left!==c.right||c.top===c.bottom)return n;let{rowModel:l}=e,u=null;for(let d=c.top;d<=c.bottom;d+=1){if(d===r.row)continue;let c=l.getSourceIndex(d),f=c===void 0?void 0:(u??n)[c];c===void 0||f==null||!t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},l,d,r.col,f,i)||s.decideCellWrite(i,f,a,e.localeTexts).action===`reject`||(u??=n.slice(),u[c]={...t.setCellValue(f,i,a),...o})}return u??n},y=(e,t)=>e===null?[]:Object.keys(e).map(n=>({viewIndex:t,column:u.toFillRowColumn(n),value:e[n]})),b=()=>{let r=null,b=null,x=null,S=null,C=!1,w=!1,T=null,E=null,D=null,O=(e,t)=>{let n=e.visibleColumns[t.col];return!n||t.row<0||t.row>=e.rowModel.getRowCount()?null:c.isNewRowAt(e.rowModel,t.row)?{rowKey:c.NEW_ROW_KEY,columnKey:n.key}:e.rowModel.getRow(t.row)===void 0?null:{rowKey:e.rowModel.getRowKey(t.row),columnKey:n.key}},k=(e,t)=>{let n=e.visibleColumns.findIndex(e=>e.key===t.columnKey);if(n<0)return null;if(Object.is(t.rowKey,`__ssg_new_row__`)){let t=e.rowModel.newRow;return t===void 0?null:{row:t.index,col:n}}let r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1)if(e.rowModel.getRow(i)!==void 0&&Object.is(e.rowModel.getRowKey(i),t.rowKey))return{row:i,col:n};return null},A=t=>{r=t;let n=t.uiState.editingCell;if(!n){b=null,T=null;return}let i=O(t,n);if(b!==null&&i!==null&&Object.is(i.rowKey,b.rowKey)&&i.columnKey===b.columnKey){b={...b,cell:n},j(t,n);return}let a=b!==null&&b.cell.row===n.row&&b.cell.col===n.col;if(b===null||!a){b=i?{...i,cell:n,editorKind:d(t,n),startValue:f(t,n)}:null,x!==null&&(x.superseded=!0,x=null,t.editorActionGuardRef.current=!1);return}let o=k(t,b);if(o)b={...b,cell:o},t.dispatch(e.gridActions.retargetEdit(o,t.rowModel.getRowCount())),j(t,o);else{let e=b;b=null,M(t,e)}},j=(e,t)=>{b===null||b.editorKind===void 0||d(e,t)===b.editorKind||(b=null,T=null,U())},M=(t,n)=>{if(t.editorActionGuardRef.current){t.dispatch(e.gridActions.stopEdit());return}S=n,C=!1;let r=T;T=null,w=!0;let i;try{r!==null&&(r(),S=null),i=z()}finally{w=!1,S=null}let a=t.gridRootRef.current;if(!i&&a!==null&&a.isConnected&&h(a)&&(a.focus({preventScroll:!0}),i=!0),C&&t.editorActionGuardRef.current){C=!1;return}C=!1,t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),R(null,null,void 0,i)},N=(e,t)=>{let{rows:n,rowKeyGetter:r}=e;for(let e=0;e<n.length;e+=1){let i=n[e];if(i!==void 0&&Object.is(r?r(i,e):e,t))return e}return-1},P=t=>{r!==null&&(r.dispatch(e.gridActions.startSelection(t)),r.dispatch(e.gridActions.endSelection()),r.dispatch(e.gridActions.activateCell(t)))},F=(t,n)=>{r!==null&&(r.setEditorInitialValue(n),r.dispatch(e.gridActions.startEdit(t)))},I=(e,i)=>{if(r===null)return;let a=c.resolveEditRow(r.rowModel,e.row),o=r.visibleColumns[e.col];r.startLocked===!0||!a||!o||n.resolveColumnEditor(o,a)?.type===`checkbox`||!t.isViewCellEditable({readOnly:r.readOnly,canEditCell:r.canEditCell},r.rowModel,e.row,e.col,a,o)||F(e,i)},L=(e,t,n)=>{let r=e.getRowCount(),i=a.clamp(t,0,Math.max(r-1,0)),{getLabelRow:o}=e;if(o&&n!==void 0&&i!==n){let e=i>n?1:-1;for(;i>=0&&i<r&&o(i);)i+=e;(i<0||i>=r)&&(i=a.clamp(n,0,Math.max(r-1,0)))}return i},R=(e,t=null,n,o=!1,s,c)=>{let l=r;if(l===null)return;let u=!1,d={superseded:!1};x=d;let f=l.uiState.editingCell,h=o=>{if(u)return;if(d.superseded){u=!0;return}let h=r===null?null:r.getUiState?.()??null;if(h!==null&&h.editingCell!==null&&h.editingCell!==f){u=!0,x===d&&(x=null),l.editorActionGuardRef.current=!1;return}if(!o&&(r===null||r.uiState.editingCell!==null))return;u=!0,x===d&&(x=null);let g=l.gridRootRef.current;if(g!==null&&m(g)&&g.focus(),e!==null&&r!==null&&!(t!==null&&p(t,r.uiState))){let t=r.visibleColumns.length,o=s===void 0?-1:Object.is(s,`__ssg_new_row__`)?r.rowModel.newRow?.index??-1:i.findViewRowIndexByKey(r.rowModel,s,new Map),u={row:o>=0?o:L(r.rowModel,e.row,n),col:a.clamp(e.col,0,Math.max(t-1,0))};P(u),l.editorActionGuardRef.current=!1,c!==void 0&&c!==``&&I(u,c);return}l.editorActionGuardRef.current=!1};o&&queueMicrotask(()=>h(!1)),requestAnimationFrame(()=>h(!0))},z=()=>{let e=r?.gridRootRef.current??null;return g(e)?(e.focus({preventScroll:!0}),!0):!1},B=(e,t,n,r,i)=>i===void 0?null:u.resolveSelectFillRow(t,n,e.rowModel.getRowKey(r),i,e.columns??e.visibleColumns,e.localeTexts),V=(n,r,i,a,l,d,f)=>{let{rowModel:p,visibleColumns:m,uiState:h,dispatch:g,editorActionGuardRef:_}=n,v=p.newRow,y=m[r.col],b=v?.ensureRow();if(!v||!y||!b)return g(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:n.readOnly,canEditCell:n.canEditCell},p,r.row,r.col,b,y))return _.current=!0,g(e.gridActions.stopEdit()),R(null),{status:`noop`};if(!o.isUnchangedEditorCommit(y,t.getCellValue(b,y),a,b)){let e=o.parseCommittedValue(y,a,b,n.localeTexts?.multiSelectSeparator),i=s.decideCellWrite(y,b,e,n.localeTexts);if(i.action===`reject`)return{status:`rejected`,message:i.message};let c=d===void 0?null:u.resolveSelectFillRow(y,b,n.rowModel.getRowKey(r.row)??`__ssg_new_row__`,d,n.columns??m,n.localeTexts),l=c===null?t.setCellValue(b,y,e):{...t.setCellValue(b,y,e),...c};v.writeRow(l)}let x=l===`right`&&(i.col>m.length-1||!(()=>{let e=v.peekRow()??b;for(let i=r.col+1;i<m.length;i+=1){let a=m[i];if(a!==void 0&&t.isViewCellEditable({readOnly:n.readOnly,canEditCell:n.canEditCell},p,r.row,i,e,a))return!0}return!1})()),S=i,C=i.row===r.row?c.NEW_ROW_KEY:void 0;if((l===`down`||x)&&v.hasDraft()){v.commit();let e=c.resolveFirstEditableColIndex(m,n.readOnly);S={row:r.row,col:x&&e>=0?e:r.col},C=c.NEW_ROW_KEY}else l===`down`&&(C=c.NEW_ROW_KEY);_.current=!0;let w=z();return R(S,l===void 0?{activeCell:h.activeCell,selection:h.selection}:null,r.row,w,C,l===void 0?void 0:f),g(e.gridActions.stopEdit()),{status:`committed`}},H=(n,a,l,u)=>{if(r===null)return{status:`noop`};let{uiState:d,visibleColumns:f,rowModel:p,rows:m,applyServerSideCellEdits:h,onRowsChange:g,dispatch:x,editorActionGuardRef:C}=r;if(C.current||!d.editingCell)return{status:`noop`};if(w){let e=S;return S=null,e===null?{status:`noop`}:G(r,e,n,!0,l)}let T=d.editingCell,E=r.cellSpans?.current().getSpan(T.row,T.col)??null,D=E?r.cellSpans?.entryFor({row:E.top,col:E.left})??T:T,O=a===`down`?{row:(E?.bottom??T.row)+1,col:D.col}:a===`up`?{row:(E?.top??T.row)-1,col:D.col}:a===`right`?{row:D.row,col:(E?.right??T.col)+1}:a===`left`?{row:D.row,col:Math.max((E?.left??T.col)-1,i.resolveFirstDataColIndex(f))}:T;if(c.isNewRowAt(p,T.row))return V(r,T,O,n,a,l,u);let k=f[T.col],A=p.getSourceIndex(T.row),j=h?p.getRow(T.row):m[A];if(!k||!j)return x(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:r.readOnly,canEditCell:r.canEditCell},p,T.row,T.col,j,k))return C.current=!0,x(e.gridActions.stopEdit()),R(null),{status:`noop`};let M=t.getCellValue(j,k),N=b!==null&&b.cell.row===T.row&&b.cell.col===T.col?b.startValue:void 0,P=o.isUnchangedEditorCommit(k,M,n,j)||N!==void 0&&!Object.is(N.value,M)&&o.isUnchangedEditorCommit(k,N.value,n,j);if(!P&&h){let e=o.parseCommittedValue(k,n,j,r.localeTexts?.multiSelectSeparator),t=s.decideCellWrite(k,j,e,r.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};let i=B(r,k,j,T.row,l);h([{viewIndex:T.row,column:k,value:e},...y(i,T.row)])}else if(!P&&g){let e=o.parseCommittedValue(k,n,j,r.localeTexts?.multiSelectSeparator),t=s.decideCellWrite(k,j,e,r.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};let i=B(r,k,j,T.row,l),a=i===null?o.writeRowsCell(m,A,k,e):_(m,A,k,e,i);i!==null&&(a=v(r,a,T,k,e,i)),g(a)}C.current=!0;let F=z(),I;if(r.followsRow===!0){let e=L(p,O.row,T.row);(p.getRow(e)!=null||p.getLabelRow?.(e)!==void 0)&&(I=p.getRowKey(e))}return R(O,a===void 0?{activeCell:d.activeCell,selection:d.selection}:null,T.row,F,I,a===void 0?void 0:u),x(e.gridActions.stopEdit()),{status:`committed`}},U=()=>{if(r===null||r.editorActionGuardRef.current)return;C=!0,S=null,r.editorActionGuardRef.current=!0;let t=z();r.dispatch(e.gridActions.stopEdit()),R(null,null,void 0,t)},W=e=>{T=e},G=(e,n,r,i,a)=>{let c=e.visibleColumns.find(e=>e.key===n.columnKey),d=i?null:l.readLiveUiState(e).editingCell,f=d&&O(e,d);if(c===void 0||f&&Object.is(f.rowKey,n.rowKey)&&f.columnKey===n.columnKey)return{status:`noop`};if(Object.is(n.rowKey,`__ssg_new_row__`)){let n=e.rowModel.newRow,a=n?.peekRow();if(!n||a===void 0)return{status:`noop`};let l=e.visibleColumns.indexOf(c);if(!t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},e.rowModel,n.index,l,a,c))return{status:`noop`};if(o.isUnchangedEditorCommit(c,t.getCellValue(a,c),r,a))return{status:`committed`};let u=o.parseCommittedValue(c,r,a,e.localeTexts?.multiSelectSeparator),d=s.decideCellWrite(c,a,u,e.localeTexts);return d.action===`reject`?i?{status:`noop`}:{status:`rejected`,message:d.message}:(n.writeRow(t.setCellValue(a,c,u)),{status:`committed`})}let p=k(e,n),m,h=-1,g=D!==null&&D.from===e.rows?D.rows:e.rows;e.applyServerSideCellEdits===void 0?e.onRowsChange!==void 0&&(h=N(e,n.rowKey),m=h<0?void 0:g[h]):m=p===null?void 0:e.rowModel.getRow(p.row);let v=p??n.cell;if(m===void 0||!t.isCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},v.row+(e.rowModel.pageStart??0),v.col,m,c,{sourceRowIndex:h>=0?h:e.rowModel.getSourceIndex(v.row),rowKey:n.rowKey}))return{status:`noop`};if(o.isUnchangedEditorCommit(c,t.getCellValue(m,c),r,m))return{status:`committed`};let b=o.parseCommittedValue(c,r,m,e.localeTexts?.multiSelectSeparator),x=s.decideCellWrite(c,m,b,e.localeTexts);if(x.action===`reject`)return i?{status:`noop`}:{status:`rejected`,message:x.message};let S=a===void 0?null:u.resolveSelectFillRow(c,m,n.rowKey,a,e.columns??e.visibleColumns,e.localeTexts);if(e.applyServerSideCellEdits!==void 0&&p!==null)e.applyServerSideCellEdits([{viewIndex:p.row,column:c,value:b},...y(S,p.row)]);else if(e.onRowsChange!==void 0&&h>=0){let t=S===null?o.writeRowsCell(g,h,c,b):_(g,h,c,b,S);D={from:e.rows,rows:t},e.onRowsChange(t)}return{status:`committed`}};return{update:A,activateSingleCell:P,startEditWithValue:F,commitEdit:H,cancelEdit:U,registerDraftFlush:W,endEditLeftOpen:()=>{let t=r;if(t===null||t.editorActionGuardRef.current)return;let i=l.readLiveUiState(t).editingCell;if(i===null)return;let a=t.visibleColumns[i.col];if(a===void 0||n.resolveColumnEditor(a,c.peekEditRow(t.rowModel,i.row))?.type!==`custom`)return;let o=b??O(t,i),s=E;if(o!==null&&s!==null){let e={...o,cell:i},t=!1;s(n=>t||r===null?{status:`noop`}:(t=!0,G(r,e,n)))}t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),R(null)},registerLateCommitReceiver:e=>(E=e,()=>{E===e&&(E=null)}),dispose:()=>{r=null,E=null}}};exports.createEditController=b;
|
|
@@ -2,6 +2,7 @@ import { type GridUiAction } from '../model/gridActions.js';
|
|
|
2
2
|
import type { CellCoord, EditorCommitDirection, EditorCommitResult, GridColumn, GridSelectEditorOption, GridRowKey, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
|
|
3
3
|
import { type ValidationLocaleText } from '../logic/validation.js';
|
|
4
4
|
import type { ServerSideCellEditInput } from '../logic/serverSideEdits.js';
|
|
5
|
+
import type { KeyboardCellSpans } from './keyboardController.js';
|
|
5
6
|
export type EditControllerArgs<T extends object> = {
|
|
6
7
|
uiState: GridUiState;
|
|
7
8
|
rows: T[];
|
|
@@ -18,12 +19,14 @@ export type EditControllerArgs<T extends object> = {
|
|
|
18
19
|
current: boolean;
|
|
19
20
|
};
|
|
20
21
|
readOnly?: boolean;
|
|
22
|
+
startLocked?: boolean | undefined;
|
|
21
23
|
canEditCell?: SpreadsheetGridProps<T>['canEditCell'];
|
|
22
24
|
localeTexts?: ValidationLocaleText;
|
|
23
25
|
followsRow?: boolean | undefined;
|
|
24
26
|
getUiState?: (() => GridUiState) | undefined;
|
|
25
27
|
rowKeyGetter?: ((row: T, index: number) => GridRowKey) | undefined;
|
|
26
28
|
columns?: GridColumn<T>[] | undefined;
|
|
29
|
+
cellSpans?: KeyboardCellSpans | undefined;
|
|
27
30
|
};
|
|
28
31
|
export type LateEditCommit = (value: unknown) => EditorCommitResult;
|
|
29
32
|
export type LateEditCommitReceiver = (commit: LateEditCommit) => void;
|