@byteluck-fe/model-driven-driven 2.23.0-beta.12 → 2.23.0-beta.14

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/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # Driven
2
- 设计态引擎
3
-
4
- Builder.ts // 兼容旧版Designer,提供页面初始化
5
- constants.ts // 常量
6
- Designer.ts // 旧版designer的实现
7
- designerUtils.ts // 工具函数
8
- Driven.ts // 引擎
9
- EventLogic.ts // 事件管理
10
- index.ts
11
- Plugin.ts // 插件
12
- Store.ts // 仓库
13
- utils.ts // 工具
1
+ # Driven
2
+ 设计态引擎
3
+
4
+ Builder.ts // 兼容旧版Designer,提供页面初始化
5
+ constants.ts // 常量
6
+ Designer.ts // 旧版designer的实现
7
+ designerUtils.ts // 工具函数
8
+ Driven.ts // 引擎
9
+ EventLogic.ts // 事件管理
10
+ index.ts
11
+ Plugin.ts // 插件
12
+ Store.ts // 仓库
13
+ utils.ts // 工具
@@ -41,10 +41,6 @@ function _async_to_generator(fn) {
41
41
  });
42
42
  };
43
43
  }
44
- function _call_super(_this, derived, args) {
45
- derived = _get_prototype_of(derived);
46
- return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
47
- }
48
44
  function _class_call_check(instance, Constructor) {
49
45
  if (!(instance instanceof Constructor)) {
50
46
  throw new TypeError("Cannot call a class as a function");
@@ -138,12 +134,28 @@ function _unsupported_iterable_to_array(o, minLen) {
138
134
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
139
135
  }
140
136
  function _is_native_reflect_construct() {
137
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
138
+ if (Reflect.construct.sham) return false;
139
+ if (typeof Proxy === "function") return true;
141
140
  try {
142
- var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
143
- } catch (_) {}
144
- return (_is_native_reflect_construct = function() {
145
- return !!result;
146
- })();
141
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
142
+ return true;
143
+ } catch (e) {
144
+ return false;
145
+ }
146
+ }
147
+ function _create_super(Derived) {
148
+ var hasNativeReflectConstruct = _is_native_reflect_construct();
149
+ return function _createSuperInternal() {
150
+ var Super = _get_prototype_of(Derived), result;
151
+ if (hasNativeReflectConstruct) {
152
+ var NewTarget = _get_prototype_of(this).constructor;
153
+ result = Reflect.construct(Super, arguments, NewTarget);
154
+ } else {
155
+ result = Super.apply(this, arguments);
156
+ }
157
+ return _possible_constructor_return(this, result);
158
+ };
147
159
  }
148
160
  function _ts_generator(thisArg, body) {
149
161
  var f, y, t, g, _ = {
@@ -247,12 +259,16 @@ import { toSchema, getModelBindInfoList, checkSchema } from './utils';
247
259
  var Designer = /*#__PURE__*/ function _target(RegisterControls) {
248
260
  "use strict";
249
261
  _inherits(Designer, RegisterControls);
262
+ var _super = _create_super(Designer);
250
263
  function Designer() {
251
264
  _class_call_check(this, Designer);
252
265
  var _this;
253
- _this = _call_super(this, Designer, [
254
- 'Designer'
255
- ]), _define_property(_this, "toolbox", []), _define_property(_this, "services", {}), _define_property(_this, "eventLogic", new EventLogic()), _define_property(_this, "fieldTypes", FieldTypes), _define_property(_this, "controlSettingMap", new Map());
266
+ _this = _super.call(this, 'Designer');
267
+ _define_property(_assert_this_initialized(_this), "toolbox", []);
268
+ _define_property(_assert_this_initialized(_this), "services", {});
269
+ _define_property(_assert_this_initialized(_this), "eventLogic", new EventLogic());
270
+ _define_property(_assert_this_initialized(_this), "fieldTypes", FieldTypes);
271
+ _define_property(_assert_this_initialized(_this), "controlSettingMap", new Map());
256
272
  (_instanceof(this, Designer) ? this.constructor : void 0).staticControls.forEach(function(control) {
257
273
  var _$Designer = control.Designer, Setting = control.Setting;
258
274
  _this.controlSettingMap.set(_$Designer.controlType, Setting);
@@ -263,7 +279,6 @@ var Designer = /*#__PURE__*/ function _target(RegisterControls) {
263
279
  {
264
280
  key: "registerControl",
265
281
  value: function registerControl(control) {
266
- ;
267
282
  this.constructor.register(control, 'Designer');
268
283
  var DesignerClass = control.Designer, Setting = control.Setting;
269
284
  this.register(DesignerClass);
@@ -15,10 +15,6 @@ function _assert_this_initialized(self) {
15
15
  }
16
16
  return self;
17
17
  }
18
- function _call_super(_this, derived, args) {
19
- derived = _get_prototype_of(derived);
20
- return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
21
- }
22
18
  function _class_call_check(instance, Constructor) {
23
19
  if (!(instance instanceof Constructor)) {
24
20
  throw new TypeError("Cannot call a class as a function");
@@ -173,12 +169,28 @@ function _unsupported_iterable_to_array(o, minLen) {
173
169
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
174
170
  }
175
171
  function _is_native_reflect_construct() {
172
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
173
+ if (Reflect.construct.sham) return false;
174
+ if (typeof Proxy === "function") return true;
176
175
  try {
177
- var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
178
- } catch (_) {}
179
- return (_is_native_reflect_construct = function() {
180
- return !!result;
181
- })();
176
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
177
+ return true;
178
+ } catch (e) {
179
+ return false;
180
+ }
181
+ }
182
+ function _create_super(Derived) {
183
+ var hasNativeReflectConstruct = _is_native_reflect_construct();
184
+ return function _createSuperInternal() {
185
+ var Super = _get_prototype_of(Derived), result;
186
+ if (hasNativeReflectConstruct) {
187
+ var NewTarget = _get_prototype_of(this).constructor;
188
+ result = Reflect.construct(Super, arguments, NewTarget);
189
+ } else {
190
+ result = Super.apply(this, arguments);
191
+ }
192
+ return _possible_constructor_return(this, result);
193
+ };
182
194
  }
183
195
  import { CONTROL_BASE_TYPE, error, genNonDuplicateId, isArray, isBuiltInControls, isObject, isString, updateValueFromKeys, warn, Watcher } from '@byteluck-fe/model-driven-shared';
184
196
  import { findInstanceDataScopeParent, Store } from './Store';
@@ -189,28 +201,42 @@ import { Group, initSettings, Tab } from '@byteluck-fe/model-driven-settings';
189
201
  import { DEFAULT_LOCALE } from '@byteluck-fe/model-driven-shared';
190
202
  // 当前正在注册的插件名称
191
203
  var applyingPluginName = '';
192
- /**
193
- * 设计器驱动
204
+ /**
205
+ * 设计器驱动
194
206
  * */ var Driven = /*#__PURE__*/ function(Watcher) {
195
207
  "use strict";
196
208
  _inherits(Driven, Watcher);
209
+ var _super = _create_super(Driven);
197
210
  function Driven(options) {
198
211
  _class_call_check(this, Driven);
199
212
  var _this;
200
- _this = _call_super(this, Driven), _define_property(_this, "mode", void 0), _define_property(_this, "isMounted", false), _define_property(_this, "id", genNonDuplicateId(8)), /**
201
- * 控件可选的事件
202
- * */ _define_property(_this, "eventLogic", void 0), /**
203
- * 处理数据存储,存放模型等
204
- * */ _define_property(_this, "store", void 0), /**
205
- * 额外参数存储
206
- */ _define_property(_this, "externalParams", void 0), /**
207
- * 处理instance,和schema存储
208
- * */ _define_property(_this, "designer", void 0), /**
209
- * 插件数组
210
- * */ _define_property(_this, "__plugins", void 0), _define_property(_this, "__pluginsApplied", false), _define_property(_this, "$options", void 0), // TODO 拿到schema
211
- _define_property(_this, "getSchema", toSchema), // TODO 拿到model_bind_info_list
212
- _define_property(_this, "getModelBindInfoList", getModelBindInfoList), // TODO 拿到permission_controls
213
- _define_property(_this, "generatePermissions", generatePermissions);
213
+ _this = _super.call(this);
214
+ _define_property(_assert_this_initialized(_this), "mode", void 0);
215
+ _define_property(_assert_this_initialized(_this), "isMounted", false);
216
+ _define_property(_assert_this_initialized(_this), "id", genNonDuplicateId(8));
217
+ /**
218
+ * 控件可选的事件
219
+ * */ _define_property(_assert_this_initialized(_this), "eventLogic", void 0);
220
+ /**
221
+ * 处理数据存储,存放模型等
222
+ * */ _define_property(_assert_this_initialized(_this), "store", void 0);
223
+ /**
224
+ * 额外参数存储
225
+ */ _define_property(_assert_this_initialized(_this), "externalParams", void 0);
226
+ /**
227
+ * 处理instance,和schema存储
228
+ * */ _define_property(_assert_this_initialized(_this), "designer", void 0);
229
+ /**
230
+ * 插件数组
231
+ * */ _define_property(_assert_this_initialized(_this), "__plugins", void 0);
232
+ _define_property(_assert_this_initialized(_this), "__pluginsApplied", false);
233
+ _define_property(_assert_this_initialized(_this), "$options", void 0);
234
+ // TODO 拿到schema
235
+ _define_property(_assert_this_initialized(_this), "getSchema", toSchema);
236
+ // TODO 拿到model_bind_info_list
237
+ _define_property(_assert_this_initialized(_this), "getModelBindInfoList", getModelBindInfoList);
238
+ // TODO 拿到permission_controls
239
+ _define_property(_assert_this_initialized(_this), "generatePermissions", generatePermissions);
214
240
  _this.$options = Object.freeze(options);
215
241
  var _this_$options = _this.$options, _this_$options_autoMount = _this_$options.autoMount, autoMount = _this_$options_autoMount === void 0 ? false : _this_$options_autoMount, tmp = _this_$options.Designer, DesignerClass = tmp === void 0 ? Designer : tmp, schema = _this_$options.schema, _this_$options_mode = _this_$options.mode, mode = _this_$options_mode === void 0 ? 'form' : _this_$options_mode, tmp1 = _this_$options.store, storeOptions = tmp1 === void 0 ? {} : tmp1, messagesI18n = _this_$options.messagesI18n, _this_$options_language = _this_$options.language, language = _this_$options_language === void 0 ? DEFAULT_LOCALE : _this_$options_language;
216
242
  _this.eventLogic = new EventLogic();
@@ -474,10 +500,10 @@ var applyingPluginName = '';
474
500
  if (instance === null) return;
475
501
  var _instance = this.getInstance(instance);
476
502
  if (!_instance) return;
477
- /*
478
- 移动之后,拿到控件新的位置,并触发事件, 如果是新增的控件的话,就没有原始位置和父级,
479
- 事件是否区分move和add
480
- move是从主表移动到子表或子表移动到主表才触发,还是所有移动都触发
503
+ /*
504
+ 移动之后,拿到控件新的位置,并触发事件, 如果是新增的控件的话,就没有原始位置和父级,
505
+ 事件是否区分move和add
506
+ move是从主表移动到子表或子表移动到主表才触发,还是所有移动都触发
481
507
  */ var oldDataScopeParent = this.store.movingInstanceOldDataScopeParent;
482
508
  var newDataScopeParent = findInstanceDataScopeParent(_instance);
483
509
  var oldParent = this.store.movingInstanceOldParent;
@@ -602,8 +628,8 @@ var applyingPluginName = '';
602
628
  },
603
629
  {
604
630
  key: "removeInstance",
605
- value: /**
606
- * 删除控件
631
+ value: /**
632
+ * 删除控件
607
633
  * */ function removeInstance(instance) {
608
634
  // 删除实例,并触发事件 removed
609
635
  var parent = instance.parent;
@@ -642,8 +668,8 @@ var applyingPluginName = '';
642
668
  },
643
669
  {
644
670
  key: "updateInstanceType",
645
- value: /**
646
- * 修改控件类型
671
+ value: /**
672
+ * 修改控件类型
647
673
  * */ function updateInstanceType(instance, type) {
648
674
  var schema = instance.toSchema();
649
675
  var newInstance = this.createInstance(type, {
@@ -701,16 +727,16 @@ var applyingPluginName = '';
701
727
  },
702
728
  {
703
729
  key: "assertInstance",
704
- value: /**
705
- * 判断控件的类型,返回当前控件的正确类型
730
+ value: /**
731
+ * 判断控件的类型,返回当前控件的正确类型
706
732
  * */ function assertInstance(instance, types) {
707
733
  return isString(types) ? instance.type === types : types.includes(instance.type);
708
734
  }
709
735
  },
710
736
  {
711
737
  key: "getInstanceInListControl",
712
- value: /**
713
- * 控件在列表控件内,如明细子表或列表控件
738
+ value: /**
739
+ * 控件在列表控件内,如明细子表或列表控件
714
740
  * */ function getInstanceInListControl(instance) {
715
741
  var _instance = instance;
716
742
  while(_instance){
@@ -781,7 +807,7 @@ var applyingPluginName = '';
781
807
  ]);
782
808
  return Driven;
783
809
  }(Watcher);
784
- /**
785
- * 控件事件定义
810
+ /**
811
+ * 控件事件定义
786
812
  * */ _define_property(Driven, "EventLogic", EventLogic);
787
813
  export { Driven };
package/dist/esm/Store.js CHANGED
@@ -96,42 +96,42 @@ export var Store = /*#__PURE__*/ function() {
96
96
  "use strict";
97
97
  function Store(options) {
98
98
  _class_call_check(this, Store);
99
- /**
100
- * 页面控件实例树
99
+ /**
100
+ * 页面控件实例树
101
101
  * */ _define_property(this, "instance", void 0);
102
- /**
103
- * 拍平的控件数组
102
+ /**
103
+ * 拍平的控件数组
104
104
  * */ _define_property(this, "flatInstances", void 0);
105
- /**
106
- * 控件id组成的map
105
+ /**
106
+ * 控件id组成的map
107
107
  * */ _define_property(this, "instanceIdMap", void 0);
108
- /**
109
- * dataCode和fieldCode组成的map
110
- * {
111
- * [主表dataCode]: {
112
- * [fieldCode]: 控件
113
- * },
114
- * [子表dataCode]: {
115
- * [fieldCode]: 控件
116
- * }
117
- * }
108
+ /**
109
+ * dataCode和fieldCode组成的map
110
+ * {
111
+ * [主表dataCode]: {
112
+ * [fieldCode]: 控件
113
+ * },
114
+ * [子表dataCode]: {
115
+ * [fieldCode]: 控件
116
+ * }
117
+ * }
118
118
  * */ _define_property(this, "dataFieldCodeMap", void 0);
119
- /**
120
- * 当前选中的控件
119
+ /**
120
+ * 当前选中的控件
121
121
  * */ _define_property(this, "selected", null);
122
- /**
123
- * 当前选中的数据作用域控件
122
+ /**
123
+ * 当前选中的数据作用域控件
124
124
  * */ _define_property(this, "selectedInstanceDataScopeParent", null);
125
125
  _define_property(this, "selectedDataScopeFlatInstances", []);
126
- /**
127
- * 当前选中控件的setting
126
+ /**
127
+ * 当前选中控件的setting
128
128
  * */ _define_property(this, "selectedInstanceSetting", []);
129
129
  _define_property(this, "selectedInstanceSettingItems", []);
130
- /**
131
- * 当前选中控件的数据模型
130
+ /**
131
+ * 当前选中控件的数据模型
132
132
  * */ _define_property(this, "selectedFieldItem", null);
133
- /**
134
- * 扩展字段,比如appId,dataCode等
133
+ /**
134
+ * 扩展字段,比如appId,dataCode等
135
135
  * */ _define_property(this, "external", {});
136
136
  _define_property(this, "movingInstance", null);
137
137
  _define_property(this, "movingInstanceOldParent", null);
@@ -147,8 +147,8 @@ export var Store = /*#__PURE__*/ function() {
147
147
  _create_class(Store, [
148
148
  {
149
149
  key: "selectedRules",
150
- get: /**
151
- * 当前选中控件的rules
150
+ get: /**
151
+ * 当前选中控件的rules
152
152
  * */ function get() {
153
153
  if (!this.selected) {
154
154
  return null;
@@ -158,8 +158,8 @@ export var Store = /*#__PURE__*/ function() {
158
158
  },
159
159
  {
160
160
  key: "selectedAntdRules",
161
- get: /**
162
- * 当前选中控件的antd rules
161
+ get: /**
162
+ * 当前选中控件的antd rules
163
163
  * */ function get() {
164
164
  var rules = this.selectedRules;
165
165
  if (!rules) {
package/dist/esm/utils.js CHANGED
@@ -197,9 +197,9 @@ export function getMasterFormControls(controls) {
197
197
  });
198
198
  return formctls;
199
199
  }
200
- /**
201
- * @description 给modelBindInfoList中填充fieldCode和dataCode
202
- * @description 我们生成fieldCode的规则是:DataBind的控件,取`field_${id}`,ObjectDataBind的控件,取`field_${id}_${key}`, key指的是ObjectDataBind.keys()
200
+ /**
201
+ * @description 给modelBindInfoList中填充fieldCode和dataCode
202
+ * @description 我们生成fieldCode的规则是:DataBind的控件,取`field_${id}`,ObjectDataBind的控件,取`field_${id}_${key}`, key指的是ObjectDataBind.keys()
203
203
  * */ export function fillModelBindInfoListFieldCode(modelBindInfoList) {
204
204
  var dataCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '';
205
205
  if (!modelBindInfoList || !Array.isArray(modelBindInfoList)) return [];
@@ -217,7 +217,6 @@ export function getMasterFormControls(controls) {
217
217
  dataBind.dataCode = dataCode;
218
218
  });
219
219
  } else {
220
- ;
221
220
  item.dataBind.fieldCode = fieldCodeBeforeAddPrefix(item.controlId);
222
221
  item.dataBind.dataCode = dataCode;
223
222
  }