@sepveneto/dnde-core 0.1.0
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/LICENSE +21 -0
- package/dist/Widget-BRcHUoH6.d.cts +166 -0
- package/dist/Widget-BRcHUoH6.d.ts +166 -0
- package/dist/chunk-4QIIKQ6B.js +8 -0
- package/dist/chunk-4QVESRP3.js +0 -0
- package/dist/chunk-6FNC3XMI.js +45 -0
- package/dist/chunk-AEGKV2TZ.js +65 -0
- package/dist/chunk-CJZUQN2X.js +50 -0
- package/dist/chunk-D2MSIUE2.js +6 -0
- package/dist/chunk-QYATL3P2.js +15 -0
- package/dist/chunk-TM53N6AZ.js +24 -0
- package/dist/chunk-W776G2UQ.js +36 -0
- package/dist/chunk-WPER3YKQ.js +111 -0
- package/dist/chunk-XJ2IJHKH.js +8 -0
- package/dist/chunk-YSTVVZUQ.js +48 -0
- package/dist/class/Container.cjs +94 -0
- package/dist/class/Container.d.cts +10 -0
- package/dist/class/Container.d.ts +10 -0
- package/dist/class/Container.js +8 -0
- package/dist/class/Node.cjs +167 -0
- package/dist/class/Node.d.cts +49 -0
- package/dist/class/Node.d.ts +49 -0
- package/dist/class/Node.js +9 -0
- package/dist/class/Widget.cjs +84 -0
- package/dist/class/Widget.d.cts +4 -0
- package/dist/class/Widget.d.ts +4 -0
- package/dist/class/Widget.js +7 -0
- package/dist/class/index.cjs +238 -0
- package/dist/class/index.d.cts +6 -0
- package/dist/class/index.d.ts +6 -0
- package/dist/class/index.js +17 -0
- package/dist/helper/EventEmitter.cjs +60 -0
- package/dist/helper/EventEmitter.d.cts +12 -0
- package/dist/helper/EventEmitter.d.ts +12 -0
- package/dist/helper/EventEmitter.js +7 -0
- package/dist/helper/index.cjs +175 -0
- package/dist/helper/index.d.cts +7 -0
- package/dist/helper/index.d.ts +7 -0
- package/dist/helper/index.js +19 -0
- package/dist/helper/schema.cjs +92 -0
- package/dist/helper/schema.d.cts +27 -0
- package/dist/helper/schema.d.ts +27 -0
- package/dist/helper/schema.js +8 -0
- package/dist/helper/widget.cjs +73 -0
- package/dist/helper/widget.d.cts +51 -0
- package/dist/helper/widget.d.ts +51 -0
- package/dist/helper/widget.js +9 -0
- package/dist/index.cjs +211 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +33 -0
- package/dist/internal.cjs +49 -0
- package/dist/internal.d.cts +18 -0
- package/dist/internal.d.ts +18 -0
- package/dist/internal.js +9 -0
- package/dist/tokens.cjs +30 -0
- package/dist/tokens.d.cts +15 -0
- package/dist/tokens.d.ts +15 -0
- package/dist/tokens.js +7 -0
- package/dist/types.cjs +32 -0
- package/dist/types.d.cts +4 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +7 -0
- package/dist/utils.cjs +32 -0
- package/dist/utils.d.cts +3 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +7 -0
- package/package.json +60 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __copyProps = (to, from, except, desc) => {
|
|
30
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(from))
|
|
32
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
33
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return to;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
|
+
mod
|
|
44
|
+
));
|
|
45
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
+
var __async = (__this, __arguments, generator) => {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
var fulfilled = (value) => {
|
|
49
|
+
try {
|
|
50
|
+
step(generator.next(value));
|
|
51
|
+
} catch (e) {
|
|
52
|
+
reject(e);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var rejected = (value) => {
|
|
56
|
+
try {
|
|
57
|
+
step(generator.throw(value));
|
|
58
|
+
} catch (e) {
|
|
59
|
+
reject(e);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
63
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// src/class/index.ts
|
|
68
|
+
var class_exports = {};
|
|
69
|
+
__export(class_exports, {
|
|
70
|
+
Container: () => Container,
|
|
71
|
+
Node: () => Node,
|
|
72
|
+
RootNode: () => RootNode,
|
|
73
|
+
Widget: () => Widget
|
|
74
|
+
});
|
|
75
|
+
module.exports = __toCommonJS(class_exports);
|
|
76
|
+
|
|
77
|
+
// src/class/Widget.ts
|
|
78
|
+
var import_async_validator = __toESM(require("async-validator"), 1);
|
|
79
|
+
var Widget = class _Widget {
|
|
80
|
+
constructor(widget) {
|
|
81
|
+
this._data = JSON.parse(JSON.stringify(widget));
|
|
82
|
+
this.name = widget._name;
|
|
83
|
+
this.view = widget._view;
|
|
84
|
+
this.container = widget.container;
|
|
85
|
+
}
|
|
86
|
+
clone() {
|
|
87
|
+
return new _Widget(this._data);
|
|
88
|
+
}
|
|
89
|
+
get icon() {
|
|
90
|
+
return this._data._icon;
|
|
91
|
+
}
|
|
92
|
+
get props() {
|
|
93
|
+
var _a;
|
|
94
|
+
return ((_a = this._data.schema) == null ? void 0 : _a.props) || [];
|
|
95
|
+
}
|
|
96
|
+
get style() {
|
|
97
|
+
var _a;
|
|
98
|
+
return ((_a = this._data.schema) == null ? void 0 : _a.style) || [];
|
|
99
|
+
}
|
|
100
|
+
get draggable() {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
return (_b = (_a = this._data.meta) == null ? void 0 : _a.draggable) != null ? _b : true;
|
|
103
|
+
}
|
|
104
|
+
get validatorProps() {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
const _rules = ((_b = (_a = this._data.schema) == null ? void 0 : _a.props) == null ? void 0 : _b.reduce((all, curr) => {
|
|
107
|
+
all[curr.key] = curr.rules || [];
|
|
108
|
+
return all;
|
|
109
|
+
}, {})) || {};
|
|
110
|
+
const validator = new import_async_validator.default(_rules);
|
|
111
|
+
return validator;
|
|
112
|
+
}
|
|
113
|
+
get validatorStyle() {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
const _rules = ((_b = (_a = this._data.schema) == null ? void 0 : _a.style) == null ? void 0 : _b.reduce((all, curr) => {
|
|
116
|
+
all[curr.key] = curr.rules || [];
|
|
117
|
+
return all;
|
|
118
|
+
}, {})) || {};
|
|
119
|
+
const validator = new import_async_validator.default(_rules);
|
|
120
|
+
return validator;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// src/class/Container.ts
|
|
125
|
+
var Container = class extends Widget {
|
|
126
|
+
constructor(data) {
|
|
127
|
+
super(data);
|
|
128
|
+
this.view = "container";
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// src/class/Node.ts
|
|
133
|
+
var import_uuid = require("uuid");
|
|
134
|
+
var Node = class _Node {
|
|
135
|
+
constructor(widget, info) {
|
|
136
|
+
this.level = 0;
|
|
137
|
+
this.list = [];
|
|
138
|
+
this.data = {};
|
|
139
|
+
this.style = {};
|
|
140
|
+
this.hovering = false;
|
|
141
|
+
this.dragging = false;
|
|
142
|
+
this.widget = widget;
|
|
143
|
+
this.wid = (0, import_uuid.v4)();
|
|
144
|
+
this.list = (info == null ? void 0 : info.list) || [];
|
|
145
|
+
this.data = (info == null ? void 0 : info.props) || {};
|
|
146
|
+
this.style = (info == null ? void 0 : info.style) || {};
|
|
147
|
+
}
|
|
148
|
+
get isContainer() {
|
|
149
|
+
return !!this.widget.container;
|
|
150
|
+
}
|
|
151
|
+
get hasList() {
|
|
152
|
+
return this.list && this.list.length > 0;
|
|
153
|
+
}
|
|
154
|
+
get mouseover() {
|
|
155
|
+
return this.hovering;
|
|
156
|
+
}
|
|
157
|
+
get type() {
|
|
158
|
+
var _a;
|
|
159
|
+
return ((_a = this.widget) == null ? void 0 : _a.view) || "root";
|
|
160
|
+
}
|
|
161
|
+
get name() {
|
|
162
|
+
var _a;
|
|
163
|
+
return ((_a = this.widget) == null ? void 0 : _a.name) || "\u9875\u9762";
|
|
164
|
+
}
|
|
165
|
+
validate(only = false) {
|
|
166
|
+
return __async(this, null, function* () {
|
|
167
|
+
const valid = yield Promise.all([
|
|
168
|
+
this.widget.validatorProps.validate(this.data),
|
|
169
|
+
this.widget.validatorStyle.validate(this.style)
|
|
170
|
+
]).catch(() => {
|
|
171
|
+
return false;
|
|
172
|
+
});
|
|
173
|
+
if (!valid) {
|
|
174
|
+
return this.wid;
|
|
175
|
+
}
|
|
176
|
+
if (only || !this.list) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
for (const item of this.list) {
|
|
180
|
+
const invalid = yield item.validate();
|
|
181
|
+
if (invalid) {
|
|
182
|
+
return invalid;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
triggerHover(hover) {
|
|
188
|
+
this.hovering = hover;
|
|
189
|
+
}
|
|
190
|
+
setList(list) {
|
|
191
|
+
this.list = list;
|
|
192
|
+
}
|
|
193
|
+
copy() {
|
|
194
|
+
var _a;
|
|
195
|
+
const list = (_a = this.list) == null ? void 0 : _a.map((item) => item.copy());
|
|
196
|
+
const info = {
|
|
197
|
+
props: JSON.parse(JSON.stringify(this.data)),
|
|
198
|
+
style: JSON.parse(JSON.stringify(this.style)),
|
|
199
|
+
list
|
|
200
|
+
};
|
|
201
|
+
return new _Node(this.widget.clone(), info);
|
|
202
|
+
}
|
|
203
|
+
parse() {
|
|
204
|
+
var _a;
|
|
205
|
+
const res = __spreadProps(__spreadValues({
|
|
206
|
+
_uuid: this.wid,
|
|
207
|
+
_name: this.name,
|
|
208
|
+
_view: this.type,
|
|
209
|
+
// TODO
|
|
210
|
+
isShow: true
|
|
211
|
+
}, this.data), {
|
|
212
|
+
style: this.style,
|
|
213
|
+
list: (_a = this.list) == null ? void 0 : _a.map((item) => item.parse())
|
|
214
|
+
});
|
|
215
|
+
return res;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
var RootNode = class {
|
|
219
|
+
constructor(widget, info) {
|
|
220
|
+
this.level = 0;
|
|
221
|
+
this.list = [];
|
|
222
|
+
this.data = {};
|
|
223
|
+
this.style = {};
|
|
224
|
+
this.hovering = false;
|
|
225
|
+
this.dragging = false;
|
|
226
|
+
this.widget = widget;
|
|
227
|
+
this.wid = (0, import_uuid.v4)();
|
|
228
|
+
this.data = (info == null ? void 0 : info.props) || {};
|
|
229
|
+
this.style = (info == null ? void 0 : info.style) || {};
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
233
|
+
0 && (module.exports = {
|
|
234
|
+
Container,
|
|
235
|
+
Node,
|
|
236
|
+
RootNode,
|
|
237
|
+
Widget
|
|
238
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Container
|
|
3
|
+
} from "../chunk-QYATL3P2.js";
|
|
4
|
+
import {
|
|
5
|
+
Node,
|
|
6
|
+
RootNode
|
|
7
|
+
} from "../chunk-WPER3YKQ.js";
|
|
8
|
+
import {
|
|
9
|
+
Widget
|
|
10
|
+
} from "../chunk-CJZUQN2X.js";
|
|
11
|
+
import "../chunk-6FNC3XMI.js";
|
|
12
|
+
export {
|
|
13
|
+
Container,
|
|
14
|
+
Node,
|
|
15
|
+
RootNode,
|
|
16
|
+
Widget
|
|
17
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/helper/EventEmitter.ts
|
|
21
|
+
var EventEmitter_exports = {};
|
|
22
|
+
__export(EventEmitter_exports, {
|
|
23
|
+
EventEmitter: () => EventEmitter
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(EventEmitter_exports);
|
|
26
|
+
var EventEmitter = class {
|
|
27
|
+
constructor(subscribeFn) {
|
|
28
|
+
this.events = /* @__PURE__ */ new Map();
|
|
29
|
+
this.notify = subscribeFn;
|
|
30
|
+
}
|
|
31
|
+
on(event, callback) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (!this.events.has(event)) {
|
|
34
|
+
this.events.set(event, []);
|
|
35
|
+
}
|
|
36
|
+
(_a = this.events.get(event)) == null ? void 0 : _a.push(callback);
|
|
37
|
+
}
|
|
38
|
+
emit(event, ...args) {
|
|
39
|
+
var _a;
|
|
40
|
+
this.notify(event, ...args);
|
|
41
|
+
if (this.events.has(event)) {
|
|
42
|
+
(_a = this.events.get(event)) == null ? void 0 : _a.forEach((callback) => {
|
|
43
|
+
callback(...args);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
off(event, callback) {
|
|
48
|
+
var _a;
|
|
49
|
+
if (this.events.has(event)) {
|
|
50
|
+
this.events.set(event, ((_a = this.events.get(event)) == null ? void 0 : _a.filter((cb) => cb !== callback)) || []);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
clear() {
|
|
54
|
+
this.events.clear();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
EventEmitter
|
|
60
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type CallbackFn = (...args: any[]) => void;
|
|
2
|
+
declare class EventEmitter {
|
|
3
|
+
notify: CallbackFn;
|
|
4
|
+
events: Map<string, CallbackFn[]>;
|
|
5
|
+
constructor(subscribeFn: CallbackFn);
|
|
6
|
+
on(event: string, callback: CallbackFn): void;
|
|
7
|
+
emit(event: string, ...args: any[]): void;
|
|
8
|
+
off(event: string, callback: CallbackFn): void;
|
|
9
|
+
clear(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { EventEmitter };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type CallbackFn = (...args: any[]) => void;
|
|
2
|
+
declare class EventEmitter {
|
|
3
|
+
notify: CallbackFn;
|
|
4
|
+
events: Map<string, CallbackFn[]>;
|
|
5
|
+
constructor(subscribeFn: CallbackFn);
|
|
6
|
+
on(event: string, callback: CallbackFn): void;
|
|
7
|
+
emit(event: string, ...args: any[]): void;
|
|
8
|
+
off(event: string, callback: CallbackFn): void;
|
|
9
|
+
clear(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { EventEmitter };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/helper/index.ts
|
|
21
|
+
var helper_exports = {};
|
|
22
|
+
__export(helper_exports, {
|
|
23
|
+
EventEmitter: () => EventEmitter,
|
|
24
|
+
schema: () => schema,
|
|
25
|
+
widget: () => widget,
|
|
26
|
+
widgetType: () => widgetType
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(helper_exports);
|
|
29
|
+
|
|
30
|
+
// src/helper/EventEmitter.ts
|
|
31
|
+
var EventEmitter = class {
|
|
32
|
+
constructor(subscribeFn) {
|
|
33
|
+
this.events = /* @__PURE__ */ new Map();
|
|
34
|
+
this.notify = subscribeFn;
|
|
35
|
+
}
|
|
36
|
+
on(event, callback) {
|
|
37
|
+
var _a;
|
|
38
|
+
if (!this.events.has(event)) {
|
|
39
|
+
this.events.set(event, []);
|
|
40
|
+
}
|
|
41
|
+
(_a = this.events.get(event)) == null ? void 0 : _a.push(callback);
|
|
42
|
+
}
|
|
43
|
+
emit(event, ...args) {
|
|
44
|
+
var _a;
|
|
45
|
+
this.notify(event, ...args);
|
|
46
|
+
if (this.events.has(event)) {
|
|
47
|
+
(_a = this.events.get(event)) == null ? void 0 : _a.forEach((callback) => {
|
|
48
|
+
callback(...args);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
off(event, callback) {
|
|
53
|
+
var _a;
|
|
54
|
+
if (this.events.has(event)) {
|
|
55
|
+
this.events.set(event, ((_a = this.events.get(event)) == null ? void 0 : _a.filter((cb) => cb !== callback)) || []);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
clear() {
|
|
59
|
+
this.events.clear();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/utils.ts
|
|
64
|
+
function likeArray(val) {
|
|
65
|
+
return Array.isArray(val) ? val : [val];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/helper/schema.ts
|
|
69
|
+
var schema = {
|
|
70
|
+
input(config) {
|
|
71
|
+
const base = {
|
|
72
|
+
label: config.label,
|
|
73
|
+
key: config.key,
|
|
74
|
+
type: "input",
|
|
75
|
+
rules: normalizeRules(config),
|
|
76
|
+
attrs: config.attrs
|
|
77
|
+
};
|
|
78
|
+
return base;
|
|
79
|
+
},
|
|
80
|
+
number(config) {
|
|
81
|
+
return {
|
|
82
|
+
label: config.label,
|
|
83
|
+
key: config.key,
|
|
84
|
+
type: "number",
|
|
85
|
+
rules: normalizeRules(config),
|
|
86
|
+
attrs: config.attrs
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
select(config) {
|
|
90
|
+
return {
|
|
91
|
+
label: config.label,
|
|
92
|
+
key: config.key,
|
|
93
|
+
type: "select",
|
|
94
|
+
attrs: config.attrs,
|
|
95
|
+
rules: normalizeRules(config),
|
|
96
|
+
options: config.options
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
styleNumber(config) {
|
|
100
|
+
return {
|
|
101
|
+
label: config.label,
|
|
102
|
+
key: config.key,
|
|
103
|
+
type: "styleNumber",
|
|
104
|
+
rules: normalizeRules(config)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
function normalizeRules(config) {
|
|
109
|
+
const rules = likeArray(config.rules || []);
|
|
110
|
+
if (config.required) {
|
|
111
|
+
if (typeof config.required === "string") {
|
|
112
|
+
rules.push({
|
|
113
|
+
required: true,
|
|
114
|
+
message: config.required
|
|
115
|
+
});
|
|
116
|
+
} else if (config.required) {
|
|
117
|
+
rules.push({
|
|
118
|
+
required: true,
|
|
119
|
+
message: `\u8BF7\u586B\u5199${config.label}`
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return rules;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/helper/widget.ts
|
|
127
|
+
var widgetType = /* @__PURE__ */ ((widgetType2) => {
|
|
128
|
+
widgetType2[widgetType2["WIDGET"] = 0] = "WIDGET";
|
|
129
|
+
widgetType2[widgetType2["GROUP"] = 1] = "GROUP";
|
|
130
|
+
return widgetType2;
|
|
131
|
+
})(widgetType || {});
|
|
132
|
+
var widget = {
|
|
133
|
+
columnContainer(config) {
|
|
134
|
+
return {
|
|
135
|
+
_name: config.name || "\u6805\u683C\u5BB9\u5668",
|
|
136
|
+
_view: "containerGrid",
|
|
137
|
+
_icon: config.icon,
|
|
138
|
+
container: true,
|
|
139
|
+
meta: config.config,
|
|
140
|
+
style: config.defaultStyle,
|
|
141
|
+
schema: {
|
|
142
|
+
props: config.attributes,
|
|
143
|
+
style: config.stylesheet
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
create(config) {
|
|
148
|
+
return {
|
|
149
|
+
_name: config.name,
|
|
150
|
+
_view: config.type,
|
|
151
|
+
_icon: config.icon,
|
|
152
|
+
container: config.isContainer,
|
|
153
|
+
meta: config.config,
|
|
154
|
+
schema: {
|
|
155
|
+
props: config.attributes,
|
|
156
|
+
style: config.stylesheet
|
|
157
|
+
},
|
|
158
|
+
style: config.defaultStyle
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
group(name, list) {
|
|
162
|
+
return {
|
|
163
|
+
type: 1 /* GROUP */,
|
|
164
|
+
name,
|
|
165
|
+
list
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
+
0 && (module.exports = {
|
|
171
|
+
EventEmitter,
|
|
172
|
+
schema,
|
|
173
|
+
widget,
|
|
174
|
+
widgetType
|
|
175
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "../chunk-4QVESRP3.js";
|
|
2
|
+
import {
|
|
3
|
+
EventEmitter
|
|
4
|
+
} from "../chunk-W776G2UQ.js";
|
|
5
|
+
import {
|
|
6
|
+
schema
|
|
7
|
+
} from "../chunk-AEGKV2TZ.js";
|
|
8
|
+
import {
|
|
9
|
+
widget,
|
|
10
|
+
widgetType
|
|
11
|
+
} from "../chunk-YSTVVZUQ.js";
|
|
12
|
+
import "../chunk-XJ2IJHKH.js";
|
|
13
|
+
import "../chunk-6FNC3XMI.js";
|
|
14
|
+
export {
|
|
15
|
+
EventEmitter,
|
|
16
|
+
schema,
|
|
17
|
+
widget,
|
|
18
|
+
widgetType
|
|
19
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/helper/schema.ts
|
|
21
|
+
var schema_exports = {};
|
|
22
|
+
__export(schema_exports, {
|
|
23
|
+
schema: () => schema
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(schema_exports);
|
|
26
|
+
|
|
27
|
+
// src/utils.ts
|
|
28
|
+
function likeArray(val) {
|
|
29
|
+
return Array.isArray(val) ? val : [val];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/helper/schema.ts
|
|
33
|
+
var schema = {
|
|
34
|
+
input(config) {
|
|
35
|
+
const base = {
|
|
36
|
+
label: config.label,
|
|
37
|
+
key: config.key,
|
|
38
|
+
type: "input",
|
|
39
|
+
rules: normalizeRules(config),
|
|
40
|
+
attrs: config.attrs
|
|
41
|
+
};
|
|
42
|
+
return base;
|
|
43
|
+
},
|
|
44
|
+
number(config) {
|
|
45
|
+
return {
|
|
46
|
+
label: config.label,
|
|
47
|
+
key: config.key,
|
|
48
|
+
type: "number",
|
|
49
|
+
rules: normalizeRules(config),
|
|
50
|
+
attrs: config.attrs
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
select(config) {
|
|
54
|
+
return {
|
|
55
|
+
label: config.label,
|
|
56
|
+
key: config.key,
|
|
57
|
+
type: "select",
|
|
58
|
+
attrs: config.attrs,
|
|
59
|
+
rules: normalizeRules(config),
|
|
60
|
+
options: config.options
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
styleNumber(config) {
|
|
64
|
+
return {
|
|
65
|
+
label: config.label,
|
|
66
|
+
key: config.key,
|
|
67
|
+
type: "styleNumber",
|
|
68
|
+
rules: normalizeRules(config)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
function normalizeRules(config) {
|
|
73
|
+
const rules = likeArray(config.rules || []);
|
|
74
|
+
if (config.required) {
|
|
75
|
+
if (typeof config.required === "string") {
|
|
76
|
+
rules.push({
|
|
77
|
+
required: true,
|
|
78
|
+
message: config.required
|
|
79
|
+
});
|
|
80
|
+
} else if (config.required) {
|
|
81
|
+
rules.push({
|
|
82
|
+
required: true,
|
|
83
|
+
message: `\u8BF7\u586B\u5199${config.label}`
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return rules;
|
|
88
|
+
}
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
schema
|
|
92
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { InputInstance, InputNumberInstance, SelectInstance, ElOption } from 'element-plus';
|
|
2
|
+
import { j as SchemaItem } from '../Widget-BRcHUoH6.cjs';
|
|
3
|
+
import 'vue';
|
|
4
|
+
import 'async-validator';
|
|
5
|
+
|
|
6
|
+
type Option = InstanceType<typeof ElOption>;
|
|
7
|
+
interface BaseConfig {
|
|
8
|
+
label: SchemaItem['label'];
|
|
9
|
+
key: SchemaItem['key'];
|
|
10
|
+
required?: boolean | string;
|
|
11
|
+
rules?: SchemaItem['rules'];
|
|
12
|
+
}
|
|
13
|
+
declare const schema: {
|
|
14
|
+
input(config: BaseConfig & {
|
|
15
|
+
attrs?: InputInstance["$props"];
|
|
16
|
+
}): SchemaItem;
|
|
17
|
+
number(config: BaseConfig & {
|
|
18
|
+
attrs?: InputNumberInstance["$props"];
|
|
19
|
+
}): SchemaItem;
|
|
20
|
+
select(config: BaseConfig & {
|
|
21
|
+
attrs?: SelectInstance["$props"];
|
|
22
|
+
options?: Option["$props"][];
|
|
23
|
+
}): SchemaItem;
|
|
24
|
+
styleNumber(config: BaseConfig): SchemaItem;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { schema };
|