@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.
@@ -0,0 +1 @@
1
+ "use strict";const b=require("@telia-ace/widget-core"),f=require("@telia-ace/widget-ui"),h=require("@telia-ace/widget-utilities"),p=(s,t,n)=>{if(n!=="center")return{};const e=c=>c.reduce((u,d)=>{const[l]=d.padding.split("px"),[g]=d.size.split("px");return u+(+g+ +l*2)},0),o=e(s),a=e(t),r=o-a;return r===0?{}:{[o>a?"right":"left"]:`${Math.abs(r)}px`}},w=s=>Object.keys(s).reduce((t,n)=>{const e=s[n];if(!e)return t;const[o,a]=t,r=e.position==="left"?o:a;return s[n].symbol,r.push({symbol:e.symbol&&typeof e.symbol=="string"?{type:"Uri",content:e.symbol}:e.symbol,type:n,padding:e.padding||"10px",label:e.label,size:e.size||"64px",tooltip:e.tooltip,order:e.order||0,show:e.show}),t},[[],[]]),k=s=>s.getAsync("router").then(t=>{if(!t)return!0;const n=t.getInitialRoute(),{name:e,params:o}=t.getRouteData();return h.removeNullAndUndefinedValues(o),!((n==null?void 0:n.name)!==e||Object.keys(o).length>0)}),y=s=>f.createReactComponent(s,"widget-header",Promise.resolve().then(()=>require("./widget-header-393b5e28.js")),t=>{const{events:n}=s.get("$widget"),[e,o]=b.createEventSubscriber(n),{actions:a={}}=t.properties();if(t.actions.create("close",(r,i)=>i.preventDefault?void 0:s.get("$widget").invoke("close")),t.actions.create("back",(r,i)=>{if(!i.preventDefault)return s.getAsync("router").then(c=>{c.goBack()})}),t.properties(r=>{const{actions:i={}}=r;if(i.back)return Object.keys(i).forEach(c=>{const u=i[c];c==="back"&&(u.show=r.showBack)}),{actions:i}}),t.actions.create("show-back",r=>{t.writeProperties({showBack:r})}),a.back){const r=()=>k(s).then(i=>t.actions.dispatch("show-back",!i));r(),e("router:changed",r)}return t.actions.create("minimize",(r,i)=>i.preventDefault?void 0:s.get("$widget").invoke("hide")),()=>{o()}});exports.WidgetHeaderComponent=y;exports.calculateMargin=p;exports.createNodes=w;
@@ -0,0 +1,72 @@
1
+ import { createEventSubscriber as p } from "@telia-ace/widget-core";
2
+ import { createReactComponent as f } from "@telia-ace/widget-ui";
3
+ import { removeNullAndUndefinedValues as b } from "@telia-ace/widget-utilities";
4
+ const y = (s, e, n) => {
5
+ if (n !== "center")
6
+ return {};
7
+ const t = (a) => a.reduce((u, d) => {
8
+ const [l] = d.padding.split("px"), [g] = d.size.split("px");
9
+ return u + (+g + +l * 2);
10
+ }, 0), o = t(s), c = t(e), r = o - c;
11
+ return r === 0 ? {} : {
12
+ [o > c ? "right" : "left"]: `${Math.abs(r)}px`
13
+ };
14
+ }, v = (s) => Object.keys(s).reduce(
15
+ (e, n) => {
16
+ const t = s[n];
17
+ if (!t)
18
+ return e;
19
+ const [o, c] = e, r = t.position === "left" ? o : c;
20
+ return s[n].symbol, r.push({
21
+ symbol: t.symbol && typeof t.symbol == "string" ? { type: "Uri", content: t.symbol } : t.symbol,
22
+ type: n,
23
+ padding: t.padding || "10px",
24
+ label: t.label,
25
+ size: t.size || "64px",
26
+ tooltip: t.tooltip,
27
+ order: t.order || 0,
28
+ show: t.show
29
+ }), e;
30
+ },
31
+ [[], []]
32
+ ), h = (s) => s.getAsync("router").then((e) => {
33
+ if (!e)
34
+ return !0;
35
+ const n = e.getInitialRoute(), { name: t, params: o } = e.getRouteData();
36
+ return b(o), !((n == null ? void 0 : n.name) !== t || Object.keys(o).length > 0);
37
+ }), z = (s) => f(
38
+ s,
39
+ "widget-header",
40
+ import("./widget-header-3dd8c261.mjs"),
41
+ (e) => {
42
+ const { events: n } = s.get("$widget"), [t, o] = p(n), { actions: c = {} } = e.properties();
43
+ if (e.actions.create("close", (r, i) => i.preventDefault ? void 0 : s.get("$widget").invoke("close")), e.actions.create("back", (r, i) => {
44
+ if (!i.preventDefault)
45
+ return s.getAsync("router").then((a) => {
46
+ a.goBack();
47
+ });
48
+ }), e.properties((r) => {
49
+ const { actions: i = {} } = r;
50
+ if (i.back)
51
+ return Object.keys(i).forEach((a) => {
52
+ const u = i[a];
53
+ a === "back" && (u.show = r.showBack);
54
+ }), { actions: i };
55
+ }), e.actions.create("show-back", (r) => {
56
+ e.writeProperties({ showBack: r });
57
+ }), c.back) {
58
+ const r = () => h(s).then(
59
+ (i) => e.actions.dispatch("show-back", !i)
60
+ );
61
+ r(), t("router:changed", r);
62
+ }
63
+ return e.actions.create("minimize", (r, i) => i.preventDefault ? void 0 : s.get("$widget").invoke("hide")), () => {
64
+ o();
65
+ };
66
+ }
67
+ );
68
+ export {
69
+ z as W,
70
+ y as a,
71
+ v as c
72
+ };
package/index.js CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";const e=require("./index-8f0189a9.js");require("@telia-ace/widget-core");require("@telia-ace/widget-ui");require("@telia-ace/widget-utilities");module.exports=e.WidgetHeaderComponent;
package/index.mjs CHANGED
@@ -1,11 +1,7 @@
1
- import { W as d } from "./index-8825e52f.mjs";
2
- import "@emotion/react";
3
- import "react/jsx-runtime";
4
- import "react";
5
- import "@emotion/styled";
6
- import "react-transition-group";
7
- import "react-dom";
8
- import "react-router-dom";
1
+ import { W as i } from "./index-cc80e958.mjs";
2
+ import "@telia-ace/widget-core";
3
+ import "@telia-ace/widget-ui";
4
+ import "@telia-ace/widget-utilities";
9
5
  export {
10
- d as default
6
+ i as default
11
7
  };
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.2",
3
+ "version": "1.1.1-rc.4",
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.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",
13
+ "@telia-ace/widget-core": "^1.1.1-rc.4",
14
+ "@telia-ace/widget-routing": "^1.1.1-rc.4",
15
+ "@telia-ace/widget-ui": "^1.1.1-rc.4",
16
+ "@telia-ace/widget-utilities": "^1.1.1-rc.4",
17
17
  "@webprovisions/platform": "^1.1.4"
18
18
  },
19
19
  "peerDependencies": {
@@ -0,0 +1,79 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),u=require("@emotion/react"),m=require("@emotion/styled"),r=require("@telia-ace/widget-ui"),v=require("@telia-ace/widget-utilities"),b=require("./index-8f0189a9.js");require("@telia-ace/widget-core");const j=({node:e})=>{if(!e.symbol)return null;let t;const s=e.symbol.type==="Svg";if(e.symbol.type==="Svg"){const o=parseInt(e.size,10);isNaN(o)||(t=o)}return i.jsx(f,{symbol:e.symbol,svg:s,size:t,backgroundSize:"cover"})},f=m(({svg:e,...t})=>i.jsx(r.SymbolBadge,{...t}))`
2
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
3
+ ${e=>!e.svg&&u.css`
4
+ border-radius: 50%;
5
+ overflow: hidden;
6
+ `}
7
+ `,z=({node:e})=>{const t=e.symbol||{type:"Svg",content:"back"};return i.jsx(r.SymbolBadge,{size:20,symbol:t})},S=({node:e})=>{const t=e.symbol||{type:"Svg",content:"close"},s=parseInt(e==null?void 0:e.size,10)||14;return i.jsx(r.SymbolBadge,{size:s,symbol:t})},k=({node:e})=>{const t=e.symbol||{type:"Svg",content:"minimize"},s=parseInt(e==null?void 0:e.size,10)||20;return i.jsx(r.SymbolBadge,{size:s,symbol:t})},y=({className:e="",...t})=>{const s=r.useDispatch(),{size:o,padding:g,type:a,tooltip:l,show:d=!0}=t;return a==="back"?i.jsx($,{size:o||"64px",padding:g||"10px",children:i.jsx(r.TransitionComponent,{in:d,timeout:300,transitions:{enter:{type:"scale",easing:"cubic-bezier(.08,.84,.74,1.84)"},exit:{type:"scale",easing:"ease-out"}},children:(h,x)=>i.jsx(p,{title:l,"aria-label":l,animationCss:x,onClick:()=>{s("back")},children:i.jsx(z,{node:t})})})}):d?i.jsxs($,{size:o||"64px",padding:g||"10px",squareRatio:a==="avatar",children:[a==="avatar"&&i.jsx(j,{node:t}),a==="close"&&i.jsx(p,{title:l,"aria-label":l,onClick:()=>{s("close")},children:i.jsx(S,{node:t})}),a==="minimize"&&i.jsx(p,{title:l,"aria-label":l,onClick:()=>{s("minimize")},children:i.jsx(k,{node:t})})]}):null},$=m.div`
8
+ flex: 1;
9
+ max-width: ${e=>e.size};
10
+ ${e=>e.squareRatio&&`max-height: ${e.size};`}
11
+ text-align: center;
12
+ padding: 0 ${e=>e.padding};
13
+ && {
14
+ box-sizing: content-box;
15
+ }
16
+
17
+ svg {
18
+ vertical-align: middle;
19
+ }
20
+
21
+ i {
22
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
23
+ font-size: ${e=>e.size};
24
+ min-width: 1em;
25
+ min-height: 1em;
26
+ display: inline-block;
27
+ }
28
+ `,p=m.button`
29
+ ${e=>!!e.animationCss&&e.animationCss};
30
+ background: none;
31
+ border: none;
32
+ cursor: pointer;
33
+ padding: 0;
34
+ &:focus-visible {
35
+ ${r.borderTabStyle};
36
+ border-color: ${e=>{var t,s;return(s=(t=e.theme.accessibility)==null?void 0:t.colors)==null?void 0:s.inactiveText}};
37
+ }
38
+ `,N=({className:e,...t})=>{const{header:s,tagline:o,route:g,tooltip:a="",actions:l={},textAlign:d="center"}=r.useProperties(),[h,x]=b.createNodes(l);return h.sort((n,c)=>(n.order||0)-(c.order||0)),x.sort((n,c)=>(n.order||0)-(c.order||0)),i.jsxs(w,{...t,className:v.appendClassNames(e,"humany-widget-header"),children:[h.map((n,c)=>i.jsx(y,{...n},`${n.type}+_${c}`)),i.jsxs(C,{textAlign:d,margin:b.calculateMargin(h,x,d),children:[g?i.jsx(T,{routeName:g,title:a,"aria-label":a,children:i.jsx(r.Typography,{variant:"h1",children:s})}):i.jsx(r.Typography,{variant:"h1",children:s}),o&&i.jsx(q,{children:o})]}),x.map((n,c)=>i.jsx(y,{...n},`${n.type}+_${c}`))]})},w=m.div`
39
+ display: flex;
40
+ flex-direction: row;
41
+ align-items: center;
42
+
43
+ ${e=>{var t,s;return r.headingElement(e)("h1",u.css`
44
+ font-size: ${(t=e.theme.fonts)==null?void 0:t.huge};
45
+ margin: 0;
46
+ font-weight: 300;
47
+ color: ${(s=e.theme.colors)==null?void 0:s.text};
48
+ `)}}
49
+
50
+ p {
51
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
52
+ margin: 0;
53
+ }
54
+
55
+ svg {
56
+ line,
57
+ path,
58
+ circle {
59
+ stroke: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
60
+ }
61
+ }
62
+ `,q=m.p`
63
+ font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
64
+ font-weight: 300;
65
+ `,C=m.div`
66
+ flex: 1;
67
+ text-align: ${e=>e.textAlign};
68
+
69
+ margin-right: ${e=>e.margin.right||0};
70
+ margin-left: ${e=>e.margin.left||0};
71
+ `,T=m(r.Link)`
72
+ text-decoration: none;
73
+ &:focus-visible {
74
+ ${e=>r.headingElement(e)("h1",u.css`
75
+ ${r.linkTabStyle(e)}
76
+ display: inline-block;
77
+ `)}
78
+ }
79
+ `;exports.default=N;
@@ -0,0 +1,222 @@
1
+ import { jsx as i, jsxs as u } from "react/jsx-runtime";
2
+ import { css as y } from "@emotion/react";
3
+ import c from "@emotion/styled";
4
+ import { SymbolBadge as h, borderTabStyle as z, useDispatch as k, TransitionComponent as N, useProperties as S, Typography as f, headingElement as v, Link as C, linkTabStyle as w } from "@telia-ace/widget-ui";
5
+ import { appendClassNames as T } from "@telia-ace/widget-utilities";
6
+ import { c as A, a as W } from "./index-cc80e958.mjs";
7
+ import "@telia-ace/widget-core";
8
+ const B = ({ node: e }) => {
9
+ if (!e.symbol)
10
+ return null;
11
+ let t;
12
+ const r = e.symbol.type === "Svg";
13
+ if (e.symbol.type === "Svg") {
14
+ const o = parseInt(e.size, 10);
15
+ isNaN(o) || (t = o);
16
+ }
17
+ return /* @__PURE__ */ i(I, { symbol: e.symbol, svg: r, size: t, backgroundSize: "cover" });
18
+ }, I = c(({ svg: e, ...t }) => /* @__PURE__ */ i(h, { ...t }))`
19
+ color: ${(e) => {
20
+ var t;
21
+ return (t = e.theme.colors) == null ? void 0 : t.text;
22
+ }};
23
+ ${(e) => !e.svg && y`
24
+ border-radius: 50%;
25
+ overflow: hidden;
26
+ `}
27
+ `, M = ({ node: e }) => {
28
+ const t = e.symbol || { type: "Svg", content: "back" };
29
+ return /* @__PURE__ */ i(h, { size: 20, symbol: t });
30
+ }, j = ({ node: e }) => {
31
+ const t = e.symbol || { type: "Svg", content: "close" }, r = parseInt(e == null ? void 0 : e.size, 10) || 14;
32
+ return /* @__PURE__ */ i(h, { size: r, symbol: t });
33
+ }, q = ({ node: e }) => {
34
+ const t = e.symbol || { type: "Svg", content: "minimize" }, r = parseInt(e == null ? void 0 : e.size, 10) || 20;
35
+ return /* @__PURE__ */ i(h, { size: r, symbol: t });
36
+ }, x = ({ className: e = "", ...t }) => {
37
+ const r = k(), { size: o, padding: m, type: n, tooltip: a, show: g = !0 } = t;
38
+ return n === "back" ? /* @__PURE__ */ i($, { size: o || "64px", padding: m || "10px", children: /* @__PURE__ */ i(
39
+ N,
40
+ {
41
+ in: g,
42
+ timeout: 300,
43
+ transitions: {
44
+ enter: {
45
+ type: "scale",
46
+ easing: "cubic-bezier(.08,.84,.74,1.84)"
47
+ },
48
+ exit: {
49
+ type: "scale",
50
+ easing: "ease-out"
51
+ }
52
+ },
53
+ children: (d, p) => /* @__PURE__ */ i(
54
+ b,
55
+ {
56
+ title: a,
57
+ "aria-label": a,
58
+ animationCss: p,
59
+ onClick: () => {
60
+ r("back");
61
+ },
62
+ children: /* @__PURE__ */ i(M, { node: t })
63
+ }
64
+ )
65
+ }
66
+ ) }) : g ? /* @__PURE__ */ u(
67
+ $,
68
+ {
69
+ size: o || "64px",
70
+ padding: m || "10px",
71
+ squareRatio: n === "avatar",
72
+ children: [
73
+ n === "avatar" && /* @__PURE__ */ i(B, { node: t }),
74
+ n === "close" && /* @__PURE__ */ i(
75
+ b,
76
+ {
77
+ title: a,
78
+ "aria-label": a,
79
+ onClick: () => {
80
+ r("close");
81
+ },
82
+ children: /* @__PURE__ */ i(j, { node: t })
83
+ }
84
+ ),
85
+ n === "minimize" && /* @__PURE__ */ i(
86
+ b,
87
+ {
88
+ title: a,
89
+ "aria-label": a,
90
+ onClick: () => {
91
+ r("minimize");
92
+ },
93
+ children: /* @__PURE__ */ i(q, { node: t })
94
+ }
95
+ )
96
+ ]
97
+ }
98
+ ) : null;
99
+ }, $ = c.div`
100
+ flex: 1;
101
+ max-width: ${(e) => e.size};
102
+ ${(e) => e.squareRatio && `max-height: ${e.size};`}
103
+ text-align: center;
104
+ padding: 0 ${(e) => e.padding};
105
+ && {
106
+ box-sizing: content-box;
107
+ }
108
+
109
+ svg {
110
+ vertical-align: middle;
111
+ }
112
+
113
+ i {
114
+ color: ${(e) => {
115
+ var t;
116
+ return (t = e.theme.colors) == null ? void 0 : t.text;
117
+ }};
118
+ font-size: ${(e) => e.size};
119
+ min-width: 1em;
120
+ min-height: 1em;
121
+ display: inline-block;
122
+ }
123
+ `, b = c.button`
124
+ ${(e) => !!e.animationCss && e.animationCss};
125
+ background: none;
126
+ border: none;
127
+ cursor: pointer;
128
+ padding: 0;
129
+ &:focus-visible {
130
+ ${z};
131
+ border-color: ${(e) => {
132
+ var t, r;
133
+ return (r = (t = e.theme.accessibility) == null ? void 0 : t.colors) == null ? void 0 : r.inactiveText;
134
+ }};
135
+ }
136
+ `, O = ({ className: e, ...t }) => {
137
+ const {
138
+ header: r,
139
+ tagline: o,
140
+ route: m,
141
+ tooltip: n = "",
142
+ actions: a = {},
143
+ textAlign: g = "center"
144
+ } = S(), [d, p] = A(a);
145
+ return d.sort((s, l) => (s.order || 0) - (l.order || 0)), p.sort((s, l) => (s.order || 0) - (l.order || 0)), /* @__PURE__ */ u(L, { ...t, className: T(e, "humany-widget-header"), children: [
146
+ d.map((s, l) => /* @__PURE__ */ i(x, { ...s }, `${s.type}+_${l}`)),
147
+ /* @__PURE__ */ u(
148
+ _,
149
+ {
150
+ textAlign: g,
151
+ margin: W(d, p, g),
152
+ children: [
153
+ m ? /* @__PURE__ */ i(D, { routeName: m, title: n, "aria-label": n, children: /* @__PURE__ */ i(f, { variant: "h1", children: r }) }) : /* @__PURE__ */ i(f, { variant: "h1", children: r }),
154
+ o && /* @__PURE__ */ i(R, { children: o })
155
+ ]
156
+ }
157
+ ),
158
+ p.map((s, l) => /* @__PURE__ */ i(x, { ...s }, `${s.type}+_${l}`))
159
+ ] });
160
+ }, L = c.div`
161
+ display: flex;
162
+ flex-direction: row;
163
+ align-items: center;
164
+
165
+ ${(e) => {
166
+ var t, r;
167
+ return v(e)(
168
+ "h1",
169
+ y`
170
+ font-size: ${(t = e.theme.fonts) == null ? void 0 : t.huge};
171
+ margin: 0;
172
+ font-weight: 300;
173
+ color: ${(r = e.theme.colors) == null ? void 0 : r.text};
174
+ `
175
+ );
176
+ }}
177
+
178
+ p {
179
+ color: ${(e) => {
180
+ var t;
181
+ return (t = e.theme.colors) == null ? void 0 : t.text;
182
+ }};
183
+ margin: 0;
184
+ }
185
+
186
+ svg {
187
+ line,
188
+ path,
189
+ circle {
190
+ stroke: ${(e) => {
191
+ var t;
192
+ return (t = e.theme.colors) == null ? void 0 : t.text;
193
+ }};
194
+ }
195
+ }
196
+ `, R = c.p`
197
+ font-size: ${(e) => {
198
+ var t;
199
+ return (t = e.theme.fonts) == null ? void 0 : t.normal;
200
+ }};
201
+ font-weight: 300;
202
+ `, _ = c.div`
203
+ flex: 1;
204
+ text-align: ${(e) => e.textAlign};
205
+
206
+ margin-right: ${(e) => e.margin.right || 0};
207
+ margin-left: ${(e) => e.margin.left || 0};
208
+ `, D = c(C)`
209
+ text-decoration: none;
210
+ &:focus-visible {
211
+ ${(e) => v(e)(
212
+ "h1",
213
+ y`
214
+ ${w(e)}
215
+ display: inline-block;
216
+ `
217
+ )}
218
+ }
219
+ `;
220
+ export {
221
+ O as default
222
+ };