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