@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.
- package/LICENSE +21 -0
- package/README.md +198 -0
- package/README.zh-CN.md +199 -0
- package/dist/echarts.min.js +45 -0
- package/dist/yoya-ui.umd.js +35 -0
- package/dist/yoya.core.js +1674 -0
- package/dist/yoya.echart.js +636 -0
- package/dist/yoya.ssr.js +491 -0
- package/dist/yoya.ui.css +2010 -0
- package/dist/yoya.ui.js +11899 -0
- package/package.json +94 -0
- package/types/actions.d.ts +166 -0
- package/types/async.d.ts +58 -0
- package/types/chart.d.ts +40 -0
- package/types/core.d.ts +495 -0
- package/types/css.d.ts +5 -0
- package/types/data-display.d.ts +518 -0
- package/types/effects.d.ts +40 -0
- package/types/feedback.d.ts +119 -0
- package/types/form.d.ts +486 -0
- package/types/html.d.ts +288 -0
- package/types/i18n.d.ts +56 -0
- package/types/index.d.ts +4 -0
- package/types/layout.d.ts +429 -0
- package/types/navigation.d.ts +275 -0
- package/types/router.d.ts +123 -0
- package/types/ssr.d.ts +81 -0
- package/types/svg.d.ts +158 -0
- package/types/theme.d.ts +40 -0
- package/types/yoya.core.d.ts +7 -0
- package/types/yoya.echart.d.ts +4 -0
- package/types/yoya.ssr.d.ts +4 -0
- package/types/yoya.ui.d.ts +19 -0
package/dist/yoya.ssr.js
ADDED
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
//#region src/core/node.js
|
|
2
|
+
function e(e) {
|
|
3
|
+
return typeof e == "string" ? document.querySelector(e) : e;
|
|
4
|
+
}
|
|
5
|
+
function t(e) {
|
|
6
|
+
return String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7
|
+
}
|
|
8
|
+
var n = class t {
|
|
9
|
+
constructor(e = null) {
|
|
10
|
+
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);
|
|
11
|
+
}
|
|
12
|
+
setup(e) {
|
|
13
|
+
return typeof e == "function" ? e(this) : e instanceof t ? this.child(e) : typeof e == "string" || typeof e == "number" ? this.text(e) : e && typeof e == "object" && this._setupObject(e), this;
|
|
14
|
+
}
|
|
15
|
+
_setupObject(e) {
|
|
16
|
+
e.children && this.child(e.children);
|
|
17
|
+
}
|
|
18
|
+
children() {
|
|
19
|
+
return [...this._children];
|
|
20
|
+
}
|
|
21
|
+
clearChildren() {
|
|
22
|
+
return this._children.forEach((e) => {
|
|
23
|
+
this._pendingRemovals.add(e);
|
|
24
|
+
}), this._children = [], this._childrenDirty = !0, this;
|
|
25
|
+
}
|
|
26
|
+
child(...e) {
|
|
27
|
+
return e.flat(Infinity).forEach((e) => {
|
|
28
|
+
if (e == null) return;
|
|
29
|
+
let t = a(e);
|
|
30
|
+
this._pendingRemovals.delete(t), this._children.push(t), this._childrenDirty = !0;
|
|
31
|
+
}), this;
|
|
32
|
+
}
|
|
33
|
+
text(e) {
|
|
34
|
+
return this.child(new r(e));
|
|
35
|
+
}
|
|
36
|
+
on(e, t, n) {
|
|
37
|
+
return this._events.has(e) || this._events.set(e, []), this._events.get(e).push({
|
|
38
|
+
handler: t,
|
|
39
|
+
options: n
|
|
40
|
+
}), this._el && (this._el.addEventListener(e, t, n), this._cleanup.push(() => this._el.removeEventListener(e, t, n))), this;
|
|
41
|
+
}
|
|
42
|
+
registerStateAttrs(...e) {
|
|
43
|
+
return e.forEach((e) => {
|
|
44
|
+
if (typeof e == "string") {
|
|
45
|
+
this._stateTypes[e] = "boolean";
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
e && typeof e == "object" && Object.entries(e).forEach(([e, t]) => {
|
|
49
|
+
this._stateTypes[e] = t || "boolean";
|
|
50
|
+
});
|
|
51
|
+
}), this;
|
|
52
|
+
}
|
|
53
|
+
registerStateHandler(e, t) {
|
|
54
|
+
return this._stateHandlers.has(e) || this._stateHandlers.set(e, []), this._stateHandlers.get(e).push(t), this;
|
|
55
|
+
}
|
|
56
|
+
setState(e, t = !0) {
|
|
57
|
+
let n = this._states[e];
|
|
58
|
+
return this._states[e] = t, (this._stateHandlers.get(e) || []).forEach((e) => e(t, this, n)), this;
|
|
59
|
+
}
|
|
60
|
+
getState(e) {
|
|
61
|
+
return this._states[e];
|
|
62
|
+
}
|
|
63
|
+
getBooleanState(e) {
|
|
64
|
+
return !!this.getState(e);
|
|
65
|
+
}
|
|
66
|
+
getStringState(e) {
|
|
67
|
+
let t = this.getState(e);
|
|
68
|
+
return t == null ? "" : String(t);
|
|
69
|
+
}
|
|
70
|
+
getNumberState(e) {
|
|
71
|
+
return Number(this.getState(e) || 0);
|
|
72
|
+
}
|
|
73
|
+
renderDom() {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
commit() {
|
|
77
|
+
return this.renderDom();
|
|
78
|
+
}
|
|
79
|
+
_commitChildren() {
|
|
80
|
+
this._pendingRemovals.forEach((e) => e.destroy()), this._pendingRemovals.clear(), this._childrenDirty = !1;
|
|
81
|
+
}
|
|
82
|
+
bindTo(t) {
|
|
83
|
+
let n = e(t), r = this.renderDom();
|
|
84
|
+
return n && r && n.appendChild(r), this;
|
|
85
|
+
}
|
|
86
|
+
destroy() {
|
|
87
|
+
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;
|
|
88
|
+
}
|
|
89
|
+
toHTML() {
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
hydrateSnapshot() {
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
}, r = class extends n {
|
|
96
|
+
constructor(e = "") {
|
|
97
|
+
super(null), this._content = String(e), this._textNode = null;
|
|
98
|
+
}
|
|
99
|
+
textContent(e) {
|
|
100
|
+
return e === void 0 ? this._content : (this._content = String(e), this._textNode && (this._textNode.textContent = this._content), this);
|
|
101
|
+
}
|
|
102
|
+
renderDom() {
|
|
103
|
+
return this._deleted ? null : (this._textNode || (this._textNode = document.createTextNode(this._content), this._el = this._textNode), this._textNode);
|
|
104
|
+
}
|
|
105
|
+
toHTML() {
|
|
106
|
+
return this._deleted ? "" : t(this._content);
|
|
107
|
+
}
|
|
108
|
+
}, i = class extends n {
|
|
109
|
+
constructor(e) {
|
|
110
|
+
super(null), this._component = e, this._resolved = null;
|
|
111
|
+
}
|
|
112
|
+
_resolve() {
|
|
113
|
+
if (this._resolved) return this._resolved;
|
|
114
|
+
let e = typeof this._component == "function" ? this._component() : this._component.render();
|
|
115
|
+
if (!(e instanceof n)) throw TypeError("Component render must return a ViewNode");
|
|
116
|
+
return this._resolved = e, e;
|
|
117
|
+
}
|
|
118
|
+
children() {
|
|
119
|
+
return this._resolved ? this._resolved.children() : [];
|
|
120
|
+
}
|
|
121
|
+
textContent() {
|
|
122
|
+
let e = this._resolve();
|
|
123
|
+
return typeof e.textContent == "function" ? e.textContent() : "";
|
|
124
|
+
}
|
|
125
|
+
renderDom() {
|
|
126
|
+
if (this._deleted) return null;
|
|
127
|
+
let e = this._resolve().renderDom();
|
|
128
|
+
return this._el = e, e;
|
|
129
|
+
}
|
|
130
|
+
toHTML() {
|
|
131
|
+
return this._deleted ? "" : this._resolve().toHTML();
|
|
132
|
+
}
|
|
133
|
+
destroy() {
|
|
134
|
+
return this._resolved && this._resolved.destroy(), super.destroy();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
function a(e) {
|
|
138
|
+
if (e instanceof n) return e;
|
|
139
|
+
if (typeof e == "function" || e && typeof e == "object" && typeof e.render == "function") return new i(e);
|
|
140
|
+
if (typeof e == "string" || typeof e == "number") return new r(e);
|
|
141
|
+
throw TypeError("ViewNode child must be a ViewNode, component, string, or number");
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/core/id.js
|
|
145
|
+
var o = null;
|
|
146
|
+
function s() {
|
|
147
|
+
let e = 0;
|
|
148
|
+
return { next() {
|
|
149
|
+
return e += 1, e;
|
|
150
|
+
} };
|
|
151
|
+
}
|
|
152
|
+
function c(e, t) {
|
|
153
|
+
let n = o;
|
|
154
|
+
o = e;
|
|
155
|
+
try {
|
|
156
|
+
return t();
|
|
157
|
+
} finally {
|
|
158
|
+
o = n;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/core/i18n.js
|
|
163
|
+
var l = "yoya-ui:i18n", u = /* @__PURE__ */ new Map(), d = class {
|
|
164
|
+
constructor(e = {}) {
|
|
165
|
+
let t = e.language || "zh-CN";
|
|
166
|
+
this._key = e.key || null, this._storage = k(e.storage), this._storageKey = e.storageKey || null, this._sharedStorageKey = this._key ? l : null, this._fallbackLanguage = e.fallbackLanguage || t, this._language = this._readStoredLanguage(t), this._messages = {}, this._listeners = /* @__PURE__ */ new Set(), this.registerMessages(e.messages || {}), this._key && y(this);
|
|
167
|
+
}
|
|
168
|
+
key() {
|
|
169
|
+
return this._key;
|
|
170
|
+
}
|
|
171
|
+
getLanguage() {
|
|
172
|
+
return this._language;
|
|
173
|
+
}
|
|
174
|
+
setLanguage(e) {
|
|
175
|
+
return !e || e === this._language ? this : (this._language = e, this._persistLanguage(), this._notify(), this);
|
|
176
|
+
}
|
|
177
|
+
getFallbackLanguage() {
|
|
178
|
+
return this._fallbackLanguage;
|
|
179
|
+
}
|
|
180
|
+
setFallbackLanguage(e) {
|
|
181
|
+
return e ? (this._fallbackLanguage = e, this._notify(), this) : this;
|
|
182
|
+
}
|
|
183
|
+
clearPersistedLanguage() {
|
|
184
|
+
if (!this._storageKey) {
|
|
185
|
+
if (!this._sharedStorageKey) return this;
|
|
186
|
+
let e = x(this._storage, this._sharedStorageKey);
|
|
187
|
+
return delete e[this._key], S(this._storage, this._sharedStorageKey, e), this;
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
this._storage.removeItem(this._storageKey);
|
|
191
|
+
} catch {}
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
register(e, t = {}) {
|
|
195
|
+
return e ? (O(t).forEach((t) => {
|
|
196
|
+
this._messages[e] = T(this._messages[e] || {}, t);
|
|
197
|
+
}), this._notify(), this) : this;
|
|
198
|
+
}
|
|
199
|
+
registerMessages(e = {}) {
|
|
200
|
+
return D(e).forEach((e) => {
|
|
201
|
+
if (e.language) {
|
|
202
|
+
this.register(e.language, e.messages || {});
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
Object.entries(e).forEach(([e, t]) => {
|
|
206
|
+
this.register(e, t);
|
|
207
|
+
});
|
|
208
|
+
}), this;
|
|
209
|
+
}
|
|
210
|
+
t(e, t = {}, n = void 0) {
|
|
211
|
+
let r = C(this._messages[this._language], e) ?? C(this._messages[this._fallbackLanguage], e) ?? n ?? e;
|
|
212
|
+
return w(typeof r == "function" ? r(t, this) : r, t);
|
|
213
|
+
}
|
|
214
|
+
text(e, t = {}, n = void 0) {
|
|
215
|
+
return new f(this, e, t, n);
|
|
216
|
+
}
|
|
217
|
+
subscribe(e) {
|
|
218
|
+
return this._listeners.add(e), () => {
|
|
219
|
+
this._listeners.delete(e);
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
_readStoredLanguage(e) {
|
|
223
|
+
if (this._storageKey) try {
|
|
224
|
+
return this._storage.getItem(this._storageKey) || e;
|
|
225
|
+
} catch {
|
|
226
|
+
return e;
|
|
227
|
+
}
|
|
228
|
+
return this._sharedStorageKey && x(this._storage, this._sharedStorageKey)[this._key] || e;
|
|
229
|
+
}
|
|
230
|
+
_persistLanguage() {
|
|
231
|
+
if (this._storageKey) {
|
|
232
|
+
try {
|
|
233
|
+
this._storage.setItem(this._storageKey, this._language);
|
|
234
|
+
} catch {}
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (this._sharedStorageKey) {
|
|
238
|
+
let e = x(this._storage, this._sharedStorageKey);
|
|
239
|
+
e[this._key] = this._language, S(this._storage, this._sharedStorageKey, e);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
_notify() {
|
|
243
|
+
this._listeners.forEach((e) => e(this));
|
|
244
|
+
}
|
|
245
|
+
}, f = class extends r {
|
|
246
|
+
constructor(e, t, n = {}, r = void 0) {
|
|
247
|
+
super(e.t(t, n, r)), this._i18n = e, this._key = t, this._params = n || {}, this._defaultValue = r, this._unsubscribe = e.subscribe(() => this.refresh());
|
|
248
|
+
}
|
|
249
|
+
key(e) {
|
|
250
|
+
return e === void 0 ? this._key : (this._key = e, this.refresh());
|
|
251
|
+
}
|
|
252
|
+
params(e) {
|
|
253
|
+
return e === void 0 ? { ...this._params } : (this._params = e || {}, this.refresh());
|
|
254
|
+
}
|
|
255
|
+
defaultValue(e) {
|
|
256
|
+
return e === void 0 ? this._defaultValue : (this._defaultValue = e, this.refresh());
|
|
257
|
+
}
|
|
258
|
+
refresh() {
|
|
259
|
+
return this.textContent(this._i18n.t(this._key, this._params, this._defaultValue)), this;
|
|
260
|
+
}
|
|
261
|
+
destroy() {
|
|
262
|
+
return this._unsubscribe &&= (this._unsubscribe(), null), super.destroy();
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
function p(e = {}) {
|
|
266
|
+
return new d(e);
|
|
267
|
+
}
|
|
268
|
+
var m = p(), h = m;
|
|
269
|
+
function g(e = m) {
|
|
270
|
+
return h = e, String.prototype._yoyaUiStringShortcutInstalled ? e : (Object.defineProperty(String.prototype, "_yoyaUiStringShortcutInstalled", {
|
|
271
|
+
configurable: !0,
|
|
272
|
+
enumerable: !1,
|
|
273
|
+
value: !0
|
|
274
|
+
}), Object.defineProperty(String.prototype, "s", {
|
|
275
|
+
configurable: !0,
|
|
276
|
+
enumerable: !1,
|
|
277
|
+
value: function(e, t, n) {
|
|
278
|
+
let r = String(this), i = {}, a = h;
|
|
279
|
+
return v(t) ? a = t : typeof t == "string" ? a = b(t) || h : (i = t || {}, v(n) ? a = n : typeof n == "string" && (a = b(n) || h)), a.text(e || r, i, r);
|
|
280
|
+
}
|
|
281
|
+
}), e);
|
|
282
|
+
}
|
|
283
|
+
function _(e, t) {
|
|
284
|
+
let n = h;
|
|
285
|
+
h = e || n;
|
|
286
|
+
try {
|
|
287
|
+
return t();
|
|
288
|
+
} finally {
|
|
289
|
+
h = n;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function v(e) {
|
|
293
|
+
return !!(e && typeof e.text == "function");
|
|
294
|
+
}
|
|
295
|
+
function y(e) {
|
|
296
|
+
let t = e?.key?.();
|
|
297
|
+
return t ? (u.set(t, e), () => {
|
|
298
|
+
u.get(t) === e && u.delete(t);
|
|
299
|
+
}) : () => {};
|
|
300
|
+
}
|
|
301
|
+
function b(e) {
|
|
302
|
+
return e && u.get(e) || null;
|
|
303
|
+
}
|
|
304
|
+
function x(e, t) {
|
|
305
|
+
if (!e) return {};
|
|
306
|
+
try {
|
|
307
|
+
let n = e.getItem(t);
|
|
308
|
+
if (!n) return {};
|
|
309
|
+
let r = JSON.parse(n);
|
|
310
|
+
return r && typeof r == "object" ? r : {};
|
|
311
|
+
} catch {
|
|
312
|
+
return {};
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function S(e, t, n) {
|
|
316
|
+
if (e) try {
|
|
317
|
+
e.setItem(t, JSON.stringify(n));
|
|
318
|
+
} catch {}
|
|
319
|
+
}
|
|
320
|
+
g(m);
|
|
321
|
+
function C(e, t) {
|
|
322
|
+
if (!(!e || !t)) return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : String(t).split(".").reduce((e, t) => {
|
|
323
|
+
if (e && typeof e == "object" && Object.prototype.hasOwnProperty.call(e, t)) return e[t];
|
|
324
|
+
}, e);
|
|
325
|
+
}
|
|
326
|
+
function w(e, t) {
|
|
327
|
+
return String(e).replace(/\{([^{}]+)\}/g, (e, n) => {
|
|
328
|
+
let r = t?.[n.trim()];
|
|
329
|
+
return r == null ? e : String(r);
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
function T(e, t) {
|
|
333
|
+
let n = { ...e };
|
|
334
|
+
return Object.entries(t || {}).forEach(([e, t]) => {
|
|
335
|
+
E(t) && E(n[e]) ? n[e] = T(n[e], t) : n[e] = t;
|
|
336
|
+
}), n;
|
|
337
|
+
}
|
|
338
|
+
function E(e) {
|
|
339
|
+
return Object.prototype.toString.call(e) === "[object Object]";
|
|
340
|
+
}
|
|
341
|
+
function D(e) {
|
|
342
|
+
return Array.isArray(e) ? e.flatMap((e) => D(e)) : [e || {}];
|
|
343
|
+
}
|
|
344
|
+
function O(e) {
|
|
345
|
+
return Array.isArray(e) ? e.flatMap((e) => O(e)) : [e || {}];
|
|
346
|
+
}
|
|
347
|
+
function k(e) {
|
|
348
|
+
if (e) return e;
|
|
349
|
+
try {
|
|
350
|
+
if (typeof globalThis < "u" && globalThis.localStorage) return globalThis.localStorage;
|
|
351
|
+
} catch {}
|
|
352
|
+
return j();
|
|
353
|
+
}
|
|
354
|
+
var A = /* @__PURE__ */ new Map();
|
|
355
|
+
function j() {
|
|
356
|
+
return {
|
|
357
|
+
getItem(e) {
|
|
358
|
+
return A.has(e) ? A.get(e) : null;
|
|
359
|
+
},
|
|
360
|
+
setItem(e, t) {
|
|
361
|
+
A.set(e, String(t));
|
|
362
|
+
},
|
|
363
|
+
removeItem(e) {
|
|
364
|
+
A.delete(e);
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/core/ssr.js
|
|
370
|
+
function M(e = {}, t = {}) {
|
|
371
|
+
let { cookie: n = "", url: r = "", acceptLanguage: i = "" } = e || {}, { cookieKey: a = "yoya-lang", queryKey: o = "locale", defaultLanguage: s = "zh-CN" } = t;
|
|
372
|
+
return N(n, a) || P(r, o) || F(i) || s;
|
|
373
|
+
}
|
|
374
|
+
function N(e, t) {
|
|
375
|
+
if (!e || !t) return null;
|
|
376
|
+
for (let n of String(e).split(";")) {
|
|
377
|
+
let e = n.indexOf("=");
|
|
378
|
+
if (e === -1 || n.slice(0, e).trim() !== t) continue;
|
|
379
|
+
let r = n.slice(e + 1).trim();
|
|
380
|
+
if (!r) return null;
|
|
381
|
+
try {
|
|
382
|
+
return decodeURIComponent(r);
|
|
383
|
+
} catch {
|
|
384
|
+
return r;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
function P(e, t) {
|
|
390
|
+
if (!e || !t) return null;
|
|
391
|
+
let n = String(e).indexOf("?");
|
|
392
|
+
return n === -1 ? null : new URLSearchParams(String(e).slice(n + 1)).get(t) || null;
|
|
393
|
+
}
|
|
394
|
+
function F(e) {
|
|
395
|
+
if (!e) return null;
|
|
396
|
+
let t = String(e).split(",")[0];
|
|
397
|
+
return t && t.split(";")[0].trim() || null;
|
|
398
|
+
}
|
|
399
|
+
function I(e, t, n) {
|
|
400
|
+
return e ? _(typeof e == "function" ? e(t) : e, n) : n();
|
|
401
|
+
}
|
|
402
|
+
function L(e, t = null) {
|
|
403
|
+
if (e instanceof n) return e;
|
|
404
|
+
if (typeof e == "function") return L(e(t), t);
|
|
405
|
+
if (e && typeof e.render == "function") return L(e.render(), t);
|
|
406
|
+
throw TypeError("renderToString/mount requires a ViewNode, a component object with render(), or a factory function");
|
|
407
|
+
}
|
|
408
|
+
function R(e) {
|
|
409
|
+
let t = 1;
|
|
410
|
+
return typeof e.children == "function" && e.children().forEach((e) => {
|
|
411
|
+
t += R(e instanceof i ? e._resolve() : e);
|
|
412
|
+
}), t;
|
|
413
|
+
}
|
|
414
|
+
function z(e, t = {}) {
|
|
415
|
+
let { maxNodes: n = Infinity, state: r = null, i18n: i = null } = t || {}, a = B(r);
|
|
416
|
+
return c(s(), () => I(i, r, () => {
|
|
417
|
+
let t = typeof e == "function", i = L(e, r), o;
|
|
418
|
+
try {
|
|
419
|
+
o = R(i) > n ? {
|
|
420
|
+
exceeded: !0,
|
|
421
|
+
html: "",
|
|
422
|
+
state: a
|
|
423
|
+
} : {
|
|
424
|
+
exceeded: !1,
|
|
425
|
+
html: i.toHTML(),
|
|
426
|
+
state: a
|
|
427
|
+
};
|
|
428
|
+
} finally {
|
|
429
|
+
t && i.destroy();
|
|
430
|
+
}
|
|
431
|
+
return o;
|
|
432
|
+
}));
|
|
433
|
+
}
|
|
434
|
+
function B(e) {
|
|
435
|
+
return e == null ? null : JSON.stringify(e).replace(/</g, "\\u003c");
|
|
436
|
+
}
|
|
437
|
+
function V(e) {
|
|
438
|
+
return e == null || e === "" ? null : JSON.parse(e);
|
|
439
|
+
}
|
|
440
|
+
function H(t, n, r = null, i = {}) {
|
|
441
|
+
return c(s(), () => I(i.i18n, r, () => {
|
|
442
|
+
let i = L(t, r), a = e(n);
|
|
443
|
+
return a && (a.replaceChildren(), a.appendChild(i.renderDom())), i;
|
|
444
|
+
}));
|
|
445
|
+
}
|
|
446
|
+
function U(t, n, r = null, i = {}) {
|
|
447
|
+
return c(s(), () => I(i.i18n, r, () => {
|
|
448
|
+
let i = L(t, r), a = e(n);
|
|
449
|
+
if (a) {
|
|
450
|
+
let e = a.firstElementChild;
|
|
451
|
+
e ? (W(i, e), K(i), G(i), i.renderDom()) : a.appendChild(i.renderDom());
|
|
452
|
+
}
|
|
453
|
+
return i;
|
|
454
|
+
}));
|
|
455
|
+
}
|
|
456
|
+
function W(e, t) {
|
|
457
|
+
if (e instanceof i) {
|
|
458
|
+
W(e._resolve(), t);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (e instanceof r) {
|
|
462
|
+
t && t.nodeType === 3 ? (e._textNode = t, e._el = t, t.textContent !== e._content && (t.textContent = e._content)) : q(t, e.renderDom());
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
if (t && t.nodeType === 1 && t.tagName.toLowerCase() === e._tagName) {
|
|
466
|
+
e._el = t, e._hydrated = !0;
|
|
467
|
+
let n = Array.from(t.childNodes);
|
|
468
|
+
e.children().forEach((e, t) => W(e, n[t]));
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
q(t, e.renderDom());
|
|
472
|
+
}
|
|
473
|
+
function G(e) {
|
|
474
|
+
if (e instanceof i) {
|
|
475
|
+
G(e._resolve());
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
e instanceof r || (e._el && e._hydrated && e._applyBindingsToElement(), e.children().forEach(G));
|
|
479
|
+
}
|
|
480
|
+
function K(e) {
|
|
481
|
+
if (e instanceof i) {
|
|
482
|
+
K(e._resolve());
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
e instanceof r || (e.children().forEach(K), typeof e.hydrateSnapshot == "function" && e.hydrateSnapshot());
|
|
486
|
+
}
|
|
487
|
+
function q(e, t) {
|
|
488
|
+
e && e.parentNode && e.parentNode.replaceChild(t, e);
|
|
489
|
+
}
|
|
490
|
+
//#endregion
|
|
491
|
+
export { U as hydrate, H as mount, V as parseState, z as renderToString, M as resolveLocale, B as serializeState };
|