@telia-ace/knowledge-widget-components-related-tag-list 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.
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { default as RelatedTagListComponent } from './related-tag-list-component';
2
+
3
+ export default RelatedTagListComponent;
package/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";const o=require("@telia-ace/knowledge-data-client"),d=require("@telia-ace/knowledge-widget-core"),u=require("@telia-ace/knowledge-widget-ui"),g=a=>u.createReactComponent(a,"related-tag-list",Promise.resolve().then(()=>require("./related-tag-list-23f3dee2.js")),t=>{const{events:s}=a.get("$widget"),[i,n]=d.createEventSubscriber(s),c=e=>{t.writeProperties({loading:!0,error:void 0}),t.actions.dispatch("fetch",{params:e})};return t.actions.create("fetch",({items:e=[]})=>t.actions.dispatch("fetched",{items:e,loading:!0})),t.actions.create("fetched",e=>t.writeProperties({...e,loading:!1})),a.getAsync("router").then(e=>{const{params:r}=e.getRouteData();c(r)}),i("router:changed",(e,{current:r})=>{c(r.routeData.params)}),()=>{n()}}).then(()=>d.extendComponent(a,"related-tag-list",t=>{t.actions.watch("related-tag-list.fetch",(s,i)=>{const{params:{guide:n,connection:c}}=s;if(typeof n<"u")return o.DataClient.getInstance(a).then(e=>e.fetch(o.DataType.Guide,{connection:c,guideId:n}).then(({tags:r})=>i({...s,items:r||[]})).catch(r=>i(s)))})}));module.exports=g;
package/index.mjs ADDED
@@ -0,0 +1,38 @@
1
+ import { DataClient as o, DataType as d } from "@telia-ace/knowledge-data-client";
2
+ import { createEventSubscriber as u, extendComponent as h } from "@telia-ace/knowledge-widget-core";
3
+ import { createReactComponent as f } from "@telia-ace/knowledge-widget-ui";
4
+ const m = (a) => f(
5
+ a,
6
+ "related-tag-list",
7
+ import("./related-tag-list-49e465d4.mjs"),
8
+ (e) => {
9
+ const { events: s } = a.get("$widget"), [i, c] = u(s), n = (t) => {
10
+ e.writeProperties({ loading: !0, error: void 0 }), e.actions.dispatch("fetch", { params: t });
11
+ };
12
+ return e.actions.create("fetch", ({ items: t = [] }) => e.actions.dispatch("fetched", {
13
+ items: t,
14
+ loading: !0
15
+ })), e.actions.create("fetched", (t) => e.writeProperties({ ...t, loading: !1 })), a.getAsync("router").then((t) => {
16
+ const { params: r } = t.getRouteData();
17
+ n(r);
18
+ }), i("router:changed", (t, { current: r }) => {
19
+ n(r.routeData.params);
20
+ }), () => {
21
+ c();
22
+ };
23
+ }
24
+ ).then(() => h(a, "related-tag-list", (e) => {
25
+ e.actions.watch("related-tag-list.fetch", (s, i) => {
26
+ const {
27
+ params: { guide: c, connection: n }
28
+ } = s;
29
+ if (typeof c < "u")
30
+ return o.getInstance(a).then((t) => t.fetch(d.Guide, {
31
+ connection: n,
32
+ guideId: c
33
+ }).then(({ tags: r }) => i({ ...s, items: r || [] })).catch((r) => i(s)));
34
+ });
35
+ }));
36
+ export {
37
+ m as default
38
+ };
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@telia-ace/knowledge-widget-components-related-tag-list",
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-data-client": "*",
15
+ "@telia-ace/knowledge-widget-ui": "*",
16
+ "@telia-ace/widget-utilities": "*",
17
+ "@webprovisions/platform": "^1.1.4"
18
+ },
19
+ "peerDependencies": {
20
+ "@emotion/react": "11.11.1",
21
+ "@emotion/styled": "11.11.0",
22
+ "react": "18.2.0"
23
+ }
24
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),l=require("@emotion/styled"),r=require("@telia-ace/knowledge-widget-ui"),n=require("@telia-ace/widget-utilities"),$=(e,t,s)=>e&&s?a.jsx(u,{symbol:s,size:18}):t?a.jsx(u,{symbol:t,size:18}):null,z=({className:e,embedded:t=!1,...s})=>{const g=r.useContainer(),{route:h="search",header:y,items:d=[],showIcons:f}=r.useProperties(),{params:m}=r.useRouteData();return d.length?a.jsx(j,{embedded:t?"true":"false",...s,className:n.appendClassNames(e,"humany-tag-list","humany-related-tag-list"),header:y,items:d,renderItem:o=>{const{id:i,title:x,defaultIcon:p,activeIcon:b}=o,c=m.tag===o.id||!m.tag&&o.id==="0";return a.jsx("li",{"data-tag":i,children:a.jsx(w,{routeName:h,selected:c,params:n.createParams({tag:i}),text:x,children:f&&$(c,p,b)})},i)}}):r.createEmptyComponent(g,{...s,className:n.appendClassNames(e,"humany-tag-list","humany-related-tag-list")})},u=l(r.SymbolBadge)`
2
+ margin-right: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}};
3
+ ${e=>{if(e.symbol.type==="Uri")return`
4
+ width: ${e.size}px;
5
+ height: ${e.size}px;
6
+ `;if(e.symbol.type==="FontAwesome")return`
7
+ font-size: ${e.size}px;
8
+ `}}
9
+ `,j=l(r.ItemList)`
10
+ ${r.itemList}
11
+ ${e=>e.embedded==="false"&&r.contentBox}
12
+ ${e=>{var t;return`padding: ${(t=e.theme.sizes)==null?void 0:t.large};`}}
13
+ justify-content: flex-start;
14
+
15
+ ul {
16
+ display: flex;
17
+ flex-wrap: wrap;
18
+ li {
19
+ margin: 0 ${e=>{var t,s;return`${(t=e.theme.sizes)==null?void 0:t.small} ${(s=e.theme.sizes)==null?void 0:s.small}`}} 0;
20
+
21
+ a {
22
+ color: #fff;
23
+ }
24
+ }
25
+ }
26
+ `,w=l(r.TextLink)`
27
+ padding: 8px 15px;
28
+ background-color: ${e=>{var t,s;return e.selected?(t=e.theme.colors)==null?void 0:t.text:(s=e.theme.colors)==null?void 0:s.primary}};
29
+ font-weight: 300;
30
+ border-radius: ${e=>e.theme.borderRadius};
31
+ display: block;
32
+ font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
33
+
34
+ &:focus-visible {
35
+ ${r.borderTabStyle}
36
+ padding: 6px 15px;
37
+ background-color: transparent;
38
+ }
39
+
40
+ @media (hover: hover) {
41
+ &:hover {
42
+ background-color: ${e=>{var t,s;return e.selected?(t=e.theme.colors)==null?void 0:t.primary:(s=e.theme.colors)==null?void 0:s.text}};
43
+ }
44
+ }
45
+ `;exports.default=z;
@@ -0,0 +1,122 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import i from "@emotion/styled";
3
+ import { useContainer as x, useProperties as $, useRouteData as z, createEmptyComponent as k, SymbolBadge as w, ItemList as L, itemList as S, contentBox as I, TextLink as v, borderTabStyle as B } from "@telia-ace/knowledge-widget-ui";
4
+ import { appendClassNames as d, createParams as C } from "@telia-ace/widget-utilities";
5
+ const N = (e, t, r) => e && r ? /* @__PURE__ */ s(c, { symbol: r, size: 18 }) : t ? /* @__PURE__ */ s(c, { symbol: t, size: 18 }) : null, E = ({
6
+ className: e,
7
+ embedded: t = !1,
8
+ ...r
9
+ }) => {
10
+ const u = x(), {
11
+ route: h = "search",
12
+ header: f,
13
+ items: l = [],
14
+ showIcons: g
15
+ } = $(), { params: n } = z();
16
+ return l.length ? /* @__PURE__ */ s(
17
+ R,
18
+ {
19
+ embedded: t ? "true" : "false",
20
+ ...r,
21
+ className: d(
22
+ e,
23
+ "humany-tag-list",
24
+ "humany-related-tag-list"
25
+ ),
26
+ header: f,
27
+ items: l,
28
+ renderItem: (a) => {
29
+ const { id: o, title: y, defaultIcon: p, activeIcon: b } = a, m = n.tag === a.id || !n.tag && a.id === "0";
30
+ return /* @__PURE__ */ s("li", { "data-tag": o, children: /* @__PURE__ */ s(
31
+ T,
32
+ {
33
+ routeName: h,
34
+ selected: m,
35
+ params: C({
36
+ tag: o
37
+ }),
38
+ text: y,
39
+ children: g && N(m, p, b)
40
+ }
41
+ ) }, o);
42
+ }
43
+ }
44
+ ) : k(u, {
45
+ ...r,
46
+ className: d(
47
+ e,
48
+ "humany-tag-list",
49
+ "humany-related-tag-list"
50
+ )
51
+ });
52
+ }, c = i(w)`
53
+ margin-right: ${(e) => {
54
+ var t;
55
+ return (t = e.theme.sizes) == null ? void 0 : t.small;
56
+ }};
57
+ ${(e) => {
58
+ if (e.symbol.type === "Uri")
59
+ return `
60
+ width: ${e.size}px;
61
+ height: ${e.size}px;
62
+ `;
63
+ if (e.symbol.type === "FontAwesome")
64
+ return `
65
+ font-size: ${e.size}px;
66
+ `;
67
+ }}
68
+ `, R = i(L)`
69
+ ${S}
70
+ ${(e) => e.embedded === "false" && I}
71
+ ${(e) => {
72
+ var t;
73
+ return `padding: ${(t = e.theme.sizes) == null ? void 0 : t.large};`;
74
+ }}
75
+ justify-content: flex-start;
76
+
77
+ ul {
78
+ display: flex;
79
+ flex-wrap: wrap;
80
+ li {
81
+ margin: 0 ${(e) => {
82
+ var t, r;
83
+ return `${(t = e.theme.sizes) == null ? void 0 : t.small} ${(r = e.theme.sizes) == null ? void 0 : r.small}`;
84
+ }} 0;
85
+
86
+ a {
87
+ color: #fff;
88
+ }
89
+ }
90
+ }
91
+ `, T = i(v)`
92
+ padding: 8px 15px;
93
+ background-color: ${(e) => {
94
+ var t, r;
95
+ return e.selected ? (t = e.theme.colors) == null ? void 0 : t.text : (r = e.theme.colors) == null ? void 0 : r.primary;
96
+ }};
97
+ font-weight: 300;
98
+ border-radius: ${(e) => e.theme.borderRadius};
99
+ display: block;
100
+ font-size: ${(e) => {
101
+ var t;
102
+ return (t = e.theme.fonts) == null ? void 0 : t.normal;
103
+ }};
104
+
105
+ &:focus-visible {
106
+ ${B}
107
+ padding: 6px 15px;
108
+ background-color: transparent;
109
+ }
110
+
111
+ @media (hover: hover) {
112
+ &:hover {
113
+ background-color: ${(e) => {
114
+ var t, r;
115
+ return e.selected ? (t = e.theme.colors) == null ? void 0 : t.primary : (r = e.theme.colors) == null ? void 0 : r.text;
116
+ }};
117
+ }
118
+ }
119
+ `;
120
+ export {
121
+ E as default
122
+ };
@@ -0,0 +1,10 @@
1
+ import { Container } from '@webprovisions/platform';
2
+
3
+ export type RelatedTagListComponentProps = {
4
+ header: string;
5
+ route?: string;
6
+ items?: any[];
7
+ showIcons?: boolean;
8
+ };
9
+ declare const RelatedTagListComponent: (container: Container) => Promise<void>;
10
+ export default RelatedTagListComponent;
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+
3
+ type Props = {
4
+ className: string;
5
+ embedded?: boolean;
6
+ };
7
+ declare const RelatedTagList: React.FC<Props>;
8
+ export default RelatedTagList;