@univerjs/sheets-source-binding 0.5.5-nightly.202501241606 → 0.6.0-experimental.20250125-1d060b9

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