@telia-ace/knowledge-widget-components-guide-category-dropdown 1.1.2-rc.0 → 1.1.2-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.
@@ -1,135 +1,135 @@
1
1
  import { jsxs as c, jsx as o, Fragment as j } from "react/jsx-runtime";
2
- import { loadingOpacity as B, contentBox as M, borderTabStyle as O, Link as G, linkTabStyle as R, List as A, list as E, Text as $, useProperties as C, useHover as P, SymbolBadge as y, useRouteData as W, useContainer as H, useIsTabbing as U, createEmptyComponent as q } from "@telia-ace/knowledge-widget-ui";
2
+ import { loadingOpacity as B, contentBox as M, borderTabStyle as O, Link as G, linkTabStyle as R, List as A, list as E, Text as $, useProperties as C, useHover as P, SymbolBadge as f, useRouteData as W, useContainer as H, useIsTabbing as U, createEmptyComponent as q } from "@telia-ace/knowledge-widget-ui";
3
3
  import { appendClassNames as T, createParams as J, formatUrl as K } from "@telia-ace/widget-utilities";
4
4
  import { useState as N, useEffect as Q } from "react";
5
5
  import { initialRouteFallback as V } from "@telia-ace/knowledge-widget-component-utilities";
6
6
  import { css as x } from "@emotion/react";
7
7
  import m from "@emotion/styled";
8
8
  const X = m.div`
9
- ${B}
10
- ${M}
9
+ ${B}
10
+ ${M}
11
11
  overflow: hidden;
12
- min-height: 50px;
13
- ${(e) => e["data-toggler-in-focus"] && e.isTabbing && x`
14
- && {
15
- ${O(e)}
16
- }
17
- `};
12
+ min-height: 50px;
13
+ ${(e) => e["data-toggler-in-focus"] && e.isTabbing && x`
14
+ && {
15
+ ${O(e)}
16
+ }
17
+ `};
18
18
  `, Y = m.button`
19
- background: none;
20
- border: 0;
21
- outline: 0;
22
- display: block;
23
- cursor: pointer;
24
- padding: 0;
25
- font-size: ${(e) => {
19
+ background: none;
20
+ border: 0;
21
+ outline: 0;
22
+ display: block;
23
+ cursor: pointer;
24
+ padding: 0;
25
+ font-size: ${(e) => {
26
26
  var t;
27
27
  return (t = e.theme.fonts) == null ? void 0 : t.normal;
28
28
  }};
29
- text-align: end;
30
- flex: 1 0 auto;
31
- svg {
32
- path,
33
- line {
34
- stroke: ${(e) => {
29
+ text-align: end;
30
+ flex: 1 0 auto;
31
+ svg {
32
+ path,
33
+ line {
34
+ stroke: ${(e) => {
35
35
  var t;
36
36
  return (t = e.theme.colors) == null ? void 0 : t.text;
37
37
  }};
38
- }
39
38
  }
39
+ }
40
40
  `, L = (e) => {
41
41
  var t, g, u, r, n, p, s, h;
42
42
  return x`
43
- font-size: ${(t = e.theme.fonts) == null ? void 0 : t.normal};
44
- text-align: left;
45
- text-align: left;
46
- text-decoration: none;
47
- font-weight: 300;
48
- display: flex;
49
- align-items: center;
50
- padding: ${(g = e.theme.sizes) == null ? void 0 : g.small};
51
- padding-left: ${(u = e.theme.sizes) == null ? void 0 : u.large};
52
- cursor: pointer;
53
- overflow: hidden;
54
- ${e.selected ? x`
55
- border-left: 2px solid ${(r = e.theme.colors) == null ? void 0 : r.primary};
56
- color: ${(n = e.theme.colors) == null ? void 0 : n.primary};
57
- ` : x`
58
- color: ${(p = e.theme.colors) == null ? void 0 : p.text};
59
- `};
43
+ font-size: ${(t = e.theme.fonts) == null ? void 0 : t.normal};
44
+ text-align: left;
45
+ text-align: left;
46
+ text-decoration: none;
47
+ font-weight: 300;
48
+ display: flex;
49
+ align-items: center;
50
+ padding: ${(g = e.theme.sizes) == null ? void 0 : g.small};
51
+ padding-left: ${(u = e.theme.sizes) == null ? void 0 : u.large};
52
+ cursor: pointer;
53
+ overflow: hidden;
54
+ ${e.selected ? x`
55
+ border-left: 2px solid ${(r = e.theme.colors) == null ? void 0 : r.primary};
56
+ color: ${(n = e.theme.colors) == null ? void 0 : n.primary};
57
+ ` : x`
58
+ color: ${(p = e.theme.colors) == null ? void 0 : p.text};
59
+ `};
60
60
 
61
- span {
62
- overflow: hidden;
63
- text-overflow: ellipsis;
64
- }
61
+ span {
62
+ overflow: hidden;
63
+ text-overflow: ellipsis;
64
+ }
65
65
 
66
- i {
67
- margin-right: ${(s = e.theme.sizes) == null ? void 0 : s.normal};
68
- font-size: ${(h = e.theme.fonts) == null ? void 0 : h.medium};
69
- min-height: 1em;
70
- min-width: 1em;
71
- }
66
+ i {
67
+ margin-right: ${(s = e.theme.sizes) == null ? void 0 : s.normal};
68
+ font-size: ${(h = e.theme.fonts) == null ? void 0 : h.medium};
69
+ min-height: 1em;
70
+ min-width: 1em;
71
+ }
72
72
  `;
73
73
  }, Z = m.div`
74
- ${L}
74
+ ${L}
75
75
  `, _ = m(G)`
76
- ${L}
77
- &:focus {
78
- outline: none;
79
- }
80
- &:focus-visible {
81
- span {
82
- ${R};
83
- }
76
+ ${L}
77
+ &:focus {
78
+ outline: none;
79
+ }
80
+ &:focus-visible {
81
+ span {
82
+ ${R};
84
83
  }
84
+ }
85
85
  `, ee = m.div`
86
- display: flex;
87
- justify-content: space-between;
88
- padding-right: ${(e) => {
86
+ display: flex;
87
+ justify-content: space-between;
88
+ padding-right: ${(e) => {
89
89
  var t;
90
90
  return (t = e.theme.sizes) == null ? void 0 : t.large;
91
91
  }};
92
- min-height: 52px;
93
- white-space: nowrap;
92
+ min-height: 52px;
93
+ white-space: nowrap;
94
94
 
95
- && {
96
- font-weight: normal;
95
+ && {
96
+ font-weight: normal;
97
97
 
98
- a {
99
- font-weight: normal;
100
- }
101
- }
102
- .humany-guide-category-dropdown-item {
103
- font-weight: normal;
98
+ a {
99
+ font-weight: normal;
104
100
  }
101
+ }
102
+ .humany-guide-category-dropdown-item {
103
+ font-weight: normal;
104
+ }
105
105
  `, te = m(A)`
106
- ${E}
107
- display: flex;
108
- justify-content: center;
109
- flex-direction: column;
110
- margin-right: ${(e) => {
106
+ ${E}
107
+ display: flex;
108
+ justify-content: center;
109
+ flex-direction: column;
110
+ margin-right: ${(e) => {
111
111
  var t;
112
112
  return (t = e.theme.sizes) == null ? void 0 : t.medium;
113
113
  }};
114
- margin-left: ${(e) => {
114
+ margin-left: ${(e) => {
115
115
  var t;
116
116
  return (t = e.theme.sizes) == null ? void 0 : t.large;
117
117
  }};
118
- margin-bottom: 22px;
119
- border-left: ${(e) => e.theme.border};
120
- li {
121
- margin: 0 0 ${(e) => {
118
+ margin-bottom: 22px;
119
+ border-left: ${(e) => e.theme.border};
120
+ li {
121
+ margin: 0 0 ${(e) => {
122
122
  var t;
123
123
  return (t = e.theme.sizes) == null ? void 0 : t.normal;
124
124
  }} -2px;
125
- }
126
- li:last-child {
127
- margin: 0 0 0 -2px;
128
- }
129
- flex-basis: 100%;
130
- border-width: 2px;
125
+ }
126
+ li:last-child {
127
+ margin: 0 0 0 -2px;
128
+ }
129
+ flex-basis: 100%;
130
+ border-width: 2px;
131
131
  `, oe = m($)`
132
- margin: 0 0 0 ${(e) => {
132
+ margin: 0 0 0 ${(e) => {
133
133
  var t;
134
134
  return (t = e.theme.sizes) == null ? void 0 : t.small;
135
135
  }};
@@ -148,7 +148,10 @@ const X = m.div`
148
148
  e,
149
149
  ")"
150
150
  ] });
151
- }, ne = ({ item: e, guideCategory: t }) => {
151
+ }, ne = ({
152
+ item: e,
153
+ guideCategory: t
154
+ }) => {
152
155
  const {
153
156
  route: g = "browse",
154
157
  categoryAriaLabel: u = "",
@@ -158,17 +161,19 @@ const X = m.div`
158
161
  return /* @__PURE__ */ o("li", { ref: s, children: /* @__PURE__ */ c(
159
162
  a.Link,
160
163
  {
161
- ...V(e, g, n, "category"),
162
- "aria-pressed": d,
163
- "aria-label": (d ? r : u).replace(
164
- "{{category}}",
165
- b
164
+ ...V(
165
+ e,
166
+ g,
167
+ n,
168
+ "category"
166
169
  ),
170
+ "aria-pressed": d,
171
+ "aria-label": (d ? r : u).replace("{{category}}", b),
167
172
  className: "humany-guide-category-dropdown-link",
168
173
  "aria-current": d,
169
174
  selected: d,
170
175
  children: [
171
- (d || p) && l ? /* @__PURE__ */ o(y, { symbol: l }) : i && /* @__PURE__ */ o(y, { symbol: i }),
176
+ (d || p) && l ? /* @__PURE__ */ o(f, { symbol: l }) : i && /* @__PURE__ */ o(f, { symbol: i }),
172
177
  /* @__PURE__ */ o($, { children: b }),
173
178
  /* @__PURE__ */ o(v, { ...e })
174
179
  ]
@@ -188,7 +193,7 @@ const X = m.div`
188
193
  ...t,
189
194
  className: T(e, "humany-guide-category-dropdown")
190
195
  });
191
- const f = s.find((w) => w.id === k) || n, z = f.activeSymbol || f.symbol;
196
+ const y = s.find((w) => w.id === k) || n, z = y.activeSymbol || y.symbol;
192
197
  return /* @__PURE__ */ o(
193
198
  a.Wrapper,
194
199
  {
@@ -214,7 +219,7 @@ const X = m.div`
214
219
  }),
215
220
  selected: !1,
216
221
  children: [
217
- n.symbol ? /* @__PURE__ */ o(y, { symbol: n.symbol }) : null,
222
+ n.symbol ? /* @__PURE__ */ o(f, { symbol: n.symbol }) : null,
218
223
  /* @__PURE__ */ o($, { children: n.title }),
219
224
  /* @__PURE__ */ o(v, { ...n })
220
225
  ]
@@ -230,9 +235,9 @@ const X = m.div`
230
235
  l(!i);
231
236
  },
232
237
  "aria-expanded": "true",
233
- "aria-label": f.title,
238
+ "aria-label": n.title,
234
239
  children: /* @__PURE__ */ o(
235
- y,
240
+ f,
236
241
  {
237
242
  size: 18,
238
243
  symbol: { type: "Svg", content: "caret-up" }
@@ -266,9 +271,9 @@ const X = m.div`
266
271
  },
267
272
  selected: !1,
268
273
  children: [
269
- z ? /* @__PURE__ */ o(y, { symbol: z }) : null,
270
- /* @__PURE__ */ o($, { children: f.title }),
271
- /* @__PURE__ */ o(v, { ...f })
274
+ z ? /* @__PURE__ */ o(f, { symbol: z }) : null,
275
+ /* @__PURE__ */ o($, { children: y.title }),
276
+ /* @__PURE__ */ o(v, { ...y })
272
277
  ]
273
278
  }
274
279
  ),
@@ -282,9 +287,9 @@ const X = m.div`
282
287
  l(!i);
283
288
  },
284
289
  "aria-expanded": "false",
285
- "aria-label": f.title,
290
+ "aria-label": y.title,
286
291
  children: /* @__PURE__ */ o(
287
- y,
292
+ f,
288
293
  {
289
294
  size: 18,
290
295
  symbol: { type: "Svg", content: "caret-down" }
@@ -1,105 +1,105 @@
1
1
  "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),s=require("@telia-ace/knowledge-widget-ui"),b=require("@telia-ace/widget-utilities"),$=require("react"),I=require("@telia-ace/knowledge-widget-component-utilities"),w=require("@emotion/react"),g=require("@emotion/styled"),B=g.div`
2
- ${s.loadingOpacity}
3
- ${s.contentBox}
2
+ ${s.loadingOpacity}
3
+ ${s.contentBox}
4
4
  overflow: hidden;
5
- min-height: 50px;
6
- ${e=>e["data-toggler-in-focus"]&&e.isTabbing&&w.css`
7
- && {
8
- ${s.borderTabStyle(e)}
9
- }
10
- `};
5
+ min-height: 50px;
6
+ ${e=>e["data-toggler-in-focus"]&&e.isTabbing&&w.css`
7
+ && {
8
+ ${s.borderTabStyle(e)}
9
+ }
10
+ `};
11
11
  `,L=g.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
- }
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}};
26
25
  }
26
+ }
27
27
  `,k=e=>{var t,m,u,i,n,y,l,h;return w.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: ${(m=e.theme.sizes)==null?void 0:m.small};
36
- padding-left: ${(u=e.theme.sizes)==null?void 0:u.large};
37
- cursor: pointer;
38
- overflow: hidden;
39
- ${e.selected?w.css`
40
- border-left: 2px solid ${(i=e.theme.colors)==null?void 0:i.primary};
41
- color: ${(n=e.theme.colors)==null?void 0:n.primary};
42
- `:w.css`
43
- color: ${(y=e.theme.colors)==null?void 0:y.text};
44
- `};
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: ${(m=e.theme.sizes)==null?void 0:m.small};
36
+ padding-left: ${(u=e.theme.sizes)==null?void 0:u.large};
37
+ cursor: pointer;
38
+ overflow: hidden;
39
+ ${e.selected?w.css`
40
+ border-left: 2px solid ${(i=e.theme.colors)==null?void 0:i.primary};
41
+ color: ${(n=e.theme.colors)==null?void 0:n.primary};
42
+ `:w.css`
43
+ color: ${(y=e.theme.colors)==null?void 0:y.text};
44
+ `};
45
45
 
46
- span {
47
- overflow: hidden;
48
- text-overflow: ellipsis;
49
- }
46
+ span {
47
+ overflow: hidden;
48
+ text-overflow: ellipsis;
49
+ }
50
50
 
51
- i {
52
- margin-right: ${(l=e.theme.sizes)==null?void 0:l.normal};
53
- font-size: ${(h=e.theme.fonts)==null?void 0:h.medium};
54
- min-height: 1em;
55
- min-width: 1em;
56
- }
51
+ i {
52
+ margin-right: ${(l=e.theme.sizes)==null?void 0:l.normal};
53
+ font-size: ${(h=e.theme.fonts)==null?void 0:h.medium};
54
+ min-height: 1em;
55
+ min-width: 1em;
56
+ }
57
57
  `},q=g.div`
58
- ${k}
58
+ ${k}
59
59
  `,F=g(s.Link)`
60
- ${k}
61
- &:focus {
62
- outline: none;
63
- }
64
- &:focus-visible {
65
- span {
66
- ${s.linkTabStyle};
67
- }
60
+ ${k}
61
+ &:focus {
62
+ outline: none;
63
+ }
64
+ &:focus-visible {
65
+ span {
66
+ ${s.linkTabStyle};
68
67
  }
68
+ }
69
69
  `,D=g.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;
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
75
 
76
- && {
77
- font-weight: normal;
76
+ && {
77
+ font-weight: normal;
78
78
 
79
- a {
80
- font-weight: normal;
81
- }
82
- }
83
- .humany-guide-category-dropdown-item {
84
- font-weight: normal;
79
+ a {
80
+ font-weight: normal;
85
81
  }
82
+ }
83
+ .humany-guide-category-dropdown-item {
84
+ font-weight: normal;
85
+ }
86
86
  `,M=g(s.List)`
87
- ${s.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;
87
+ ${s.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
103
  `,O=g(s.Text)`
104
- margin: 0 0 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}};
105
- `,a={Wrapper:B,Toggler:L,List:M,Item:q,Link:F,TopItem:D,MatchCount:O},C=({matches:e})=>{const{showMatchCount:t=!1}=s.useProperties();return!t||typeof e>"u"?null:o.jsxs(a.MatchCount,{children:["(",e,")"]})},P=({item:e,guideCategory:t})=>{const{route:m="browse",categoryAriaLabel:u="",activeCategoryAriaLabel:i="",fallbackOnInitialRoute:n=!1}=s.useProperties(),[y,l]=s.useHover(),{id:h,title:f,symbol:r,activeSymbol:d}=e,c=t===h;return o.jsx("li",{ref:l,children:o.jsxs(a.Link,{...I.initialRouteFallback(e,m,n,"category"),"aria-pressed":c,"aria-label":(c?i:u).replace("{{category}}",f),className:"humany-guide-category-dropdown-link","aria-current":c,selected:c,children:[(c||y)&&d?o.jsx(s.SymbolBadge,{symbol:d}):r&&o.jsx(s.SymbolBadge,{symbol:r}),o.jsx(s.Text,{children:f}),o.jsx(C,{...e})]})})},R=({className:e,...t})=>{const m=s.useRouteData(),[u,i]=$.useState(!1),{parent:n,route:y="browse",categories:l=[],loading:h=!1}=s.useProperties(),f=s.useContainer(),[r,d]=$.useState(!1),{params:c}=m,v=s.useIsTabbing(),{guideCategory:j,tag:T,phrase:z,sorting:N}=c;if($.useEffect(()=>{r&&d(!1)},[j]),h||!n||!l.length)return s.createEmptyComponent(f,{...t,className:b.appendClassNames(e,"humany-guide-category-dropdown")});const p=l.find(x=>x.id===j)||n,S=p.activeSymbol||p.symbol;return o.jsx(a.Wrapper,{...t,"data-loading":!1,"data-toggler-in-focus":u,"aria-expanded":r,isTabbing:v,className:b.appendClassNames(e,"humany-guide-category-dropdown"),children:r?o.jsxs(o.Fragment,{children:[o.jsxs(a.TopItem,{className:"humany-guide-category-dropdown-top-item",children:[o.jsxs(a.Link,{className:"humany-guide-category-dropdown-link",routeName:y,params:b.createParams({tag:T,phrase:z,sorting:N,guideCategory:n.id,uriName:b.formatUrl(n.title)}),selected:!1,children:[n.symbol?o.jsx(s.SymbolBadge,{symbol:n.symbol}):null,o.jsx(s.Text,{children:n.title}),o.jsx(C,{...n})]}),o.jsx(a.Toggler,{onBlur:()=>i(!1),onFocus:()=>i(!0),className:"humany-guide-category-dropdown-toggler",onClick:()=>{d(!r)},"aria-expanded":"true","aria-label":p.title,children:o.jsx(s.SymbolBadge,{size:18,symbol:{type:"Svg",content:"caret-up"}})})]}),o.jsx(a.List,{className:"humany-guide-category-dropdown-open",items:l,renderItem:x=>o.jsx(P,{item:x,guideCategory:j},x.id)})]}):o.jsxs(a.TopItem,{className:"humany-guide-category-dropdown-top-item",children:[o.jsxs(a.Item,{className:"humany-guide-category-dropdown-item",onClick:()=>{d(!r)},selected:!1,children:[S?o.jsx(s.SymbolBadge,{symbol:S}):null,o.jsx(s.Text,{children:p.title}),o.jsx(C,{...p})]}),o.jsx(a.Toggler,{onBlur:()=>i(!1),onFocus:()=>i(!0),className:"humany-guide-category-dropdown-toggler",onClick:()=>{d(!r)},"aria-expanded":"false","aria-label":p.title,children:o.jsx(s.SymbolBadge,{size:18,symbol:{type:"Svg",content:"caret-down"}})})]})})};exports.default=R;
104
+ margin: 0 0 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}};
105
+ `,a={Wrapper:B,Toggler:L,List:M,Item:q,Link:F,TopItem:D,MatchCount:O},C=({matches:e})=>{const{showMatchCount:t=!1}=s.useProperties();return!t||typeof e>"u"?null:o.jsxs(a.MatchCount,{children:["(",e,")"]})},P=({item:e,guideCategory:t})=>{const{route:m="browse",categoryAriaLabel:u="",activeCategoryAriaLabel:i="",fallbackOnInitialRoute:n=!1}=s.useProperties(),[y,l]=s.useHover(),{id:h,title:f,symbol:r,activeSymbol:d}=e,c=t===h;return o.jsx("li",{ref:l,children:o.jsxs(a.Link,{...I.initialRouteFallback(e,m,n,"category"),"aria-pressed":c,"aria-label":(c?i:u).replace("{{category}}",f),className:"humany-guide-category-dropdown-link","aria-current":c,selected:c,children:[(c||y)&&d?o.jsx(s.SymbolBadge,{symbol:d}):r&&o.jsx(s.SymbolBadge,{symbol:r}),o.jsx(s.Text,{children:f}),o.jsx(C,{...e})]})})},R=({className:e,...t})=>{const m=s.useRouteData(),[u,i]=$.useState(!1),{parent:n,route:y="browse",categories:l=[],loading:h=!1}=s.useProperties(),f=s.useContainer(),[r,d]=$.useState(!1),{params:c}=m,v=s.useIsTabbing(),{guideCategory:j,tag:T,phrase:z,sorting:N}=c;if($.useEffect(()=>{r&&d(!1)},[j]),h||!n||!l.length)return s.createEmptyComponent(f,{...t,className:b.appendClassNames(e,"humany-guide-category-dropdown")});const p=l.find(x=>x.id===j)||n,S=p.activeSymbol||p.symbol;return o.jsx(a.Wrapper,{...t,"data-loading":!1,"data-toggler-in-focus":u,"aria-expanded":r,isTabbing:v,className:b.appendClassNames(e,"humany-guide-category-dropdown"),children:r?o.jsxs(o.Fragment,{children:[o.jsxs(a.TopItem,{className:"humany-guide-category-dropdown-top-item",children:[o.jsxs(a.Link,{className:"humany-guide-category-dropdown-link",routeName:y,params:b.createParams({tag:T,phrase:z,sorting:N,guideCategory:n.id,uriName:b.formatUrl(n.title)}),selected:!1,children:[n.symbol?o.jsx(s.SymbolBadge,{symbol:n.symbol}):null,o.jsx(s.Text,{children:n.title}),o.jsx(C,{...n})]}),o.jsx(a.Toggler,{onBlur:()=>i(!1),onFocus:()=>i(!0),className:"humany-guide-category-dropdown-toggler",onClick:()=>{d(!r)},"aria-expanded":"true","aria-label":n.title,children:o.jsx(s.SymbolBadge,{size:18,symbol:{type:"Svg",content:"caret-up"}})})]}),o.jsx(a.List,{className:"humany-guide-category-dropdown-open",items:l,renderItem:x=>o.jsx(P,{item:x,guideCategory:j},x.id)})]}):o.jsxs(a.TopItem,{className:"humany-guide-category-dropdown-top-item",children:[o.jsxs(a.Item,{className:"humany-guide-category-dropdown-item",onClick:()=>{d(!r)},selected:!1,children:[S?o.jsx(s.SymbolBadge,{symbol:S}):null,o.jsx(s.Text,{children:p.title}),o.jsx(C,{...p})]}),o.jsx(a.Toggler,{onBlur:()=>i(!1),onFocus:()=>i(!0),className:"humany-guide-category-dropdown-toggler",onClick:()=>{d(!r)},"aria-expanded":"false","aria-label":p.title,children:o.jsx(s.SymbolBadge,{size:18,symbol:{type:"Svg",content:"caret-down"}})})]})})};exports.default=R;
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";const g=require("@telia-ace/knowledge-data-client"),l=require("@telia-ace/knowledge-widget-core"),v=require("@telia-ace/knowledge-widget-ui"),D=(e,a,n)=>!n||n.length<1?a:h(e,a,null,n),h=(e,a,n,o)=>{if(e.find(s=>s.id===o)||!o)return n||a;for(let s=0;s<e.length;s+=1){const t=e[s];if(t.items){const r=h(t.items,a,t,o);if(r)return r}}},P=e=>e.matches&&e.matches>0,q=e=>{const{events:a}=e.get("$widget"),[n,o]=l.createEventSubscriber(a);return v.createReactComponent(e,"guide-category-dropdown",Promise.resolve().then(()=>require("./guide-category-dropdown-2cb0c652.js")),i=>{const s=t=>{i.writeProperties({loading:!0}),i.actions.dispatch("fetch",{params:t}).then(()=>{i.writeProperties({loading:!1})})};i.actions.create("fetch",({parent:t,categories:r})=>{i.writeProperties({parent:t,categories:r,loading:!1})}),e.getAsync("router").then(t=>{const{params:r}=t.getRouteData();s(r)}),n("router:changed",(t,{current:r})=>{s(r.routeData.params)})}).then(()=>l.extendComponent(e,"guide-category-dropdown",i=>{i.actions.watch("guide-category-dropdown.fetch",(s,t)=>{const{matchFilters:r={search:!1,tag:!1},rootCategoryHeader:f}=i.properties(),{params:{phrase:p,guideCategory:w,tag:m}}=s;return g.DataClient.getInstance(e).then(b=>b.fetch(g.DataType.GuideCategories,{searchPhrase:r.search?p:void 0,tagId:r.tag?m:void 0}).then(({categories:d,matches:C})=>{var u;const c=D(d,{matches:C,id:"0",title:f,items:d},w);return t({parent:c,categories:(u=c==null?void 0:c.items)==null?void 0:u.filter(P)})}))})})).then(()=>{o()})};module.exports=q;
1
+ "use strict";const g=require("@telia-ace/knowledge-data-client"),l=require("@telia-ace/knowledge-widget-core"),v=require("@telia-ace/knowledge-widget-ui"),D=(e,a,n)=>!n||n.length<1?a:h(e,a,null,n),h=(e,a,n,o)=>{if(e.find(s=>s.id===o)||!o)return n||a;for(let s=0;s<e.length;s+=1){const t=e[s];if(t.items){const r=h(t.items,a,t,o);if(r)return r}}},P=e=>e.matches&&e.matches>0,q=e=>{const{events:a}=e.get("$widget"),[n,o]=l.createEventSubscriber(a);return v.createReactComponent(e,"guide-category-dropdown",Promise.resolve().then(()=>require("./guide-category-dropdown-61b15156.js")),i=>{const s=t=>{i.writeProperties({loading:!0}),i.actions.dispatch("fetch",{params:t}).then(()=>{i.writeProperties({loading:!1})})};i.actions.create("fetch",({parent:t,categories:r})=>{i.writeProperties({parent:t,categories:r,loading:!1})}),e.getAsync("router").then(t=>{const{params:r}=t.getRouteData();s(r)}),n("router:changed",(t,{current:r})=>{s(r.routeData.params)})}).then(()=>l.extendComponent(e,"guide-category-dropdown",i=>{i.actions.watch("guide-category-dropdown.fetch",(s,t)=>{const{matchFilters:r={search:!1,tag:!1},rootCategoryHeader:f}=i.properties(),{params:{phrase:p,guideCategory:w,tag:m}}=s;return g.DataClient.getInstance(e).then(b=>b.fetch(g.DataType.GuideCategories,{searchPhrase:r.search?p:void 0,tagId:r.tag?m:void 0}).then(({categories:d,matches:C})=>{var u;const c=D(d,{matches:C,id:"0",title:f,items:d},w);return t({parent:c,categories:(u=c==null?void 0:c.items)==null?void 0:u.filter(P)})}))})})).then(()=>{o()})};module.exports=q;
package/index.mjs CHANGED
@@ -17,7 +17,7 @@ const y = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a,
17
17
  return P(
18
18
  e,
19
19
  "guide-category-dropdown",
20
- import("./guide-category-dropdown-db6f2b55.mjs"),
20
+ import("./guide-category-dropdown-1d1ef79b.mjs"),
21
21
  (i) => {
22
22
  const s = (t) => {
23
23
  i.writeProperties({ loading: !0 }), i.actions.dispatch("fetch", { params: t }).then(() => {
@@ -37,39 +37,46 @@ const y = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a,
37
37
  s(r.routeData.params);
38
38
  });
39
39
  }
40
- ).then(() => D(e, "guide-category-dropdown", (i) => {
41
- i.actions.watch("guide-category-dropdown.fetch", (s, t) => {
42
- const {
43
- matchFilters: r = {
44
- search: !1,
45
- tag: !1
46
- },
47
- rootCategoryHeader: u
48
- } = i.properties(), {
49
- params: { phrase: l, guideCategory: g, tag: p }
50
- } = s;
51
- return b.getInstance(e).then((m) => m.fetch(v.GuideCategories, {
52
- searchPhrase: r.search ? l : void 0,
53
- tagId: r.tag ? p : void 0
54
- }).then(({ categories: d, matches: w }) => {
55
- var f;
56
- const c = y(
57
- d,
58
- {
59
- matches: w,
60
- id: "0",
61
- title: u,
62
- items: d
63
- },
64
- g
65
- );
66
- return t({
67
- parent: c,
68
- categories: (f = c == null ? void 0 : c.items) == null ? void 0 : f.filter(R)
69
- });
70
- }));
71
- });
72
- })).then(() => {
40
+ ).then(() => D(
41
+ e,
42
+ "guide-category-dropdown",
43
+ (i) => {
44
+ i.actions.watch(
45
+ "guide-category-dropdown.fetch",
46
+ (s, t) => {
47
+ const {
48
+ matchFilters: r = {
49
+ search: !1,
50
+ tag: !1
51
+ },
52
+ rootCategoryHeader: u
53
+ } = i.properties(), {
54
+ params: { phrase: l, guideCategory: g, tag: p }
55
+ } = s;
56
+ return b.getInstance(e).then((m) => m.fetch(v.GuideCategories, {
57
+ searchPhrase: r.search ? l : void 0,
58
+ tagId: r.tag ? p : void 0
59
+ }).then(({ categories: d, matches: w }) => {
60
+ var f;
61
+ const c = y(
62
+ d,
63
+ {
64
+ matches: w,
65
+ id: "0",
66
+ title: u,
67
+ items: d
68
+ },
69
+ g
70
+ );
71
+ return t({
72
+ parent: c,
73
+ categories: (f = c == null ? void 0 : c.items) == null ? void 0 : f.filter(R)
74
+ });
75
+ }));
76
+ }
77
+ );
78
+ }
79
+ )).then(() => {
73
80
  o();
74
81
  });
75
82
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-components-guide-category-dropdown",
3
- "version": "1.1.2-rc.0",
3
+ "version": "1.1.2-rc.2",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -10,11 +10,11 @@
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "@telia-ace/knowledge-widget-core": "^1.1.2-rc.0",
14
- "@telia-ace/knowledge-widget-component-utilities": "^1.1.2-rc.0",
15
- "@telia-ace/knowledge-widget-ui": "^1.1.2-rc.0",
16
- "@telia-ace/widget-utilities": "^1.1.2-rc.0",
17
- "@telia-ace/knowledge-data-client": "^1.1.2-rc.0",
13
+ "@telia-ace/knowledge-widget-core": "^1.1.2-rc.2",
14
+ "@telia-ace/knowledge-widget-component-utilities": "^1.1.2-rc.2",
15
+ "@telia-ace/knowledge-widget-ui": "^1.1.2-rc.2",
16
+ "@telia-ace/widget-utilities": "^1.1.2-rc.2",
17
+ "@telia-ace/knowledge-data-client": "^1.1.2-rc.2",
18
18
  "@webprovisions/platform": "^1.1.4"
19
19
  },
20
20
  "peerDependencies": {