@telia-ace/knowledge-widget-components-related-guide-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 RelatedGuideListComponent } from './related-guide-list-component';
2
+
3
+ export default RelatedGuideListComponent;
package/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";const u=require("@telia-ace/knowledge-data-client"),d=require("@telia-ace/knowledge-widget-core"),o=require("@telia-ace/knowledge-widget-ui"),g=i=>o.createReactComponent(i,"related-guide-list",Promise.resolve().then(()=>require("./related-guide-list-b7e96ecc.js")),t=>{const{events:r}=i.get("$widget"),[a,c]=d.createEventSubscriber(r),n=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})),i.getAsync("router").then(e=>{const{params:s}=e.getRouteData();n(s)}),a("router:changed",(e,{current:s})=>{n(s.routeData.params)}),()=>{c()}}).then(()=>d.extendComponent(i,"related-guide-list",t=>{t.actions.watch("related-guide-list.fetch",(r,a)=>{const{params:{guide:c,connection:n}}=r;return c?(t.properties(),u.DataClient.getInstance(i).then(e=>e.fetch(u.DataType.Guide,{connection:n,guideId:c}).then(({related:s})=>a({...r,items:s||[]})).catch(s=>a(r)))):a(r)})}));module.exports=g;
package/index.mjs ADDED
@@ -0,0 +1,37 @@
1
+ import { DataClient as d, DataType as o } from "@telia-ace/knowledge-data-client";
2
+ import { createEventSubscriber as n, extendComponent as h } from "@telia-ace/knowledge-widget-core";
3
+ import { createReactComponent as g } from "@telia-ace/knowledge-widget-ui";
4
+ const m = (s) => g(
5
+ s,
6
+ "related-guide-list",
7
+ import("./related-guide-list-ffa77ba3.mjs"),
8
+ (t) => {
9
+ const { events: r } = s.get("$widget"), [i, c] = n(r), u = (e) => {
10
+ t.writeProperties({ loading: !0, error: void 0 }), t.actions.dispatch("fetch", { params: e });
11
+ };
12
+ return t.actions.create("fetch", ({ items: e = [] }) => t.actions.dispatch("fetched", {
13
+ items: e,
14
+ loading: !0
15
+ })), t.actions.create("fetched", (e) => t.writeProperties({ ...e, loading: !1 })), s.getAsync("router").then((e) => {
16
+ const { params: a } = e.getRouteData();
17
+ u(a);
18
+ }), i("router:changed", (e, { current: a }) => {
19
+ u(a.routeData.params);
20
+ }), () => {
21
+ c();
22
+ };
23
+ }
24
+ ).then(() => h(s, "related-guide-list", (t) => {
25
+ t.actions.watch("related-guide-list.fetch", (r, i) => {
26
+ const {
27
+ params: { guide: c, connection: u }
28
+ } = r;
29
+ return c ? (t.properties(), d.getInstance(s).then((e) => e.fetch(o.Guide, {
30
+ connection: u,
31
+ guideId: c
32
+ }).then(({ related: a }) => i({ ...r, items: a || [] })).catch((a) => i(r)))) : i(r);
33
+ });
34
+ }));
35
+ export {
36
+ m as default
37
+ };
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@telia-ace/knowledge-widget-components-related-guide-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-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
+ "@emotion/styled": "11.11.0",
23
+ "react": "18.2.0"
24
+ }
25
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react/jsx-runtime"),q=require("@emotion/styled"),e=require("@telia-ace/knowledge-widget-ui"),a=require("@telia-ace/widget-utilities"),w=({className:i,...o})=>{const{name:r,params:s}=e.useRouteData(),d=e.useContainer(),{showFavoriteToggle:l=!1,items:t,header:n,metadata:m,tags:u,addFavoriteTooltip:c,removeFavoriteCancelLabel:g,removeFavoriteConfirmLabel:p,removeFavoriteHeader:b,removeFavoriteLabel:v,removeFavoriteTooltip:L,metadataByLabel:y,metadataModifiedLabel:f,metadataPublishedLabel:h}=e.useProperties();return!t||!t.length?e.createEmptyComponent(d,{...o,className:a.appendClassNames(i,"humany-related-guide-list")}):T.jsx(N,{...o,className:a.appendClassNames(i,"humany-related-guide-list"),header:n,items:t,paramMappers:{guide:({id:F,title:C})=>a.createParams({...s,guide:F,uriName:a.formatUrl(C),connection:void 0})},showTags:u,showFavoriteToggle:l,addFavoriteTooltip:c,removeFavoriteCancelLabel:g,removeFavoriteConfirmLabel:p,removeFavoriteHeader:b,removeFavoriteLabel:v,removeFavoriteTooltip:L,metadata:{...m,modifiedLabel:f,publishedLabel:h,byLabel:y},routing:{guide:r}})},N=q(e.GuideList)`
2
+ ${e.contentBox}
3
+ li:last-child {
4
+ margin: 0;
5
+ }
6
+ `;exports.default=w;
@@ -0,0 +1,11 @@
1
+ import { FavoriteProperties, MetaDataProperties } from '../../utilities/src/index.ts';
2
+ import { Container } from '@webprovisions/platform';
3
+
4
+ export type RelatedGuideListComponentProps = {
5
+ header: string;
6
+ items?: any[];
7
+ showFavoriteToggle?: boolean;
8
+ tags?: boolean;
9
+ } & FavoriteProperties & MetaDataProperties;
10
+ declare const RelatedGuideListComponent: (container: Container) => Promise<void>;
11
+ export default RelatedGuideListComponent;
@@ -0,0 +1,67 @@
1
+ import { jsx as C } from "react/jsx-runtime";
2
+ import T from "@emotion/styled";
3
+ import { useRouteData as x, useContainer as G, useProperties as N, createEmptyComponent as P, GuideList as w, contentBox as B } from "@telia-ace/knowledge-widget-ui";
4
+ import { appendClassNames as o, createParams as M, formatUrl as R } from "@telia-ace/widget-utilities";
5
+ const U = ({ className: a, ...t }) => {
6
+ const { name: i, params: r } = x(), m = G(), {
7
+ showFavoriteToggle: s = !1,
8
+ items: e,
9
+ header: d,
10
+ metadata: l,
11
+ tags: n,
12
+ addFavoriteTooltip: u,
13
+ removeFavoriteCancelLabel: p,
14
+ removeFavoriteConfirmLabel: c,
15
+ removeFavoriteHeader: v,
16
+ removeFavoriteLabel: b,
17
+ removeFavoriteTooltip: g,
18
+ metadataByLabel: L,
19
+ metadataModifiedLabel: f,
20
+ metadataPublishedLabel: h
21
+ } = N();
22
+ return !e || !e.length ? P(m, {
23
+ ...t,
24
+ className: o(a, "humany-related-guide-list")
25
+ }) : /* @__PURE__ */ C(
26
+ j,
27
+ {
28
+ ...t,
29
+ className: o(a, "humany-related-guide-list"),
30
+ header: d,
31
+ items: e,
32
+ paramMappers: {
33
+ guide: ({ id: y, title: F }) => M({
34
+ ...r,
35
+ guide: y,
36
+ uriName: R(F),
37
+ connection: void 0
38
+ })
39
+ },
40
+ showTags: n,
41
+ showFavoriteToggle: s,
42
+ addFavoriteTooltip: u,
43
+ removeFavoriteCancelLabel: p,
44
+ removeFavoriteConfirmLabel: c,
45
+ removeFavoriteHeader: v,
46
+ removeFavoriteLabel: b,
47
+ removeFavoriteTooltip: g,
48
+ metadata: {
49
+ ...l,
50
+ modifiedLabel: f,
51
+ publishedLabel: h,
52
+ byLabel: L
53
+ },
54
+ routing: {
55
+ guide: i
56
+ }
57
+ }
58
+ );
59
+ }, j = T(w)`
60
+ ${B}
61
+ li:last-child {
62
+ margin: 0;
63
+ }
64
+ `;
65
+ export {
66
+ U as default
67
+ };
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+
3
+ type Props = {
4
+ className: string;
5
+ };
6
+ declare const RelatedGuideList: React.FC<Props>;
7
+ export default RelatedGuideList;