@univerjs/sheets-source-binding 0.5.4-nightly.202501160647 → 0.5.4-nightly.202501160704
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/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +22 -13
- package/lib/es/index.js +383 -255
- package/lib/types/controllers/binding-manager.d.ts +11 -4
- package/lib/types/controllers/source-manager.d.ts +4 -1
- package/lib/types/facade/f-workbook.d.ts +29 -3
- package/lib/types/index.d.ts +2 -1
- package/lib/types/model/binding-model.d.ts +4 -4
- package/lib/types/model/source-model.d.ts +7 -4
- package/lib/types/services/source-binding-service.d.ts +7 -1
- package/lib/types/types.d.ts +15 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +3 -3
package/lib/es/index.js
CHANGED
@@ -1,61 +1,76 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var u = (
|
4
|
-
import { Disposable as
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
class
|
8
|
-
constructor(
|
1
|
+
var G = Object.defineProperty;
|
2
|
+
var H = (i, e, t) => e in i ? G(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
3
|
+
var u = (i, e, t) => H(i, typeof e != "symbol" ? e + "" : e, t);
|
4
|
+
import { CellValueType as E, Inject as S, Disposable as y, Range as q, generateRandomId as j, IUniverInstanceService as z, RTree as F, InterceptorEffectEnum as T, Plugin as K, UniverInstanceType as Q, touchDependencies as X, Injector as Y, IConfigService as Z } from "@univerjs/core";
|
5
|
+
import { SheetInterceptorService as J, SheetsSelectionsService as k, getSheetCommandTarget as ee, ClearSelectionContentCommand as te, ClearSelectionAllCommand as ne, INTERCEPTOR_POINT as oe } from "@univerjs/sheets";
|
6
|
+
import { Subject as V } from "rxjs";
|
7
|
+
class O {
|
8
|
+
constructor(e) {
|
9
9
|
u(this, "_matrix", {});
|
10
10
|
u(this, "_nodeMap", /* @__PURE__ */ new Map());
|
11
11
|
u(this, "_sourceIdMap", /* @__PURE__ */ new Map());
|
12
|
-
|
12
|
+
e && this._init(e);
|
13
13
|
}
|
14
|
-
_init(
|
15
|
-
this.fromJSON();
|
14
|
+
_init(e) {
|
15
|
+
this.fromJSON(e);
|
16
16
|
}
|
17
|
-
getBindingNodesBySourceId(
|
18
|
-
const
|
19
|
-
if (
|
20
|
-
return
|
17
|
+
getBindingNodesBySourceId(e) {
|
18
|
+
const t = this._sourceIdMap.get(e);
|
19
|
+
if (t)
|
20
|
+
return t.map((n) => this._nodeMap.get(n));
|
21
21
|
}
|
22
|
-
setBindingNode(
|
23
|
-
this._matrix[
|
24
|
-
const
|
25
|
-
|
26
|
-
}
|
27
|
-
getBindingNode(o, e) {
|
28
|
-
var t;
|
29
|
-
return (t = this._matrix[o]) == null ? void 0 : t[e];
|
22
|
+
setBindingNode(e, t, n) {
|
23
|
+
this._matrix[e] || (this._matrix[e] = {}), this._matrix[e][t] || (this._matrix[e][t] = n), this._nodeMap.set(n.nodeId, n);
|
24
|
+
const o = this._sourceIdMap.get(n.sourceId);
|
25
|
+
o ? o.push(n.nodeId) : this._sourceIdMap.set(n.sourceId, [n.nodeId]);
|
30
26
|
}
|
31
|
-
|
27
|
+
getBindingNode(e, t) {
|
32
28
|
var n;
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
return (n = this._matrix[e]) == null ? void 0 : n[t];
|
30
|
+
}
|
31
|
+
removeBindingNode(e, t) {
|
32
|
+
var o;
|
33
|
+
const n = (o = this._matrix[e]) == null ? void 0 : o[t];
|
34
|
+
if (n) {
|
35
|
+
this._matrix[e][t] = void 0, this._nodeMap.delete(n.nodeId);
|
36
|
+
const s = this._sourceIdMap.get(n.sourceId);
|
37
37
|
if (s) {
|
38
|
-
const r = s.indexOf(
|
39
|
-
r >= 0 && s.splice(r, 1), s.length === 0 && this._sourceIdMap.delete(
|
38
|
+
const r = s.indexOf(n.nodeId);
|
39
|
+
r >= 0 && s.splice(r, 1), s.length === 0 && this._sourceIdMap.delete(n.sourceId);
|
40
40
|
}
|
41
41
|
}
|
42
42
|
}
|
43
|
-
getBindingNodeById(
|
44
|
-
return this._nodeMap.get(
|
43
|
+
getBindingNodeById(e) {
|
44
|
+
return this._nodeMap.get(e);
|
45
45
|
}
|
46
|
-
fromJSON() {
|
46
|
+
fromJSON(e) {
|
47
|
+
e.forEach((t) => {
|
48
|
+
this.setBindingNode(t.row, t.column, t);
|
49
|
+
});
|
47
50
|
}
|
48
51
|
toJSON() {
|
52
|
+
return Array.from(this._nodeMap.values());
|
49
53
|
}
|
50
54
|
}
|
51
|
-
var
|
52
|
-
|
53
|
-
|
55
|
+
var f = /* @__PURE__ */ ((i) => (i.List = "list", i.Object = "object", i))(f || {}), m = /* @__PURE__ */ ((i) => (i.Path = "path", i.Value = "value", i))(m || {}), M = /* @__PURE__ */ ((i) => (i.Add = "add", i.Remove = "remove", i.Update = "update", i))(M || {});
|
56
|
+
function se(i) {
|
57
|
+
return i instanceof Date && !isNaN(i.getTime());
|
58
|
+
}
|
59
|
+
function L(i) {
|
60
|
+
const e = new Date(i);
|
61
|
+
if (!se(e))
|
62
|
+
return i;
|
63
|
+
const t = new Date(Date.UTC(1900, 0, 1, 0, 0, 0)), n = new Date(Date.UTC(1900, 1, 28, 0, 0, 0));
|
64
|
+
let s = (e.getTime() - t.getTime()) / (1e3 * 3600 * 24);
|
65
|
+
return e > n && (s += 1), s + 1;
|
66
|
+
}
|
67
|
+
class D {
|
68
|
+
constructor(e) {
|
54
69
|
u(this, "_data");
|
55
70
|
u(this, "id");
|
56
71
|
u(this, "_hasData", !1);
|
57
72
|
u(this, "type");
|
58
|
-
this.id =
|
73
|
+
this.id = e;
|
59
74
|
}
|
60
75
|
getId() {
|
61
76
|
return this.id;
|
@@ -66,36 +81,60 @@ class N {
|
|
66
81
|
hasData() {
|
67
82
|
return this._hasData;
|
68
83
|
}
|
69
|
-
setSourceData(
|
70
|
-
this._data =
|
84
|
+
setSourceData(e) {
|
85
|
+
this._data = e, this._hasData = !0;
|
86
|
+
}
|
87
|
+
toJSON() {
|
88
|
+
return {
|
89
|
+
id: this.id,
|
90
|
+
type: this.type
|
91
|
+
};
|
92
|
+
}
|
93
|
+
fromJSON(e) {
|
94
|
+
this.id = e.id, this.type = e.type;
|
71
95
|
}
|
72
96
|
}
|
73
|
-
class
|
74
|
-
constructor(
|
75
|
-
super(
|
76
|
-
u(this, "type",
|
97
|
+
class U extends D {
|
98
|
+
constructor(t, n) {
|
99
|
+
super(t);
|
100
|
+
u(this, "type", f.List);
|
77
101
|
u(this, "_isListObject");
|
78
102
|
u(this, "_fieldIndexMap", /* @__PURE__ */ new Map());
|
79
103
|
u(this, "_data", { fields: [], records: [] });
|
80
|
-
this._isListObject =
|
104
|
+
this._isListObject = n != null ? n : !0;
|
81
105
|
}
|
82
106
|
/**
|
83
107
|
* Toggle the list object mode. The default value is true.
|
84
108
|
* In the list object mode, the records is an array of objects. Such as [{name: 'Tom', age: 20}, {name: 'Jerry', age: 18}].
|
85
109
|
* In the list array mode, the records is an array of arrays. Such as [['Tom', 20], ['Jerry', 18]].
|
86
110
|
*/
|
87
|
-
toggleListObject(
|
88
|
-
this._isListObject =
|
89
|
-
}
|
90
|
-
getData(
|
91
|
-
const { path:
|
92
|
-
|
111
|
+
toggleListObject(t) {
|
112
|
+
this._isListObject = t;
|
113
|
+
}
|
114
|
+
getData(t, n) {
|
115
|
+
const { path: o, row: s } = t, r = this._fieldIndexMap.get(o), d = n - s;
|
116
|
+
if (d === 0)
|
117
|
+
return {
|
118
|
+
v: this._data.fields[r]
|
119
|
+
};
|
120
|
+
let a;
|
121
|
+
return this._isListObject && (a = this._data.records[d - 1][o]), a = this._data.records[d - 1][r], t.isDate === !0 ? {
|
122
|
+
v: L(a),
|
123
|
+
s: {
|
124
|
+
n: {
|
125
|
+
pattern: "yyyy-m-d am/pm h:mm"
|
126
|
+
}
|
127
|
+
},
|
128
|
+
t: E.NUMBER
|
129
|
+
} : {
|
130
|
+
v: a
|
131
|
+
};
|
93
132
|
}
|
94
|
-
setSourceData(
|
95
|
-
super.setSourceData(
|
96
|
-
const { fields:
|
97
|
-
this._fieldIndexMap.clear(),
|
98
|
-
this._fieldIndexMap.set(
|
133
|
+
setSourceData(t) {
|
134
|
+
super.setSourceData(t);
|
135
|
+
const { fields: n } = t;
|
136
|
+
this._fieldIndexMap.clear(), n.forEach((o, s) => {
|
137
|
+
this._fieldIndexMap.set(o, s);
|
99
138
|
});
|
100
139
|
}
|
101
140
|
getSourceInfo() {
|
@@ -107,173 +146,252 @@ class F extends N {
|
|
107
146
|
};
|
108
147
|
}
|
109
148
|
}
|
110
|
-
class
|
111
|
-
constructor(
|
112
|
-
super(
|
113
|
-
u(this, "type",
|
149
|
+
class P extends D {
|
150
|
+
constructor(t) {
|
151
|
+
super(t);
|
152
|
+
u(this, "type", f.Object);
|
114
153
|
}
|
115
|
-
getData(
|
116
|
-
const
|
154
|
+
getData(t) {
|
155
|
+
const o = t.path.split(".");
|
117
156
|
let s = this._data;
|
118
|
-
for (const r of
|
157
|
+
for (const r of o)
|
119
158
|
if (s = s[r], s === void 0)
|
120
159
|
return null;
|
121
|
-
return
|
160
|
+
return t.isDate === !0 ? {
|
161
|
+
v: L(s),
|
162
|
+
s: {
|
163
|
+
n: {
|
164
|
+
pattern: "yyyy-m-d am/pm h:mm"
|
165
|
+
}
|
166
|
+
},
|
167
|
+
t: E.NUMBER
|
168
|
+
} : {
|
169
|
+
v: s
|
170
|
+
};
|
122
171
|
}
|
123
172
|
getSourceInfo() {
|
124
173
|
return {
|
125
174
|
sourceId: this.id,
|
126
|
-
sourceType:
|
175
|
+
sourceType: f.Object
|
127
176
|
};
|
128
177
|
}
|
129
178
|
}
|
130
|
-
|
131
|
-
|
179
|
+
var re = Object.defineProperty, ie = Object.getOwnPropertyDescriptor, de = (i, e, t, n) => {
|
180
|
+
for (var o = n > 1 ? void 0 : n ? ie(e, t) : e, s = i.length - 1, r; s >= 0; s--)
|
181
|
+
(r = i[s]) && (o = (n ? r(e, t, o) : r(o)) || o);
|
182
|
+
return n && o && re(e, t, o), o;
|
183
|
+
}, w = (i, e) => (t, n) => e(t, n, i);
|
184
|
+
let v = class extends y {
|
185
|
+
constructor(e, t, n) {
|
132
186
|
super();
|
133
187
|
u(this, "modelMap", /* @__PURE__ */ new Map());
|
134
|
-
u(this, "_cellBindInfoUpdate$", new
|
188
|
+
u(this, "_cellBindInfoUpdate$", new V());
|
135
189
|
u(this, "cellBindInfoUpdate$", this._cellBindInfoUpdate$.asObservable());
|
190
|
+
this._univerInstanceService = e, this._sheetInterceptorService = t, this._sheetsSelectionsService = n, this._initRemoveCommand();
|
191
|
+
}
|
192
|
+
_initRemoveCommand() {
|
193
|
+
this.disposeWithMe(
|
194
|
+
this._sheetInterceptorService.interceptCommand({
|
195
|
+
getMutations: (e) => {
|
196
|
+
const t = [], n = [], o = this._sheetsSelectionsService.getCurrentSelections(), s = ee(this._univerInstanceService);
|
197
|
+
if (!s || !o || o.length === 0)
|
198
|
+
return {
|
199
|
+
redos: [],
|
200
|
+
undos: []
|
201
|
+
};
|
202
|
+
const { unitId: r, subUnitId: d } = s;
|
203
|
+
return (e.id === te.id || e.id === ne.id) && o.forEach(({ range: a }) => {
|
204
|
+
q.foreach(a, (c, l) => {
|
205
|
+
this.getBindingNode(r, d, c, l) && this.removeBindingNode(r, d, c, l);
|
206
|
+
});
|
207
|
+
}), { redos: t, undos: n };
|
208
|
+
}
|
209
|
+
})
|
210
|
+
);
|
136
211
|
}
|
137
212
|
getBindingModelBySourceId(e) {
|
138
213
|
const t = [];
|
139
|
-
return this.modelMap.forEach((n,
|
140
|
-
n.forEach((
|
141
|
-
const
|
142
|
-
if (
|
143
|
-
for (const
|
214
|
+
return this.modelMap.forEach((n, o) => {
|
215
|
+
n.forEach((s, r) => {
|
216
|
+
const d = s.getBindingNodesBySourceId(e);
|
217
|
+
if (d)
|
218
|
+
for (const a of d)
|
144
219
|
t.push({
|
145
|
-
unitId:
|
146
|
-
subunitId:
|
220
|
+
unitId: o,
|
221
|
+
subunitId: r,
|
147
222
|
sourceId: e,
|
148
|
-
nodeId:
|
149
|
-
row:
|
150
|
-
column:
|
223
|
+
nodeId: a.nodeId,
|
224
|
+
row: a.row,
|
225
|
+
column: a.column
|
151
226
|
});
|
152
227
|
});
|
153
228
|
}), t;
|
154
229
|
}
|
155
230
|
addModel(e, t, n) {
|
156
|
-
var
|
157
|
-
this.modelMap.has(e) || this.modelMap.set(e, /* @__PURE__ */ new Map()), (
|
231
|
+
var o;
|
232
|
+
this.modelMap.has(e) || this.modelMap.set(e, /* @__PURE__ */ new Map()), (o = this.modelMap.get(e)) == null || o.set(t, n);
|
158
233
|
}
|
159
234
|
getModel(e, t) {
|
160
235
|
var n;
|
161
236
|
return (n = this.modelMap.get(e)) == null ? void 0 : n.get(t);
|
162
237
|
}
|
163
238
|
setBindingNode(e, t, n) {
|
164
|
-
let
|
165
|
-
|
166
|
-
const { row:
|
167
|
-
if (
|
239
|
+
let o = this.getModel(e, t);
|
240
|
+
o || (o = new O(), this.addModel(e, t, o)), n.nodeId || (n.nodeId = j());
|
241
|
+
const { row: s, column: r } = n;
|
242
|
+
if (s === void 0 || r === void 0)
|
168
243
|
throw new Error("row and column is required");
|
169
|
-
const
|
170
|
-
|
244
|
+
const d = o.getBindingNode(s, r);
|
245
|
+
o.setBindingNode(s, r, { ...n, row: s, column: r }), this._cellBindInfoUpdate$.next({
|
171
246
|
unitId: e,
|
172
247
|
subunitId: t,
|
173
248
|
sourceId: n.sourceId,
|
174
249
|
nodeId: n.nodeId,
|
175
|
-
row:
|
176
|
-
column:
|
177
|
-
changeType:
|
178
|
-
oldSourceId:
|
250
|
+
row: s,
|
251
|
+
column: r,
|
252
|
+
changeType: d ? M.Update : M.Add,
|
253
|
+
oldSourceId: d == null ? void 0 : d.sourceId
|
179
254
|
});
|
180
255
|
}
|
181
|
-
removeBindingNode(e, t, n,
|
182
|
-
const
|
183
|
-
if (
|
184
|
-
const
|
185
|
-
|
256
|
+
removeBindingNode(e, t, n, o) {
|
257
|
+
const s = this.getModel(e, t);
|
258
|
+
if (s) {
|
259
|
+
const r = s.getBindingNode(n, o);
|
260
|
+
r && (s.removeBindingNode(n, o), this._cellBindInfoUpdate$.next({
|
186
261
|
unitId: e,
|
187
262
|
subunitId: t,
|
188
|
-
sourceId:
|
189
|
-
nodeId:
|
263
|
+
sourceId: r.sourceId,
|
264
|
+
nodeId: r.nodeId,
|
190
265
|
row: n,
|
191
|
-
column:
|
192
|
-
changeType:
|
266
|
+
column: o,
|
267
|
+
changeType: M.Remove
|
193
268
|
}));
|
194
269
|
}
|
195
270
|
}
|
196
|
-
getBindingNode(e, t, n,
|
197
|
-
const
|
198
|
-
if (
|
199
|
-
return
|
271
|
+
getBindingNode(e, t, n, o) {
|
272
|
+
const s = this.getModel(e, t);
|
273
|
+
if (s)
|
274
|
+
return s.getBindingNode(n, o);
|
200
275
|
}
|
201
276
|
createModel(e, t, n) {
|
202
|
-
const
|
203
|
-
return this.addModel(e, t,
|
277
|
+
const o = new O(n);
|
278
|
+
return this.addModel(e, t, o), o;
|
279
|
+
}
|
280
|
+
toJSON(e) {
|
281
|
+
const t = {}, n = this.modelMap.get(e);
|
282
|
+
return n && n.forEach((o, s) => {
|
283
|
+
t[s] = o.toJSON();
|
284
|
+
}), t;
|
285
|
+
}
|
286
|
+
fromJSON(e, t) {
|
287
|
+
Object.entries(t).forEach(([n, o]) => {
|
288
|
+
this.createModel(e, n, o);
|
289
|
+
});
|
204
290
|
}
|
205
291
|
dispose() {
|
206
|
-
this.modelMap.clear();
|
292
|
+
this.modelMap.clear(), this._cellBindInfoUpdate$.complete();
|
207
293
|
}
|
208
|
-
}
|
209
|
-
|
294
|
+
};
|
295
|
+
v = de([
|
296
|
+
w(0, z),
|
297
|
+
w(1, S(J)),
|
298
|
+
w(2, S(k))
|
299
|
+
], v);
|
300
|
+
class R extends y {
|
210
301
|
constructor() {
|
211
302
|
super();
|
212
303
|
u(this, "sourceMap", /* @__PURE__ */ new Map());
|
213
|
-
u(this, "_sourceDataUpdate$", new
|
304
|
+
u(this, "_sourceDataUpdate$", new V());
|
214
305
|
u(this, "sourceDataUpdate$", this._sourceDataUpdate$.asObservable());
|
215
306
|
}
|
216
|
-
_ensureUnitMap(
|
217
|
-
let
|
218
|
-
return
|
307
|
+
_ensureUnitMap(t) {
|
308
|
+
let n = this.sourceMap.get(t);
|
309
|
+
return n || (n = /* @__PURE__ */ new Map(), this.sourceMap.set(t, n)), n;
|
219
310
|
}
|
220
|
-
_getUnitMap(
|
221
|
-
return this.sourceMap.get(
|
311
|
+
_getUnitMap(t) {
|
312
|
+
return this.sourceMap.get(t);
|
222
313
|
}
|
223
|
-
getSource(
|
224
|
-
const
|
225
|
-
return
|
226
|
-
}
|
227
|
-
createSource(
|
228
|
-
const r = s === void 0 ?
|
229
|
-
let
|
230
|
-
switch (
|
231
|
-
case
|
232
|
-
|
314
|
+
getSource(t, n) {
|
315
|
+
const o = this._getUnitMap(t);
|
316
|
+
return o == null ? void 0 : o.get(n);
|
317
|
+
}
|
318
|
+
createSource(t, n, o, s) {
|
319
|
+
const r = s === void 0 ? j() : s;
|
320
|
+
let d;
|
321
|
+
switch (n) {
|
322
|
+
case f.List:
|
323
|
+
d = new U(r, o);
|
233
324
|
break;
|
234
|
-
case
|
235
|
-
|
325
|
+
case f.Object:
|
326
|
+
d = new P(r);
|
236
327
|
break;
|
237
328
|
default:
|
238
|
-
throw new Error(`Invalid source type: ${
|
329
|
+
throw new Error(`Invalid source type: ${n}`);
|
239
330
|
}
|
240
|
-
return this._ensureUnitMap(
|
331
|
+
return this._ensureUnitMap(t).set(r, d), d;
|
241
332
|
}
|
242
|
-
updateSourceData(
|
243
|
-
const s = this._getUnitMap(
|
244
|
-
if (
|
245
|
-
|
333
|
+
updateSourceData(t, n, o) {
|
334
|
+
const s = this._getUnitMap(t), r = n instanceof D ? n.getId() : n, d = s == null ? void 0 : s.get(r);
|
335
|
+
if (d)
|
336
|
+
d.setSourceData(o), this._sourceDataUpdate$.next({ ...d.getSourceInfo(), unitId: t, changeType: M.Add });
|
246
337
|
else
|
247
338
|
throw new Error(`Source not found: ${r}`);
|
248
339
|
}
|
249
|
-
removeSource(
|
250
|
-
const
|
251
|
-
s && (
|
340
|
+
removeSource(t, n) {
|
341
|
+
const o = this._getUnitMap(t), s = o == null ? void 0 : o.get(n);
|
342
|
+
s && (o == null || o.delete(n), this._sourceDataUpdate$.next({ ...s.getSourceInfo(), unitId: t, changeType: M.Remove }));
|
343
|
+
}
|
344
|
+
toJSON(t) {
|
345
|
+
const n = [], o = this._getUnitMap(t);
|
346
|
+
if (o)
|
347
|
+
for (const s of o.values())
|
348
|
+
n.push(s.toJSON());
|
349
|
+
return n;
|
350
|
+
}
|
351
|
+
fromJSON(t, n) {
|
352
|
+
const o = this._ensureUnitMap(t);
|
353
|
+
for (const s of n) {
|
354
|
+
let r;
|
355
|
+
switch (s.type) {
|
356
|
+
case f.List:
|
357
|
+
r = new U(s.id);
|
358
|
+
break;
|
359
|
+
case f.Object:
|
360
|
+
r = new P(s.id);
|
361
|
+
break;
|
362
|
+
default:
|
363
|
+
throw new Error(`Invalid source type: ${s.type}`);
|
364
|
+
}
|
365
|
+
r.fromJSON(s), o.set(s.id, r);
|
366
|
+
}
|
367
|
+
}
|
368
|
+
dispose() {
|
369
|
+
this._sourceDataUpdate$.complete(), this.sourceMap.clear();
|
252
370
|
}
|
253
371
|
}
|
254
|
-
var
|
255
|
-
for (var
|
256
|
-
(r =
|
257
|
-
return
|
258
|
-
},
|
259
|
-
let
|
260
|
-
constructor(
|
372
|
+
var ae = Object.defineProperty, ce = Object.getOwnPropertyDescriptor, ue = (i, e, t, n) => {
|
373
|
+
for (var o = n > 1 ? void 0 : n ? ce(e, t) : e, s = i.length - 1, r; s >= 0; s--)
|
374
|
+
(r = i[s]) && (o = (n ? r(e, t, o) : r(o)) || o);
|
375
|
+
return n && o && ae(e, t, o), o;
|
376
|
+
}, b = (i, e) => (t, n) => e(t, n, i);
|
377
|
+
let N = class extends y {
|
378
|
+
constructor(e, t, n) {
|
261
379
|
super();
|
262
|
-
u(this, "_bindingModel",
|
380
|
+
u(this, "_bindingModel", m.Value);
|
263
381
|
u(this, "_bindModelRTreeCollection", /* @__PURE__ */ new Map());
|
264
|
-
this._sheetInterceptorService =
|
382
|
+
this._sheetInterceptorService = e, this._sheetsBindingManager = t, this._sheetsSourceManager = n, this._registerInterceptor(), this._registerSourceChange();
|
265
383
|
}
|
266
384
|
/**
|
267
385
|
* Set the binding model to path mode, in this mode, the binding path will show in the cell.
|
268
386
|
*/
|
269
387
|
usePathMode() {
|
270
|
-
this._bindingModel =
|
388
|
+
this._bindingModel = m.Path;
|
271
389
|
}
|
272
390
|
/**
|
273
391
|
* Set the binding model to value mode, in this mode, the value of source will show in the cell.
|
274
392
|
*/
|
275
393
|
useValueMode() {
|
276
|
-
this._bindingModel =
|
394
|
+
this._bindingModel = m.Value;
|
277
395
|
}
|
278
396
|
/**
|
279
397
|
* Get the current binding model.
|
@@ -282,180 +400,190 @@ let v = class extends T {
|
|
282
400
|
getBindingModel() {
|
283
401
|
return this._bindingModel;
|
284
402
|
}
|
285
|
-
createBindModel(
|
286
|
-
return this._sheetsBindingManager.createModel(
|
403
|
+
createBindModel(e, t) {
|
404
|
+
return this._sheetsBindingManager.createModel(e, t);
|
287
405
|
}
|
288
|
-
setBindingNode(
|
289
|
-
this._sheetsBindingManager.setBindingNode(
|
406
|
+
setBindingNode(e, t, n) {
|
407
|
+
this._sheetsBindingManager.setBindingNode(e, t, n);
|
290
408
|
}
|
291
|
-
removeBindingNode(
|
292
|
-
this._sheetsBindingManager.removeBindingNode(
|
409
|
+
removeBindingNode(e, t, n, o) {
|
410
|
+
this._sheetsBindingManager.removeBindingNode(e, t, n, o);
|
293
411
|
}
|
294
|
-
getBindingNode(
|
295
|
-
return this._sheetsBindingManager.getBindingNode(
|
412
|
+
getBindingNode(e, t, n, o) {
|
413
|
+
return this._sheetsBindingManager.getBindingNode(e, t, n, o);
|
296
414
|
}
|
297
|
-
getSource(
|
298
|
-
return this._sheetsSourceManager.getSource(
|
415
|
+
getSource(e, t) {
|
416
|
+
return this._sheetsSourceManager.getSource(e, t);
|
299
417
|
}
|
300
|
-
createSource(
|
301
|
-
return this._sheetsSourceManager.createSource(
|
418
|
+
createSource(e, t, n, o) {
|
419
|
+
return this._sheetsSourceManager.createSource(e, t, n, o);
|
420
|
+
}
|
421
|
+
getSourceBindingPathInfo(e) {
|
422
|
+
return {
|
423
|
+
source: this._sheetsSourceManager.toJSON(e),
|
424
|
+
cellBinding: this._sheetsBindingManager.toJSON(e)
|
425
|
+
};
|
302
426
|
}
|
303
|
-
|
304
|
-
|
427
|
+
loadSourceBindingPathInfo(e, t) {
|
428
|
+
this._sheetsSourceManager.fromJSON(e, t.source), this._sheetsBindingManager.fromJSON(e, t.cellBinding);
|
305
429
|
}
|
306
|
-
|
307
|
-
return this._bindModelRTreeCollection.get(
|
430
|
+
_ensureRTreeCollection(e) {
|
431
|
+
return this._bindModelRTreeCollection.has(e) || this._bindModelRTreeCollection.set(e, new F()), this._bindModelRTreeCollection.get(e);
|
432
|
+
}
|
433
|
+
_getRTeeCollection(e) {
|
434
|
+
return this._bindModelRTreeCollection.get(e);
|
308
435
|
}
|
309
436
|
// eslint-disable-next-line max-lines-per-function
|
310
437
|
_registerSourceChange() {
|
311
|
-
this.disposeWithMe(this._sheetsSourceManager.sourceDataUpdate$.subscribe((
|
312
|
-
const { sourceId:
|
313
|
-
if (
|
314
|
-
if (s ===
|
315
|
-
const
|
316
|
-
for (const { unitId: c, subunitId:
|
317
|
-
const
|
318
|
-
if (
|
319
|
-
const I = { startRow:
|
320
|
-
|
438
|
+
this.disposeWithMe(this._sheetsSourceManager.sourceDataUpdate$.subscribe((e) => {
|
439
|
+
const { sourceId: t, sourceType: n, unitId: o, changeType: s } = e;
|
440
|
+
if (n === f.List) {
|
441
|
+
if (s === M.Remove) {
|
442
|
+
const d = this._sheetsBindingManager.getBindingModelBySourceId(t), a = e.recordCount;
|
443
|
+
for (const { unitId: c, subunitId: l, nodeId: h, row: p, column: g } of d) {
|
444
|
+
const _ = this._getRTeeCollection(o);
|
445
|
+
if (_) {
|
446
|
+
const I = { startRow: p, startColumn: g, endRow: p + a, endColumn: g };
|
447
|
+
_.remove({ unitId: c, sheetId: l, id: h, range: I });
|
321
448
|
}
|
322
449
|
}
|
323
450
|
return;
|
324
451
|
}
|
325
|
-
if (s ===
|
326
|
-
const
|
327
|
-
for (const { unitId: c, subunitId:
|
328
|
-
const
|
329
|
-
if (
|
330
|
-
const I = { startRow:
|
331
|
-
|
452
|
+
if (s === M.Update) {
|
453
|
+
const d = e.oldRecordCount, a = this._sheetsBindingManager.getBindingModelBySourceId(t);
|
454
|
+
for (const { unitId: c, subunitId: l, nodeId: h, row: p, column: g } of a) {
|
455
|
+
const _ = this._getRTeeCollection(o);
|
456
|
+
if (_) {
|
457
|
+
const I = { startRow: p, startColumn: g, endRow: p + d, endColumn: g }, B = { startRow: p, startColumn: g, endRow: p + e.recordCount, endColumn: g };
|
458
|
+
_.remove({ unitId: c, sheetId: l, id: h, range: I }), _.insert({ unitId: c, sheetId: l, id: h, range: B });
|
332
459
|
}
|
333
460
|
}
|
334
461
|
return;
|
335
462
|
}
|
336
|
-
const r = this._sheetsSourceManager.getSource(
|
463
|
+
const r = this._sheetsSourceManager.getSource(o, t);
|
337
464
|
if (r && r.hasData()) {
|
338
|
-
const a = r.getSourceInfo().recordCount, c = this._sheetsBindingManager.getBindingModelBySourceId(
|
339
|
-
for (const { unitId:
|
340
|
-
const I = this._ensureRTreeCollection(
|
341
|
-
I.insert({ unitId:
|
465
|
+
const a = r.getSourceInfo().recordCount, c = this._sheetsBindingManager.getBindingModelBySourceId(t);
|
466
|
+
for (const { unitId: l, subunitId: h, nodeId: p, row: g, column: _ } of c) {
|
467
|
+
const I = this._ensureRTreeCollection(l), B = { startRow: g, startColumn: _, endRow: g + a, endColumn: _ };
|
468
|
+
I.insert({ unitId: l, sheetId: h, id: p, range: B });
|
342
469
|
}
|
343
470
|
}
|
344
471
|
}
|
345
|
-
})), this.disposeWithMe(this._sheetsBindingManager.cellBindInfoUpdate$.subscribe((
|
346
|
-
const { unitId:
|
347
|
-
if (
|
348
|
-
const
|
349
|
-
if (
|
350
|
-
const
|
351
|
-
if (a ===
|
352
|
-
c.insert({ unitId:
|
353
|
-
else if (a ===
|
354
|
-
c.remove({ unitId:
|
355
|
-
else if (a ===
|
356
|
-
const
|
472
|
+
})), this.disposeWithMe(this._sheetsBindingManager.cellBindInfoUpdate$.subscribe((e) => {
|
473
|
+
const { unitId: t, subunitId: n, sourceId: o, nodeId: s, row: r, column: d, changeType: a } = e, c = this._ensureRTreeCollection(t), l = this._sheetsSourceManager.getSource(t, o);
|
474
|
+
if (l && l.hasData()) {
|
475
|
+
const h = l.getSourceInfo();
|
476
|
+
if (h.sourceType === f.List) {
|
477
|
+
const p = h.recordCount, g = { startRow: r, startColumn: d, endRow: r + p, endColumn: d };
|
478
|
+
if (a === M.Add)
|
479
|
+
c.insert({ unitId: t, sheetId: n, id: s, range: g });
|
480
|
+
else if (a === M.Remove)
|
481
|
+
c.remove({ unitId: t, sheetId: n, id: s, range: g });
|
482
|
+
else if (a === M.Update) {
|
483
|
+
const _ = e.oldSourceId, I = this._sheetsSourceManager.getSource(t, _);
|
357
484
|
if (I && I.hasData()) {
|
358
|
-
const
|
359
|
-
c.remove({ unitId:
|
485
|
+
const A = I.getSourceInfo().recordCount, W = { startRow: r, startColumn: d, endRow: r + A, endColumn: d };
|
486
|
+
c.remove({ unitId: t, sheetId: n, id: s, range: W });
|
360
487
|
}
|
361
|
-
c.insert({ unitId:
|
488
|
+
c.insert({ unitId: t, sheetId: n, id: s, range: g });
|
362
489
|
}
|
363
490
|
}
|
364
491
|
}
|
365
492
|
}));
|
366
493
|
}
|
367
|
-
_getPathModeCellValue(
|
368
|
-
const s = this._sheetsBindingManager.getModel(
|
494
|
+
_getPathModeCellValue(e, t, n, o) {
|
495
|
+
const s = this._sheetsBindingManager.getModel(e, t), r = s == null ? void 0 : s.getBindingNode(n, o);
|
369
496
|
if (r) {
|
370
|
-
const
|
371
|
-
if (
|
497
|
+
const d = r.type;
|
498
|
+
if (d === f.List)
|
372
499
|
return {
|
373
500
|
v: `#{${r.path}}`,
|
374
501
|
s: { cl: { rgb: "blue" } }
|
375
502
|
};
|
376
|
-
if (
|
503
|
+
if (d === f.Object)
|
377
504
|
return {
|
378
505
|
v: `[${r.path}]`,
|
379
506
|
s: { cl: { rgb: "blue" } }
|
380
507
|
};
|
381
508
|
}
|
382
509
|
}
|
383
|
-
_getValueModeCellValue(
|
384
|
-
const s = this._sheetsBindingManager.getModel(
|
510
|
+
_getValueModeCellValue(e, t, n, o) {
|
511
|
+
const s = this._sheetsBindingManager.getModel(e, t);
|
385
512
|
if (s) {
|
386
|
-
const
|
387
|
-
if (
|
388
|
-
const { sourceId: a } =
|
513
|
+
const d = s.getBindingNode(n, o);
|
514
|
+
if (d) {
|
515
|
+
const { sourceId: a } = d, c = this._sheetsSourceManager.getSource(e, a);
|
389
516
|
if (c && c.hasData())
|
390
|
-
return {
|
391
|
-
v: (c == null ? void 0 : c.getData(i, t, n)) || ""
|
392
|
-
};
|
517
|
+
return (c == null ? void 0 : c.getData(d, n, o)) || { v: "" };
|
393
518
|
}
|
394
519
|
}
|
395
|
-
const r = this._getRTeeCollection(
|
520
|
+
const r = this._getRTeeCollection(e);
|
396
521
|
if (s && r) {
|
397
|
-
const
|
522
|
+
const d = { startRow: n, startColumn: o, endRow: n, endColumn: o }, a = Array.from(r.bulkSearch([{ unitId: e, sheetId: t, range: d }]));
|
398
523
|
if (a.length > 0) {
|
399
524
|
const c = s.getBindingNodeById(a[0]);
|
400
525
|
if (c) {
|
401
|
-
const { sourceId:
|
402
|
-
if (
|
403
|
-
return {
|
404
|
-
v: (l == null ? void 0 : l.getData(c, t, n)) || ""
|
405
|
-
};
|
526
|
+
const { sourceId: l } = c, h = this._sheetsSourceManager.getSource(e, l);
|
527
|
+
if (h && h.hasData())
|
528
|
+
return (h == null ? void 0 : h.getData(c, n, o)) || { v: "" };
|
406
529
|
}
|
407
530
|
}
|
408
531
|
}
|
409
532
|
}
|
410
533
|
_registerInterceptor() {
|
411
|
-
this.disposeWithMe(this._sheetInterceptorService.intercept(
|
412
|
-
effect:
|
413
|
-
|
414
|
-
|
534
|
+
this.disposeWithMe(this._sheetInterceptorService.intercept(oe.CELL_CONTENT, {
|
535
|
+
effect: T.Value | T.Style,
|
536
|
+
priority: 102,
|
537
|
+
handler: (e, t, n) => {
|
538
|
+
const { row: o, col: s, unitId: r, subUnitId: d } = t;
|
415
539
|
let a = null;
|
416
|
-
return this._bindingModel ===
|
540
|
+
return this._bindingModel === m.Path ? a = this._getPathModeCellValue(r, d, o, s) : a = this._getValueModeCellValue(r, d, o, s), n(a !== null ? { ...e, ...a } : e);
|
417
541
|
}
|
418
542
|
}));
|
419
543
|
}
|
544
|
+
dispose() {
|
545
|
+
this._bindModelRTreeCollection.clear();
|
546
|
+
}
|
420
547
|
};
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
],
|
426
|
-
var
|
427
|
-
for (var
|
428
|
-
(r =
|
429
|
-
return
|
430
|
-
},
|
431
|
-
let
|
432
|
-
constructor(
|
433
|
-
super(), this._config =
|
548
|
+
N = ue([
|
549
|
+
b(0, S(J)),
|
550
|
+
b(1, S(v)),
|
551
|
+
b(2, S(R))
|
552
|
+
], N);
|
553
|
+
var le = Object.defineProperty, he = Object.getOwnPropertyDescriptor, ge = (i, e, t, n) => {
|
554
|
+
for (var o = n > 1 ? void 0 : n ? he(e, t) : e, s = i.length - 1, r; s >= 0; s--)
|
555
|
+
(r = i[s]) && (o = (n ? r(e, t, o) : r(o)) || o);
|
556
|
+
return n && o && le(e, t, o), o;
|
557
|
+
}, $ = (i, e) => (t, n) => e(t, n, i), C;
|
558
|
+
let x = (C = class extends K {
|
559
|
+
constructor(i = {}, e, t) {
|
560
|
+
super(), this._config = i, this._injector = e, this._configService = t;
|
434
561
|
}
|
435
562
|
onStarting() {
|
436
563
|
[
|
437
|
-
[
|
438
|
-
[
|
439
|
-
[
|
440
|
-
].forEach((
|
564
|
+
[v],
|
565
|
+
[R],
|
566
|
+
[N]
|
567
|
+
].forEach((i) => this._injector.add(i));
|
441
568
|
}
|
442
569
|
onReady() {
|
443
|
-
|
444
|
-
[
|
445
|
-
[
|
446
|
-
[
|
570
|
+
X(this._injector, [
|
571
|
+
[v],
|
572
|
+
[R],
|
573
|
+
[N]
|
447
574
|
]);
|
448
575
|
}
|
449
|
-
}, u(
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
],
|
576
|
+
}, u(C, "type", Q.UNIVER_SHEET), u(C, "pluginName", "SHEET_BINDING_SOURCE_PLUGIN"), C);
|
577
|
+
x = ge([
|
578
|
+
$(1, S(Y)),
|
579
|
+
$(2, Z)
|
580
|
+
], x);
|
454
581
|
export {
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
582
|
+
m as BindModeEnum,
|
583
|
+
O as BindingModel,
|
584
|
+
f as DataBindingNodeTypeEnum,
|
585
|
+
N as SheetsSourceBindService,
|
586
|
+
R as SheetsSourceManager,
|
587
|
+
D as SourceModelBase,
|
588
|
+
x as UniverSheetsBindingSourcePlugin
|
461
589
|
};
|