@telia-ace/knowledge-widget-components-guide-category-dropdown 1.2.6 → 1.2.7-rc.5
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,21 +1,21 @@
|
|
|
1
|
-
import { jsxs as c, jsx as o, Fragment as
|
|
2
|
-
import { loadingOpacity as
|
|
3
|
-
import { appendClassNames as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { initialRouteFallback as
|
|
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 f, useRouteData as W, useContainer as H, useIsTabbing as U, createEmptyComponent as q } from "@telia-ace/knowledge-widget-ui";
|
|
3
|
+
import { appendClassNames as T, createParams as J, formatUrl as K } from "@telia-ace/widget-utilities";
|
|
4
|
+
import { useState as N, useEffect as Q } from "react";
|
|
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
|
-
const
|
|
9
|
-
${j}
|
|
8
|
+
const X = m.div`
|
|
10
9
|
${B}
|
|
10
|
+
${M}
|
|
11
11
|
overflow: hidden;
|
|
12
12
|
min-height: 50px;
|
|
13
13
|
${(e) => e["data-toggler-in-focus"] && e.isTabbing && x`
|
|
14
14
|
&& {
|
|
15
|
-
${
|
|
15
|
+
${O(e)}
|
|
16
16
|
}
|
|
17
17
|
`};
|
|
18
|
-
`,
|
|
18
|
+
`, Y = m.button`
|
|
19
19
|
background: none;
|
|
20
20
|
border: 0;
|
|
21
21
|
outline: 0;
|
|
@@ -37,7 +37,7 @@ const V = m.div`
|
|
|
37
37
|
}};
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
`,
|
|
40
|
+
`, L = (e) => {
|
|
41
41
|
var t, g, u, r, n, p, s, h;
|
|
42
42
|
return x`
|
|
43
43
|
font-size: ${(t = e.theme.fonts) == null ? void 0 : t.normal};
|
|
@@ -70,19 +70,19 @@ const V = m.div`
|
|
|
70
70
|
min-width: 1em;
|
|
71
71
|
}
|
|
72
72
|
`;
|
|
73
|
-
},
|
|
74
|
-
${
|
|
75
|
-
`,
|
|
76
|
-
${
|
|
73
|
+
}, Z = m.div`
|
|
74
|
+
${L}
|
|
75
|
+
`, _ = m(G)`
|
|
76
|
+
${L}
|
|
77
77
|
&:focus {
|
|
78
78
|
outline: none;
|
|
79
79
|
}
|
|
80
80
|
&:focus-visible {
|
|
81
81
|
span {
|
|
82
|
-
${
|
|
82
|
+
${R};
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
`,
|
|
85
|
+
`, ee = m.div`
|
|
86
86
|
display: flex;
|
|
87
87
|
justify-content: space-between;
|
|
88
88
|
padding-right: ${(e) => {
|
|
@@ -102,8 +102,8 @@ const V = m.div`
|
|
|
102
102
|
.humany-guide-category-dropdown-item {
|
|
103
103
|
font-weight: normal;
|
|
104
104
|
}
|
|
105
|
-
`,
|
|
106
|
-
${
|
|
105
|
+
`, te = m(A)`
|
|
106
|
+
${E}
|
|
107
107
|
display: flex;
|
|
108
108
|
justify-content: center;
|
|
109
109
|
flex-direction: column;
|
|
@@ -128,19 +128,19 @@ const V = m.div`
|
|
|
128
128
|
}
|
|
129
129
|
flex-basis: 100%;
|
|
130
130
|
border-width: 2px;
|
|
131
|
-
`,
|
|
131
|
+
`, oe = m($)`
|
|
132
132
|
margin: 0 0 0 ${(e) => {
|
|
133
133
|
var t;
|
|
134
134
|
return (t = e.theme.sizes) == null ? void 0 : t.small;
|
|
135
135
|
}};
|
|
136
136
|
`, a = {
|
|
137
|
-
Wrapper:
|
|
138
|
-
Toggler:
|
|
139
|
-
List:
|
|
140
|
-
Item:
|
|
141
|
-
Link:
|
|
142
|
-
TopItem:
|
|
143
|
-
MatchCount:
|
|
137
|
+
Wrapper: X,
|
|
138
|
+
Toggler: Y,
|
|
139
|
+
List: te,
|
|
140
|
+
Item: Z,
|
|
141
|
+
Link: _,
|
|
142
|
+
TopItem: ee,
|
|
143
|
+
MatchCount: oe
|
|
144
144
|
}, v = ({ matches: e }) => {
|
|
145
145
|
const { showMatchCount: t = !1 } = C();
|
|
146
146
|
return !t || typeof e > "u" ? null : /* @__PURE__ */ c(a.MatchCount, { children: [
|
|
@@ -148,7 +148,7 @@ const V = m.div`
|
|
|
148
148
|
e,
|
|
149
149
|
")"
|
|
150
150
|
] });
|
|
151
|
-
},
|
|
151
|
+
}, ne = ({
|
|
152
152
|
item: e,
|
|
153
153
|
guideCategory: t
|
|
154
154
|
}) => {
|
|
@@ -157,65 +157,65 @@ const V = m.div`
|
|
|
157
157
|
categoryAriaLabel: u = "",
|
|
158
158
|
activeCategoryAriaLabel: r = "",
|
|
159
159
|
fallbackOnInitialRoute: n = !1
|
|
160
|
-
} = C(), [p, s] =
|
|
160
|
+
} = C(), [p, s] = P(), { id: h, title: b, symbol: i, activeSymbol: l } = e, d = t === h;
|
|
161
161
|
return /* @__PURE__ */ o("li", { ref: s, children: /* @__PURE__ */ c(
|
|
162
162
|
a.Link,
|
|
163
163
|
{
|
|
164
|
-
...
|
|
164
|
+
...V(
|
|
165
165
|
e,
|
|
166
166
|
g,
|
|
167
167
|
n,
|
|
168
168
|
"category"
|
|
169
169
|
),
|
|
170
170
|
"aria-pressed": d,
|
|
171
|
-
"aria-label": (d ? r : u).replace("{{category}}",
|
|
171
|
+
"aria-label": (d ? r : u).replace("{{category}}", b),
|
|
172
172
|
className: "humany-guide-category-dropdown-link",
|
|
173
173
|
"aria-current": d,
|
|
174
174
|
selected: d,
|
|
175
175
|
children: [
|
|
176
176
|
(d || p) && l ? /* @__PURE__ */ o(f, { symbol: l }) : i && /* @__PURE__ */ o(f, { symbol: i }),
|
|
177
|
-
/* @__PURE__ */ o($, { children:
|
|
177
|
+
/* @__PURE__ */ o($, { children: b }),
|
|
178
178
|
/* @__PURE__ */ o(v, { ...e })
|
|
179
179
|
]
|
|
180
180
|
}
|
|
181
181
|
) });
|
|
182
|
-
},
|
|
183
|
-
const g =
|
|
182
|
+
}, me = ({ className: e, ...t }) => {
|
|
183
|
+
const g = W(), [u, r] = N(!1), {
|
|
184
184
|
parent: n,
|
|
185
185
|
route: p = "browse",
|
|
186
186
|
categories: s = [],
|
|
187
187
|
loading: h = !1
|
|
188
|
-
} = C(),
|
|
189
|
-
if (
|
|
188
|
+
} = C(), b = H(), [i, l] = N(!1), { params: d } = g, I = U(), { guideCategory: k, tag: S, phrase: F, sorting: D } = d;
|
|
189
|
+
if (Q(() => {
|
|
190
190
|
i && l(!1);
|
|
191
191
|
}, [k]), h || !n || !s.length)
|
|
192
|
-
return
|
|
192
|
+
return q(b, {
|
|
193
193
|
...t,
|
|
194
|
-
className:
|
|
194
|
+
className: T(e, "humany-guide-category-dropdown")
|
|
195
195
|
});
|
|
196
|
-
const
|
|
197
|
-
return
|
|
196
|
+
const y = s.find((w) => w.id === k) || n, z = y.activeSymbol || y.symbol;
|
|
197
|
+
return /* @__PURE__ */ o(
|
|
198
198
|
a.Wrapper,
|
|
199
199
|
{
|
|
200
200
|
...t,
|
|
201
201
|
"data-loading": !1,
|
|
202
202
|
"data-toggler-in-focus": u,
|
|
203
203
|
"aria-expanded": i,
|
|
204
|
-
isTabbing:
|
|
205
|
-
className:
|
|
206
|
-
children: i ? /* @__PURE__ */ c(
|
|
204
|
+
isTabbing: I,
|
|
205
|
+
className: T(e, "humany-guide-category-dropdown"),
|
|
206
|
+
children: i ? /* @__PURE__ */ c(j, { children: [
|
|
207
207
|
/* @__PURE__ */ c(a.TopItem, { className: "humany-guide-category-dropdown-top-item", children: [
|
|
208
208
|
/* @__PURE__ */ c(
|
|
209
209
|
a.Link,
|
|
210
210
|
{
|
|
211
211
|
className: "humany-guide-category-dropdown-link",
|
|
212
212
|
routeName: p,
|
|
213
|
-
params:
|
|
214
|
-
tag:
|
|
215
|
-
phrase:
|
|
216
|
-
sorting:
|
|
213
|
+
params: J({
|
|
214
|
+
tag: S,
|
|
215
|
+
phrase: F,
|
|
216
|
+
sorting: D,
|
|
217
217
|
guideCategory: n.id,
|
|
218
|
-
uriName:
|
|
218
|
+
uriName: K(n.title)
|
|
219
219
|
}),
|
|
220
220
|
selected: !1,
|
|
221
221
|
children: [
|
|
@@ -252,7 +252,7 @@ const V = m.div`
|
|
|
252
252
|
className: "humany-guide-category-dropdown-open",
|
|
253
253
|
items: s,
|
|
254
254
|
renderItem: (w) => /* @__PURE__ */ o(
|
|
255
|
-
|
|
255
|
+
ne,
|
|
256
256
|
{
|
|
257
257
|
item: w,
|
|
258
258
|
guideCategory: k
|
|
@@ -271,9 +271,9 @@ const V = m.div`
|
|
|
271
271
|
},
|
|
272
272
|
selected: !1,
|
|
273
273
|
children: [
|
|
274
|
-
|
|
275
|
-
/* @__PURE__ */ o($, { children:
|
|
276
|
-
/* @__PURE__ */ o(v, { ...
|
|
274
|
+
z ? /* @__PURE__ */ o(f, { symbol: z }) : null,
|
|
275
|
+
/* @__PURE__ */ o($, { children: y.title }),
|
|
276
|
+
/* @__PURE__ */ o(v, { ...y })
|
|
277
277
|
]
|
|
278
278
|
}
|
|
279
279
|
),
|
|
@@ -287,7 +287,7 @@ const V = m.div`
|
|
|
287
287
|
l(!i);
|
|
288
288
|
},
|
|
289
289
|
"aria-expanded": "false",
|
|
290
|
-
"aria-label":
|
|
290
|
+
"aria-label": y.title,
|
|
291
291
|
children: /* @__PURE__ */ o(
|
|
292
292
|
f,
|
|
293
293
|
{
|
|
@@ -302,5 +302,5 @@ const V = m.div`
|
|
|
302
302
|
);
|
|
303
303
|
};
|
|
304
304
|
export {
|
|
305
|
-
|
|
305
|
+
me as default
|
|
306
306
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
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"),
|
|
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
2
|
${s.loadingOpacity}
|
|
3
3
|
${s.contentBox}
|
|
4
4
|
overflow: hidden;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
${s.borderTabStyle(e)}
|
|
9
9
|
}
|
|
10
10
|
`};
|
|
11
|
-
`,
|
|
11
|
+
`,L=g.button`
|
|
12
12
|
background: none;
|
|
13
13
|
border: 0;
|
|
14
14
|
outline: 0;
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
min-height: 1em;
|
|
55
55
|
min-width: 1em;
|
|
56
56
|
}
|
|
57
|
-
`},
|
|
57
|
+
`},q=g.div`
|
|
58
58
|
${k}
|
|
59
|
-
`,
|
|
59
|
+
`,F=g(s.Link)`
|
|
60
60
|
${k}
|
|
61
61
|
&:focus {
|
|
62
62
|
outline: none;
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
${s.linkTabStyle};
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
`,
|
|
69
|
+
`,D=g.div`
|
|
70
70
|
display: flex;
|
|
71
71
|
justify-content: space-between;
|
|
72
72
|
padding-right: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.large}};
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
.humany-guide-category-dropdown-item {
|
|
84
84
|
font-weight: normal;
|
|
85
85
|
}
|
|
86
|
-
`,
|
|
86
|
+
`,M=g(s.List)`
|
|
87
87
|
${s.list}
|
|
88
88
|
display: flex;
|
|
89
89
|
justify-content: center;
|
|
@@ -100,6 +100,6 @@
|
|
|
100
100
|
}
|
|
101
101
|
flex-basis: 100%;
|
|
102
102
|
border-width: 2px;
|
|
103
|
-
`,
|
|
103
|
+
`,O=g(s.Text)`
|
|
104
104
|
margin: 0 0 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}};
|
|
105
|
-
`,a={Wrapper:
|
|
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-
|
|
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-
|
|
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(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/knowledge-widget-components-guide-category-dropdown",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7-rc.5",
|
|
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": "
|
|
14
|
-
"@telia-ace/knowledge-widget-component-utilities": "
|
|
15
|
-
"@telia-ace/knowledge-widget-ui": "
|
|
16
|
-
"@telia-ace/widget-utilities": "
|
|
17
|
-
"@telia-ace/knowledge-data-client": "
|
|
13
|
+
"@telia-ace/knowledge-widget-core": "^1.2.7-rc.5",
|
|
14
|
+
"@telia-ace/knowledge-widget-component-utilities": "^1.2.7-rc.5",
|
|
15
|
+
"@telia-ace/knowledge-widget-ui": "^1.2.7-rc.5",
|
|
16
|
+
"@telia-ace/widget-utilities": "^1.2.7-rc.5",
|
|
17
|
+
"@telia-ace/knowledge-data-client": "^1.2.7-rc.5",
|
|
18
18
|
"@webprovisions/platform": "^1.1.4"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|