@moser-inc/moser-labs-custom-elements 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -10
- package/dist/external/moser-labs-custom-elements.js +107 -98
- package/dist/moser-labs-custom-elements.js +521 -512
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,30 +10,33 @@ npm i @moser-inc/moser-labs-custom-elements
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
For these custom elements to function properly, you must first authenticate the user with Keycloak
|
|
13
|
+
For these custom elements to function properly, you must first authenticate the user with Keycloak before calling the provided `registerCustomElements` function, passing the Keycloak instance to it.
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import Keycloak from 'keycloak-js';
|
|
17
|
-
import {
|
|
17
|
+
import { registerCustomElements } from '@moser-inc/moser-labs-custom-elements';
|
|
18
18
|
|
|
19
19
|
const keycloak = new Keycloak('/keycloak.json');
|
|
20
20
|
|
|
21
21
|
keycloak.init({ onLoad: 'login-required' }).then((isAuthenticated) => {
|
|
22
22
|
if (!isAuthenticated) return;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
registerCustomElements();
|
|
24
|
+
registerCustomElements({ keycloak });
|
|
26
25
|
});
|
|
27
26
|
```
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
## API
|
|
29
|
+
|
|
30
|
+
In order for the custom elements to use the correct instance for calling API endpoints and getting profile pictures, pass the `apiUri` option to `registerCustomElements`, using an environment variable for it to be dynamic between staging and production. It defaults to using `window.location.origin`.
|
|
30
31
|
|
|
31
32
|
```ts
|
|
32
|
-
|
|
33
|
+
registerCustomElements({ keycloak, apiUri: import.meta.env.VITE_API_URI });
|
|
34
|
+
```
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
registerCustomElements();
|
|
36
|
+
## External
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
When using a Vue + PrimeVue based application, a version of the package is provided that marks these dependencies as external to drastically reduce the bundle size.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { registerCustomElements } from '@moser-inc/moser-labs-custom-elements/external';
|
|
39
42
|
```
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var X = Object.defineProperty;
|
|
2
2
|
var Z = (a, r, s) => r in a ? X(a, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[r] = s;
|
|
3
|
-
var
|
|
3
|
+
var A = (a, r, s) => Z(a, typeof r != "symbol" ? r + "" : r, s);
|
|
4
4
|
import ee from "primevue/config";
|
|
5
5
|
import te from "primevue/tooltip";
|
|
6
|
-
import * as
|
|
7
|
-
import { inject as se, defineComponent as
|
|
6
|
+
import * as B from "vue";
|
|
7
|
+
import { inject as se, defineComponent as M, toRef as b, ref as T, computed as g, openBlock as y, createBlock as D, unref as v, createElementBlock as C, Fragment as R, createVNode as E, withCtx as P, createElementVNode as x, toDisplayString as S, createCommentVNode as I, resolveDirective as oe, withDirectives as ne, createSlots as re, mergeProps as ie, normalizeClass as z, createTextVNode as ae, getCurrentInstance as le, nextTick as ce, render as F, h as ue } from "vue";
|
|
8
8
|
import G from "primevue/button";
|
|
9
9
|
import pe from "primevue/divider";
|
|
10
10
|
import W from "primevue/menu";
|
|
@@ -12,8 +12,8 @@ import { useEventListener as de, useFetch as fe, createEventHook as he } from "@
|
|
|
12
12
|
import me from "primevue/avatar";
|
|
13
13
|
import _e from "primevue/inlinemessage";
|
|
14
14
|
import be from "primevue/progressspinner";
|
|
15
|
-
import { extend as H, isArray as K, camelize as
|
|
16
|
-
const J = Symbol("labs-custom-elements-options"),
|
|
15
|
+
import { extend as H, isArray as K, camelize as O, toNumber as q, hyphenate as L } from "@vue/shared";
|
|
16
|
+
const J = Symbol("labs-custom-elements-options"), $ = () => {
|
|
17
17
|
const a = se(J);
|
|
18
18
|
if (!a)
|
|
19
19
|
throw new Error("useCeOptions(): could not find custom elements options!");
|
|
@@ -21,7 +21,7 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
21
21
|
...a,
|
|
22
22
|
apiUri: a.apiUri || window.location.origin
|
|
23
23
|
};
|
|
24
|
-
}, ve = /* @__PURE__ */
|
|
24
|
+
}, ve = /* @__PURE__ */ M({
|
|
25
25
|
inheritAttrs: !1,
|
|
26
26
|
__name: "LabsAvatar.ce",
|
|
27
27
|
props: {
|
|
@@ -32,53 +32,62 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
32
32
|
shape: { type: null }
|
|
33
33
|
},
|
|
34
34
|
setup(a) {
|
|
35
|
-
const r = a, { apiUri: s } =
|
|
35
|
+
const r = a, { apiUri: s } = $(), t = b(() => r.userId), e = T(), o = g(() => {
|
|
36
36
|
if (!e.value) return;
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
39
|
-
const h =
|
|
37
|
+
const d = e.value.$el;
|
|
38
|
+
if (!d) return;
|
|
39
|
+
const h = d.querySelector("img");
|
|
40
40
|
if (h)
|
|
41
41
|
return h;
|
|
42
|
-
}), n =
|
|
42
|
+
}), n = T(!0);
|
|
43
43
|
de(o, "error", () => n.value = !1);
|
|
44
44
|
const u = b(() => `${s}/api/users/${t.value}/photo`), f = g(() => {
|
|
45
45
|
var i, m;
|
|
46
|
-
const
|
|
47
|
-
return `${
|
|
48
|
-
}),
|
|
46
|
+
const d = ((i = r.firstName) == null ? void 0 : i.charAt(0).toLocaleUpperCase()) ?? "", h = ((m = r.lastName) == null ? void 0 : m.charAt(0).toLocaleUpperCase()) ?? "";
|
|
47
|
+
return `${d}${h}`;
|
|
48
|
+
}), p = g(() => {
|
|
49
49
|
if (!n.value)
|
|
50
50
|
return f.value;
|
|
51
51
|
}), _ = g(() => {
|
|
52
52
|
if (n.value)
|
|
53
53
|
return u.value;
|
|
54
54
|
}), c = g(() => {
|
|
55
|
-
if (!(n.value ||
|
|
55
|
+
if (!(n.value || p.value))
|
|
56
56
|
return "pi-user";
|
|
57
57
|
});
|
|
58
|
-
return (
|
|
58
|
+
return (d, h) => (y(), D(v(me), {
|
|
59
59
|
ref_key: "avatarRef",
|
|
60
60
|
ref: e,
|
|
61
|
-
size:
|
|
62
|
-
shape:
|
|
63
|
-
label:
|
|
61
|
+
size: d.size,
|
|
62
|
+
shape: d.shape,
|
|
63
|
+
label: p.value,
|
|
64
64
|
image: _.value,
|
|
65
65
|
icon: c.value,
|
|
66
66
|
pt: { image: "size-full rounded-inherit object-cover" }
|
|
67
67
|
}, null, 8, ["size", "shape", "label", "image", "icon"]));
|
|
68
68
|
}
|
|
69
|
-
}), ge = "",
|
|
69
|
+
}), ge = "", U = (a, r) => {
|
|
70
70
|
const s = a.__vccOpts || a;
|
|
71
71
|
for (const [t, e] of r)
|
|
72
72
|
s[t] = e;
|
|
73
73
|
return s;
|
|
74
|
-
}, Y = /* @__PURE__ */
|
|
74
|
+
}, Y = /* @__PURE__ */ U(ve, [["styles", [ge]]]), ye = "moser-labs-web", Ae = Object.freeze({
|
|
75
75
|
SUPER_ADMIN: "super-admin",
|
|
76
76
|
TENANT_ADMIN: "tenant-admin"
|
|
77
|
-
}), Ee = { class: "flex flex-col break-words px-5 py-3
|
|
77
|
+
}), Ee = { class: "flex flex-col gap-1 break-words px-5 py-3 leading-tight" }, ke = {
|
|
78
|
+
key: 0,
|
|
79
|
+
class: "text-base font-bold leading-inherit"
|
|
80
|
+
}, we = {
|
|
81
|
+
key: 1,
|
|
82
|
+
class: "text-sm text-color-secondary leading-inherit"
|
|
83
|
+
}, Ce = {
|
|
84
|
+
key: 2,
|
|
85
|
+
class: "text-xs text-color-secondary leading-inherit"
|
|
86
|
+
}, Ne = /* @__PURE__ */ M({
|
|
78
87
|
inheritAttrs: !1,
|
|
79
88
|
__name: "LabsAccount.ce",
|
|
80
89
|
setup(a) {
|
|
81
|
-
const { keycloak: r, apiUri: s } =
|
|
90
|
+
const { keycloak: r, apiUri: s } = $(), t = b(() => r.tokenParsed), e = b(() => {
|
|
82
91
|
var l;
|
|
83
92
|
return ((l = t.value) == null ? void 0 : l.user_id) || "";
|
|
84
93
|
}), o = b(() => {
|
|
@@ -93,7 +102,7 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
93
102
|
}), f = b(() => {
|
|
94
103
|
var l;
|
|
95
104
|
return ((l = t.value) == null ? void 0 : l.job_title) || "";
|
|
96
|
-
}),
|
|
105
|
+
}), p = b(() => {
|
|
97
106
|
var l;
|
|
98
107
|
return ((l = t.value) == null ? void 0 : l.email) || "";
|
|
99
108
|
}), _ = b(() => {
|
|
@@ -102,7 +111,7 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
102
111
|
}), c = b(() => {
|
|
103
112
|
var l;
|
|
104
113
|
return ((l = _.value) == null ? void 0 : l.roles) ?? [];
|
|
105
|
-
}), { SUPER_ADMIN:
|
|
114
|
+
}), { SUPER_ADMIN: d, TENANT_ADMIN: h } = Ae, i = g(() => c.value.includes(d)), m = g(() => c.value.includes(h)), k = g(() => i.value || m.value), w = g(() => [
|
|
106
115
|
{
|
|
107
116
|
label: "Profile",
|
|
108
117
|
icon: "pi-user",
|
|
@@ -112,18 +121,18 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
112
121
|
label: "Admin",
|
|
113
122
|
icon: "pi-shield",
|
|
114
123
|
url: `${s}/admin`,
|
|
115
|
-
visible:
|
|
124
|
+
visible: k.value
|
|
116
125
|
},
|
|
117
126
|
{
|
|
118
127
|
label: "Logout",
|
|
119
128
|
icon: "pi-sign-out",
|
|
120
129
|
command: () => r.logout({ redirectUri: `${s}/login` })
|
|
121
130
|
}
|
|
122
|
-
]),
|
|
131
|
+
]), V = T(), Q = (l) => {
|
|
123
132
|
var N;
|
|
124
|
-
return (N =
|
|
133
|
+
return (N = V.value) == null ? void 0 : N.toggle(l);
|
|
125
134
|
};
|
|
126
|
-
return (l, N) => (
|
|
135
|
+
return (l, N) => (y(), C(R, null, [
|
|
127
136
|
E(v(G), {
|
|
128
137
|
"aria-label": `Signed in as ${u.value} - toggle account menu`,
|
|
129
138
|
"aria-haspopup": "",
|
|
@@ -131,7 +140,7 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
131
140
|
class: "border-0 bg-transparent p-0 text-inherit",
|
|
132
141
|
onClick: Q
|
|
133
142
|
}, {
|
|
134
|
-
default:
|
|
143
|
+
default: P(() => [
|
|
135
144
|
E(Y, {
|
|
136
145
|
"user-id": e.value,
|
|
137
146
|
"first-name": o.value,
|
|
@@ -143,17 +152,17 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
143
152
|
E(v(W), {
|
|
144
153
|
id: "account-menu",
|
|
145
154
|
ref_key: "menuRef",
|
|
146
|
-
ref:
|
|
155
|
+
ref: V,
|
|
147
156
|
"aria-label": "Account",
|
|
148
|
-
model:
|
|
157
|
+
model: w.value,
|
|
149
158
|
popup: "",
|
|
150
159
|
class: "mt-2 w-50"
|
|
151
160
|
}, {
|
|
152
|
-
start:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
161
|
+
start: P(() => [
|
|
162
|
+
x("div", Ee, [
|
|
163
|
+
u.value ? (y(), C("span", ke, S(u.value), 1)) : I("", !0),
|
|
164
|
+
f.value ? (y(), C("span", we, S(f.value), 1)) : I("", !0),
|
|
165
|
+
p.value ? (y(), C("span", Ce, S(p.value), 1)) : I("", !0)
|
|
157
166
|
]),
|
|
158
167
|
E(v(pe), { class: "my-1" })
|
|
159
168
|
]),
|
|
@@ -161,11 +170,11 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
161
170
|
}, 8, ["model"])
|
|
162
171
|
], 64));
|
|
163
172
|
}
|
|
164
|
-
}), xe = "", Le = /* @__PURE__ */
|
|
173
|
+
}), xe = "", Le = /* @__PURE__ */ U(Ne, [["styles", [xe]]]), Pe = ["href"], Se = { class: "text-xs leading-tight" }, Ie = { class: "p-button-label" }, Re = /* @__PURE__ */ M({
|
|
165
174
|
inheritAttrs: !1,
|
|
166
175
|
__name: "LabsAppSwitcher.ce",
|
|
167
176
|
setup(a) {
|
|
168
|
-
const { keycloak: r, apiUri: s } =
|
|
177
|
+
const { keycloak: r, apiUri: s } = $(), { data: t, isFetching: e, error: o } = fe(
|
|
169
178
|
() => `${s}/graphql`,
|
|
170
179
|
{
|
|
171
180
|
async beforeFetch(c) {
|
|
@@ -194,8 +203,8 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
194
203
|
}
|
|
195
204
|
}
|
|
196
205
|
), n = b(() => {
|
|
197
|
-
var c,
|
|
198
|
-
return ((
|
|
206
|
+
var c, d;
|
|
207
|
+
return ((d = (c = t.value) == null ? void 0 : c.tenant) == null ? void 0 : d.apps) ?? [];
|
|
199
208
|
}), u = (c) => c ? {
|
|
200
209
|
EATS: "i-mli-eats-badge",
|
|
201
210
|
ENGAGEMENTS: "i-mli-engagements-badge",
|
|
@@ -212,20 +221,20 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
212
221
|
href: h.url,
|
|
213
222
|
label: h.name,
|
|
214
223
|
icon: u(h.id)
|
|
215
|
-
})),
|
|
224
|
+
})), d = {
|
|
216
225
|
variant: "button",
|
|
217
226
|
href: s,
|
|
218
227
|
label: "Moser Labs Dashboard",
|
|
219
228
|
icon: "pi-arrow-right"
|
|
220
229
|
};
|
|
221
|
-
return [...c,
|
|
222
|
-
}),
|
|
223
|
-
var
|
|
224
|
-
return (
|
|
230
|
+
return [...c, d].filter((h) => !h.hidden);
|
|
231
|
+
}), p = T(), _ = (c) => {
|
|
232
|
+
var d;
|
|
233
|
+
return (d = p.value) == null ? void 0 : d.toggle(c);
|
|
225
234
|
};
|
|
226
|
-
return (c,
|
|
235
|
+
return (c, d) => {
|
|
227
236
|
const h = oe("tooltip");
|
|
228
|
-
return
|
|
237
|
+
return y(), C(R, null, [
|
|
229
238
|
ne(E(v(G), {
|
|
230
239
|
"aria-label": "App Switcher",
|
|
231
240
|
"aria-haspopup": "",
|
|
@@ -246,7 +255,7 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
246
255
|
E(v(W), {
|
|
247
256
|
id: "app-switcher-menu",
|
|
248
257
|
ref_key: "menuRef",
|
|
249
|
-
ref:
|
|
258
|
+
ref: p,
|
|
250
259
|
"aria-label": "Moser labs apps",
|
|
251
260
|
model: f.value,
|
|
252
261
|
popup: "",
|
|
@@ -261,44 +270,44 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
261
270
|
content: "flex flex-col items-center rounded-xl transition-200"
|
|
262
271
|
}
|
|
263
272
|
}, re({
|
|
264
|
-
item:
|
|
265
|
-
|
|
273
|
+
item: P(({ item: i, props: m }) => [
|
|
274
|
+
x("a", ie({
|
|
266
275
|
href: i.href,
|
|
267
276
|
class: ["w-full duration-150 !rounded-inherit !transition-background-color", {
|
|
268
277
|
"flex flex-col gap-2 p-3 text-center text-color-secondary": i.variant === "app",
|
|
269
278
|
"p-button p-button-text w-full rounded-xl color-inherit no-underline": i.variant === "button"
|
|
270
279
|
}]
|
|
271
280
|
}, m.action), [
|
|
272
|
-
i.variant === "app" ? (
|
|
273
|
-
|
|
274
|
-
class:
|
|
281
|
+
i.variant === "app" ? (y(), C(R, { key: 0 }, [
|
|
282
|
+
x("i", {
|
|
283
|
+
class: z([i.icon, "text-5xl"])
|
|
275
284
|
}, null, 2),
|
|
276
|
-
|
|
277
|
-
], 64)) : i.variant === "button" ? (
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
class:
|
|
285
|
+
x("span", Se, S(i.label), 1)
|
|
286
|
+
], 64)) : i.variant === "button" ? (y(), C(R, { key: 1 }, [
|
|
287
|
+
x("span", Ie, S(i.label), 1),
|
|
288
|
+
x("i", {
|
|
289
|
+
class: z([i.icon, "p-button-icon p-button-icon-right"])
|
|
281
290
|
}, null, 2)
|
|
282
|
-
], 64)) :
|
|
291
|
+
], 64)) : I("", !0)
|
|
283
292
|
], 16, Pe)
|
|
284
293
|
]),
|
|
285
294
|
_: 2
|
|
286
295
|
}, [
|
|
287
296
|
v(e) || v(o) ? {
|
|
288
297
|
name: "start",
|
|
289
|
-
fn:
|
|
290
|
-
v(e) ? (
|
|
298
|
+
fn: P(() => [
|
|
299
|
+
v(e) ? (y(), D(v(be), {
|
|
291
300
|
key: 0,
|
|
292
301
|
class: "m-8"
|
|
293
|
-
})) : v(o) ? (
|
|
302
|
+
})) : v(o) ? (y(), D(v(_e), {
|
|
294
303
|
key: 1,
|
|
295
304
|
severity: "error"
|
|
296
305
|
}, {
|
|
297
|
-
default:
|
|
306
|
+
default: P(() => [
|
|
298
307
|
ae(" Unable to load application list ")
|
|
299
308
|
]),
|
|
300
309
|
_: 1
|
|
301
|
-
})) :
|
|
310
|
+
})) : I("", !0)
|
|
302
311
|
]),
|
|
303
312
|
key: "0"
|
|
304
313
|
} : void 0
|
|
@@ -306,9 +315,9 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
306
315
|
], 64);
|
|
307
316
|
};
|
|
308
317
|
}
|
|
309
|
-
}), Te = "", Me = /* @__PURE__ */
|
|
318
|
+
}), Te = "", Me = /* @__PURE__ */ U(Re, [["styles", [Te]]]), Oe = (a) => {
|
|
310
319
|
const r = le(), s = he();
|
|
311
|
-
if (
|
|
320
|
+
if (B.onBeforeUnmount(() => s.trigger(void 0)), !r)
|
|
312
321
|
throw new Error("useCeVueApp(): could not find vue instance!");
|
|
313
322
|
const t = {
|
|
314
323
|
version: "FAKE_APP_FOR_CE",
|
|
@@ -323,7 +332,7 @@ const J = Symbol("labs-custom-elements-options"), D = () => {
|
|
|
323
332
|
return r.appContext.directives[e] = o, t;
|
|
324
333
|
},
|
|
325
334
|
provide(e, o) {
|
|
326
|
-
return
|
|
335
|
+
return B.provide(e, o), t;
|
|
327
336
|
},
|
|
328
337
|
onUnmount(e) {
|
|
329
338
|
s.on(e);
|
|
@@ -347,13 +356,13 @@ const De = (() => {
|
|
|
347
356
|
document.addEventListener(a, e);
|
|
348
357
|
class o extends HTMLElement {
|
|
349
358
|
static withParsedCallback(u, f = "parsed") {
|
|
350
|
-
const { prototype:
|
|
351
|
-
m.disconnect(),
|
|
359
|
+
const { prototype: p } = u, { connectedCallback: _ } = p, c = f + "Callback", d = (i, m, k, w) => {
|
|
360
|
+
m.disconnect(), k.removeEventListener(a, w), h(i);
|
|
352
361
|
}, h = (i) => {
|
|
353
362
|
s.length || requestAnimationFrame(e), s.push([i, c]);
|
|
354
363
|
};
|
|
355
364
|
return Object.defineProperties(
|
|
356
|
-
|
|
365
|
+
p,
|
|
357
366
|
{
|
|
358
367
|
connectedCallback: {
|
|
359
368
|
configurable: !0,
|
|
@@ -364,12 +373,12 @@ const De = (() => {
|
|
|
364
373
|
if (r.set(i, !1), m.readyState === "complete" || t(i))
|
|
365
374
|
h(i);
|
|
366
375
|
else {
|
|
367
|
-
const
|
|
368
|
-
m.addEventListener(a,
|
|
369
|
-
const
|
|
370
|
-
t(i) &&
|
|
376
|
+
const k = () => d(i, w, m, k);
|
|
377
|
+
m.addEventListener(a, k);
|
|
378
|
+
const w = new MutationObserver(() => {
|
|
379
|
+
t(i) && d(i, w, m, k);
|
|
371
380
|
});
|
|
372
|
-
|
|
381
|
+
w.observe(i.parentNode, { childList: !0, subtree: !0 });
|
|
373
382
|
}
|
|
374
383
|
}
|
|
375
384
|
}
|
|
@@ -389,29 +398,29 @@ const De = (() => {
|
|
|
389
398
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
390
399
|
// @__NO_SIDE_EFFECTS__
|
|
391
400
|
function $e(a, r, s) {
|
|
392
|
-
const t =
|
|
393
|
-
class e extends
|
|
401
|
+
const t = M(a);
|
|
402
|
+
class e extends j {
|
|
394
403
|
constructor(n) {
|
|
395
404
|
super(t, n, r, s);
|
|
396
405
|
}
|
|
397
406
|
}
|
|
398
|
-
return
|
|
407
|
+
return A(e, "def", t), e;
|
|
399
408
|
}
|
|
400
409
|
const Ue = typeof HTMLElement < "u" ? De : class {
|
|
401
410
|
};
|
|
402
|
-
class
|
|
411
|
+
class j extends Ue {
|
|
403
412
|
constructor(s, t = {}, e = {}, o) {
|
|
404
413
|
super();
|
|
405
414
|
/**
|
|
406
415
|
* @internal
|
|
407
416
|
*/
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
417
|
+
A(this, "_instance", null);
|
|
418
|
+
A(this, "_connected", !1);
|
|
419
|
+
A(this, "_resolved", !1);
|
|
420
|
+
A(this, "_numberProps", null);
|
|
421
|
+
A(this, "_styles");
|
|
422
|
+
A(this, "_slots");
|
|
423
|
+
A(this, "_ob", null);
|
|
415
424
|
this._def = s, this._props = t, this._config = e, this._config = H(
|
|
416
425
|
{
|
|
417
426
|
shadowRoot: !0
|
|
@@ -454,12 +463,12 @@ class U extends Ue {
|
|
|
454
463
|
const { props: n, styles: u } = e;
|
|
455
464
|
let f;
|
|
456
465
|
if (n && !K(n))
|
|
457
|
-
for (const
|
|
458
|
-
const _ = n[
|
|
459
|
-
(_ === Number || _ && _.type === Number) && (
|
|
466
|
+
for (const p in n) {
|
|
467
|
+
const _ = n[p];
|
|
468
|
+
(_ === Number || _ && _.type === Number) && (p in this._props && (this._props[p] = q(this._props[p])), (f || (f = /* @__PURE__ */ Object.create(null)))[O(p)] = !0);
|
|
460
469
|
}
|
|
461
470
|
this._numberProps = f, o && this._resolveProps(e), this._config.shadowRoot || (this._slots = Array.from(this.children).map(
|
|
462
|
-
(
|
|
471
|
+
(p) => p.cloneNode(!0)
|
|
463
472
|
), this.replaceChildren()), this._applyStyles(u), this._update();
|
|
464
473
|
}, t = this._def.__asyncLoader;
|
|
465
474
|
t ? t().then((e) => s(e, !0)) : s(this._def);
|
|
@@ -468,7 +477,7 @@ class U extends Ue {
|
|
|
468
477
|
const { props: t } = s, e = K(t) ? t : Object.keys(t || {});
|
|
469
478
|
for (const o of Object.keys(this))
|
|
470
479
|
o[0] !== "_" && e.includes(o) && this._setProp(o, this[o], !0, !1);
|
|
471
|
-
for (const o of e.map(
|
|
480
|
+
for (const o of e.map(O))
|
|
472
481
|
Object.defineProperty(this, o, {
|
|
473
482
|
get() {
|
|
474
483
|
return this._getProp(o);
|
|
@@ -480,7 +489,7 @@ class U extends Ue {
|
|
|
480
489
|
}
|
|
481
490
|
_setAttr(s) {
|
|
482
491
|
let t = this.getAttribute(s);
|
|
483
|
-
const e =
|
|
492
|
+
const e = O(s);
|
|
484
493
|
this._numberProps && this._numberProps[e] && (t = q(t)), this._setProp(e, t, !1);
|
|
485
494
|
}
|
|
486
495
|
/**
|
|
@@ -493,7 +502,7 @@ class U extends Ue {
|
|
|
493
502
|
* @internal
|
|
494
503
|
*/
|
|
495
504
|
_setProp(s, t, e = !0, o = !0) {
|
|
496
|
-
t !== this._props[s] && (this._props[s] = t, o && this._instance && this._update(), e && (t === !0 ? this.setAttribute(
|
|
505
|
+
t !== this._props[s] && (this._props[s] = t, o && this._instance && this._update(), e && (t === !0 ? this.setAttribute(L(s), "") : typeof t == "string" || typeof t == "number" ? this.setAttribute(L(s), t + "") : t || this.removeAttribute(L(s))));
|
|
497
506
|
}
|
|
498
507
|
_update() {
|
|
499
508
|
F(this._createVNode(), this._root);
|
|
@@ -504,8 +513,8 @@ class U extends Ue {
|
|
|
504
513
|
const e = (o) => {
|
|
505
514
|
const n = {};
|
|
506
515
|
for (let u = 0, f = o.length; u < f; u++) {
|
|
507
|
-
const
|
|
508
|
-
n[
|
|
516
|
+
const p = o[u];
|
|
517
|
+
n[p.nodeName] = p.nodeValue;
|
|
509
518
|
}
|
|
510
519
|
return n;
|
|
511
520
|
};
|
|
@@ -525,11 +534,11 @@ class U extends Ue {
|
|
|
525
534
|
);
|
|
526
535
|
};
|
|
527
536
|
e.emit = (u, ...f) => {
|
|
528
|
-
o(u, f),
|
|
537
|
+
o(u, f), L(u) !== u && o(L(u), f);
|
|
529
538
|
};
|
|
530
539
|
let n = this;
|
|
531
540
|
for (; n = n && (n.parentNode || n.host); )
|
|
532
|
-
if (n instanceof
|
|
541
|
+
if (n instanceof j) {
|
|
533
542
|
e.parent = n._instance, e.provides = n._instance.provides;
|
|
534
543
|
break;
|
|
535
544
|
}
|