@ishibashi0112/spreadsheet-grid-core 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/activeRowFollowController.cjs +1 -1
- package/dist/controllers/activeRowFollowController.d.ts +1 -0
- package/dist/controllers/activeRowFollowController.js +33 -24
- package/dist/controllers/changeTracker.cjs +1 -1
- package/dist/controllers/changeTracker.d.ts +6 -0
- package/dist/controllers/changeTracker.js +338 -160
- package/dist/controllers/clipboardController.cjs +2 -1
- package/dist/controllers/clipboardController.d.ts +5 -1
- package/dist/controllers/clipboardController.js +217 -91
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +3 -1
- package/dist/controllers/columnAutosizeRunner.js +12 -11
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +231 -159
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +114 -113
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +3 -1
- package/dist/controllers/findController.js +80 -75
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +25 -1
- package/dist/controllers/historyController.js +115 -64
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +5 -0
- package/dist/controllers/keyboardController.js +154 -140
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +1 -0
- package/dist/engine/cellCommands.cjs +1 -1
- package/dist/engine/cellCommands.js +81 -62
- package/dist/engine/columnLayout.cjs +1 -1
- package/dist/engine/columnLayout.d.ts +1 -0
- package/dist/engine/columnLayout.js +10 -10
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +6 -1
- package/dist/engine/createGridEngine.js +58 -50
- package/dist/engine/excelShortcutCommands.cjs +1 -0
- package/dist/engine/excelShortcutCommands.d.ts +29 -0
- package/dist/engine/excelShortcutCommands.js +256 -0
- package/dist/engine/exportCommands.cjs +2 -2
- package/dist/engine/exportCommands.js +82 -34
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +21 -0
- package/dist/engine/features.js +23 -2
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +24 -10
- package/dist/engine/gridApi.cjs +10 -9
- package/dist/engine/gridApi.d.ts +21 -2
- package/dist/engine/gridApi.js +239 -101
- package/dist/engine/memo.cjs +1 -1
- package/dist/engine/memo.d.ts +1 -1
- package/dist/engine/memo.js +12 -11
- package/dist/engine/newRowController.cjs +1 -0
- package/dist/engine/newRowController.d.ts +31 -0
- package/dist/engine/newRowController.js +157 -0
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +9 -1
- package/dist/engine/notifiers.js +23 -8
- package/dist/engine/rowPipeline.cjs +1 -1
- package/dist/engine/rowPipeline.d.ts +29 -2
- package/dist/engine/rowPipeline.js +76 -50
- package/dist/engine/treeStage.cjs +1 -0
- package/dist/engine/treeStage.d.ts +46 -0
- package/dist/engine/treeStage.js +171 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +12 -0
- package/dist/logic/cellPlacement.cjs +1 -1
- package/dist/logic/cellPlacement.d.ts +1 -1
- package/dist/logic/cellPlacement.js +1 -1
- package/dist/logic/changeTracking.cjs +1 -1
- package/dist/logic/changeTracking.d.ts +26 -1
- package/dist/logic/changeTracking.js +139 -32
- package/dist/logic/clearCells.cjs +1 -1
- package/dist/logic/clearCells.d.ts +4 -2
- package/dist/logic/clearCells.js +24 -24
- package/dist/logic/columnAutosize.cjs +1 -1
- package/dist/logic/columnAutosize.d.ts +4 -1
- package/dist/logic/columnAutosize.js +89 -72
- package/dist/logic/conditionalFormat.cjs +1 -1
- package/dist/logic/conditionalFormat.js +8 -5
- package/dist/logic/editorKeys.cjs +1 -1
- package/dist/logic/editorKeys.d.ts +9 -1
- package/dist/logic/editorKeys.js +23 -17
- package/dist/logic/excelShortcuts.cjs +1 -0
- package/dist/logic/excelShortcuts.d.ts +13 -0
- package/dist/logic/excelShortcuts.js +36 -0
- package/dist/logic/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +11 -1
- package/dist/logic/exportCsv.js +30 -22
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +3 -2
- package/dist/logic/exportData.js +40 -28
- package/dist/logic/featureWarnings.cjs +1 -1
- package/dist/logic/featureWarnings.js +16 -6
- package/dist/logic/fillHandle.cjs +1 -1
- package/dist/logic/fillHandle.js +1 -1
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.d.ts +1 -1
- package/dist/logic/find.js +11 -9
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +3 -2
- package/dist/logic/gridState.js +6 -6
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +22 -21
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +16 -0
- package/dist/logic/localeTextFeatures.js +22 -8
- package/dist/logic/newRow.cjs +1 -0
- package/dist/logic/newRow.d.ts +9 -0
- package/dist/logic/newRow.js +69 -0
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +3 -2
- package/dist/logic/sorting.cjs +1 -1
- package/dist/logic/sorting.d.ts +1 -1
- package/dist/logic/sorting.js +32 -32
- package/dist/logic/treeData.cjs +7 -0
- package/dist/logic/treeData.d.ts +83 -0
- package/dist/logic/treeData.js +438 -0
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +10 -9
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +15 -0
- package/dist/model/gridActions.js +15 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +175 -156
- package/dist/model/gridStore.cjs +1 -1
- package/dist/model/gridStore.d.ts +17 -1
- package/dist/model/gridStore.js +4 -4
- package/dist/model/gridTypes.core.d.ts +325 -25
- package/dist/model/gridTypes.unbound.d.ts +1 -0
- package/dist/utils/clipboard.cjs +1 -1
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.js +13 -10
- package/dist/utils/permissions.cjs +1 -1
- package/dist/utils/permissions.d.ts +2 -2
- package/dist/utils/permissions.js +1 -1
- package/package.json +1 -1
|
@@ -1,224 +1,402 @@
|
|
|
1
1
|
import { createCellWriteDraft as e, getCellValue as t, writeCellValue as n } from "../utils/permissions.js";
|
|
2
|
-
import { buildOriginalRow as r,
|
|
2
|
+
import { buildOriginalRow as r, cloneRowChangeRecords as i, countUnsaved as a, createRowChangeRecords as o, createRowLocator as s, insertRowsAfterAnchors as c, isRowChangeRecordsEmpty as l, reconcileRowChangeRecords as u, reconcileUnsavedRecords as d, recordGridRowsAddRemove as f, recordGridRowsChange as p, resolveTrackedColumns as m, resolveUnsavedColumnKeys as h } from "../logic/changeTracking.js";
|
|
3
3
|
//#region src/controllers/changeTracker.ts
|
|
4
|
-
var
|
|
4
|
+
var g = (e) => e ? {
|
|
5
|
+
rows: [],
|
|
6
|
+
rowCount: 0,
|
|
7
|
+
cellCount: 0,
|
|
8
|
+
added: [],
|
|
9
|
+
removed: [],
|
|
10
|
+
addedCount: 0,
|
|
11
|
+
removedCount: 0
|
|
12
|
+
} : {
|
|
5
13
|
rows: [],
|
|
6
14
|
rowCount: 0,
|
|
7
15
|
cellCount: 0
|
|
8
|
-
}
|
|
9
|
-
|
|
16
|
+
}, _ = {
|
|
17
|
+
rowCount: 0,
|
|
18
|
+
cellCount: 0,
|
|
19
|
+
addedCount: 0,
|
|
20
|
+
removedCount: 0
|
|
21
|
+
}, v = (e, t) => e.rowCount === t.rowCount && e.cellCount === t.cellCount && e.addedCount === t.addedCount && e.removedCount === t.removedCount, y = () => {
|
|
22
|
+
let y = null, x = /* @__PURE__ */ new Map(), S = o(), C = /* @__PURE__ */ new Map(), w = null, T = null, E = null, D = null, O = {
|
|
10
23
|
version: 0,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (!(!e &&
|
|
19
|
-
|
|
20
|
-
version:
|
|
24
|
+
..._
|
|
25
|
+
}, k = { ..._ }, A = /* @__PURE__ */ new Set(), j = () => y !== null && y.enabled && y.rowKeyGetter !== void 0, M = () => j() && y?.trackRows === !0, N = (e) => {
|
|
26
|
+
let t = {
|
|
27
|
+
...a(x),
|
|
28
|
+
addedCount: S.added.size,
|
|
29
|
+
removedCount: S.removed.size
|
|
30
|
+
};
|
|
31
|
+
if (!(!e && v(t, O))) {
|
|
32
|
+
O = {
|
|
33
|
+
version: O.version + 1,
|
|
21
34
|
...t
|
|
22
35
|
};
|
|
23
|
-
for (let e of [...
|
|
36
|
+
for (let e of [...A]) e();
|
|
24
37
|
}
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
v
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
}, P = (e, t) => t ? { ...e } : {
|
|
39
|
+
rowCount: e.rowCount,
|
|
40
|
+
cellCount: e.cellCount
|
|
41
|
+
}, F = () => P(O, M()), I, L = !1, R = (e) => {
|
|
42
|
+
I = e;
|
|
43
|
+
let t = {
|
|
44
|
+
rowCount: O.rowCount,
|
|
45
|
+
cellCount: O.cellCount,
|
|
46
|
+
addedCount: O.addedCount,
|
|
47
|
+
removedCount: O.removedCount
|
|
48
|
+
};
|
|
49
|
+
v(t, k) || (k = t, L = M(), e?.(P(t, L)));
|
|
50
|
+
}, z = () => {
|
|
51
|
+
D !== null && (clearTimeout(D), D = null);
|
|
52
|
+
}, ee = () => {
|
|
53
|
+
E = null, z(), !(x.size === 0 && l(S)) && (x = /* @__PURE__ */ new Map(), S = o(), N(!0));
|
|
54
|
+
}, B = () => E !== null && !E.settled ? E : {
|
|
55
|
+
rows: y?.rows ?? [],
|
|
56
|
+
records: x,
|
|
57
|
+
rowChanges: S
|
|
58
|
+
}, V = (e) => {
|
|
59
|
+
if (y = e, !j()) {
|
|
60
|
+
T = e.rows, ee();
|
|
45
61
|
return;
|
|
46
62
|
}
|
|
47
|
-
let t =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
let t = !1;
|
|
64
|
+
e.trackRows !== !0 && !l(S) && (S = o(), t = !0), e.trackRows !== !0 && E !== null && !l(E.rowChanges) && (E.rowChanges = o());
|
|
65
|
+
let n = e.rowKeyGetter, r = e.columns !== w, i = !1;
|
|
66
|
+
if (r) {
|
|
67
|
+
w = e.columns;
|
|
68
|
+
let t = m(e.columns);
|
|
69
|
+
if (x.size > 0 || E !== null) for (let [e, n] of C) !t.has(e) && H(e) && t.set(e, n);
|
|
70
|
+
i = !b(C, t), C = t;
|
|
71
|
+
}
|
|
72
|
+
let a = e.rows !== T, s = !a;
|
|
73
|
+
if (E !== null && (a ? ((e.rows === E.rows || !E.settled) && (x = E.records, S = E.rowChanges, s = e.rows === E.rows), E = null, z()) : E.settled = !0), !a && !r) {
|
|
74
|
+
t && N(!0);
|
|
75
|
+
return;
|
|
53
76
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, A = (e) => {
|
|
60
|
-
for (let t of _ === null ? [p] : [p, _.records]) for (let n of t.values()) if (n.saved.has(e)) return !0;
|
|
77
|
+
T = e.rows;
|
|
78
|
+
let c = d(x, e.rows, n, C, s), f = a && u(S, e.rows, n);
|
|
79
|
+
N(c || t || f || i && x.size > 0);
|
|
80
|
+
}, H = (e) => {
|
|
81
|
+
for (let t of E === null ? [x] : [x, E.records]) for (let n of t.values()) if (n.saved.has(e)) return !0;
|
|
61
82
|
return !1;
|
|
62
|
-
},
|
|
63
|
-
if (!
|
|
64
|
-
let n = new Map(
|
|
65
|
-
|
|
83
|
+
}, U = (e, t) => {
|
|
84
|
+
if (!j() || y === null) return;
|
|
85
|
+
let n = y.rowKeyGetter, r = new Map(E?.records ?? x), a = E?.rowChanges ?? S, o = a;
|
|
86
|
+
y.trackRows === !0 && (o = i(a), f(o, r, e, t, n, C)), p(r, e, t, n, C, o.added.size > 0 ? o.added : void 0), E = {
|
|
66
87
|
rows: t,
|
|
67
|
-
records:
|
|
88
|
+
records: r,
|
|
89
|
+
rowChanges: o,
|
|
68
90
|
settled: !1
|
|
69
|
-
},
|
|
70
|
-
|
|
91
|
+
}, z(), D = setTimeout(() => {
|
|
92
|
+
D = null, E !== null && y?.rows !== E.rows && (E.settled = !0);
|
|
71
93
|
}, 0);
|
|
72
|
-
},
|
|
73
|
-
let t =
|
|
94
|
+
}, W = (e) => {
|
|
95
|
+
let t = B().records.get(e);
|
|
74
96
|
return t?.present ? t.saved : void 0;
|
|
75
|
-
},
|
|
76
|
-
let
|
|
97
|
+
}, G = () => {
|
|
98
|
+
let e = B(), t = [];
|
|
99
|
+
for (let [n, r] of e.records) r.present && t.push(n);
|
|
100
|
+
for (let n of e.rowChanges.added.keys()) t.push(n);
|
|
101
|
+
return t;
|
|
102
|
+
}, K = (e) => B().rowChanges.added.has(e), q = (e, t) => {
|
|
103
|
+
let n = W(e);
|
|
77
104
|
return n?.has(t) ? { value: n.get(t) } : void 0;
|
|
78
|
-
},
|
|
79
|
-
let e =
|
|
80
|
-
if (!
|
|
81
|
-
let { rows:
|
|
82
|
-
for (let [
|
|
83
|
-
if (!
|
|
84
|
-
let e =
|
|
85
|
-
if (e === void 0 ||
|
|
86
|
-
let
|
|
87
|
-
|
|
105
|
+
}, J = () => {
|
|
106
|
+
let e = B(), t = M();
|
|
107
|
+
if (!j() || y === null || e.records.size === 0 && l(e.rowChanges)) return g(t);
|
|
108
|
+
let { rows: n } = e, i = y.rowKeyGetter, a = s(n, i), o = [], c = 0;
|
|
109
|
+
for (let [t, i] of e.records) {
|
|
110
|
+
if (!i.present) continue;
|
|
111
|
+
let e = a(t, i.index), s = e === void 0 ? void 0 : n[e];
|
|
112
|
+
if (e === void 0 || s === void 0) continue;
|
|
113
|
+
let l = h(s, i.saved, C);
|
|
114
|
+
l.length !== 0 && (c += l.length, o.push({
|
|
88
115
|
index: e,
|
|
89
116
|
entry: {
|
|
90
|
-
rowKey:
|
|
91
|
-
row:
|
|
92
|
-
original: r(
|
|
93
|
-
columnKeys:
|
|
117
|
+
rowKey: t,
|
|
118
|
+
row: s,
|
|
119
|
+
original: r(s, i.saved, l, C),
|
|
120
|
+
columnKeys: l
|
|
94
121
|
}
|
|
95
122
|
}));
|
|
96
123
|
}
|
|
97
|
-
|
|
124
|
+
o.sort((e, t) => e.index - t.index);
|
|
125
|
+
let u = {
|
|
98
126
|
rows: o.map((e) => e.entry),
|
|
99
127
|
rowCount: o.length,
|
|
100
|
-
cellCount:
|
|
128
|
+
cellCount: c
|
|
101
129
|
};
|
|
102
|
-
|
|
103
|
-
let
|
|
130
|
+
if (!t) return u;
|
|
131
|
+
let d = [];
|
|
132
|
+
for (let [t, r] of e.rowChanges.added) {
|
|
133
|
+
let e = a(t, r.index), i = e === void 0 ? void 0 : n[e];
|
|
134
|
+
e !== void 0 && i !== void 0 && d.push({
|
|
135
|
+
index: e,
|
|
136
|
+
entry: {
|
|
137
|
+
rowKey: t,
|
|
138
|
+
row: i
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
d.sort((e, t) => e.index - t.index);
|
|
143
|
+
let f = [...e.rowChanges.removed].map(([e, t]) => ({
|
|
144
|
+
rowKey: e,
|
|
145
|
+
row: t.row
|
|
146
|
+
}));
|
|
147
|
+
return {
|
|
148
|
+
...u,
|
|
149
|
+
added: d.map((e) => e.entry),
|
|
150
|
+
removed: f,
|
|
151
|
+
addedCount: d.length,
|
|
152
|
+
removedCount: f.length
|
|
153
|
+
};
|
|
154
|
+
}, Y = (e, n, r) => {
|
|
155
|
+
let i = y?.rowKeyGetter, a = i === void 0 ? null : s(n, i);
|
|
104
156
|
for (let i of r.rows) {
|
|
105
|
-
let r = e.get(i.rowKey),
|
|
157
|
+
let r = e.get(i.rowKey), o = a?.(i.rowKey, r?.index ?? 0), s = o === void 0 ? void 0 : n[o], c = new Map(r?.saved);
|
|
106
158
|
for (let e of i.columnKeys) {
|
|
107
|
-
let n =
|
|
159
|
+
let n = C.get(e);
|
|
108
160
|
if (!n) continue;
|
|
109
161
|
let r = t(i.row, n);
|
|
110
162
|
s === void 0 || Object.is(t(s, n), r) ? c.delete(e) : c.set(e, r);
|
|
111
163
|
}
|
|
112
164
|
c.size === 0 ? e.delete(i.rowKey) : e.set(i.rowKey, {
|
|
113
165
|
saved: c,
|
|
114
|
-
index:
|
|
166
|
+
index: o ?? r?.index ?? 0,
|
|
115
167
|
present: r?.present ?? !0
|
|
116
168
|
});
|
|
117
169
|
}
|
|
118
|
-
},
|
|
119
|
-
|
|
170
|
+
}, X = (e, n, r, i) => {
|
|
171
|
+
let a = y?.rowKeyGetter, o = a === void 0 ? null : s(r, a);
|
|
172
|
+
for (let s of i) {
|
|
173
|
+
let i = n.added.get(s.rowKey);
|
|
174
|
+
n.added.delete(s.rowKey);
|
|
175
|
+
let c = o?.(s.rowKey, i?.index ?? r.length), l = c === void 0 ? void 0 : r[c];
|
|
176
|
+
if (l === void 0) {
|
|
177
|
+
if (i === void 0 && o !== null && M() && !n.removed.has(s.rowKey)) {
|
|
178
|
+
let t = r[r.length - 1];
|
|
179
|
+
n.removed.set(s.rowKey, {
|
|
180
|
+
row: s.row,
|
|
181
|
+
index: r.length,
|
|
182
|
+
afterKey: t === void 0 || a === void 0 ? null : a(t, r.length - 1)
|
|
183
|
+
}), e.delete(s.rowKey);
|
|
184
|
+
}
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (i === void 0 || l === s.row) continue;
|
|
188
|
+
let u = /* @__PURE__ */ new Map();
|
|
189
|
+
for (let [e, n] of C) {
|
|
190
|
+
let r = t(s.row, n);
|
|
191
|
+
Object.is(t(l, n), r) || u.set(e, r);
|
|
192
|
+
}
|
|
193
|
+
u.size > 0 && e.set(s.rowKey, {
|
|
194
|
+
saved: u,
|
|
195
|
+
index: c ?? i.index,
|
|
196
|
+
present: !0
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}, Z = (e, t, n, r) => {
|
|
200
|
+
let i = y?.rowKeyGetter, a = i === void 0 ? null : s(n, i);
|
|
201
|
+
for (let i of r) {
|
|
202
|
+
let r = t.removed.delete(i.rowKey), o = a?.(i.rowKey, 0);
|
|
203
|
+
r || o === void 0 || n[o] === void 0 ? e.delete(i.rowKey) : M() && (e.delete(i.rowKey), t.added.set(i.rowKey, { index: o }));
|
|
204
|
+
}
|
|
205
|
+
}, Q = (e) => {
|
|
206
|
+
if (x.size === 0 && l(S) && E === null && (e === void 0 || Array.isArray(e))) return;
|
|
120
207
|
let t = [{
|
|
121
|
-
map:
|
|
122
|
-
|
|
208
|
+
map: x,
|
|
209
|
+
changes: S,
|
|
210
|
+
rows: y?.rows ?? []
|
|
123
211
|
}];
|
|
124
|
-
|
|
125
|
-
map:
|
|
126
|
-
|
|
212
|
+
E !== null && t.push({
|
|
213
|
+
map: E.records,
|
|
214
|
+
changes: E.rowChanges,
|
|
215
|
+
rows: E.rows
|
|
127
216
|
});
|
|
128
|
-
for (let { map: n,
|
|
129
|
-
else if (Array.isArray(e)) for (let t of e) n.delete(t);
|
|
130
|
-
else
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
217
|
+
for (let { map: n, changes: r, rows: i } of t) if (e === void 0) n.clear(), r.added.clear(), r.removed.clear();
|
|
218
|
+
else if (Array.isArray(e)) for (let t of e) n.delete(t), r.added.delete(t), r.removed.delete(t);
|
|
219
|
+
else {
|
|
220
|
+
let t = e;
|
|
221
|
+
Y(n, i, t), t.added && X(n, r, i, t.added), Z(n, r, i, t.removed ?? []);
|
|
222
|
+
}
|
|
223
|
+
N(!0);
|
|
224
|
+
}, te = (e) => {
|
|
225
|
+
$(e, [], []);
|
|
226
|
+
}, $ = (t, r, i) => {
|
|
227
|
+
let a = B();
|
|
228
|
+
if (!j() || y === null || !y.applyRows || t.length === 0 && r.length === 0 && i.length === 0) return;
|
|
229
|
+
let o = y.rowKeyGetter, l = /* @__PURE__ */ new Map();
|
|
230
|
+
for (let e of t) if (a.records.has(e.rowKey)) {
|
|
231
|
+
if (e.columnKey === void 0) l.set(e.rowKey, null);
|
|
232
|
+
else if (l.get(e.rowKey) !== null) {
|
|
233
|
+
let t = l.get(e.rowKey) ?? /* @__PURE__ */ new Set();
|
|
234
|
+
t.add(e.columnKey), l.set(e.rowKey, t);
|
|
141
235
|
}
|
|
142
236
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
237
|
+
let u = new Set(r.filter((e) => a.rowChanges.added.has(e))), d = i.flatMap((e) => {
|
|
238
|
+
let t = a.rowChanges.removed.get(e);
|
|
239
|
+
return t === void 0 ? [] : [{
|
|
240
|
+
key: e,
|
|
241
|
+
record: t
|
|
242
|
+
}];
|
|
243
|
+
});
|
|
244
|
+
if (l.size === 0 && u.size === 0 && d.length === 0) return;
|
|
245
|
+
let f = a.records, p = (e, t, n) => h(e, t, C).filter((e) => C.has(e) && (n === null || n.has(e))), m = (e) => {
|
|
246
|
+
if (u.size === 0 && d.length === 0) return null;
|
|
247
|
+
let t = u.size === 0 ? e : e.filter((e, t) => !u.has(o(e, t))), n = /* @__PURE__ */ new Set();
|
|
248
|
+
t.forEach((e, t) => n.add(o(e, t)));
|
|
249
|
+
let r = d.filter(({ key: e }) => !n.has(e)).map(({ key: e, record: t }) => ({
|
|
250
|
+
key: e,
|
|
251
|
+
row: t.row,
|
|
252
|
+
anchor: _(t.afterKey, n),
|
|
253
|
+
fallbackIndex: t.index
|
|
254
|
+
}));
|
|
255
|
+
return r.length === 0 ? t.length === e.length ? null : t : c(t, r, o);
|
|
256
|
+
}, g = new Set(d.map(({ key: e }) => e)), _ = (e, t) => {
|
|
257
|
+
let n = e, r = /* @__PURE__ */ new Set();
|
|
258
|
+
for (; n !== null && !t.has(n) && !g.has(n) && !r.has(n);) {
|
|
259
|
+
r.add(n);
|
|
260
|
+
let e = a.rowChanges.removed.get(n);
|
|
261
|
+
if (e === void 0) return n;
|
|
262
|
+
n = e.afterKey;
|
|
263
|
+
}
|
|
264
|
+
return n;
|
|
265
|
+
}, v = (t, r) => {
|
|
266
|
+
if (r && (u.size > 0 || d.length > 0) && m(t) !== null) return t;
|
|
267
|
+
let i = s(t, o), a = null;
|
|
268
|
+
for (let [o, s] of l) {
|
|
269
|
+
let c = f.get(o);
|
|
270
|
+
if (!c) continue;
|
|
271
|
+
let l = i(o, c.index), u = l === void 0 ? void 0 : t[l];
|
|
272
|
+
if (l === void 0 || u === void 0) continue;
|
|
273
|
+
let d = p(u, c.saved, s);
|
|
274
|
+
if (d.length === 0) continue;
|
|
153
275
|
if (r) return t;
|
|
154
|
-
let
|
|
155
|
-
for (let e of
|
|
156
|
-
let t =
|
|
157
|
-
t && n(
|
|
276
|
+
let m = e(u);
|
|
277
|
+
for (let e of d) {
|
|
278
|
+
let t = C.get(e);
|
|
279
|
+
t && n(m, t, c.saved.get(e));
|
|
158
280
|
}
|
|
159
|
-
|
|
281
|
+
m.row !== u && (a ??= t.slice(), a[l] = m.row);
|
|
160
282
|
}
|
|
161
|
-
return
|
|
283
|
+
return m(a ?? t) ?? a;
|
|
162
284
|
};
|
|
163
|
-
|
|
285
|
+
v(a.rows, !0) !== null && y.applyRows((e) => v(e, !1) ?? e);
|
|
164
286
|
};
|
|
165
287
|
return {
|
|
166
|
-
update:
|
|
167
|
-
noteGridRowsChange:
|
|
168
|
-
getUnsavedCells:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
288
|
+
update: V,
|
|
289
|
+
noteGridRowsChange: U,
|
|
290
|
+
getUnsavedCells: W,
|
|
291
|
+
getUnsavedRowKeys: G,
|
|
292
|
+
isAddedRow: K,
|
|
293
|
+
getSummary: F,
|
|
294
|
+
getSavedValue: q,
|
|
295
|
+
getChanges: J,
|
|
296
|
+
markChangesSaved: Q,
|
|
172
297
|
revertChanges: (e) => {
|
|
173
|
-
let t = e ?? [...
|
|
174
|
-
|
|
298
|
+
let t = B(), n = e ?? [...t.records.keys()], r = M(), i = r ? e ? e.filter((e) => t.rowChanges.added.has(e)) : [...t.rowChanges.added.keys()] : [], a = r ? e ? e.filter((e) => t.rowChanges.removed.has(e)) : [...t.rowChanges.removed.keys()] : [];
|
|
299
|
+
$(n.filter((e) => t.records.has(e)).map((e) => ({ rowKey: e })), i, a);
|
|
175
300
|
},
|
|
176
|
-
revert:
|
|
177
|
-
absorbSavedRows: (r,
|
|
178
|
-
let o =
|
|
179
|
-
if (!
|
|
180
|
-
let
|
|
181
|
-
for (let
|
|
182
|
-
let o = i
|
|
301
|
+
revert: te,
|
|
302
|
+
absorbSavedRows: (r, a) => {
|
|
303
|
+
let o = B();
|
|
304
|
+
if (!j() || y === null || o.records.size === 0 && l(o.rowChanges)) return a;
|
|
305
|
+
let u = y.rowKeyGetter, d = s(r, u), f = new Map(o.records), p = null;
|
|
306
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
307
|
+
let o = a[i];
|
|
183
308
|
if (o === void 0) continue;
|
|
184
|
-
let
|
|
185
|
-
if (!
|
|
186
|
-
let
|
|
187
|
-
if (
|
|
188
|
-
let
|
|
189
|
-
for (let [e, r] of
|
|
190
|
-
let i =
|
|
309
|
+
let s = u(o, i), c = f.get(s);
|
|
310
|
+
if (!c?.present) continue;
|
|
311
|
+
let l = d(s, c.index), m = l === void 0 ? void 0 : r[l];
|
|
312
|
+
if (m === void 0 || m === o) continue;
|
|
313
|
+
let h = e(o), g = new Map(c.saved);
|
|
314
|
+
for (let [e, r] of c.saved) {
|
|
315
|
+
let i = C.get(e), a = i ? t(m, i) : void 0;
|
|
191
316
|
if (!i || Object.is(a, r) || Object.is(a, t(o, i))) {
|
|
192
|
-
|
|
317
|
+
g.delete(e);
|
|
193
318
|
continue;
|
|
194
319
|
}
|
|
195
|
-
|
|
320
|
+
g.set(e, t(o, i)), n(h, i, a);
|
|
196
321
|
}
|
|
197
|
-
|
|
198
|
-
saved:
|
|
199
|
-
index:
|
|
322
|
+
g.size === 0 ? f.delete(s) : f.set(s, {
|
|
323
|
+
saved: g,
|
|
324
|
+
index: i,
|
|
200
325
|
present: !0
|
|
201
|
-
}),
|
|
326
|
+
}), h.row !== o && (p ??= a.slice(), p[i] = h.row);
|
|
327
|
+
}
|
|
328
|
+
let m = o.rowChanges;
|
|
329
|
+
if (!l(o.rowChanges)) {
|
|
330
|
+
m = i(o.rowChanges);
|
|
331
|
+
let s = /* @__PURE__ */ new Map();
|
|
332
|
+
a.forEach((e, t) => {
|
|
333
|
+
let n = u(e, t);
|
|
334
|
+
s.has(n) || s.set(n, t);
|
|
335
|
+
});
|
|
336
|
+
let l = [];
|
|
337
|
+
for (let [i, c] of o.rowChanges.added) {
|
|
338
|
+
let o = d(i, c.index), h = o === void 0 ? void 0 : r[o];
|
|
339
|
+
if (o === void 0 || h === void 0) {
|
|
340
|
+
m.added.delete(i);
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
let g = s.get(i);
|
|
344
|
+
if (g === void 0) {
|
|
345
|
+
let e = o > 0 ? r[o - 1] : void 0;
|
|
346
|
+
l.push({
|
|
347
|
+
key: i,
|
|
348
|
+
row: h,
|
|
349
|
+
anchor: e === void 0 ? null : u(e, o - 1),
|
|
350
|
+
fallbackIndex: o
|
|
351
|
+
});
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
if (a[g] === h) continue;
|
|
355
|
+
m.added.delete(i);
|
|
356
|
+
let _ = (p ?? a)[g], v = e(_), y = /* @__PURE__ */ new Map();
|
|
357
|
+
for (let [e, r] of C) {
|
|
358
|
+
let i = t(h, r), a = t(_, r);
|
|
359
|
+
Object.is(i, a) || (y.set(e, a), n(v, r, i));
|
|
360
|
+
}
|
|
361
|
+
y.size > 0 && f.set(i, {
|
|
362
|
+
saved: y,
|
|
363
|
+
index: g,
|
|
364
|
+
present: !0
|
|
365
|
+
}), v.row !== _ && (p ??= a.slice(), p[g] = v.row);
|
|
366
|
+
}
|
|
367
|
+
let h = /* @__PURE__ */ new Set(), g = o.rowChanges.removed.size > 0 && a.some((e, t) => {
|
|
368
|
+
let n = d(u(e, t), t);
|
|
369
|
+
return n !== void 0 && r[n] === e;
|
|
370
|
+
});
|
|
371
|
+
for (let [e, t] of o.rowChanges.removed) {
|
|
372
|
+
let n = s.get(e);
|
|
373
|
+
if (n === void 0) {
|
|
374
|
+
g || m.removed.delete(e);
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
m.removed.set(e, {
|
|
378
|
+
...t,
|
|
379
|
+
row: a[n]
|
|
380
|
+
}), h.add(e);
|
|
381
|
+
}
|
|
382
|
+
if (h.size > 0 || l.length > 0) {
|
|
383
|
+
let e = p ?? a;
|
|
384
|
+
h.size > 0 && (e = e.filter((e, t) => !h.has(u(e, t)))), p = l.length > 0 ? c(e, l, u) : e;
|
|
385
|
+
}
|
|
202
386
|
}
|
|
203
|
-
return
|
|
387
|
+
return x = f, S = m, E = null, z(), N(!0), p ?? a;
|
|
204
388
|
},
|
|
205
|
-
notifyChanges:
|
|
206
|
-
getTrackedColumns: () =>
|
|
207
|
-
getSnapshot: () =>
|
|
208
|
-
subscribe: (e) => (
|
|
209
|
-
|
|
389
|
+
notifyChanges: R,
|
|
390
|
+
getTrackedColumns: () => C,
|
|
391
|
+
getSnapshot: () => O,
|
|
392
|
+
subscribe: (e) => (A.add(e), () => {
|
|
393
|
+
A.delete(e);
|
|
210
394
|
}),
|
|
211
395
|
dispose: () => {
|
|
212
|
-
|
|
213
|
-
rowCount: 0,
|
|
214
|
-
cellCount: 0
|
|
215
|
-
}, w?.({
|
|
216
|
-
rowCount: 0,
|
|
217
|
-
cellCount: 0
|
|
218
|
-
}));
|
|
396
|
+
z(), v(k, _) || (k = { ..._ }, I?.(P(_, L)));
|
|
219
397
|
}
|
|
220
398
|
};
|
|
221
|
-
},
|
|
399
|
+
}, b = (e, t) => {
|
|
222
400
|
if (e.size !== t.size) return !1;
|
|
223
401
|
let n = t.entries();
|
|
224
402
|
for (let [t, r] of e) {
|
|
@@ -230,4 +408,4 @@ var u = () => ({
|
|
|
230
408
|
return !0;
|
|
231
409
|
};
|
|
232
410
|
//#endregion
|
|
233
|
-
export {
|
|
411
|
+
export { y as createChangeTracker };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/detailRow.cjs"),r=require("../model/gridSelectors.cjs"),i=require("../logic/selectLabels.cjs"),a=require("../logic/geometry.cjs"),o=require("../logic/domGuards.cjs"),s=require("../logic/editorValues.cjs"),c=require("../utils/clipboard.cjs"),l=require("../logic/labelRows.cjs"),u=require("../logic/newRow.cjs"),d=require("../logic/pasteFill.cjs"),f=require("../logic/clearCells.cjs"),p=require("./liveUiState.cjs");var m=e=>e.replace(/\r\n?/g,`
|
|
2
|
+
`).replace(/\n+$/,``),h=(e,t,n)=>{if(t===0||n===0||e?.type!==`cell`)return!1;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);return a===0&&o===0&&s===t-1&&c===n-1},ee=(e,t)=>{if(e?.type===`cell`){let n=r.normalizeCellRange(e.range);return t.row>=n.start.row&&t.row<=n.end.row&&t.col>=n.start.col&&t.col<=n.end.col?n.start:t}return e?.type===`col`?{row:0,col:Math.min(e.startCol,e.endCol)}:e?.type===`row`?{row:Math.min(e.startRow,e.endRow),col:0}:t},te=(e,t)=>{let n,r;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);else if(e?.type===`row`)n=Math.min(e.startRow,e.endRow),r=Math.max(e.startRow,e.endRow);else return!1;r=Math.min(r,t.getRowCount()-1);for(let e=Math.max(n,0);e<=r;e+=1)if(t.getRow(e)==null&&t.getLabelRow?.(e)===void 0)return!0;return!1},g=(e,t,n)=>{let r={row:e.row,rowKey:n,rowIndex:t,columnKey:e.column.key,colIndex:e.colIndex,text:e.text,reason:e.reason};return e.reason===`invalid`&&(r.value=e.value,r.message=e.message),r},_=()=>{let r=null,_=e=>{r=e},v=e=>{let{isRowExportable:t,rowModel:n}=e;if(t)return(e,r)=>t(e,{viewRowIndex:r,rowKey:n.getRowKey(r)??r})},y=e=>{let{rowModel:t}=e,n=c.filterClipboardColumns(e.visibleColumns),r=t.getRowCount();if(r===0||n.length===0)return``;let a=v(e),o=[];for(let e=0;e<r;e+=1){let r=t.getRow(e);if(!r||a&&!a(r,e))continue;let s=t.getTreeRow?.(e)?.aggregates;o.push(c.joinTsvRow(n.map(e=>s!==void 0&&e.key in s?i.formatCellClipboardText(e,s[e.key],r):c.formatClipboardCell(r,e))))}return c.joinTsvLines(o)},b=(e,t)=>{let{rowModel:n,visibleColumns:r}=e;return h(t,u.getSelectableRowCount(n),r.length)?y(e):c.serializeSelectionToTsv(n.getRow,n.getRowCount(),r,t,v(e),n.getTreeRow?e=>n.getTreeRow?.(e)?.aggregates:void 0)},x=(e,t,n)=>{let{rowModel:r,visibleColumns:i,readOnly:a,onRowsChange:o,applyServerSideCellEdits:s}=e;if(a||!o&&!s)return;let c=f.resolveClearTarget(t,null,r.getRowCount(),i.length);if(c===null)return;let l=[];for(let e=c.startRow;e<=c.endRow;e+=1)l.push(r.getRow(e)==null?void 0:r.getRowKey(e));let u=[];for(let e=c.startCol;e<=c.endCol;e+=1)u.push(i[e]?.key??``);return{text:n,...c,rowKeys:l,columnKeys:u}},S=async e=>{if(r===null)return;let t=r,n=p.readLiveUiState(t),i=n.selection??(n.activeCell?{type:`cell`,range:{start:n.activeCell,end:n.activeCell}}:null),a=b(t,i);if(a&&await c.writeTextToClipboard(a)&&i){let n=e?x(t,i,a):void 0;n===void 0?t.onCopied?.(i):t.onCopied?.(i,n)}},C=()=>S(!1),w=()=>S(!0),ne=(e,t)=>{let n=e.getLiveCopiedRange?.()??null,r=n?.cut;if(n===null||r===void 0)return null;let i=m(t);if(i!==m(r.text))return null;let{rowModel:a,visibleColumns:o}=e;if(r.endRow>=a.getRowCount()||r.endCol>=o.length)return null;for(let e=0;e<r.rowKeys.length;e+=1){let t=r.startRow+e;if((a.getRow(t)==null?void 0:a.getRowKey(t))!==r.rowKeys[e])return null}for(let e=0;e<r.columnKeys.length;e+=1)if(o[r.startCol+e]?.key!==r.columnKeys[e])return null;return m(b(e,n.selection))===i?r:null},re=(e,n,r)=>{let{rowModel:a,visibleColumns:o,readOnly:c,canEditCell:l}=e;for(let e=n.startRow;e<=n.endRow;e+=1){let u=a.getRow(e);if(u!=null)for(let d=n.startCol;d<=n.endCol;d+=1){let n=o[d];if(n===void 0||r(e,d)||!t.isViewCellEditable({readOnly:c,canEditCell:l},a,e,d,u,n))continue;let f=t.getCellValue(u,n);if(f==null||f===``)continue;if(typeof f==`object`)return!1;let p=s.resolveCellParser(n)(i.formatCellClipboardText(n,f,u),u);if(!Object.is(p,f)&&(typeof p==`object`||String(p)!==String(f)))return!1}}return!0};return{update:_,handleCopy:C,handleCut:w,handlePaste:i=>{if(r===null)return;let s=r,{rows:u,rowModel:m,columns:h,visibleColumns:_,readOnly:y,canEditCell:b,rowKeyGetter:x,createRow:S,createOverflowColumn:C,onRowsChange:w,onColumnsChange:ie,applyServerSideCellEdits:T,onPasteSkipped:ae,localeTexts:oe,pasteFillsSelection:se=!0,dispatch:E}=r,D=p.readLiveUiState(r);if(p.isEditingAtEvent(r)||o.shouldIgnoreGridKeydown(i.target??null)||y||!w&&!T||!D.activeCell)return;let O=i.clipboardData?.getData(`text/plain`)??``;if(!O)return;i.preventDefault();let k=c.parseClipboardText(O);if(k.length===0)return;let A=ne(s,O),ce=se&&A===null?d.expandPasteMatrixToSelection(k,D.selection,D.activeCell,m,_):null,j=ce!==null&&T&&te(D.selection,m)?k:ce??k,M=ae?[]:null,le=()=>{let e=M?.filter(e=>!(e.reason===`readOnly`&&e.text===``));e!==void 0&&e.length>0&&ae?.({cells:e})},ue=j.reduce((e,t)=>Math.max(e,t.length),0);if(ue===0)return;let N=ee(D.selection,D.activeCell),P={row:l.findFirstPasteRow(m,N.row),col:c.resolvePasteColumnIndexes(_,N.col,1)[0]??N.col},F=P.row,I=P.col,L=c.resolvePasteColumnIndexes(_,I,ue),R=L[L.length-1]??I,z=m.getLabelRow!==void 0||m.getGroupRow!==void 0?l.resolvePasteTargetViewIndexes(m,F,j.length):null,B=e=>z?z[e-F]:e,V=z?z[z.length-1]:P.row+Math.max(j.length-1,0),H=A===null?null:{type:`cell`,range:{start:{row:A.startRow,col:A.startCol},end:{row:A.endRow,col:A.endCol}}},U;if(A!==null){let e=new Set;for(let t=0;t<j.length;t+=1)e.add(B(F+t));let t=new Set(L),r=v(s);U=(i,a)=>{if(e.has(i)&&t.has(a))return!0;let o=_[a];if(o===void 0||n.isSyntheticColumnKey(o.key))return!0;let s=m.getRow(i);if(s==null||m.getLabelRow?.(i)!==void 0||m.getGroupRow?.(i)!==void 0)return!0;let c=m.getTreeRow?.(i)?.aggregates;return c!==void 0&&o.key in c?!0:r!==void 0&&!r(s,i)}}let W=A!==null&&U!==void 0&&!re(s,A,U),de=e=>{A!==null&&e!==``&&(W=!0)},fe=(e,t)=>j.some((n,r)=>n.some((n,i)=>n!==``&&(e(r)||(L[i]??t)>=t)));if(T){let n=c.buildClipboardCellEdits(e=>m.getRow(B(e)),_,j,F,I,(e,n,r,i)=>t.isViewCellEditable({readOnly:y,canEditCell:b},m,B(e),n,r,i),M!==null||A!==null?e=>{if(de(e.text),M===null)return;let t=B(e.rowIndex);M.push(g(e,t,m.getRowKey(t)??t))}:void 0,oe).map(e=>({...e,viewIndex:B(e.viewIndex)}));A!==null&&fe(e=>{let t=B(F+e);return t>=m.getRowCount()||m.getRow(t)==null},_.length)&&(W=!0);let r=H===null||W?[]:f.buildClearCellEdits({getRow:e=>m.getRow(e),columns:_,selection:H,activeCell:null,viewRowCount:m.getRowCount(),canWriteCell:(e,n,r,i)=>t.isViewCellEditable({readOnly:y,canEditCell:b},m,e,n,r,i),skipCell:U});(n.length>0||r.length>0)&&T([...r,...n]);let i=a.clamp(V,0,Math.max(m.getRowCount()-1,0)),o=a.clamp(R,0,Math.max(_.length-1,0));E(e.gridActions.startSelection(P)),E(e.gridActions.updateSelection({row:i,col:o})),E(e.gridActions.endSelection()),E(e.gridActions.activateCell(P)),A!==null&&s.onCutPasted?.(),le();return}if(!w)return;let G=m.newRow,K=G!==void 0&&F>=G.index;if(m.getSourceIndex(F)===void 0&&!K)return;let pe=P.col,q=[...u],J=[..._],Y=G===void 0?m.getRowCount():G.index,me=q.length,he=e=>{let t=B(e);return t<Y?m.getSourceIndex(t):me+(t-Y)},ge=Math.max(V+1-Y,0),_e=q.length+ge,X=K&&ge>0?G?.peekRow():void 0;if(_e>q.length&&S)for(X!==void 0&&q.push(X);q.length<_e;)q.push(S());let ve=R+1,Z=[];if(ve>J.length&&ie&&C)for(;J.length<ve;){let e=C(J.length);J.push(e),Z.push(e)}let ye=(e,t,n)=>(e<Y?m.getRowKey(e):x?.(t,n)??n)??n,be=c.applyClipboardMatrixToRows(q,he,J,j,F,pe,(e,n,r,i,a)=>{let o=B(a);return t.isCellEditable({readOnly:y,canEditCell:b},o,n,r,i,{sourceRowIndex:e,rowKey:ye(o,r,e)})},M!==null||A!==null?e=>{if(de(e.text),M===null)return;let t=B(e.rowIndex),n=e.sourceRowIndex??t;M.push(g(e,t,ye(t,e.row,n)))}:void 0,oe),Q=be!==q;A!==null&&fe(e=>{let t=he(F+e);return t===void 0||t>=q.length},J.length)&&(W=!0);let xe=Q?be:u,$=H===null||W?xe:f.clearCellsInSelection({rows:xe,resolveSourceIndex:e=>m.getSourceIndex(e),columns:_,selection:H,activeCell:null,viewRowCount:m.getRowCount(),canWriteCell:(e,n,r,i,a)=>t.isViewCellEditable({readOnly:y,canEditCell:b},m,a,n,r,i),skipCell:U}).nextRows;if(!Q&&M!==null){let e=M.filter(e=>e.rowIndex<Y&&e.colIndex<_.length);M.length=0,M.push(...e)}let Se=a.clamp(V,0,Math.max(Q&&q.length>u.length?V:Y-1,0)),Ce=a.clamp(R,0,Math.max((Q?J:_).length-1,0));Q?(G!==void 0&&q.length>u.length&&(X!==void 0&&G.takeRow(),G.noteAppended(q.length-u.length)),Z.length>0&&ie?.(h?[...h,...Z]:J),w($)):$!==u&&w($),E(e.gridActions.startSelection(P)),E(e.gridActions.updateSelection({row:Se,col:Ce})),E(e.gridActions.endSelection()),E(e.gridActions.activateCell(P)),A!==null&&s.onCutPasted?.(),le()}}};exports.computeIsWholeGridSelected=h,exports.createClipboardController=_,exports.resolvePasteAnchor=ee;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type GridUiAction } from '../model/gridActions.js';
|
|
2
2
|
import type { CellCoord, GridColumn, GridRowKey, GridSelection, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
|
|
3
|
+
import type { GridCopiedRange, GridCutSource } from '../model/gridStore.js';
|
|
3
4
|
import type { ServerSideCellEditInput } from '../logic/serverSideEdits.js';
|
|
4
5
|
import type { ValidationLocaleText } from '../logic/validation.js';
|
|
5
6
|
export type ClipboardEventLike = {
|
|
@@ -29,11 +30,14 @@ export type ClipboardControllerArgs<T extends object> = {
|
|
|
29
30
|
onPasteSkipped?: SpreadsheetGridProps<T>['onPasteSkipped'];
|
|
30
31
|
localeTexts?: ValidationLocaleText;
|
|
31
32
|
pasteFillsSelection?: boolean;
|
|
32
|
-
onCopied?: (selection: NonNullable<GridSelection
|
|
33
|
+
onCopied?: (selection: NonNullable<GridSelection>, cut?: GridCutSource) => void;
|
|
34
|
+
getLiveCopiedRange?: (() => GridCopiedRange | null) | undefined;
|
|
35
|
+
onCutPasted?: (() => void) | undefined;
|
|
33
36
|
};
|
|
34
37
|
export type ClipboardController<T extends object> = {
|
|
35
38
|
update: (args: ClipboardControllerArgs<T>) => void;
|
|
36
39
|
handleCopy: () => Promise<void>;
|
|
40
|
+
handleCut: () => Promise<void>;
|
|
37
41
|
handlePaste: (event: ClipboardEventLike) => void;
|
|
38
42
|
};
|
|
39
43
|
export declare const computeIsWholeGridSelected: (selection: GridSelection, viewRowCount: number, columnCount: number) => boolean;
|