@byteluck-fe/model-driven-driven 1.3.0-beta.25 → 1.5.0-beta.2

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.
@@ -0,0 +1,96 @@
1
+ function _classCallCheck(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
5
+ }
6
+ import Designer from "./Designer";
7
+ import { CONTROL_TYPE } from "@byteluck-fe/model-driven-shared";
8
+ export var Builder = /*#__PURE__*/ function() {
9
+ "use strict";
10
+ function Builder() {
11
+ _classCallCheck(this, Builder);
12
+ this.designer = new Designer();
13
+ }
14
+ var _proto = Builder.prototype;
15
+ // @ts-ignore
16
+ _proto.ListPageBuilder = function ListPageBuilder() {
17
+ var listview = this.designer.createControlInstance(// @ts-ignore
18
+ CONTROL_TYPE.LIST_VIEW);
19
+ var simpleSearch = this.designer.createControlInstance(// @ts-ignore
20
+ CONTROL_TYPE.SIMPLE_SEARCH);
21
+ var gridTable = this.designer.createControlInstance(// @ts-ignore
22
+ CONTROL_TYPE.GRID_TABLE);
23
+ var createBtn = this.designer.createControlInstance(// @ts-ignore
24
+ CONTROL_TYPE.CREATE_FORM_LIST_BUTTON);
25
+ var importBtn = this.designer.createControlInstance(// @ts-ignore
26
+ CONTROL_TYPE.IMPORT_RECORD_LIST_BUTTON);
27
+ var exportBtn = this.designer.createControlInstance(// @ts-ignore
28
+ CONTROL_TYPE.EXPORT_LIST_BUTTON);
29
+ var exportRecordBtn = this.designer.createControlInstance(// @ts-ignore
30
+ CONTROL_TYPE.EXPORT_RECORD_LIST_BUTTON);
31
+ // @ts-ignore
32
+ gridTable.children.push(createBtn);
33
+ // @ts-ignore
34
+ gridTable.children.push(importBtn);
35
+ // @ts-ignore
36
+ gridTable.children.push(exportBtn);
37
+ // @ts-ignore
38
+ gridTable.children.push(exportRecordBtn);
39
+ // @ts-ignore
40
+ listview.children.push(simpleSearch);
41
+ // @ts-ignore
42
+ listview.children.push(gridTable);
43
+ return listview;
44
+ };
45
+ // @ts-ignore
46
+ _proto.ProListPageBuilder = function ProListPageBuilder() {
47
+ // @ts-ignore
48
+ var listview = this.designer.createControlInstance(// @ts-ignore
49
+ CONTROL_TYPE.LIST_VIEW);
50
+ var simpleSearch = this.designer.createControlInstance(// @ts-ignore
51
+ CONTROL_TYPE.SIMPLE_SEARCH);
52
+ var gridTable = this.designer.createControlInstance(// @ts-ignore
53
+ CONTROL_TYPE.GRID_TABLE);
54
+ // @ts-ignore
55
+ var exportBtn = this.designer.createControlInstance(// @ts-ignore
56
+ CONTROL_TYPE.EXPORT_LIST_BUTTON);
57
+ var exportRecordBtn = this.designer.createControlInstance(// @ts-ignore
58
+ CONTROL_TYPE.EXPORT_RECORD_LIST_BUTTON);
59
+ // @ts-ignore
60
+ gridTable.children.push(exportBtn);
61
+ // @ts-ignore
62
+ gridTable.children.push(exportRecordBtn);
63
+ // @ts-ignore
64
+ listview.children.push(simpleSearch);
65
+ // @ts-ignore
66
+ listview.children.push(gridTable);
67
+ return listview;
68
+ };
69
+ // @ts-ignore
70
+ _proto.FormPageBuilder = function FormPageBuilder() {
71
+ var dataView = this.designer.createControlInstance(// @ts-ignore
72
+ CONTROL_TYPE.DATA_VIEW);
73
+ // @ts-ignore
74
+ var title = this.designer.createControlInstance(CONTROL_TYPE.TITLE);
75
+ // @ts-ignore
76
+ var grid = this.designer.createControlInstance(CONTROL_TYPE.GRID);
77
+ // @ts-ignore
78
+ dataView.children.push(title);
79
+ // @ts-ignore
80
+ dataView.children.push(grid);
81
+ return dataView;
82
+ };
83
+ // @ts-ignore
84
+ _proto.VuePageBuilder = function VuePageBuilder() {
85
+ var grid = this.designer.createControlInstance(// @ts-ignore
86
+ CONTROL_TYPE.GRID);
87
+ var vueFormItem = this.designer.createControlInstance(// @ts-ignore
88
+ CONTROL_TYPE.VUE_FORM_ITEM);
89
+ // @ts-ignore
90
+ vueFormItem.props.controlExportName = "VuePage";
91
+ // @ts-ignore
92
+ grid.children.push(vueFormItem);
93
+ return grid;
94
+ };
95
+ return Builder;
96
+ }();
@@ -0,0 +1,232 @@
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function _assertThisInitialized(self) {
10
+ if (self === void 0) {
11
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
12
+ }
13
+ return self;
14
+ }
15
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
16
+ try {
17
+ var info = gen[key](arg);
18
+ var value = info.value;
19
+ } catch (error) {
20
+ reject(error);
21
+ return;
22
+ }
23
+ if (info.done) {
24
+ resolve(value);
25
+ } else {
26
+ Promise.resolve(value).then(_next, _throw);
27
+ }
28
+ }
29
+ function _asyncToGenerator(fn) {
30
+ return function() {
31
+ var self = this, args = arguments;
32
+ return new Promise(function(resolve, reject) {
33
+ var gen = fn.apply(self, args);
34
+ function _next(value) {
35
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
36
+ }
37
+ function _throw(err) {
38
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
39
+ }
40
+ _next(undefined);
41
+ });
42
+ };
43
+ }
44
+ function _classCallCheck(instance, Constructor) {
45
+ if (!(instance instanceof Constructor)) {
46
+ throw new TypeError("Cannot call a class as a function");
47
+ }
48
+ }
49
+ function _getPrototypeOf(o) {
50
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
51
+ return o.__proto__ || Object.getPrototypeOf(o);
52
+ };
53
+ return _getPrototypeOf(o);
54
+ }
55
+ function _inherits(subClass, superClass) {
56
+ if (typeof superClass !== "function" && superClass !== null) {
57
+ throw new TypeError("Super expression must either be null or a function");
58
+ }
59
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
60
+ constructor: {
61
+ value: subClass,
62
+ writable: true,
63
+ configurable: true
64
+ }
65
+ });
66
+ if (superClass) _setPrototypeOf(subClass, superClass);
67
+ }
68
+ function _instanceof(left, right) {
69
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
70
+ return !!right[Symbol.hasInstance](left);
71
+ } else {
72
+ return left instanceof right;
73
+ }
74
+ }
75
+ function _iterableToArray(iter) {
76
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
77
+ }
78
+ function _nonIterableSpread() {
79
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
80
+ }
81
+ function _possibleConstructorReturn(self, call) {
82
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
83
+ return call;
84
+ }
85
+ return _assertThisInitialized(self);
86
+ }
87
+ function _setPrototypeOf(o, p) {
88
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
89
+ o.__proto__ = p;
90
+ return o;
91
+ };
92
+ return _setPrototypeOf(o, p);
93
+ }
94
+ function _toConsumableArray(arr) {
95
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
96
+ }
97
+ var _typeof = function(obj) {
98
+ "@swc/helpers - typeof";
99
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
100
+ };
101
+ function _unsupportedIterableToArray(o, minLen) {
102
+ if (!o) return;
103
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
104
+ var n = Object.prototype.toString.call(o).slice(8, -1);
105
+ if (n === "Object" && o.constructor) n = o.constructor.name;
106
+ if (n === "Map" || n === "Set") return Array.from(n);
107
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
108
+ }
109
+ function _isNativeReflectConstruct() {
110
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
111
+ if (Reflect.construct.sham) return false;
112
+ if (typeof Proxy === "function") return true;
113
+ try {
114
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
115
+ return true;
116
+ } catch (e) {
117
+ return false;
118
+ }
119
+ }
120
+ function _createSuper(Derived) {
121
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
122
+ return function _createSuperInternal() {
123
+ var Super = _getPrototypeOf(Derived), result;
124
+ if (hasNativeReflectConstruct) {
125
+ var NewTarget = _getPrototypeOf(this).constructor;
126
+ result = Reflect.construct(Super, arguments, NewTarget);
127
+ } else {
128
+ result = Super.apply(this, arguments);
129
+ }
130
+ return _possibleConstructorReturn(this, result);
131
+ };
132
+ }
133
+ import regeneratorRuntime from "regenerator-runtime";
134
+ import { RegisterControls, controlHooksEmitter } from "@byteluck-fe/model-driven-core";
135
+ import EventLogic from "./EventLogic";
136
+ import { FieldTypes } from "@byteluck-fe/model-driven-shared";
137
+ import { toSchema, getModelBindInfoList, checkSchema } from "./utils";
138
+ var Designer = /*#__PURE__*/ function _target(RegisterControls) {
139
+ "use strict";
140
+ _inherits(Designer, RegisterControls);
141
+ var _super = _createSuper(Designer);
142
+ function Designer() {
143
+ _classCallCheck(this, Designer);
144
+ var _this;
145
+ _this = _super.call(this, "Designer");
146
+ _this.toolbox = [];
147
+ _this.services = {};
148
+ _this.eventLogic = new EventLogic();
149
+ _this.fieldTypes = FieldTypes;
150
+ _this.controlSettingMap = new Map();
151
+ (_instanceof(this, Designer) ? this.constructor : void 0).staticControls.forEach(function(control) {
152
+ var _$Designer = control.Designer, Setting = control.Setting;
153
+ _this.controlSettingMap.set(_$Designer.controlType, Setting);
154
+ });
155
+ return _this;
156
+ }
157
+ var _proto = Designer.prototype;
158
+ _proto.registerControl = function registerControl(control) {
159
+ this.constructor.register(control);
160
+ var DesignerClass = control.Designer, Setting = control.Setting;
161
+ this.register(DesignerClass);
162
+ this.registeredControlTypes.add(DesignerClass.controlType);
163
+ this.controlSettingMap.set(DesignerClass.controlType, Setting);
164
+ };
165
+ _proto.getControlSetting = function getControlSetting(type) {
166
+ var setting = this.controlSettingMap.get(type);
167
+ if (!setting) {
168
+ return null;
169
+ }
170
+ return setting;
171
+ };
172
+ _proto.setInstance = function setInstance(instance, props, value) {
173
+ try {
174
+ if (!instance) {
175
+ return;
176
+ }
177
+ // @ts-ignore
178
+ instance.updateProps(props, value);
179
+ } catch (e) {
180
+ throw e;
181
+ }
182
+ };
183
+ _proto.eachControls = function eachControls(callback) {
184
+ this.getControls().forEach(callback);
185
+ };
186
+ // 获取初始化的数据模型
187
+ _proto.getInitControl = function getInitControl() {
188
+ // @ts-ignore
189
+ return [
190
+ this.createControlInstance("grid")
191
+ ];
192
+ };
193
+ _proto.checkSchema = function checkSchema1() {
194
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
195
+ args[_key] = arguments[_key];
196
+ }
197
+ return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
198
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
199
+ while(1)switch(_ctx.prev = _ctx.next){
200
+ case 0:
201
+ return _ctx.abrupt("return", checkSchema.apply(void 0, _toConsumableArray(args)));
202
+ case 1:
203
+ case "end":
204
+ return _ctx.stop();
205
+ }
206
+ }, _callee);
207
+ }))();
208
+ };
209
+ _proto.getModelBindInfoList = function getModelBindInfoList1() {
210
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
211
+ args[_key] = arguments[_key];
212
+ }
213
+ return getModelBindInfoList.apply(void 0, _toConsumableArray(args));
214
+ };
215
+ _proto.getSchema = function getSchema() {
216
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
217
+ args[_key] = arguments[_key];
218
+ }
219
+ return toSchema.apply(void 0, _toConsumableArray(args));
220
+ };
221
+ _proto.listenControlHook = function listenControlHook() {
222
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
223
+ args[_key] = arguments[_key];
224
+ }
225
+ var _controlHooksEmitter;
226
+ return (_controlHooksEmitter = controlHooksEmitter).on.apply(_controlHooksEmitter, _toConsumableArray(args));
227
+ };
228
+ return Designer;
229
+ }(RegisterControls);
230
+ Designer.EventLogic = EventLogic;
231
+ export { Designer as default };
232
+ export { Designer };