@telia-ace/knowledge-widget-components-guide-category-dropdown 0.0.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.
@@ -0,0 +1,306 @@
1
+ import { jsxs as c, jsx as o, Fragment as D } from "react/jsx-runtime";
2
+ import { loadingOpacity as j, contentBox as B, borderTabStyle as M, Link as O, linkTabStyle as G, List as R, list as A, Text as $, useProperties as C, useHover as E, SymbolBadge as f, useRouteData as P, useContainer as W, useIsTabbing as H, createEmptyComponent as U } from "@telia-ace/knowledge-widget-ui";
3
+ import { appendClassNames as z, createParams as q, formatUrl as J } from "@telia-ace/widget-utilities";
4
+ import { useState as T, useEffect as K } from "react";
5
+ import { initialRouteFallback as Q } from "@telia-ace/knowledge-widget-component-utilities";
6
+ import { css as x } from "@emotion/react";
7
+ import m from "@emotion/styled";
8
+ const V = m.div`
9
+ ${j}
10
+ ${B}
11
+ overflow: hidden;
12
+ min-height: 50px;
13
+ ${(e) => e["data-toggler-in-focus"] && e.isTabbing && x`
14
+ && {
15
+ ${M(e)}
16
+ }
17
+ `};
18
+ `, X = m.button`
19
+ background: none;
20
+ border: 0;
21
+ outline: 0;
22
+ display: block;
23
+ cursor: pointer;
24
+ padding: 0;
25
+ font-size: ${(e) => {
26
+ var t;
27
+ return (t = e.theme.fonts) == null ? void 0 : t.normal;
28
+ }};
29
+ text-align: end;
30
+ flex: 1 0 auto;
31
+ svg {
32
+ path,
33
+ line {
34
+ stroke: ${(e) => {
35
+ var t;
36
+ return (t = e.theme.colors) == null ? void 0 : t.text;
37
+ }};
38
+ }
39
+ }
40
+ `, N = (e) => {
41
+ var t, g, u, r, n, p, s, h;
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
+ `};
60
+
61
+ span {
62
+ overflow: hidden;
63
+ text-overflow: ellipsis;
64
+ }
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
+ }
72
+ `;
73
+ }, Y = m.div`
74
+ ${N}
75
+ `, Z = m(O)`
76
+ ${N}
77
+ &:focus {
78
+ outline: none;
79
+ }
80
+ &:focus-visible {
81
+ span {
82
+ ${G};
83
+ }
84
+ }
85
+ `, _ = m.div`
86
+ display: flex;
87
+ justify-content: space-between;
88
+ padding-right: ${(e) => {
89
+ var t;
90
+ return (t = e.theme.sizes) == null ? void 0 : t.large;
91
+ }};
92
+ min-height: 52px;
93
+ white-space: nowrap;
94
+
95
+ && {
96
+ font-weight: normal;
97
+
98
+ a {
99
+ font-weight: normal;
100
+ }
101
+ }
102
+ .humany-guide-category-dropdown-item {
103
+ font-weight: normal;
104
+ }
105
+ `, ee = m(R)`
106
+ ${A}
107
+ display: flex;
108
+ justify-content: center;
109
+ flex-direction: column;
110
+ margin-right: ${(e) => {
111
+ var t;
112
+ return (t = e.theme.sizes) == null ? void 0 : t.medium;
113
+ }};
114
+ margin-left: ${(e) => {
115
+ var t;
116
+ return (t = e.theme.sizes) == null ? void 0 : t.large;
117
+ }};
118
+ margin-bottom: 22px;
119
+ border-left: ${(e) => e.theme.border};
120
+ li {
121
+ margin: 0 0 ${(e) => {
122
+ var t;
123
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
124
+ }} -2px;
125
+ }
126
+ li:last-child {
127
+ margin: 0 0 0 -2px;
128
+ }
129
+ flex-basis: 100%;
130
+ border-width: 2px;
131
+ `, te = m($)`
132
+ margin: 0 0 0 ${(e) => {
133
+ var t;
134
+ return (t = e.theme.sizes) == null ? void 0 : t.small;
135
+ }};
136
+ `, a = {
137
+ Wrapper: V,
138
+ Toggler: X,
139
+ List: ee,
140
+ Item: Y,
141
+ Link: Z,
142
+ TopItem: _,
143
+ MatchCount: te
144
+ }, v = ({ matches: e }) => {
145
+ const { showMatchCount: t = !1 } = C();
146
+ return !t || typeof e > "u" ? null : /* @__PURE__ */ c(a.MatchCount, { children: [
147
+ "(",
148
+ e,
149
+ ")"
150
+ ] });
151
+ }, oe = ({
152
+ item: e,
153
+ guideCategory: t
154
+ }) => {
155
+ const {
156
+ route: g = "browse",
157
+ categoryAriaLabel: u = "",
158
+ activeCategoryAriaLabel: r = "",
159
+ fallbackOnInitialRoute: n = !1
160
+ } = C(), [p, s] = E(), { id: h, title: y, symbol: i, activeSymbol: l } = e, d = t === h;
161
+ return /* @__PURE__ */ o("li", { ref: s, children: /* @__PURE__ */ c(
162
+ a.Link,
163
+ {
164
+ ...Q(
165
+ e,
166
+ g,
167
+ n,
168
+ "category"
169
+ ),
170
+ "aria-pressed": d,
171
+ "aria-label": (d ? r : u).replace("{{category}}", y),
172
+ className: "humany-guide-category-dropdown-link",
173
+ "aria-current": d,
174
+ selected: d,
175
+ children: [
176
+ (d || p) && l ? /* @__PURE__ */ o(f, { symbol: l }) : i && /* @__PURE__ */ o(f, { symbol: i }),
177
+ /* @__PURE__ */ o($, { children: y }),
178
+ /* @__PURE__ */ o(v, { ...e })
179
+ ]
180
+ }
181
+ ) });
182
+ }, ce = ({ className: e, ...t }) => {
183
+ const g = P(), [u, r] = T(!1), {
184
+ parent: n,
185
+ route: p = "browse",
186
+ categories: s = [],
187
+ loading: h = !1
188
+ } = C(), y = W(), [i, l] = T(!1), { params: d } = g, L = H(), { guideCategory: k, tag: I, phrase: S, sorting: F } = d;
189
+ if (K(() => {
190
+ i && l(!1);
191
+ }, [k]), h || !n || !s.length)
192
+ return U(y, {
193
+ ...t,
194
+ className: z(e, "humany-guide-category-dropdown")
195
+ });
196
+ const b = s.find((w) => w.id === k) || n;
197
+ return b.activeSymbol || b.symbol, /* @__PURE__ */ o(
198
+ a.Wrapper,
199
+ {
200
+ ...t,
201
+ "data-loading": !1,
202
+ "data-toggler-in-focus": u,
203
+ "aria-expanded": i,
204
+ isTabbing: L,
205
+ className: z(e, "humany-guide-category-dropdown"),
206
+ children: i ? /* @__PURE__ */ c(D, { children: [
207
+ /* @__PURE__ */ c(a.TopItem, { className: "humany-guide-category-dropdown-top-item", children: [
208
+ /* @__PURE__ */ c(
209
+ a.Link,
210
+ {
211
+ className: "humany-guide-category-dropdown-link",
212
+ routeName: p,
213
+ params: q({
214
+ tag: I,
215
+ phrase: S,
216
+ sorting: F,
217
+ guideCategory: n.id,
218
+ uriName: J(n.title)
219
+ }),
220
+ selected: !1,
221
+ children: [
222
+ n.symbol ? /* @__PURE__ */ o(f, { symbol: n.symbol }) : null,
223
+ /* @__PURE__ */ o($, { children: n.title }),
224
+ /* @__PURE__ */ o(v, { ...n })
225
+ ]
226
+ }
227
+ ),
228
+ /* @__PURE__ */ o(
229
+ a.Toggler,
230
+ {
231
+ onBlur: () => r(!1),
232
+ onFocus: () => r(!0),
233
+ className: "humany-guide-category-dropdown-toggler",
234
+ onClick: () => {
235
+ l(!i);
236
+ },
237
+ "aria-expanded": "true",
238
+ "aria-label": n.title,
239
+ children: /* @__PURE__ */ o(
240
+ f,
241
+ {
242
+ size: 18,
243
+ symbol: { type: "Svg", content: "caret-up" }
244
+ }
245
+ )
246
+ }
247
+ )
248
+ ] }),
249
+ /* @__PURE__ */ o(
250
+ a.List,
251
+ {
252
+ className: "humany-guide-category-dropdown-open",
253
+ items: s,
254
+ renderItem: (w) => /* @__PURE__ */ o(
255
+ oe,
256
+ {
257
+ item: w,
258
+ guideCategory: k
259
+ },
260
+ w.id
261
+ )
262
+ }
263
+ )
264
+ ] }) : /* @__PURE__ */ c(a.TopItem, { className: "humany-guide-category-dropdown-top-item", children: [
265
+ /* @__PURE__ */ c(
266
+ a.Item,
267
+ {
268
+ className: "humany-guide-category-dropdown-item",
269
+ onClick: () => {
270
+ l(!i);
271
+ },
272
+ selected: !1,
273
+ children: [
274
+ n.symbol ? /* @__PURE__ */ o(f, { symbol: n.symbol }) : null,
275
+ /* @__PURE__ */ o($, { children: n.title }),
276
+ /* @__PURE__ */ o(v, { ...b })
277
+ ]
278
+ }
279
+ ),
280
+ /* @__PURE__ */ o(
281
+ a.Toggler,
282
+ {
283
+ onBlur: () => r(!1),
284
+ onFocus: () => r(!0),
285
+ className: "humany-guide-category-dropdown-toggler",
286
+ onClick: () => {
287
+ l(!i);
288
+ },
289
+ "aria-expanded": "false",
290
+ "aria-label": b.title,
291
+ children: /* @__PURE__ */ o(
292
+ f,
293
+ {
294
+ size: 18,
295
+ symbol: { type: "Svg", content: "caret-down" }
296
+ }
297
+ )
298
+ }
299
+ )
300
+ ] })
301
+ }
302
+ );
303
+ };
304
+ export {
305
+ ce as default
306
+ };
@@ -0,0 +1,105 @@
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"),N=require("@telia-ace/knowledge-widget-component-utilities"),w=require("@emotion/react"),g=require("@emotion/styled"),I=g.div`
2
+ ${s.loadingOpacity}
3
+ ${s.contentBox}
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
+ `};
11
+ `,B=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
+ }
26
+ }
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
+ `};
45
+
46
+ span {
47
+ overflow: hidden;
48
+ text-overflow: ellipsis;
49
+ }
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
+ }
57
+ `},L=g.div`
58
+ ${k}
59
+ `,q=g(s.Link)`
60
+ ${k}
61
+ &:focus {
62
+ outline: none;
63
+ }
64
+ &:focus-visible {
65
+ span {
66
+ ${s.linkTabStyle};
67
+ }
68
+ }
69
+ `,F=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;
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
+ `,D=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;
103
+ `,M=g(s.Text)`
104
+ margin: 0 0 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}};
105
+ `,a={Wrapper:I,Toggler:B,List:D,Item:L,Link:q,TopItem:F,MatchCount:M},C=({matches:e})=>{const{showMatchCount:t=!1}=s.useProperties();return!t||typeof e>"u"?null:o.jsxs(a.MatchCount,{children:["(",e,")"]})},O=({item:e,guideCategory:t})=>{const{route:m="browse",categoryAriaLabel:u="",activeCategoryAriaLabel:i="",fallbackOnInitialRoute:n=!1}=s.useProperties(),[y,l]=s.useHover(),{id:h,title:p,symbol:r,activeSymbol:d}=e,c=t===h;return o.jsx("li",{ref:l,children:o.jsxs(a.Link,{...N.initialRouteFallback(e,m,n,"category"),"aria-pressed":c,"aria-label":(c?i:u).replace("{{category}}",p),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:p}),o.jsx(C,{...e})]})})},P=({className:e,...t})=>{const m=s.useRouteData(),[u,i]=$.useState(!1),{parent:n,route:y="browse",categories:l=[],loading:h=!1}=s.useProperties(),p=s.useContainer(),[r,d]=$.useState(!1),{params:c}=m,v=s.useIsTabbing(),{guideCategory:j,tag:S,phrase:T,sorting:z}=c;if($.useEffect(()=>{r&&d(!1)},[j]),h||!n||!l.length)return s.createEmptyComponent(p,{...t,className:b.appendClassNames(e,"humany-guide-category-dropdown")});const f=l.find(x=>x.id===j)||n;return f.activeSymbol||f.symbol,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:S,phrase:T,sorting:z,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(O,{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:[n.symbol?o.jsx(s.SymbolBadge,{symbol:n.symbol}):null,o.jsx(s.Text,{children:n.title}),o.jsx(C,{...f})]}),o.jsx(a.Toggler,{onBlur:()=>i(!1),onFocus:()=>i(!0),className:"humany-guide-category-dropdown-toggler",onClick:()=>{d(!r)},"aria-expanded":"false","aria-label":f.title,children:o.jsx(s.SymbolBadge,{size:18,symbol:{type:"Svg",content:"caret-down"}})})]})})};exports.default=P;
@@ -0,0 +1,17 @@
1
+ import { MatchFilterProperties } from '../../utilities/src/index.ts';
2
+ import { Category } from '../../../knowledge/core/src/index.ts';
3
+ import { Container } from '@webprovisions/platform';
4
+
5
+ export type GuideCategoryDropdownComponentProps = {
6
+ matchFilters?: Partial<MatchFilterProperties>;
7
+ rootCategoryHeader: string;
8
+ route?: string;
9
+ categoryAriaLabel?: string;
10
+ activeCategoryAriaLabel?: string;
11
+ parent?: Category;
12
+ categories?: Category[];
13
+ showMatchCount?: boolean;
14
+ fallbackOnInitialRoute?: boolean;
15
+ };
16
+ declare const _default: (container: Container) => Promise<void>;
17
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { Category } from '../../../knowledge/core/src/index.ts';
2
+ import { default as React } from 'react';
3
+
4
+ type Props = {
5
+ item: Category;
6
+ guideCategory: string;
7
+ };
8
+ declare const GuideCategoryDropdownItem: React.FC<Props>;
9
+ export default GuideCategoryDropdownItem;
@@ -0,0 +1,5 @@
1
+ import { Category } from '../../../knowledge/core/src/index.ts';
2
+ import { default as React } from 'react';
3
+
4
+ declare const GuideCategoryDropdownMatchCount: React.FC<Category>;
5
+ export default GuideCategoryDropdownMatchCount;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+
3
+ type Props = {
4
+ className: string;
5
+ };
6
+ declare const GuideCategoryDropdown: React.FC<Props>;
7
+ export default GuideCategoryDropdown;
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ Wrapper: any;
3
+ Toggler: any;
4
+ List: any;
5
+ Item: any;
6
+ Link: any;
7
+ TopItem: any;
8
+ MatchCount: any;
9
+ };
10
+ export default _default;
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { default as GuideCategoryDropdownComponent } from './guide-category-dropdown-component';
2
+
3
+ export default GuideCategoryDropdownComponent;
package/index.js ADDED
@@ -0,0 +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-677e0f86.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 ADDED
@@ -0,0 +1,85 @@
1
+ import { DataClient as b, DataType as v } from "@telia-ace/knowledge-data-client";
2
+ import { createEventSubscriber as C, extendComponent as D } from "@telia-ace/knowledge-widget-core";
3
+ import { createReactComponent as P } from "@telia-ace/knowledge-widget-ui";
4
+ const y = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a, o) => {
5
+ if (e.find((s) => s.id === o) || !o)
6
+ return a || n;
7
+ for (let s = 0; s < e.length; s += 1) {
8
+ const t = e[s];
9
+ if (t.items) {
10
+ const r = h(t.items, n, t, o);
11
+ if (r)
12
+ return r;
13
+ }
14
+ }
15
+ }, R = (e) => e.matches && e.matches > 0, G = (e) => {
16
+ const { events: n } = e.get("$widget"), [a, o] = C(n);
17
+ return P(
18
+ e,
19
+ "guide-category-dropdown",
20
+ import("./guide-category-dropdown-3698c67e.mjs"),
21
+ (i) => {
22
+ const s = (t) => {
23
+ i.writeProperties({ loading: !0 }), i.actions.dispatch("fetch", { params: t }).then(() => {
24
+ i.writeProperties({ loading: !1 });
25
+ });
26
+ };
27
+ i.actions.create("fetch", ({ parent: t, categories: r }) => {
28
+ i.writeProperties({
29
+ parent: t,
30
+ categories: r,
31
+ loading: !1
32
+ });
33
+ }), e.getAsync("router").then((t) => {
34
+ const { params: r } = t.getRouteData();
35
+ s(r);
36
+ }), a("router:changed", (t, { current: r }) => {
37
+ s(r.routeData.params);
38
+ });
39
+ }
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(() => {
80
+ o();
81
+ });
82
+ };
83
+ export {
84
+ G as default
85
+ };
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@telia-ace/knowledge-widget-components-guide-category-dropdown",
3
+ "version": "0.0.1",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./index.mjs",
9
+ "require": "./index.js"
10
+ }
11
+ },
12
+ "dependencies": {
13
+ "@telia-ace/knowledge-widget-core": "*",
14
+ "@telia-ace/knowledge-widget-component-utilities": "*",
15
+ "@telia-ace/knowledge-widget-ui": "*",
16
+ "@telia-ace/widget-utilities": "*",
17
+ "@telia-ace/knowledge-data-client": "*",
18
+ "@webprovisions/platform": "^1.1.4"
19
+ },
20
+ "peerDependencies": {
21
+ "@emotion/react": "11.11.1",
22
+ "react": "18.2.0",
23
+ "@emotion/styled": "11.11.0"
24
+ }
25
+ }