@telia-ace/widget-types-grid 1.0.30-experimental.5 → 1.0.30-experimental.7

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/index.js CHANGED
@@ -1,996 +1,26 @@
1
- var ve = Object.defineProperty, Ee = Object.defineProperties;
2
- var Ce = Object.getOwnPropertyDescriptors;
3
- var G = Object.getOwnPropertySymbols;
4
- var re = Object.prototype.hasOwnProperty, ae = Object.prototype.propertyIsEnumerable;
5
- var ie = (t, e, n) => e in t ? ve(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, p = (t, e) => {
6
- for (var n in e || (e = {}))
7
- re.call(e, n) && ie(t, n, e[n]);
8
- if (G)
9
- for (var n of G(e))
10
- ae.call(e, n) && ie(t, n, e[n]);
11
- return t;
12
- }, C = (t, e) => Ee(t, Ce(e));
13
- var M = (t, e) => {
14
- var n = {};
15
- for (var o in t)
16
- re.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]);
17
- if (t != null && G)
18
- for (var o of G(t))
19
- e.indexOf(o) < 0 && ae.call(t, o) && (n[o] = t[o]);
20
- return n;
21
- };
22
- var ce = (t, e, n) => new Promise((o, s) => {
23
- var i = (a) => {
24
- try {
25
- c(n.next(a));
26
- } catch (l) {
27
- s(l);
28
- }
29
- }, r = (a) => {
30
- try {
31
- c(n.throw(a));
32
- } catch (l) {
33
- s(l);
34
- }
35
- }, c = (a) => a.done ? o(a.value) : Promise.resolve(a.value).then(i, r);
36
- c((n = n.apply(t, e)).next());
37
- });
38
- import { Grid as de, useRouteData as Oe, useRouter as Se, useProperties as he, useContext as ee, useContainer as B, useComponentNode as te, useScroll as me, transitionComposer as Ae, paddedBorderTabStyle as $e, useComponent as xe, useComponentDescriptor as De, filterCssPropsStyle as Me, Typography as Ne, useComponentPlatform as pe, useIsMounted as Le, useColumns as Pe, useLayout as ke, ComponentNodeContext as Re, ComponentPropertyContext as Ve, filterCssProps as _e } from "@telia-ace/widget-ui";
39
- import h, { useState as T, forwardRef as fe, useMemo as Ie, Suspense as Te, useEffect as z } from "react";
40
- import { css as ge, ThemeProvider as ze, useTheme as Be } from "@emotion/react";
41
- import { asDescriptor as J, ComponentPlatform as je, createComponentModel as Fe, ComponentQuery as Ge, WidgetRenderState as O } from "@telia-ace/widget-core";
42
- import k from "@emotion/styled";
43
- import { appendClassNames as K, notifyDataLoaded as We, lock as q, removeNullAndUndefinedValues as le, uuid as He } from "@telia-ace/widget-utilities";
44
- import { TransitionGroup as Ke, Transition as Ue } from "react-transition-group";
45
- import { Switch as Ye, Route as Q } from "react-router";
46
- import { onWidgetUrl as qe } from "@telia-ace/widget-routing";
47
- import { readStorage as N, StorageMedium as v, createStorageWriter as V, StorageCategory as _, StorageScope as Qe } from "@telia-ace/widget-services";
48
- import { supportBootstrapping as Ze } from "@webprovisions/bootstrapping";
49
- import { WidgetState as Je, WidgetType as Xe } from "@webprovisions/platform";
50
- var X = /* @__PURE__ */ ((t) => (t.back = "back", t.forth = "forth", t))(X || {});
51
- const et = (t, e, n) => typeof n[t] == "number" && typeof n[e] == "number" && n[t] > n[e] ? "back" : "forth", tt = ({ views: t, location: e, render: n }) => /* @__PURE__ */ h.createElement(
52
- Ye,
53
- {
54
- location: e && C(p({}, e), {
55
- pathname: e.pathname.split("?")[0]
56
- })
57
- },
58
- [
59
- ...Object.keys(t).filter((o) => !!t[o].path),
60
- ...Object.keys(t).filter((o) => !t[o].path)
61
- ].map((o) => {
62
- const { path: s } = t[o];
63
- return s ? Array.isArray(s) ? s.map((i) => /* @__PURE__ */ h.createElement(Q, { key: o, exact: !0, path: i, render: () => n(o) })) : /* @__PURE__ */ h.createElement(Q, { key: o, exact: !0, path: s, render: () => n(o) }) : /* @__PURE__ */ h.createElement(Q, { key: o, render: () => n(o) });
64
- })
65
- ), ye = tt, nt = k.div`
66
- position: relative;
67
- width: 100%;
68
- flex: 1;
69
- `, ot = k(de)`
70
- position: absolute;
71
- left: 0;
72
- right: 0;
73
- ${(t) => !!t.animationCss && t.animationCss}
74
- ${(t) => !!t.scrollableCss && t.scrollableCss}
75
- `, st = {
76
- index: 1,
77
- search: 2,
78
- browse: 3,
79
- guide: 4,
80
- contact: 5,
81
- "contact-method": 6,
82
- conversation: 7
83
- }, it = (n) => {
84
- var o = n, { className: t = "" } = o, e = M(o, ["className"]);
85
- const [s, i] = T("index"), [r, c] = T(X.forth), a = Oe(), l = Se(), d = he(), u = ee(), f = B(), m = te(), { gap: g = "0" } = u, F = d, { columns: b = 1, animation: y = "none", scrollable: E = !1 } = F, A = M(F, ["columns", "animation", "scrollable"]), [j, L] = me(E);
86
- if (!m || !l)
87
- return null;
88
- const { location: se } = l;
89
- a.name !== s && a.name !== "" && y && (c(et(s, a.name, st)), i(a.name));
90
- const { views: $ } = f.get("$settings");
91
- if (!Object.keys($).length)
92
- return null;
93
- const x = (w, D, R) => {
94
- const S = Y(D, R), I = m.getChildren(w)[0];
95
- return /* @__PURE__ */ h.createElement(
96
- ot,
97
- C(p(C(p(p({}, e), A), {
98
- scrollableCss: j,
99
- ref: L,
100
- columns: b,
101
- gap: g
102
- }), S), {
103
- className: K(t, "humany-view")
104
- }),
105
- /* @__PURE__ */ h.createElement(ne, { id: I.id, branch: "default" })
106
- );
107
- }, Y = (w, D) => {
108
- if (y === "slide" || y === "fade")
109
- return {
110
- animationCss: Ae.composeViewTransition(
111
- w,
112
- y,
113
- D
114
- ),
115
- ["data-state"]: w
116
- };
117
- };
118
- return /* @__PURE__ */ h.createElement(nt, { className: "humany-animated-view" }, /* @__PURE__ */ h.createElement(
119
- Ke,
120
- {
121
- component: null,
122
- childFactory: (w) => h.cloneElement(w, { direction: r })
123
- },
124
- /* @__PURE__ */ h.createElement(
125
- Ue,
126
- {
127
- key: s,
128
- timeout: { enter: 500, exit: 500 },
129
- onEnter: (w) => w == null ? void 0 : w.clientHeight,
130
- unmountOnExit: !0,
131
- direction: X.forth
132
- },
133
- (w, { direction: D }) => /* @__PURE__ */ h.createElement(
134
- ye,
135
- {
136
- views: $,
137
- location: se,
138
- render: (R) => x(R, w, D)
139
- }
140
- )
141
- )
142
- ));
143
- }, rt = it, at = k(de)`
144
- ${(t) => !!t.scrollableCss && t.scrollableCss}
145
- `, ct = (n) => {
146
- var o = n, { className: t = "" } = o, e = M(o, ["className"]);
147
- const s = he(), i = ee(), r = B(), c = te(), { views: a } = r.get("$settings"), { gap: l = "0" } = i, y = s, { columns: d = 1, animation: u = "none", scrollable: f = !1 } = y, m = M(y, ["columns", "animation", "scrollable"]), [g, b] = me(f);
148
- return c ? /* @__PURE__ */ h.createElement(
149
- at,
150
- C(p(p({}, e), m), {
151
- scrollableCss: g,
152
- ref: b,
153
- columns: d,
154
- gap: l,
155
- className: K(t, "humany-view")
156
- }),
157
- /* @__PURE__ */ h.createElement(
158
- ye,
159
- {
160
- views: a,
161
- render: (E) => {
162
- const A = c.getChildren(E)[0];
163
- return /* @__PURE__ */ h.createElement(ne, { id: A.id, node: A, branch: "default" });
164
- }
165
- }
166
- )
167
- ) : null;
168
- }, lt = ct, U = (t) => {
169
- var e, n;
170
- return ge`
171
- outline: none;
172
- box-sizing: border-box;
173
- * {
174
- box-sizing: border-box;
175
- outline: none;
176
- }
177
-
178
- grid-column: ${t["data-indent"] ? `${t["data-indent"] + 1} / ${t["data-indent"] + (t["data-width"] || 0) + 1}` : `span ${t["data-width"]}`};
179
-
180
- ${((e = t.theme.fonts) == null ? void 0 : e.type) && `
181
- font-family: ${t.theme.fonts.type};
182
-
183
- input, textarea {
184
- font-family: ${t.theme.fonts.type};
185
- }
186
- `}
187
-
188
- ${((n = t.theme.fonts) == null ? void 0 : n.base) && `
189
- font-size: ${t.theme.fonts.base};
190
- `}
191
-
192
- &:focus-visible {
193
- ${$e(t)};
194
- }
195
- `;
196
- }, ut = k(lt)`
197
- ${(t) => U(t)}
198
- `, dt = k(rt)`
199
- ${(t) => U(t)}
200
- `, ht = k.div`
201
- text-align: center;
202
- ${(t) => {
203
- var e, n, o;
204
- return typeof ((e = t.theme.colors) == null ? void 0 : e.warning) != "undefined" && ge`
205
- color: ${(n = t.theme.colors) == null ? void 0 : n.warning};
206
- border: 2px dashed ${(o = t.theme.colors) == null ? void 0 : o.warning};
207
- `;
208
- }}
209
- ${(t) => typeof t.theme.borderRadius != "undefined" && `border-radius: ${t.theme.borderRadius};`}
210
- ${(t) => U(t)}
211
- `, mt = fe(
212
- (s, o) => {
213
- var i = s, { className: t = "", children: e } = i, n = M(i, ["className", "children"]);
214
- const r = xe(), { name: c, type: a, id: l } = De(), d = Ie(() => r ? k(r)`
215
- ${U}
216
- ${Me}
217
- ` : null, [r]);
218
- return typeof r == "undefined" ? null : r === null || d === null ? process.env.NODE_ENV !== "production" ? /* @__PURE__ */ h.createElement(
219
- ht,
220
- C(p({}, n), {
221
- title: `type: ${a}, definition-id: ${c}, instance-id: ${l}`,
222
- className: K(t, "humany-non-resolved-component")
223
- }),
224
- /* @__PURE__ */ h.createElement(Ne, { variant: "h5" }, "Non Resolved Component Type")
225
- ) : null : /* @__PURE__ */ h.createElement(Te, { fallback: null }, /* @__PURE__ */ h.createElement(
226
- d,
227
- C(p({
228
- ref: o
229
- }, n), {
230
- className: K(
231
- t,
232
- "humany-component",
233
- `humany-component-${c}`
234
- )
235
- }),
236
- e
237
- ));
238
- }
239
- ), pt = mt, ft = (t) => {
240
- const e = te(t), n = pe(), [o, s] = T({}), i = Le();
241
- return z(() => {
242
- e && i.current && s(e.attributes.properties);
243
- }, [e, t, i]), z(() => {
244
- if (n) {
245
- const r = n.events.subscribe(
246
- "components:properties-changed",
247
- (c, a) => {
248
- e === a.node && i.current && s(a.node.attributes.properties);
249
- }
250
- );
251
- return () => {
252
- r();
253
- };
254
- }
255
- }, [n, i, t, e]), o;
256
- }, gt = (t, e) => e ? !0 : typeof t == "string" ? t === "full" : t > 0, yt = fe(
257
- (l, a) => {
258
- var d = l, { className: t = "", id: e, branch: n, node: o, ariaLabel: s, tabIndex: i, context: r } = d, c = M(d, ["className", "id", "branch", "node", "ariaLabel", "tabIndex", "context"]);
259
- const u = pe(), f = B(), [m, g] = T(), b = Pe(), y = ee(e), E = ft(e), { size: A = "none", indent: j = 0 } = ke(e), L = gt(A, o);
260
- if (z(() => {
261
- if (u) {
262
- if (e && !o) {
263
- const S = u.nodes.get(e);
264
- if (S && (g(J(S, n)), L)) {
265
- const I = S.mount(f);
266
- return () => {
267
- I();
268
- };
269
- }
270
- } else if (o) {
271
- g(J(o, n));
272
- const S = o.mount(f);
273
- return () => {
274
- S();
275
- };
276
- }
277
- }
278
- }, [u, e, o, L]), !m || !L)
279
- return null;
280
- const R = p(p({}, y), r || {}), {
281
- cardinal: $,
282
- fonts: x = {},
283
- accessibility: Y = {}
284
- } = R, F = M(R, [
285
- "cardinal",
286
- "fonts",
287
- "accessibility"
288
- ]), w = {
289
- type: x.type,
290
- base: x.base || "16px",
291
- small: x.small || "0.8em",
292
- normal: x.normal || "1em",
293
- medium: x.medium || "1.2em",
294
- large: x.large || "1.6em",
295
- huge: x.huge || "2.5em"
296
- }, D = C(p({}, F), {
297
- fonts: w,
298
- accessibility: p({}, Y)
299
- });
300
- return typeof $ == "number" && (D.sizes = {
301
- cardinal: $,
302
- small: `${$}px`,
303
- normal: `${$ * 3}px`,
304
- medium: `${$ * 5}px`,
305
- large: `${$ * 8}px`
306
- }), /* @__PURE__ */ h.createElement(ze, { theme: D }, /* @__PURE__ */ h.createElement(Re.Provider, { value: m }, /* @__PURE__ */ h.createElement(Ve.Provider, { value: E }, (() => {
307
- const S = p({
308
- "data-width": A === "full" ? b : Math.min(A, b),
309
- "data-indent": j,
310
- "data-name": m.name,
311
- "data-node-id": m.id,
312
- "data-component-type": m.type,
313
- "aria-label": s,
314
- tabIndex: i,
315
- id: m.id,
316
- role: E && E.role
317
- }, c);
318
- switch (m.type) {
319
- case "view":
320
- return typeof E.animation == "string" && E.animation !== "none" ? /* @__PURE__ */ h.createElement(dt, C(p({}, S), { className: t })) : /* @__PURE__ */ h.createElement(ut, C(p({}, S), { className: t }));
321
- default: {
322
- const I = _e(E);
323
- return /* @__PURE__ */ h.createElement(
324
- pt,
325
- C(p(p({
326
- ref: a
327
- }, S), I), {
328
- className: t
329
- })
330
- );
331
- }
332
- }
333
- })())));
334
- }
335
- ), ne = yt, bt = ({ builder: t }) => {
336
- const e = B(), [n, o] = T(null);
337
- return z(() => {
338
- e.getAsync("components").then((s) => t(s).then((i) => {
339
- o(i);
340
- }));
341
- }, []), z(() => () => {
342
- n && e.getAsync("components").then((s) => {
343
- s.nodes.detached = s.nodes.detached.filter(
344
- (i) => i.id !== n.id
345
- );
346
- });
347
- }, [n]), n ? /* @__PURE__ */ h.createElement(ne, { id: n.id, node: n, branch: "default" }) : null;
348
- }, wt = bt, vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
349
- __proto__: null,
350
- default: wt
351
- }, Symbol.toStringTag, { value: "Module" })), Et = h.lazy(() => Promise.resolve().then(() => vt)), Ct = ({ showSearch: t = !1 }) => {
352
- const e = Be(), n = B();
353
- return /* @__PURE__ */ h.createElement(h.Suspense, { fallback: null }, /* @__PURE__ */ h.createElement(
354
- Et,
355
- {
356
- builder: (o) => n.get("settings").then((s) => {
357
- var l;
358
- const { properties: i, context: r } = Object.keys(s.components).reduce(
359
- (d, u) => (s.components[u].type === "not-found" && (d.properties = s.components[u].properties, d.context = s.components[u].context), d),
360
- { properties: {}, context: {} }
361
- );
362
- i.showSearch = t;
363
- const c = o.createNode("area", { detached: !0 });
364
- if (c.name = "not-found-area", c.writeLayout({
365
- size: "full"
366
- }), t) {
367
- const d = Object.keys(s.components).reduce(
368
- (f, m) => s.components[m].type === "search" ? s.components[m].properties : f,
369
- {}
370
- ), u = o.createNode("search", { detached: !0 });
371
- u.writeLayout({ size: "full" }), u.writeProperties(p({
372
- "css-margin-bottom": ((l = e == null ? void 0 : e.sizes) == null ? void 0 : l.normal) || "15px"
373
- }, d)), c.appendChild(u);
374
- }
375
- const a = o.createNode("not-found", { detached: !0 });
376
- return a.writeLayout({ size: "full" }), a.writeProperties(i), a.writeContext(r), c.appendChild(a), c;
377
- })
378
- }
379
- ));
380
- }, Xt = Ct, Ot = (t) => `w-${t}`, en = (t, e, n) => ce(void 0, null, function* () {
381
- const o = n.nodes.get(t);
382
- if (!e) {
383
- console.warn("Could not find resolver. Make sure it is registered on the container.");
384
- return;
385
- }
386
- if (!o) {
387
- console.warn(`Unable to find node with id: ${t}`);
388
- return;
389
- }
390
- const s = J(o);
391
- if (!(s != null && s.type)) {
392
- console.warn(`Could not get descriptor for: ${o.name}`);
393
- return;
394
- }
395
- const i = Ot(s.type);
396
- if (customElements.get(i))
397
- return;
398
- const r = e.getComponent(s.type);
399
- if (!r) {
400
- console.warn("Component is missing or using incorrect import.");
401
- return;
402
- }
403
- const c = yield r();
404
- if (!customElements.get(i))
405
- try {
406
- customElements.define(i, c.default);
407
- } catch (a) {
408
- console.log("error", a);
409
- }
410
- return customElements.whenDefined(i).then(() => ({
411
- nodeId: t,
412
- tag: i
413
- }));
414
- }), St = (t) => {
415
- if (t) {
416
- const { type: e, content: n } = t;
417
- switch (e) {
418
- case "FontAwesome":
419
- return `<i class="humany-icon fa fa-${n}"></i>`;
420
- case "Uri":
421
- return `<i class="humany-icon humany-custom-icon" style="background: url(${n}) no-repeat center center;background-size: contain;"></i>`;
422
- default:
423
- return "";
424
- }
425
- }
426
- }, At = (t) => {
427
- const e = (s, i) => {
428
- !s || (i ? s.classList.add("humany-tabbing") : s.classList.remove("humany-tabbing"));
429
- }, n = (s) => {
430
- s.key === "Tab" ? e(t, !0) : s.key === "Enter" && document.activeElement && document.activeElement.classList.contains("humany-trigger") || e(t, !1);
431
- }, o = (s) => {
432
- document.activeElement && document.activeElement.classList.contains("humany-trigger") && document.activeElement.classList.contains("humany-tabbing") || e(t, !1);
433
- };
434
- return document.addEventListener("keydown", n), document.addEventListener("click", o), () => {
435
- document.removeEventListener("keydown", n), document.removeEventListener("click", o);
436
- };
437
- };
438
- function $t(t, e) {
439
- const { symbol: n, widgetName: o, label: s = "", ariaLabel: i = "", tooltip: r = "" } = e;
440
- t.classList.add("humany-trigger"), t.classList.add(`humany_${o}`), s.length && t.classList.add("humany-has-text"), i.length && !t.getAttribute("aria-label") && t.setAttribute("aria-label", i), i.length && !t.getAttribute("tabindex") && t.setAttribute("tabindex", "0"), r.length && !t.getAttribute("title") && t.setAttribute("title", r);
441
- const c = St(n) || "";
442
- return t.innerHTML = `${c}
443
- <span class="humany-close">
444
- <svg width="18" height="9" viewBox="0 0 18 9" fill="none" xmlns="http://www.w3.org/2000/svg">
445
- <path d="M9 9C8.81794 9.00045 8.63759 8.96634 8.46939 8.89965C8.3012 8.83295 8.14851 8.735 8.02015 8.61145L0.194523 1.12367C0.068294 0.99862 -0.00155266 0.831133 2.61958e-05 0.657285C0.00160506 0.483436 0.0744832 0.317136 0.202964 0.194202C0.331445 0.0712675 0.505249 0.00153576 0.686941 2.50649e-05C0.868634 -0.00148563 1.04368 0.0653456 1.17437 0.186125L9 7.6739L16.8256 0.186125C16.9563 0.0653456 17.1314 -0.00148563 17.3131 2.50649e-05C17.4948 0.00153576 17.6686 0.0712675 17.797 0.194202C17.9255 0.317136 17.9984 0.483436 18 0.657285C18.0016 0.831133 17.9317 0.99862 17.8055 1.12367L9.97985 8.61145C9.85149 8.735 9.6988 8.83295 9.53061 8.89965C9.36241 8.96634 9.18206 9.00045 9 9Z" fill="white"/>
446
- </svg>
447
- </span>
448
- <span class="humany-loader">
449
- <svg viewBox="25 25 50 50">
450
- <circle
451
- cx="50"
452
- cy="50"
453
- r="20"
454
- fill="none"
455
- stroke="#000"
456
- stroke-width="2"
457
- stroke-miterlimit="10" />
458
- </svg>
459
- </span>
460
- ${s.length ? `<span>${s}</span>` : ""}`, setTimeout(() => t && t.classList.add("humany-rendered")), At(t);
461
- }
462
- function xt(t, e) {
463
- t instanceof HTMLElement ? (e && t.setAttribute("title", e), t.classList.remove("humany-active"), t.classList.remove("humany-loading")) : t instanceof Array && t.forEach((n) => {
464
- e && n.setAttribute("title", e), n.classList.remove("humany-active"), n.classList.remove("humany-loading");
465
- });
466
- }
467
- function Dt(t) {
468
- t instanceof HTMLElement ? (t.classList.remove("humany-active"), t.classList.add("humany-loading")) : t instanceof Array && t.forEach((e) => {
469
- e.classList.remove("humany-active"), e.classList.add("humany-loading");
470
- });
471
- }
472
- function be(t, e) {
473
- t instanceof HTMLElement ? (e && t.setAttribute("title", e), t.classList.add("humany-active"), t.classList.remove("humany-loading")) : t instanceof Array && t.forEach((n) => {
474
- e && n.setAttribute("title", e), n.classList.add("humany-active"), n.classList.remove("humany-loading");
475
- });
476
- }
477
- var P = /* @__PURE__ */ ((t) => (t.Inline = "inline", t.Link = "link", t.Badge = "badge", t.Unsupported = "unsupported", t))(P || {});
478
- const Mt = (t, e) => t && e ? "both" : t ? "widgetDOM" : e ? "triggerDOM" : "none", we = (t) => t ? typeof t == "boolean" && t ? "link" : typeof t == "object" && !Array.isArray(t) ? "badge" : "unsupported" : "inline", Nt = (t, e, n, o, s = !1) => {
479
- var l, d;
480
- const i = Mt(
481
- e,
482
- n
483
- ), r = we(o), c = {
484
- widgetDOMElement: e ? e.cloneNode(!0) : void 0,
485
- triggerDOMElement: n ? n.cloneNode(!0) : void 0
486
- }, a = {
487
- triggerType: r,
488
- cachedOriginals: c,
489
- widgetDOMElement: document.createElement("div")
490
- };
491
- switch (i) {
492
- case "both": {
493
- a.widgetDOMElement = e || document.createElement("div"), r !== "inline" && (a.triggerDOMElement = n);
494
- break;
495
- }
496
- case "widgetDOM": {
497
- if (a.widgetDOMElement = e || document.createElement("div"), r !== "inline") {
498
- const u = document.body.appendChild(document.createElement("a"));
499
- r === "link" && (u.innerText = t), a.triggerDOMElement = u;
500
- }
501
- break;
502
- }
503
- case "triggerDOM": {
504
- const u = document.createElement("div");
505
- a.widgetDOMElement = u, r === "inline" ? (u.id = (n == null ? void 0 : n.id) || "", s ? (u.style.display = "none", (l = n == null ? void 0 : n.parentNode) == null || l.appendChild(u), a.callback = () => {
506
- var f;
507
- (f = n == null ? void 0 : n.parentNode) == null || f.replaceChild(
508
- u,
509
- n
510
- ), u.style.display = (n == null ? void 0 : n.style.display) || "block";
511
- }) : (d = n == null ? void 0 : n.parentNode) == null || d.replaceChild(
512
- u,
513
- n
514
- ), a.cachedOriginals.widgetDOMElement = n, a.cachedOriginals.triggerDOMElement = void 0) : (a.widgetDOMElement = document.body.appendChild(u), a.triggerDOMElement = n);
515
- break;
516
- }
517
- case "none": {
518
- const u = document.body.appendChild(document.createElement("div"));
519
- if (a.widgetDOMElement = u, r !== "inline") {
520
- const f = document.body.appendChild(document.createElement("a"));
521
- r === "link" && (f.innerText = t), a.triggerDOMElement = f;
522
- }
523
- break;
524
- }
525
- }
526
- return a;
527
- }, Lt = "modals";
528
- class Pt {
529
- constructor(e, n) {
530
- this.options = n, this.unsubscribe = [], this.container = e.createChild(this), this.container.register("widgetDOMElement", this.options.widgetDOMElement), this.container.register("triggerDOMElement", this.options.triggerDOMElement);
531
- const o = this.container.get("$widget");
532
- this.options.widgetDOMElement.classList.add("humany-widget"), this.options.widgetDOMElement.classList.add(`humany_${o.name}`);
533
- const s = e.get("widgetDOMElements") || [];
534
- e.register("widgetDOMElements", [
535
- ...s,
536
- this.options.widgetDOMElement
537
- ]);
538
- }
539
- render() {
540
- const { widgetDOMElement: e, triggerDOMElement: n } = this.options, o = this.container.get("$widget");
541
- return e.getAttribute("data-rendered") === "true" ? Promise.resolve() : (n && this.options.triggerType === P.Badge && Dt(n), import("./render.8116b1de.js").then((s) => s.default(o.name, this.container, e)).then(() => {
542
- if (e.setAttribute("data-rendered", "true"), n && this.options.triggerType === P.Badge) {
543
- const i = this.options.triggerOptions.openTooltip;
544
- be(n, i);
545
- }
546
- We(this.container, e);
547
- const s = this.container.get("$environment").widgets.all();
548
- N(
549
- this.container,
550
- Lt,
551
- v.Session
552
- ).then((i) => {
553
- i && i.forEach((r) => {
554
- s.find(
555
- (c) => c.name === r.name && c.state === "activated"
556
- ) && o.events.dispatch("widget:modal-opened", r);
557
- });
558
- });
559
- }));
560
- }
561
- renderBadge(e) {
562
- const { triggerDOMElement: n } = this.options;
563
- if (!n)
564
- return;
565
- n.getAttribute("role") || n.setAttribute("role", "button");
566
- const { name: o } = this.container.get("$widget"), { label: s, symbol: i, ariaLabel: r, closedTooltip: c, openTooltip: a } = e, l = { closedTooltip: c, openTooltip: a };
567
- this.options.triggerOptions = l;
568
- const d = $t(n, {
569
- label: s,
570
- symbol: i,
571
- ariaLabel: r,
572
- widgetName: o,
573
- tooltip: c
574
- });
575
- this.unsubscribe.push(d);
576
- }
577
- dispose() {
578
- return import("./unmount.b0816844.js").then((e) => {
579
- var s, i, r, c;
580
- const { triggerDOMElement: n, widgetDOMElement: o } = this.options;
581
- e.default(o), this.options.cachedOriginals.widgetDOMElement && o && ((s = o.parentNode) == null || s.replaceChild(
582
- this.options.cachedOriginals.widgetDOMElement,
583
- o
584
- )), this.options.cachedOriginals.triggerDOMElement && n && ((i = n.parentNode) == null || i.replaceChild(
585
- this.options.cachedOriginals.triggerDOMElement,
586
- n
587
- )), this.unsubscribe.forEach((a) => {
588
- a();
589
- }), (r = o.parentNode) == null || r.removeChild(o), (c = n == null ? void 0 : n.parentNode) == null || c.removeChild(n);
590
- });
591
- }
592
- }
593
- const W = "changesets", kt = (t) => {
594
- const e = { tags: t.tags };
595
- return t.context && typeof t.context != "function" && (e.context = t.context), t.properties && typeof t.properties != "function" && (e.properties = t.properties), t.layout && typeof t.layout != "function" && (e.layout = t.layout), e;
596
- };
597
- class oe {
598
- constructor(e, n) {
599
- this.container = e, this.storageWriter = n;
600
- }
601
- static create(e) {
602
- return V(e, W, _.Necessary, {
603
- medium: v.Local
604
- }).then((n) => new oe(e, n));
605
- }
606
- write(e, n, o, s) {
607
- return q(this)(() => N(
608
- this.container,
609
- W,
610
- v.Local
611
- ).then((i = {}) => {
612
- const { keys: r = [], items: c = {} } = i, a = r.indexOf(e);
613
- return a > -1 && r.splice(a, 1), r.push(e), c[e] = {
614
- options: s,
615
- attributes: kt(o),
616
- rules: n.rules
617
- }, this.storageWriter({ keys: r, items: c });
618
- }));
619
- }
620
- remove(e) {
621
- return q(this)(() => N(
622
- this.container,
623
- W,
624
- v.Local
625
- ).then((n = {}) => {
626
- const { keys: o = [], items: s = {} } = n, i = o.indexOf(e);
627
- if (i > -1)
628
- return o.splice(i, 1), delete s[e], this.storageWriter(n);
629
- }));
630
- }
631
- load(e) {
632
- return q(this)(() => N(
633
- this.container,
634
- W,
635
- v.Local
636
- ).then((n = {}) => {
637
- const { keys: o = [], items: s = {} } = n;
638
- o.forEach((i) => {
639
- const r = s[i];
640
- if (r) {
641
- const { rules: c, attributes: a, options: l } = r;
642
- e.write({
643
- attributes: a,
644
- options: l,
645
- target: new Ge(e, c)
646
- });
647
- }
648
- });
649
- }));
650
- }
651
- }
652
- const Rt = (t) => {
653
- const { container: e } = t;
654
- return oe.create(e).then((n) => {
655
- const o = e.get("$settings"), s = { localStorage: n }, i = new je(t, s), r = Fe(i, o);
656
- return t.events.subscribe("widget:state-change", (c, a) => {
657
- a.state === Je.Deactivating && r();
658
- }), i;
659
- });
660
- }, Vt = (t) => import("@telia-ace/widget-routing").then(({ RoutingService: e, HistoryMode: n }) => t.get("settings").then((o) => {
661
- const {
662
- routing: { initialPath: s = "/", mode: i = n.scopedHash, basePath: r },
663
- views: c
664
- } = o;
665
- return new e(t, {
666
- initialPath: s,
667
- mode: i,
668
- routes: Object.keys(c).map((l) => ({
669
- name: l,
670
- path: c[l].path
671
- })),
672
- basePath: r
673
- });
674
- })), _t = (t) => import("@telia-ace/widget-services").then(({ StorageProvider: e }) => new e()), It = (t) => import("@telia-ace/widget-core").then(({ ActionResolver: e }) => new e(t)), Tt = (t) => import("@telia-ace/widget-core").then(({ ComponentResolver: e }) => new e(t)), zt = (t) => import("@telia-ace/widget-core").then(({ ComponentPlatform: e, createComponentModel: n }) => Rt(t.get("$widget"))), Z = "$settings", H = "open", ue = "activeStickyWidget";
675
- class tn extends Xe {
676
- constructor(e) {
677
- super(e), this.outlets = /* @__PURE__ */ new Map(), this.activated = void 0, this.subs = [], this.handleBootstrapping = (n) => {
678
- const o = {
679
- triggerDOMElement: n.sourceDOMElement,
680
- withRenderState: "storage"
681
- };
682
- this.container.get("settings").then((s) => {
683
- const { activate: i } = s;
684
- (typeof i == "undefined" || i === null || i === !0) && (this.activated = (this.activated || this.widget.activate()).then(
685
- () => this.attach(o)
686
- ));
687
- });
688
- }, this.container.registerAsync("storage", () => _t(this.container)), this.container.registerFactory("settings", () => N(
689
- this.container,
690
- Z,
691
- v.Local
692
- ).then((n = {}) => p(p({}, this.container.get("$settings")), n))), Ze(this, "load", this.handleBootstrapping), this.container.registerAsync(
693
- "componentResolver",
694
- () => Tt(this.container).then((n) => (this.events.dispatch("widget:component-resolver-registered", { resolver: n }), n))
695
- ), this.container.registerAsync("router", () => Vt(this.container)), this.container.registerAsync("actionResolver", () => It(this.container)), this.container.register("matchMedia", window.matchMedia), this.container.registerAsync("components", () => zt(this.container));
696
- }
697
- initialize() {
698
- const e = this.container.getManyAsync(
699
- "actionResolver",
700
- "router",
701
- "components"
702
- );
703
- return Promise.all([e, this.container.get("settings")]).then(
704
- ([{ actionResolver: n, router: o, components: s }, i]) => {
705
- var a;
706
- n.subscribe(
707
- this.widget.name,
708
- (l, d, u) => this.onAction(d, u)
709
- );
710
- const r = (l) => {
711
- s.nodes.query({ type: "view" }).forEach((d) => {
712
- s.setSwitch(d, l);
713
- });
714
- }, c = ((a = o.getInitialRoute()) == null ? void 0 : a.name) || "index";
715
- return r(c), this.events.subscribe("widget:data-loaded", (l, { element: d }) => {
716
- this.widget.container.get("seoConfiguration") && this.events.dispatch("widget:preloaded-replaced", {
717
- element: d
718
- });
719
- }), this.events.subscribe(
720
- "router:change",
721
- (l, { previous: d = { routeData: {} }, next: u = { routeData: {} } }) => {
722
- const { routeData: f } = d, { routeData: m } = u, g = Object.keys(i.views).reduce((b, y) => typeof i.views[y].path == "undefined" ? y : b, "");
723
- !m.name && g ? r(g) : r(m.name), le(f && f.params), le(m && m.params), this.container.getAsync("actionResolver").then((b) => {
724
- b.action(this.widget.name, "routeChange", {
725
- next: m,
726
- previous: f
727
- });
728
- });
729
- }
730
- ), o.initialize();
731
- }
732
- );
733
- }
734
- attach(e = {}) {
735
- return this.container.get("settings").then(({ trigger: n }) => {
736
- var f, m;
737
- const {
738
- widgetDOMElement: o,
739
- key: s = He(),
740
- triggerDOMElement: i,
741
- withRenderState: r
742
- } = e, a = we(n) === P.Inline && ((i == null ? void 0 : i.childElementCount) || 0) > 0, l = Nt(
743
- this.widget.name,
744
- o,
745
- i,
746
- n,
747
- a
748
- );
749
- this.outlets.size < 1 && !r && this.setRenderState("unset");
750
- const d = () => {
751
- const g = () => b.querySelectorAll("[data-loading=true]").length === 0, [b] = this.widget.container.get("widgetDOMElements"), y = (j, L) => {
752
- g() && (l.callback && l.callback(), L.disconnect());
753
- }, E = {
754
- attributes: !0,
755
- subtree: !0,
756
- childList: !0
757
- };
758
- g() && l.callback && l.callback(), new MutationObserver(y).observe(b, E);
759
- };
760
- a && this.widget.container.getAsync("dataClient").then(({ events: g }) => {
761
- g.subscribe("data-client:fetched", (b, y) => {
762
- y.unresolvedQueries === 0 && d();
763
- });
764
- });
765
- const u = this.getOrCreateViewOutlet(s, l);
766
- if (this.outlets.set(s, u), this.widget.events.dispatch("widget:attached", {}, { bubbles: !0 }), l.triggerType === P.Badge && n && ((f = l.triggerDOMElement) == null || f.setAttribute("aria-expanded", "false"), u == null || u.renderBadge(n)), l.triggerType !== P.Inline && ((m = l.triggerDOMElement) == null || m.addEventListener("click", (g) => {
767
- g.preventDefault(), this.container.get("settings").then(({ trigger: b }) => {
768
- u.render().then(() => this.renderState()).then((y) => b && b.action && b.action === "hide" ? y === O.open ? this.hide() : this.open() : y === O.open ? this.close() : this.open());
769
- });
770
- })), this.outlets.size > 1)
771
- return this.renderState().then((g) => {
772
- this.triggerStateIfApplicable(g);
773
- });
774
- if (r)
775
- return r === "storage" ? this.renderState().then((g) => {
776
- if (l.triggerType === P.Inline) {
777
- this.triggerStateIfApplicable("open");
778
- return;
779
- }
780
- this.triggerStateIfApplicable(g);
781
- }) : this.triggerStateIfApplicable(r);
782
- });
783
- }
784
- detach(e) {
785
- if (e) {
786
- if (this.outlets.has(e)) {
787
- const n = this.outlets.get(e);
788
- n == null || n.dispose(), this.outlets.delete(e);
789
- return;
790
- }
791
- process.env.NODE_ENV !== "production" && console.warn(`detach(): Could not find View Outlet with key ${e}`);
792
- return;
793
- }
794
- this.outlets.forEach((n) => {
795
- n.dispose();
796
- }), this.outlets.clear();
797
- }
798
- triggerStateIfApplicable(e) {
799
- return this.container.getAsync("router").then((n) => {
800
- switch (e) {
801
- case "closed":
802
- this.close();
803
- break;
804
- case "open":
805
- this.open();
806
- break;
807
- case "hidden":
808
- this.hide(), n.start();
809
- break;
810
- default:
811
- return;
812
- }
813
- });
814
- }
815
- getOrCreateViewOutlet(e, n) {
816
- return this.outlets.has(e) ? this.outlets.get(e) : new Pt(this.container, n);
817
- }
818
- render(e = {}) {
819
- if (process.env.NODE_ENV !== "production" && console.warn("widget.render() is deprecated. Use widget.attach() instead."), e.open) {
820
- const n = C(p({}, e), {
821
- withRenderState: "open"
822
- });
823
- return this.attach(n);
824
- }
825
- return this.attach(e);
826
- }
827
- activate(e) {
828
- e != null && e.override && this.setSettings(() => e.override), e != null && e.apiNotificationPriorityBy && this.container.register("apiNotificationPriorityBy", e.apiNotificationPriorityBy);
829
- }
830
- setSettings(e) {
831
- return Promise.all([
832
- this.container.get("settings"),
833
- V(this.container, Z, _.Necessary, {
834
- medium: v.Local
835
- })
836
- ]).then(([n, o]) => Promise.resolve(e(n)).then((s) => o(s).then(() => {
837
- const i = p(p({}, n), s);
838
- return this.widget.events.dispatch("widget:settings-updated", i), i;
839
- })));
840
- }
841
- clearSettings() {
842
- return V(
843
- this.container,
844
- Z,
845
- _.Necessary,
846
- { medium: v.Local }
847
- ).then((e) => e()).then(() => this.container.get("settings")).then((e) => {
848
- this.widget.events.dispatch("widget:settings-updated", e);
849
- });
850
- }
851
- action({ action: e, value: n }) {
852
- return this.container.getAsync("actionResolver").then((o) => {
853
- o.action(this.widget.name, e, n);
854
- });
855
- }
856
- renderState() {
857
- if (qe(this.container))
858
- return Promise.resolve(O.open);
859
- const e = () => N(
860
- this.container,
861
- H,
862
- v.Session
863
- ).then((o = O.closed) => o), n = () => N(
864
- this.container,
865
- H,
866
- v.Session
867
- ).then((o = O.closed) => o);
868
- return this.container.getAsync("router").then((o) => o.isSticky() ? n().then((s) => s === O.open ? s : e()) : e());
869
- }
870
- hide() {
871
- return this.outlets.size < 1 ? (process.env.NODE_ENV !== "production" && console.warn(
872
- "hide(): No-op as no view outlets are registered. Invoke the attach() command first."
873
- ), Promise.resolve()) : (this.outlets.forEach((e) => e.render()), this.action({ action: "hide" }).then(() => {
874
- this.setTriggerState(!1);
875
- }));
876
- }
877
- open() {
878
- return this.outlets.size < 1 ? (process.env.NODE_ENV !== "production" && console.warn(
879
- "open(): No-op as no view outlets are registered. Invoke the attach() command first."
880
- ), Promise.resolve()) : (this.outlets.forEach((e) => e.render()), this.action({ action: "open" }).then(() => (this.widget.events.dispatch("tracking:widget-rendered", {}), this.onOpen())));
881
- }
882
- close() {
883
- return this.outlets.size < 1 ? (process.env.NODE_ENV !== "production" && console.warn(
884
- "close(): No-op as no view outlets are registered. Invoke the attach() command first."
885
- ), Promise.resolve()) : this.action({ action: "close" }).then(() => this.onClose());
886
- }
887
- show() {
888
- return process.env.NODE_ENV !== "production" && console.warn(
889
- "show(): Command is deprecated and will be removed in the future. Use open() instead."
890
- ), this.open();
891
- }
892
- onAction(e, n) {
893
- switch (e) {
894
- case "close":
895
- case "open":
896
- case "hide":
897
- const o = e === "open" ? O.open : e === "close" ? O.closed : O.hidden;
898
- return this.setRenderState(o).then(() => {
899
- this.setTriggerState(o === O.open), o !== O.hidden ? o === O.open ? this.onOpen() : this.onClose() : this.outlets.forEach(
900
- (s) => {
901
- var i;
902
- return (i = s.options.triggerDOMElement) == null ? void 0 : i.setAttribute("aria-expanded", "false");
903
- }
904
- );
905
- });
906
- }
907
- }
908
- setRenderState(e) {
909
- const { invoke: n, events: o } = this.container.get("$widget");
910
- return Promise.all([
911
- V(this.container, H, _.Necessary, {
912
- medium: v.Session
913
- }),
914
- V(this.container, H, _.Necessary, {
915
- medium: v.Local,
916
- duration: { minutes: 5 }
917
- }),
918
- this.container.getAsync("router"),
919
- n("renderState")
920
- ]).then(([s, i, r, c]) => {
921
- e === "unset" || !e ? (i(), s()) : (r.isSticky() && i(e), s(e)), o.dispatch("widget:render-state-changed", {
922
- previous: c,
923
- next: e
924
- });
925
- });
926
- }
927
- onOpen() {
928
- return this.container.getAsync("router").then((e) => (this.outlets.forEach(
929
- (n) => {
930
- var o;
931
- return (o = n.options.triggerDOMElement) == null ? void 0 : o.setAttribute("aria-expanded", "true");
932
- }
933
- ), e.start()));
934
- }
935
- onClose() {
936
- const e = this.container.getManyAsync("router", "components");
937
- return (() => this.container.get("settings").then((o) => {
938
- const { activate: s } = this.container.get("$settings");
939
- return o.activate !== s ? this.setSettings(() => Promise.resolve({ activate: s })) : Promise.resolve();
940
- }))().then(() => e).then(
941
- ({
942
- router: o,
943
- components: s
944
- }) => {
945
- const i = s.nodes.visible;
946
- return this.outlets.forEach(
947
- (r) => {
948
- var c;
949
- return (c = r.options.triggerDOMElement) == null ? void 0 : c.setAttribute("aria-expanded", "false");
950
- }
951
- ), i.filter(
952
- (r) => r.attributes.properties.animation && r.attributes.properties.animation !== "none"
953
- ).length ? new Promise((r) => {
954
- setTimeout(() => {
955
- r(o);
956
- }, 200);
957
- }) : Promise.resolve(o);
958
- }
959
- ).then((o) => o.stop());
960
- }
961
- setTriggerState(e) {
962
- this.outlets.forEach((n) => {
963
- const {
964
- options: { triggerDOMElement: o, triggerOptions: s }
965
- } = n, { openTooltip: i, closedTooltip: r } = s || {};
966
- o && (e ? be(o, i) : xt(o, r));
967
- });
968
- }
969
- deactivate() {
970
- this.subs.forEach((n) => n());
971
- const e = [];
972
- return this.outlets.forEach((n) => e.push(n.dispose())), N(
973
- this.container,
974
- ue,
975
- v.Local
976
- ).then((n) => n === this.widget.name ? V(
977
- this.container,
978
- ue,
979
- _.Necessary,
980
- {
981
- medium: v.Local,
982
- scope: Qe.Implementation
983
- }
984
- ).then((o) => o()).then(() => Promise.all(e)) : Promise.all(e));
985
- }
986
- }
1
+ import { C as D, D as N, a as f, N as h, a as u, W as v, s as x, r as y } from "./index.c6989014.js";
2
+ import "@telia-ace/widget-ui";
3
+ import "react";
4
+ import "@emotion/react";
5
+ import "@telia-ace/widget-core";
6
+ import "@emotion/styled";
7
+ import "@telia-ace/widget-utilities";
8
+ import "react-transition-group";
9
+ import "react-router";
10
+ import "@open-wc/lit-helpers";
11
+ import "lit";
12
+ import "@telia-ace/widget-routing";
13
+ import "@telia-ace/widget-services";
14
+ import "@webprovisions/bootstrapping";
15
+ import "@webprovisions/platform";
987
16
  export {
988
- ne as Component,
989
- wt as DetachedComponent,
990
- tn as GridWidget,
991
- Xt as NotFound,
992
- tn as Widget,
993
- U as genericComponentStyling,
994
- en as resolveComponent
17
+ D as Component,
18
+ N as DetachedComponent,
19
+ f as GridWidget,
20
+ h as NotFound,
21
+ u as Widget,
22
+ v as WidgetComponent,
23
+ x as genericComponentStyling,
24
+ y as resolveComponent
995
25
  };
996
26
  //# sourceMappingURL=index.js.map