@telia-ace/knowledge-widget-components-guide 1.1.1-rc.3 → 1.1.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.
Files changed (3) hide show
  1. package/index.js +1 -1
  2. package/index.mjs +39 -37
  3. package/package.json +10 -10
package/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use strict";const u=require("@telia-ace/knowledge-data-client"),l=require("@telia-ace/knowledge-widget-component-utilities"),b=require("@telia-ace/knowledge-widget-core"),v=require("@telia-ace/knowledge-widget-ui"),k=require("clipboard-polyfill");function w(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(r,a,s.get?s:{enumerable:!0,get:()=>e[a]})}}return r.default=e,Object.freeze(r)}const m=w(k),y=(e,r)=>{r.actions.create("feedback",a=>{const s=a==="negative"?u.FeedbackType.Negative:u.FeedbackType.Positive,{guide:i,submitButtonLabel:c="Submit"}=r.properties();if(i){const{connection:t,id:n,hasHandover:o}=i;r.writeProperties({feedbackGiven:a,loading:o&&s===u.FeedbackType.Negative});const{events:d}=e.get("$widget");return d.dispatch("tracking:feedback-given",{guide:i,categories:i.categories,feedbackType:s.toLowerCase()}),u.DataClient.getInstance(e).then(h=>h.feedback(n,t,s).then(()=>{if(o&&s===u.FeedbackType.Negative)return h.fetch(u.DataType.ContactMethods,{guideId:n}).then(({contactMethods:p})=>r.actions.dispatch("handover",{handoverContactMethods:p.map(g=>({...g,body:l.updateForm(g,{submit:c})})),loading:!1}))}))}}),r.actions.create("handover",a=>r.writeProperties({...a,loading:!1}))},T=({title:e,body:r})=>{let a="";e&&e.length&&(a=e.trim()),r&&r.length&&(a=`${a.trim()}
2
- ${r.trim()}`);const s=document.createElement("div");s.innerHTML=a;const i=Array.from(s.getElementsByTagName("a"));let c=s.innerText;return i.forEach(t=>{c=c.replace(t.innerText,`[${t.href}] (${t.innerText})`)}),c},C=({title:e,body:r})=>{let a="";return e&&e.length&&(a=`<h2>${e.trim()}</h2>`),r&&r.length&&(a=`${a.trim()}${r.trim()}`),a.trim()},x=e=>{const{events:r}=e.get("$widget"),[a,s]=b.createEventSubscriber(r);return v.createReactComponent(e,"guide",Promise.resolve().then(()=>require("./guide-e74afad8.js")),i=>{const c=t=>{i.writeProperties({loading:!0,error:void 0,guide:void 0,feedbackGiven:void 0}),i.actions.dispatch("fetch",{params:t})};i.actions.create("copy",t=>{const n=new m.ClipboardItem({"text/html":new Blob([C(t)],{type:"text/html"}),"text/plain":new Blob([T(t)],{type:"text/plain"})});return m.write([n]).then(()=>{r.dispatch("widget:menu-toggled",null)})}),i.actions.create("print",()=>{const t=document.querySelector(".humany-guide .humany-paragraph"),n=window.open("","","height=500, width=500");r.dispatch("widget:menu-toggled",null),t&&n&&(n.document.write(`<html><body>${t.innerHTML}</body></html>`),n.document.close(),n.print())}),i.actions.create("back",(t,n)=>{if(!n.preventDefault)return e.getAsync("router").then(o=>{o.goBack()})}),i.actions.create("fetch",({contactMethods:t=[],dialog:n=[],guide:o,error:d})=>{if(d)return i.actions.dispatch("fetched",{error:d,guide:void 0,contactMethods:[],feedbackGiven:void 0,handoverContactMethods:[],showFeedback:!1,loading:!0});const{showFeedback:h=!0,submitButtonLabel:p="Submit"}=i.properties(),g={showFeedback:h,dialog:n,guide:o,feedbackGiven:void 0,handoverContactMethods:[],contactMethods:t.map(f=>({...f,body:l.updateForm(f,{submit:p})}))};return i.actions.dispatch("fetched",{...g,loading:!0})}),i.actions.create("fetched",t=>i.writeProperties({...t,feedbackGiven:void 0,loading:!1})),e.getAsync("router").then(t=>{const{params:n}=t.getRouteData();c(n)}),a("router:changed",(t,{current:n})=>{c(n.routeData.params)}),y(e,i),l.useForm(e,i),l.useExpand(i)}).then(()=>b.extendComponent(e,"guide",i=>{i.actions.watch("guide.fetch",(c,t)=>{const{params:{guide:n,connection:o}}=c;return n?u.DataClient.getInstance(e).then(d=>d.fetch(u.DataType.Guide,{connection:o,guideId:n})).then(t).catch(d=>{if(d)return t(d)}):t(c)})})).then(()=>{s()})};module.exports=x;
2
+ ${r.trim()}`);const s=document.createElement("div");s.innerHTML=a;const i=Array.from(s.getElementsByTagName("a"));let c=s.innerText;return i.forEach(t=>{c=c.replace(t.innerText,`[${t.href}] (${t.innerText})`)}),c},C=({title:e,body:r})=>{let a="";return e&&e.length&&(a=`<h2>${e.trim()}</h2>`),r&&r.length&&(a=`${a.trim()}${r.trim()}`),a.trim()},x=e=>{const{events:r}=e.get("$widget"),[a,s]=b.createEventSubscriber(r);return v.createReactComponent(e,"guide",Promise.resolve().then(()=>require("./guide-e74afad8.js")),i=>{const c=t=>{i.writeProperties({loading:!0,error:void 0,guide:void 0,dialog:void 0,contactMethods:void 0,feedbackGiven:void 0}),i.actions.dispatch("fetch",{params:t})};i.actions.create("copy",t=>{const n=new m.ClipboardItem({"text/html":new Blob([C(t)],{type:"text/html"}),"text/plain":new Blob([T(t)],{type:"text/plain"})});return m.write([n]).then(()=>{r.dispatch("widget:menu-toggled",null)})}),i.actions.create("print",()=>{const t=document.querySelector(".humany-guide .humany-paragraph"),n=window.open("","","height=500, width=500");r.dispatch("widget:menu-toggled",null),t&&n&&(n.document.write(`<html><body>${t.innerHTML}</body></html>`),n.document.close(),n.print())}),i.actions.create("back",(t,n)=>{if(!n.preventDefault)return e.getAsync("router").then(o=>{o.goBack()})}),i.actions.create("fetch",({contactMethods:t=[],dialog:n=[],guide:o,error:d})=>{if(d)return i.actions.dispatch("fetched",{error:d,guide:void 0,contactMethods:[],feedbackGiven:void 0,handoverContactMethods:[],showFeedback:!1,loading:!0});const{showFeedback:h=!0,submitButtonLabel:p="Submit"}=i.properties(),g={showFeedback:h,dialog:n,guide:o,feedbackGiven:void 0,handoverContactMethods:[],contactMethods:t.map(f=>({...f,body:l.updateForm(f,{submit:p})}))};return i.actions.dispatch("fetched",{...g,loading:!0})}),i.actions.create("fetched",t=>i.writeProperties({...t,feedbackGiven:void 0,loading:!1})),e.getAsync("router").then(t=>{const{params:n}=t.getRouteData();c(n)}),a("router:changed",(t,{current:n})=>{c(n.routeData.params)}),y(e,i),l.useForm(e,i),l.useExpand(i)}).then(()=>b.extendComponent(e,"guide",i=>{i.actions.watch("guide.fetch",(c,t)=>{const{params:{guide:n,connection:o}}=c;return n?u.DataClient.getInstance(e).then(d=>d.fetch(u.DataType.Guide,{connection:o,guideId:n})).then(t).catch(d=>{if(d)return t(d)}):t(c)})})).then(()=>{s()})};module.exports=x;
package/index.mjs CHANGED
@@ -3,23 +3,23 @@ import { updateForm as v, useForm as w, useExpand as k } from "@telia-ace/knowle
3
3
  import { createEventSubscriber as y, extendComponent as T } from "@telia-ace/knowledge-widget-core";
4
4
  import { createReactComponent as x } from "@telia-ace/knowledge-widget-ui";
5
5
  import * as p from "clipboard-polyfill";
6
- const $ = (r, a) => {
7
- a.actions.create("feedback", (n) => {
8
- const d = n === "negative" ? g.Negative : g.Positive, { guide: t, submitButtonLabel: s = "Submit" } = a.properties();
6
+ const $ = (a, r) => {
7
+ r.actions.create("feedback", (n) => {
8
+ const d = n === "negative" ? g.Negative : g.Positive, { guide: t, submitButtonLabel: s = "Submit" } = r.properties();
9
9
  if (t) {
10
- const { connection: e, id: i, hasHandover: o } = t;
11
- a.writeProperties({
10
+ const { connection: e, id: i, hasHandover: c } = t;
11
+ r.writeProperties({
12
12
  feedbackGiven: n,
13
- loading: o && d === g.Negative
13
+ loading: c && d === g.Negative
14
14
  });
15
- const { events: c } = r.get("$widget");
16
- return c.dispatch("tracking:feedback-given", {
15
+ const { events: o } = a.get("$widget");
16
+ return o.dispatch("tracking:feedback-given", {
17
17
  guide: t,
18
18
  categories: t.categories,
19
19
  feedbackType: d.toLowerCase()
20
- }), l.getInstance(r).then((u) => u.feedback(i, e, d).then(() => {
21
- if (o && d === g.Negative)
22
- return u.fetch(b.ContactMethods, { guideId: i }).then(({ contactMethods: f }) => a.actions.dispatch("handover", {
20
+ }), l.getInstance(a).then((u) => u.feedback(i, e, d).then(() => {
21
+ if (c && d === g.Negative)
22
+ return u.fetch(b.ContactMethods, { guideId: i }).then(({ contactMethods: f }) => r.actions.dispatch("handover", {
23
23
  handoverContactMethods: f.map((h) => ({
24
24
  ...h,
25
25
  body: v(h, {
@@ -30,11 +30,11 @@ const $ = (r, a) => {
30
30
  }));
31
31
  }));
32
32
  }
33
- }), a.actions.create("handover", (n) => a.writeProperties({ ...n, loading: !1 }));
34
- }, C = ({ title: r, body: a }) => {
33
+ }), r.actions.create("handover", (n) => r.writeProperties({ ...n, loading: !1 }));
34
+ }, C = ({ title: a, body: r }) => {
35
35
  let n = "";
36
- r && r.length && (n = r.trim()), a && a.length && (n = `${n.trim()}
37
- ${a.trim()}`);
36
+ a && a.length && (n = a.trim()), r && r.length && (n = `${n.trim()}
37
+ ${r.trim()}`);
38
38
  const d = document.createElement("div");
39
39
  d.innerHTML = n;
40
40
  const t = Array.from(d.getElementsByTagName("a"));
@@ -42,13 +42,13 @@ ${a.trim()}`);
42
42
  return t.forEach((e) => {
43
43
  s = s.replace(e.innerText, `[${e.href}] (${e.innerText})`);
44
44
  }), s;
45
- }, M = ({ title: r, body: a }) => {
45
+ }, M = ({ title: a, body: r }) => {
46
46
  let n = "";
47
- return r && r.length && (n = `<h2>${r.trim()}</h2>`), a && a.length && (n = `${n.trim()}${a.trim()}`), n.trim();
48
- }, P = (r) => {
49
- const { events: a } = r.get("$widget"), [n, d] = y(a);
47
+ return a && a.length && (n = `<h2>${a.trim()}</h2>`), r && r.length && (n = `${n.trim()}${r.trim()}`), n.trim();
48
+ }, P = (a) => {
49
+ const { events: r } = a.get("$widget"), [n, d] = y(r);
50
50
  return x(
51
- r,
51
+ a,
52
52
  "guide",
53
53
  import("./guide-38b65368.mjs"),
54
54
  (t) => {
@@ -57,6 +57,8 @@ ${a.trim()}`);
57
57
  loading: !0,
58
58
  error: void 0,
59
59
  guide: void 0,
60
+ dialog: void 0,
61
+ contactMethods: void 0,
60
62
  feedbackGiven: void 0
61
63
  }), t.actions.dispatch("fetch", { params: e });
62
64
  };
@@ -68,22 +70,22 @@ ${a.trim()}`);
68
70
  })
69
71
  });
70
72
  return p.write([i]).then(() => {
71
- a.dispatch("widget:menu-toggled", null);
73
+ r.dispatch("widget:menu-toggled", null);
72
74
  });
73
75
  }), t.actions.create("print", () => {
74
76
  const e = document.querySelector(".humany-guide .humany-paragraph"), i = window.open("", "", "height=500, width=500");
75
- a.dispatch("widget:menu-toggled", null), e && i && (i.document.write(`<html><body>${e.innerHTML}</body></html>`), i.document.close(), i.print());
77
+ r.dispatch("widget:menu-toggled", null), e && i && (i.document.write(`<html><body>${e.innerHTML}</body></html>`), i.document.close(), i.print());
76
78
  }), t.actions.create("back", (e, i) => {
77
79
  if (!i.preventDefault)
78
- return r.getAsync("router").then((o) => {
79
- o.goBack();
80
+ return a.getAsync("router").then((c) => {
81
+ c.goBack();
80
82
  });
81
83
  }), t.actions.create(
82
84
  "fetch",
83
- ({ contactMethods: e = [], dialog: i = [], guide: o, error: c }) => {
84
- if (c)
85
+ ({ contactMethods: e = [], dialog: i = [], guide: c, error: o }) => {
86
+ if (o)
85
87
  return t.actions.dispatch("fetched", {
86
- error: c,
88
+ error: o,
87
89
  guide: void 0,
88
90
  contactMethods: [],
89
91
  feedbackGiven: void 0,
@@ -94,7 +96,7 @@ ${a.trim()}`);
94
96
  const { showFeedback: u = !0, submitButtonLabel: f = "Submit" } = t.properties(), h = {
95
97
  showFeedback: u,
96
98
  dialog: i,
97
- guide: o,
99
+ guide: c,
98
100
  feedbackGiven: void 0,
99
101
  handoverContactMethods: [],
100
102
  contactMethods: e.map((m) => ({
@@ -111,23 +113,23 @@ ${a.trim()}`);
111
113
  ...e,
112
114
  feedbackGiven: void 0,
113
115
  loading: !1
114
- })), r.getAsync("router").then((e) => {
116
+ })), a.getAsync("router").then((e) => {
115
117
  const { params: i } = e.getRouteData();
116
118
  s(i);
117
119
  }), n("router:changed", (e, { current: i }) => {
118
120
  s(i.routeData.params);
119
- }), $(r, t), w(r, t), k(t);
121
+ }), $(a, t), w(a, t), k(t);
120
122
  }
121
- ).then(() => T(r, "guide", (t) => {
123
+ ).then(() => T(a, "guide", (t) => {
122
124
  t.actions.watch("guide.fetch", (s, e) => {
123
125
  const {
124
- params: { guide: i, connection: o }
126
+ params: { guide: i, connection: c }
125
127
  } = s;
126
- return i ? l.getInstance(r).then(
127
- (c) => c.fetch(b.Guide, { connection: o, guideId: i })
128
- ).then(e).catch((c) => {
129
- if (c)
130
- return e(c);
128
+ return i ? l.getInstance(a).then(
129
+ (o) => o.fetch(b.Guide, { connection: c, guideId: i })
130
+ ).then(e).catch((o) => {
131
+ if (o)
132
+ return e(o);
131
133
  }) : e(s);
132
134
  });
133
135
  })).then(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-components-guide",
3
- "version": "1.1.1-rc.3",
3
+ "version": "1.1.1",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -10,15 +10,15 @@
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "@telia-ace/knowledge-widget-ui": "^1.1.1-rc.3",
14
- "@telia-ace/widget-utilities": "^1.1.1-rc.3",
15
- "@telia-ace/knowledge-widget-core": "^1.1.1-rc.3",
16
- "@telia-ace/knowledge-widget-adapters": "^1.1.1-rc.3",
17
- "@telia-ace/knowledge-widget-component-utilities": "^1.1.1-rc.3",
18
- "@telia-ace/widget-forms": "^1.1.1-rc.3",
19
- "@telia-ace/widget-routing": "^1.1.1-rc.3",
20
- "@telia-ace/widget-types-grid": "^1.1.1-rc.3",
21
- "@telia-ace/knowledge-data-client": "^1.1.1-rc.3",
13
+ "@telia-ace/knowledge-widget-ui": "^1.1.1",
14
+ "@telia-ace/widget-utilities": "^1.1.1",
15
+ "@telia-ace/knowledge-widget-core": "^1.1.1",
16
+ "@telia-ace/knowledge-widget-adapters": "^1.1.1",
17
+ "@telia-ace/knowledge-widget-component-utilities": "^1.1.1",
18
+ "@telia-ace/widget-forms": "^1.1.1",
19
+ "@telia-ace/widget-routing": "^1.1.1",
20
+ "@telia-ace/widget-types-grid": "^1.1.1",
21
+ "@telia-ace/knowledge-data-client": "^1.1.1",
22
22
  "@webprovisions/platform": "^1.1.4",
23
23
  "clipboard-polyfill": "4.0.0-rc1"
24
24
  },