@telia-ace/widget-components-widget-header 1.1.1-rc.1 → 1.1.1-rc.3

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.
@@ -1,88 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),i=require("./index-8e05a7b4.js"),f=require("react");require("react-dom");const j=e=>e==="entering"||e==="entered",S=e=>e==="exiting"||e==="exited",g={fade:{in:"opacity: 1;",out:"opacity: 0;"},"slide-left":{in:"transform: translateX(0);",out:"transform: translateX(-100%);"},"slide-right":{in:"transform: translateX(0);",out:"transform: translateX(100%);"},"slide-up":{in:"transform: translateY(0);",out:"transform: translateY(100%);"},"slide-down":{in:"transform: translateY(0);",out:"transform: translateY(-100%);"},scale:{in:"transform: scale(1);",out:"transform: scale(0);"}},v=["slide-up","slide-down","slide-left","slide-right","scale"],y={compose:(e="exited",t)=>{const{enter:s,exit:u}=t,n=s.transitionKeys.split(" "),d=v.indexOf(n[0])>-1?"transform":"opacity";if(j(e))return n&&n.length>0?i.css`
2
- ${n&&n.length>0&&n.map(a=>g[a]?g[a].in:"")}
3
- transition: ${d} ${s.duration}ms ${s.easing};
4
- `:"";const r=n&&n.length>0&&i.css`
5
- ${n.map(a=>g[a]?g[a].out:"")}
6
- `;if(S(e)){const a=u.transitionKeys.split(" ");return a&&a.length>0&&e==="exiting"?i.css`
7
- ${r};
8
- ${a.map(l=>g[l]?g[l].out:"")}
9
- transition: ${d} ${u.duration}ms ${u.easing};
10
- `:r}},composeViewTransition:(e,t,s)=>{if(t==="slide")return y.compose(e,{enter:{transitionKeys:s==="forth"?"slide-right":"slide-left",duration:500},exit:{transitionKeys:s==="forth"?"slide-left":"slide-right",duration:500}});if(t==="fade")return y.compose(e,{enter:{transitionKeys:"fade",duration:500},exit:{transitionKeys:"fade",duration:500}})},get:e=>g[e]},z=()=>f.useContext(i.ComponentNodeContext),w=()=>{const e=i.useComponentPlatform(),t=z(),[s,u]=f.useState([]),[n,d]=f.useState();return f.useEffect(()=>{if(e&&t){const r=new i.ComponentQuery(e).withId(t.id),a=e.actions(r,t.type||i.uuid());d(a),s!==null&&(s.forEach(l=>{a.dispatch(l.key,l.data).then(c=>l.resolve(c)).catch(c=>l.reject(c))}),u(null))}},[e,t.id]),(r,a)=>s!==null?new Promise((l,c)=>{s.push({key:r,data:a,resolve:l,reject:c})}):n.dispatch(r,a)},C=()=>f.useContext(i.ComponentPropertyContext),N=e=>{const{in:t,mountOnEnter:s=!0,unmountOnExit:u=!0,timeout:n,children:d,transitions:r}=e,l=(()=>{var c,m;if(!(!r||r==="none")){if(typeof r=="string")return{enter:{transitionKeys:r,duration:n?typeof n=="number"?n:n.enter:200,easing:"ease-in"},exit:{transitionKeys:r,duration:n?typeof n=="number"?n:n.exit:200,easing:"ease-out"}};if(typeof r=="object"){const{enter:p,exit:h}=r;return{enter:{transitionKeys:(c=r.enter)==null?void 0:c.type,duration:n?typeof n=="number"?n:n.enter:200,easing:p.easing?p.easing:"ease-in"},exit:{transitionKeys:(m=r.enter)==null?void 0:m.type,duration:n?typeof n=="number"?n:n.enter:200,easing:h.easing?h.easing:"ease-out"}}}}})();return o.jsx(i.Transition,{timeout:{enter:l&&l.enter.duration||0,exit:l&&l.exit.duration||0},in:t,appear:!0,mountOnEnter:s,unmountOnExit:u,onEnter:c=>c.clientHeight,children:c=>d&&d(c,l&&y.compose(c,l))})},T=({node:e})=>{if(!e.symbol)return null;let t;const s=e.symbol.type==="Svg";if(e.symbol.type==="Svg"){const u=parseInt(e.size,10);isNaN(u)||(t=u)}return o.jsx(k,{symbol:e.symbol,svg:s,size:t,backgroundSize:"cover"})},k=i.newStyled(({svg:e,...t})=>o.jsx(i.SymbolBadge,{...t}))`
11
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
12
- ${e=>!e.svg&&i.css`
13
- border-radius: 50%;
14
- overflow: hidden;
15
- `}
16
- `,K=({node:e})=>{const t=e.symbol||{type:"Svg",content:"back"};return o.jsx(i.SymbolBadge,{size:20,symbol:t})},E=({node:e})=>{const t=e.symbol||{type:"Svg",content:"close"},s=parseInt(e==null?void 0:e.size,10)||14;return o.jsx(i.SymbolBadge,{size:s,symbol:t})},q=({node:e})=>{const t=e.symbol||{type:"Svg",content:"minimize"},s=parseInt(e==null?void 0:e.size,10)||20;return o.jsx(i.SymbolBadge,{size:s,symbol:t})},b=({className:e="",...t})=>{const s=w(),{size:u,padding:n,type:d,tooltip:r,show:a=!0}=t;return d==="back"?o.jsx($,{size:u||"64px",padding:n||"10px",children:o.jsx(N,{in:a,timeout:300,transitions:{enter:{type:"scale",easing:"cubic-bezier(.08,.84,.74,1.84)"},exit:{type:"scale",easing:"ease-out"}},children:(l,c)=>o.jsx(x,{title:r,"aria-label":r,animationCss:c,onClick:()=>{s("back")},children:o.jsx(K,{node:t})})})}):a?o.jsxs($,{size:u||"64px",padding:n||"10px",squareRatio:d==="avatar",children:[d==="avatar"&&o.jsx(T,{node:t}),d==="close"&&o.jsx(x,{title:r,"aria-label":r,onClick:()=>{s("close")},children:o.jsx(E,{node:t})}),d==="minimize"&&o.jsx(x,{title:r,"aria-label":r,onClick:()=>{s("minimize")},children:o.jsx(q,{node:t})})]}):null},$=i.newStyled.div`
17
- flex: 1;
18
- max-width: ${e=>e.size};
19
- ${e=>e.squareRatio&&`max-height: ${e.size};`}
20
- text-align: center;
21
- padding: 0 ${e=>e.padding};
22
- && {
23
- box-sizing: content-box;
24
- }
25
-
26
- svg {
27
- vertical-align: middle;
28
- }
29
-
30
- i {
31
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
32
- font-size: ${e=>e.size};
33
- min-width: 1em;
34
- min-height: 1em;
35
- display: inline-block;
36
- }
37
- `,x=i.newStyled.button`
38
- ${e=>!!e.animationCss&&e.animationCss};
39
- background: none;
40
- border: none;
41
- cursor: pointer;
42
- padding: 0;
43
- &:focus-visible {
44
- ${i.borderTabStyle};
45
- border-color: ${e=>{var t,s;return(s=(t=e.theme.accessibility)==null?void 0:t.colors)==null?void 0:s.inactiveText}};
46
- }
47
- `,B=({className:e,...t})=>{const{header:s,tagline:u,route:n,tooltip:d="",actions:r={},textAlign:a="center"}=C(),[l,c]=i.createNodes(r);return l.sort((m,p)=>(m.order||0)-(p.order||0)),c.sort((m,p)=>(m.order||0)-(p.order||0)),o.jsxs(P,{...t,className:i.appendClassNames(e,"humany-widget-header"),children:[l.map((m,p)=>o.jsx(b,{...m},`${m.type}+_${p}`)),o.jsxs(D,{textAlign:a,margin:i.calculateMargin(l,c,a),children:[n?o.jsx(I,{routeName:n,title:d,"aria-label":d,children:o.jsx(i.Typography,{variant:"h1",children:s})}):o.jsx(i.Typography,{variant:"h1",children:s}),u&&o.jsx(A,{children:u})]}),c.map((m,p)=>o.jsx(b,{...m},`${m.type}+_${p}`))]})},P=i.newStyled.div`
48
- display: flex;
49
- flex-direction: row;
50
- align-items: center;
51
-
52
- ${e=>{var t,s;return i.headingElement(e)("h1",i.css`
53
- font-size: ${(t=e.theme.fonts)==null?void 0:t.huge};
54
- margin: 0;
55
- font-weight: 300;
56
- color: ${(s=e.theme.colors)==null?void 0:s.text};
57
- `)}}
58
-
59
- p {
60
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
61
- margin: 0;
62
- }
63
-
64
- svg {
65
- line,
66
- path,
67
- circle {
68
- stroke: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
69
- }
70
- }
71
- `,A=i.newStyled.p`
72
- font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
73
- font-weight: 300;
74
- `,D=i.newStyled.div`
75
- flex: 1;
76
- text-align: ${e=>e.textAlign};
77
-
78
- margin-right: ${e=>e.margin.right||0};
79
- margin-left: ${e=>e.margin.left||0};
80
- `,I=i.newStyled(i.Link)`
81
- text-decoration: none;
82
- &:focus-visible {
83
- ${e=>i.headingElement(e)("h1",i.css`
84
- ${i.linkTabStyle(e)}
85
- display: inline-block;
86
- `)}
87
- }
88
- `;exports.default=B;
@@ -1,362 +0,0 @@
1
- import { jsx as a, jsxs as x } from "react/jsx-runtime";
2
- import { c as f, C as k, u as K, a as T, b as E, d as j, T as A, n as g, S as h, e as P, f as B, g as D, h as I, i as v, j as w, L as W, l as X } from "./index-addbd6d9.mjs";
3
- import { useContext as N, useState as z, useEffect as Y } from "react";
4
- import "react-dom";
5
- const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting" || t === "exited", p = {
6
- fade: {
7
- in: "opacity: 1;",
8
- out: "opacity: 0;"
9
- },
10
- "slide-left": {
11
- in: "transform: translateX(0);",
12
- out: "transform: translateX(-100%);"
13
- },
14
- "slide-right": {
15
- in: "transform: translateX(0);",
16
- out: "transform: translateX(100%);"
17
- },
18
- "slide-up": {
19
- in: "transform: translateY(0);",
20
- out: "transform: translateY(100%);"
21
- },
22
- "slide-down": {
23
- in: "transform: translateY(0);",
24
- out: "transform: translateY(-100%);"
25
- },
26
- scale: {
27
- in: "transform: scale(1);",
28
- out: "transform: scale(0);"
29
- }
30
- }, M = ["slide-up", "slide-down", "slide-left", "slide-right", "scale"], b = {
31
- compose: (t = "exited", e) => {
32
- const { enter: i, exit: c } = e, n = i.transitionKeys.split(" "), m = M.indexOf(n[0]) > -1 ? "transform" : "opacity";
33
- if (q(t))
34
- return n && n.length > 0 ? f`
35
- ${n && n.length > 0 && n.map((s) => p[s] ? p[s].in : "")}
36
- transition: ${m} ${i.duration}ms ${i.easing};
37
- ` : "";
38
- const r = n && n.length > 0 && f`
39
- ${n.map((s) => p[s] ? p[s].out : "")}
40
- `;
41
- if (L(t)) {
42
- const s = c.transitionKeys.split(" ");
43
- return s && s.length > 0 && t === "exiting" ? f`
44
- ${r};
45
- ${s.map((o) => p[o] ? p[o].out : "")}
46
- transition: ${m} ${c.duration}ms ${c.easing};
47
- ` : r;
48
- }
49
- },
50
- composeViewTransition: (t, e, i) => {
51
- if (e === "slide")
52
- return b.compose(t, {
53
- enter: {
54
- transitionKeys: i === "forth" ? "slide-right" : "slide-left",
55
- duration: 500
56
- },
57
- exit: {
58
- transitionKeys: i === "forth" ? "slide-left" : "slide-right",
59
- duration: 500
60
- }
61
- });
62
- if (e === "fade")
63
- return b.compose(t, {
64
- enter: {
65
- transitionKeys: "fade",
66
- duration: 500
67
- },
68
- exit: {
69
- transitionKeys: "fade",
70
- duration: 500
71
- }
72
- });
73
- },
74
- get: (t) => p[t]
75
- }, O = () => N(k), H = () => {
76
- const t = K(), e = O(), [i, c] = z([]), [n, m] = z();
77
- return Y(() => {
78
- if (t && e) {
79
- const r = new T(t).withId(e.id), s = t.actions(r, e.type || E());
80
- m(s), i !== null && (i.forEach((o) => {
81
- s.dispatch(o.key, o.data).then((l) => o.resolve(l)).catch((l) => o.reject(l));
82
- }), c(null));
83
- }
84
- }, [t, e.id]), (r, s) => i !== null ? new Promise((o, l) => {
85
- i.push({
86
- key: r,
87
- data: s,
88
- resolve: o,
89
- reject: l
90
- });
91
- }) : n.dispatch(r, s);
92
- }, Q = () => N(j), R = (t) => {
93
- const {
94
- in: e,
95
- mountOnEnter: i = !0,
96
- unmountOnExit: c = !0,
97
- timeout: n,
98
- children: m,
99
- transitions: r
100
- } = t, o = (() => {
101
- var l, u;
102
- if (!(!r || r === "none")) {
103
- if (typeof r == "string")
104
- return {
105
- enter: {
106
- transitionKeys: r,
107
- duration: n ? typeof n == "number" ? n : n.enter : 200,
108
- easing: "ease-in"
109
- },
110
- exit: {
111
- transitionKeys: r,
112
- duration: n ? typeof n == "number" ? n : n.exit : 200,
113
- easing: "ease-out"
114
- }
115
- };
116
- if (typeof r == "object") {
117
- const { enter: d, exit: $ } = r;
118
- return {
119
- enter: {
120
- transitionKeys: (l = r.enter) == null ? void 0 : l.type,
121
- duration: n ? typeof n == "number" ? n : n.enter : 200,
122
- easing: d.easing ? d.easing : "ease-in"
123
- },
124
- exit: {
125
- transitionKeys: (u = r.enter) == null ? void 0 : u.type,
126
- duration: n ? typeof n == "number" ? n : n.enter : 200,
127
- easing: $.easing ? $.easing : "ease-out"
128
- }
129
- };
130
- }
131
- }
132
- })();
133
- return /* @__PURE__ */ a(
134
- A,
135
- {
136
- timeout: {
137
- enter: o && o.enter.duration || 0,
138
- exit: o && o.exit.duration || 0
139
- },
140
- in: e,
141
- appear: !0,
142
- mountOnEnter: i,
143
- unmountOnExit: c,
144
- onEnter: (l) => l.clientHeight,
145
- children: (l) => m && m(l, o && b.compose(l, o))
146
- }
147
- );
148
- }, _ = ({ node: t }) => {
149
- if (!t.symbol)
150
- return null;
151
- let e;
152
- const i = t.symbol.type === "Svg";
153
- if (t.symbol.type === "Svg") {
154
- const c = parseInt(t.size, 10);
155
- isNaN(c) || (e = c);
156
- }
157
- return /* @__PURE__ */ a(V, { symbol: t.symbol, svg: i, size: e, backgroundSize: "cover" });
158
- }, V = g(({ svg: t, ...e }) => /* @__PURE__ */ a(h, { ...e }))`
159
- color: ${(t) => {
160
- var e;
161
- return (e = t.theme.colors) == null ? void 0 : e.text;
162
- }};
163
- ${(t) => !t.svg && f`
164
- border-radius: 50%;
165
- overflow: hidden;
166
- `}
167
- `, F = ({ node: t }) => {
168
- const e = t.symbol || { type: "Svg", content: "back" };
169
- return /* @__PURE__ */ a(h, { size: 20, symbol: e });
170
- }, G = ({ node: t }) => {
171
- const e = t.symbol || { type: "Svg", content: "close" }, i = parseInt(t == null ? void 0 : t.size, 10) || 14;
172
- return /* @__PURE__ */ a(h, { size: i, symbol: e });
173
- }, J = ({ node: t }) => {
174
- const e = t.symbol || { type: "Svg", content: "minimize" }, i = parseInt(t == null ? void 0 : t.size, 10) || 20;
175
- return /* @__PURE__ */ a(h, { size: i, symbol: e });
176
- }, C = ({ className: t = "", ...e }) => {
177
- const i = H(), { size: c, padding: n, type: m, tooltip: r, show: s = !0 } = e;
178
- return m === "back" ? /* @__PURE__ */ a(S, { size: c || "64px", padding: n || "10px", children: /* @__PURE__ */ a(
179
- R,
180
- {
181
- in: s,
182
- timeout: 300,
183
- transitions: {
184
- enter: {
185
- type: "scale",
186
- easing: "cubic-bezier(.08,.84,.74,1.84)"
187
- },
188
- exit: {
189
- type: "scale",
190
- easing: "ease-out"
191
- }
192
- },
193
- children: (o, l) => /* @__PURE__ */ a(
194
- y,
195
- {
196
- title: r,
197
- "aria-label": r,
198
- animationCss: l,
199
- onClick: () => {
200
- i("back");
201
- },
202
- children: /* @__PURE__ */ a(F, { node: e })
203
- }
204
- )
205
- }
206
- ) }) : s ? /* @__PURE__ */ x(
207
- S,
208
- {
209
- size: c || "64px",
210
- padding: n || "10px",
211
- squareRatio: m === "avatar",
212
- children: [
213
- m === "avatar" && /* @__PURE__ */ a(_, { node: e }),
214
- m === "close" && /* @__PURE__ */ a(
215
- y,
216
- {
217
- title: r,
218
- "aria-label": r,
219
- onClick: () => {
220
- i("close");
221
- },
222
- children: /* @__PURE__ */ a(G, { node: e })
223
- }
224
- ),
225
- m === "minimize" && /* @__PURE__ */ a(
226
- y,
227
- {
228
- title: r,
229
- "aria-label": r,
230
- onClick: () => {
231
- i("minimize");
232
- },
233
- children: /* @__PURE__ */ a(J, { node: e })
234
- }
235
- )
236
- ]
237
- }
238
- ) : null;
239
- }, S = g.div`
240
- flex: 1;
241
- max-width: ${(t) => t.size};
242
- ${(t) => t.squareRatio && `max-height: ${t.size};`}
243
- text-align: center;
244
- padding: 0 ${(t) => t.padding};
245
- && {
246
- box-sizing: content-box;
247
- }
248
-
249
- svg {
250
- vertical-align: middle;
251
- }
252
-
253
- i {
254
- color: ${(t) => {
255
- var e;
256
- return (e = t.theme.colors) == null ? void 0 : e.text;
257
- }};
258
- font-size: ${(t) => t.size};
259
- min-width: 1em;
260
- min-height: 1em;
261
- display: inline-block;
262
- }
263
- `, y = g.button`
264
- ${(t) => !!t.animationCss && t.animationCss};
265
- background: none;
266
- border: none;
267
- cursor: pointer;
268
- padding: 0;
269
- &:focus-visible {
270
- ${P};
271
- border-color: ${(t) => {
272
- var e, i;
273
- return (i = (e = t.theme.accessibility) == null ? void 0 : e.colors) == null ? void 0 : i.inactiveText;
274
- }};
275
- }
276
- `, ot = ({ className: t, ...e }) => {
277
- const {
278
- header: i,
279
- tagline: c,
280
- route: n,
281
- tooltip: m = "",
282
- actions: r = {},
283
- textAlign: s = "center"
284
- } = Q(), [o, l] = B(r);
285
- return o.sort((u, d) => (u.order || 0) - (d.order || 0)), l.sort((u, d) => (u.order || 0) - (d.order || 0)), /* @__PURE__ */ x(U, { ...e, className: D(t, "humany-widget-header"), children: [
286
- o.map((u, d) => /* @__PURE__ */ a(C, { ...u }, `${u.type}+_${d}`)),
287
- /* @__PURE__ */ x(
288
- tt,
289
- {
290
- textAlign: s,
291
- margin: I(o, l, s),
292
- children: [
293
- n ? /* @__PURE__ */ a(et, { routeName: n, title: m, "aria-label": m, children: /* @__PURE__ */ a(v, { variant: "h1", children: i }) }) : /* @__PURE__ */ a(v, { variant: "h1", children: i }),
294
- c && /* @__PURE__ */ a(Z, { children: c })
295
- ]
296
- }
297
- ),
298
- l.map((u, d) => /* @__PURE__ */ a(C, { ...u }, `${u.type}+_${d}`))
299
- ] });
300
- }, U = g.div`
301
- display: flex;
302
- flex-direction: row;
303
- align-items: center;
304
-
305
- ${(t) => {
306
- var e, i;
307
- return w(t)(
308
- "h1",
309
- f`
310
- font-size: ${(e = t.theme.fonts) == null ? void 0 : e.huge};
311
- margin: 0;
312
- font-weight: 300;
313
- color: ${(i = t.theme.colors) == null ? void 0 : i.text};
314
- `
315
- );
316
- }}
317
-
318
- p {
319
- color: ${(t) => {
320
- var e;
321
- return (e = t.theme.colors) == null ? void 0 : e.text;
322
- }};
323
- margin: 0;
324
- }
325
-
326
- svg {
327
- line,
328
- path,
329
- circle {
330
- stroke: ${(t) => {
331
- var e;
332
- return (e = t.theme.colors) == null ? void 0 : e.text;
333
- }};
334
- }
335
- }
336
- `, Z = g.p`
337
- font-size: ${(t) => {
338
- var e;
339
- return (e = t.theme.fonts) == null ? void 0 : e.normal;
340
- }};
341
- font-weight: 300;
342
- `, tt = g.div`
343
- flex: 1;
344
- text-align: ${(t) => t.textAlign};
345
-
346
- margin-right: ${(t) => t.margin.right || 0};
347
- margin-left: ${(t) => t.margin.left || 0};
348
- `, et = g(W)`
349
- text-decoration: none;
350
- &:focus-visible {
351
- ${(t) => w(t)(
352
- "h1",
353
- f`
354
- ${X(t)}
355
- display: inline-block;
356
- `
357
- )}
358
- }
359
- `;
360
- export {
361
- ot as default
362
- };