@yoyaflow/yoya-ui 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.
@@ -0,0 +1,636 @@
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 } = G(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: x, body: S, br: C, button: w, canvas: T, caption: E, cite: D, code: O, col: k, colgroup: A, data: j, datalist: M, dd: N, del: P, details: F, dfn: I, dialog: L, div: R, dl: z, dt: B, em: V, embed: H, fieldset: U, figcaption: de, figure: fe, footer: pe, form: me, h1: he, h2: ge, h3: _e, h4: ve, h5: ye, h6: be, head: xe, header: Se, hgroup: Ce, hr: we, html: Te, i: Ee, iframe: De, img: Oe, input: ke, ins: Ae, kbd: je, label: Me, legend: Ne, li: Pe, link: Fe, main: Ie, map: Le, mark: Re, menu: ze, meta: Be, meter: Ve, nav: He, noscript: Ue, object: We, ol: Ge, optgroup: Ke, option: qe, output: Je, p: Ye, picture: Xe, pre: Ze, progress: Qe, q: $e, rp: et, rt: tt, ruby: nt, s: rt, samp: it, script: at, search: ot, section: st, select: ct, selectedcontent: lt, slot: ut, small: dt, source: ft, span: pt, strong: mt, style: ht, styleTag: gt, sub: _t, summary: vt, sup: yt, table: bt, tbody: xt, td: St, template: Ct, textarea: wt, tfoot: Tt, th: Et, thead: Dt, time: Ot, title: kt, tr: At, track: jt, u: Mt, ul: Nt, varTag: Pt, video: Ft, wbr: W } = b;
466
+ function G(e) {
467
+ return typeof e == "string" ? {
468
+ name: e,
469
+ tagName: e
470
+ } : e;
471
+ }
472
+ //#endregion
473
+ //#region src/components/shared.js
474
+ var K = "yoya-component";
475
+ function q(e = null, t = null, n = null) {
476
+ return f(e, t, n);
477
+ }
478
+ function J(e, t) {
479
+ return typeof e.attr == "function" || typeof e.styles == "function" ? p(e, t) : (typeof e.render == "function" && p(e.render(), t), e);
480
+ }
481
+ function Y(e, t = null, n = null) {
482
+ return J(e, t), typeof n == "function" && n(e), e;
483
+ }
484
+ function X(e, t = null, n = null, r = null) {
485
+ let { first: i, options: a, callback: o } = q(t, n, r);
486
+ return Y(i instanceof e ? i : new e(i), a, o);
487
+ }
488
+ function Z(e) {
489
+ if (Object.prototype.toString.call(e) !== "[object Object]") return !1;
490
+ let t = Object.getPrototypeOf(e);
491
+ return t === Object.prototype || t === null;
492
+ }
493
+ //#endregion
494
+ //#region src/chart/echart.js
495
+ var Q = class extends _ {
496
+ constructor(e = null) {
497
+ 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({
498
+ height: this._height,
499
+ overflow: "hidden",
500
+ position: "relative",
501
+ width: this._width
502
+ }), this._setupEchart(e);
503
+ }
504
+ echartsLib(e) {
505
+ return e ? this._echartsLib = e : typeof window < "u" && window.echarts && (this._echartsLib = window.echarts), this;
506
+ }
507
+ option(e) {
508
+ return e === void 0 ? this._option : (this._option = e || null, this._chartInstance && this._echartsLib && this._chartInstance.setOption(this._option, !0), this);
509
+ }
510
+ width(e) {
511
+ return e === void 0 ? this._width : (this._width = e, this.style("width", e), this);
512
+ }
513
+ height(e) {
514
+ return e === void 0 ? this._height : (this._height = e, this.style("height", e), this);
515
+ }
516
+ theme(e) {
517
+ return e === void 0 ? this._theme : (this._theme = e, this);
518
+ }
519
+ renderer(e) {
520
+ return e === void 0 ? this._renderer : (this._renderer = e === "svg" ? "svg" : "canvas", this);
521
+ }
522
+ devicePixelRatio(e) {
523
+ return e === void 0 ? this._devicePixelRatio : (this._devicePixelRatio = e, this);
524
+ }
525
+ autoResize(e) {
526
+ return e === void 0 ? this._autoResize : (this._autoResize = !!e, this);
527
+ }
528
+ loading(e, t = "加载中...") {
529
+ return this._loading = !!e, this._loadingText = t, this._chartInstance && (this._loading ? this._chartInstance.showLoading({
530
+ color: "var(--yoya-color-primary, #2563eb)",
531
+ lineWidth: 2,
532
+ maskColor: "rgba(255, 255, 255, 0.8)",
533
+ text: t,
534
+ textColor: "var(--yoya-color-text, #172033)"
535
+ }) : this._chartInstance.hideLoading()), this;
536
+ }
537
+ onChartReady(e) {
538
+ return typeof e == "function" && (this._chartInstance ? e(this._chartInstance) : this._onReadyCallbacks.push(e)), this;
539
+ }
540
+ onChartResize(e) {
541
+ return typeof e == "function" && this._onResizeCallbacks.push(e), this;
542
+ }
543
+ getChartInstance() {
544
+ return this._chartInstance;
545
+ }
546
+ resize(e = {}) {
547
+ return this._chartInstance && this._chartInstance.resize(e), this;
548
+ }
549
+ clear() {
550
+ return this._chartInstance && this._chartInstance.clear(), this;
551
+ }
552
+ dispose() {
553
+ return this._disposeChart(), this;
554
+ }
555
+ destroy() {
556
+ return this._disposeChart(), super.destroy();
557
+ }
558
+ renderDom() {
559
+ let e = super.renderDom();
560
+ return e && !this._chartInstance && requestAnimationFrame(() => this._initChart()), e;
561
+ }
562
+ _setupEchart(e) {
563
+ if (e != null) {
564
+ if (typeof e == "function") {
565
+ e(this);
566
+ return;
567
+ }
568
+ if (Z(e)) {
569
+ 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;
570
+ 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);
571
+ return;
572
+ }
573
+ this.child(e);
574
+ }
575
+ }
576
+ _initChart() {
577
+ if (!this._deleted) {
578
+ if (this._echartsLib || this.echartsLib(), !this._echartsLib) {
579
+ console.warn("[VEchart] ECharts library not provided. Call echartsLib() first.");
580
+ return;
581
+ }
582
+ if (!(this._chartInstance || !this._el)) try {
583
+ this._chartInstance = this._echartsLib.init(this._el, this._theme, {
584
+ devicePixelRatio: this._devicePixelRatio,
585
+ renderer: this._renderer
586
+ }), this._option && this._chartInstance.setOption(this._option, !0), this._loading && this.loading(!0, this._loadingText), setTimeout(() => {
587
+ this._chartInstance && !this._chartInstance.isDisposed() && this._chartInstance.resize();
588
+ }, 100), this._executeReadyCallbacks(), this._autoResize && this._initResizeObserver();
589
+ } catch (e) {
590
+ console.error("[VEchart] Failed to initialize chart:", e);
591
+ }
592
+ }
593
+ }
594
+ _executeReadyCallbacks() {
595
+ this._chartInstance && (this._onReadyCallbacks.forEach((e) => {
596
+ try {
597
+ e(this._chartInstance);
598
+ } catch (e) {
599
+ console.error("[VEchart] Error in onChartReady callback:", e);
600
+ }
601
+ }), this._onReadyCallbacks = []);
602
+ }
603
+ _initResizeObserver() {
604
+ if (typeof ResizeObserver < "u") {
605
+ this._resizeObserver = new ResizeObserver((e) => {
606
+ for (let t of e) {
607
+ let { height: e, width: n } = t.contentRect;
608
+ this._handleResize(n, e);
609
+ }
610
+ }), this._el && this._resizeObserver.observe(this._el);
611
+ return;
612
+ }
613
+ this._resizeHandler = () => this._handleResize(), window.addEventListener("resize", this._resizeHandler);
614
+ }
615
+ _handleResize(e, t) {
616
+ this._chartInstance && (this._chartInstance.resize(), this._onResizeCallbacks.forEach((n) => {
617
+ try {
618
+ n({
619
+ height: t,
620
+ width: e
621
+ });
622
+ } catch (e) {
623
+ console.error("[VEchart] Error in onChartResize callback:", e);
624
+ }
625
+ }));
626
+ }
627
+ _disposeChart() {
628
+ this._resizeObserver &&= (this._resizeObserver.disconnect(), null), this._resizeHandler &&= (window.removeEventListener("resize", this._resizeHandler), null), this._chartInstance &&= (this._chartInstance.dispose(), null);
629
+ }
630
+ };
631
+ function $(e = null, t = null, n = null) {
632
+ return X(Q, e, t, n);
633
+ }
634
+ g(_, { vEchart: $ });
635
+ //#endregion
636
+ export { Q as VEchart, $ as vEchart };