@yoyaflow/yoya-ui 0.3.3 → 0.4.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/README.md +305 -261
- package/README.zh-CN.md +269 -225
- package/dist/yoya.core.chunk.js +4275 -0
- package/dist/yoya.core.chunk.min.js +9 -0
- package/dist/yoya.core.js +3 -2338
- package/dist/yoya.core.min.js +1 -0
- package/dist/yoya.devtools.js +3 -223
- package/dist/yoya.devtools.min.js +1 -0
- package/dist/yoya.echart.js +182 -849
- package/dist/yoya.echart.min.js +1 -0
- package/dist/yoya.router.full.js +5271 -0
- package/dist/yoya.router.full.min.js +43 -0
- package/dist/yoya.router.js +1330 -0
- package/dist/yoya.router.min.js +35 -0
- package/dist/yoya.three.js +360 -0
- package/dist/yoya.three.min.js +1 -0
- package/dist/yoya.ui-router.full.js +21843 -0
- package/dist/yoya.ui-router.full.min.js +43 -0
- package/dist/yoya.ui-router.umd.js +43 -0
- package/dist/yoya.ui-router.umd.min.js +43 -0
- package/dist/yoya.ui.css +9 -0
- package/dist/yoya.ui.full.js +20169 -0
- package/dist/yoya.ui.full.min.js +1 -0
- package/dist/yoya.ui.js +12106 -9840
- package/dist/yoya.ui.min.js +1 -0
- package/package.json +18 -14
- package/types/index.d.ts +1 -1
- package/types/three.d.ts +77 -0
- package/types/yoya.router.d.ts +7 -0
- package/types/yoya.three.d.ts +4 -0
- package/types/yoya.ui-router.d.ts +19 -0
- package/types/yoya.ui.d.ts +2 -7
- package/dist/yoya-ui.umd.js +0 -35
- package/dist/yoya.ssr.js +0 -3444
- package/types/yoya.ssr.d.ts +0 -9
package/dist/yoya.echart.js
CHANGED
|
@@ -1,900 +1,233 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function t(e) {
|
|
4
|
-
if (!e) return null;
|
|
5
|
-
if (typeof e == "object" && e.code) return {
|
|
6
|
-
code: e.code,
|
|
7
|
-
level: e.level === "write" ? "write" : "read"
|
|
8
|
-
};
|
|
9
|
-
let t = String(e).trim();
|
|
10
|
-
return t ? t.startsWith("w.") ? {
|
|
11
|
-
code: t.slice(2),
|
|
12
|
-
level: "write"
|
|
13
|
-
} : t.startsWith("r.") ? {
|
|
14
|
-
code: t.slice(2),
|
|
15
|
-
level: "read"
|
|
16
|
-
} : {
|
|
17
|
-
code: t,
|
|
18
|
-
level: "write"
|
|
19
|
-
} : null;
|
|
20
|
-
}
|
|
21
|
-
function n(t, n) {
|
|
22
|
-
let r = e;
|
|
23
|
-
e = t || r;
|
|
24
|
-
try {
|
|
25
|
-
return n();
|
|
26
|
-
} finally {
|
|
27
|
-
e = r;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function r() {
|
|
31
|
-
return e || null;
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/core/node.js
|
|
35
|
-
var i = Symbol.for("yoya.devtools.bridge");
|
|
36
|
-
function a() {
|
|
37
|
-
return typeof globalThis > "u" ? null : globalThis[i] || null;
|
|
38
|
-
}
|
|
39
|
-
function o() {
|
|
40
|
-
let e = a();
|
|
41
|
-
return e ? e.enabled() : !1;
|
|
42
|
-
}
|
|
43
|
-
function s(e) {
|
|
44
|
-
let t = a();
|
|
45
|
-
t && t.emit(e);
|
|
46
|
-
}
|
|
47
|
-
function c(e) {
|
|
48
|
-
let t = a();
|
|
49
|
-
t && t.unregister(e);
|
|
50
|
-
}
|
|
51
|
-
function l(e) {
|
|
52
|
-
let t = a();
|
|
53
|
-
t && t.captureScope(e);
|
|
54
|
-
}
|
|
55
|
-
function u(e) {
|
|
56
|
-
let t = a();
|
|
57
|
-
return t ? t.ensureId(e) : void 0;
|
|
58
|
-
}
|
|
59
|
-
function d(e, t, n) {
|
|
60
|
-
let r = a();
|
|
61
|
-
r && r.notify(e, t, n);
|
|
62
|
-
}
|
|
63
|
-
function f(e) {
|
|
64
|
-
let t = a();
|
|
65
|
-
t && t.commit(e);
|
|
66
|
-
}
|
|
67
|
-
var p = /* @__PURE__ */ new Set([
|
|
68
|
-
"checked",
|
|
69
|
-
"disabled",
|
|
70
|
-
"readonly",
|
|
71
|
-
"selected"
|
|
72
|
-
]), m = /* @__PURE__ */ new Set([
|
|
73
|
-
"input",
|
|
74
|
-
"select",
|
|
75
|
-
"textarea",
|
|
76
|
-
"button",
|
|
77
|
-
"fieldset",
|
|
78
|
-
"option",
|
|
79
|
-
"optgroup",
|
|
80
|
-
"keygen"
|
|
81
|
-
]), h = /* @__PURE__ */ new Set(["input", "textarea"]), g = [];
|
|
82
|
-
function _() {
|
|
83
|
-
return g.length > 0 ? g[g.length - 1] : null;
|
|
84
|
-
}
|
|
85
|
-
function v(e, t) {
|
|
86
|
-
g.push(e);
|
|
87
|
-
try {
|
|
88
|
-
return t();
|
|
89
|
-
} finally {
|
|
90
|
-
g.pop();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function y(e, t, n, r) {
|
|
94
|
-
throw TypeError(`vStateNode binding scope required for function value (${e}${t ? ` "${t}"` : ""})`);
|
|
95
|
-
}
|
|
96
|
-
var b = /* @__PURE__ */ new Set([
|
|
97
|
-
"area",
|
|
98
|
-
"base",
|
|
99
|
-
"br",
|
|
100
|
-
"col",
|
|
101
|
-
"embed",
|
|
102
|
-
"hr",
|
|
103
|
-
"img",
|
|
104
|
-
"input",
|
|
105
|
-
"link",
|
|
106
|
-
"meta",
|
|
107
|
-
"param",
|
|
108
|
-
"source",
|
|
109
|
-
"track",
|
|
110
|
-
"wbr"
|
|
111
|
-
]);
|
|
112
|
-
function x(e) {
|
|
113
|
-
return typeof e == "string" ? document.querySelector(e) : e;
|
|
114
|
-
}
|
|
115
|
-
function S(e) {
|
|
116
|
-
return String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
117
|
-
}
|
|
118
|
-
function C(e) {
|
|
119
|
-
return p.has(e);
|
|
120
|
-
}
|
|
121
|
-
function w(e, t, n) {
|
|
122
|
-
if (n == null || n === !1) {
|
|
123
|
-
if (e.removeAttribute(t), t in e) try {
|
|
124
|
-
e[t] = !1;
|
|
125
|
-
} catch {}
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (n === !0 || C(t)) {
|
|
129
|
-
if (e.setAttribute(t, t), t in e) try {
|
|
130
|
-
e[t] = !0;
|
|
131
|
-
} catch {}
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (e.setAttribute(t, String(n)), t in e) try {
|
|
135
|
-
e[t] = n;
|
|
136
|
-
} catch {}
|
|
137
|
-
}
|
|
138
|
-
function T(e) {
|
|
139
|
-
return Object.entries(e).filter(([, e]) => e != null && e !== "").map(([e, t]) => `${E(e)}:${S(t)}`).join("; ");
|
|
140
|
-
}
|
|
141
|
-
function E(e) {
|
|
142
|
-
return String(e).replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
|
|
143
|
-
}
|
|
144
|
-
function D(e, t) {
|
|
145
|
-
return e === t ? !0 : !e || !t || typeof e != "object" || typeof t != "object" ? !1 : !!e.capture == !!t.capture && !!e.once == !!t.once && !!e.passive == !!t.passive;
|
|
146
|
-
}
|
|
147
|
-
var O = class e {
|
|
148
|
-
constructor(e = null) {
|
|
149
|
-
this._children = [], this._childKeys = /* @__PURE__ */ new Map(), this._events = /* @__PURE__ */ new Map(), this._domAdapters = /* @__PURE__ */ new Map(), this._cleanup = [], this._states = {}, this._stateTypes = {}, this._stateHandlers = /* @__PURE__ */ new Map(), this._pendingRemovals = /* @__PURE__ */ new Set(), this._childrenDirty = !1, this._deleted = !1, this._access = null, this._accessContext = r(), o() && l(this), e !== null && this.setup(e);
|
|
150
|
-
}
|
|
151
|
-
setup(t) {
|
|
152
|
-
return typeof t == "function" ? t(this) : t instanceof e ? this.child(t) : typeof t == "string" || typeof t == "number" ? this.text(t) : t && typeof t == "object" && this._setupObject(t), this;
|
|
153
|
-
}
|
|
154
|
-
access(e) {
|
|
155
|
-
let n = t(e);
|
|
156
|
-
return this._access = n ? {
|
|
157
|
-
code: n.code,
|
|
158
|
-
level: "write"
|
|
159
|
-
} : null, this;
|
|
160
|
-
}
|
|
161
|
-
_permissionState() {
|
|
162
|
-
let e = this._access ?? _();
|
|
163
|
-
if (!e) return "active";
|
|
164
|
-
let t = this._accessContext || r();
|
|
165
|
-
return t ? t.canRead(e.code) ? e.level === "write" && !t.canWrite(e.code) ? "readonly" : "active" : "hidden" : "active";
|
|
166
|
-
}
|
|
167
|
-
_applyAccessState(e) {}
|
|
168
|
-
_setupObject(e) {
|
|
169
|
-
e.children && this.child(e.children);
|
|
170
|
-
}
|
|
171
|
-
children() {
|
|
172
|
-
return [...this._children];
|
|
173
|
-
}
|
|
174
|
-
clearChildren() {
|
|
175
|
-
let e = this._el && o() && !this._devtoolsRendering ? this._children.map((e) => u(e)) : [];
|
|
176
|
-
return this._dropChildKeys(this._children), this._children.forEach((e) => {
|
|
177
|
-
this._pendingRemovals.add(e);
|
|
178
|
-
}), this._children = [], this._childrenDirty = !0, e.length > 0 && !this._devtoolsRendering && d(this, "child", { removed: e }), this;
|
|
179
|
-
}
|
|
180
|
-
addChild(e, t) {
|
|
181
|
-
let n = String(e);
|
|
182
|
-
if (this._childKeys.has(n)) throw TypeError(`duplicate key "${n}"`);
|
|
183
|
-
let r = j(t);
|
|
184
|
-
if (this._childKeys.set(n, r), typeof r.attr == "function" && r.attr("data-row-key", n), this._pendingRemovals.delete(r), this._children.push(r), this._childrenDirty = !0, this._el) {
|
|
185
|
-
let e = v(this._access ?? _(), () => r.renderDom());
|
|
186
|
-
e && e.parentNode !== this._el && this._el.appendChild(e), o() && !this._devtoolsRendering && d(this, "child", { added: [u(r)] });
|
|
187
|
-
}
|
|
188
|
-
return this;
|
|
189
|
-
}
|
|
190
|
-
getChild(e) {
|
|
191
|
-
return this._childKeys.get(String(e)) || null;
|
|
192
|
-
}
|
|
193
|
-
removeChild(e) {
|
|
194
|
-
let t = String(e), n = this._childKeys.get(t);
|
|
195
|
-
if (!n) return this;
|
|
196
|
-
this._childKeys.delete(t);
|
|
197
|
-
let r = this._children.indexOf(n);
|
|
198
|
-
r !== -1 && this._children.splice(r, 1), this._childrenDirty = !0;
|
|
199
|
-
let i = this._el && o() && !this._devtoolsRendering ? u(n) : null;
|
|
200
|
-
return n.destroy(), i !== null && d(this, "child", { removed: [i] }), this;
|
|
201
|
-
}
|
|
202
|
-
_dropChildKeys(e) {
|
|
203
|
-
let t = new Set(e);
|
|
204
|
-
this._childKeys.forEach((e, n) => {
|
|
205
|
-
t.has(e) && this._childKeys.delete(n);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
child(...e) {
|
|
209
|
-
return e.flat(Infinity).forEach((e) => {
|
|
210
|
-
if (e == null) return;
|
|
211
|
-
let t = j(e);
|
|
212
|
-
this._pendingRemovals.delete(t), this._children.push(t), this._childrenDirty = !0;
|
|
213
|
-
}), this;
|
|
214
|
-
}
|
|
215
|
-
text(e) {
|
|
216
|
-
return this.child(new k(e));
|
|
217
|
-
}
|
|
218
|
-
on(e, t, n) {
|
|
219
|
-
if (typeof t != "function") throw TypeError("ViewNode event handler must be a function");
|
|
220
|
-
let r = this._events.get(e);
|
|
221
|
-
return this._events.set(e, {
|
|
222
|
-
handler: t,
|
|
223
|
-
options: n
|
|
224
|
-
}), this._el && this._bindDomAdapter(e, r?.options, n), this;
|
|
225
|
-
}
|
|
226
|
-
off(e) {
|
|
227
|
-
this._events.delete(e);
|
|
228
|
-
let t = this._domAdapters.get(e);
|
|
229
|
-
return t && (t.cleanup(), this._removeCleanup(t.cleanup), this._domAdapters.delete(e)), this;
|
|
230
|
-
}
|
|
231
|
-
_bindDomAdapter(e, t, n) {
|
|
232
|
-
let r = this._domAdapters.get(e);
|
|
233
|
-
if (r) {
|
|
234
|
-
if (D(t, n)) return;
|
|
235
|
-
r.cleanup(), this._removeCleanup(r.cleanup), this._domAdapters.delete(e);
|
|
236
|
-
}
|
|
237
|
-
let i = (t) => {
|
|
238
|
-
let n = this._events.get(e);
|
|
239
|
-
!n || typeof n.handler != "function" || (n.handler.call(this, t), n.options?.once && this.off(e));
|
|
240
|
-
}, a = () => {
|
|
241
|
-
this._el && this._el.removeEventListener(e, i, n);
|
|
242
|
-
};
|
|
243
|
-
this._el.addEventListener(e, i, n), this._domAdapters.set(e, { cleanup: a }), this._cleanup.push(a);
|
|
244
|
-
}
|
|
245
|
-
_removeCleanup(e) {
|
|
246
|
-
let t = this._cleanup.indexOf(e);
|
|
247
|
-
t !== -1 && this._cleanup.splice(t, 1);
|
|
248
|
-
}
|
|
249
|
-
registerStateAttrs(...e) {
|
|
250
|
-
return e.forEach((e) => {
|
|
251
|
-
if (typeof e == "string") {
|
|
252
|
-
this._stateTypes[e] = "boolean";
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
e && typeof e == "object" && Object.entries(e).forEach(([e, t]) => {
|
|
256
|
-
this._stateTypes[e] = t || "boolean";
|
|
257
|
-
});
|
|
258
|
-
}), this;
|
|
259
|
-
}
|
|
260
|
-
registerStateHandler(e, t) {
|
|
261
|
-
return this._stateHandlers.has(e) || this._stateHandlers.set(e, []), this._stateHandlers.get(e).push(t), this;
|
|
262
|
-
}
|
|
263
|
-
setState(e, t = !0) {
|
|
264
|
-
let n = this._states[e];
|
|
265
|
-
return this._states[e] = t, (this._stateHandlers.get(e) || []).forEach((e) => e(t, this, n)), this;
|
|
266
|
-
}
|
|
267
|
-
getState(e) {
|
|
268
|
-
return this._states[e];
|
|
269
|
-
}
|
|
270
|
-
getBooleanState(e) {
|
|
271
|
-
return !!this.getState(e);
|
|
272
|
-
}
|
|
273
|
-
getStringState(e) {
|
|
274
|
-
let t = this.getState(e);
|
|
275
|
-
return t == null ? "" : String(t);
|
|
276
|
-
}
|
|
277
|
-
getNumberState(e) {
|
|
278
|
-
return Number(this.getState(e) || 0);
|
|
279
|
-
}
|
|
280
|
-
renderDom() {
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
commit() {
|
|
284
|
-
return this.renderDom();
|
|
285
|
-
}
|
|
286
|
-
_commitChildren() {
|
|
287
|
-
this._pendingRemovals.forEach((e) => e.destroy()), this._pendingRemovals.clear(), this._childrenDirty = !1;
|
|
288
|
-
}
|
|
289
|
-
bindTo(e) {
|
|
290
|
-
let t = x(e), n = this.renderDom();
|
|
291
|
-
return t && n && t.appendChild(n), this;
|
|
292
|
-
}
|
|
293
|
-
destroy() {
|
|
294
|
-
return o() && (s({
|
|
295
|
-
type: "destroy",
|
|
296
|
-
node: this
|
|
297
|
-
}), c(this)), this._deleted = !0, this._cleanup.forEach((e) => e()), this._cleanup = [], this._children.forEach((e) => e.destroy()), this._pendingRemovals.forEach((e) => e.destroy()), this._pendingRemovals.clear(), this._children = [], this._childKeys.clear(), this._el?.parentNode && this._el.parentNode.removeChild(this._el), this;
|
|
298
|
-
}
|
|
299
|
-
toHTML() {
|
|
300
|
-
return "";
|
|
301
|
-
}
|
|
302
|
-
hydrateSnapshot() {
|
|
303
|
-
return this;
|
|
304
|
-
}
|
|
305
|
-
}, k = class extends O {
|
|
306
|
-
constructor(e = "") {
|
|
307
|
-
if (super(null), this._content = "", this._textNode = null, typeof e == "function") {
|
|
308
|
-
y("text", null, e, (e) => this.textContent(e));
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
this._content = String(e);
|
|
312
|
-
}
|
|
313
|
-
textContent(e) {
|
|
314
|
-
if (e === void 0) return this._content;
|
|
315
|
-
if (typeof e == "function") return y("text", null, e, (e) => this.textContent(e)), this;
|
|
316
|
-
let t = this._content;
|
|
317
|
-
return this._content = String(e), this._textNode && (this._textNode.textContent = this._content), this._textNode && o() && !Object.is(t, this._content) && d(this, "text", {
|
|
318
|
-
from: t,
|
|
319
|
-
to: this._content
|
|
320
|
-
}), this;
|
|
321
|
-
}
|
|
322
|
-
renderDom() {
|
|
323
|
-
return this._deleted || this._permissionState() === "hidden" ? null : (this._textNode || (this._textNode = document.createTextNode(this._content), this._el = this._textNode), this._textNode);
|
|
324
|
-
}
|
|
325
|
-
toHTML() {
|
|
326
|
-
return this._deleted || this._permissionState() === "hidden" ? "" : S(this._content);
|
|
327
|
-
}
|
|
328
|
-
}, A = class extends O {
|
|
329
|
-
constructor(e) {
|
|
330
|
-
super(null), this._component = e, this._resolved = null, this._resolvedList = null, this._roots = null, this._fragmentDom = null;
|
|
331
|
-
}
|
|
332
|
-
_resolve() {
|
|
333
|
-
if (this._resolvedList) return this._resolved;
|
|
334
|
-
let e = n(this._accessContext || r(), () => typeof this._component == "function" ? this._component() : this._component.render()), t = Array.isArray(e) ? e.slice() : [e];
|
|
335
|
-
return t.forEach((e) => {
|
|
336
|
-
if (!(e instanceof O)) throw TypeError("Component render must return a ViewNode or an array of ViewNodes");
|
|
337
|
-
}), this._resolvedList = t, this._resolved = t[0] || null, this._roots = Array.isArray(e) ? t : null, this._component && typeof this._component == "object" && typeof this._component._attachHost == "function" && this._component._attachHost(this), this._resolved;
|
|
338
|
-
}
|
|
339
|
-
_resolveList() {
|
|
340
|
-
return this._resolve(), this._resolvedList || [];
|
|
341
|
-
}
|
|
342
|
-
_replaceResolved(e) {
|
|
343
|
-
let t = this._resolvedList || [], n = Array.isArray(e) ? e.slice() : [e];
|
|
344
|
-
if (n.forEach((e) => {
|
|
345
|
-
if (!(e instanceof O)) throw TypeError("Component render must return a ViewNode or an array of ViewNodes");
|
|
346
|
-
}), t.length === n.length && t.every((e, t) => e === n[t])) return;
|
|
347
|
-
let r = [];
|
|
348
|
-
if (this._fragmentDom && this._fragmentDom.length > 0) r.push(...this._fragmentDom);
|
|
349
|
-
else if (t.length > 0) {
|
|
350
|
-
let e = t[0]._el;
|
|
351
|
-
e && e.parentNode && r.push(e);
|
|
352
|
-
}
|
|
353
|
-
if (this._resolvedList = n, this._resolved = n[0] || null, this._roots = Array.isArray(e) ? n : null, this._fragmentDom = null, r.length === 0) {
|
|
354
|
-
t.forEach((e) => e.destroy());
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
let i = _(), a = r[0].parentNode, o = [];
|
|
358
|
-
n.forEach((e) => {
|
|
359
|
-
let t = v(this._access ?? i, () => e.renderDom());
|
|
360
|
-
t && o.push(t);
|
|
361
|
-
}), o.length > 0 && a && o.forEach((e) => a.insertBefore(e, r[0])), r.forEach((e) => {
|
|
362
|
-
e.parentNode === a && a.removeChild(e);
|
|
363
|
-
}), this._roots ? this._fragmentDom = o : this._el = o[0] || null, t.forEach((e) => e.destroy());
|
|
364
|
-
}
|
|
365
|
-
children() {
|
|
366
|
-
return this._resolvedList ? this._roots ? this._resolvedList.flatMap((e) => e.children()) : this._resolvedList[0] ? this._resolvedList[0].children() : [] : [];
|
|
367
|
-
}
|
|
368
|
-
textContent() {
|
|
369
|
-
return this._resolveList().map((e) => typeof e.textContent == "function" ? e.textContent() : "").join("");
|
|
370
|
-
}
|
|
371
|
-
renderDom() {
|
|
372
|
-
if (this._deleted || this._permissionState() === "hidden") return null;
|
|
373
|
-
let e = _(), t = this._resolveList();
|
|
374
|
-
if (this._roots) {
|
|
375
|
-
if (this._fragmentDom) return null;
|
|
376
|
-
let n = [];
|
|
377
|
-
t.forEach((t) => {
|
|
378
|
-
let r = v(this._access ?? e, () => t.renderDom());
|
|
379
|
-
r && n.push(r);
|
|
380
|
-
}), this._fragmentDom = n;
|
|
381
|
-
let r = document.createDocumentFragment();
|
|
382
|
-
return n.forEach((e) => r.appendChild(e)), r;
|
|
383
|
-
}
|
|
384
|
-
let n = t[0];
|
|
385
|
-
return v(this._access ?? e, () => {
|
|
386
|
-
let e = n.renderDom();
|
|
387
|
-
return this._el = e, e;
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
toHTML() {
|
|
391
|
-
if (this._deleted || this._permissionState() === "hidden") return "";
|
|
392
|
-
let e = _(), t = this._resolveList();
|
|
393
|
-
return v(this._access ?? e, () => t.map((e) => e.toHTML()).join(""));
|
|
394
|
-
}
|
|
395
|
-
destroy() {
|
|
396
|
-
return this._component && typeof this._component == "object" && typeof this._component.destroy == "function" && this._component.destroy(), (this._resolvedList || []).forEach((e) => e.destroy()), this._fragmentDom = null, super.destroy();
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
function j(e) {
|
|
400
|
-
if (e instanceof O) return e;
|
|
401
|
-
if (typeof e == "function" || e && typeof e == "object" && typeof e.render == "function") return new A(e);
|
|
402
|
-
if (typeof e == "string" || typeof e == "number") return new k(e);
|
|
403
|
-
throw TypeError("ViewNode child must be a ViewNode, component, string, or number");
|
|
404
|
-
}
|
|
405
|
-
function M(e = null, t = null, n = null) {
|
|
406
|
-
return typeof t == "function" && n == null ? {
|
|
407
|
-
first: e,
|
|
408
|
-
options: null,
|
|
409
|
-
callback: t
|
|
410
|
-
} : {
|
|
411
|
-
first: e,
|
|
412
|
-
options: t,
|
|
413
|
-
callback: n
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
function N(e, t) {
|
|
417
|
-
return !t || typeof t != "object" || Array.isArray(t) ? e : (t.attrs && typeof e.attr == "function" && e.attr(t.attrs), t.style && typeof e.styles == "function" && e.styles(t.style), e);
|
|
418
|
-
}
|
|
419
|
-
var P = class extends O {
|
|
420
|
-
constructor(e, t = null) {
|
|
421
|
-
super(null), this._tagName = e, this._attrs = {}, this._styles = {}, this._classes = /* @__PURE__ */ new Set(), this._el = null, t !== null && this.setup(t);
|
|
422
|
-
}
|
|
423
|
-
_setupObject(e) {
|
|
424
|
-
Object.entries(e).forEach(([e, t]) => {
|
|
425
|
-
if (e === "class" || e === "className") {
|
|
426
|
-
this.className(t);
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
if (e === "attrs") {
|
|
430
|
-
this.attr(t);
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
if (e === "style") {
|
|
434
|
-
this.styles(t);
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
if (e === "children") {
|
|
438
|
-
this.child(t);
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
if (e.startsWith("on") && typeof t == "function") {
|
|
442
|
-
this.on(e.slice(2).toLowerCase(), t);
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
if (typeof this[e] == "function") {
|
|
446
|
-
this[e](t);
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
typeof t != "function" && this.attr(e, t);
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
tagName() {
|
|
453
|
-
return this._tagName;
|
|
454
|
-
}
|
|
455
|
-
textContent() {
|
|
456
|
-
return this._children.map((e) => typeof e.textContent == "function" ? e.textContent() : "").join("");
|
|
457
|
-
}
|
|
458
|
-
attr(e, t) {
|
|
459
|
-
if (t === void 0 && typeof e == "string") return this._attrs[e];
|
|
460
|
-
if (e && typeof e == "object") return Object.entries(e).forEach(([e, t]) => this.attr(e, t)), this;
|
|
461
|
-
if (typeof t == "function") return y("attr", e, t, (t) => this.attr(e, t)), this;
|
|
462
|
-
let n = this._attrs[e];
|
|
463
|
-
return t == null || t === !1 ? delete this._attrs[e] : this._attrs[e] = t, this._el && w(this._el, e, t), this._el && o() && !this._devtoolsRendering && !Object.is(n, t) && d(this, "attr", {
|
|
464
|
-
name: e,
|
|
465
|
-
previous: n,
|
|
466
|
-
next: t
|
|
467
|
-
}), this;
|
|
468
|
-
}
|
|
469
|
-
id(e) {
|
|
470
|
-
return e === void 0 ? this.attr("id") : this.attr("id", e);
|
|
471
|
-
}
|
|
472
|
-
name(e) {
|
|
473
|
-
return e === void 0 ? this.attr("name") : this.attr("name", e);
|
|
474
|
-
}
|
|
475
|
-
className(...e) {
|
|
476
|
-
return e.length === 0 ? [...this._classes].join(" ") : (e.flat(Infinity).forEach((e) => {
|
|
477
|
-
e && String(e).split(/\s+/).filter(Boolean).forEach((e) => this._classes.add(e));
|
|
478
|
-
}), this._syncClassName(), this);
|
|
479
|
-
}
|
|
480
|
-
class(...e) {
|
|
481
|
-
return this.className(...e);
|
|
482
|
-
}
|
|
483
|
-
replaceClassName(e, t, n = !1) {
|
|
484
|
-
return !e || !t || e === t ? this : this._classes.has(e) ? (this._classes.delete(e), this.className(t)) : n ? this.className(t) : this;
|
|
485
|
-
}
|
|
486
|
-
style(e, t) {
|
|
487
|
-
if (t === void 0 && typeof e == "string") return this._styles[e];
|
|
488
|
-
if (e && typeof e == "object") return this.styles(e);
|
|
489
|
-
if (typeof t == "function") return y("style", e, t, (t) => this.style(e, t)), this;
|
|
490
|
-
let n = this._styles[e];
|
|
491
|
-
return t == null || t === "" ? delete this._styles[e] : this._styles[e] = t, this._el && (this._el.style[e] = t || ""), this._el && o() && !this._devtoolsRendering && !Object.is(n, t) && d(this, "style", {
|
|
492
|
-
name: e,
|
|
493
|
-
previous: n,
|
|
494
|
-
next: t
|
|
495
|
-
}), this;
|
|
496
|
-
}
|
|
497
|
-
styles(e) {
|
|
498
|
-
return Object.entries(e || {}).forEach(([e, t]) => this.style(e, t)), this;
|
|
499
|
-
}
|
|
500
|
-
child(...e) {
|
|
501
|
-
let t = this._el && o() && !this._devtoolsRendering ? [] : null;
|
|
502
|
-
return e.flat(Infinity).forEach((e) => {
|
|
503
|
-
if (e == null) return;
|
|
504
|
-
let n = j(e);
|
|
505
|
-
if (this._pendingRemovals.delete(n), this._children.push(n), this._childrenDirty = !0, this._el) {
|
|
506
|
-
let e = v(this._access ?? _(), () => n.renderDom());
|
|
507
|
-
e && e.parentNode !== this._el && this._el.appendChild(e), t && t.push(u(n));
|
|
508
|
-
}
|
|
509
|
-
}), t && t.length > 0 && d(this, "child", { added: t }), this;
|
|
510
|
-
}
|
|
511
|
-
_applyAccessState(e) {
|
|
512
|
-
if (e === "readonly") {
|
|
513
|
-
this._accessAttrsApplied = !0;
|
|
514
|
-
let e = this._tagName;
|
|
515
|
-
m.has(e) && this.attr("disabled", !0), h.has(e) && this.attr("readonly", !0), this.attr("aria-disabled", "true");
|
|
516
|
-
return;
|
|
517
|
-
}
|
|
518
|
-
this._accessAttrsApplied && (this._accessAttrsApplied = !1, this.attr("disabled", null), this.attr("readonly", null), this.attr("aria-disabled", null));
|
|
519
|
-
}
|
|
520
|
-
renderDom() {
|
|
521
|
-
if (this._deleted) return null;
|
|
522
|
-
let e = this._permissionState();
|
|
523
|
-
if (e === "hidden") return null;
|
|
524
|
-
let t = this._access ?? _();
|
|
525
|
-
o() && (this._devtoolsRendering = !0);
|
|
526
|
-
try {
|
|
527
|
-
return this._el || (this._el = document.createElement(this._tagName), v(t, () => this._applySnapshotToElement())), this._applyAccessState(e), this._commitChildren(), this._children.forEach((e) => {
|
|
528
|
-
v(t, () => {
|
|
529
|
-
let t = e.renderDom();
|
|
530
|
-
t && t.parentNode !== this._el ? this._el.appendChild(t) : !t && e._el && e._el.parentNode === this._el && this._el.removeChild(e._el);
|
|
531
|
-
});
|
|
532
|
-
}), o() && f(this), this._el;
|
|
533
|
-
} finally {
|
|
534
|
-
this._devtoolsRendering = !1;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
toHTML() {
|
|
538
|
-
if (this._deleted) return "";
|
|
539
|
-
let e = this._permissionState();
|
|
540
|
-
return e === "hidden" ? "" : (this._applyAccessState(e), v(this._access ?? _(), () => {
|
|
541
|
-
let e = this._serializeAttributes(), t = e ? `<${this._tagName} ${e}>` : `<${this._tagName}>`;
|
|
542
|
-
return b.has(this._tagName) ? t : `${t}${this._children.map((e) => e.toHTML()).join("")}</${this._tagName}>`;
|
|
543
|
-
}));
|
|
544
|
-
}
|
|
545
|
-
_applyBindingsToElement() {
|
|
546
|
-
Object.entries(this._attrs).forEach(([e, t]) => w(this._el, e, t)), this._syncClassName(), Object.entries(this._styles).forEach(([e, t]) => {
|
|
547
|
-
this._el.style[e] = t;
|
|
548
|
-
}), this._events.forEach((e, t) => {
|
|
549
|
-
this._bindDomAdapter(t, void 0, e.options);
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
_applySnapshotToElement() {
|
|
553
|
-
this._applyBindingsToElement(), this._children.forEach((e) => {
|
|
554
|
-
let t = e.renderDom();
|
|
555
|
-
t && this._el.appendChild(t);
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
_syncClassName() {
|
|
559
|
-
let e = this._attrs.class, t = [...this._classes].join(" ");
|
|
560
|
-
t ? this._attrs.class = t : delete this._attrs.class, this._el && (t ? this._el.className = t : this._el.removeAttribute("class"), o() && !this._devtoolsRendering && !Object.is(e, t) && d(this, "attr", {
|
|
561
|
-
name: "class",
|
|
562
|
-
previous: e,
|
|
563
|
-
next: t || void 0
|
|
564
|
-
}));
|
|
565
|
-
}
|
|
566
|
-
_serializeAttributes() {
|
|
567
|
-
let e = { ...this._attrs }, t = this._serializeStyles();
|
|
568
|
-
return t && (e.style = e.style ? `${e.style}; ${t}` : t), Object.entries(e).filter(([, e]) => e != null && e !== !1).map(([e, t]) => t === !0 || C(e) ? `${e}="${e}"` : `${e}="${S(t)}"`).join(" ");
|
|
569
|
-
}
|
|
570
|
-
_serializeStyles() {
|
|
571
|
-
return T(this._styles);
|
|
572
|
-
}
|
|
573
|
-
};
|
|
574
|
-
function F(e, t = P) {
|
|
575
|
-
return function(n = null, r = null, i = null) {
|
|
576
|
-
let a = M(n, r, i), o = new t(e, a.first);
|
|
577
|
-
return N(o, a.options), typeof a.callback == "function" && a.callback(o), o;
|
|
578
|
-
};
|
|
579
|
-
}
|
|
580
|
-
function I(e, t, n = {}) {
|
|
581
|
-
let { override: r = !1 } = n;
|
|
582
|
-
Object.entries(t).forEach(([t, n]) => {
|
|
583
|
-
!r && e.prototype[t] || (e.prototype[t] = function(...e) {
|
|
584
|
-
return this.child(n(...e));
|
|
585
|
-
});
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
//#endregion
|
|
589
|
-
//#region src/html/index.js
|
|
590
|
-
var L = class extends P {}, R = [
|
|
591
|
-
"a",
|
|
592
|
-
"abbr",
|
|
593
|
-
"address",
|
|
594
|
-
"area",
|
|
595
|
-
"article",
|
|
596
|
-
"aside",
|
|
597
|
-
"audio",
|
|
598
|
-
"b",
|
|
599
|
-
"base",
|
|
600
|
-
"bdi",
|
|
601
|
-
"bdo",
|
|
602
|
-
"blockquote",
|
|
603
|
-
"body",
|
|
604
|
-
"br",
|
|
605
|
-
"button",
|
|
606
|
-
"canvas",
|
|
607
|
-
"caption",
|
|
608
|
-
"cite",
|
|
609
|
-
"code",
|
|
610
|
-
"col",
|
|
611
|
-
"colgroup",
|
|
612
|
-
"data",
|
|
613
|
-
"datalist",
|
|
614
|
-
"dd",
|
|
615
|
-
"del",
|
|
616
|
-
"details",
|
|
617
|
-
"dfn",
|
|
618
|
-
"dialog",
|
|
619
|
-
"div",
|
|
620
|
-
"dl",
|
|
621
|
-
"dt",
|
|
622
|
-
"em",
|
|
623
|
-
"embed",
|
|
624
|
-
"fieldset",
|
|
625
|
-
"figcaption",
|
|
626
|
-
"figure",
|
|
627
|
-
"footer",
|
|
628
|
-
"form",
|
|
629
|
-
"h1",
|
|
630
|
-
"h2",
|
|
631
|
-
"h3",
|
|
632
|
-
"h4",
|
|
633
|
-
"h5",
|
|
634
|
-
"h6",
|
|
635
|
-
"head",
|
|
636
|
-
"header",
|
|
637
|
-
"hgroup",
|
|
638
|
-
"hr",
|
|
639
|
-
"html",
|
|
640
|
-
"i",
|
|
641
|
-
"iframe",
|
|
642
|
-
"img",
|
|
643
|
-
"input",
|
|
644
|
-
"ins",
|
|
645
|
-
"kbd",
|
|
646
|
-
"label",
|
|
647
|
-
"legend",
|
|
648
|
-
"li",
|
|
649
|
-
"link",
|
|
650
|
-
"main",
|
|
651
|
-
"map",
|
|
652
|
-
"mark",
|
|
653
|
-
"menu",
|
|
654
|
-
"meta",
|
|
655
|
-
"meter",
|
|
656
|
-
"nav",
|
|
657
|
-
"noscript",
|
|
658
|
-
"object",
|
|
659
|
-
"ol",
|
|
660
|
-
"optgroup",
|
|
661
|
-
"option",
|
|
662
|
-
"output",
|
|
663
|
-
"p",
|
|
664
|
-
"picture",
|
|
665
|
-
"pre",
|
|
666
|
-
"progress",
|
|
667
|
-
"q",
|
|
668
|
-
"rp",
|
|
669
|
-
"rt",
|
|
670
|
-
"ruby",
|
|
671
|
-
"s",
|
|
672
|
-
"samp",
|
|
673
|
-
"script",
|
|
674
|
-
"search",
|
|
675
|
-
"section",
|
|
676
|
-
"select",
|
|
677
|
-
"selectedcontent",
|
|
678
|
-
"slot",
|
|
679
|
-
"small",
|
|
680
|
-
"source",
|
|
681
|
-
"span",
|
|
682
|
-
"strong",
|
|
683
|
-
{
|
|
684
|
-
name: "style",
|
|
685
|
-
tagName: "style",
|
|
686
|
-
aliases: ["styleTag"]
|
|
687
|
-
},
|
|
688
|
-
"sub",
|
|
689
|
-
"summary",
|
|
690
|
-
"sup",
|
|
691
|
-
"table",
|
|
692
|
-
"tbody",
|
|
693
|
-
"td",
|
|
694
|
-
"template",
|
|
695
|
-
"textarea",
|
|
696
|
-
"tfoot",
|
|
697
|
-
"th",
|
|
698
|
-
"thead",
|
|
699
|
-
"time",
|
|
700
|
-
"title",
|
|
701
|
-
"tr",
|
|
702
|
-
"track",
|
|
703
|
-
"u",
|
|
704
|
-
"ul",
|
|
705
|
-
{
|
|
706
|
-
name: "varTag",
|
|
707
|
-
tagName: "var"
|
|
708
|
-
},
|
|
709
|
-
"video",
|
|
710
|
-
"wbr"
|
|
711
|
-
];
|
|
712
|
-
function z() {
|
|
713
|
-
return R.reduce((e, t) => {
|
|
714
|
-
let { aliases: n = [], name: r, tagName: i } = W(t), a = F(i, L);
|
|
715
|
-
return e[r] = a, n.forEach((t) => {
|
|
716
|
-
e[t] = a;
|
|
717
|
-
}), e;
|
|
718
|
-
}, {});
|
|
719
|
-
}
|
|
720
|
-
var B = z();
|
|
721
|
-
I(L, B);
|
|
722
|
-
var { a: ee, abbr: te, address: ne, area: re, article: ie, aside: ae, audio: oe, b: se, base: ce, bdi: le, bdo: ue, blockquote: de, body: V, br: H, button: fe, canvas: pe, caption: me, cite: he, code: ge, col: _e, colgroup: ve, data: ye, datalist: be, dd: xe, del: Se, details: Ce, dfn: we, dialog: Te, div: Ee, dl: De, dt: Oe, em: ke, embed: Ae, fieldset: je, figcaption: Me, figure: Ne, footer: Pe, form: Fe, h1: Ie, h2: Le, h3: Re, h4: ze, h5: Be, h6: Ve, head: He, header: Ue, hgroup: We, hr: Ge, html: Ke, i: qe, iframe: Je, img: Ye, input: Xe, ins: Ze, kbd: Qe, label: $e, legend: et, li: tt, link: nt, main: rt, map: it, mark: at, menu: ot, meta: st, meter: ct, nav: lt, noscript: ut, object: dt, ol: ft, optgroup: pt, option: mt, output: ht, p: gt, picture: _t, pre: vt, progress: yt, q: bt, rp: xt, rt: St, ruby: Ct, s: wt, samp: Tt, script: Et, search: Dt, section: Ot, select: kt, selectedcontent: At, slot: jt, small: Mt, source: Nt, span: Pt, strong: Ft, style: It, styleTag: Lt, sub: Rt, summary: zt, sup: Bt, table: Vt, tbody: Ht, td: Ut, template: Wt, textarea: Gt, tfoot: Kt, th: qt, thead: Jt, time: Yt, title: Xt, tr: U, track: Zt, u: Qt, ul: $t, varTag: en, video: tn, wbr: nn } = B;
|
|
723
|
-
function W(e) {
|
|
724
|
-
return typeof e == "string" ? {
|
|
725
|
-
name: e,
|
|
726
|
-
tagName: e
|
|
727
|
-
} : e;
|
|
728
|
-
}
|
|
729
|
-
//#endregion
|
|
730
|
-
//#region src/core/document-events.js
|
|
731
|
-
function G(e, t, n = void 0) {
|
|
732
|
-
return typeof window > "u" ? () => {} : (window.addEventListener(e, t, n), () => {
|
|
733
|
-
window.removeEventListener(e, t, n);
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
//#endregion
|
|
737
|
-
//#region src/components/shared.js
|
|
738
|
-
var K = "yoya-component";
|
|
739
|
-
function q(e = null, t = null, n = null) {
|
|
740
|
-
return M(e, t, n);
|
|
741
|
-
}
|
|
742
|
-
function J(e, t) {
|
|
743
|
-
return typeof e.attr == "function" || typeof e.styles == "function" ? N(e, t) : (typeof e.render == "function" && N(e.render(), t), e);
|
|
744
|
-
}
|
|
745
|
-
function Y(e, t = null, n = null) {
|
|
746
|
-
return J(e, t), typeof n == "function" && n(e), e;
|
|
747
|
-
}
|
|
748
|
-
function X(e, t = null, n = null, r = null) {
|
|
749
|
-
let { first: i, options: a, callback: o } = q(t, n, r);
|
|
750
|
-
return Y(i instanceof e ? i : new e(i), a, o);
|
|
751
|
-
}
|
|
752
|
-
function Z(e) {
|
|
753
|
-
if (Object.prototype.toString.call(e) !== "[object Object]") return !1;
|
|
754
|
-
let t = Object.getPrototypeOf(e);
|
|
755
|
-
return t === Object.prototype || t === null;
|
|
756
|
-
}
|
|
757
|
-
//#endregion
|
|
1
|
+
import { Mi as registerChildFactories, Tt as HtmlElementNode, g as createComponentFactory, h as componentClass, v as isPlainObject, vi as bindWindowEvent } from "./yoya.core.chunk.js";
|
|
2
|
+
|
|
758
3
|
//#region src/chart/echart.js
|
|
759
|
-
var
|
|
760
|
-
constructor(
|
|
761
|
-
super("div", null)
|
|
4
|
+
var VEchart = class extends HtmlElementNode {
|
|
5
|
+
constructor(setup = null) {
|
|
6
|
+
super("div", null);
|
|
7
|
+
this._autoResize = true;
|
|
8
|
+
this._chartInstance = null;
|
|
9
|
+
this._devicePixelRatio = null;
|
|
10
|
+
this._echartsLib = null;
|
|
11
|
+
this._height = "400px";
|
|
12
|
+
this._loading = false;
|
|
13
|
+
this._loadingText = "加载中...";
|
|
14
|
+
this._onReadyCallbacks = [];
|
|
15
|
+
this._onResizeCallbacks = [];
|
|
16
|
+
this._option = null;
|
|
17
|
+
this._renderer = "canvas";
|
|
18
|
+
this._resizeObserver = null;
|
|
19
|
+
this._theme = null;
|
|
20
|
+
this._width = "100%";
|
|
21
|
+
this.className(componentClass, "yoya-vechart");
|
|
22
|
+
this.styles({
|
|
762
23
|
height: this._height,
|
|
763
24
|
overflow: "hidden",
|
|
764
25
|
position: "relative",
|
|
765
26
|
width: this._width
|
|
766
|
-
})
|
|
27
|
+
});
|
|
28
|
+
this._setupEchart(setup);
|
|
767
29
|
}
|
|
768
|
-
echartsLib(
|
|
769
|
-
|
|
30
|
+
echartsLib(lib) {
|
|
31
|
+
if (lib) this._echartsLib = lib;
|
|
32
|
+
else if (typeof window !== "undefined" && window.echarts) this._echartsLib = window.echarts;
|
|
33
|
+
return this;
|
|
770
34
|
}
|
|
771
|
-
option(
|
|
772
|
-
|
|
35
|
+
option(value) {
|
|
36
|
+
if (value === void 0) return this._option;
|
|
37
|
+
this._option = value || null;
|
|
38
|
+
if (this._chartInstance && this._echartsLib) this._chartInstance.setOption(this._option, true);
|
|
39
|
+
return this;
|
|
773
40
|
}
|
|
774
|
-
width(
|
|
775
|
-
|
|
41
|
+
width(value) {
|
|
42
|
+
if (value === void 0) return this._width;
|
|
43
|
+
this._width = value;
|
|
44
|
+
this.style("width", value);
|
|
45
|
+
return this;
|
|
776
46
|
}
|
|
777
|
-
height(
|
|
778
|
-
|
|
47
|
+
height(value) {
|
|
48
|
+
if (value === void 0) return this._height;
|
|
49
|
+
this._height = value;
|
|
50
|
+
this.style("height", value);
|
|
51
|
+
return this;
|
|
779
52
|
}
|
|
780
|
-
theme(
|
|
781
|
-
|
|
53
|
+
theme(value) {
|
|
54
|
+
if (value === void 0) return this._theme;
|
|
55
|
+
this._theme = value;
|
|
56
|
+
return this;
|
|
782
57
|
}
|
|
783
|
-
renderer(
|
|
784
|
-
|
|
58
|
+
renderer(value) {
|
|
59
|
+
if (value === void 0) return this._renderer;
|
|
60
|
+
this._renderer = value === "svg" ? "svg" : "canvas";
|
|
61
|
+
return this;
|
|
785
62
|
}
|
|
786
|
-
devicePixelRatio(
|
|
787
|
-
|
|
63
|
+
devicePixelRatio(value) {
|
|
64
|
+
if (value === void 0) return this._devicePixelRatio;
|
|
65
|
+
this._devicePixelRatio = value;
|
|
66
|
+
return this;
|
|
788
67
|
}
|
|
789
|
-
autoResize(
|
|
790
|
-
|
|
68
|
+
autoResize(value) {
|
|
69
|
+
if (value === void 0) return this._autoResize;
|
|
70
|
+
this._autoResize = Boolean(value);
|
|
71
|
+
return this;
|
|
791
72
|
}
|
|
792
|
-
loading(
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
73
|
+
loading(value, text = "加载中...") {
|
|
74
|
+
this._loading = Boolean(value);
|
|
75
|
+
this._loadingText = text;
|
|
76
|
+
if (this._chartInstance) {
|
|
77
|
+
if (this._loading) this._chartInstance.showLoading({
|
|
78
|
+
color: "var(--yoya-color-primary, #2563eb)",
|
|
79
|
+
lineWidth: 2,
|
|
80
|
+
maskColor: "rgba(255, 255, 255, 0.8)",
|
|
81
|
+
text,
|
|
82
|
+
textColor: "var(--yoya-color-text, #172033)"
|
|
83
|
+
});
|
|
84
|
+
else this._chartInstance.hideLoading();
|
|
85
|
+
}
|
|
86
|
+
return this;
|
|
800
87
|
}
|
|
801
|
-
onChartReady(
|
|
802
|
-
|
|
88
|
+
onChartReady(callback) {
|
|
89
|
+
if (typeof callback === "function") {
|
|
90
|
+
if (this._chartInstance) callback(this._chartInstance);
|
|
91
|
+
else this._onReadyCallbacks.push(callback);
|
|
92
|
+
}
|
|
93
|
+
return this;
|
|
803
94
|
}
|
|
804
|
-
onChartResize(
|
|
805
|
-
|
|
95
|
+
onChartResize(callback) {
|
|
96
|
+
if (typeof callback === "function") this._onResizeCallbacks.push(callback);
|
|
97
|
+
return this;
|
|
806
98
|
}
|
|
807
99
|
getChartInstance() {
|
|
808
100
|
return this._chartInstance;
|
|
809
101
|
}
|
|
810
|
-
resize(
|
|
811
|
-
|
|
102
|
+
resize(opts = {}) {
|
|
103
|
+
if (this._chartInstance) this._chartInstance.resize(opts);
|
|
104
|
+
return this;
|
|
812
105
|
}
|
|
813
106
|
clear() {
|
|
814
|
-
|
|
107
|
+
if (this._chartInstance) this._chartInstance.clear();
|
|
108
|
+
return this;
|
|
815
109
|
}
|
|
816
110
|
dispose() {
|
|
817
|
-
|
|
111
|
+
this._disposeChart();
|
|
112
|
+
return this;
|
|
818
113
|
}
|
|
819
114
|
destroy() {
|
|
820
|
-
|
|
115
|
+
this._disposeChart();
|
|
116
|
+
return super.destroy();
|
|
821
117
|
}
|
|
822
118
|
renderDom() {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
if (Z(e)) {
|
|
833
|
-
let { autoResize: t, devicePixelRatio: n, echartsLib: r, height: i, loading: a, loadingText: o, onChartReady: s, onChartResize: c, option: l, renderer: u, theme: d, width: f, ...p } = e;
|
|
834
|
-
Object.keys(p).length > 0 && this.setup(p), r !== void 0 && this.echartsLib(r), f !== void 0 && this.width(f), i !== void 0 && this.height(i), d !== void 0 && this.theme(d), u !== void 0 && this.renderer(u), n !== void 0 && this.devicePixelRatio(n), t !== void 0 && this.autoResize(t), o !== void 0 && (this._loadingText = o), s !== void 0 && this.onChartReady(s), c !== void 0 && this.onChartResize(c), l !== void 0 && this.option(l), a !== void 0 && this.loading(a, this._loadingText);
|
|
835
|
-
return;
|
|
836
|
-
}
|
|
837
|
-
this.child(e);
|
|
119
|
+
const element = super.renderDom();
|
|
120
|
+
if (element && !this._chartInstance) requestAnimationFrame(() => this._initChart());
|
|
121
|
+
return element;
|
|
122
|
+
}
|
|
123
|
+
_setupEchart(setup) {
|
|
124
|
+
if (setup === null || setup === void 0) return;
|
|
125
|
+
if (typeof setup === "function") {
|
|
126
|
+
setup(this);
|
|
127
|
+
return;
|
|
838
128
|
}
|
|
129
|
+
if (isPlainObject(setup)) {
|
|
130
|
+
const { autoResize, devicePixelRatio, echartsLib, height, loading, loadingText, onChartReady, onChartResize, option, renderer, theme, width, ...elementConfig } = setup;
|
|
131
|
+
if (Object.keys(elementConfig).length > 0) this.setup(elementConfig);
|
|
132
|
+
if (echartsLib !== void 0) this.echartsLib(echartsLib);
|
|
133
|
+
if (width !== void 0) this.width(width);
|
|
134
|
+
if (height !== void 0) this.height(height);
|
|
135
|
+
if (theme !== void 0) this.theme(theme);
|
|
136
|
+
if (renderer !== void 0) this.renderer(renderer);
|
|
137
|
+
if (devicePixelRatio !== void 0) this.devicePixelRatio(devicePixelRatio);
|
|
138
|
+
if (autoResize !== void 0) this.autoResize(autoResize);
|
|
139
|
+
if (loadingText !== void 0) this._loadingText = loadingText;
|
|
140
|
+
if (onChartReady !== void 0) this.onChartReady(onChartReady);
|
|
141
|
+
if (onChartResize !== void 0) this.onChartResize(onChartResize);
|
|
142
|
+
if (option !== void 0) this.option(option);
|
|
143
|
+
if (loading !== void 0) this.loading(loading, this._loadingText);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.child(setup);
|
|
839
147
|
}
|
|
840
148
|
_initChart() {
|
|
841
|
-
if (
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
149
|
+
if (this._deleted) return;
|
|
150
|
+
if (!this._echartsLib) this.echartsLib();
|
|
151
|
+
if (!this._echartsLib) {
|
|
152
|
+
console.warn("[VEchart] ECharts library not provided. Call echartsLib() first.");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (this._chartInstance || !this._el) return;
|
|
156
|
+
try {
|
|
157
|
+
this._chartInstance = this._echartsLib.init(this._el, this._theme, {
|
|
158
|
+
devicePixelRatio: this._devicePixelRatio,
|
|
159
|
+
renderer: this._renderer
|
|
160
|
+
});
|
|
161
|
+
if (this._option) this._chartInstance.setOption(this._option, true);
|
|
162
|
+
if (this._loading) this.loading(true, this._loadingText);
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
if (this._chartInstance && !this._chartInstance.isDisposed()) this._chartInstance.resize();
|
|
165
|
+
}, 100);
|
|
166
|
+
this._executeReadyCallbacks();
|
|
167
|
+
if (this._autoResize) this._initResizeObserver();
|
|
168
|
+
} catch (error) {
|
|
169
|
+
console.error("[VEchart] Failed to initialize chart:", error);
|
|
856
170
|
}
|
|
857
171
|
}
|
|
858
172
|
_executeReadyCallbacks() {
|
|
859
|
-
|
|
173
|
+
if (!this._chartInstance) return;
|
|
174
|
+
this._onReadyCallbacks.forEach((callback) => {
|
|
860
175
|
try {
|
|
861
|
-
|
|
862
|
-
} catch (
|
|
863
|
-
console.error("[VEchart] Error in onChartReady callback:",
|
|
176
|
+
callback(this._chartInstance);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.error("[VEchart] Error in onChartReady callback:", error);
|
|
864
179
|
}
|
|
865
|
-
})
|
|
180
|
+
});
|
|
181
|
+
this._onReadyCallbacks = [];
|
|
866
182
|
}
|
|
867
183
|
_initResizeObserver() {
|
|
868
|
-
if (typeof ResizeObserver
|
|
869
|
-
this._resizeObserver = new ResizeObserver((
|
|
870
|
-
for (
|
|
871
|
-
|
|
872
|
-
this._handleResize(
|
|
184
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
185
|
+
this._resizeObserver = new ResizeObserver((entries) => {
|
|
186
|
+
for (const entry of entries) {
|
|
187
|
+
const { height, width } = entry.contentRect;
|
|
188
|
+
this._handleResize(width, height);
|
|
873
189
|
}
|
|
874
|
-
})
|
|
190
|
+
});
|
|
191
|
+
if (this._el) this._resizeObserver.observe(this._el);
|
|
875
192
|
return;
|
|
876
193
|
}
|
|
877
|
-
this._resizeHandler = () => this._handleResize()
|
|
194
|
+
this._resizeHandler = () => this._handleResize();
|
|
195
|
+
this._resizeUnbind = bindWindowEvent("resize", this._resizeHandler);
|
|
878
196
|
}
|
|
879
|
-
_handleResize(
|
|
880
|
-
|
|
197
|
+
_handleResize(width, height) {
|
|
198
|
+
if (!this._chartInstance) return;
|
|
199
|
+
this._chartInstance.resize();
|
|
200
|
+
this._onResizeCallbacks.forEach((callback) => {
|
|
881
201
|
try {
|
|
882
|
-
|
|
883
|
-
height
|
|
884
|
-
width
|
|
202
|
+
callback({
|
|
203
|
+
height,
|
|
204
|
+
width
|
|
885
205
|
});
|
|
886
|
-
} catch (
|
|
887
|
-
console.error("[VEchart] Error in onChartResize callback:",
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.error("[VEchart] Error in onChartResize callback:", error);
|
|
888
208
|
}
|
|
889
|
-
})
|
|
209
|
+
});
|
|
890
210
|
}
|
|
891
211
|
_disposeChart() {
|
|
892
|
-
|
|
212
|
+
if (this._resizeObserver) {
|
|
213
|
+
this._resizeObserver.disconnect();
|
|
214
|
+
this._resizeObserver = null;
|
|
215
|
+
}
|
|
216
|
+
if (this._resizeHandler) {
|
|
217
|
+
this._resizeUnbind?.();
|
|
218
|
+
this._resizeHandler = null;
|
|
219
|
+
this._resizeUnbind = null;
|
|
220
|
+
}
|
|
221
|
+
if (this._chartInstance) {
|
|
222
|
+
this._chartInstance.dispose();
|
|
223
|
+
this._chartInstance = null;
|
|
224
|
+
}
|
|
893
225
|
}
|
|
894
226
|
};
|
|
895
|
-
function
|
|
896
|
-
return
|
|
227
|
+
function vEchart(first = null, second = null, third = null) {
|
|
228
|
+
return createComponentFactory(VEchart, first, second, third);
|
|
897
229
|
}
|
|
898
|
-
|
|
230
|
+
registerChildFactories(HtmlElementNode, { vEchart });
|
|
231
|
+
|
|
899
232
|
//#endregion
|
|
900
|
-
export {
|
|
233
|
+
export { VEchart, vEchart };
|