@byteluck-fe/model-driven-driven 2.10.0-alpha.8 → 2.11.0-alpha.1

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 // 工具
@@ -200,8 +200,8 @@ import { checkSchema, generatePermissions, getModelBindInfoList, toSchema } from
200
200
  import { Group, initSettings, Tab } from "@byteluck-fe/model-driven-settings";
201
201
  // 当前正在注册的插件名称
202
202
  var applyingPluginName = "";
203
- /**
204
- * 设计器驱动
203
+ /**
204
+ * 设计器驱动
205
205
  * */ var Driven = /*#__PURE__*/ function(Watcher) {
206
206
  "use strict";
207
207
  _inherits(Driven, Watcher);
@@ -213,20 +213,20 @@ var applyingPluginName = "";
213
213
  _define_property(_assert_this_initialized(_this), "mode", void 0);
214
214
  _define_property(_assert_this_initialized(_this), "isMounted", false);
215
215
  _define_property(_assert_this_initialized(_this), "id", genNonDuplicateId(8));
216
- /**
217
- * 控件可选的事件
216
+ /**
217
+ * 控件可选的事件
218
218
  * */ _define_property(_assert_this_initialized(_this), "eventLogic", void 0);
219
- /**
220
- * 处理数据存储,存放模型等
219
+ /**
220
+ * 处理数据存储,存放模型等
221
221
  * */ _define_property(_assert_this_initialized(_this), "store", void 0);
222
- /**
223
- * 额外参数存储
222
+ /**
223
+ * 额外参数存储
224
224
  */ _define_property(_assert_this_initialized(_this), "externalParams", void 0);
225
- /**
226
- * 处理instance,和schema存储
225
+ /**
226
+ * 处理instance,和schema存储
227
227
  * */ _define_property(_assert_this_initialized(_this), "designer", void 0);
228
- /**
229
- * 插件数组
228
+ /**
229
+ * 插件数组
230
230
  * */ _define_property(_assert_this_initialized(_this), "__plugins", void 0);
231
231
  _define_property(_assert_this_initialized(_this), "__pluginsApplied", false);
232
232
  _define_property(_assert_this_initialized(_this), "$options", void 0);
@@ -499,10 +499,10 @@ var applyingPluginName = "";
499
499
  if (instance === null) return;
500
500
  var _instance = this.getInstance(instance);
501
501
  if (!_instance) return;
502
- /*
503
- 移动之后,拿到控件新的位置,并触发事件, 如果是新增的控件的话,就没有原始位置和父级,
504
- 事件是否区分move和add
505
- move是从主表移动到子表或子表移动到主表才触发,还是所有移动都触发
502
+ /*
503
+ 移动之后,拿到控件新的位置,并触发事件, 如果是新增的控件的话,就没有原始位置和父级,
504
+ 事件是否区分move和add
505
+ move是从主表移动到子表或子表移动到主表才触发,还是所有移动都触发
506
506
  */ var oldDataScopeParent = this.store.movingInstanceOldDataScopeParent;
507
507
  var newDataScopeParent = findInstanceDataScopeParent(_instance);
508
508
  var oldParent = this.store.movingInstanceOldParent;
@@ -602,8 +602,8 @@ var applyingPluginName = "";
602
602
  {
603
603
  key: "updateInstanceProps",
604
604
  value: function updateInstanceProps(instance, props, payload) {
605
- var _this = this;
606
605
  var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "";
606
+ var _this = this;
607
607
  Object.entries(props).forEach(function(param) {
608
608
  var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
609
609
  var propName = "".concat(prevKey ? prevKey + "." : "").concat(key);
@@ -627,8 +627,8 @@ var applyingPluginName = "";
627
627
  },
628
628
  {
629
629
  key: "removeInstance",
630
- value: /**
631
- * 删除控件
630
+ value: /**
631
+ * 删除控件
632
632
  * */ function removeInstance(instance) {
633
633
  // 删除实例,并触发事件 removed
634
634
  var parent = instance.parent;
@@ -667,8 +667,8 @@ var applyingPluginName = "";
667
667
  },
668
668
  {
669
669
  key: "updateInstanceType",
670
- value: /**
671
- * 修改控件类型
670
+ value: /**
671
+ * 修改控件类型
672
672
  * */ function updateInstanceType(instance, type) {
673
673
  var schema = instance.toSchema();
674
674
  var newInstance = this.createInstance(type, {
@@ -726,16 +726,16 @@ var applyingPluginName = "";
726
726
  },
727
727
  {
728
728
  key: "assertInstance",
729
- value: /**
730
- * 判断控件的类型,返回当前控件的正确类型
729
+ value: /**
730
+ * 判断控件的类型,返回当前控件的正确类型
731
731
  * */ function assertInstance(instance, types) {
732
732
  return isString(types) ? instance.type === types : types.includes(instance.type);
733
733
  }
734
734
  },
735
735
  {
736
736
  key: "getInstanceInListControl",
737
- value: /**
738
- * 控件在列表控件内,如明细子表或列表控件
737
+ value: /**
738
+ * 控件在列表控件内,如明细子表或列表控件
739
739
  * */ function getInstanceInListControl(instance) {
740
740
  var _instance = instance;
741
741
  while(_instance){
@@ -763,8 +763,8 @@ var applyingPluginName = "";
763
763
  {
764
764
  key: "callSelectedEffect",
765
765
  value: function callSelectedEffect(effectKey) {
766
- var _this = this;
767
766
  var payload = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
767
+ var _this = this;
768
768
  this.store.selectedInstanceSettingItems.forEach(function(setting) {
769
769
  setting.callEffect(effectKey, _this, _object_spread({
770
770
  control: _this.store.selected
@@ -775,8 +775,8 @@ var applyingPluginName = "";
775
775
  {
776
776
  key: "callSelectedScopeEffect",
777
777
  value: function callSelectedScopeEffect() {
778
- var _this = this;
779
778
  var payload = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
779
+ var _this = this;
780
780
  this.store.selectedInstanceSettingItems.forEach(function(setting) {
781
781
  setting.callScopeEffect(_this, _object_spread({
782
782
  control: _this.store.selected
@@ -806,7 +806,7 @@ var applyingPluginName = "";
806
806
  ]);
807
807
  return Driven;
808
808
  }(Watcher);
809
- /**
810
- * 控件事件定义
809
+ /**
810
+ * 控件事件定义
811
811
  * */ _define_property(Driven, "EventLogic", EventLogic);
812
812
  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
@@ -181,9 +181,10 @@ function _ts_generator(thisArg, body) {
181
181
  }
182
182
  }
183
183
  import { loopFormControl } from "./designerUtils";
184
- import { CONTROL_BASE_TYPE, CONTROL_TYPE, FieldTypeToColumnType, isArray } from "@byteluck-fe/model-driven-shared";
185
- import Designer from "./Designer";
186
- import { objectDataBindControlTypes, objectDataBindKeyToFieldType } from "./constants";
184
+ import { CONTROL_BASE_TYPE, CONTROL_TYPE, // FieldTypes,
185
+ // FieldTypeToColumnType,
186
+ isArray } from "@byteluck-fe/model-driven-shared";
187
+ import { objectDataBindControlTypes } from "./constants";
187
188
  export function getMasterFormControls(controls) {
188
189
  var formctls = [];
189
190
  // @ts-ignore
@@ -195,9 +196,9 @@ export function getMasterFormControls(controls) {
195
196
  });
196
197
  return formctls;
197
198
  }
198
- /**
199
- * @description 给modelBindInfoList中填充fieldCode和dataCode
200
- * @description 我们生成fieldCode的规则是:DataBind的控件,取`field_${id}`,ObjectDataBind的控件,取`field_${id}_${key}`, key指的是ObjectDataBind.keys()
199
+ /**
200
+ * @description 给modelBindInfoList中填充fieldCode和dataCode
201
+ * @description 我们生成fieldCode的规则是:DataBind的控件,取`field_${id}`,ObjectDataBind的控件,取`field_${id}_${key}`, key指的是ObjectDataBind.keys()
201
202
  * */ export function fillModelBindInfoListFieldCode(modelBindInfoList) {
202
203
  var dataCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
203
204
  if (!modelBindInfoList || !Array.isArray(modelBindInfoList)) return [];
@@ -228,75 +229,6 @@ function fieldCodeBeforeAddPrefix(fieldCode) {
228
229
  }
229
230
  return prefix + fieldCode;
230
231
  }
231
- /**
232
- * @description 通过fieldType获取列表表头的type
233
- * */ export function getColumnTypeFromFiledType(fieldType) {
234
- return FieldTypeToColumnType[fieldType];
235
- }
236
- /**
237
- * @description 通过modelBindInfoList生成多个columns
238
- * */ export function getColumnsFromModelBindInfoList(modelBindInfoList) {
239
- var designer = new Designer();
240
- var columns = [];
241
- modelBindInfoList.forEach(function(item) {
242
- // 控件在明细子表内或者没有dataBind的话 不做生成
243
- if (item.parentId || !item.dataBind) return;
244
- // 如果是对象形式的dataBind的话
245
- if (objectDataBindControlTypes.includes(item.type)) {
246
- var objectDataBind = item.dataBind;
247
- var datasourceBind = item.datasourceBind;
248
- // 对象的每一个key生成一个column
249
- Object.keys(objectDataBind).forEach(function(key) {
250
- // 对应的dataBind
251
- var dataBind = objectDataBind[key];
252
- // 当前key对应的fieldType
253
- var fieldType = objectDataBindKeyToFieldType[key].fieldType;
254
- // 拼接当前列的caption
255
- var caption = item.caption + "_" + objectDataBindKeyToFieldType[key].caption;
256
- // 通过fieldType获取列类型
257
- var controlType = getColumnTypeFromFiledType(fieldType);
258
- if (!controlType) return;
259
- var props = {
260
- caption: caption,
261
- dataBind: dataBind
262
- };
263
- if (key === "currency") {
264
- props.optionConfig = "datasource";
265
- props.datasourceBind = datasourceBind;
266
- }
267
- // @ts-ignore
268
- var column = designer.createControlInstance(controlType, {
269
- props: props
270
- });
271
- column && columns.push(column);
272
- });
273
- } else {
274
- var controlType = getColumnTypeFromFiledType(item.fieldType);
275
- if (!controlType) return;
276
- // @ts-ignore
277
- var column = designer.createControlInstance(controlType, {
278
- props: {
279
- caption: item.caption,
280
- dataBind: item.dataBind,
281
- datasourceBind: item.datasourceBind
282
- }
283
- });
284
- column && columns.push(column);
285
- }
286
- });
287
- return columns;
288
- }
289
- export function getColumnsFromFiledType(fieldTypes) {
290
- var designer = new Designer();
291
- var fieldTypesMap = Array.isArray(fieldTypes) ? fieldTypes : [
292
- fieldTypes
293
- ];
294
- var result = fieldTypesMap.map(function(fieldType) {
295
- var columnType = getColumnTypeFromFiledType(fieldType);
296
- return designer.createControlInstance(columnType);
297
- });
298
- return Array.isArray(fieldTypes) ? result : result[0];
299
- }
300
232
  function toSchema(schema) {
301
233
  if (Array.isArray(schema)) {
302
234
  return schema.map(function(item) {