@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.61 → 0.0.1-alpha.63
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/LICENSE.txt +5 -5
- package/README.md +12 -12
- package/dist/contact-method-list.d45b8f36.js +88 -0
- package/dist/contact-method-list.d45b8f36.js.map +1 -0
- package/dist/contact-method.fb45a5e2.js +119 -0
- package/dist/contact-method.fb45a5e2.js.map +1 -0
- package/dist/entry-handler.d.ts +2 -0
- package/dist/feedback-list.29c075b4.js +70 -0
- package/dist/feedback-list.29c075b4.js.map +1 -0
- package/dist/http-client.d.ts +43 -0
- package/dist/index.76a36f22.js +767 -0
- package/dist/index.76a36f22.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -669
- package/dist/index.js.map +1 -1
- package/dist/no-good-alternative.45aa0387.js +41 -0
- package/dist/no-good-alternative.45aa0387.js.map +1 -0
- package/dist/notification-list.cae1df51.js +62 -0
- package/dist/notification-list.cae1df51.js.map +1 -0
- package/dist/plugin.d.ts +3 -3
- package/dist/provider.d.ts +25 -0
- package/dist/store.d.ts +15 -0
- package/dist/styles.6c010dfc.js +15 -0
- package/dist/styles.6c010dfc.js.map +1 -0
- package/dist/types.d.ts +79 -0
- package/dist/ui/contact-method-list.d.ts +10 -0
- package/dist/ui/contact-method.d.ts +9 -0
- package/dist/ui/feedback-list.d.ts +8 -0
- package/dist/ui/no-good-alternative.d.ts +6 -0
- package/dist/ui/notification-list.d.ts +11 -0
- package/dist/ui/styles.d.ts +1 -0
- package/dist/utils.d.ts +26 -0
- package/package.json +11 -14
- package/dist/client/chat.client.d.ts +0 -16
- package/dist/client/contact-method.client.d.ts +0 -25
- package/dist/client/http.client.d.ts +0 -23
- package/dist/client/middleware.client.d.ts +0 -14
- package/dist/contact-method.15886c3d.js +0 -66
- package/dist/contact-method.15886c3d.js.map +0 -1
- package/dist/contract/custom-component/contact-method-item.d.ts +0 -8
- package/dist/contract/custom-component/contact-method-list.d.ts +0 -7
- package/dist/contract/custom-component/contact-method.d.ts +0 -3
- package/dist/contract/enum/server-entry-type.enum.d.ts +0 -7
- package/dist/contract/model/conversation-api-model/list.model.d.ts +0 -5
- package/dist/contract/model/conversation-api-model/message.model.d.ts +0 -7
- package/dist/contract/model/http/action.model.d.ts +0 -3
- package/dist/contract/model/http/client-action.model.d.ts +0 -4
- package/dist/contract/model/http/client-envelope.model.d.ts +0 -9
- package/dist/contract/model/http/connect-options.model.d.ts +0 -5
- package/dist/contract/model/http/global-state.model.d.ts +0 -8
- package/dist/contract/model/http/http-client-options.model.d.ts +0 -5
- package/dist/contract/model/http/server-entry.model.d.ts +0 -11
- package/dist/contract/model/http/server-envelope.model.d.ts +0 -10
- package/dist/contract/model/middleware/aggregator-state.model.d.ts +0 -4
- package/dist/contract/model/shared/loose-object.model.d.ts +0 -3
- package/dist/helper/chat.helper.d.ts +0 -8
- package/dist/helper/http.helper.d.ts +0 -13
- package/dist/helper/middleware.helper.d.ts +0 -12
- package/dist/helper/store.helper.d.ts +0 -22
- package/dist/interface/entry.interface.d.ts +0 -20
- package/dist/interface/middleware/paging.interface.d.ts +0 -4
- package/dist/interface/middleware/processor.interface.d.ts +0 -10
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Copyright © 2021, Telia Company AB. All rights reserved.
|
|
2
|
-
|
|
3
|
-
THIS PACKAGE AND CONTAINING SOFTWARE IS PART OF
|
|
4
|
-
THE HUMANY SERVICE. BY USING THIS SOFTWARE YOU
|
|
5
|
-
AGREE TO THE FOLLOWING TERMS AND CONDITIONS:
|
|
1
|
+
Copyright © 2021, Telia Company AB. All rights reserved.
|
|
2
|
+
|
|
3
|
+
THIS PACKAGE AND CONTAINING SOFTWARE IS PART OF
|
|
4
|
+
THE HUMANY SERVICE. BY USING THIS SOFTWARE YOU
|
|
5
|
+
AGREE TO THE FOLLOWING TERMS AND CONDITIONS:
|
|
6
6
|
http://www.humany.com/legal
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# `@telia-ace/knowledge-widget-bot-provider`
|
|
2
|
-
|
|
3
|
-
Provider for the ACE Knowledge chat bot.
|
|
4
|
-
|
|
5
|
-
For this provider to work, the "chat.bot" provider must be registered in the widget config file.
|
|
6
|
-
|
|
7
|
-
In addition, these plugins are also required:
|
|
8
|
-
WidgetHeaderComponent
|
|
9
|
-
AreaComponent
|
|
10
|
-
ConversationComponent
|
|
11
|
-
DefaultContactMethodsPlugin
|
|
12
|
-
ConversationPlugin
|
|
1
|
+
# `@telia-ace/knowledge-widget-bot-provider`
|
|
2
|
+
|
|
3
|
+
Provider for the ACE Knowledge chat bot.
|
|
4
|
+
|
|
5
|
+
For this provider to work, the "chat.bot" provider must be registered in the widget config file.
|
|
6
|
+
|
|
7
|
+
In addition, these plugins are also required:
|
|
8
|
+
WidgetHeaderComponent
|
|
9
|
+
AreaComponent
|
|
10
|
+
ConversationComponent
|
|
11
|
+
DefaultContactMethodsPlugin
|
|
12
|
+
ConversationPlugin
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var y = Object.defineProperty, C = Object.defineProperties;
|
|
2
|
+
var M = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var p = Object.getOwnPropertySymbols;
|
|
4
|
+
var $ = Object.prototype.hasOwnProperty, E = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var u = (t, e, n) => e in t ? y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, d = (t, e) => {
|
|
6
|
+
for (var n in e || (e = {}))
|
|
7
|
+
$.call(e, n) && u(t, n, e[n]);
|
|
8
|
+
if (p)
|
|
9
|
+
for (var n of p(e))
|
|
10
|
+
E.call(e, n) && u(t, n, e[n]);
|
|
11
|
+
return t;
|
|
12
|
+
}, h = (t, e) => C(t, M(e));
|
|
13
|
+
import { ContactList as b, ContactMethod as S } from "@telia-ace/knowledge-widget-adapters";
|
|
14
|
+
import { useDispatch as v, useContainer as z } from "@telia-ace/knowledge-widget-ui";
|
|
15
|
+
import s, { useState as L, useMemo as j } from "react";
|
|
16
|
+
import c from "styled-components";
|
|
17
|
+
import I from "./contact-method.fb45a5e2.js";
|
|
18
|
+
import "@telia-ace/knowledge-widget-types-grid";
|
|
19
|
+
import "@telia-ace/widget-forms";
|
|
20
|
+
import "./index.76a36f22.js";
|
|
21
|
+
import "@telia-ace/widget-conversation";
|
|
22
|
+
import "@telia-ace/widget-services";
|
|
23
|
+
import "@telia-ace/widget-utilities";
|
|
24
|
+
const P = ({ actions: t, entryId: e, groupId: n }) => {
|
|
25
|
+
const f = v(), a = z(), [r, g] = L([]), m = j(() => t.map((o) => h(d({}, o.data), {
|
|
26
|
+
onClick: (l, i) => {
|
|
27
|
+
if (i.inline && !i.expanded)
|
|
28
|
+
g([...r, i.id]);
|
|
29
|
+
else {
|
|
30
|
+
const { events: x } = a.get("$widget");
|
|
31
|
+
x.dispatch("provider:open-contact-method", {
|
|
32
|
+
entryId: e,
|
|
33
|
+
contactMethod: i,
|
|
34
|
+
actionKey: o.actionKey
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
})), [t, a, e, r]);
|
|
39
|
+
return m.length ? /* @__PURE__ */ s.createElement(K, {
|
|
40
|
+
contactMethods: m,
|
|
41
|
+
dispatch: f,
|
|
42
|
+
itemRenderer: (o, l) => (r.includes(o.id) || o.expanded) && o.inline ? /* @__PURE__ */ s.createElement(R, {
|
|
43
|
+
contactMethodId: o.id,
|
|
44
|
+
groupId: n,
|
|
45
|
+
guideId: o.body.guideId
|
|
46
|
+
}) : /* @__PURE__ */ s.createElement(k, d(d({}, o), l))
|
|
47
|
+
}) : null;
|
|
48
|
+
}, K = c(b)`
|
|
49
|
+
> ul > li {
|
|
50
|
+
a {
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
outline-offset: -2px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&:not(:last-child) {
|
|
57
|
+
${(t) => t.theme.border && `border-bottom: ${t.theme.border};`}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`, R = c(I)`
|
|
61
|
+
i {
|
|
62
|
+
margin: 0 ${(t) => {
|
|
63
|
+
var e;
|
|
64
|
+
return (e = t.theme.sizes) == null ? void 0 : e.medium;
|
|
65
|
+
}} 0 0;
|
|
66
|
+
display: flex;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
align-items: center;
|
|
69
|
+
}
|
|
70
|
+
`, k = c(S)`
|
|
71
|
+
padding: ${(t) => {
|
|
72
|
+
var e;
|
|
73
|
+
return (e = t.theme.sizes) == null ? void 0 : e.medium;
|
|
74
|
+
}};
|
|
75
|
+
i {
|
|
76
|
+
margin: 0 ${(t) => {
|
|
77
|
+
var e;
|
|
78
|
+
return (e = t.theme.sizes) == null ? void 0 : e.medium;
|
|
79
|
+
}} 0 0;
|
|
80
|
+
display: flex;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
align-items: center;
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
export {
|
|
86
|
+
P as default
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=contact-method-list.d45b8f36.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-method-list.d45b8f36.js","sources":["../src/ui/contact-method-list.tsx"],"sourcesContent":["import {\r\n ContactList,\r\n ContactMethod as GenericContactMethod,\r\n} from '@telia-ace/knowledge-widget-adapters';\r\nimport { useContainer, useDispatch } from '@telia-ace/knowledge-widget-ui';\r\nimport React, { useMemo, useState } from 'react';\r\nimport styled from 'styled-components';\r\nimport { ActionItem } from '../types';\r\nimport ContactMethod from './contact-method';\r\n\r\ntype Props = {\r\n actions: ActionItem[];\r\n contactMethodIds?: string[];\r\n entryId: string;\r\n groupId: string;\r\n};\r\nconst ContactMethodList: React.FC<Props> = ({ actions, entryId, groupId }) => {\r\n const dispatch = useDispatch();\r\n const container = useContainer();\r\n const [expanded, setExpanded] = useState<string[]>([]);\r\n\r\n const items = useMemo<any[]>(() => {\r\n return actions.map((action) => {\r\n return {\r\n ...action.data,\r\n onClick: (_event: any, data: any) => {\r\n if (data.inline && !data.expanded) {\r\n setExpanded([...expanded, data.id]);\r\n } else {\r\n const { events } = container.get('$widget');\r\n events.dispatch('provider:open-contact-method', {\r\n entryId,\r\n contactMethod: data,\r\n actionKey: action.actionKey,\r\n });\r\n }\r\n },\r\n };\r\n });\r\n }, [actions, container, entryId, expanded]);\r\n\r\n if (!items.length) {\r\n return null;\r\n }\r\n\r\n return (\r\n <StyledContactList\r\n contactMethods={items}\r\n dispatch={dispatch}\r\n itemRenderer={(cm: any, props: any) => {\r\n const isExpanded = expanded.includes(cm.id) || cm.expanded;\r\n if (isExpanded && cm.inline) {\r\n return (\r\n <StyledContactMethod\r\n contactMethodId={cm.id}\r\n groupId={groupId}\r\n guideId={cm.body.guideId}\r\n />\r\n );\r\n }\r\n return <StyledGenericContactMethod {...cm} {...props} />;\r\n }}\r\n />\r\n );\r\n};\r\n\r\nexport default ContactMethodList;\r\n\r\nconst StyledContactList = styled(ContactList)`\r\n > ul > li {\r\n a {\r\n display: flex;\r\n align-items: center;\r\n outline-offset: -2px;\r\n }\r\n\r\n &:not(:last-child) {\r\n ${(p) => p.theme.border && `border-bottom: ${p.theme.border};`}\r\n }\r\n }\r\n`;\r\n\r\nconst StyledContactMethod = styled(ContactMethod)`\r\n i {\r\n margin: 0 ${(p) => p.theme.sizes?.medium} 0 0;\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n }\r\n`;\r\nconst StyledGenericContactMethod = styled(GenericContactMethod)`\r\n padding: ${(p) => p.theme.sizes?.medium};\r\n i {\r\n margin: 0 ${(p) => p.theme.sizes?.medium} 0 0;\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n }\r\n`;\r\n"],"names":["ContactMethodList","actions","entryId","groupId","dispatch","useDispatch","container","useContainer","expanded","setExpanded","useState","items","useMemo","action","__spreadProps","__spreadValues","_event","data","events","React","StyledContactList","cm","props","StyledContactMethod","StyledGenericContactMethod","styled","ContactList","p","ContactMethod","_a","GenericContactMethod"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAMA,IAAqC,CAAC,EAAE,SAAAC,GAAS,SAAAC,GAAS,SAAAC,QAAc;AAC1E,QAAMC,IAAWC,KACXC,IAAYC,KACZ,CAACC,GAAUC,CAAW,IAAIC,EAAmB,CAAE,CAAA,GAE/CC,IAAQC,EAAe,MAClBX,EAAQ,IAAI,CAACY,MACTC,EAAAC,EAAA,IACAF,EAAO,OADP;AAAA,IAEH,SAAS,CAACG,GAAaC,MAAc;AACjC,UAAIA,EAAK,UAAU,CAACA,EAAK;AACrB,QAAAR,EAAY,CAAC,GAAGD,GAAUS,EAAK,EAAE,CAAC;AAAA,WAC/B;AACH,cAAM,EAAE,QAAAC,EAAW,IAAAZ,EAAU,IAAI,SAAS;AAC1C,QAAAY,EAAO,SAAS,gCAAgC;AAAA,UAC5C,SAAAhB;AAAA,UACA,eAAee;AAAA,UACf,WAAWJ,EAAO;AAAA,QAAA,CACrB;AAAA,MACL;AAAA,IACJ;AAAA,EAAA,EAEP,GACF,CAACZ,GAASK,GAAWJ,GAASM,CAAQ,CAAC;AAEtC,SAACG,EAAM,SAKN,gBAAAQ,EAAA,cAAAC,GAAA;AAAA,IACG,gBAAgBT;AAAA,IAChB,UAAAP;AAAA,IACA,cAAc,CAACiB,GAASC,OACDd,EAAS,SAASa,EAAG,EAAE,KAAKA,EAAG,aAChCA,EAAG,SAEZ,gBAAAF,EAAA,cAAAI,GAAA;AAAA,MACG,iBAAiBF,EAAG;AAAA,MACpB,SAAAlB;AAAA,MACA,SAASkB,EAAG,KAAK;AAAA,IAAA,CACrB,IAGA,gBAAAF,EAAA,cAAAK,GAAAT,IAAA,IAA+BM,IAAQC,EAAO;AAAA,EAC1D,CACJ,IApBO;AAsBf,GAIMF,IAAoBK,EAAOC,CAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAS9B,CAACC,MAAMA,EAAE,MAAM,UAAU,kBAAkBA,EAAE,MAAM;AAAA;AAAA;AAAA,GAK3DJ,IAAsBE,EAAOG,CAAa;AAAA;AAAA,oBAE5B,CAACD,MAAM;;AAAA,UAAAE,IAAAF,EAAE,MAAM,UAAR,gBAAAE,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAMpCL,IAA6BC,EAAOK,CAAoB;AAAA,eAC/C,CAACH,MAAM;;AAAA,UAAAE,IAAAF,EAAE,MAAM,UAAR,gBAAAE,EAAe;AAAA;AAAA;AAAA,oBAEjB,CAACF,MAAM;;AAAA,UAAAE,IAAAF,EAAE,MAAM,UAAR,gBAAAE,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var x = Object.defineProperty, z = Object.defineProperties;
|
|
2
|
+
var B = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var S = Object.getOwnPropertySymbols;
|
|
4
|
+
var D = Object.prototype.hasOwnProperty, T = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var $ = (e, t, o) => t in e ? x(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o, s = (e, t) => {
|
|
6
|
+
for (var o in t || (t = {}))
|
|
7
|
+
D.call(t, o) && $(e, o, t[o]);
|
|
8
|
+
if (S)
|
|
9
|
+
for (var o of S(t))
|
|
10
|
+
T.call(t, o) && $(e, o, t[o]);
|
|
11
|
+
return e;
|
|
12
|
+
}, c = (e, t) => z(e, B(t));
|
|
13
|
+
var y = (e, t, o) => new Promise((h, r) => {
|
|
14
|
+
var i = (a) => {
|
|
15
|
+
try {
|
|
16
|
+
f(o.next(a));
|
|
17
|
+
} catch (m) {
|
|
18
|
+
r(m);
|
|
19
|
+
}
|
|
20
|
+
}, d = (a) => {
|
|
21
|
+
try {
|
|
22
|
+
f(o.throw(a));
|
|
23
|
+
} catch (m) {
|
|
24
|
+
r(m);
|
|
25
|
+
}
|
|
26
|
+
}, f = (a) => a.done ? h(a.value) : Promise.resolve(a.value).then(i, d);
|
|
27
|
+
f((o = o.apply(e, t)).next());
|
|
28
|
+
});
|
|
29
|
+
import { ContactMethod as _ } from "@telia-ace/knowledge-widget-adapters";
|
|
30
|
+
import { DataType as k } from "@telia-ace/knowledge-widget-types-grid";
|
|
31
|
+
import { useContainer as G, useDispatch as V } from "@telia-ace/knowledge-widget-ui";
|
|
32
|
+
import { FormBuilder as j } from "@telia-ace/widget-forms";
|
|
33
|
+
import q, { useState as H, useRef as J, useEffect as A, useCallback as K } from "react";
|
|
34
|
+
import L from "styled-components";
|
|
35
|
+
import { u as F } from "./index.76a36f22.js";
|
|
36
|
+
import "@telia-ace/widget-conversation";
|
|
37
|
+
import "@telia-ace/widget-services";
|
|
38
|
+
import "@telia-ace/widget-utilities";
|
|
39
|
+
const rt = ({ contactMethodId: e, guideId: t, groupId: o, className: h }) => {
|
|
40
|
+
const [r, i] = H(), d = G(), f = V(), a = J(!0);
|
|
41
|
+
A(() => {
|
|
42
|
+
const { events: p } = d.get("$widget"), w = p.subscribe("bot-provider:form-submitted", (C, l) => y(void 0, null, function* () {
|
|
43
|
+
var g;
|
|
44
|
+
if (((g = l.form.meta) == null ? void 0 : g.groupId) !== o || l.id !== r.id)
|
|
45
|
+
return;
|
|
46
|
+
const M = yield d.getAsync("contactMethods"), n = c(s({}, r), {
|
|
47
|
+
body: c(s({}, r.body), {
|
|
48
|
+
form: l.form
|
|
49
|
+
})
|
|
50
|
+
}), { errors: b, valid: v, errorTypes: O } = yield M.validate(n);
|
|
51
|
+
if (!v) {
|
|
52
|
+
const E = new j(r.body.form);
|
|
53
|
+
i(void 0), E.setValidationErrors(b), n.body = c(s({}, n.body), {
|
|
54
|
+
form: E.get()
|
|
55
|
+
}), i(s({}, n));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const R = yield M.submit(n);
|
|
59
|
+
n.confirmation = R, i(n);
|
|
60
|
+
})), u = p.subscribe("bot-provider:evaluate", (C, l) => y(void 0, null, function* () {
|
|
61
|
+
if (l.id != e)
|
|
62
|
+
return;
|
|
63
|
+
const n = yield (yield d.getAsync("contactMethods")).evaluate(r);
|
|
64
|
+
let b = c(s({}, r), {
|
|
65
|
+
body: c(s({}, r.body), {
|
|
66
|
+
form: n
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
const v = F(b, {
|
|
70
|
+
submit: "Submit",
|
|
71
|
+
errors: {},
|
|
72
|
+
meta: { groupId: o }
|
|
73
|
+
});
|
|
74
|
+
b = c(s({}, b), {
|
|
75
|
+
body: v
|
|
76
|
+
}), i(b);
|
|
77
|
+
}));
|
|
78
|
+
return () => {
|
|
79
|
+
w(), u();
|
|
80
|
+
};
|
|
81
|
+
}, [d, r, i]);
|
|
82
|
+
const m = K(
|
|
83
|
+
(p) => y(void 0, null, function* () {
|
|
84
|
+
const u = yield (yield d.getAsync("dataClient")).fetch(k.ContactMethod, {
|
|
85
|
+
contactMethodId: p,
|
|
86
|
+
guideId: t
|
|
87
|
+
}), C = F(u, {
|
|
88
|
+
submit: "Submit",
|
|
89
|
+
errors: {},
|
|
90
|
+
meta: { groupId: o }
|
|
91
|
+
});
|
|
92
|
+
if (u.body = C, u.body.guideId = t, !a.current)
|
|
93
|
+
return null;
|
|
94
|
+
i(u);
|
|
95
|
+
}),
|
|
96
|
+
[a]
|
|
97
|
+
);
|
|
98
|
+
return A(() => (m(e), () => {
|
|
99
|
+
a.current = !1;
|
|
100
|
+
}), [e, m]), r ? /* @__PURE__ */ q.createElement(N, c(s({}, r), {
|
|
101
|
+
body: r.body,
|
|
102
|
+
inline: !0,
|
|
103
|
+
expanded: !0,
|
|
104
|
+
dispatch: f,
|
|
105
|
+
className: h
|
|
106
|
+
})) : null;
|
|
107
|
+
}, N = L(_)`
|
|
108
|
+
padding: ${(e) => {
|
|
109
|
+
var t;
|
|
110
|
+
return (t = e.theme.sizes) == null ? void 0 : t.normal;
|
|
111
|
+
}} ${(e) => {
|
|
112
|
+
var t;
|
|
113
|
+
return (t = e.theme.sizes) == null ? void 0 : t.medium;
|
|
114
|
+
}};
|
|
115
|
+
`;
|
|
116
|
+
export {
|
|
117
|
+
rt as default
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=contact-method.fb45a5e2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-method.fb45a5e2.js","sources":["../src/ui/contact-method.tsx"],"sourcesContent":["import {\r\n ContactMethod as GenericContactMethod,\r\n ContactMethodPlatform,\r\n} from '@telia-ace/knowledge-widget-adapters';\r\nimport { DataType } from '@telia-ace/knowledge-widget-types-grid';\r\nimport { useContainer, useDispatch } from '@telia-ace/knowledge-widget-ui';\r\nimport { FormBuilder } from '@telia-ace/widget-forms';\r\nimport { Widget } from '@webprovisions/platform';\r\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\r\nimport styled from 'styled-components';\r\nimport { updateForm } from '../utils';\r\n\r\ntype Props = {\r\n contactMethodId: string;\r\n groupId: string;\r\n guideId?: string;\r\n className?: string;\r\n};\r\nconst ContactMethod: React.FC<Props> = ({ contactMethodId, guideId, groupId, className }) => {\r\n const [contactMethod, setContactMethod] = useState<any>();\r\n const container = useContainer();\r\n const dispatch = useDispatch();\r\n const mountedRef = useRef<boolean>(true);\r\n\r\n useEffect(() => {\r\n const { events } = container.get('$widget') as Widget;\r\n\r\n const unsubscribe = events.subscribe('bot-provider:form-submitted', async (_, data) => {\r\n // making sure that this is the form that is submitted\r\n if (data.form.meta?.groupId !== groupId || data.id !== contactMethod.id) {\r\n return;\r\n }\r\n\r\n const platform = (await container.getAsync('contactMethods')) as ContactMethodPlatform;\r\n\r\n const updatedMethod = {\r\n ...contactMethod,\r\n body: {\r\n ...contactMethod.body,\r\n form: data.form,\r\n },\r\n };\r\n\r\n const { errors, valid, errorTypes } = await platform.validate(updatedMethod);\r\n\r\n if (!valid) {\r\n const builder = new FormBuilder(contactMethod.body.form);\r\n setContactMethod(undefined);\r\n\r\n builder.setValidationErrors(errors);\r\n\r\n updatedMethod.body = {\r\n ...updatedMethod.body,\r\n form: builder.get(),\r\n };\r\n\r\n setContactMethod({ ...updatedMethod });\r\n return;\r\n }\r\n\r\n const result = await platform.submit(updatedMethod);\r\n\r\n updatedMethod.confirmation = result;\r\n setContactMethod(updatedMethod);\r\n });\r\n\r\n const unsubscribeEvaluate = events.subscribe('bot-provider:evaluate', async (_, data) => {\r\n if (data.id != contactMethodId) {\r\n return;\r\n }\r\n\r\n const platform = (await container.getAsync('contactMethods')) as ContactMethodPlatform;\r\n\r\n const updatedForm = await platform.evaluate(contactMethod);\r\n\r\n let updatedMethod = {\r\n ...contactMethod,\r\n body: {\r\n ...contactMethod.body,\r\n form: updatedForm,\r\n },\r\n };\r\n\r\n const updatedBody = updateForm(updatedMethod, {\r\n submit: 'Submit',\r\n errors: {},\r\n meta: { groupId },\r\n });\r\n\r\n updatedMethod = {\r\n ...updatedMethod,\r\n body: updatedBody,\r\n };\r\n\r\n setContactMethod(updatedMethod);\r\n });\r\n\r\n return () => {\r\n unsubscribe();\r\n unsubscribeEvaluate();\r\n };\r\n }, [container, contactMethod, setContactMethod]);\r\n\r\n const fetchContactMethod = useCallback(\r\n async (id: string) => {\r\n const dataClient = await container.getAsync('dataClient');\r\n\r\n const cm = await dataClient.fetch(DataType.ContactMethod, {\r\n contactMethodId: id,\r\n guideId,\r\n });\r\n\r\n const body = updateForm(cm, {\r\n submit: 'Submit',\r\n errors: {},\r\n meta: { groupId },\r\n });\r\n cm.body = body;\r\n cm.body.guideId = guideId;\r\n\r\n if (!mountedRef.current) {\r\n return null;\r\n }\r\n setContactMethod(cm);\r\n },\r\n [mountedRef]\r\n );\r\n\r\n useEffect(() => {\r\n fetchContactMethod(contactMethodId);\r\n return () => {\r\n mountedRef.current = false; // clean up\r\n };\r\n }, [contactMethodId, fetchContactMethod]);\r\n\r\n if (!contactMethod) {\r\n return null;\r\n }\r\n return (\r\n <StyledGenericContactMethod\r\n {...contactMethod}\r\n body={contactMethod.body}\r\n inline={true}\r\n expanded={true}\r\n dispatch={dispatch}\r\n className={className}\r\n />\r\n );\r\n};\r\n\r\nexport default ContactMethod;\r\n\r\nconst StyledGenericContactMethod = styled(GenericContactMethod)`\r\n padding: ${(p) => p.theme.sizes?.normal} ${(p) => p.theme.sizes?.medium};\r\n`;\r\n"],"names":["ContactMethod","contactMethodId","guideId","groupId","className","contactMethod","setContactMethod","useState","container","useContainer","dispatch","useDispatch","mountedRef","useRef","useEffect","events","unsubscribe","_","data","__async","_a","platform","updatedMethod","__spreadProps","__spreadValues","errors","valid","errorTypes","builder","FormBuilder","result","unsubscribeEvaluate","updatedForm","updatedBody","updateForm","fetchContactMethod","useCallback","id","cm","DataType","body","React","StyledGenericContactMethod","styled","GenericContactMethod","p"],"mappings":"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"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useDispatch as n, Icon as s, List as i, list as l, Button as c, buttonCss as m, invertedHoverButton as d } from "@telia-ace/knowledge-widget-ui";
|
|
2
|
+
import o from "react";
|
|
3
|
+
import r from "styled-components";
|
|
4
|
+
import { m as p } from "./styles.6c010dfc.js";
|
|
5
|
+
const F = ({ actions: t }) => {
|
|
6
|
+
const e = n();
|
|
7
|
+
return /* @__PURE__ */ o.createElement(f, {
|
|
8
|
+
items: t,
|
|
9
|
+
"data-direction": "vertical",
|
|
10
|
+
renderItem: (a) => /* @__PURE__ */ o.createElement("li", {
|
|
11
|
+
key: a.actionKey
|
|
12
|
+
}, /* @__PURE__ */ o.createElement(u, {
|
|
13
|
+
className: "humany-feedback-button",
|
|
14
|
+
disabled: !1,
|
|
15
|
+
"aria-pressed": !0,
|
|
16
|
+
"data-selected": !0,
|
|
17
|
+
onClick: () => {
|
|
18
|
+
e("action", a.actionKey);
|
|
19
|
+
}
|
|
20
|
+
}, /* @__PURE__ */ o.createElement(s, {
|
|
21
|
+
faIcon: a.actionKey == "yes" ? "smile-o" : "frown-o"
|
|
22
|
+
}), /* @__PURE__ */ o.createElement("span", null, a.label)))
|
|
23
|
+
});
|
|
24
|
+
}, f = r(i)`
|
|
25
|
+
${l}
|
|
26
|
+
${p}
|
|
27
|
+
display: flex;
|
|
28
|
+
gap: ${(t) => {
|
|
29
|
+
var e;
|
|
30
|
+
return (e = t.theme.sizes) == null ? void 0 : e.normal;
|
|
31
|
+
}};
|
|
32
|
+
flex-direction: ${(t) => t["data-direction"] === "horizontal" ? "row" : "column"};
|
|
33
|
+
> li {
|
|
34
|
+
flex: 1;
|
|
35
|
+
margin: 0;
|
|
36
|
+
}
|
|
37
|
+
`, u = r(c)`
|
|
38
|
+
${m}
|
|
39
|
+
font-size: ${(t) => {
|
|
40
|
+
var e;
|
|
41
|
+
return (e = t.theme.fonts) == null ? void 0 : e.normal;
|
|
42
|
+
}};
|
|
43
|
+
border-color: ${(t) => {
|
|
44
|
+
var e;
|
|
45
|
+
return (e = t.theme.colors) == null ? void 0 : e.primary;
|
|
46
|
+
}};
|
|
47
|
+
font-weight: 300;
|
|
48
|
+
display: block;
|
|
49
|
+
width: 100%;
|
|
50
|
+
|
|
51
|
+
${(t) => {
|
|
52
|
+
var e;
|
|
53
|
+
return d({
|
|
54
|
+
primaryColor: `${(e = t.theme.colors) == null ? void 0 : e.primary}`,
|
|
55
|
+
secondaryColor: "#FFFFFF"
|
|
56
|
+
});
|
|
57
|
+
}}
|
|
58
|
+
i {
|
|
59
|
+
margin: 0 ${(t) => {
|
|
60
|
+
var e;
|
|
61
|
+
return (e = t.theme.sizes) == null ? void 0 : e.small;
|
|
62
|
+
}} 0 0;
|
|
63
|
+
}
|
|
64
|
+
span {
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
export {
|
|
68
|
+
F as default
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=feedback-list.29c075b4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback-list.29c075b4.js","sources":["../src/ui/feedback-list.tsx"],"sourcesContent":["import {\r\n Button,\r\n buttonCss,\r\n Icon,\r\n invertedHoverButton,\r\n list,\r\n List,\r\n useDispatch,\r\n} from '@telia-ace/knowledge-widget-ui';\r\nimport React from 'react';\r\nimport styled from 'styled-components';\r\nimport { messageContentPadding } from './styles';\r\n\r\ntype Props = {\r\n actions: { [key: string]: string }[];\r\n};\r\nconst FeedbackList: React.FC<Props> = ({ actions }) => {\r\n const dispatch = useDispatch();\r\n return (\r\n <StyledButtonList\r\n items={actions}\r\n data-direction={'vertical'}\r\n renderItem={(item: any) => {\r\n return (\r\n <li key={item.actionKey}>\r\n <FeedbackButton\r\n className=\"humany-feedback-button\"\r\n disabled={false}\r\n aria-pressed={true}\r\n data-selected={true}\r\n onClick={() => {\r\n dispatch('action', item.actionKey);\r\n }}\r\n >\r\n <Icon faIcon={item.actionKey == 'yes' ? 'smile-o' : 'frown-o'} />\r\n <span>{item.label}</span>\r\n </FeedbackButton>\r\n </li>\r\n );\r\n }}\r\n />\r\n );\r\n};\r\n\r\nexport default FeedbackList;\r\n\r\nconst StyledButtonList = styled(List)<{ 'data-direction': 'horizontal' | 'vertical' } & any>`\r\n ${list}\r\n ${messageContentPadding}\r\n display: flex;\r\n gap: ${(p) => p.theme.sizes?.normal};\r\n flex-direction: ${(p) => (p['data-direction'] === 'horizontal' ? 'row' : 'column')};\r\n > li {\r\n flex: 1;\r\n margin: 0;\r\n }\r\n`;\r\n\r\nconst FeedbackButton = styled(Button)<{\r\n 'data-selected': boolean;\r\n}>`\r\n ${buttonCss}\r\n font-size: ${(p) => p.theme.fonts?.normal};\r\n border-color: ${(p) => p.theme.colors?.primary};\r\n font-weight: 300;\r\n display: block;\r\n width: 100%;\r\n\r\n ${(p) =>\r\n invertedHoverButton({\r\n primaryColor: `${p.theme.colors?.primary}`,\r\n secondaryColor: '#FFFFFF',\r\n })}\r\n i {\r\n margin: 0 ${(p) => p.theme.sizes?.small} 0 0;\r\n }\r\n span {\r\n }\r\n`;\r\n"],"names":["FeedbackList","actions","dispatch","useDispatch","React","StyledButtonList","item","FeedbackButton","Icon","styled","List","list","messageContentPadding","p","_a","Button","buttonCss","invertedHoverButton"],"mappings":";;;;AAgBA,MAAMA,IAAgC,CAAC,EAAE,SAAAC,QAAc;AACnD,QAAMC,IAAWC;AACjB,SACK,gBAAAC,EAAA,cAAAC,GAAA;AAAA,IACG,OAAOJ;AAAA,IACP,kBAAgB;AAAA,IAChB,YAAY,CAACK,MAEJ,gBAAAF,EAAA,cAAA,MAAA;AAAA,MAAG,KAAKE,EAAK;AAAA,IAAA,GACT,gBAAAF,EAAA,cAAAG,GAAA;AAAA,MACG,WAAU;AAAA,MACV,UAAU;AAAA,MACV,gBAAc;AAAA,MACd,iBAAe;AAAA,MACf,SAAS,MAAM;AACF,QAAAL,EAAA,UAAUI,EAAK,SAAS;AAAA,MACrC;AAAA,IAAA,GAEC,gBAAAF,EAAA,cAAAI,GAAA;AAAA,MAAK,QAAQF,EAAK,aAAa,QAAQ,YAAY;AAAA,IAAA,CAAW,GAC9D,gBAAAF,EAAA,cAAA,QAAA,MAAME,EAAK,KAAM,CACtB,CACJ;AAAA,EAER,CACJ;AAER,GAIMD,IAAmBI,EAAOC,CAAI;AAAA,MAC9BC;AAAA,MACAC;AAAA;AAAA,WAEK,CAACC,MAAM;;AAAA,UAAAC,IAAAD,EAAE,MAAM,UAAR,gBAAAC,EAAe;AAAA;AAAA,sBACX,CAACD,MAAOA,EAAE,sBAAsB,eAAe,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,GAOvEN,IAAiBE,EAAOM,CAAM;AAAA,MAG9BC;AAAA,iBACW,CAACH,MAAM;;AAAA,UAAAC,IAAAD,EAAE,MAAM,UAAR,gBAAAC,EAAe;AAAA;AAAA,oBACnB,CAACD,MAAM;;AAAA,UAAAC,IAAAD,EAAE,MAAM,WAAR,gBAAAC,EAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAKrC,CAACD;;AACC,SAAAI,EAAoB;AAAA,IAChB,cAAc,IAAGH,IAAAD,EAAE,MAAM,WAAR,gBAAAC,EAAgB;AAAA,IACjC,gBAAgB;AAAA,EACpB,CAAC;AAAA;AAAA;AAAA,oBAEW,CAACD,MAAM;;AAAA,UAAAC,IAAAD,EAAE,MAAM,UAAR,gBAAAC,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Container, EventManager } from '@webprovisions/platform';
|
|
2
|
+
import Store from './store';
|
|
3
|
+
import { MessageGroup } from './types';
|
|
4
|
+
declare class HttpClient {
|
|
5
|
+
private endpoint;
|
|
6
|
+
private events;
|
|
7
|
+
private store;
|
|
8
|
+
private container;
|
|
9
|
+
private globalState;
|
|
10
|
+
private localState;
|
|
11
|
+
private clientId;
|
|
12
|
+
private entries;
|
|
13
|
+
constructor(endpoint: string, events: EventManager, store: Store, container: Container);
|
|
14
|
+
start(): Promise<MessageGroup[]>;
|
|
15
|
+
sendMessage(message: string): Promise<MessageGroup[]>;
|
|
16
|
+
helpAction(): Promise<MessageGroup[]>;
|
|
17
|
+
nextAction(group: MessageGroup): Promise<{
|
|
18
|
+
meta: {
|
|
19
|
+
[x: string]: any;
|
|
20
|
+
};
|
|
21
|
+
items: {
|
|
22
|
+
message: any[];
|
|
23
|
+
id: string;
|
|
24
|
+
groupId: string;
|
|
25
|
+
isUser: boolean;
|
|
26
|
+
}[];
|
|
27
|
+
id: string;
|
|
28
|
+
isUser: boolean;
|
|
29
|
+
writer?: any;
|
|
30
|
+
} | undefined>;
|
|
31
|
+
showContactMethodAction(data: {
|
|
32
|
+
contactMethod: any;
|
|
33
|
+
actionKey: string;
|
|
34
|
+
entryId: string;
|
|
35
|
+
}): Promise<MessageGroup[] | undefined>;
|
|
36
|
+
defaultAction(action: string): Promise<MessageGroup[] | undefined>;
|
|
37
|
+
private createInitialEnvelope;
|
|
38
|
+
private postEnvelope;
|
|
39
|
+
private handleResponse;
|
|
40
|
+
private getHttpOptions;
|
|
41
|
+
private getEntryOfAction;
|
|
42
|
+
}
|
|
43
|
+
export default HttpClient;
|