agile-core 3.0.9 → 3.0.10

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/dist/core.es.js CHANGED
@@ -1,442 +1 @@
1
- import { createApp as e, defineComponent as t, useAttrs as n, shallowRef as o, ref as r, useSlots as i, onMounted as s, onUpdated as a, h as l } from "vue";
2
- import { merge as u } from "ts-deepmerge";
3
- var h, c;
4
- const d = function() {
5
- try {
6
- return __AUI_CONFIG__;
7
- } catch (e2) {
8
- return { tagPrefix: "aui" };
9
- }
10
- }().tagPrefix || "aui", p = "data-v-aui", m = "auix", f = Symbol("shadow");
11
- const _AuiComponent = class _AuiComponent extends (c = HTMLElement, h = f, c) {
12
- constructor(e2) {
13
- super(), this.__hasVue__ = false, this[h] = { needHook: false, slot: {} }, this[_AuiComponent.shadowSymbol].options = e2 || {}, this.$initAttrs();
14
- }
15
- connectedCallback() {
16
- this.$needInit() && (this.$initVue(), this.$needHook(true));
17
- }
18
- set innerHTML(e2) {
19
- this.$needHook() ? this.$innerHTML("default", e2) : Reflect.set(HTMLElement.prototype, "innerHTML", e2, this);
20
- }
21
- get innerHTML() {
22
- return this.$needHook() ? this.$innerHTML("default") : Reflect.get(HTMLElement.prototype, "innerHTML", this) || "";
23
- }
24
- set textContent(e2) {
25
- this.$needHook() ? this.$textContent("default", e2) : Reflect.set(HTMLElement.prototype, "innerHTML", e2, this);
26
- }
27
- get textContent() {
28
- return this.$needHook() ? this.$textContent("default") : Reflect.get(HTMLElement.prototype, "innerHTML", this) || "";
29
- }
30
- set innerText(e2) {
31
- this.$ignoreLog("innerText"), Reflect.set(HTMLElement.prototype, "innerText", e2, this);
32
- }
33
- set value(e2) {
34
- let t2 = e2;
35
- const n2 = this[_AuiComponent.shadowSymbol].value;
36
- let o2;
37
- this.$isArrayValue() ? (t2 = _AuiComponent.$anyToArray(e2), o2 = JSON.stringify(t2)) : o2 = t2.toString(), n2 !== o2 && (this[_AuiComponent.shadowSymbol].value = o2, this[_AuiComponent.shadowSymbol].el && this.$attrChange("value"));
38
- }
39
- get value() {
40
- const e2 = this[_AuiComponent.shadowSymbol].value;
41
- return this.$isArrayValue() && "string" == typeof e2 ? JSON.parse(e2) : e2;
42
- }
43
- prepend(e2) {
44
- if (!this.$needHook()) return HTMLElement.prototype.prepend.call(this, e2);
45
- this.$prepend("default", e2);
46
- }
47
- appendChild(e2) {
48
- return this.$needHook() ? this.$appendChild("default", e2) : HTMLElement.prototype.appendChild.call(this, e2);
49
- }
50
- insertBefore(e2, t2) {
51
- return this.$needHook() ? this.$insertBefore("default", e2, t2) : HTMLElement.prototype.insertBefore.call(this, e2, t2);
52
- }
53
- hasAttribute(e2) {
54
- const t2 = this[_AuiComponent.shadowSymbol].el;
55
- return t2 ? t2.hasAttribute(e2) : HTMLElement.prototype.hasAttribute.call(this, e2);
56
- }
57
- setAttribute(e2, t2) {
58
- t2 = t2.toString();
59
- const n2 = this[_AuiComponent.shadowSymbol].el;
60
- if (n2) {
61
- if (n2.getAttribute(e2) === t2) return;
62
- n2.setAttribute(e2, t2);
63
- }
64
- this.$isShowProp(b.vueAttrName(e2)) && HTMLElement.prototype.setAttribute.call(this, e2, t2), "value" === e2 && n2 ? this.value = n2.getAttribute(e2) : this.$attrChange(e2);
65
- }
66
- getAttribute(e2) {
67
- const t2 = this[_AuiComponent.shadowSymbol].el;
68
- return t2 ? t2.getAttribute(e2) : super.getAttribute(e2);
69
- }
70
- removeAttribute(e2) {
71
- const t2 = this[_AuiComponent.shadowSymbol].el;
72
- t2 && t2.removeAttribute(e2);
73
- this.$isShowProp(b.vueAttrName(e2)) && HTMLElement.prototype.removeAttribute.call(this, e2), this.$attrChange(e2);
74
- }
75
- attributeChangedCallback(e2, t2, n2) {
76
- const o2 = this[_AuiComponent.shadowSymbol].el;
77
- o2 && t2 !== n2 && (this.$isShowProp(b.vueAttrName(e2)) || HTMLElement.prototype.removeAttribute.call(this, e2), o2.setAttribute(e2, n2 || ""), "value" !== e2 && this.$attrChange(e2));
78
- }
79
- static $anyToArray(e2) {
80
- let t2 = [];
81
- if ("string" == typeof e2) {
82
- try {
83
- const t3 = JSON.parse(e2);
84
- if (t3 instanceof Array) return t3;
85
- } catch (e3) {
86
- }
87
- t2 = e2.split(",").filter((e3) => !!e3 && e3.trim());
88
- } else e2 instanceof Array && (t2 = e2);
89
- return t2;
90
- }
91
- $resetShadowSymbol() {
92
- this[_AuiComponent.shadowSymbol] = { needHook: false, slot: {} };
93
- }
94
- $customEvent(e2, t2) {
95
- this.dispatchEvent(new CustomEvent(e2, Object.assign({ bubbles: false, composed: false, cancelable: true }, t2 || {})));
96
- }
97
- $forceUpdate() {
98
- let e2 = null;
99
- const t2 = this[_AuiComponent.shadowSymbol].slot;
100
- for (const n2 in t2) {
101
- const o2 = this.$slotCollection(t2[n2]);
102
- e2 || (e2 = {}), e2[n2] = o2;
103
- }
104
- e2 && (this[_AuiComponent.shadowSymbol].slotCollection = e2), this.$customEvent("aui-force-update");
105
- }
106
- $slotCollection(e2) {
107
- var _a;
108
- const { start: t2, end: n2 } = e2, o2 = [];
109
- let r2;
110
- for (; t2 && (r2 = t2.nextSibling) && r2 !== n2; ) (_a = t2.parentNode) == null ? void 0 : _a.removeChild(r2), o2.push(r2);
111
- return o2;
112
- }
113
- $slotReplace() {
114
- const e2 = this[_AuiComponent.shadowSymbol].slotCollection;
115
- if (e2) {
116
- delete this[_AuiComponent.shadowSymbol].slotCollection;
117
- for (const t2 in e2) {
118
- this.querySelector(`aui-slot[name="${t2}"]`).$replace(this), this.$replaceChildren(t2, e2[t2]);
119
- }
120
- }
121
- }
122
- $textContent(e2, ...t2) {
123
- if (0 === t2.length) {
124
- const t3 = [], { start: n2, end: o2 } = this.$slot(e2) || {};
125
- let r2 = n2;
126
- for (; r2 && (r2 = r2.nextSibling) && r2 !== o2; ) t3.push(r2.textContent);
127
- return t3.join("");
128
- }
129
- return this.$hasSlot() ? (this.$replaceChildren(e2, [document.createTextNode(t2[0] || "")]), "") : "";
130
- }
131
- $innerHTML(e2, ...t2) {
132
- if (0 === t2.length) {
133
- const t3 = [], { start: n2, end: o2 } = this.$slot(e2) || {};
134
- let r2 = n2;
135
- for (; r2 && (r2 = r2.nextSibling) && r2 !== o2; ) if (r2.outerHTML) t3.push(r2.outerHTML);
136
- else {
137
- let e3 = r2.textContent;
138
- r2 instanceof Comment && (e3 = `<!--${e3}-->`), t3.push(e3);
139
- }
140
- return t3.join("");
141
- }
142
- {
143
- if (!this.$hasSlot()) return "";
144
- const n2 = document.createElement("div");
145
- n2.innerHTML = t2[0] || "";
146
- const o2 = this.$moveChildren(n2);
147
- this.$replaceChildren(e2, o2.default);
148
- }
149
- return "";
150
- }
151
- $prepend(e2, t2) {
152
- var _a;
153
- const { start: n2 } = this.$slot(e2) || {};
154
- (_a = n2 == null ? void 0 : n2.parentNode) == null ? void 0 : _a.insertBefore(t2, n2.nextSibling);
155
- }
156
- $appendChild(e2, t2) {
157
- var _a;
158
- const { end: n2 } = this.$slot(e2) || {};
159
- return (_a = n2 == null ? void 0 : n2.parentNode) == null ? void 0 : _a.insertBefore(t2, n2), t2;
160
- }
161
- $insertBefore(e2, t2, n2) {
162
- const { start: o2 } = this.$slot(e2) || {}, r2 = (o2 == null ? void 0 : o2.parentNode) || this;
163
- return n2 ? r2 === this ? HTMLElement.prototype.insertBefore.call(this, t2, n2) : r2.insertBefore(t2, n2) : this.appendChild(t2), t2;
164
- }
165
- $childNodes(e2) {
166
- const t2 = [], { start: n2, end: o2 } = this.$slot(e2) || {};
167
- let r2 = n2;
168
- for (; r2 && (r2 = r2.nextSibling) && r2 !== o2; ) t2.push(r2);
169
- return t2;
170
- }
171
- $children(e2) {
172
- const t2 = [], { start: n2, end: o2 } = this.$slot(e2) || {};
173
- let r2 = n2;
174
- for (; r2 && (r2 = r2.nextSibling) && r2 !== o2; ) r2 instanceof HTMLElement && t2.push(r2);
175
- return t2;
176
- }
177
- $replaceChildren(e2, t2) {
178
- var _a, _b;
179
- const { start: n2, end: o2 } = this.$slot(e2) || {};
180
- let r2 = null;
181
- for (; n2 && (r2 = n2.nextSibling) && r2 !== o2; ) (_a = r2.parentNode) == null ? void 0 : _a.removeChild(r2);
182
- if (o2) for (; r2 = t2.shift(); ) (_b = o2.parentNode) == null ? void 0 : _b.insertBefore(r2, o2);
183
- }
184
- $slot(e2, t2) {
185
- if (e2 = e2 || "default", !t2) return this[_AuiComponent.shadowSymbol].slot[e2];
186
- this[_AuiComponent.shadowSymbol].slot[e2] = t2;
187
- }
188
- $hasSlot() {
189
- return Object.keys(this[_AuiComponent.shadowSymbol].slot).length > 0;
190
- }
191
- $needHook(e2) {
192
- return "boolean" == typeof e2 && (this[_AuiComponent.shadowSymbol].needHook = e2), this[_AuiComponent.shadowSymbol].needHook;
193
- }
194
- $ignoreLog(e2) {
195
- }
196
- $moveChildren(e2) {
197
- var _a;
198
- const t2 = (e2 = e2 || this).childNodes, n2 = { default: [] };
199
- for (; t2.length > 0; ) {
200
- const o2 = t2[0];
201
- if ((_a = o2.parentNode) == null ? void 0 : _a.removeChild(o2), $.$isForAuiSlot(o2)) {
202
- const t3 = o2.getAttribute("for") || "default";
203
- n2[t3] = n2[t3] || [];
204
- const r2 = Array.prototype.slice.call(o2.childNodes);
205
- $.prototype.$bind.call(o2, e2), n2[t3].push(...r2);
206
- } else n2.default.push(o2);
207
- }
208
- return n2;
209
- }
210
- $isArrayValue() {
211
- var _a;
212
- return ((_a = this[_AuiComponent.shadowSymbol].options) == null ? void 0 : _a.valueType) === Array;
213
- }
214
- $attrChange(e2) {
215
- if ("value" === e2) {
216
- const e3 = this.value;
217
- HTMLElement.prototype.hasAttribute.call(this, p) ? this.$call("$emit", "update:value", e3) : this.$customEvent("input", { bubbles: true, composed: true });
218
- }
219
- this.$customEvent("aui-attr-change", { bubbles: true, composed: true, detail: { attributeName: b.vueAttrName(e2) } });
220
- }
221
- $initAttrs() {
222
- const e2 = this.attributes, t2 = document.createElement("div");
223
- for (let n2 = 0; n2 < e2.length; n2++) {
224
- const o2 = e2[n2];
225
- t2.setAttribute(o2.name, o2.value), this.$isShowProp(b.vueAttrName(o2.name)) || HTMLElement.prototype.removeAttribute.call(this, o2.name), "value" === o2.name && (this.value = o2.value);
226
- }
227
- Object.defineProperty(this, "attributes", { get value() {
228
- return t2.attributes;
229
- }, writable: false }), this[_AuiComponent.shadowSymbol].el = t2;
230
- }
231
- $isShowProp(e2) {
232
- if (b.isVueAttr(e2)) return true;
233
- const t2 = this.$getProp(e2), n2 = t2 == null ? void 0 : t2.show;
234
- return n2;
235
- }
236
- $getProp(e2) {
237
- var _a;
238
- const t2 = b.cache.getAuiVueDefined(this.tagName);
239
- return (((_a = t2 == null ? void 0 : t2.origin) == null ? void 0 : _a.props) || {})[e2];
240
- }
241
- $initVue() {
242
- if (this.__hasVue__) return;
243
- this.__hasVue__ = true;
244
- const t2 = this.tagName.toLowerCase();
245
- b.cache.getAuiVueDefined(t2) && e(b.createVueComponent(t2, this)).mount(this);
246
- }
247
- $needInit() {
248
- return !HTMLElement.prototype.hasAttribute.call(this, p);
249
- }
250
- $bindVue(e2) {
251
- var _a, _b;
252
- if (this[_AuiComponent.shadowSymbol].ref) return;
253
- this[_AuiComponent.shadowSymbol].ref = e2, this.__hasVue__ = true, this.$customEvent("aui-init", { bubbles: false, detail: { code: 0 } });
254
- const t2 = (_b = (_a = b.cache.getAuiVueDefined(this.tagName)) == null ? void 0 : _a.origin) == null ? void 0 : _b.auiInit;
255
- t2 && t2.call(e2);
256
- }
257
- $call(e2, ...t2) {
258
- const n2 = this[_AuiComponent.shadowSymbol].ref;
259
- return b.$call(n2, e2, ...t2);
260
- }
261
- };
262
- _AuiComponent.shadowSymbol = f;
263
- let AuiComponent = _AuiComponent;
264
- class $ extends HTMLElement {
265
- constructor() {
266
- super();
267
- }
268
- connectedCallback() {
269
- this.style.display = "none";
270
- }
271
- set textContent(e2) {
272
- var _a;
273
- this._name_ ? (_a = this._el_) == null ? void 0 : _a.$textContent(this._name_, e2) : Reflect.set(HTMLElement.prototype, "textContent", e2, this);
274
- }
275
- set innerHTML(e2) {
276
- var _a;
277
- this._name_ ? (_a = this._el_) == null ? void 0 : _a.$innerHTML(this._name_, e2) : Reflect.set(HTMLElement.prototype, "innerHTML", e2, this);
278
- }
279
- prepend(e2) {
280
- var _a;
281
- this._name_ ? (_a = this._el_) == null ? void 0 : _a.$prepend(this._name_, e2) : HTMLElement.prototype.prepend.call(this, e2);
282
- }
283
- appendChild(e2) {
284
- var _a;
285
- return this._name_ ? ((_a = this._el_) == null ? void 0 : _a.$appendChild(this._name_, e2), e2) : HTMLElement.prototype.appendChild.call(this, e2);
286
- }
287
- static $isAuiSlot(e2) {
288
- return !(!e2 || e2.nodeType !== Node.ELEMENT_NODE) && "aui-slot" === e2.tagName.toLowerCase();
289
- }
290
- static $isForAuiSlot(e2) {
291
- return !(!$.$isAuiSlot(e2) || !e2.hasAttribute("for"));
292
- }
293
- $bind(e2) {
294
- this._el_ = e2, this._name_ = this.getAttribute("for") || "default";
295
- }
296
- $replace(e2) {
297
- const t2 = this.getAttribute("name") || "default", n2 = document.createComment(`aui-slot-${t2}-start`), o2 = document.createComment(`aui-slot-${t2}-end`);
298
- e2.$slot(t2, { start: n2, end: o2 }), this.$replaceWith(n2, o2);
299
- }
300
- $replaceWith(...e2) {
301
- var _a;
302
- e2.forEach((e3) => {
303
- var _a2;
304
- (_a2 = this.parentNode) == null ? void 0 : _a2.insertBefore(e3, this);
305
- }), (_a = this.parentNode) == null ? void 0 : _a.removeChild(this);
306
- }
307
- }
308
- const b = { init: () => (b.defineSlot(), b), defineSlot() {
309
- b.defineCustomElement("aui-slot", $);
310
- }, $call(e2, t2, ...n2) {
311
- if (!e2) return new Error("not init");
312
- if (!t2) return e2;
313
- if ("function" == typeof e2[t2]) return e2[t2].call(e2, ...n2);
314
- const o2 = t2.split(".");
315
- let r2 = e2, i2 = null;
316
- const s2 = o2.pop() || "";
317
- for (; i2 = o2.shift(); ) {
318
- if (!Object.prototype.hasOwnProperty.call(r2, i2)) return new Error("no match name");
319
- r2 = r2[i2];
320
- }
321
- return 0 === n2.length ? r2[s2] : (r2[s2] = n2[0], null);
322
- }, formatName: (e2) => e2 ? (e2 = e2.replace(/[A-Z]/g, function(e3) {
323
- return "-" + e3.toLowerCase();
324
- }), d + e2) : "", cache: { defined: {}, getAuiVueDefined: (e2) => (e2 = e2.toLowerCase(), b.cache.defined[e2]), getAuiPropNames(e2) {
325
- var _a;
326
- const t2 = b.cache.getAuiVueDefined(e2), n2 = ((_a = t2 == null ? void 0 : t2.origin) == null ? void 0 : _a.props) || {}, o2 = [];
327
- for (const e3 in n2) o2.push(b.auiAttrName(e3));
328
- return -1 === o2.indexOf(m) && o2.push(m), o2;
329
- }, addHooks(e2, t2) {
330
- e2 = e2.toLowerCase();
331
- const n2 = b.cache.getAuiVueDefined(e2);
332
- n2 ? (n2.hooks = n2.hooks || [], n2.hooks.push(t2)) : b.cache.defined[e2] = { hooks: [t2] };
333
- } }, createExtendComp: (e2) => {
334
- var _a, _b;
335
- return t({ props: { [m]: { type: String }, value: { type: ((_b = (_a = e2.props) == null ? void 0 : _a.value) == null ? void 0 : _b.type) || [String, Number, Array] } }, methods: { $anyToArray: AuiComponent.$anyToArray, $value(...e3) {
336
- const t2 = this.$aui();
337
- if (0 === e3.length) return t2 == null ? void 0 : t2.value;
338
- t2 && (t2.value = e3[0]);
339
- }, $call(e3, ...t2) {
340
- const n2 = this.$aui();
341
- return n2 ? b.$call(n2, e3, ...t2) : null;
342
- }, $aui() {
343
- var _a2;
344
- return (_a2 = this.$el) == null ? void 0 : _a2.parentNode;
345
- } }, data: () => ({}) });
346
- }, patchDefaultProps(e2) {
347
- var _a, _b;
348
- const t2 = (_b = (_a = e2.props) == null ? void 0 : _a.value) == null ? void 0 : _b.type;
349
- return e2.mixins || (e2.mixins = []), e2.mixins.push(b.createExtendComp(e2)), t2;
350
- }, defineAuiComponent(e2, t2, n2) {
351
- var _a, _b;
352
- const o2 = b.patchDefaultProps(n2);
353
- if ((_a = b.cache.defined[e2]) == null ? void 0 : _a.origin) b.cache.defined[e2].origin = n2;
354
- else {
355
- class r2 extends AuiComponent {
356
- constructor() {
357
- super({ valueType: o2 });
358
- }
359
- static get observedAttributes() {
360
- return b.cache.getAuiPropNames(e2);
361
- }
362
- }
363
- b.cache.defined[e2] = { aui: r2, vue: t2, origin: n2, hooks: ((_b = b.cache.defined[e2]) == null ? void 0 : _b.hooks) || [] }, b.defineCustomElement(e2, r2);
364
- }
365
- }, defineCustomElement(e2, t2) {
366
- try {
367
- customElements.define(e2, t2);
368
- } catch (e3) {
369
- }
370
- }, sameComponent(e2, t2) {
371
- if (!Object.prototype.hasOwnProperty.call(t2, "__hmrId")) return false;
372
- const n2 = b.cache.getAuiVueDefined(e2), o2 = n2 == null ? void 0 : n2.origin;
373
- return !!o2 && t2.__hmrId === o2.__hmrId;
374
- }, notifyComponentUpdate(e2) {
375
- document.querySelectorAll(e2).forEach((e3) => {
376
- e3.$forceUpdate();
377
- });
378
- }, define(e2, t2 = true) {
379
- const n2 = b.formatName(e2.name);
380
- if (!n2) return e2;
381
- const o2 = b.cache.getAuiVueDefined(n2);
382
- if (o2 && o2.vue) return (t2 || b.sameComponent(n2, e2)) && (b.defineAuiComponent(n2, o2.vue, e2), b.notifyComponentUpdate(n2)), o2.vue;
383
- const r2 = b.createVueComponent(n2);
384
- return b.defineAuiComponent(n2, r2, e2), r2;
385
- }, createTempSlot(e2) {
386
- const t2 = {};
387
- return Object.keys(e2).forEach((e3) => {
388
- t2[e3] = () => l("aui-slot", { name: e3 });
389
- }), t2;
390
- }, replaceTempSlot(e2, t2) {
391
- Object.keys(t2).forEach((n2) => {
392
- const o2 = e2.querySelector(`aui-slot[name="${n2}"]`);
393
- o2 && ($.prototype.$replace.call(o2, e2), e2.$replaceChildren(n2, t2[n2]));
394
- });
395
- }, createVueComponent(e2, t2) {
396
- const u2 = t2 ? t2.$moveChildren() : { default: [] };
397
- return { setup() {
398
- const h2 = n(), c2 = o(null), d2 = o(null), m2 = r({}), f2 = o(t2 ? b.createTempSlot(u2) : i()), $2 = o(null);
399
- return s(() => {
400
- c2.value && d2.value && d2.value.$bindVue && (d2.value.$bindVue(c2.value), t2 && b.replaceTempSlot(t2, u2), d2.value.addEventListener("aui-attr-change", () => {
401
- d2.value && (m2.value = b.getAuiAttrs(d2.value));
402
- }), d2.value.addEventListener("aui-force-update", () => {
403
- $2.value = null;
404
- }), d2.value.$call("$emit", "update:value", d2.value.value));
405
- }), a(() => {
406
- d2.value && d2.value.$slotReplace();
407
- }), () => {
408
- if (t2 && (d2.value = t2, m2.value = b.getAuiAttrs(t2)), $2.value || ($2.value = b.formatStructure(e2)), !$2.value) return null;
409
- const n2 = l($2.value, { ...h2, ...m2.value, ref: c2 }, f2.value || {});
410
- return t2 ? n2 : l(e2, { ref: d2, [p]: "" }, [n2]);
411
- };
412
- } };
413
- }, getAuiAttrs(e2) {
414
- const t2 = {}, n2 = e2.attributes;
415
- for (let e3 = 0; e3 < n2.length; e3++) {
416
- const o2 = n2[e3];
417
- o2.name === d || b.isVueAttr(o2.name) || (t2[o2.name] = o2.value);
418
- }
419
- return null !== e2.value && (t2.value = e2.value), t2;
420
- }, isVueAttr: (e2) => 0 === e2.indexOf("data-v-"), auiAttrName: (e2) => e2.replace(/([A-Z])/g, (e3) => "-" + e3.toLowerCase()), vueAttrName: (e2) => b.isVueAttr(e2) ? e2 : e2.replace(/-([a-z])/g, (e3, t2) => t2.toUpperCase()), hookStructure(e2, t2) {
421
- b.cache.addHooks(e2, t2);
422
- }, getHookStructure(e2) {
423
- const t2 = b.cache.getAuiVueDefined(e2);
424
- return ((t2 == null ? void 0 : t2.hooks) || []).slice(0);
425
- }, formatStructure(e2) {
426
- const t2 = b.cache.getAuiVueDefined(e2);
427
- if (!(t2 == null ? void 0 : t2.origin)) return null;
428
- let n2 = u({}, t2.origin);
429
- const o2 = b.getHookStructure(e2);
430
- let r2;
431
- for (; r2 = o2.shift(); ) {
432
- const e3 = r2(n2);
433
- e3 && (n2 = e3);
434
- }
435
- return n2;
436
- } }, y = b.init();
437
- export {
438
- AuiComponent,
439
- $ as AuiSlot,
440
- y as default
441
- };
442
- //# sourceMappingURL=core.es.js.map
1
+ import{createApp as e,defineComponent as t,useAttrs as n,shallowRef as o,ref as r,useSlots as i,onMounted as s,h as l}from"vue";import{merge as a}from"ts-deepmerge";var u,h;const c=function(){try{return __AUI_CONFIG__}catch(e){return{tagPrefix:"aui"}}}().tagPrefix||"aui",d="data-v-aui",p="auix",m=/* @__PURE__ */Symbol("shadow"),f=class t extends(h=HTMLElement,u=m,h){constructor(e){super(),this.__hasVue__=!1,this[u]={needHook:!1,slot:{}},this[t.shadowSymbol].options=e||{},this.$initAttrs()}connectedCallback(){this.$needInit()&&(this.$initVue(),this.$needHook(!0))}set innerHTML(e){this.$needHook()?this.$innerHTML("default",e):Reflect.set(HTMLElement.prototype,"innerHTML",e,this)}get innerHTML(){return this.$needHook()?this.$innerHTML("default"):Reflect.get(HTMLElement.prototype,"innerHTML",this)||""}set textContent(e){this.$needHook()?this.$textContent("default",e):Reflect.set(HTMLElement.prototype,"innerHTML",e,this)}get textContent(){return this.$needHook()?this.$textContent("default"):Reflect.get(HTMLElement.prototype,"innerHTML",this)||""}set innerText(e){this.$ignoreLog("innerText"),Reflect.set(HTMLElement.prototype,"innerText",e,this)}set value(e){let n=e;const o=this[t.shadowSymbol].value;let r;this.$isArrayValue()?(n=t.$anyToArray(e),r=JSON.stringify(n)):r=n.toString(),o!==r&&(this[t.shadowSymbol].value=r,this[t.shadowSymbol].el&&this.$attrChange("value"))}get value(){const e=this[t.shadowSymbol].value;return this.$isArrayValue()&&"string"==typeof e?JSON.parse(e):e}prepend(e){if(!this.$needHook())return HTMLElement.prototype.prepend.call(this,e);this.$prepend("default",e)}appendChild(e){return this.$needHook()?this.$appendChild("default",e):HTMLElement.prototype.appendChild.call(this,e)}insertBefore(e,t){return this.$needHook()?this.$insertBefore("default",e,t):HTMLElement.prototype.insertBefore.call(this,e,t)}hasAttribute(e){const n=this[t.shadowSymbol].el;return n?n.hasAttribute(e):HTMLElement.prototype.hasAttribute.call(this,e)}setAttribute(e,n){n=n.toString();const o=this[t.shadowSymbol].el;if(o){if(o.getAttribute(e)===n)return;o.setAttribute(e,n)}this.$isShowProp(b.vueAttrName(e))&&HTMLElement.prototype.setAttribute.call(this,e,n),"value"===e&&o?this.value=o.getAttribute(e):this.$attrChange(e)}getAttribute(e){const n=this[t.shadowSymbol].el;return n?n.getAttribute(e):super.getAttribute(e)}removeAttribute(e){const n=this[t.shadowSymbol].el;n&&n.removeAttribute(e),this.$isShowProp(b.vueAttrName(e))&&HTMLElement.prototype.removeAttribute.call(this,e),this.$attrChange(e)}attributeChangedCallback(e,n,o){const r=this[t.shadowSymbol].el;r&&n!==o&&(this.$isShowProp(b.vueAttrName(e))||HTMLElement.prototype.removeAttribute.call(this,e),r.setAttribute(e,o||""),"value"!==e&&this.$attrChange(e))}static $anyToArray(e){let t=[];if("string"==typeof e){try{const t=JSON.parse(e);if(t instanceof Array)return t}catch(n){}t=e.split(",").filter(e=>!!e&&e.trim())}else e instanceof Array&&(t=e);return t}$resetShadowSymbol(){this[t.shadowSymbol]={needHook:!1,slot:{}}}$customEvent(e,t){this.dispatchEvent(new CustomEvent(e,Object.assign({bubbles:!1,composed:!1,cancelable:!0},t||{})))}$forceUpdate(){let e=null;const n=this[t.shadowSymbol].slot;for(const t in n){const o=this.$slotCollection(n[t]);e||(e={}),e[t]=o}e&&(this[t.shadowSymbol].slotCollection=e),this.$customEvent("aui-force-update")}$slotCollection(e){var t;const{start:n,end:o}=e,r=[];let i;for(;n&&(i=n.nextSibling)&&i!==o;)null==(t=n.parentNode)||t.removeChild(i),r.push(i);return r}$slotReplace(){const e=this[t.shadowSymbol].slotCollection;if(e){delete this[t.shadowSymbol].slotCollection;for(const t in e)this.querySelector(`aui-slot[name="${t}"]`).$replace(this),this.$replaceChildren(t,e[t])}}$textContent(e,...t){if(0===t.length){const t=[],{start:n,end:o}=this.$slot(e)||{};let r=n;for(;r&&(r=r.nextSibling)&&r!==o;)t.push(r.textContent);return t.join("")}return this.$hasSlot()?(this.$replaceChildren(e,[document.createTextNode(t[0]||"")]),""):""}$innerHTML(e,...t){if(0===t.length){const t=[],{start:n,end:o}=this.$slot(e)||{};let r=n;for(;r&&(r=r.nextSibling)&&r!==o;)if(r.outerHTML)t.push(r.outerHTML);else{let e=r.textContent;r instanceof Comment&&(e=`\x3c!--${e}--\x3e`),t.push(e)}return t.join("")}{if(!this.$hasSlot())return"";const n=document.createElement("div");n.innerHTML=t[0]||"";const o=this.$moveChildren(n);this.$replaceChildren(e,o.default)}return""}$prepend(e,t){var n;const{start:o}=this.$slot(e)||{};null==(n=null==o?void 0:o.parentNode)||n.insertBefore(t,o.nextSibling)}$appendChild(e,t){var n;const{end:o}=this.$slot(e)||{};return null==(n=null==o?void 0:o.parentNode)||n.insertBefore(t,o),t}$insertBefore(e,t,n){const{start:o}=this.$slot(e)||{},r=(null==o?void 0:o.parentNode)||this;return n?r===this?HTMLElement.prototype.insertBefore.call(this,t,n):r.insertBefore(t,n):this.appendChild(t),t}$childNodes(e){const t=[],{start:n,end:o}=this.$slot(e)||{};let r=n;for(;r&&(r=r.nextSibling)&&r!==o;)t.push(r);return t}$children(e){const t=[],{start:n,end:o}=this.$slot(e)||{};let r=n;for(;r&&(r=r.nextSibling)&&r!==o;)r instanceof HTMLElement&&t.push(r);return t}$replaceChildren(e,t){var n,o;const{start:r,end:i}=this.$slot(e)||{};let s=null;for(;r&&(s=r.nextSibling)&&s!==i;)null==(n=s.parentNode)||n.removeChild(s);if(i)for(;s=t.shift();)null==(o=i.parentNode)||o.insertBefore(s,i)}$slot(e,n){if(e=e||"default",!n)return this[t.shadowSymbol].slot[e];this[t.shadowSymbol].slot[e]=n}$hasSlot(){return Object.keys(this[t.shadowSymbol].slot).length>0}$needHook(e){return"boolean"==typeof e&&(this[t.shadowSymbol].needHook=e),this[t.shadowSymbol].needHook}$ignoreLog(e){}$moveChildren(e){var t;const n=(e=e||this).childNodes,o={default:[]};for(;n.length>0;){const r=n[0];if(null==(t=r.parentNode)||t.removeChild(r),$.$isForAuiSlot(r)){const t=r.getAttribute("for")||"default";o[t]=o[t]||[];const n=Array.prototype.slice.call(r.childNodes);$.prototype.$bind.call(r,e),o[t].push(...n)}else o.default.push(r)}return o}$isArrayValue(){var e;return(null==(e=this[t.shadowSymbol].options)?void 0:e.valueType)===Array}$attrChange(e){if("value"===e){const e=this.value;HTMLElement.prototype.hasAttribute.call(this,d)?this.$call("$emit","update:value",e):this.$customEvent("input",{bubbles:!0,composed:!0})}this.$customEvent("aui-attr-change",{bubbles:!0,composed:!0,detail:{attributeName:b.vueAttrName(e)}})}$initAttrs(){const e=this.attributes,n=document.createElement("div");for(let t=0;t<e.length;t++){const o=e[t];n.setAttribute(o.name,o.value),this.$isShowProp(b.vueAttrName(o.name))||HTMLElement.prototype.removeAttribute.call(this,o.name),"value"===o.name&&(this.value=o.value)}Object.defineProperty(this,"attributes",{get value(){return n.attributes},writable:!1}),this[t.shadowSymbol].el=n}$isShowProp(e){if(b.isVueAttr(e))return!0;const t=this.$getProp(e);return null==t?void 0:t.show}$getProp(e){var t;const n=b.cache.getAuiVueDefined(this.tagName);return((null==(t=null==n?void 0:n.origin)?void 0:t.props)||{})[e]}$initVue(){if(this.__hasVue__)return;this.__hasVue__=!0;const t=this.tagName.toLowerCase();b.cache.getAuiVueDefined(t)&&e(b.createVueComponent(t,this)).mount(this)}$needInit(){return!HTMLElement.prototype.hasAttribute.call(this,d)}$bindVue(e){var n,o;if(this[t.shadowSymbol].ref)return;this[t.shadowSymbol].ref=e,this.__hasVue__=!0,this.$customEvent("aui-init",{bubbles:!1,detail:{code:0}});const r=null==(o=null==(n=b.cache.getAuiVueDefined(this.tagName))?void 0:n.origin)?void 0:o.auiInit;r&&r.call(e)}$call(e,...n){const o=this[t.shadowSymbol].ref;return b.$call(o,e,...n)}};f.shadowSymbol=m;let v=f;class $ extends HTMLElement{constructor(){super()}connectedCallback(){this.style.display="none"}set textContent(e){var t;this._name_?null==(t=this._el_)||t.$textContent(this._name_,e):Reflect.set(HTMLElement.prototype,"textContent",e,this)}set innerHTML(e){var t;this._name_?null==(t=this._el_)||t.$innerHTML(this._name_,e):Reflect.set(HTMLElement.prototype,"innerHTML",e,this)}prepend(e){var t;this._name_?null==(t=this._el_)||t.$prepend(this._name_,e):HTMLElement.prototype.prepend.call(this,e)}appendChild(e){var t;return this._name_?(null==(t=this._el_)||t.$appendChild(this._name_,e),e):HTMLElement.prototype.appendChild.call(this,e)}static $isAuiSlot(e){return!(!e||e.nodeType!==Node.ELEMENT_NODE)&&"aui-slot"===e.tagName.toLowerCase()}static $isForAuiSlot(e){return!(!$.$isAuiSlot(e)||!e.hasAttribute("for"))}$bind(e){this._el_=e,this._name_=this.getAttribute("for")||"default"}$replace(e){const t=this.getAttribute("name")||"default",n=document.createComment(`aui-slot-${t}-start`),o=document.createComment(`aui-slot-${t}-end`);e.$slot(t,{start:n,end:o}),this.$replaceWith(n,o)}$replaceWith(...e){var t;e.forEach(e=>{var t;null==(t=this.parentNode)||t.insertBefore(e,this)}),null==(t=this.parentNode)||t.removeChild(this)}}const b={init:()=>(b.defineSlot(),b),defineSlot(){b.defineCustomElement("aui-slot",$)},$call(e,t,...n){if(!e)return new Error("not init");if(!t)return e;if("function"==typeof e[t])return e[t].call(e,...n);const o=t.split(".");let r=e,i=null;const s=o.pop()||"";for(;i=o.shift();){if(!Object.prototype.hasOwnProperty.call(r,i))return new Error("no match name");r=r[i]}return 0===n.length?r[s]:(r[s]=n[0],null)},formatName:e=>e?(e=e.replace(/[A-Z]/g,function(e){return"-"+e.toLowerCase()}),c+e):"",cache:{defined:{},getAuiVueDefined:e=>(e=e.toLowerCase(),b.cache.defined[e]),getAuiPropNames(e){var t;const n=b.cache.getAuiVueDefined(e),o=(null==(t=null==n?void 0:n.origin)?void 0:t.props)||{},r=[];for(const i in o)r.push(b.auiAttrName(i));return-1===r.indexOf(p)&&r.push(p),r},addHooks(e,t){e=e.toLowerCase();const n=b.cache.getAuiVueDefined(e);n?(n.hooks=n.hooks||[],n.hooks.push(t)):b.cache.defined[e]={hooks:[t]}}},createExtendComp:e=>{var n,o;return t({props:{[p]:{type:String},value:{type:(null==(o=null==(n=e.props)?void 0:n.value)?void 0:o.type)||[String,Number,Array]}},methods:{$anyToArray:v.$anyToArray,$value(...e){const t=this.$aui();if(0===e.length)return null==t?void 0:t.value;t&&(t.value=e[0])},$call(e,...t){const n=this.$aui();return n?b.$call(n,e,...t):null},$aui(){var e;return null==(e=this.$el)?void 0:e.parentNode}},data:()=>({})})},patchDefaultProps(e){var t,n;const o=null==(n=null==(t=e.props)?void 0:t.value)?void 0:n.type;return e.mixins||(e.mixins=[]),e.mixins.push(b.createExtendComp(e)),o},defineAuiComponent(e,t,n){var o,r;const i=b.patchDefaultProps(n);if(null==(o=b.cache.defined[e])?void 0:o.origin)b.cache.defined[e].origin=n;else{class o extends v{constructor(){super({valueType:i})}static get observedAttributes(){return b.cache.getAuiPropNames(e)}}b.cache.defined[e]={aui:o,vue:t,origin:n,hooks:(null==(r=b.cache.defined[e])?void 0:r.hooks)||[]},b.defineCustomElement(e,o)}},defineCustomElement(e,t){try{customElements.define(e,t)}catch(n){}},sameComponent(e,t){if(!Object.prototype.hasOwnProperty.call(t,"__hmrId"))return!1;const n=b.cache.getAuiVueDefined(e),o=null==n?void 0:n.origin;return!!o&&t.__hmrId===o.__hmrId},notifyComponentUpdate(e){document.querySelectorAll(e).forEach(e=>{e.$forceUpdate()})},define(e,t=!0){const n=b.formatName(e.name);if(!n)return e;const o=b.cache.getAuiVueDefined(n);if(o&&o.vue)return(t||b.sameComponent(n,e))&&(b.defineAuiComponent(n,o.vue,e),b.notifyComponentUpdate(n)),o.vue;const r=b.createVueComponent(n);return b.defineAuiComponent(n,r,e),r},createTempSlot(e){const t={};return Object.keys(e).forEach(n=>{t[n]=()=>l("aui-slot",{name:n,onVnodeMounted(t){const o=t.el;o&&o.$replaceWith&&o.$replaceWith(...e[n])}})}),t},replaceTempSlot(e,t){Object.keys(t).forEach(n=>{const o=e.querySelector(`aui-slot[name="${n}"]`);o&&($.prototype.$replace.call(o,e),e.$replaceChildren(n,t[n]))})},createVueComponent(e,t){const a=t?t.$moveChildren():{default:[]};return{setup(){const u=n(),h=o(null),c=o(null),p=r({}),m=o(t?b.createTempSlot(a):i()),f=o(null);return s(()=>{h.value&&c.value&&c.value.$bindVue&&(c.value.$bindVue(h.value),c.value.addEventListener("aui-attr-change",()=>{c.value&&(p.value=b.getAuiAttrs(c.value))}),c.value.addEventListener("aui-force-update",()=>{f.value=null}),c.value.$call("$emit","update:value",c.value.value))}),()=>{if(t&&(c.value=t,p.value=b.getAuiAttrs(t)),f.value||(f.value=b.formatStructure(e)),!f.value)return null;const n=l(f.value,{...u,...p.value,ref:h},m.value||{});return t?n:l(e,{ref:c,[d]:""},[n])}}}},getAuiAttrs(e){const t={},n=e.attributes;for(let o=0;o<n.length;o++){const e=n[o];e.name===c||b.isVueAttr(e.name)||(t[e.name]=e.value)}return null!==e.value&&(t.value=e.value),t},isVueAttr:e=>0===e.indexOf("data-v-"),auiAttrName:e=>e.replace(/([A-Z])/g,e=>"-"+e.toLowerCase()),vueAttrName:e=>b.isVueAttr(e)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),hookStructure(e,t){b.cache.addHooks(e,t)},getHookStructure(e){const t=b.cache.getAuiVueDefined(e);return((null==t?void 0:t.hooks)||[]).slice(0)},formatStructure(e){const t=b.cache.getAuiVueDefined(e);if(!(null==t?void 0:t.origin))return null;let n=a({},t.origin);const o=b.getHookStructure(e);let r;for(;r=o.shift();){const e=r(n);e&&(n=e)}return n}},y=b.init();export{v as AuiComponent,$ as AuiSlot,y as default};//# sourceMappingURL=core.es.js.map