@telia-ace/widget-components-widget-header 1.1.1-rc.0 → 1.1.1-rc.2

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/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";const e=require("./index-8e05a7b4.js");require("react/jsx-runtime");require("react");require("react-dom");module.exports=e.WidgetHeaderComponent;
1
+ "use strict";const e=require("./index-f80d12f5.js");require("@emotion/react");require("react/jsx-runtime");require("react");require("@emotion/styled");require("react-transition-group");require("react-dom");require("react-router-dom");module.exports=e.WidgetHeaderComponent;
package/index.mjs CHANGED
@@ -1,7 +1,11 @@
1
- import { W as i } from "./index-addbd6d9.mjs";
1
+ import { W as d } from "./index-8825e52f.mjs";
2
+ import "@emotion/react";
2
3
  import "react/jsx-runtime";
3
4
  import "react";
5
+ import "@emotion/styled";
6
+ import "react-transition-group";
4
7
  import "react-dom";
8
+ import "react-router-dom";
5
9
  export {
6
- i as default
10
+ d as default
7
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-components-widget-header",
3
- "version": "1.1.1-rc.0",
3
+ "version": "1.1.1-rc.2",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -10,10 +10,10 @@
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "@telia-ace/widget-core": "^1.1.1-rc.0",
14
- "@telia-ace/widget-routing": "^1.1.1-rc.0",
15
- "@telia-ace/widget-ui": "^1.1.1-rc.0",
16
- "@telia-ace/widget-utilities": "^1.1.1-rc.0",
13
+ "@telia-ace/widget-core": "^1.1.1-rc.2",
14
+ "@telia-ace/widget-routing": "^1.1.1-rc.2",
15
+ "@telia-ace/widget-ui": "^1.1.1-rc.2",
16
+ "@telia-ace/widget-utilities": "^1.1.1-rc.2",
17
17
  "@webprovisions/platform": "^1.1.4"
18
18
  },
19
19
  "peerDependencies": {
@@ -0,0 +1,88 @@
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,8 +1,12 @@
1
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";
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";
4
6
  import "react-dom";
5
- const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting" || t === "exited", p = {
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 = {
6
10
  fade: {
7
11
  in: "opacity: 1;",
8
12
  out: "opacity: 0;"
@@ -32,17 +36,17 @@ const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting"
32
36
  const { enter: i, exit: c } = e, n = i.transitionKeys.split(" "), m = M.indexOf(n[0]) > -1 ? "transform" : "opacity";
33
37
  if (q(t))
34
38
  return n && n.length > 0 ? f`
35
- ${n && n.length > 0 && n.map((s) => p[s] ? p[s].in : "")}
39
+ ${n && n.length > 0 && n.map((o) => d[o] ? d[o].in : "")}
36
40
  transition: ${m} ${i.duration}ms ${i.easing};
37
41
  ` : "";
38
42
  const r = n && n.length > 0 && f`
39
- ${n.map((s) => p[s] ? p[s].out : "")}
43
+ ${n.map((o) => d[o] ? d[o].out : "")}
40
44
  `;
41
45
  if (L(t)) {
42
- const s = c.transitionKeys.split(" ");
43
- return s && s.length > 0 && t === "exiting" ? f`
46
+ const o = c.transitionKeys.split(" ");
47
+ return o && o.length > 0 && t === "exiting" ? f`
44
48
  ${r};
45
- ${s.map((o) => p[o] ? p[o].out : "")}
49
+ ${o.map((s) => d[s] ? d[s].out : "")}
46
50
  transition: ${m} ${c.duration}ms ${c.easing};
47
51
  ` : r;
48
52
  }
@@ -71,25 +75,25 @@ const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting"
71
75
  }
72
76
  });
73
77
  },
74
- get: (t) => p[t]
78
+ get: (t) => d[t]
75
79
  }, O = () => N(k), H = () => {
76
80
  const t = K(), e = O(), [i, c] = z([]), [n, m] = z();
77
- return Y(() => {
81
+ return X(() => {
78
82
  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));
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));
82
86
  }), c(null));
83
87
  }
84
- }, [t, e.id]), (r, s) => i !== null ? new Promise((o, l) => {
88
+ }, [t, e.id]), (r, o) => i !== null ? new Promise((s, l) => {
85
89
  i.push({
86
90
  key: r,
87
- data: s,
88
- resolve: o,
91
+ data: o,
92
+ resolve: s,
89
93
  reject: l
90
94
  });
91
- }) : n.dispatch(r, s);
92
- }, Q = () => N(j), R = (t) => {
95
+ }) : n.dispatch(r, o);
96
+ }, Q = () => N(A), R = (t) => {
93
97
  const {
94
98
  in: e,
95
99
  mountOnEnter: i = !0,
@@ -97,7 +101,7 @@ const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting"
97
101
  timeout: n,
98
102
  children: m,
99
103
  transitions: r
100
- } = t, o = (() => {
104
+ } = t, s = (() => {
101
105
  var l, u;
102
106
  if (!(!r || r === "none")) {
103
107
  if (typeof r == "string")
@@ -114,12 +118,12 @@ const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting"
114
118
  }
115
119
  };
116
120
  if (typeof r == "object") {
117
- const { enter: d, exit: $ } = r;
121
+ const { enter: p, exit: $ } = r;
118
122
  return {
119
123
  enter: {
120
124
  transitionKeys: (l = r.enter) == null ? void 0 : l.type,
121
125
  duration: n ? typeof n == "number" ? n : n.enter : 200,
122
- easing: d.easing ? d.easing : "ease-in"
126
+ easing: p.easing ? p.easing : "ease-in"
123
127
  },
124
128
  exit: {
125
129
  transitionKeys: (u = r.enter) == null ? void 0 : u.type,
@@ -131,18 +135,18 @@ const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting"
131
135
  }
132
136
  })();
133
137
  return /* @__PURE__ */ a(
134
- A,
138
+ Y,
135
139
  {
136
140
  timeout: {
137
- enter: o && o.enter.duration || 0,
138
- exit: o && o.exit.duration || 0
141
+ enter: s && s.enter.duration || 0,
142
+ exit: s && s.exit.duration || 0
139
143
  },
140
144
  in: e,
141
145
  appear: !0,
142
146
  mountOnEnter: i,
143
147
  unmountOnExit: c,
144
148
  onEnter: (l) => l.clientHeight,
145
- children: (l) => m && m(l, o && b.compose(l, o))
149
+ children: (l) => m && m(l, s && b.compose(l, s))
146
150
  }
147
151
  );
148
152
  }, _ = ({ node: t }) => {
@@ -174,11 +178,11 @@ const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting"
174
178
  const e = t.symbol || { type: "Svg", content: "minimize" }, i = parseInt(t == null ? void 0 : t.size, 10) || 20;
175
179
  return /* @__PURE__ */ a(h, { size: i, symbol: e });
176
180
  }, C = ({ className: t = "", ...e }) => {
177
- const i = H(), { size: c, padding: n, type: m, tooltip: r, show: s = !0 } = e;
181
+ const i = H(), { size: c, padding: n, type: m, tooltip: r, show: o = !0 } = e;
178
182
  return m === "back" ? /* @__PURE__ */ a(S, { size: c || "64px", padding: n || "10px", children: /* @__PURE__ */ a(
179
183
  R,
180
184
  {
181
- in: s,
185
+ in: o,
182
186
  timeout: 300,
183
187
  transitions: {
184
188
  enter: {
@@ -190,7 +194,7 @@ const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting"
190
194
  easing: "ease-out"
191
195
  }
192
196
  },
193
- children: (o, l) => /* @__PURE__ */ a(
197
+ children: (s, l) => /* @__PURE__ */ a(
194
198
  y,
195
199
  {
196
200
  title: r,
@@ -203,7 +207,7 @@ const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting"
203
207
  }
204
208
  )
205
209
  }
206
- ) }) : s ? /* @__PURE__ */ x(
210
+ ) }) : o ? /* @__PURE__ */ x(
207
211
  S,
208
212
  {
209
213
  size: c || "64px",
@@ -273,29 +277,29 @@ const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting"
273
277
  return (i = (e = t.theme.accessibility) == null ? void 0 : e.colors) == null ? void 0 : i.inactiveText;
274
278
  }};
275
279
  }
276
- `, ot = ({ className: t, ...e }) => {
280
+ `, mt = ({ className: t, ...e }) => {
277
281
  const {
278
282
  header: i,
279
283
  tagline: c,
280
284
  route: n,
281
285
  tooltip: m = "",
282
286
  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
+ 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}`)),
287
291
  /* @__PURE__ */ x(
288
292
  tt,
289
293
  {
290
- textAlign: s,
291
- margin: I(o, l, s),
294
+ textAlign: o,
295
+ margin: D(s, l, o),
292
296
  children: [
293
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 }),
294
298
  c && /* @__PURE__ */ a(Z, { children: c })
295
299
  ]
296
300
  }
297
301
  ),
298
- l.map((u, d) => /* @__PURE__ */ a(C, { ...u }, `${u.type}+_${d}`))
302
+ l.map((u, p) => /* @__PURE__ */ a(C, { ...u }, `${u.type}+_${p}`))
299
303
  ] });
300
304
  }, U = g.div`
301
305
  display: flex;
@@ -345,18 +349,18 @@ const q = (t) => t === "entering" || t === "entered", L = (t) => t === "exiting"
345
349
 
346
350
  margin-right: ${(t) => t.margin.right || 0};
347
351
  margin-left: ${(t) => t.margin.left || 0};
348
- `, et = g(W)`
352
+ `, et = g(I)`
349
353
  text-decoration: none;
350
354
  &:focus-visible {
351
355
  ${(t) => w(t)(
352
356
  "h1",
353
357
  f`
354
- ${X(t)}
358
+ ${W(t)}
355
359
  display: inline-block;
356
360
  `
357
361
  )}
358
362
  }
359
363
  `;
360
364
  export {
361
- ot as default
365
+ mt as default
362
366
  };