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

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 ADDED
@@ -0,0 +1 @@
1
+ "use strict";const e=require("./index-8e05a7b4.js");require("react/jsx-runtime");require("react");require("react-dom");module.exports=e.WidgetHeaderComponent;
package/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ import { W as i } from "./index-addbd6d9.mjs";
2
+ import "react/jsx-runtime";
3
+ import "react";
4
+ import "react-dom";
5
+ export {
6
+ i as default
7
+ };
package/package.json CHANGED
@@ -1,49 +1,24 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-components-widget-header",
3
- "version": "1.0.31",
4
- "description": "Widget header component for ACE Widgets.",
5
- "license": "SEE LICENSE IN LICENSE.txt",
6
- "author": "Telia Company AB",
7
- "keywords": [
8
- "telia"
9
- ],
10
- "main": "dist/index.js",
11
- "sourceMain": "src/index.ts",
12
- "type": "module",
13
- "types": "dist/index.d.ts",
14
- "files": [
15
- "LICENSE.txt",
16
- "README.md",
17
- "dist/"
18
- ],
19
- "publishConfig": {
20
- "access": "public"
3
+ "version": "1.1.1-rc.1",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./index.mjs",
9
+ "require": "./index.js"
10
+ }
21
11
  },
22
- "sideEffects": false,
23
12
  "dependencies": {
24
- "@telia-ace/widget-core": "1.0.28",
25
- "@telia-ace/widget-routing": "1.0.29",
26
- "@telia-ace/widget-ui": "1.0.35",
27
- "@telia-ace/widget-utilities": "1.0.17",
28
- "@webprovisions/platform": "^1.1.3"
13
+ "@telia-ace/widget-core": "^1.1.1-rc.1",
14
+ "@telia-ace/widget-routing": "^1.1.1-rc.1",
15
+ "@telia-ace/widget-ui": "^1.1.1-rc.1",
16
+ "@telia-ace/widget-utilities": "^1.1.1-rc.1",
17
+ "@webprovisions/platform": "^1.1.4"
29
18
  },
30
19
  "peerDependencies": {
31
- "@emotion/react": "^11.10.5",
32
- "@emotion/styled": "^11.10.5",
33
- "react": "^18.2.0",
34
- "react-dom": "^18.2.0"
35
- },
36
- "devDependencies": {
37
- "@emotion/react": "^11.10.5",
38
- "@emotion/styled": "^11.10.5",
39
- "@telia-ace/widget-developer-tools": "1.0.23",
40
- "@types/react": "^18.0.27",
41
- "@types/react-dom": "^18.0.10",
42
- "react": "^18.2.0",
43
- "react-dom": "^18.2.0"
44
- },
45
- "scripts": {
46
- "clean": "rimraf ./dist",
47
- "build": "rimraf ./dist && tsc -emitDeclarationOnly && vite build"
20
+ "@emotion/react": "11.11.1",
21
+ "@emotion/styled": "11.11.0",
22
+ "react": "18.2.0"
48
23
  }
49
24
  }
@@ -0,0 +1,88 @@
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;
@@ -0,0 +1,362 @@
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
+ };
package/LICENSE.txt DELETED
@@ -1,6 +0,0 @@
1
- Copyright © 2021, Telia Company AB. All rights reserved.
2
-
3
- THIS PACKAGE AND CONTAINING SOFTWARE IS PART OF
4
- THE HUMANY SERVICE. BY USING THIS SOFTWARE YOU
5
- AGREE TO THE FOLLOWING TERMS AND CONDITIONS:
6
- http://www.humany.com/legal
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # `@telia-ace/widget-components-widget-header`
2
-
3
- Widget header component for ACE Widgets.
@@ -1,73 +0,0 @@
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 v = (s, e, i) => {
5
- if (i !== "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
- }, z = (s) => Object.keys(s).reduce(
15
- (e, i) => {
16
- const t = s[i];
17
- if (!t)
18
- return e;
19
- const [o, c] = e, r = t.position === "left" ? o : c;
20
- return s[i].symbol, r.push({
21
- symbol: t.symbol && typeof t.symbol == "string" ? { type: "Uri", content: t.symbol } : t.symbol,
22
- type: i,
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 i = e.getInitialRoute(), { name: t, params: o } = e.getRouteData();
36
- return b(o), !((i == null ? void 0 : i.name) !== t || Object.keys(o).length > 0);
37
- }), w = (s) => f(
38
- s,
39
- "widget-header",
40
- import("./widget-header-6c106e50.js"),
41
- (e) => {
42
- const { events: i } = s.get("$widget"), [t, o] = p(i), { actions: c = {} } = e.properties();
43
- if (e.actions.create("close", (r, n) => n.preventDefault ? void 0 : s.get("$widget").invoke("close")), e.actions.create("back", (r, n) => {
44
- if (!n.preventDefault)
45
- return s.getAsync("router").then((a) => {
46
- a.goBack();
47
- });
48
- }), e.properties((r) => {
49
- const { actions: n = {} } = r;
50
- if (n.back)
51
- return Object.keys(n).forEach((a) => {
52
- const u = n[a];
53
- a === "back" && (u.show = r.showBack);
54
- }), { actions: n };
55
- }), e.actions.create("show-back", (r) => {
56
- e.writeProperties({ showBack: r });
57
- }), c.back) {
58
- const r = () => h(s).then(
59
- (n) => e.actions.dispatch("show-back", !n)
60
- );
61
- r(), t("router:changed", r);
62
- }
63
- return e.actions.create("minimize", (r, n) => n.preventDefault ? void 0 : s.get("$widget").invoke("hide")), () => {
64
- o();
65
- };
66
- }
67
- ), x = w;
68
- export {
69
- x as W,
70
- v as a,
71
- z as c
72
- };
73
- //# sourceMappingURL=index-805ec287.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-805ec287.js","sources":["../src/utils.ts","../src/widget-header-component.ts"],"sourcesContent":["import { RoutingService } from '@telia-ace/widget-routing';\nimport { removeNullAndUndefinedValues } from '@telia-ace/widget-utilities';\nimport { Container } from '@webprovisions/platform';\nimport { ActionNode, Symbol } from './widget-header-component';\n\nexport const calculateMargin = (\n leftNodes: ActionNode[],\n rightNodes: ActionNode[],\n textAlign: string\n) => {\n if (textAlign !== 'center') {\n return {};\n }\n\n const calculate = (nodes: ActionNode[]) => {\n return nodes.reduce<number>((acc, node) => {\n const [padding] = node.padding.split('px');\n const [size] = node.size.split('px');\n return acc + (+size + +padding * 2);\n }, 0);\n };\n const leftSize = calculate(leftNodes);\n const rightSize = calculate(rightNodes);\n\n const total = leftSize - rightSize;\n\n if (total === 0) {\n return {};\n }\n\n const direction = leftSize > rightSize ? 'right' : 'left';\n return {\n [direction]: `${Math.abs(total)}px`,\n };\n};\n\nexport const createNodes = (actions: { [key: string]: ActionNode }) => {\n return Object.keys(actions).reduce<[ActionNode[], ActionNode[]]>(\n (acc, key) => {\n const node = actions[key];\n if (!node) {\n return acc;\n }\n const [left, right] = acc;\n const arr = node.position === 'left' ? left : right;\n\n let symbol = actions[key].symbol;\n if (symbol && typeof symbol === 'string') {\n symbol = {\n type: 'Uri',\n content: symbol,\n };\n }\n\n arr.push({\n symbol:\n node.symbol && typeof node.symbol === 'string'\n ? { type: 'Uri', content: node.symbol }\n : (node.symbol as Symbol),\n type: key,\n padding: node.padding || '10px',\n label: node.label,\n size: node.size || '64px',\n tooltip: node.tooltip,\n order: node.order || 0,\n show: node.show,\n });\n\n return acc;\n },\n [[], []]\n );\n};\n\nexport const isOnInitialRoute = (container: Container) =>\n container.getAsync('router').then((router: RoutingService) => {\n if (!router) {\n return true;\n }\n const initialRoute = router.getInitialRoute();\n const { name, params } = router.getRouteData();\n\n removeNullAndUndefinedValues(params);\n\n if (initialRoute?.name !== name || Object.keys(params).length > 0) {\n return false;\n }\n\n return true;\n });\n","import { createEventSubscriber } from '@telia-ace/widget-core';\nimport { RoutingService } from '@telia-ace/widget-routing';\nimport { createReactComponent } from '@telia-ace/widget-ui';\nimport { Container } from '@webprovisions/platform';\nimport { isOnInitialRoute } from './utils';\n\nexport type Symbol = {\n type: 'Uri' | 'Svg' | 'FontAwesome' | 'Text' | string;\n content: string;\n};\n\nexport type ActionNode = {\n type: string;\n label?: string;\n position?: 'right' | 'left';\n symbol?: Symbol;\n size: string;\n padding: string;\n tooltip?: string;\n order?: number;\n show?: boolean;\n};\n\nexport type WidgetHeaderComponentProps = {\n header: string;\n tagline: string;\n textAlign?: string;\n actions?: { [key: string]: ActionNode };\n tooltip?: string;\n route?: string;\n};\n\nconst WidgetHeaderComponent = (container: Container) => {\n return createReactComponent(\n container,\n 'widget-header',\n import('./widget-header'),\n (component) => {\n const { events } = container.get('$widget');\n const [subscribe, unsubscribe] = createEventSubscriber(events);\n\n const { actions = {} } = component.properties<WidgetHeaderComponentProps>();\n\n component.actions.create('close', (data, options) => {\n if (options.preventDefault) {\n return;\n }\n\n const widget = container.get('$widget');\n return widget.invoke('close');\n });\n component.actions.create('back', (data, options) => {\n if (options.preventDefault) {\n return;\n }\n\n return container.getAsync('router').then((router: RoutingService) => {\n router.goBack();\n });\n });\n\n component.properties((properties) => {\n const { actions = {} } = properties;\n\n if (!actions.back) {\n return;\n }\n\n Object.keys(actions).forEach((key) => {\n const node = actions[key];\n if (key === 'back') {\n node.show = properties.showBack;\n }\n });\n\n return { actions };\n });\n\n component.actions.create('show-back', (showBack) => {\n component.writeProperties({ showBack });\n });\n\n if (actions.back) {\n const showBack = () =>\n isOnInitialRoute(container).then((onInitialRoute) =>\n component.actions.dispatch('show-back', !onInitialRoute)\n );\n\n showBack();\n subscribe('router:changed', showBack);\n }\n\n component.actions.create('minimize', (data, options) => {\n if (options.preventDefault) {\n return;\n }\n\n const widget = container.get('$widget');\n return widget.invoke('hide');\n });\n\n return () => {\n unsubscribe();\n };\n }\n );\n};\n\nexport default WidgetHeaderComponent;\n"],"names":["calculateMargin","leftNodes","rightNodes","textAlign","calculate","nodes","acc","node","padding","size","leftSize","rightSize","total","createNodes","actions","key","left","right","arr","isOnInitialRoute","container","router","initialRoute","name","params","removeNullAndUndefinedValues","WidgetHeaderComponent","createReactComponent","component","events","subscribe","unsubscribe","createEventSubscriber","data","options","properties","showBack","onInitialRoute","WidgetHeaderComponent$1"],"mappings":";;;AAKO,MAAMA,IAAkB,CAC3BC,GACAC,GACAC,MACC;AACD,MAAIA,MAAc;AACd,WAAO;AAGL,QAAAC,IAAY,CAACC,MACRA,EAAM,OAAe,CAACC,GAAKC,MAAS;AACvC,UAAM,CAACC,CAAO,IAAID,EAAK,QAAQ,MAAM,IAAI,GACnC,CAACE,CAAI,IAAIF,EAAK,KAAK,MAAM,IAAI;AACnC,WAAOD,KAAO,CAACG,IAAO,CAACD,IAAU;AAAA,KAClC,CAAC,GAEFE,IAAWN,EAAUH,CAAS,GAC9BU,IAAYP,EAAUF,CAAU,GAEhCU,IAAQF,IAAWC;AAEzB,SAAIC,MAAU,IACH,KAIJ;AAAA,IACH,CAFcF,IAAWC,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"@telia-ace/widget-core";
3
- import "@telia-ace/widget-ui";
4
- import "@telia-ace/widget-utilities";
5
- export {
6
- i as default
7
- };
8
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}