@telia-ace/widget-components-grid 1.1.1-rc.2 → 1.1.1-rc.4

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/grid-f0087a03.mjs DELETED
@@ -1,549 +0,0 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { css as C, ThemeProvider as se } from "@emotion/react";
3
- import { C as k, u as E, a as j, b as O, c as ie, d as ae, e as M, f as q, g as J, G as Q, h as H, i as Z, j as T, p as ce, k as le, T as ue, l as de, m as me } from "./index-fe430b79.mjs";
4
- import ee, { useContext as L, useState as v, useCallback as pe, useEffect as g, forwardRef as te, useMemo as ne, Suspense as fe } from "react";
5
- import "react-dom";
6
- import { TransitionGroup as he, Transition as ge } from "react-transition-group";
7
- import w from "@emotion/styled";
8
- import { Switch as be, Route as X } from "react-router";
9
- const ye = (e) => e === "entering" || e === "entered", $e = (e) => e === "exiting" || e === "exited", N = {
10
- fade: {
11
- in: "opacity: 1;",
12
- out: "opacity: 0;"
13
- },
14
- "slide-left": {
15
- in: "transform: translateX(0);",
16
- out: "transform: translateX(-100%);"
17
- },
18
- "slide-right": {
19
- in: "transform: translateX(0);",
20
- out: "transform: translateX(100%);"
21
- },
22
- "slide-up": {
23
- in: "transform: translateY(0);",
24
- out: "transform: translateY(100%);"
25
- },
26
- "slide-down": {
27
- in: "transform: translateY(0);",
28
- out: "transform: translateY(-100%);"
29
- },
30
- scale: {
31
- in: "transform: scale(1);",
32
- out: "transform: scale(0);"
33
- }
34
- }, xe = ["slide-up", "slide-down", "slide-left", "slide-right", "scale"], Y = {
35
- compose: (e = "exited", t) => {
36
- const { enter: n, exit: r } = t, o = n.transitionKeys.split(" "), s = xe.indexOf(o[0]) > -1 ? "transform" : "opacity";
37
- if (ye(e))
38
- return o && o.length > 0 ? C`
39
- ${o && o.length > 0 && o.map((a) => N[a] ? N[a].in : "")}
40
- transition: ${s} ${n.duration}ms ${n.easing};
41
- ` : "";
42
- const i = o && o.length > 0 && C`
43
- ${o.map((a) => N[a] ? N[a].out : "")}
44
- `;
45
- if ($e(e)) {
46
- const a = r.transitionKeys.split(" ");
47
- return a && a.length > 0 && e === "exiting" ? C`
48
- ${i};
49
- ${a.map((c) => N[c] ? N[c].out : "")}
50
- transition: ${s} ${r.duration}ms ${r.easing};
51
- ` : i;
52
- }
53
- },
54
- composeViewTransition: (e, t, n) => {
55
- if (t === "slide")
56
- return Y.compose(e, {
57
- enter: {
58
- transitionKeys: n === "forth" ? "slide-right" : "slide-left",
59
- duration: 500
60
- },
61
- exit: {
62
- transitionKeys: n === "forth" ? "slide-left" : "slide-right",
63
- duration: 500
64
- }
65
- });
66
- if (t === "fade")
67
- return Y.compose(e, {
68
- enter: {
69
- transitionKeys: "fade",
70
- duration: 500
71
- },
72
- exit: {
73
- transitionKeys: "fade",
74
- duration: 500
75
- }
76
- });
77
- },
78
- get: (e) => N[e]
79
- }, U = (e = {}) => (Object.keys(e).forEach((t) => {
80
- (e[t] === null || typeof e[t] > "u") && delete e[t];
81
- }), e), oe = () => L(k), B = (e, t) => ({
82
- id: e.id,
83
- type: e.type,
84
- name: e.name,
85
- branch: t || "default"
86
- }), Ce = () => {
87
- const e = E(), t = j(), [n, r] = v([]), o = O(), s = pe(
88
- (i) => {
89
- if (t && o.current && i) {
90
- const a = t.getBranch(i), c = i.getChildren(a).map((u) => B(u));
91
- r(c);
92
- }
93
- },
94
- [o, t, r, e]
95
- );
96
- return g(() => {
97
- e && s(e);
98
- }, [e, t]), g(() => {
99
- if (t) {
100
- const [i, a] = ie(t.events);
101
- return i("components:set-layout", (c, u) => {
102
- (e === u.node.parent || u.node.parent === t.nodes.root) && s(u.node.parent);
103
- }), i("components:node-appended", (c, u) => {
104
- (e === u.node.parent || u.node.parent === t.nodes.root) && s(u.node.parent);
105
- }), i("components:node-removed", (c, { parentNode: u }) => {
106
- (u === e || u === t.nodes.root) && s(u);
107
- }), () => {
108
- a();
109
- };
110
- }
111
- }, [e, t, s]), n;
112
- }, ve = () => L(ae), we = (e, t) => {
113
- const n = oe(), r = M(), [o, s] = v(void 0), i = O(), a = e || n.type || "";
114
- return g(() => {
115
- if (a) {
116
- let c;
117
- return (t || r).getAsync("componentResolver").then((u) => {
118
- if (i.current) {
119
- const p = u.getComponent(a);
120
- s(p);
121
- }
122
- c = u.registerResolver(a, (p) => {
123
- i.current && s(p);
124
- });
125
- }), () => {
126
- c && c();
127
- };
128
- }
129
- }, [i, a, t, r]), o;
130
- }, Se = (e) => {
131
- const t = E(e), n = j(), [r, o] = v({}), s = O();
132
- return g(() => {
133
- t && s.current && o(t.attributes.layout);
134
- }, [t, s]), g(() => {
135
- if (n) {
136
- const i = n.events.subscribe(
137
- "components:layout-changed",
138
- (a, c) => {
139
- t === c.node && s.current && o(c.node.attributes.layout);
140
- }
141
- );
142
- return () => {
143
- i();
144
- };
145
- }
146
- }, [n, s, t]), r;
147
- }, W = () => L(q), Ne = (e) => {
148
- const t = M(), n = J(), [r, o] = v({ name: "", params: {} }), s = O();
149
- return g(() => {
150
- const i = (e || t).get("$widget");
151
- if (!i)
152
- return;
153
- const { events: a } = i;
154
- return a.subscribe("router:change", (u, { next: { routeData: p } }) => {
155
- if (s.current) {
156
- const { name: d, params: b } = p;
157
- U(b), o({ name: d, params: b });
158
- }
159
- });
160
- }, [s, e, t]), g(() => {
161
- if (n && n.history && s.current) {
162
- const i = n.getRouteData(), { name: a, params: c } = i;
163
- U(c), o({ name: a, params: c });
164
- }
165
- }, [n, s]), r;
166
- };
167
- var F = /* @__PURE__ */ ((e) => (e.back = "back", e.forth = "forth", e))(F || {});
168
- const De = (e, t, n) => typeof n[e] == "number" && typeof n[t] == "number" && n[e] > n[t] ? "back" : "forth", re = ({ views: e, location: t, render: n }) => /* @__PURE__ */ l(
169
- be,
170
- {
171
- location: t && {
172
- ...t,
173
- pathname: t.pathname.split("?")[0]
174
- },
175
- children: [
176
- ...Object.keys(e).filter((r) => !!e[r].path),
177
- ...Object.keys(e).filter((r) => !e[r].path)
178
- ].map((r) => {
179
- const { path: o } = e[r];
180
- return o ? Array.isArray(o) ? o.map((s) => /* @__PURE__ */ l(X, { exact: !0, path: s, render: () => n(r) }, r)) : /* @__PURE__ */ l(X, { exact: !0, path: o, render: () => n(r) }, r) : /* @__PURE__ */ l(X, { render: () => n(r) }, r);
181
- })
182
- }
183
- ), Pe = w.div`
184
- position: relative;
185
- width: 100%;
186
- flex: 1;
187
- `, Ae = w(Q)`
188
- position: absolute;
189
- left: 0;
190
- right: 0;
191
- ${(e) => !!e.animationCss && e.animationCss}
192
- ${(e) => !!e.scrollableCss && e.scrollableCss}
193
- `, Ve = {
194
- index: 1,
195
- search: 2,
196
- browse: 3,
197
- guide: 4,
198
- contact: 5,
199
- "contact-method": 6,
200
- conversation: 7
201
- }, Re = ({ className: e = "", ...t }) => {
202
- const [n, r] = v("index"), [o, s] = v(
203
- F.forth
204
- ), i = Ne(), a = J(), c = W(), u = H(), p = M(), d = E(), { gap: b = "0" } = u, {
205
- columns: D = 1,
206
- animation: x = "none",
207
- scrollable: f = !1,
208
- ...A
209
- } = c, [G, V] = Z(f);
210
- if (!d || !a)
211
- return null;
212
- const { location: _ } = a;
213
- i.name !== n && i.name !== "" && x && (s(
214
- De(n, i.name, Ve)
215
- ), r(i.name));
216
- const { views: y } = p.get("$settings");
217
- if (!Object.keys(y).length)
218
- return null;
219
- const $ = (m, S, P) => {
220
- const h = z(S, P), R = d.getChildren(m)[0];
221
- return /* @__PURE__ */ l(
222
- Ae,
223
- {
224
- ...t,
225
- ...A,
226
- scrollableCss: G,
227
- ref: V,
228
- columns: D,
229
- gap: b,
230
- ...h,
231
- className: T(e, "humany-view"),
232
- children: /* @__PURE__ */ l(I, { id: R.id, branch: "default" })
233
- }
234
- );
235
- }, z = (m, S) => {
236
- if (x === "slide" || x === "fade")
237
- return {
238
- animationCss: Y.composeViewTransition(
239
- m,
240
- x,
241
- S
242
- ),
243
- "data-state": m
244
- };
245
- };
246
- return /* @__PURE__ */ l(Pe, { className: "humany-animated-view", children: /* @__PURE__ */ l(
247
- he,
248
- {
249
- component: null,
250
- childFactory: (m) => ee.cloneElement(m, { direction: o }),
251
- children: /* @__PURE__ */ l(
252
- ge,
253
- {
254
- timeout: { enter: 500, exit: 500 },
255
- onEnter: (m) => m == null ? void 0 : m.clientHeight,
256
- unmountOnExit: !0,
257
- direction: F.forth,
258
- children: (m, { direction: S }) => /* @__PURE__ */ l(
259
- re,
260
- {
261
- views: y,
262
- location: _,
263
- render: (P) => $(P, m, S)
264
- }
265
- )
266
- },
267
- n
268
- )
269
- }
270
- ) });
271
- }, Te = w(Q)`
272
- ${(e) => !!e.scrollableCss && e.scrollableCss}
273
- `, Ee = ({ className: e = "", ...t }) => {
274
- const n = W(), r = H(), o = M(), s = E(), { views: i } = o.get("$settings"), { gap: a = "0" } = r, { columns: c = 1, animation: u = "none", scrollable: p = !1, ...d } = n, [b, D] = Z(p);
275
- return s ? /* @__PURE__ */ l(
276
- Te,
277
- {
278
- ...t,
279
- ...d,
280
- scrollableCss: b,
281
- ref: D,
282
- columns: c,
283
- gap: a,
284
- className: T(e, "humany-view"),
285
- children: /* @__PURE__ */ l(
286
- re,
287
- {
288
- views: i,
289
- render: (x) => {
290
- const f = s.getChildren(x)[0];
291
- return /* @__PURE__ */ l(I, { id: f.id, node: f, branch: "default" });
292
- }
293
- }
294
- )
295
- }
296
- ) : null;
297
- }, K = (e) => {
298
- var t, n;
299
- return C`
300
- outline: none;
301
- box-sizing: border-box;
302
- * {
303
- box-sizing: border-box;
304
- outline: none;
305
- }
306
-
307
- grid-column: ${e["data-indent"] ? `${e["data-indent"] + 1} / ${e["data-indent"] + (e["data-width"] || 0) + 1}` : `span ${e["data-width"]}`};
308
-
309
- ${((t = e.theme.fonts) == null ? void 0 : t.type) && `
310
- font-family: ${e.theme.fonts.type};
311
-
312
- input, textarea {
313
- font-family: ${e.theme.fonts.type};
314
- }
315
- `}
316
-
317
- ${((n = e.theme.fonts) == null ? void 0 : n.base) && `
318
- font-size: ${e.theme.fonts.base};
319
- `}
320
-
321
- &:focus-visible {
322
- ${ce(e)};
323
- }
324
- `;
325
- }, Oe = w(Ee)`
326
- ${(e) => K(e)}
327
- `, Me = w(Re)`
328
- ${(e) => K(e)}
329
- `, je = w.div`
330
- text-align: center;
331
- ${(e) => {
332
- var t, n, r;
333
- return typeof ((t = e.theme.colors) == null ? void 0 : t.warning) < "u" && C`
334
- color: ${(n = e.theme.colors) == null ? void 0 : n.warning};
335
- border: 2px dashed ${(r = e.theme.colors) == null ? void 0 : r.warning};
336
- `;
337
- }}
338
- ${(e) => typeof e.theme.borderRadius < "u" && `border-radius: ${e.theme.borderRadius};`}
339
- ${(e) => K(e)}
340
- `, Ke = te(
341
- ({ className: e = "", children: t, ...n }, r) => {
342
- const o = we(), { name: s, type: i, id: a } = oe(), c = ne(() => o ? w(o)`
343
- ${K}
344
- ${le}
345
- ` : null, [o]);
346
- return typeof o > "u" ? null : o === null || c === null ? process.env.NODE_ENV !== "production" ? /* @__PURE__ */ l(
347
- je,
348
- {
349
- ...n,
350
- title: `type: ${i}, definition-id: ${s}, instance-id: ${a}`,
351
- className: T(e, "humany-non-resolved-component"),
352
- children: /* @__PURE__ */ l(ue, { variant: "h5", children: "Non Resolved Component Type" })
353
- }
354
- ) : null : /* @__PURE__ */ l(fe, { fallback: null, children: /* @__PURE__ */ l(
355
- c,
356
- {
357
- ref: r,
358
- ...n,
359
- className: T(
360
- e,
361
- "humany-component",
362
- `humany-component-${s}`
363
- ),
364
- children: t
365
- }
366
- ) });
367
- }
368
- ), Ge = (e) => {
369
- const t = E(e), n = j(), [r, o] = v({}), s = O();
370
- return g(() => {
371
- t && s.current && o(t.attributes.properties);
372
- }, [t, e, s]), g(() => {
373
- if (n) {
374
- const i = n.events.subscribe(
375
- "components:properties-changed",
376
- (a, c) => {
377
- t === c.node && s.current && o(c.node.attributes.properties);
378
- }
379
- );
380
- return () => {
381
- i();
382
- };
383
- }
384
- }, [n, s, e, t]), r;
385
- }, _e = (e, t) => t ? !0 : typeof e == "string" ? e === "full" : e > 0, I = te(
386
- ({
387
- className: e = "",
388
- id: t,
389
- branch: n,
390
- node: r,
391
- ariaLabel: o,
392
- tabIndex: s,
393
- context: i,
394
- ...a
395
- }, c) => {
396
- const u = j(), p = M(), [d, b] = v(), D = ve(), x = H(t), f = Ge(t), { size: A = "none", indent: G = 0 } = Se(t), V = _e(A, r);
397
- if (g(() => {
398
- if (u) {
399
- if (t && !r) {
400
- const h = u.nodes.get(t);
401
- if (h && (b(B(h, n)), V)) {
402
- const R = h.mount(p);
403
- return () => {
404
- R();
405
- };
406
- }
407
- } else if (r) {
408
- b(B(r, n));
409
- const h = r.mount(p);
410
- return () => {
411
- h();
412
- };
413
- }
414
- }
415
- }, [u, t, r, V]), !d || !V)
416
- return null;
417
- const _ = { ...x, ...i || {} }, {
418
- cardinal: y,
419
- fonts: $ = {},
420
- accessibility: z = {},
421
- ...m
422
- } = _, S = {
423
- type: $.type,
424
- base: $.base || "16px",
425
- small: $.small || "0.8em",
426
- normal: $.normal || "1em",
427
- medium: $.medium || "1.2em",
428
- large: $.large || "1.6em",
429
- huge: $.huge || "2.5em"
430
- }, P = {
431
- ...m,
432
- fonts: S,
433
- accessibility: {
434
- ...z
435
- }
436
- };
437
- return typeof y == "number" && (P.sizes = {
438
- cardinal: y,
439
- small: `${y}px`,
440
- normal: `${y * 3}px`,
441
- medium: `${y * 5}px`,
442
- large: `${y * 8}px`
443
- }), /* @__PURE__ */ l(se, { theme: P, children: /* @__PURE__ */ l(k.Provider, { value: d, children: /* @__PURE__ */ l(q.Provider, { value: f, children: (() => {
444
- const h = {
445
- "data-width": A === "full" ? D : Math.min(A, D),
446
- "data-indent": G,
447
- "data-name": d.name,
448
- "data-node-id": d.id,
449
- "data-component-type": d.type,
450
- "aria-label": o,
451
- tabIndex: s,
452
- id: d.id,
453
- role: f && f.role,
454
- ...a
455
- };
456
- switch (d.type) {
457
- case "view":
458
- return typeof f.animation == "string" && f.animation !== "none" ? /* @__PURE__ */ l(Me, { ...h, className: e }) : /* @__PURE__ */ l(Oe, { ...h, className: e });
459
- default: {
460
- const R = de(f);
461
- return /* @__PURE__ */ l(
462
- Ke,
463
- {
464
- ref: c,
465
- ...h,
466
- ...R,
467
- className: e
468
- }
469
- );
470
- }
471
- }
472
- })() }) }) });
473
- }
474
- );
475
- ee.lazy(() => import("./detached-component-ccd8259a.mjs"));
476
- const ze = (e) => {
477
- const t = e.map((o) => "min-content").join(" "), n = e[0].split(" ").map((o) => "1fr").join(" "), r = e.map((o) => `'${o}'`).join(" ");
478
- return C`
479
- grid-template-columns: ${n};
480
- grid-template-rows: ${t};
481
- grid-template-areas: ${r};
482
- `;
483
- }, Xe = (e) => {
484
- const t = Ce(), n = ne(() => Object.entries(e.areas).map(([r, o]) => {
485
- const s = t.find((i) => i.name === r);
486
- return me(o) ? {
487
- name: r,
488
- componentDef: s,
489
- context: o.context,
490
- areaSettings: o.areaSettings,
491
- template: o.template,
492
- areas: o.areas,
493
- gap: o.gap
494
- } : {
495
- name: r,
496
- componentDef: s,
497
- areaSettings: o.areaSettings,
498
- child: o.child,
499
- context: o.context
500
- };
501
- }), [e, t]);
502
- return /* @__PURE__ */ l(
503
- Ye,
504
- {
505
- "data-grid-area": e.gridArea,
506
- gridArea: e.gridArea,
507
- gap: e.gap,
508
- template: e.template,
509
- className: T(e.className, "humany-grid"),
510
- children: n.map((r) => r.componentDef ? /* @__PURE__ */ l(
511
- I,
512
- {
513
- id: r.componentDef.id,
514
- branch: "default",
515
- context: {}
516
- },
517
- r.componentDef.id
518
- ) : null)
519
- }
520
- );
521
- }, Ye = w.div`
522
- display: grid;
523
- ${(e) => e.gridArea && C`
524
- grid-area: ${e.gridArea};
525
- `}
526
- ${(e) => ze(e.template)}
527
- ${(e) => e.gap && C`
528
- grid-gap: ${e.gap}rem;
529
- `}
530
- `, Be = ({ className: e }) => {
531
- const t = W();
532
- return /* @__PURE__ */ l(
533
- Xe,
534
- {
535
- template: t.template,
536
- areas: t.areas,
537
- gap: t.gap,
538
- areaSettings: t.areaSettings,
539
- context: t.context
540
- }
541
- );
542
- }, Je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
543
- __proto__: null,
544
- default: Be
545
- }, Symbol.toStringTag, { value: "Module" }));
546
- export {
547
- I as C,
548
- Je as g
549
- };