@telia-ace/conversational-hub-bot-provider 1.3.11-rc.1 → 1.3.11

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,3 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react/jsx-runtime"),A=require("@emotion/styled"),F=require("@telia-ace/knowledge-data-client"),B=require("@telia-ace/knowledge-widget-adapters"),p=require("@telia-ace/knowledge-widget-ui"),R=require("@telia-ace/widget-forms"),T=require("@telia-ace/widget-utilities"),u=require("react"),k=require("./index-eb780812.js");require("@telia-ace/widget-conversation");require("@telia-ace/widget-services");require("@webprovisions/platform");const $=({contactMethodId:n,guideId:o,groupId:m,className:x})=>{var C,v,w;const[e,s]=u.useState(),d=p.useContainer(),D=p.useDispatch(),b=u.useRef(!0),l=p.useConversation();u.useEffect(()=>{const{events:c}=d.get("$widget"),q=c.subscribe("conversational-hub-provider:form-submitted",async(f,r)=>{var M;if(((M=r.form.meta)==null?void 0:M.groupId)!==m||r.id!==(e==null?void 0:e.id))return;l&&(r.form.meta||(r.form.meta={}),r.form.meta.conversation=l);const y=await d.getAsync("contactMethods"),t={...e,body:{...e.body,form:r.form}},{errors:i,valid:h,errorTypes:N}=await y.validate(t);if(!h){const S=new R.FormBuilder(e.body.form);s(void 0),S.setValidationErrors(i),t.body={...t.body,form:S.get()},s({...t});return}const E=await y.submit(t);t.confirmation=E,s(t)}),a=c.subscribe("bot-provider:evaluate",async(f,r)=>{if(r.id!==n)return;const t=await(await d.getAsync("contactMethods")).evaluate(e);let i={...e,body:{...e.body,form:t}};const h=k.updateForm(i,{submit:"Submit",errors:{},meta:{groupId:m}});i={...i,body:h},s(i)});return()=>{q(),a()}},[d,e,s,l]);const g=u.useCallback(async c=>{const a=await(await F.DataClient.getInstance(d)).fetch(F.DataType.ContactMethod,{contactMethodId:c,guideId:o},{noCache:!0,isBot:!0}),f=k.updateForm(a,{submit:"Submit",errors:{},meta:{groupId:m}});if(a.body=f,a.body.guideId=o,!b.current)return null;s(a)},[b]);return u.useEffect(()=>(g(n),()=>{b.current=!1}),[n,g]),e?j.jsx(z,{...e,body:{...e.body,form:e.body.form?{...e.body.form,data:(C=e.body.form)==null?void 0:C.data,layout:{...e.body.form.layout},meta:(v=e.body.form)==null?void 0:v.meta,schema:(w=e.body.form)==null?void 0:w.schema}:void 0,guideId:e.body.guideId},inline:!0,expanded:!0,dispatch:D,className:T.appendClassNames("humany-bot-contact-method",x)}):null},z=A(B.ContactMethod)`
2
+ padding: ${n=>{var o;return(o=n.theme.sizes)==null?void 0:o.normal}} ${n=>{var o;return(o=n.theme.sizes)==null?void 0:o.medium}};
3
+ `;exports.default=$;
@@ -1,22 +1,23 @@
1
- import { jsx as F } from "react/jsx-runtime";
2
- import z from "@emotion/styled";
3
- import { DataClient as A, DataType as B } from "@telia-ace/knowledge-data-client";
1
+ import { jsx as E } from "react/jsx-runtime";
2
+ import F from "@emotion/styled";
3
+ import { DataClient as z, DataType as A } from "@telia-ace/knowledge-data-client";
4
4
  import { ContactMethod as N } from "@telia-ace/knowledge-widget-adapters";
5
5
  import { useContainer as R, useDispatch as T, useConversation as _ } from "@telia-ace/knowledge-widget-ui";
6
6
  import { FormBuilder as j } from "@telia-ace/widget-forms";
7
7
  import { appendClassNames as k } from "@telia-ace/widget-utilities";
8
8
  import { useState as G, useRef as I, useEffect as S, useCallback as V } from "react";
9
- import { u as $ } from "./index-088c9fb0.mjs";
9
+ import { u as $ } from "./index-69c78022.mjs";
10
10
  import "@telia-ace/widget-conversation";
11
11
  import "@telia-ace/widget-services";
12
- const tt = ({
12
+ import "@webprovisions/platform";
13
+ const ot = ({
13
14
  contactMethodId: a,
14
15
  guideId: e,
15
16
  groupId: c,
16
17
  className: x
17
18
  }) => {
18
19
  var h, C, v;
19
- const [t, n] = G(), m = R(), D = T(), u = I(!0), f = _();
20
+ const [t, n] = G(), m = R(), B = T(), u = I(!0), f = _();
20
21
  S(() => {
21
22
  const { events: d } = m.get("$widget"), w = d.subscribe(
22
23
  "conversational-hub-provider:form-submitted",
@@ -44,8 +45,8 @@ const tt = ({
44
45
  }, n({ ...o });
45
46
  return;
46
47
  }
47
- const E = await l.submit(o);
48
- o.confirmation = E, n(o);
48
+ const D = await l.submit(o);
49
+ o.confirmation = D, n(o);
49
50
  }
50
51
  ), s = d.subscribe(
51
52
  "bot-provider:evaluate",
@@ -79,13 +80,13 @@ const tt = ({
79
80
  }, [m, t, n, f]);
80
81
  const p = V(
81
82
  async (d) => {
82
- const s = await (await A.getInstance(m)).fetch(
83
- B.ContactMethod,
83
+ const s = await (await z.getInstance(m)).fetch(
84
+ A.ContactMethod,
84
85
  {
85
86
  contactMethodId: d,
86
87
  guideId: e
87
88
  },
88
- { noCache: !0 }
89
+ { noCache: !0, isBot: !0 }
89
90
  ), b = $(s, {
90
91
  submit: "Submit",
91
92
  errors: {},
@@ -100,7 +101,7 @@ const tt = ({
100
101
  );
101
102
  return S(() => (p(a), () => {
102
103
  u.current = !1;
103
- }), [a, p]), t ? /* @__PURE__ */ F(
104
+ }), [a, p]), t ? /* @__PURE__ */ E(
104
105
  q,
105
106
  {
106
107
  ...t,
@@ -117,11 +118,11 @@ const tt = ({
117
118
  },
118
119
  inline: !0,
119
120
  expanded: !0,
120
- dispatch: D,
121
+ dispatch: B,
121
122
  className: k("humany-bot-contact-method", x)
122
123
  }
123
124
  ) : null;
124
- }, q = z(N)`
125
+ }, q = F(N)`
125
126
  padding: ${(a) => {
126
127
  var e;
127
128
  return (e = a.theme.sizes) == null ? void 0 : e.normal;
@@ -131,5 +132,5 @@ const tt = ({
131
132
  }};
132
133
  `;
133
134
  export {
134
- tt as default
135
+ ot as default
135
136
  };
@@ -1,17 +1,18 @@
1
1
  import { jsx as a } from "react/jsx-runtime";
2
- import l from "@emotion/styled";
2
+ import m from "@emotion/styled";
3
3
  import { ContactList as M, ContactMethod as b } from "@telia-ace/knowledge-widget-adapters";
4
4
  import { useDispatch as $, useContainer as k } from "@telia-ace/knowledge-widget-ui";
5
5
  import { useState as f, useEffect as E } from "react";
6
- import S from "./contact-method-999b4ded.mjs";
6
+ import S from "./contact-method-93470880.mjs";
7
7
  import "@telia-ace/knowledge-data-client";
8
8
  import "@telia-ace/widget-forms";
9
9
  import "@telia-ace/widget-utilities";
10
- import "./index-088c9fb0.mjs";
10
+ import "./index-69c78022.mjs";
11
11
  import "@telia-ace/widget-conversation";
12
12
  import "@telia-ace/widget-services";
13
- const F = ({ actions: t, entryId: e, groupId: y }) => {
14
- const g = $(), d = k(), [m, x] = f([]), [r, C] = f([]);
13
+ import "@webprovisions/platform";
14
+ const H = ({ actions: t, entryId: e, groupId: y }) => {
15
+ const g = $(), d = k(), [l, x] = f([]), [r, C] = f([]);
15
16
  return E(() => {
16
17
  d.getAsync("contactMethods").then((i) => {
17
18
  if (!i)
@@ -50,11 +51,11 @@ const F = ({ actions: t, entryId: e, groupId: y }) => {
50
51
  x(n.filter((o) => !!o));
51
52
  });
52
53
  });
53
- }, [t, d, e, r]), m.length ? /* @__PURE__ */ a(
54
+ }, [t, d, e, r]), l.length ? /* @__PURE__ */ a(
54
55
  j,
55
56
  {
56
57
  className: "humany-bot-contact-list",
57
- contactMethods: m,
58
+ contactMethods: l,
58
59
  dispatch: g,
59
60
  itemRenderer: (i, c) => (r.includes(i.id) || i.expanded) && i.inline || i.clientName === "custom.link" ? /* @__PURE__ */ a(
60
61
  v,
@@ -66,7 +67,7 @@ const F = ({ actions: t, entryId: e, groupId: y }) => {
66
67
  ) : /* @__PURE__ */ a(z, { ...i, ...c })
67
68
  }
68
69
  ) : null;
69
- }, j = l(M)`
70
+ }, j = m(M)`
70
71
  > ul > li {
71
72
  a {
72
73
  display: flex;
@@ -78,7 +79,7 @@ const F = ({ actions: t, entryId: e, groupId: y }) => {
78
79
  ${(t) => t.theme.border && `border-bottom: ${t.theme.border};`}
79
80
  }
80
81
  }
81
- `, v = l(S)`
82
+ `, v = m(S)`
82
83
  i {
83
84
  margin: 0 ${(t) => {
84
85
  var e;
@@ -88,7 +89,7 @@ const F = ({ actions: t, entryId: e, groupId: y }) => {
88
89
  justify-content: center;
89
90
  align-items: center;
90
91
  }
91
- `, z = l(b)`
92
+ `, z = m(b)`
92
93
  padding: ${(t) => {
93
94
  var e;
94
95
  return (e = t.theme.sizes) == null ? void 0 : e.medium;
@@ -104,5 +105,5 @@ const F = ({ actions: t, entryId: e, groupId: y }) => {
104
105
  }
105
106
  `;
106
107
  export {
107
- F as default
108
+ H as default
108
109
  };
@@ -0,0 +1,28 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),u=require("@emotion/styled"),y=require("@telia-ace/knowledge-widget-adapters"),g=require("@telia-ace/knowledge-widget-ui"),l=require("react"),b=require("./contact-method-5c975b10.js");require("@telia-ace/knowledge-data-client");require("@telia-ace/widget-forms");require("@telia-ace/widget-utilities");require("./index-eb780812.js");require("@telia-ace/widget-conversation");require("@telia-ace/widget-services");require("@webprovisions/platform");const k=({actions:e,entryId:t,groupId:x})=>{const q=g.useDispatch(),o=g.useContainer(),[h,C]=l.useState([]),[d,M]=l.useState([]);return l.useEffect(()=>{o.getAsync("contactMethods").then(n=>{if(!n)return;const c=e.map(async i=>{var m;if(!((m=i.data)!=null&&m.clientName))return null;const s=await n.handleAdapters(i.data);return{...s,...i.data,description:i.data.description?i.data.description:s.description,onClick:(p,r)=>{if(typeof s.onClick=="function"&&s.onClick(p,r),!p.defaultPrevented)if(r.inline&&!r.expanded)M([...d,r.id]);else{const{events:f}=o.get("$widget");f.dispatch("conversational-hub-provider:open-contact-method",{entryId:t,contactMethod:r,actionKey:i.actionKey}),f.dispatch("tracking:contact-method-list-item-clicked",r)}}}});Promise.all(c).then(i=>{C(i.filter(s=>!!s))})})},[e,o,t,d]),h.length?a.jsx(j,{className:"humany-bot-contact-list",contactMethods:h,dispatch:q,itemRenderer:(n,c)=>(d.includes(n.id)||n.expanded)&&n.inline||n.clientName==="custom.link"?a.jsx(S,{contactMethodId:n.id,groupId:x,guideId:n.body.guideId}):a.jsx($,{...n,...c})}):null},j=u(y.ContactList)`
2
+ > ul > li {
3
+ a {
4
+ display: flex;
5
+ align-items: center;
6
+ outline-offset: -2px;
7
+ }
8
+
9
+ &:not(:last-child) {
10
+ ${e=>e.theme.border&&`border-bottom: ${e.theme.border};`}
11
+ }
12
+ }
13
+ `,S=u(b.default)`
14
+ i {
15
+ margin: 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}} 0 0;
16
+ display: flex;
17
+ justify-content: center;
18
+ align-items: center;
19
+ }
20
+ `,$=u(y.ContactMethod)`
21
+ padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
22
+ i {
23
+ margin: 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}} 0 0;
24
+ display: flex;
25
+ justify-content: center;
26
+ align-items: center;
27
+ }
28
+ `;exports.default=k;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@webprovisions/platform").ConfigurationApiDefinition;
2
+ export default _default;