@telia-ace/widget-components-back-link 1.0.31 → 1.1.1-rc.0

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,138 @@
1
+ import { jsx as c, jsxs as p } from "react/jsx-runtime";
2
+ import { E as v, C as $, u as D, a as E, b as B, c as z, d as x, e as M, f as N, n as C, l as P, g as d, B as R } from "./index-b5ce891a.mjs";
3
+ import { useContext as k, useState as h, useEffect as f } from "react";
4
+ import "react-dom";
5
+ const w = (t = {}) => (Object.keys(t).forEach((e) => {
6
+ (t[e] === null || typeof t[e] > "u") && delete t[e];
7
+ }), t), S = (t, e) => t.get("seoConfiguration") ? /* @__PURE__ */ c(v, { ...e }) : null, A = () => k($), I = () => {
8
+ const t = D(), e = A(), [n, l] = h([]), [u, r] = h();
9
+ return f(() => {
10
+ if (t && e) {
11
+ const s = new E(t).withId(e.id), i = t.actions(s, e.type || B());
12
+ r(i), n !== null && (n.forEach((o) => {
13
+ i.dispatch(o.key, o.data).then((a) => o.resolve(a)).catch((a) => o.reject(a));
14
+ }), l(null));
15
+ }
16
+ }, [t, e.id]), (s, i) => n !== null ? new Promise((o, a) => {
17
+ n.push({
18
+ key: s,
19
+ data: i,
20
+ resolve: o,
21
+ reject: a
22
+ });
23
+ }) : u.dispatch(s, i);
24
+ }, Q = () => k(z), q = (t) => {
25
+ const e = x(), n = M(), [l, u] = h({ name: "", params: {} }), r = N();
26
+ return f(() => {
27
+ const s = (t || e).get("$widget");
28
+ if (!s)
29
+ return;
30
+ const { events: i } = s;
31
+ return i.subscribe("router:change", (a, { next: { routeData: m } }) => {
32
+ if (r.current) {
33
+ const { name: b, params: g } = m;
34
+ w(g), u({ name: b, params: g });
35
+ }
36
+ });
37
+ }, [r, t, e]), f(() => {
38
+ if (n && n.history && r.current) {
39
+ const s = n.getRouteData(), { name: i, params: o } = s;
40
+ w(o), u({ name: i, params: o });
41
+ }
42
+ }, [n, r]), l;
43
+ }, y = C.div`
44
+ font-weight: 300;
45
+ button {
46
+ color: ${(t) => {
47
+ var e;
48
+ return (e = t.theme.colors) == null ? void 0 : e.primary;
49
+ }};
50
+ text-decoration: underline;
51
+ font-size: ${(t) => {
52
+ var e;
53
+ return (e = t.theme.fonts) == null ? void 0 : e.normal;
54
+ }};
55
+ span {
56
+ font-weight: 300;
57
+ }
58
+ &:focus-visible {
59
+ ${P}
60
+ padding: ${(t) => {
61
+ var e, n;
62
+ return `calc(${(e = t.theme.sizes) == null ? void 0 : e.small} / 2) ${(n = t.theme.sizes) == null ? void 0 : n.small}`;
63
+ }};
64
+ }
65
+ }
66
+ `, L = C.svg`
67
+ margin-right: ${(t) => {
68
+ var e;
69
+ return (e = t.theme.sizes) == null ? void 0 : e.small;
70
+ }};
71
+ line {
72
+ stroke: ${(t) => {
73
+ var e;
74
+ return (e = t.theme.colors) == null ? void 0 : e.primary;
75
+ }};
76
+ }
77
+ `, W = ({ className: t, ...e }) => {
78
+ const n = I(), { params: l } = q(), u = x(), { conditions: r = [], label: s = "" } = Q();
79
+ if (!(r && r.length ? r.reduce((a, m) => l[m] ? !0 : a, !1) : !0))
80
+ return S(u, {
81
+ ...e,
82
+ className: d(t, "humany-back-link")
83
+ });
84
+ const o = () => {
85
+ n("click");
86
+ };
87
+ return s ? /* @__PURE__ */ c(y, { ...e, className: d(t, "humany-back-link"), children: /* @__PURE__ */ p(R, { "aria-label": s, onClick: o, children: [
88
+ /* @__PURE__ */ p(
89
+ L,
90
+ {
91
+ width: "7",
92
+ height: "13",
93
+ viewBox: "0 0 7 13",
94
+ fill: "none",
95
+ xmlns: "http://www.w3.org/2000/svg",
96
+ children: [
97
+ /* @__PURE__ */ c("line", { x1: "6.64645", y1: "12.5513", x2: "0.648357", y2: "6.55319" }),
98
+ /* @__PURE__ */ c("line", { x1: "0.646447", y1: "6.64455", x2: "6.64454", y2: "0.646465" })
99
+ ]
100
+ }
101
+ ),
102
+ s && /* @__PURE__ */ c("span", { children: s })
103
+ ] }) }) : /* @__PURE__ */ c(y, { ...e, className: d(t, "humany-back-link"), children: /* @__PURE__ */ p(
104
+ "svg",
105
+ {
106
+ width: "8",
107
+ height: "16",
108
+ viewBox: "0 0 8 16",
109
+ fill: "none",
110
+ xmlns: "http://www.w3.org/2000/svg",
111
+ children: [
112
+ /* @__PURE__ */ c(
113
+ "line",
114
+ {
115
+ y1: "-0.5",
116
+ x2: "10.2585",
117
+ y2: "-0.5",
118
+ transform: "matrix(-0.682358 -0.731018 0.682358 -0.731018 8 14.9999)",
119
+ stroke: "white"
120
+ }
121
+ ),
122
+ /* @__PURE__ */ c(
123
+ "line",
124
+ {
125
+ y1: "-0.5",
126
+ x2: "10.2585",
127
+ y2: "-0.5",
128
+ transform: "matrix(0.682359 -0.731018 0.682358 0.731018 1 8.49915)",
129
+ stroke: "white"
130
+ }
131
+ )
132
+ ]
133
+ }
134
+ ) });
135
+ };
136
+ export {
137
+ W as default
138
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),n=require("./index-edf03e83.js"),l=require("react");require("react-dom");const f=(t={})=>(Object.keys(t).forEach(e=>{(t[e]===null||typeof t[e]>"u")&&delete t[e]}),t),g=(t,e)=>t.get("seoConfiguration")?i.jsx(n.Empty,{...e}):null,w=()=>l.useContext(n.ComponentNodeContext),C=()=>{const t=n.useComponentPlatform(),e=w(),[s,m]=l.useState([]),[d,a]=l.useState();return l.useEffect(()=>{if(t&&e){const o=new n.ComponentQuery(t).withId(e.id),c=t.actions(o,e.type||n.uuid());a(c),s!==null&&(s.forEach(r=>{c.dispatch(r.key,r.data).then(u=>r.resolve(u)).catch(u=>r.reject(u))}),m(null))}},[t,e.id]),(o,c)=>s!==null?new Promise((r,u)=>{s.push({key:o,data:c,resolve:r,reject:u})}):d.dispatch(o,c)},k=()=>l.useContext(n.ComponentPropertyContext),b=t=>{const e=n.useContainer(),s=n.useRouter(),[m,d]=l.useState({name:"",params:{}}),a=n.useIsMounted();return l.useEffect(()=>{const o=(t||e).get("$widget");if(!o)return;const{events:c}=o;return c.subscribe("router:change",(u,{next:{routeData:p}})=>{if(a.current){const{name:y,params:h}=p;f(h),d({name:y,params:h})}})},[a,t,e]),l.useEffect(()=>{if(s&&s.history&&a.current){const o=s.getRouteData(),{name:c,params:r}=o;f(r),d({name:c,params:r})}},[s,a]),m},x=n.newStyled.div`
2
+ font-weight: 300;
3
+ button {
4
+ color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.primary}};
5
+ text-decoration: underline;
6
+ font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.normal}};
7
+ span {
8
+ font-weight: 300;
9
+ }
10
+ &:focus-visible {
11
+ ${n.linkTabStyle}
12
+ padding: ${t=>{var e,s;return`calc(${(e=t.theme.sizes)==null?void 0:e.small} / 2) ${(s=t.theme.sizes)==null?void 0:s.small}`}};
13
+ }
14
+ }
15
+ `,v=n.newStyled.svg`
16
+ margin-right: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.small}};
17
+ line {
18
+ stroke: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.primary}};
19
+ }
20
+ `,j=({className:t,...e})=>{const s=C(),{params:m}=b(),d=n.useContainer(),{conditions:a=[],label:o=""}=k();if(!(a&&a.length?a.reduce((u,p)=>m[p]?!0:u,!1):!0))return g(d,{...e,className:n.appendClassNames(t,"humany-back-link")});const r=()=>{s("click")};return o?i.jsx(x,{...e,className:n.appendClassNames(t,"humany-back-link"),children:i.jsxs(n.Button,{"aria-label":o,onClick:r,children:[i.jsxs(v,{width:"7",height:"13",viewBox:"0 0 7 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("line",{x1:"6.64645",y1:"12.5513",x2:"0.648357",y2:"6.55319"}),i.jsx("line",{x1:"0.646447",y1:"6.64455",x2:"6.64454",y2:"0.646465"})]}),o&&i.jsx("span",{children:o})]})}):i.jsx(x,{...e,className:n.appendClassNames(t,"humany-back-link"),children:i.jsxs("svg",{width:"8",height:"16",viewBox:"0 0 8 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("line",{y1:"-0.5",x2:"10.2585",y2:"-0.5",transform:"matrix(-0.682358 -0.731018 0.682358 -0.731018 8 14.9999)",stroke:"white"}),i.jsx("line",{y1:"-0.5",x2:"10.2585",y2:"-0.5",transform:"matrix(0.682359 -0.731018 0.682358 0.731018 1 8.49915)",stroke:"white"})]})})};exports.default=j;