@byteluck-fe/model-driven-engine 2.7.0-alpha.25 → 2.7.0-alpha.28a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/common/ActionManager.js +28 -28
- package/dist/esm/common/DataManager.js +12 -12
- package/dist/esm/common/Engine.js +228 -184
- package/dist/esm/common/OkWorker.js +6 -6
- package/dist/esm/common/Plugin.js +2 -2
- package/dist/esm/common/Runtime.js +98 -59
- package/dist/esm/common/Store.js +17 -16
- package/dist/esm/common/checkerValue.js +73 -71
- package/dist/esm/common/proxyState.js +17 -16
- package/dist/esm/plugins/CalcPlugin.js +29 -28
- package/dist/esm/plugins/ControlsEventPlugin.js +16 -16
- package/dist/esm/plugins/ES6ModulePlugin.js +19 -19
- package/dist/esm/plugins/LifecycleEventPlugin.js +26 -26
- package/dist/esm/plugins/StylePlugin.js +7 -7
- package/dist/esm/utils/runtimeUtils.js +4 -2
- package/dist/index.umd.js +9 -9
- package/dist/types/common/Engine.d.ts +4 -3
- package/dist/types/common/Runtime.d.ts +1 -0
- package/package.json +4 -4
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
2
|
if (len == null || len > arr.length) len = arr.length;
|
|
3
3
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
4
|
return arr2;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
7
|
if (Array.isArray(arr)) return arr;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
if (Array.isArray(arr)) return
|
|
9
|
+
function _array_without_holes(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function _assert_this_initialized(self) {
|
|
13
13
|
if (self === void 0) {
|
|
14
14
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15
15
|
}
|
|
@@ -29,7 +29,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
29
29
|
Promise.resolve(value).then(_next, _throw);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function _async_to_generator(fn) {
|
|
33
33
|
return function() {
|
|
34
34
|
var self = this, args = arguments;
|
|
35
35
|
return new Promise(function(resolve, reject) {
|
|
@@ -44,7 +44,7 @@ function _asyncToGenerator(fn) {
|
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function _class_call_check(instance, Constructor) {
|
|
48
48
|
if (!(instance instanceof Constructor)) {
|
|
49
49
|
throw new TypeError("Cannot call a class as a function");
|
|
50
50
|
}
|
|
@@ -58,12 +58,12 @@ function _defineProperties(target, props) {
|
|
|
58
58
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
62
62
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
63
63
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
64
64
|
return Constructor;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function _define_property(obj, key, value) {
|
|
67
67
|
if (key in obj) {
|
|
68
68
|
Object.defineProperty(obj, key, {
|
|
69
69
|
value: value,
|
|
@@ -80,23 +80,23 @@ function _get(target, property, receiver) {
|
|
|
80
80
|
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
81
81
|
_get = Reflect.get;
|
|
82
82
|
} else {
|
|
83
|
-
_get = function
|
|
84
|
-
var base =
|
|
83
|
+
_get = function get(target, property, receiver) {
|
|
84
|
+
var base = _super_prop_base(target, property);
|
|
85
85
|
if (!base) return;
|
|
86
86
|
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
87
87
|
if (desc.get) {
|
|
88
|
-
return desc.get.call(receiver);
|
|
88
|
+
return desc.get.call(receiver || target);
|
|
89
89
|
}
|
|
90
90
|
return desc.value;
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
return _get(target, property, receiver || target);
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
|
|
95
|
+
function _get_prototype_of(o) {
|
|
96
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
97
97
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
98
98
|
};
|
|
99
|
-
return
|
|
99
|
+
return _get_prototype_of(o);
|
|
100
100
|
}
|
|
101
101
|
function _inherits(subClass, superClass) {
|
|
102
102
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
@@ -109,12 +109,12 @@ function _inherits(subClass, superClass) {
|
|
|
109
109
|
configurable: true
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
|
-
if (superClass)
|
|
112
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function _iterable_to_array(iter) {
|
|
115
115
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function _iterable_to_array_limit(arr, i) {
|
|
118
118
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
119
119
|
if (_i == null) return;
|
|
120
120
|
var _arr = [];
|
|
@@ -138,13 +138,13 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
138
138
|
}
|
|
139
139
|
return _arr;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function _non_iterable_rest() {
|
|
142
142
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function _non_iterable_spread() {
|
|
145
145
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function _object_spread(target) {
|
|
148
148
|
for(var i = 1; i < arguments.length; i++){
|
|
149
149
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
150
150
|
var ownKeys = Object.keys(source);
|
|
@@ -154,7 +154,7 @@ function _objectSpread(target) {
|
|
|
154
154
|
}));
|
|
155
155
|
}
|
|
156
156
|
ownKeys.forEach(function(key) {
|
|
157
|
-
|
|
157
|
+
_define_property(target, key, source[key]);
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
return target;
|
|
@@ -172,7 +172,7 @@ function ownKeys(object, enumerableOnly) {
|
|
|
172
172
|
}
|
|
173
173
|
return keys;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function _object_spread_props(target, source) {
|
|
176
176
|
source = source != null ? source : {};
|
|
177
177
|
if (Object.getOwnPropertyDescriptors) {
|
|
178
178
|
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
@@ -183,45 +183,45 @@ function _objectSpreadProps(target, source) {
|
|
|
183
183
|
}
|
|
184
184
|
return target;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
if (call && (
|
|
186
|
+
function _possible_constructor_return(self, call) {
|
|
187
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
188
188
|
return call;
|
|
189
189
|
}
|
|
190
|
-
return
|
|
190
|
+
return _assert_this_initialized(self);
|
|
191
191
|
}
|
|
192
|
-
function
|
|
193
|
-
|
|
192
|
+
function _set_prototype_of(o, p) {
|
|
193
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
194
194
|
o.__proto__ = p;
|
|
195
195
|
return o;
|
|
196
196
|
};
|
|
197
|
-
return
|
|
197
|
+
return _set_prototype_of(o, p);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
return
|
|
199
|
+
function _sliced_to_array(arr, i) {
|
|
200
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function _super_prop_base(object, property) {
|
|
203
203
|
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
204
|
-
object =
|
|
204
|
+
object = _get_prototype_of(object);
|
|
205
205
|
if (object === null) break;
|
|
206
206
|
}
|
|
207
207
|
return object;
|
|
208
208
|
}
|
|
209
|
-
function
|
|
210
|
-
return
|
|
209
|
+
function _to_consumable_array(arr) {
|
|
210
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
211
211
|
}
|
|
212
|
-
|
|
212
|
+
function _type_of(obj) {
|
|
213
213
|
"@swc/helpers - typeof";
|
|
214
214
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
215
|
-
}
|
|
216
|
-
function
|
|
215
|
+
}
|
|
216
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
217
217
|
if (!o) return;
|
|
218
|
-
if (typeof o === "string") return
|
|
218
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
219
219
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
220
220
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
221
221
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
222
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
222
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function _is_native_reflect_construct() {
|
|
225
225
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
226
226
|
if (Reflect.construct.sham) return false;
|
|
227
227
|
if (typeof Proxy === "function") return true;
|
|
@@ -232,20 +232,20 @@ function _isNativeReflectConstruct() {
|
|
|
232
232
|
return false;
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
var hasNativeReflectConstruct =
|
|
235
|
+
function _create_super(Derived) {
|
|
236
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
237
237
|
return function _createSuperInternal() {
|
|
238
|
-
var Super =
|
|
238
|
+
var Super = _get_prototype_of(Derived), result;
|
|
239
239
|
if (hasNativeReflectConstruct) {
|
|
240
|
-
var NewTarget =
|
|
240
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
241
241
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
242
242
|
} else {
|
|
243
243
|
result = Super.apply(this, arguments);
|
|
244
244
|
}
|
|
245
|
-
return
|
|
245
|
+
return _possible_constructor_return(this, result);
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
function _ts_generator(thisArg, body) {
|
|
249
249
|
var f, y, t, g, _ = {
|
|
250
250
|
label: 0,
|
|
251
251
|
sent: function() {
|
|
@@ -339,7 +339,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
339
339
|
done: true
|
|
340
340
|
};
|
|
341
341
|
}
|
|
342
|
-
}
|
|
342
|
+
}
|
|
343
343
|
import { isDataBind } from "@byteluck-fe/model-driven-core";
|
|
344
344
|
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from "@byteluck-fe/model-driven-shared";
|
|
345
345
|
import { Runtime } from "./Runtime";
|
|
@@ -360,29 +360,29 @@ var applyingPluginName = "";
|
|
|
360
360
|
var Engine = /*#__PURE__*/ function(Watcher) {
|
|
361
361
|
"use strict";
|
|
362
362
|
_inherits(Engine, Watcher);
|
|
363
|
-
var _super =
|
|
363
|
+
var _super = _create_super(Engine);
|
|
364
364
|
function Engine(props) {
|
|
365
|
-
|
|
365
|
+
_class_call_check(this, Engine);
|
|
366
366
|
var _this;
|
|
367
367
|
_this = _super.call(this);
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
368
|
+
_define_property(_assert_this_initialized(_this), "store", void 0);
|
|
369
|
+
_define_property(_assert_this_initialized(_this), "rawStore", {});
|
|
370
|
+
_define_property(_assert_this_initialized(_this), "parent", void 0);
|
|
371
371
|
// 提供注册运行态控件以及实例化控件的能力
|
|
372
|
-
|
|
372
|
+
_define_property(_assert_this_initialized(_this), "runtime", void 0);
|
|
373
373
|
// 提供子线程处理脚本以及修改数据的能力
|
|
374
374
|
// public worker: OkWorker
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
375
|
+
_define_property(_assert_this_initialized(_this), "isMounted", false);
|
|
376
|
+
_define_property(_assert_this_initialized(_this), "id", genNonDuplicateId(8));
|
|
377
|
+
_define_property(_assert_this_initialized(_this), "externalParams", void 0);
|
|
378
378
|
// 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
379
|
+
_define_property(_assert_this_initialized(_this), "__plugins", void 0);
|
|
380
|
+
_define_property(_assert_this_initialized(_this), "__pluginsApplied", false);
|
|
381
|
+
_define_property(_assert_this_initialized(_this), "$options", void 0);
|
|
382
|
+
_define_property(_assert_this_initialized(_this), "actionManager", new ActionManager());
|
|
383
|
+
_define_property(_assert_this_initialized(_this), "dataManager", void 0);
|
|
384
|
+
_define_property(_assert_this_initialized(_this), "_jobTasks", []);
|
|
385
|
+
_define_property(_assert_this_initialized(_this), "createControlInstance", _this.createInstance);
|
|
386
386
|
_this.$options = Object.freeze(props);
|
|
387
387
|
var _this_$options = _this.$options, _this_$options_autoMount = _this_$options.autoMount, autoMount = _this_$options_autoMount === void 0 ? true : _this_$options_autoMount, schema = _this_$options.schema, beforeCreateInstance = _this_$options.beforeCreateInstance, externalParams = _this_$options.externalParams, _this_$options_language = _this_$options.// fieldModel,
|
|
388
388
|
language, language = _this_$options_language === void 0 ? DEFAULT_LOCALE : _this_$options_language, _this_$options_debug = _this_$options.debug, debug = _this_$options_debug === void 0 ? false : _this_$options_debug;
|
|
@@ -401,14 +401,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
401
401
|
autoMount && _this.mount();
|
|
402
402
|
return _this;
|
|
403
403
|
}
|
|
404
|
-
|
|
404
|
+
_create_class(Engine, [
|
|
405
405
|
{
|
|
406
406
|
key: "debugLog",
|
|
407
407
|
value: function debugLog() {
|
|
408
408
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
409
409
|
args[_key] = arguments[_key];
|
|
410
410
|
}
|
|
411
|
-
this.debug && log.apply(void 0,
|
|
411
|
+
this.debug && log.apply(void 0, _to_consumable_array(args));
|
|
412
412
|
}
|
|
413
413
|
},
|
|
414
414
|
{
|
|
@@ -428,7 +428,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
428
428
|
arg[_key] = arguments[_key];
|
|
429
429
|
}
|
|
430
430
|
var _this_runtime;
|
|
431
|
-
(_this_runtime = this.runtime).register.apply(_this_runtime,
|
|
431
|
+
(_this_runtime = this.runtime).register.apply(_this_runtime, _to_consumable_array(arg));
|
|
432
432
|
return this;
|
|
433
433
|
}
|
|
434
434
|
},
|
|
@@ -474,6 +474,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
474
474
|
}
|
|
475
475
|
// @ts-ignore
|
|
476
476
|
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
|
|
477
|
+
var _newValue;
|
|
477
478
|
if (newValue === null) {
|
|
478
479
|
return [];
|
|
479
480
|
}
|
|
@@ -488,7 +489,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
488
489
|
}, {});
|
|
489
490
|
// @ts-ignore
|
|
490
491
|
var emptyState = this.getEmptyState(instance.id);
|
|
491
|
-
return newValue === null ||
|
|
492
|
+
return (_newValue = newValue) === null || _newValue === void 0 ? void 0 : _newValue.map(function(row) {
|
|
492
493
|
return(// @ts-ignore
|
|
493
494
|
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
494
495
|
});
|
|
@@ -517,9 +518,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
517
518
|
key: "_handlerArrayUpdate",
|
|
518
519
|
value: function _handlerArrayUpdate(state, key, type, args, result) {
|
|
519
520
|
var _this = this;
|
|
521
|
+
var _subtable;
|
|
520
522
|
var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
521
523
|
// if (!(subtable instanceof RuntimeListControl)) return
|
|
522
|
-
if (!((subtable === null ||
|
|
524
|
+
if (!(((_subtable = subtable) === null || _subtable === void 0 ? void 0 : _subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
|
|
523
525
|
// 新增多行方法
|
|
524
526
|
var createRows = function(len) {
|
|
525
527
|
// @ts-ignore
|
|
@@ -547,7 +549,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
547
549
|
var newRowLengths = args.length;
|
|
548
550
|
createdNewRows = createRows(newRowLengths);
|
|
549
551
|
createdNewRowsData = args;
|
|
550
|
-
(_subtable_children = subtable.children)[type].apply(_subtable_children,
|
|
552
|
+
(_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
|
|
551
553
|
this.runtime.getFlatInstances();
|
|
552
554
|
break;
|
|
553
555
|
case "splice":
|
|
@@ -565,7 +567,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
565
567
|
(_subtable_children1 = subtable.children)[type].apply(_subtable_children1, [
|
|
566
568
|
start,
|
|
567
569
|
replace
|
|
568
|
-
].concat(
|
|
570
|
+
].concat(_to_consumable_array(createdNewRows)));
|
|
569
571
|
this.runtime.getFlatInstances();
|
|
570
572
|
// newValues.forEach((item: any, index) => {
|
|
571
573
|
// let newIndex = start + index
|
|
@@ -581,14 +583,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
581
583
|
if (start1 + replace1 === subtable.children.length - 1) {
|
|
582
584
|
isDeleteLastOne = true;
|
|
583
585
|
}
|
|
584
|
-
(_subtable_children2 = subtable.children)[type].apply(_subtable_children2,
|
|
586
|
+
(_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _to_consumable_array(args));
|
|
585
587
|
this.runtime.getFlatInstances();
|
|
586
588
|
}
|
|
587
589
|
break;
|
|
588
590
|
default:
|
|
589
591
|
var // @ts-ignore
|
|
590
592
|
_subtable_children3;
|
|
591
|
-
(_subtable_children3 = subtable.children)[type].apply(_subtable_children3,
|
|
593
|
+
(_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _to_consumable_array(args));
|
|
592
594
|
this.runtime.getFlatInstances();
|
|
593
595
|
break;
|
|
594
596
|
}
|
|
@@ -640,7 +642,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
640
642
|
var row = this.listControlCreateRow(instance, "subtable-row");
|
|
641
643
|
row && newRows.push(row);
|
|
642
644
|
}
|
|
643
|
-
(_instance_children = instance.children).push.apply(_instance_children,
|
|
645
|
+
(_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
|
|
644
646
|
this.runtime.getFlatInstances();
|
|
645
647
|
// 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
|
|
646
648
|
// for (let i = 0; i < newValue.length; i++) {
|
|
@@ -649,7 +651,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
649
651
|
this.emit("list-change", {
|
|
650
652
|
instance: instance,
|
|
651
653
|
value: value,
|
|
652
|
-
options:
|
|
654
|
+
options: _object_spread_props(_object_spread({}, options), {
|
|
653
655
|
// @ts-ignore
|
|
654
656
|
changed: newRows,
|
|
655
657
|
data: newValue,
|
|
@@ -661,7 +663,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
661
663
|
instance: instance,
|
|
662
664
|
value: this.getState(instance.id, index),
|
|
663
665
|
rowIndex: index,
|
|
664
|
-
options:
|
|
666
|
+
options: _object_spread_props(_object_spread({}, options), {
|
|
665
667
|
oldValue: oldValue
|
|
666
668
|
})
|
|
667
669
|
});
|
|
@@ -700,8 +702,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
700
702
|
var template = JSONCopy(instance.props.headers);
|
|
701
703
|
// @ts-ignore
|
|
702
704
|
var columns = this.createControl(template);
|
|
703
|
-
(_inst_children = inst.children).push.apply(_inst_children,
|
|
705
|
+
(_inst_children = inst.children).push.apply(_inst_children, _to_consumable_array(columns));
|
|
704
706
|
}
|
|
707
|
+
//@ts-ignore
|
|
708
|
+
row.parent = instance;
|
|
705
709
|
return row;
|
|
706
710
|
}
|
|
707
711
|
},
|
|
@@ -721,11 +725,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
721
725
|
function emit(eventKey, payload) {
|
|
722
726
|
var _this = this;
|
|
723
727
|
var _this1 = this, _superprop_get_emit = function() {
|
|
724
|
-
return _get(
|
|
728
|
+
return _get(_get_prototype_of(Engine.prototype), "emit", _this);
|
|
725
729
|
};
|
|
726
|
-
return
|
|
730
|
+
return _async_to_generator(function() {
|
|
727
731
|
var needWait, promiseResolver, promise, results;
|
|
728
|
-
return
|
|
732
|
+
return _ts_generator(this, function(_state) {
|
|
729
733
|
switch(_state.label){
|
|
730
734
|
case 0:
|
|
731
735
|
if (!(eventKey === "engine-mounted")) return [
|
|
@@ -744,7 +748,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
744
748
|
2
|
|
745
749
|
];
|
|
746
750
|
console.time("engine-mounted need wait");
|
|
747
|
-
needWait =
|
|
751
|
+
needWait = _to_consumable_array(_this1._jobTasks);
|
|
748
752
|
return [
|
|
749
753
|
4,
|
|
750
754
|
Promise.all(needWait)
|
|
@@ -790,7 +794,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
790
794
|
if (applyingPluginName) {
|
|
791
795
|
callback.applyingPluginName = applyingPluginName;
|
|
792
796
|
}
|
|
793
|
-
return _get(
|
|
797
|
+
return _get(_get_prototype_of(Engine.prototype), "on", this).call(this, key, callback);
|
|
794
798
|
}
|
|
795
799
|
},
|
|
796
800
|
{
|
|
@@ -800,7 +804,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
800
804
|
args[_key] = arguments[_key];
|
|
801
805
|
}
|
|
802
806
|
var _this_runtime;
|
|
803
|
-
return (_this_runtime = this.runtime).createControl.apply(_this_runtime,
|
|
807
|
+
return (_this_runtime = this.runtime).createControl.apply(_this_runtime, _to_consumable_array(args));
|
|
804
808
|
}
|
|
805
809
|
},
|
|
806
810
|
{
|
|
@@ -821,6 +825,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
821
825
|
return this.setInstance(instance, props, value, rowIndex);
|
|
822
826
|
}
|
|
823
827
|
},
|
|
828
|
+
{
|
|
829
|
+
key: "getRule",
|
|
830
|
+
value: function getRule(controlType, props) {
|
|
831
|
+
return Runtime.staticGetRules(controlType, props);
|
|
832
|
+
}
|
|
833
|
+
},
|
|
824
834
|
{
|
|
825
835
|
key: "getAllRules",
|
|
826
836
|
value: function getAllRules(controlId) {
|
|
@@ -907,7 +917,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
907
917
|
var newStates = states !== null && states !== void 0 ? states : {};
|
|
908
918
|
Object.keys(newStates).forEach(function(stateId) {
|
|
909
919
|
Object.entries(_this.store.controlIdMapping).forEach(function(param) {
|
|
910
|
-
var _param =
|
|
920
|
+
var _param = _sliced_to_array(param, 2), controlId = _param[0], controlIdMapping = _param[1];
|
|
911
921
|
if (controlIdMapping.dataView === stateId) {
|
|
912
922
|
// state对象是dataView包裹的
|
|
913
923
|
var value = newStates[stateId][controlId];
|
|
@@ -951,7 +961,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
951
961
|
//if (dataBind instanceof ObjectDataBind) {
|
|
952
962
|
if (!isDataBind(dataBind)) {
|
|
953
963
|
return Object.entries(dataBind).reduce(function(result, param) {
|
|
954
|
-
var _param =
|
|
964
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
|
|
955
965
|
// objectDataBind的元素,跳过下一次赋值
|
|
956
966
|
if (dataBind.fieldCode === fieldCode) {
|
|
957
967
|
return result[key];
|
|
@@ -977,8 +987,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
977
987
|
var data = getFieldData.map(function(item) {
|
|
978
988
|
var obj = {};
|
|
979
989
|
for(var key in item){
|
|
980
|
-
var _controlIdMapping_controlId_children_key, _controlIdMapping_controlId
|
|
981
|
-
var fieldCode = (
|
|
990
|
+
var _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId_children_key, _controlIdMapping_controlId;
|
|
991
|
+
var fieldCode = (_controlIdMapping_controlId = controlIdMapping[controlId]) === null || _controlIdMapping_controlId === void 0 ? void 0 : (_controlIdMapping_controlId_children_key = _controlIdMapping_controlId.children[key]) === null || _controlIdMapping_controlId_children_key === void 0 ? void 0 : (_controlIdMapping_controlId_children_key_dataBind = _controlIdMapping_controlId_children_key.dataBind) === null || _controlIdMapping_controlId_children_key_dataBind === void 0 ? void 0 : _controlIdMapping_controlId_children_key_dataBind.fieldCode;
|
|
982
992
|
//未绑定字段的控件,直接抛弃
|
|
983
993
|
if (fieldCode !== "") {
|
|
984
994
|
var _controlIdMapping_controlId1;
|
|
@@ -988,7 +998,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
988
998
|
// 兼容一个控件需要绑定多个字段的情况
|
|
989
999
|
for(var keyChi in item[key]){
|
|
990
1000
|
var _controlIdMapping_controlId_children_key1, _controlIdMapping_controlId2;
|
|
991
|
-
obj[(
|
|
1001
|
+
obj[(_controlIdMapping_controlId2 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId2 === void 0 ? void 0 : (_controlIdMapping_controlId_children_key1 = _controlIdMapping_controlId2.children[key]) === null || _controlIdMapping_controlId_children_key1 === void 0 ? void 0 : _controlIdMapping_controlId_children_key1.dataBind[keyChi].fieldCode] = item[key][keyChi];
|
|
992
1002
|
}
|
|
993
1003
|
}
|
|
994
1004
|
}
|
|
@@ -998,7 +1008,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
998
1008
|
return data;
|
|
999
1009
|
} else {
|
|
1000
1010
|
var _loop = function(key) {
|
|
1001
|
-
var _controlIdMapping_key,
|
|
1011
|
+
var _controlIdMapping_key_dataBind, _controlIdMapping_key, _controlIdMapping_key_dataBind1, _controlIdMapping_key1;
|
|
1002
1012
|
if ((_controlIdMapping_key = controlIdMapping[key]) === null || _controlIdMapping_key === void 0 ? void 0 : (_controlIdMapping_key_dataBind = _controlIdMapping_key.dataBind) === null || _controlIdMapping_key_dataBind === void 0 ? void 0 : _controlIdMapping_key_dataBind.fieldCode) {
|
|
1003
1013
|
var _controlIdMapping_key2;
|
|
1004
1014
|
obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
|
|
@@ -1028,7 +1038,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1028
1038
|
// 兼容一个控件需要绑定多个字段的情况
|
|
1029
1039
|
for(var keyChi in getFieldData[key]){
|
|
1030
1040
|
var _controlIdMapping_key_dataBind_keyChi, _controlIdMapping_key4;
|
|
1031
|
-
obj[(
|
|
1041
|
+
obj[(_controlIdMapping_key4 = controlIdMapping[key]) === null || _controlIdMapping_key4 === void 0 ? void 0 : (_controlIdMapping_key_dataBind_keyChi = _controlIdMapping_key4.dataBind[keyChi]) === null || _controlIdMapping_key_dataBind_keyChi === void 0 ? void 0 : _controlIdMapping_key_dataBind_keyChi.fieldCode] = getFieldData[key][keyChi];
|
|
1032
1042
|
}
|
|
1033
1043
|
}
|
|
1034
1044
|
};
|
|
@@ -1062,7 +1072,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1062
1072
|
var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
|
|
1063
1073
|
// fieldCode不代表是key,所以需要找到对应的key
|
|
1064
1074
|
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
1065
|
-
var _param =
|
|
1075
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
|
|
1066
1076
|
// objectDataBind的元素,跳过下一次赋值
|
|
1067
1077
|
if (dataBind.fieldCode === fieldCode) {
|
|
1068
1078
|
result[key] = value;
|
|
@@ -1105,7 +1115,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1105
1115
|
var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
|
|
1106
1116
|
// fieldCode不代表是key,所以需要找到对应的key
|
|
1107
1117
|
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
1108
|
-
var _param =
|
|
1118
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
|
|
1109
1119
|
// objectDataBind的元素,跳过下一次赋值
|
|
1110
1120
|
skipKeys.push(dataBind.fieldCode);
|
|
1111
1121
|
var value = state[dataBind.fieldCode];
|
|
@@ -1130,7 +1140,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1130
1140
|
value: function buildFields(dataCode, state) {
|
|
1131
1141
|
var _this = this;
|
|
1132
1142
|
var mapping = this.getDataBindMapping(dataCode);
|
|
1133
|
-
if (!mapping) {
|
|
1143
|
+
if (!mapping || !mapping.fields) {
|
|
1134
1144
|
return;
|
|
1135
1145
|
}
|
|
1136
1146
|
var skipKeys = [];
|
|
@@ -1149,7 +1159,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1149
1159
|
var oldState = _this.getEmptyState(controlId);
|
|
1150
1160
|
// fieldCode不代表是key,所以需要找到对应的key
|
|
1151
1161
|
result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
|
|
1152
|
-
var _param =
|
|
1162
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
|
|
1153
1163
|
// objectDataBind的元素,跳过下一次赋值
|
|
1154
1164
|
skipKeys.push(dataBind.fieldCode);
|
|
1155
1165
|
var value = state[dataBind.fieldCode];
|
|
@@ -1196,7 +1206,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1196
1206
|
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1197
1207
|
;
|
|
1198
1208
|
Object.keys(row).map(function(fieldCode) {
|
|
1199
|
-
var
|
|
1209
|
+
var _this_store_dataBindMapping_dataCode_fields, _this_store_dataBindMapping_dataCode;
|
|
1200
1210
|
if (skipKey.includes(fieldCode)) {
|
|
1201
1211
|
return;
|
|
1202
1212
|
}
|
|
@@ -1262,19 +1272,22 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1262
1272
|
}
|
|
1263
1273
|
var newMapping = _this.getDataBindMapping(dataCode);
|
|
1264
1274
|
if (newMapping) {
|
|
1265
|
-
var _newMapping_fields;
|
|
1266
|
-
var mappingKeys = newMapping === null ||
|
|
1267
|
-
|
|
1275
|
+
var _newMapping_fields, _newMapping, _newMapping1, _newMapping2, _newState, _mappingKeys;
|
|
1276
|
+
var mappingKeys = (_newMapping = newMapping) === null || _newMapping === void 0 ? void 0 : (_newMapping_fields = _newMapping.fields) === null || _newMapping_fields === void 0 ? void 0 : _newMapping_fields.map(function(item) {
|
|
1277
|
+
var _item;
|
|
1278
|
+
return (_item = item) === null || _item === void 0 ? void 0 : _item.controlId;
|
|
1268
1279
|
});
|
|
1269
|
-
var mappingValue = _this.getEmptyState(newMapping === null ||
|
|
1280
|
+
var mappingValue = _this.getEmptyState((_newMapping1 = newMapping) === null || _newMapping1 === void 0 ? void 0 : _newMapping1.controlId);
|
|
1270
1281
|
var _newState_newMapping_controlId;
|
|
1271
|
-
var mainStateKeys = Object.keys((_newState_newMapping_controlId = newState === null ||
|
|
1272
|
-
mappingKeys === null ||
|
|
1273
|
-
|
|
1282
|
+
var mainStateKeys = Object.keys((_newState_newMapping_controlId = (_newState = newState) === null || _newState === void 0 ? void 0 : _newState[(_newMapping2 = newMapping) === null || _newMapping2 === void 0 ? void 0 : _newMapping2.controlId]) !== null && _newState_newMapping_controlId !== void 0 ? _newState_newMapping_controlId : {});
|
|
1283
|
+
(_mappingKeys = mappingKeys) === null || _mappingKeys === void 0 ? void 0 : _mappingKeys.forEach(function(key) {
|
|
1284
|
+
var _newMapping;
|
|
1285
|
+
if (!mainStateKeys.includes(key) && key !== "uid" && newState[(_newMapping = newMapping) === null || _newMapping === void 0 ? void 0 : _newMapping.controlId]) {
|
|
1274
1286
|
if (Object.keys(newState).length) {
|
|
1275
|
-
|
|
1287
|
+
var _newMapping1;
|
|
1288
|
+
Object.assign(newState[(_newMapping1 = newMapping) === null || _newMapping1 === void 0 ? void 0 : _newMapping1.controlId], _define_property({}, key, mappingValue[key]));
|
|
1276
1289
|
} else {
|
|
1277
|
-
Object.assign(newState,
|
|
1290
|
+
Object.assign(newState, _define_property({}, newMapping.controlId, _define_property({}, key, mappingValue[key])));
|
|
1278
1291
|
}
|
|
1279
1292
|
}
|
|
1280
1293
|
});
|
|
@@ -1323,7 +1336,59 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1323
1336
|
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1324
1337
|
* @param controlId
|
|
1325
1338
|
* @param header 明细表内是否获取表头的控件
|
|
1326
|
-
*/
|
|
1339
|
+
*/ // getInstances(
|
|
1340
|
+
// controlId?: string,
|
|
1341
|
+
// header: boolean = false
|
|
1342
|
+
// ): ControlRuntimeInstance<ControlsKeys>[] {
|
|
1343
|
+
// // const cc = console
|
|
1344
|
+
// // const label = '🐑 genInstances ' + controlId + ' ' + Date.now()
|
|
1345
|
+
// // cc.time(label)
|
|
1346
|
+
//
|
|
1347
|
+
// if (controlId === undefined) {
|
|
1348
|
+
// // cc.timeEnd(label)
|
|
1349
|
+
// return this.runtime.flatInstances
|
|
1350
|
+
// }
|
|
1351
|
+
// const instances = Array.from(this.runtime.instanceMap[controlId] || [])
|
|
1352
|
+
// if (header) {
|
|
1353
|
+
// // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1354
|
+
// if (instances.length) {
|
|
1355
|
+
// const instance: RuntimeControl = instances[0]
|
|
1356
|
+
// // if (this.inList(instance.id) === true) {
|
|
1357
|
+
// if (this.inList(instance.id) !== undefined) {
|
|
1358
|
+
// const headerInstance = this.getInstanceInSubtableHeader(instance)
|
|
1359
|
+
// if (headerInstance) {
|
|
1360
|
+
// instances.unshift(headerInstance)
|
|
1361
|
+
// }
|
|
1362
|
+
// }
|
|
1363
|
+
// } else {
|
|
1364
|
+
// const controlIdMapping = this.getControlIdMapping()
|
|
1365
|
+
// const [subtableId] =
|
|
1366
|
+
// Object.entries(controlIdMapping).find(
|
|
1367
|
+
// ([_, mapping]) => mapping.children && controlId in mapping.children
|
|
1368
|
+
// ) ?? []
|
|
1369
|
+
// if (subtableId) {
|
|
1370
|
+
// const subtable = this.getInstance(subtableId)
|
|
1371
|
+
// // @ts-ignore
|
|
1372
|
+
// const headerColumn = subtable.props.headers.find((column: any) =>
|
|
1373
|
+
// column.children.find((item: any) => item.id === controlId)
|
|
1374
|
+
// )
|
|
1375
|
+
// if (headerColumn) {
|
|
1376
|
+
// const headerInstance = headerColumn.children.find(
|
|
1377
|
+
// (item: any) => item.id === controlId
|
|
1378
|
+
// )
|
|
1379
|
+
// if (headerInstance) {
|
|
1380
|
+
// instances.unshift(
|
|
1381
|
+
// headerInstance as ControlRuntimeInstance<ControlsKeys>
|
|
1382
|
+
// )
|
|
1383
|
+
// }
|
|
1384
|
+
// }
|
|
1385
|
+
// }
|
|
1386
|
+
// }
|
|
1387
|
+
// }
|
|
1388
|
+
// // @ts-ignore
|
|
1389
|
+
// return instances
|
|
1390
|
+
// }
|
|
1391
|
+
key: "getInstances",
|
|
1327
1392
|
value: function getInstances(controlId) {
|
|
1328
1393
|
var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1329
1394
|
// const cc = console
|
|
@@ -1333,42 +1398,15 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1333
1398
|
// cc.timeEnd(label)
|
|
1334
1399
|
return this.runtime.flatInstances;
|
|
1335
1400
|
}
|
|
1336
|
-
var instances =
|
|
1401
|
+
var instances = this.runtime.instanceMap[controlId] || [];
|
|
1337
1402
|
if (header) {
|
|
1338
|
-
|
|
1339
|
-
if (
|
|
1340
|
-
var
|
|
1341
|
-
//
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
instances.unshift(headerInstance);
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
} else {
|
|
1349
|
-
var _this_getControlIdMapping;
|
|
1350
|
-
var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
|
|
1351
|
-
var _Object_entries_find;
|
|
1352
|
-
var _ref = _slicedToArray((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
|
|
1353
|
-
var _param = _slicedToArray(param, 2), _ = _param[0], mapping = _param[1];
|
|
1354
|
-
return mapping.children && controlId in mapping.children;
|
|
1355
|
-
})) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
|
|
1356
|
-
if (subtableId) {
|
|
1357
|
-
var subtable = this.getInstance(subtableId);
|
|
1358
|
-
// @ts-ignore
|
|
1359
|
-
var headerColumn = subtable.props.headers.find(function(column) {
|
|
1360
|
-
return column.children.find(function(item) {
|
|
1361
|
-
return item.id === controlId;
|
|
1362
|
-
});
|
|
1363
|
-
});
|
|
1364
|
-
if (headerColumn) {
|
|
1365
|
-
var headerInstance1 = headerColumn.children.find(function(item) {
|
|
1366
|
-
return item.id === controlId;
|
|
1367
|
-
});
|
|
1368
|
-
if (headerInstance1) {
|
|
1369
|
-
instances.unshift(headerInstance1);
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1403
|
+
var instance = instances[0];
|
|
1404
|
+
if (instance) {
|
|
1405
|
+
var _instance_parent;
|
|
1406
|
+
// @ts-ignore
|
|
1407
|
+
var parentId = (_instance_parent = instance.parent) === null || _instance_parent === void 0 ? void 0 : _instance_parent.id;
|
|
1408
|
+
if (parentId) {
|
|
1409
|
+
instances = this.runtime.instanceMap[parentId] || [];
|
|
1372
1410
|
}
|
|
1373
1411
|
}
|
|
1374
1412
|
}
|
|
@@ -1483,55 +1521,64 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1483
1521
|
* 如果控件在表头内,则返回-1
|
|
1484
1522
|
* 如果控件在表内,则返回行下标
|
|
1485
1523
|
* 如果控件不在明细表内,则返回undefined
|
|
1486
|
-
* */
|
|
1524
|
+
* */ // public getInstanceRowIndex(
|
|
1525
|
+
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1526
|
+
// ) {
|
|
1527
|
+
// if (!instance.parent) {
|
|
1528
|
+
// return
|
|
1529
|
+
// }
|
|
1530
|
+
// let rowIndex: number | undefined
|
|
1531
|
+
// // @ts-ignore
|
|
1532
|
+
// if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1533
|
+
// // 表头内的控件
|
|
1534
|
+
// // @ts-ignore
|
|
1535
|
+
// if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1536
|
+
// rowIndex = -1
|
|
1537
|
+
// } else {
|
|
1538
|
+
// // @ts-ignore
|
|
1539
|
+
// // const index = instance.parent.children.findIndex(
|
|
1540
|
+
// // (item: any) => item === instance
|
|
1541
|
+
// // )
|
|
1542
|
+
// let instances = this.runtime.instanceMap[instance.id] || []
|
|
1543
|
+
// const index = instances.findIndex((item: any) => item === instance)
|
|
1544
|
+
// if (index > -1) {
|
|
1545
|
+
// rowIndex = index
|
|
1546
|
+
// }
|
|
1547
|
+
// }
|
|
1548
|
+
// } else {
|
|
1549
|
+
// rowIndex = this.getInstanceRowIndex(instance.parent)
|
|
1550
|
+
// }
|
|
1551
|
+
// return rowIndex
|
|
1552
|
+
// }
|
|
1553
|
+
function getInstanceRowIndex(instance) {
|
|
1487
1554
|
if (!instance.parent) {
|
|
1488
1555
|
return;
|
|
1489
1556
|
}
|
|
1490
1557
|
var rowIndex;
|
|
1491
1558
|
// @ts-ignore
|
|
1492
|
-
if (this.assertInstance(instance
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1559
|
+
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1560
|
+
rowIndex = -1;
|
|
1561
|
+
} else {
|
|
1562
|
+
var isColumnChild = this.getInstanceParentControl(instance, // @ts-ignore
|
|
1563
|
+
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1564
|
+
if (isColumnChild) {
|
|
1565
|
+
var instanceList = this.runtime.instanceMap[instance.id];
|
|
1566
|
+
if (Object.prototype.toString.call(instanceList) === "[object Array]") {
|
|
1567
|
+
var index = instanceList.findIndex(function(item) {
|
|
1568
|
+
return item === instance;
|
|
1569
|
+
});
|
|
1570
|
+
if (index > -1) {
|
|
1571
|
+
rowIndex = index;
|
|
1572
|
+
}
|
|
1504
1573
|
}
|
|
1505
1574
|
}
|
|
1506
|
-
} else {
|
|
1507
|
-
rowIndex = this.getInstanceRowIndex(instance.parent);
|
|
1508
1575
|
}
|
|
1509
1576
|
return rowIndex;
|
|
1510
1577
|
}
|
|
1511
1578
|
},
|
|
1512
1579
|
{
|
|
1513
1580
|
key: "getInstanceParentControl",
|
|
1514
|
-
value:
|
|
1515
|
-
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1516
|
-
// ) {
|
|
1517
|
-
// let rowIndex: number | undefined
|
|
1518
|
-
// // @ts-ignore
|
|
1519
|
-
// if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1520
|
-
// rowIndex = -1
|
|
1521
|
-
// }else{
|
|
1522
|
-
// const instanceList = this.runtime.instanceMap[instance.id]
|
|
1523
|
-
// if(Object.prototype.toString.call(instanceList) === '[object Array]'){
|
|
1524
|
-
// const index = instanceList.findIndex(
|
|
1525
|
-
// (item: any) => item === instance
|
|
1526
|
-
// )
|
|
1527
|
-
// if (index > -1) {
|
|
1528
|
-
// rowIndex = index
|
|
1529
|
-
// }
|
|
1530
|
-
// }
|
|
1531
|
-
// }
|
|
1532
|
-
// return rowIndex
|
|
1533
|
-
// }
|
|
1534
|
-
function getInstanceParentControl(instance, controlType) {
|
|
1581
|
+
value: function getInstanceParentControl(instance, controlType) {
|
|
1535
1582
|
if (!instance.parent) {
|
|
1536
1583
|
return;
|
|
1537
1584
|
}
|
|
@@ -1580,7 +1627,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1580
1627
|
args[_key] = arguments[_key];
|
|
1581
1628
|
}
|
|
1582
1629
|
var _this_runtime;
|
|
1583
|
-
return (_this_runtime = this.runtime).registerControlConfig.apply(_this_runtime,
|
|
1630
|
+
return (_this_runtime = this.runtime).registerControlConfig.apply(_this_runtime, _to_consumable_array(args));
|
|
1584
1631
|
}
|
|
1585
1632
|
},
|
|
1586
1633
|
{
|
|
@@ -1596,7 +1643,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1596
1643
|
var mapping = (_this_store_controlIdMapping = this.store.controlIdMapping) !== null && _this_store_controlIdMapping !== void 0 ? _this_store_controlIdMapping : {};
|
|
1597
1644
|
var listKey = undefined;
|
|
1598
1645
|
Object.keys(mapping).some(function(key) {
|
|
1599
|
-
var
|
|
1646
|
+
var _mapping_key_children, _mapping_key;
|
|
1600
1647
|
var matched = (_mapping_key = mapping[key]) === null || _mapping_key === void 0 ? void 0 : (_mapping_key_children = _mapping_key.children) === null || _mapping_key_children === void 0 ? void 0 : _mapping_key_children.hasOwnProperty(controlId);
|
|
1601
1648
|
if (matched) {
|
|
1602
1649
|
listKey = key;
|
|
@@ -1610,12 +1657,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1610
1657
|
{
|
|
1611
1658
|
key: "register",
|
|
1612
1659
|
value: // 注册外部控件
|
|
1613
|
-
function register() {
|
|
1614
|
-
|
|
1615
|
-
arg[_key] = arguments[_key];
|
|
1616
|
-
}
|
|
1617
|
-
var _Runtime;
|
|
1618
|
-
return (_Runtime = Runtime).register.apply(_Runtime, _toConsumableArray(arg));
|
|
1660
|
+
function register(control) {
|
|
1661
|
+
return Runtime.register(control, "Runtime");
|
|
1619
1662
|
}
|
|
1620
1663
|
},
|
|
1621
1664
|
{
|
|
@@ -1627,4 +1670,5 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1627
1670
|
]);
|
|
1628
1671
|
return Engine;
|
|
1629
1672
|
}(Watcher);
|
|
1673
|
+
// @ts-ignore
|
|
1630
1674
|
export { Engine };
|