@byteluck-fe/model-driven-engine 2.7.0-alpha.1 → 2.7.0-alpha.12

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.
@@ -40,6 +40,20 @@ function _classCallCheck(instance, Constructor) {
40
40
  throw new TypeError("Cannot call a class as a function");
41
41
  }
42
42
  }
43
+ function _defineProperties(target, props) {
44
+ for(var i = 0; i < props.length; i++){
45
+ var descriptor = props[i];
46
+ descriptor.enumerable = descriptor.enumerable || false;
47
+ descriptor.configurable = true;
48
+ if ("value" in descriptor) descriptor.writable = true;
49
+ Object.defineProperty(target, descriptor.key, descriptor);
50
+ }
51
+ }
52
+ function _createClass(Constructor, protoProps, staticProps) {
53
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
54
+ if (staticProps) _defineProperties(Constructor, staticProps);
55
+ return Constructor;
56
+ }
43
57
  function _iterableToArrayLimit(arr, i) {
44
58
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
45
59
  if (_i == null) return;
@@ -78,106 +92,12 @@ function _unsupportedIterableToArray(o, minLen) {
78
92
  if (n === "Map" || n === "Set") return Array.from(n);
79
93
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
80
94
  }
81
- var __generator = this && this.__generator || function(thisArg, body) {
82
- var f, y, t, g, _ = {
83
- label: 0,
84
- sent: function() {
85
- if (t[0] & 1) throw t[1];
86
- return t[1];
87
- },
88
- trys: [],
89
- ops: []
90
- };
91
- return(g = {
92
- next: verb(0),
93
- "throw": verb(1),
94
- "return": verb(2)
95
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
96
- return this;
97
- }), g);
98
- function verb(n) {
99
- return function(v) {
100
- return step([
101
- n,
102
- v
103
- ]);
104
- };
105
- }
106
- function step(op) {
107
- if (f) throw new TypeError("Generator is already executing.");
108
- while(_)try {
109
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
110
- if (y = 0, t) op = [
111
- op[0] & 2,
112
- t.value
113
- ];
114
- switch(op[0]){
115
- case 0:
116
- case 1:
117
- t = op;
118
- break;
119
- case 4:
120
- _.label++;
121
- return {
122
- value: op[1],
123
- done: false
124
- };
125
- case 5:
126
- _.label++;
127
- y = op[1];
128
- op = [
129
- 0
130
- ];
131
- continue;
132
- case 7:
133
- op = _.ops.pop();
134
- _.trys.pop();
135
- continue;
136
- default:
137
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
138
- _ = 0;
139
- continue;
140
- }
141
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
142
- _.label = op[1];
143
- break;
144
- }
145
- if (op[0] === 6 && _.label < t[1]) {
146
- _.label = t[1];
147
- t = op;
148
- break;
149
- }
150
- if (t && _.label < t[2]) {
151
- _.label = t[2];
152
- _.ops.push(op);
153
- break;
154
- }
155
- if (t[2]) _.ops.pop();
156
- _.trys.pop();
157
- continue;
158
- }
159
- op = body.call(thisArg, _);
160
- } catch (e) {
161
- op = [
162
- 6,
163
- e
164
- ];
165
- y = 0;
166
- } finally{
167
- f = t = 0;
168
- }
169
- if (op[0] & 5) throw op[1];
170
- return {
171
- value: op[0] ? op[1] : void 0,
172
- done: true
173
- };
174
- }
175
- };
95
+ import regeneratorRuntime from "regenerator-runtime";
176
96
  var LifecycleEventKeyMap = {
177
- "engine-mounted": "did_mount",
178
- "engine-submit": "will_submit",
179
- "engine-submit-params": "do_submit",
180
- "engine-submitted": "did_submit"
97
+ 'engine-mounted': 'did_mount',
98
+ 'engine-submit': 'will_submit',
99
+ 'engine-submit-params': 'do_submit',
100
+ 'engine-submitted': 'did_submit'
181
101
  };
182
102
  export var LifecycleEventPlugin = /*#__PURE__*/ function() {
183
103
  "use strict";
@@ -185,100 +105,97 @@ export var LifecycleEventPlugin = /*#__PURE__*/ function() {
185
105
  _classCallCheck(this, LifecycleEventPlugin);
186
106
  this.config = config;
187
107
  }
188
- var _proto = LifecycleEventPlugin.prototype;
189
- _proto.apply = function apply(engine) {
190
- var _this = this;
191
- this.engine = engine;
192
- Object.entries(LifecycleEventKeyMap).forEach(function(param) {
193
- var _param = _slicedToArray(param, 2), engineKey = _param[0], lifecycleKey = _param[1];
194
- var _this1 = _this;
195
- engine.on(engineKey, function() {
196
- var _ref = _asyncToGenerator(function(payload) {
197
- var result;
198
- return __generator(this, function(_state) {
199
- switch(_state.label){
200
- case 0:
201
- return [
202
- 4,
203
- _this1.callLifecycleEvent(lifecycleKey, payload)
204
- ];
205
- case 1:
206
- result = _state.sent();
207
- if (result.includes(false)) {
208
- return [
209
- 2,
210
- false
211
- ];
212
- } else {
213
- return [
214
- 2,
215
- result
216
- ];
108
+ _createClass(LifecycleEventPlugin, [
109
+ {
110
+ key: "apply",
111
+ value: function apply(engine) {
112
+ var _this = this;
113
+ this.engine = engine;
114
+ Object.entries(LifecycleEventKeyMap).forEach(function(param) {
115
+ var _param = _slicedToArray(param, 2), engineKey = _param[0], lifecycleKey = _param[1];
116
+ var _this1 = _this;
117
+ engine.on(engineKey, function() {
118
+ var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(payload) {
119
+ var result;
120
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
121
+ while(1)switch(_ctx.prev = _ctx.next){
122
+ case 0:
123
+ _ctx.next = 2;
124
+ return _this1.callLifecycleEvent(lifecycleKey, payload);
125
+ case 2:
126
+ result = _ctx.sent;
127
+ if (!result.includes(false)) {
128
+ _ctx.next = 7;
129
+ break;
130
+ }
131
+ return _ctx.abrupt("return", false);
132
+ case 7:
133
+ return _ctx.abrupt("return", result);
134
+ case 8:
135
+ case "end":
136
+ return _ctx.stop();
217
137
  }
218
- return [
219
- 2
220
- ];
221
- }
222
- });
138
+ }, _callee);
139
+ }));
140
+ return function(payload) {
141
+ return _ref.apply(this, arguments);
142
+ };
143
+ }());
223
144
  });
224
- return function(payload) {
225
- return _ref.apply(this, arguments);
226
- };
227
- }());
228
- });
229
- };
230
- _proto.callLifecycleEvent = function callLifecycleEvent(name, payload) {
231
- var _this = this;
232
- return _asyncToGenerator(function() {
233
- var events, result;
234
- return __generator(this, function(_state) {
235
- switch(_state.label){
236
- case 0:
237
- events = _this.config;
238
- if (!events || !Array.isArray(events[name])) {
239
- return [
240
- 2,
241
- []
242
- ];
243
- }
244
- return [
245
- 4,
246
- Promise.all(events[name].map(function() {
247
- var _ref = _asyncToGenerator(function(eventName) {
248
- var execResult;
249
- return __generator(this, function(_state) {
250
- switch(_state.label){
251
- case 0:
252
- return [
253
- 4,
254
- _this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
145
+ }
146
+ },
147
+ {
148
+ key: "callLifecycleEvent",
149
+ value: function callLifecycleEvent(name, payload) {
150
+ var _this = this;
151
+ return _asyncToGenerator(regeneratorRuntime.mark(function _callee1() {
152
+ var events, result;
153
+ return regeneratorRuntime.wrap(function _callee$(_ctx1) {
154
+ while(1)switch(_ctx1.prev = _ctx1.next){
155
+ case 0:
156
+ events = _this.config;
157
+ if (!(!events || !Array.isArray(events[name]))) {
158
+ _ctx1.next = 3;
159
+ break;
160
+ }
161
+ return _ctx1.abrupt("return", []);
162
+ case 3:
163
+ _ctx1.next = 5;
164
+ return Promise.all(events[name].map(function() {
165
+ var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(eventName) {
166
+ var execResult;
167
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
168
+ while(1)switch(_ctx.prev = _ctx.next){
169
+ case 0:
170
+ _ctx.next = 2;
171
+ return _this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
255
172
  // this.engine,
256
173
  // this.engine.getAction().actionUtils, //以前是params,空的
257
- payload)
258
- ];
259
- case 1:
260
- execResult = _state.sent();
261
- return [
262
- 2,
263
- execResult
264
- ];
265
- }
266
- });
267
- });
268
- return function(eventName) {
269
- return _ref.apply(this, arguments);
270
- };
271
- }()))
272
- ];
273
- case 1:
274
- result = _state.sent();
275
- return [
276
- 2,
277
- result
278
- ];
279
- }
280
- });
281
- })();
282
- };
174
+ payload);
175
+ case 2:
176
+ execResult = _ctx.sent;
177
+ return _ctx.abrupt("return", execResult);
178
+ case 4:
179
+ case "end":
180
+ return _ctx.stop();
181
+ }
182
+ }, _callee);
183
+ }));
184
+ return function(eventName) {
185
+ return _ref.apply(this, arguments);
186
+ };
187
+ }()));
188
+ case 5:
189
+ result = _ctx1.sent;
190
+ return _ctx1.abrupt("return", result);
191
+ case 7:
192
+ case "end":
193
+ return _ctx1.stop();
194
+ }
195
+ }, _callee1);
196
+ }))();
197
+ }
198
+ }
199
+ ]);
283
200
  return LifecycleEventPlugin;
284
201
  }();
@@ -3,24 +3,42 @@ function _classCallCheck(instance, Constructor) {
3
3
  throw new TypeError("Cannot call a class as a function");
4
4
  }
5
5
  }
6
+ function _defineProperties(target, props) {
7
+ for(var i = 0; i < props.length; i++){
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ("value" in descriptor) descriptor.writable = true;
12
+ Object.defineProperty(target, descriptor.key, descriptor);
13
+ }
14
+ }
15
+ function _createClass(Constructor, protoProps, staticProps) {
16
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
+ if (staticProps) _defineProperties(Constructor, staticProps);
18
+ return Constructor;
19
+ }
6
20
  export var StylePlugin = /*#__PURE__*/ function() {
7
21
  "use strict";
8
22
  function StylePlugin(config) {
9
23
  _classCallCheck(this, StylePlugin);
10
24
  this.config = config;
11
25
  }
12
- var _proto = StylePlugin.prototype;
13
- _proto.apply = function apply(engine) {
14
- var _this_config;
15
- this.engine = engine;
16
- var _this_config_source;
17
- var compiledStyle = (_this_config_source = (_this_config = this.config) === null || _this_config === void 0 ? void 0 : _this_config.source) !== null && _this_config_source !== void 0 ? _this_config_source : "";
18
- var style = document.createElement("style");
19
- style.className = "edit-css";
20
- style.type = "text/css";
21
- style.innerHTML = compiledStyle;
22
- var dom = document.querySelector("head");
23
- dom.appendChild(style);
24
- };
26
+ _createClass(StylePlugin, [
27
+ {
28
+ key: "apply",
29
+ value: function apply(engine) {
30
+ var ref;
31
+ this.engine = engine;
32
+ var ref1;
33
+ var compiledStyle = (ref1 = (ref = this.config) === null || ref === void 0 ? void 0 : ref.source) !== null && ref1 !== void 0 ? ref1 : '';
34
+ var style = document.createElement('style');
35
+ style.className = 'edit-css';
36
+ style.type = 'text/css';
37
+ style.innerHTML = compiledStyle;
38
+ var dom = document.querySelector('head');
39
+ dom.appendChild(style);
40
+ }
41
+ }
42
+ ]);
25
43
  return StylePlugin;
26
44
  }();
@@ -1,5 +1,5 @@
1
- export * from "./ES6ModulePlugin";
2
- export * from "./LifecycleEventPlugin";
3
- export * from "./ControlsEventPlugin";
4
- export * from "./CalcPlugin";
5
- export * from "./StylePlugin";
1
+ export * from './ES6ModulePlugin';
2
+ export * from './LifecycleEventPlugin';
3
+ export * from './ControlsEventPlugin';
4
+ export * from './CalcPlugin';
5
+ export * from './StylePlugin';
@@ -1 +1 @@
1
- export * from "./runtimeUtils";
1
+ export * from './runtimeUtils';
@@ -1,4 +1,4 @@
1
- import { CONTROL_BASE_TYPE, CONTROL_TYPE } from "@byteluck-fe/model-driven-shared";
1
+ import { CONTROL_BASE_TYPE, CONTROL_TYPE } from '@byteluck-fe/model-driven-shared';
2
2
  export function hasChildrenControl(instance) {
3
3
  return instance.controlType === CONTROL_BASE_TYPE.LAYOUT || instance.controlType === CONTROL_BASE_TYPE.WRAP || instance.controlType === CONTROL_BASE_TYPE.LIST || instance.controlType === CONTROL_BASE_TYPE.SEARCH;
4
4
  }
@@ -8,10 +8,12 @@ export function loopFormControl(control, callback) {
8
8
  //TODO 此处需要再抽象一层 datagrid/datalist
9
9
  if (item.type === CONTROL_TYPE.SUBTABLE) {
10
10
  // @ts-ignore
11
- var children = item.getChildrenFormControl();
11
+ var children = []//item.getChildrenFormControl() as RuntimeFormControl[]
12
+ ;
12
13
  callback(item, children);
13
14
  } else if (hasChildrenControl(item)) {
14
- loopFormControl(item === null || item === void 0 ? void 0 : item.children, callback);
15
+ var ref;
16
+ loopFormControl((ref = item) === null || ref === void 0 ? void 0 : ref.children, callback);
15
17
  // @ts-ignore
16
18
  } else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
17
19
  callback(item);
@@ -26,8 +28,9 @@ callback) {
26
28
  if (item.type === CONTROL_TYPE.DATA_VIEW || item.type === CONTROL_TYPE.SIMPLE_SEARCH) {
27
29
  callback(item);
28
30
  } else if (hasChildrenControl(item)) {
31
+ var ref;
29
32
  // @ts-ignore
30
- loopDataViewControl(item === null || item === void 0 ? void 0 : item.children, callback);
33
+ loopDataViewControl((ref = item) === null || ref === void 0 ? void 0 : ref.children, callback);
31
34
  }
32
35
  });
33
36
  }
@@ -35,9 +38,9 @@ callback) {
35
38
  var unique = 0;
36
39
  // uuid生成
37
40
  export function buildUUID() {
38
- var prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
41
+ var prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '';
39
42
  var time = Date.now();
40
43
  var random = Math.floor(Math.random() * 1000000000);
41
44
  unique++;
42
- return prefix + "_" + random + unique + String(time);
45
+ return prefix + '_' + random + unique + String(time);
43
46
  }