@telia-ace/knowledge-widget-components-guide-category-dropdown 1.1.1-rc.1 → 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/guide-category-dropdown-6c4d5ab0.js +105 -0
- package/{guide-category-dropdown-6e87a729.mjs → guide-category-dropdown-e6fca50c.mjs} +32 -28
- package/index-77cc22b1.js +1724 -0
- package/index-a4f978a6.mjs +7241 -0
- package/index.js +1 -1
- package/index.mjs +6 -2
- package/package.json +6 -6
- package/guide-category-dropdown-e0c53e78.js +0 -105
- package/index-34f1725b.mjs +0 -11118
- package/index-b2a67e58.js +0 -1757
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),C=require("@emotion/react"),o=require("./index-77cc22b1.js"),x=require("react");require("react-dom");require("react-transition-group");const j=require("@emotion/styled");require("react-router-dom");const z=(e,t)=>e.get("seoConfiguration")?s.jsx(o.Empty,{...t}):null,N=()=>x.useContext(o.ComponentPropertyContext),L=()=>{const[e,t]=x.useState(!1),d=x.useRef(),g=x.useCallback(()=>t(!0),[t]),a=x.useCallback(()=>t(!1),[t]);return o.useEventListener("mouseenter",g,d.current),o.useEventListener("mouseleave",a,d.current),[e,d]},B=(e,t,d,g,a,n)=>{const y=o.useRouter();if(!y)return{routeName:t,params:{}};const{params:m}=y.getRouteData();let i={},u=[];if(g==="tag"){const{tag:l,...h}=m;u=l?l.split(","):[],i=h}else{const{guideCategory:l,uriName:h,...b}=m;u=[l],i=b}if(d&&(e.id==="0"||u.includes(e.id))&&u.length===1&&(!a||a.id==="0")&&Object.keys(i).length===0){const l=y.getInitialRoute();return{routeName:(l==null?void 0:l.name)||t,params:{}}}let r={};const f=n?n.findIndex(l=>l.id===e.id):-1,c=u.includes(e.id);if(g==="tag"){const l=u.filter(b=>b!==e.id);let h=[];e.id==="0"?h=[]:h=c?l:[...u,e.id].filter(b=>b!=="0"),r=o.createParams({...i,tag:h})}else n&&f>0?r=o.createParams({...i,guideCategory:n[f-1].id,uriName:o.formatUrl(n[f-1].title)}):a?r=o.createParams({...i,guideCategory:c?a.id:e.id,uriName:c?o.formatUrl(a.title):o.formatUrl(e.title)}):r=o.createParams({...i,uriName:c?void 0:o.formatUrl(e.title),guideCategory:c?void 0:e.id});return typeof r.tag=="string"&&(r.tag=r.tag.split(",")),{routeName:t,params:{...r,id:void 0,guide:void 0,contactMethod:void 0,connectionKey:void 0,connection:void 0}}},R=j.div`
|
|
2
|
+
${o.loadingOpacity}
|
|
3
|
+
${o.contentBox}
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
min-height: 50px;
|
|
6
|
+
${e=>e["data-toggler-in-focus"]&&e.isTabbing&&C.css`
|
|
7
|
+
&& {
|
|
8
|
+
${o.borderTabStyle(e)}
|
|
9
|
+
}
|
|
10
|
+
`};
|
|
11
|
+
`,q=j.button`
|
|
12
|
+
background: none;
|
|
13
|
+
border: 0;
|
|
14
|
+
outline: 0;
|
|
15
|
+
display: block;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
padding: 0;
|
|
18
|
+
font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
|
|
19
|
+
text-align: end;
|
|
20
|
+
flex: 1 0 auto;
|
|
21
|
+
svg {
|
|
22
|
+
path,
|
|
23
|
+
line {
|
|
24
|
+
stroke: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`,k=e=>{var t,d,g,a,n,y,m,i;return C.css`
|
|
28
|
+
font-size: ${(t=e.theme.fonts)==null?void 0:t.normal};
|
|
29
|
+
text-align: left;
|
|
30
|
+
text-align: left;
|
|
31
|
+
text-decoration: none;
|
|
32
|
+
font-weight: 300;
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
padding: ${(d=e.theme.sizes)==null?void 0:d.small};
|
|
36
|
+
padding-left: ${(g=e.theme.sizes)==null?void 0:g.large};
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
${e.selected?C.css`
|
|
40
|
+
border-left: 2px solid ${(a=e.theme.colors)==null?void 0:a.primary};
|
|
41
|
+
color: ${(n=e.theme.colors)==null?void 0:n.primary};
|
|
42
|
+
`:C.css`
|
|
43
|
+
color: ${(y=e.theme.colors)==null?void 0:y.text};
|
|
44
|
+
`};
|
|
45
|
+
|
|
46
|
+
span {
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
text-overflow: ellipsis;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
i {
|
|
52
|
+
margin-right: ${(m=e.theme.sizes)==null?void 0:m.normal};
|
|
53
|
+
font-size: ${(i=e.theme.fonts)==null?void 0:i.medium};
|
|
54
|
+
min-height: 1em;
|
|
55
|
+
min-width: 1em;
|
|
56
|
+
}
|
|
57
|
+
`},M=j.div`
|
|
58
|
+
${k}
|
|
59
|
+
`,P=j(o.BaseLink)`
|
|
60
|
+
${k}
|
|
61
|
+
&:focus {
|
|
62
|
+
outline: none;
|
|
63
|
+
}
|
|
64
|
+
&:focus-visible {
|
|
65
|
+
span {
|
|
66
|
+
${o.linkTabStyle};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`,D=j.div`
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: space-between;
|
|
72
|
+
padding-right: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.large}};
|
|
73
|
+
min-height: 52px;
|
|
74
|
+
white-space: nowrap;
|
|
75
|
+
|
|
76
|
+
&& {
|
|
77
|
+
font-weight: normal;
|
|
78
|
+
|
|
79
|
+
a {
|
|
80
|
+
font-weight: normal;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
.humany-guide-category-dropdown-item {
|
|
84
|
+
font-weight: normal;
|
|
85
|
+
}
|
|
86
|
+
`,E=j(o.BaseList)`
|
|
87
|
+
${o.list}
|
|
88
|
+
display: flex;
|
|
89
|
+
justify-content: center;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
margin-right: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
|
|
92
|
+
margin-left: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.large}};
|
|
93
|
+
margin-bottom: 22px;
|
|
94
|
+
border-left: ${e=>e.theme.border};
|
|
95
|
+
li {
|
|
96
|
+
margin: 0 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}} -2px;
|
|
97
|
+
}
|
|
98
|
+
li:last-child {
|
|
99
|
+
margin: 0 0 0 -2px;
|
|
100
|
+
}
|
|
101
|
+
flex-basis: 100%;
|
|
102
|
+
border-width: 2px;
|
|
103
|
+
`,F=j(o.Text)`
|
|
104
|
+
margin: 0 0 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}};
|
|
105
|
+
`,p={Wrapper:R,Toggler:q,List:E,Item:M,Link:P,TopItem:D,MatchCount:F},$=({matches:e})=>{const{showMatchCount:t=!1}=N();return!t||typeof e>"u"?null:s.jsxs(p.MatchCount,{children:["(",e,")"]})},O=({item:e,guideCategory:t})=>{const{route:d="browse",categoryAriaLabel:g="",activeCategoryAriaLabel:a="",fallbackOnInitialRoute:n=!1}=N(),[y,m]=L(),{id:i,title:u,symbol:r,activeSymbol:f}=e,c=t===i;return s.jsx("li",{ref:m,children:s.jsxs(p.Link,{...B(e,d,n,"category"),"aria-pressed":c,"aria-label":(c?a:g).replace("{{category}}",u),className:"humany-guide-category-dropdown-link","aria-current":c,selected:c,children:[(c||y)&&f?s.jsx(o.SymbolBadge,{symbol:f}):r&&s.jsx(o.SymbolBadge,{symbol:r}),s.jsx(o.Text,{children:u}),s.jsx($,{...e})]})})},U=({className:e,...t})=>{const d=o.useRouteData(),[g,a]=x.useState(!1),{parent:n,route:y="browse",categories:m=[],loading:i=!1}=N(),u=o.useContainer(),[r,f]=x.useState(!1),{params:c}=d,l=o.useIsTabbing(),{guideCategory:h,tag:b,phrase:T,sorting:I}=c;if(x.useEffect(()=>{r&&f(!1)},[h]),i||!n||!m.length)return z(u,{...t,className:o.appendClassNames(e,"humany-guide-category-dropdown")});const w=m.find(v=>v.id===h)||n,S=w.activeSymbol||w.symbol;return s.jsx(p.Wrapper,{...t,"data-loading":!1,"data-toggler-in-focus":g,"aria-expanded":r,isTabbing:l,className:o.appendClassNames(e,"humany-guide-category-dropdown"),children:r?s.jsxs(s.Fragment,{children:[s.jsxs(p.TopItem,{className:"humany-guide-category-dropdown-top-item",children:[s.jsxs(p.Link,{className:"humany-guide-category-dropdown-link",routeName:y,params:o.createParams({tag:b,phrase:T,sorting:I,guideCategory:n.id,uriName:o.formatUrl(n.title)}),selected:!1,children:[n.symbol?s.jsx(o.SymbolBadge,{symbol:n.symbol}):null,s.jsx(o.Text,{children:n.title}),s.jsx($,{...n})]}),s.jsx(p.Toggler,{onBlur:()=>a(!1),onFocus:()=>a(!0),className:"humany-guide-category-dropdown-toggler",onClick:()=>{f(!r)},"aria-expanded":"true","aria-label":w.title,children:s.jsx(o.SymbolBadge,{size:18,symbol:{type:"Svg",content:"caret-up"}})})]}),s.jsx(p.List,{className:"humany-guide-category-dropdown-open",items:m,renderItem:v=>s.jsx(O,{item:v,guideCategory:h},v.id)})]}):s.jsxs(p.TopItem,{className:"humany-guide-category-dropdown-top-item",children:[s.jsxs(p.Item,{className:"humany-guide-category-dropdown-item",onClick:()=>{f(!r)},selected:!1,children:[S?s.jsx(o.SymbolBadge,{symbol:S}):null,s.jsx(o.Text,{children:w.title}),s.jsx($,{...w})]}),s.jsx(p.Toggler,{onBlur:()=>a(!1),onFocus:()=>a(!0),className:"humany-guide-category-dropdown-toggler",onClick:()=>{f(!r)},"aria-expanded":"false","aria-label":w.title,children:s.jsx(o.SymbolBadge,{size:18,symbol:{type:"Svg",content:"caret-down"}})})]})})};exports.default=U;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { jsx as n, jsxs as b, Fragment as F } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { css as k } from "@emotion/react";
|
|
3
|
+
import { E as O, C as G, u as R, a as A, c as C, f as $, l as H, b as P, d as W, B as K, e as U, g as q, h as J, T as I, S as v, i as Q, j as V, k as X, m as B } from "./index-a4f978a6.mjs";
|
|
3
4
|
import { useContext as Y, useState as T, useRef as Z, useCallback as M, useEffect as _ } from "react";
|
|
4
5
|
import "react-dom";
|
|
5
|
-
|
|
6
|
+
import "react-transition-group";
|
|
7
|
+
import x from "@emotion/styled";
|
|
8
|
+
import "react-router-dom";
|
|
9
|
+
const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t }) : null, L = () => Y(G), te = () => {
|
|
6
10
|
const [e, t] = T(!1), d = Z(), u = M(() => t(!0), [t]), s = M(() => t(!1), [t]);
|
|
7
11
|
return R("mouseenter", u, d.current), R("mouseleave", s, d.current), [e, d];
|
|
8
12
|
}, oe = (e, t, d, u, s, o) => {
|
|
@@ -15,10 +19,10 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
15
19
|
const { params: g } = f.getRouteData();
|
|
16
20
|
let r = {}, c = [];
|
|
17
21
|
if (u === "tag") {
|
|
18
|
-
const { tag: i, ...
|
|
19
|
-
c = i ? i.split(",") : [], r =
|
|
22
|
+
const { tag: i, ...p } = g;
|
|
23
|
+
c = i ? i.split(",") : [], r = p;
|
|
20
24
|
} else {
|
|
21
|
-
const { guideCategory: i, uriName:
|
|
25
|
+
const { guideCategory: i, uriName: p, ...y } = g;
|
|
22
26
|
c = [i], r = y;
|
|
23
27
|
}
|
|
24
28
|
if (d && (e.id === "0" || c.includes(e.id)) && c.length === 1 && (!s || s.id === "0") && Object.keys(r).length === 0) {
|
|
@@ -32,10 +36,10 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
32
36
|
const m = o ? o.findIndex((i) => i.id === e.id) : -1, l = c.includes(e.id);
|
|
33
37
|
if (u === "tag") {
|
|
34
38
|
const i = c.filter((y) => y !== e.id);
|
|
35
|
-
let
|
|
36
|
-
e.id === "0" ?
|
|
39
|
+
let p = [];
|
|
40
|
+
e.id === "0" ? p = [] : p = l ? i : [...c, e.id].filter((y) => y !== "0"), a = C({
|
|
37
41
|
...r,
|
|
38
|
-
tag:
|
|
42
|
+
tag: p
|
|
39
43
|
});
|
|
40
44
|
} else
|
|
41
45
|
o && m > 0 ? a = C({
|
|
@@ -190,7 +194,7 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
190
194
|
var t;
|
|
191
195
|
return (t = e.theme.sizes) == null ? void 0 : t.small;
|
|
192
196
|
}};
|
|
193
|
-
`,
|
|
197
|
+
`, h = {
|
|
194
198
|
Wrapper: ne,
|
|
195
199
|
Toggler: ae,
|
|
196
200
|
List: le,
|
|
@@ -199,8 +203,8 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
199
203
|
TopItem: ie,
|
|
200
204
|
MatchCount: de
|
|
201
205
|
}, z = ({ matches: e }) => {
|
|
202
|
-
const { showMatchCount: t = !1 } =
|
|
203
|
-
return !t || typeof e > "u" ? null : /* @__PURE__ */ b(
|
|
206
|
+
const { showMatchCount: t = !1 } = L();
|
|
207
|
+
return !t || typeof e > "u" ? null : /* @__PURE__ */ b(h.MatchCount, { children: [
|
|
204
208
|
"(",
|
|
205
209
|
e,
|
|
206
210
|
")"
|
|
@@ -211,9 +215,9 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
211
215
|
categoryAriaLabel: u = "",
|
|
212
216
|
activeCategoryAriaLabel: s = "",
|
|
213
217
|
fallbackOnInitialRoute: o = !1
|
|
214
|
-
} =
|
|
218
|
+
} = L(), [f, g] = te(), { id: r, title: c, symbol: a, activeSymbol: m } = e, l = t === r;
|
|
215
219
|
return /* @__PURE__ */ n("li", { ref: g, children: /* @__PURE__ */ b(
|
|
216
|
-
|
|
220
|
+
h.Link,
|
|
217
221
|
{
|
|
218
222
|
...oe(e, d, o, "category"),
|
|
219
223
|
"aria-pressed": l,
|
|
@@ -231,23 +235,23 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
231
235
|
]
|
|
232
236
|
}
|
|
233
237
|
) });
|
|
234
|
-
},
|
|
238
|
+
}, xe = ({ className: e, ...t }) => {
|
|
235
239
|
const d = Q(), [u, s] = T(!1), {
|
|
236
240
|
parent: o,
|
|
237
241
|
route: f = "browse",
|
|
238
242
|
categories: g = [],
|
|
239
243
|
loading: r = !1
|
|
240
|
-
} =
|
|
244
|
+
} = L(), c = V(), [a, m] = T(!1), { params: l } = d, i = X(), { guideCategory: p, tag: y, phrase: D, sorting: E } = l;
|
|
241
245
|
if (_(() => {
|
|
242
246
|
a && m(!1);
|
|
243
|
-
}, [
|
|
247
|
+
}, [p]), r || !o || !g.length)
|
|
244
248
|
return ee(c, {
|
|
245
249
|
...t,
|
|
246
250
|
className: B(e, "humany-guide-category-dropdown")
|
|
247
251
|
});
|
|
248
|
-
const w = g.find((N) => N.id ===
|
|
252
|
+
const w = g.find((N) => N.id === p) || o, S = w.activeSymbol || w.symbol;
|
|
249
253
|
return /* @__PURE__ */ n(
|
|
250
|
-
|
|
254
|
+
h.Wrapper,
|
|
251
255
|
{
|
|
252
256
|
...t,
|
|
253
257
|
"data-loading": !1,
|
|
@@ -256,9 +260,9 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
256
260
|
isTabbing: i,
|
|
257
261
|
className: B(e, "humany-guide-category-dropdown"),
|
|
258
262
|
children: a ? /* @__PURE__ */ b(F, { children: [
|
|
259
|
-
/* @__PURE__ */ b(
|
|
263
|
+
/* @__PURE__ */ b(h.TopItem, { className: "humany-guide-category-dropdown-top-item", children: [
|
|
260
264
|
/* @__PURE__ */ b(
|
|
261
|
-
|
|
265
|
+
h.Link,
|
|
262
266
|
{
|
|
263
267
|
className: "humany-guide-category-dropdown-link",
|
|
264
268
|
routeName: f,
|
|
@@ -278,7 +282,7 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
278
282
|
}
|
|
279
283
|
),
|
|
280
284
|
/* @__PURE__ */ n(
|
|
281
|
-
|
|
285
|
+
h.Toggler,
|
|
282
286
|
{
|
|
283
287
|
onBlur: () => s(!1),
|
|
284
288
|
onFocus: () => s(!0),
|
|
@@ -299,7 +303,7 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
299
303
|
)
|
|
300
304
|
] }),
|
|
301
305
|
/* @__PURE__ */ n(
|
|
302
|
-
|
|
306
|
+
h.List,
|
|
303
307
|
{
|
|
304
308
|
className: "humany-guide-category-dropdown-open",
|
|
305
309
|
items: g,
|
|
@@ -307,15 +311,15 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
307
311
|
ce,
|
|
308
312
|
{
|
|
309
313
|
item: N,
|
|
310
|
-
guideCategory:
|
|
314
|
+
guideCategory: p
|
|
311
315
|
},
|
|
312
316
|
N.id
|
|
313
317
|
)
|
|
314
318
|
}
|
|
315
319
|
)
|
|
316
|
-
] }) : /* @__PURE__ */ b(
|
|
320
|
+
] }) : /* @__PURE__ */ b(h.TopItem, { className: "humany-guide-category-dropdown-top-item", children: [
|
|
317
321
|
/* @__PURE__ */ b(
|
|
318
|
-
|
|
322
|
+
h.Item,
|
|
319
323
|
{
|
|
320
324
|
className: "humany-guide-category-dropdown-item",
|
|
321
325
|
onClick: () => {
|
|
@@ -323,14 +327,14 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
323
327
|
},
|
|
324
328
|
selected: !1,
|
|
325
329
|
children: [
|
|
326
|
-
|
|
330
|
+
S ? /* @__PURE__ */ n(v, { symbol: S }) : null,
|
|
327
331
|
/* @__PURE__ */ n(I, { children: w.title }),
|
|
328
332
|
/* @__PURE__ */ n(z, { ...w })
|
|
329
333
|
]
|
|
330
334
|
}
|
|
331
335
|
),
|
|
332
336
|
/* @__PURE__ */ n(
|
|
333
|
-
|
|
337
|
+
h.Toggler,
|
|
334
338
|
{
|
|
335
339
|
onBlur: () => s(!1),
|
|
336
340
|
onFocus: () => s(!0),
|
|
@@ -354,5 +358,5 @@ const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t })
|
|
|
354
358
|
);
|
|
355
359
|
};
|
|
356
360
|
export {
|
|
357
|
-
|
|
361
|
+
xe as default
|
|
358
362
|
};
|