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