@yoyaflow/yoya-ui 0.3.2 → 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.
Files changed (42) hide show
  1. package/README.md +407 -124
  2. package/README.zh-CN.md +375 -131
  3. package/dist/yoya.core.chunk.js +4275 -0
  4. package/dist/yoya.core.chunk.min.js +9 -0
  5. package/dist/yoya.core.js +3 -1779
  6. package/dist/yoya.core.min.js +1 -0
  7. package/dist/yoya.devtools.js +3 -0
  8. package/dist/yoya.devtools.min.js +1 -0
  9. package/dist/yoya.echart.js +182 -592
  10. package/dist/yoya.echart.min.js +1 -0
  11. package/dist/yoya.router.full.js +5271 -0
  12. package/dist/yoya.router.full.min.js +43 -0
  13. package/dist/yoya.router.js +1330 -0
  14. package/dist/yoya.router.min.js +35 -0
  15. package/dist/yoya.three.js +360 -0
  16. package/dist/yoya.three.min.js +1 -0
  17. package/dist/yoya.ui-router.full.js +21843 -0
  18. package/dist/yoya.ui-router.full.min.js +43 -0
  19. package/dist/yoya.ui-router.umd.js +43 -0
  20. package/dist/yoya.ui-router.umd.min.js +43 -0
  21. package/dist/yoya.ui.css +80 -0
  22. package/dist/yoya.ui.full.js +20169 -0
  23. package/dist/yoya.ui.full.min.js +1 -0
  24. package/dist/yoya.ui.js +12227 -9083
  25. package/dist/yoya.ui.min.js +1 -0
  26. package/package.json +27 -11
  27. package/types/core.d.ts +122 -1
  28. package/types/data-display.d.ts +44 -2
  29. package/types/devtools.d.ts +156 -0
  30. package/types/feedback.d.ts +13 -0
  31. package/types/form.d.ts +1 -1
  32. package/types/index.d.ts +1 -1
  33. package/types/ssr.d.ts +27 -7
  34. package/types/three.d.ts +77 -0
  35. package/types/yoya.devtools.d.ts +5 -0
  36. package/types/yoya.router.d.ts +7 -0
  37. package/types/yoya.three.d.ts +4 -0
  38. package/types/yoya.ui-router.d.ts +19 -0
  39. package/types/yoya.ui.d.ts +2 -7
  40. package/dist/yoya-ui.umd.js +0 -35
  41. package/dist/yoya.ssr.js +0 -2856
  42. package/types/yoya.ssr.d.ts +0 -9
@@ -1,643 +1,233 @@
1
- //#region src/core/node.js
2
- var e = /* @__PURE__ */ new Set([
3
- "checked",
4
- "disabled",
5
- "readonly",
6
- "selected"
7
- ]), t = /* @__PURE__ */ new Set([
8
- "area",
9
- "base",
10
- "br",
11
- "col",
12
- "embed",
13
- "hr",
14
- "img",
15
- "input",
16
- "link",
17
- "meta",
18
- "param",
19
- "source",
20
- "track",
21
- "wbr"
22
- ]);
23
- function n(e) {
24
- return typeof e == "string" ? document.querySelector(e) : e;
25
- }
26
- function r(e) {
27
- return String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
28
- }
29
- function i(t) {
30
- return e.has(t);
31
- }
32
- function a(e, t, n) {
33
- if (n == null || n === !1) {
34
- if (e.removeAttribute(t), t in e) try {
35
- e[t] = !1;
36
- } catch {}
37
- return;
38
- }
39
- if (n === !0 || i(t)) {
40
- if (e.setAttribute(t, t), t in e) try {
41
- e[t] = !0;
42
- } catch {}
43
- return;
44
- }
45
- if (e.setAttribute(t, String(n)), t in e) try {
46
- e[t] = n;
47
- } catch {}
48
- }
49
- function o(e) {
50
- return Object.entries(e).filter(([, e]) => e != null && e !== "").map(([e, t]) => `${s(e)}:${r(t)}`).join("; ");
51
- }
52
- function s(e) {
53
- return String(e).replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
54
- }
55
- var c = class e {
56
- constructor(e = null) {
57
- this._children = [], this._events = /* @__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, e !== null && this.setup(e);
58
- }
59
- setup(t) {
60
- 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;
61
- }
62
- _setupObject(e) {
63
- e.children && this.child(e.children);
64
- }
65
- children() {
66
- return [...this._children];
67
- }
68
- clearChildren() {
69
- return this._children.forEach((e) => {
70
- this._pendingRemovals.add(e);
71
- }), this._children = [], this._childrenDirty = !0, this;
72
- }
73
- child(...e) {
74
- return e.flat(Infinity).forEach((e) => {
75
- if (e == null) return;
76
- let t = d(e);
77
- this._pendingRemovals.delete(t), this._children.push(t), this._childrenDirty = !0;
78
- }), this;
79
- }
80
- text(e) {
81
- return this.child(new l(e));
82
- }
83
- on(e, t, n) {
84
- return this._events.has(e) || this._events.set(e, []), this._events.get(e).push({
85
- handler: t,
86
- options: n
87
- }), this._el && (this._el.addEventListener(e, t, n), this._cleanup.push(() => this._el.removeEventListener(e, t, n))), this;
88
- }
89
- registerStateAttrs(...e) {
90
- return e.forEach((e) => {
91
- if (typeof e == "string") {
92
- this._stateTypes[e] = "boolean";
93
- return;
94
- }
95
- e && typeof e == "object" && Object.entries(e).forEach(([e, t]) => {
96
- this._stateTypes[e] = t || "boolean";
97
- });
98
- }), this;
99
- }
100
- registerStateHandler(e, t) {
101
- return this._stateHandlers.has(e) || this._stateHandlers.set(e, []), this._stateHandlers.get(e).push(t), this;
102
- }
103
- setState(e, t = !0) {
104
- let n = this._states[e];
105
- return this._states[e] = t, (this._stateHandlers.get(e) || []).forEach((e) => e(t, this, n)), this;
106
- }
107
- getState(e) {
108
- return this._states[e];
109
- }
110
- getBooleanState(e) {
111
- return !!this.getState(e);
112
- }
113
- getStringState(e) {
114
- let t = this.getState(e);
115
- return t == null ? "" : String(t);
116
- }
117
- getNumberState(e) {
118
- return Number(this.getState(e) || 0);
119
- }
120
- renderDom() {
121
- return null;
122
- }
123
- commit() {
124
- return this.renderDom();
125
- }
126
- _commitChildren() {
127
- this._pendingRemovals.forEach((e) => e.destroy()), this._pendingRemovals.clear(), this._childrenDirty = !1;
128
- }
129
- bindTo(e) {
130
- let t = n(e), r = this.renderDom();
131
- return t && r && t.appendChild(r), this;
132
- }
133
- destroy() {
134
- return 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._el?.parentNode && this._el.parentNode.removeChild(this._el), this;
135
- }
136
- toHTML() {
137
- return "";
138
- }
139
- hydrateSnapshot() {
140
- return this;
141
- }
142
- }, l = class extends c {
143
- constructor(e = "") {
144
- super(null), this._content = String(e), this._textNode = null;
145
- }
146
- textContent(e) {
147
- return e === void 0 ? this._content : (this._content = String(e), this._textNode && (this._textNode.textContent = this._content), this);
148
- }
149
- renderDom() {
150
- return this._deleted ? null : (this._textNode || (this._textNode = document.createTextNode(this._content), this._el = this._textNode), this._textNode);
151
- }
152
- toHTML() {
153
- return this._deleted ? "" : r(this._content);
154
- }
155
- }, u = class extends c {
156
- constructor(e) {
157
- super(null), this._component = e, this._resolved = null;
158
- }
159
- _resolve() {
160
- if (this._resolved) return this._resolved;
161
- let e = typeof this._component == "function" ? this._component() : this._component.render();
162
- if (!(e instanceof c)) throw TypeError("Component render must return a ViewNode");
163
- return this._resolved = e, e;
164
- }
165
- children() {
166
- return this._resolved ? this._resolved.children() : [];
167
- }
168
- textContent() {
169
- let e = this._resolve();
170
- return typeof e.textContent == "function" ? e.textContent() : "";
171
- }
172
- renderDom() {
173
- if (this._deleted) return null;
174
- let e = this._resolve().renderDom();
175
- return this._el = e, e;
176
- }
177
- toHTML() {
178
- return this._deleted ? "" : this._resolve().toHTML();
179
- }
180
- destroy() {
181
- return this._resolved && this._resolved.destroy(), super.destroy();
182
- }
183
- };
184
- function d(e) {
185
- if (e instanceof c) return e;
186
- if (typeof e == "function" || e && typeof e == "object" && typeof e.render == "function") return new u(e);
187
- if (typeof e == "string" || typeof e == "number") return new l(e);
188
- throw TypeError("ViewNode child must be a ViewNode, component, string, or number");
189
- }
190
- function f(e = null, t = null, n = null) {
191
- return typeof t == "function" && n == null ? {
192
- first: e,
193
- options: null,
194
- callback: t
195
- } : {
196
- first: e,
197
- options: t,
198
- callback: n
199
- };
200
- }
201
- function p(e, t) {
202
- 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);
203
- }
204
- var m = class extends c {
205
- constructor(e, t = null) {
206
- super(null), this._tagName = e, this._attrs = {}, this._styles = {}, this._classes = /* @__PURE__ */ new Set(), this._el = null, t !== null && this.setup(t);
207
- }
208
- _setupObject(e) {
209
- Object.entries(e).forEach(([e, t]) => {
210
- if (e === "class" || e === "className") {
211
- this.className(t);
212
- return;
213
- }
214
- if (e === "attrs") {
215
- this.attr(t);
216
- return;
217
- }
218
- if (e === "style") {
219
- this.styles(t);
220
- return;
221
- }
222
- if (e === "children") {
223
- this.child(t);
224
- return;
225
- }
226
- if (e.startsWith("on") && typeof t == "function") {
227
- this.on(e.slice(2).toLowerCase(), t);
228
- return;
229
- }
230
- if (typeof this[e] == "function") {
231
- this[e](t);
232
- return;
233
- }
234
- typeof t != "function" && this.attr(e, t);
235
- });
236
- }
237
- tagName() {
238
- return this._tagName;
239
- }
240
- textContent() {
241
- return this._children.map((e) => typeof e.textContent == "function" ? e.textContent() : "").join("");
242
- }
243
- attr(e, t) {
244
- return t === void 0 && typeof e == "string" ? this._attrs[e] : e && typeof e == "object" ? (Object.entries(e).forEach(([e, t]) => this.attr(e, t)), this) : (t == null || t === !1 ? delete this._attrs[e] : this._attrs[e] = t, this._el && a(this._el, e, t), this);
245
- }
246
- id(e) {
247
- return e === void 0 ? this.attr("id") : this.attr("id", e);
248
- }
249
- name(e) {
250
- return e === void 0 ? this.attr("name") : this.attr("name", e);
251
- }
252
- className(...e) {
253
- return e.length === 0 ? [...this._classes].join(" ") : (e.flat(Infinity).forEach((e) => {
254
- e && String(e).split(/\s+/).filter(Boolean).forEach((e) => this._classes.add(e));
255
- }), this._syncClassName(), this);
256
- }
257
- class(...e) {
258
- return this.className(...e);
259
- }
260
- replaceClassName(e, t, n = !1) {
261
- return !e || !t || e === t ? this : this._classes.has(e) ? (this._classes.delete(e), this.className(t)) : n ? this.className(t) : this;
262
- }
263
- style(e, t) {
264
- return t === void 0 && typeof e == "string" ? this._styles[e] : e && typeof e == "object" ? this.styles(e) : (t == null || t === "" ? delete this._styles[e] : this._styles[e] = t, this._el && (this._el.style[e] = t || ""), this);
265
- }
266
- styles(e) {
267
- return Object.entries(e || {}).forEach(([e, t]) => this.style(e, t)), this;
268
- }
269
- child(...e) {
270
- return e.flat(Infinity).forEach((e) => {
271
- if (e == null) return;
272
- let t = d(e);
273
- if (this._pendingRemovals.delete(t), this._children.push(t), this._childrenDirty = !0, this._el) {
274
- let e = t.renderDom();
275
- e && e.parentNode !== this._el && this._el.appendChild(e);
276
- }
277
- }), this;
278
- }
279
- renderDom() {
280
- return this._deleted ? null : (this._el || (this._el = document.createElement(this._tagName), this._applySnapshotToElement()), this._commitChildren(), this._children.forEach((e) => {
281
- let t = e.renderDom();
282
- t && t.parentNode !== this._el && this._el.appendChild(t);
283
- }), this._el);
284
- }
285
- toHTML() {
286
- if (this._deleted) return "";
287
- let e = this._serializeAttributes(), n = e ? `<${this._tagName} ${e}>` : `<${this._tagName}>`;
288
- return t.has(this._tagName) ? n : `${n}${this._children.map((e) => e.toHTML()).join("")}</${this._tagName}>`;
289
- }
290
- _applyBindingsToElement() {
291
- Object.entries(this._attrs).forEach(([e, t]) => a(this._el, e, t)), this._syncClassName(), Object.entries(this._styles).forEach(([e, t]) => {
292
- this._el.style[e] = t;
293
- }), this._events.forEach((e, t) => {
294
- e.forEach(({ handler: e, options: n }) => {
295
- this._el.addEventListener(t, e, n), this._cleanup.push(() => this._el.removeEventListener(t, e, n));
296
- });
297
- });
298
- }
299
- _applySnapshotToElement() {
300
- this._applyBindingsToElement(), this._children.forEach((e) => {
301
- let t = e.renderDom();
302
- t && this._el.appendChild(t);
303
- });
304
- }
305
- _syncClassName() {
306
- let e = [...this._classes].join(" ");
307
- e ? this._attrs.class = e : delete this._attrs.class, this._el && (e ? this._el.className = e : this._el.removeAttribute("class"));
308
- }
309
- _serializeAttributes() {
310
- let e = { ...this._attrs }, t = this._serializeStyles();
311
- return t && (e.style = e.style ? `${e.style}; ${t}` : t), Object.entries(e).filter(([, e]) => e != null && e !== !1).map(([e, t]) => t === !0 || i(e) ? `${e}="${e}"` : `${e}="${r(t)}"`).join(" ");
312
- }
313
- _serializeStyles() {
314
- return o(this._styles);
315
- }
316
- };
317
- function h(e, t = m) {
318
- return function(n = null, r = null, i = null) {
319
- let a = f(n, r, i), o = new t(e, a.first);
320
- return p(o, a.options), typeof a.callback == "function" && a.callback(o), o;
321
- };
322
- }
323
- function g(e, t, n = {}) {
324
- let { override: r = !1 } = n;
325
- Object.entries(t).forEach(([t, n]) => {
326
- !r && e.prototype[t] || (e.prototype[t] = function(...e) {
327
- return this.child(n(...e));
328
- });
329
- });
330
- }
331
- //#endregion
332
- //#region src/html/index.js
333
- var _ = class extends m {}, v = [
334
- "a",
335
- "abbr",
336
- "address",
337
- "area",
338
- "article",
339
- "aside",
340
- "audio",
341
- "b",
342
- "base",
343
- "bdi",
344
- "bdo",
345
- "blockquote",
346
- "body",
347
- "br",
348
- "button",
349
- "canvas",
350
- "caption",
351
- "cite",
352
- "code",
353
- "col",
354
- "colgroup",
355
- "data",
356
- "datalist",
357
- "dd",
358
- "del",
359
- "details",
360
- "dfn",
361
- "dialog",
362
- "div",
363
- "dl",
364
- "dt",
365
- "em",
366
- "embed",
367
- "fieldset",
368
- "figcaption",
369
- "figure",
370
- "footer",
371
- "form",
372
- "h1",
373
- "h2",
374
- "h3",
375
- "h4",
376
- "h5",
377
- "h6",
378
- "head",
379
- "header",
380
- "hgroup",
381
- "hr",
382
- "html",
383
- "i",
384
- "iframe",
385
- "img",
386
- "input",
387
- "ins",
388
- "kbd",
389
- "label",
390
- "legend",
391
- "li",
392
- "link",
393
- "main",
394
- "map",
395
- "mark",
396
- "menu",
397
- "meta",
398
- "meter",
399
- "nav",
400
- "noscript",
401
- "object",
402
- "ol",
403
- "optgroup",
404
- "option",
405
- "output",
406
- "p",
407
- "picture",
408
- "pre",
409
- "progress",
410
- "q",
411
- "rp",
412
- "rt",
413
- "ruby",
414
- "s",
415
- "samp",
416
- "script",
417
- "search",
418
- "section",
419
- "select",
420
- "selectedcontent",
421
- "slot",
422
- "small",
423
- "source",
424
- "span",
425
- "strong",
426
- {
427
- name: "style",
428
- tagName: "style",
429
- aliases: ["styleTag"]
430
- },
431
- "sub",
432
- "summary",
433
- "sup",
434
- "table",
435
- "tbody",
436
- "td",
437
- "template",
438
- "textarea",
439
- "tfoot",
440
- "th",
441
- "thead",
442
- "time",
443
- "title",
444
- "tr",
445
- "track",
446
- "u",
447
- "ul",
448
- {
449
- name: "varTag",
450
- tagName: "var"
451
- },
452
- "video",
453
- "wbr"
454
- ];
455
- function y() {
456
- return v.reduce((e, t) => {
457
- let { aliases: n = [], name: r, tagName: i } = W(t), a = h(i, _);
458
- return e[r] = a, n.forEach((t) => {
459
- e[t] = a;
460
- }), e;
461
- }, {});
462
- }
463
- var b = y();
464
- g(_, b);
465
- 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: x, br: S, button: C, canvas: w, caption: T, cite: E, code: D, col: O, colgroup: k, data: A, datalist: j, dd: M, del: N, details: P, dfn: F, dialog: I, div: L, dl: R, dt: z, em: B, embed: V, fieldset: H, figcaption: fe, figure: pe, footer: me, form: he, h1: ge, h2: _e, h3: ve, h4: ye, h5: be, h6: xe, head: Se, header: Ce, hgroup: we, hr: Te, html: Ee, i: De, iframe: Oe, img: ke, input: Ae, ins: je, kbd: Me, label: Ne, legend: Pe, li: Fe, link: Ie, main: Le, map: Re, mark: ze, menu: Be, meta: Ve, meter: He, nav: Ue, noscript: We, object: Ge, ol: Ke, optgroup: qe, option: Je, output: Ye, p: Xe, picture: Ze, pre: Qe, progress: $e, q: et, rp: tt, rt: nt, ruby: rt, s: it, samp: at, script: ot, search: st, section: ct, select: lt, selectedcontent: ut, slot: dt, small: ft, source: pt, span: mt, strong: ht, style: gt, styleTag: _t, sub: vt, summary: yt, sup: bt, table: xt, tbody: St, td: Ct, template: wt, textarea: Tt, tfoot: Et, th: Dt, thead: Ot, time: kt, title: At, tr: jt, track: Mt, u: Nt, ul: Pt, varTag: Ft, video: It, wbr: U } = b;
466
- function W(e) {
467
- return typeof e == "string" ? {
468
- name: e,
469
- tagName: e
470
- } : e;
471
- }
472
- //#endregion
473
- //#region src/core/document-events.js
474
- function G(e, t, n = void 0) {
475
- return typeof window > "u" ? () => {} : (window.addEventListener(e, t, n), () => {
476
- window.removeEventListener(e, t, n);
477
- });
478
- }
479
- //#endregion
480
- //#region src/components/shared.js
481
- var K = "yoya-component";
482
- function q(e = null, t = null, n = null) {
483
- return f(e, t, n);
484
- }
485
- function J(e, t) {
486
- return typeof e.attr == "function" || typeof e.styles == "function" ? p(e, t) : (typeof e.render == "function" && p(e.render(), t), e);
487
- }
488
- function Y(e, t = null, n = null) {
489
- return J(e, t), typeof n == "function" && n(e), e;
490
- }
491
- function X(e, t = null, n = null, r = null) {
492
- let { first: i, options: a, callback: o } = q(t, n, r);
493
- return Y(i instanceof e ? i : new e(i), a, o);
494
- }
495
- function Z(e) {
496
- if (Object.prototype.toString.call(e) !== "[object Object]") return !1;
497
- let t = Object.getPrototypeOf(e);
498
- return t === Object.prototype || t === null;
499
- }
500
- //#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
+
501
3
  //#region src/chart/echart.js
502
- var Q = class extends _ {
503
- constructor(e = null) {
504
- super("div", null), this._autoResize = !0, this._chartInstance = null, this._devicePixelRatio = null, this._echartsLib = null, this._height = "400px", this._loading = !1, this._loadingText = "加载中...", this._onReadyCallbacks = [], this._onResizeCallbacks = [], this._option = null, this._renderer = "canvas", this._resizeObserver = null, this._theme = null, this._width = "100%", this.className(K, "yoya-vechart"), this.styles({
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({
505
23
  height: this._height,
506
24
  overflow: "hidden",
507
25
  position: "relative",
508
26
  width: this._width
509
- }), this._setupEchart(e);
27
+ });
28
+ this._setupEchart(setup);
510
29
  }
511
- echartsLib(e) {
512
- return e ? this._echartsLib = e : typeof window < "u" && window.echarts && (this._echartsLib = window.echarts), this;
30
+ echartsLib(lib) {
31
+ if (lib) this._echartsLib = lib;
32
+ else if (typeof window !== "undefined" && window.echarts) this._echartsLib = window.echarts;
33
+ return this;
513
34
  }
514
- option(e) {
515
- return e === void 0 ? this._option : (this._option = e || null, this._chartInstance && this._echartsLib && this._chartInstance.setOption(this._option, !0), this);
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;
516
40
  }
517
- width(e) {
518
- return e === void 0 ? this._width : (this._width = e, this.style("width", e), this);
41
+ width(value) {
42
+ if (value === void 0) return this._width;
43
+ this._width = value;
44
+ this.style("width", value);
45
+ return this;
519
46
  }
520
- height(e) {
521
- return e === void 0 ? this._height : (this._height = e, this.style("height", e), this);
47
+ height(value) {
48
+ if (value === void 0) return this._height;
49
+ this._height = value;
50
+ this.style("height", value);
51
+ return this;
522
52
  }
523
- theme(e) {
524
- return e === void 0 ? this._theme : (this._theme = e, this);
53
+ theme(value) {
54
+ if (value === void 0) return this._theme;
55
+ this._theme = value;
56
+ return this;
525
57
  }
526
- renderer(e) {
527
- return e === void 0 ? this._renderer : (this._renderer = e === "svg" ? "svg" : "canvas", this);
58
+ renderer(value) {
59
+ if (value === void 0) return this._renderer;
60
+ this._renderer = value === "svg" ? "svg" : "canvas";
61
+ return this;
528
62
  }
529
- devicePixelRatio(e) {
530
- return e === void 0 ? this._devicePixelRatio : (this._devicePixelRatio = e, this);
63
+ devicePixelRatio(value) {
64
+ if (value === void 0) return this._devicePixelRatio;
65
+ this._devicePixelRatio = value;
66
+ return this;
531
67
  }
532
- autoResize(e) {
533
- return e === void 0 ? this._autoResize : (this._autoResize = !!e, this);
68
+ autoResize(value) {
69
+ if (value === void 0) return this._autoResize;
70
+ this._autoResize = Boolean(value);
71
+ return this;
534
72
  }
535
- loading(e, t = "加载中...") {
536
- return this._loading = !!e, this._loadingText = t, this._chartInstance && (this._loading ? this._chartInstance.showLoading({
537
- color: "var(--yoya-color-primary, #2563eb)",
538
- lineWidth: 2,
539
- maskColor: "rgba(255, 255, 255, 0.8)",
540
- text: t,
541
- textColor: "var(--yoya-color-text, #172033)"
542
- }) : this._chartInstance.hideLoading()), this;
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;
543
87
  }
544
- onChartReady(e) {
545
- return typeof e == "function" && (this._chartInstance ? e(this._chartInstance) : this._onReadyCallbacks.push(e)), this;
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;
546
94
  }
547
- onChartResize(e) {
548
- return typeof e == "function" && this._onResizeCallbacks.push(e), this;
95
+ onChartResize(callback) {
96
+ if (typeof callback === "function") this._onResizeCallbacks.push(callback);
97
+ return this;
549
98
  }
550
99
  getChartInstance() {
551
100
  return this._chartInstance;
552
101
  }
553
- resize(e = {}) {
554
- return this._chartInstance && this._chartInstance.resize(e), this;
102
+ resize(opts = {}) {
103
+ if (this._chartInstance) this._chartInstance.resize(opts);
104
+ return this;
555
105
  }
556
106
  clear() {
557
- return this._chartInstance && this._chartInstance.clear(), this;
107
+ if (this._chartInstance) this._chartInstance.clear();
108
+ return this;
558
109
  }
559
110
  dispose() {
560
- return this._disposeChart(), this;
111
+ this._disposeChart();
112
+ return this;
561
113
  }
562
114
  destroy() {
563
- return this._disposeChart(), super.destroy();
115
+ this._disposeChart();
116
+ return super.destroy();
564
117
  }
565
118
  renderDom() {
566
- let e = super.renderDom();
567
- return e && !this._chartInstance && requestAnimationFrame(() => this._initChart()), e;
568
- }
569
- _setupEchart(e) {
570
- if (e != null) {
571
- if (typeof e == "function") {
572
- e(this);
573
- return;
574
- }
575
- if (Z(e)) {
576
- 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;
577
- 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);
578
- return;
579
- }
580
- 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;
581
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);
582
147
  }
583
148
  _initChart() {
584
- if (!this._deleted) {
585
- if (this._echartsLib || this.echartsLib(), !this._echartsLib) {
586
- console.warn("[VEchart] ECharts library not provided. Call echartsLib() first.");
587
- return;
588
- }
589
- if (!(this._chartInstance || !this._el)) try {
590
- this._chartInstance = this._echartsLib.init(this._el, this._theme, {
591
- devicePixelRatio: this._devicePixelRatio,
592
- renderer: this._renderer
593
- }), this._option && this._chartInstance.setOption(this._option, !0), this._loading && this.loading(!0, this._loadingText), setTimeout(() => {
594
- this._chartInstance && !this._chartInstance.isDisposed() && this._chartInstance.resize();
595
- }, 100), this._executeReadyCallbacks(), this._autoResize && this._initResizeObserver();
596
- } catch (e) {
597
- console.error("[VEchart] Failed to initialize chart:", e);
598
- }
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);
599
170
  }
600
171
  }
601
172
  _executeReadyCallbacks() {
602
- this._chartInstance && (this._onReadyCallbacks.forEach((e) => {
173
+ if (!this._chartInstance) return;
174
+ this._onReadyCallbacks.forEach((callback) => {
603
175
  try {
604
- e(this._chartInstance);
605
- } catch (e) {
606
- console.error("[VEchart] Error in onChartReady callback:", e);
176
+ callback(this._chartInstance);
177
+ } catch (error) {
178
+ console.error("[VEchart] Error in onChartReady callback:", error);
607
179
  }
608
- }), this._onReadyCallbacks = []);
180
+ });
181
+ this._onReadyCallbacks = [];
609
182
  }
610
183
  _initResizeObserver() {
611
- if (typeof ResizeObserver < "u") {
612
- this._resizeObserver = new ResizeObserver((e) => {
613
- for (let t of e) {
614
- let { height: e, width: n } = t.contentRect;
615
- this._handleResize(n, e);
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);
616
189
  }
617
- }), this._el && this._resizeObserver.observe(this._el);
190
+ });
191
+ if (this._el) this._resizeObserver.observe(this._el);
618
192
  return;
619
193
  }
620
- this._resizeHandler = () => this._handleResize(), this._resizeUnbind = G("resize", this._resizeHandler);
194
+ this._resizeHandler = () => this._handleResize();
195
+ this._resizeUnbind = bindWindowEvent("resize", this._resizeHandler);
621
196
  }
622
- _handleResize(e, t) {
623
- this._chartInstance && (this._chartInstance.resize(), this._onResizeCallbacks.forEach((n) => {
197
+ _handleResize(width, height) {
198
+ if (!this._chartInstance) return;
199
+ this._chartInstance.resize();
200
+ this._onResizeCallbacks.forEach((callback) => {
624
201
  try {
625
- n({
626
- height: t,
627
- width: e
202
+ callback({
203
+ height,
204
+ width
628
205
  });
629
- } catch (e) {
630
- console.error("[VEchart] Error in onChartResize callback:", e);
206
+ } catch (error) {
207
+ console.error("[VEchart] Error in onChartResize callback:", error);
631
208
  }
632
- }));
209
+ });
633
210
  }
634
211
  _disposeChart() {
635
- this._resizeObserver &&= (this._resizeObserver.disconnect(), null), this._resizeHandler && (this._resizeUnbind?.(), this._resizeHandler = null, this._resizeUnbind = null), this._chartInstance &&= (this._chartInstance.dispose(), null);
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
+ }
636
225
  }
637
226
  };
638
- function $(e = null, t = null, n = null) {
639
- return X(Q, e, t, n);
227
+ function vEchart(first = null, second = null, third = null) {
228
+ return createComponentFactory(VEchart, first, second, third);
640
229
  }
641
- g(_, { vEchart: $ });
230
+ registerChildFactories(HtmlElementNode, { vEchart });
231
+
642
232
  //#endregion
643
- export { Q as VEchart, $ as vEchart };
233
+ export { VEchart, vEchart };