@telia-ace/knowledge-widget-bot-provider 0.0.15-experimental.8 → 0.0.15
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/dist/contact-method-list.70f5e518.js +94 -0
- package/dist/contact-method-list.70f5e518.js.map +1 -0
- package/dist/contact-method.4b049dad.js +123 -0
- package/dist/contact-method.4b049dad.js.map +1 -0
- package/dist/feedback-list.73d8aa69.js +76 -0
- package/dist/feedback-list.73d8aa69.js.map +1 -0
- package/dist/index.a7a0d62d.js +787 -0
- package/dist/index.a7a0d62d.js.map +1 -0
- package/dist/index.js +6 -779
- package/dist/index.js.map +1 -1
- package/dist/no-good-alternative.e5e48f22.js +50 -0
- package/dist/no-good-alternative.e5e48f22.js.map +1 -0
- package/dist/notification-list.c3df3ee1.js +66 -0
- package/dist/notification-list.c3df3ee1.js.map +1 -0
- package/dist/styles.a00306c5.js +12 -0
- package/dist/styles.a00306c5.js.map +1 -0
- package/dist/ui/contact-method-list.d.ts +8 -1
- package/dist/ui/feedback-list.d.ts +6 -1
- package/dist/ui/no-good-alternative.d.ts +4 -1
- package/dist/ui/notification-list.d.ts +9 -1
- package/dist/utils.d.ts +2 -3
- package/package.json +10 -14
- package/dist/contact-method-list.2b3b6ea5.js +0 -5
- package/dist/contact-method-list.2b3b6ea5.js.map +0 -1
- package/dist/contact-method.016a8ec5.js +0 -5
- package/dist/contact-method.016a8ec5.js.map +0 -1
- package/dist/feedback-list.042775aa.js +0 -5
- package/dist/feedback-list.042775aa.js.map +0 -1
- package/dist/new-feedback-list.4dc450c7.js +0 -61
- package/dist/new-feedback-list.4dc450c7.js.map +0 -1
- package/dist/new-no-good-alternative.63439a76.js +0 -48
- package/dist/new-no-good-alternative.63439a76.js.map +0 -1
- package/dist/new-notification-list.17d34093.js +0 -24
- package/dist/new-notification-list.17d34093.js.map +0 -1
- package/dist/no-good-alternative.4e277f5b.js +0 -5
- package/dist/no-good-alternative.4e277f5b.js.map +0 -1
- package/dist/notification-list.399e34ff.js +0 -5
- package/dist/notification-list.399e34ff.js.map +0 -1
- package/dist/ui/new-feedback-list.d.ts +0 -13
- package/dist/ui/new-no-good-alternative.d.ts +0 -8
- package/dist/ui/new-notification-list.d.ts +0 -6
|
@@ -0,0 +1,94 @@
|
|
|
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 c from "@emotion/styled";
|
|
14
|
+
import { ContactList as b, ContactMethod as S } from "@telia-ace/knowledge-widget-adapters";
|
|
15
|
+
import { useDispatch as v, useContainer as z } from "@telia-ace/knowledge-widget-ui";
|
|
16
|
+
import s, { useState as L, useMemo as j } from "react";
|
|
17
|
+
import I from "./contact-method.4b049dad.js";
|
|
18
|
+
import "@telia-ace/knowledge-widget-types-grid";
|
|
19
|
+
import "@telia-ace/widget-forms";
|
|
20
|
+
import "./index.a7a0d62d.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(
|
|
40
|
+
K,
|
|
41
|
+
{
|
|
42
|
+
contactMethods: m,
|
|
43
|
+
dispatch: f,
|
|
44
|
+
itemRenderer: (o, l) => (r.includes(o.id) || o.expanded) && o.inline ? /* @__PURE__ */ s.createElement(
|
|
45
|
+
R,
|
|
46
|
+
{
|
|
47
|
+
contactMethodId: o.id,
|
|
48
|
+
groupId: n,
|
|
49
|
+
guideId: o.body.guideId
|
|
50
|
+
}
|
|
51
|
+
) : /* @__PURE__ */ s.createElement(k, d(d({}, o), l))
|
|
52
|
+
}
|
|
53
|
+
) : null;
|
|
54
|
+
}, K = c(b)`
|
|
55
|
+
> ul > li {
|
|
56
|
+
a {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
outline-offset: -2px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&:not(:last-child) {
|
|
63
|
+
${(t) => t.theme.border && `border-bottom: ${t.theme.border};`}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`, R = c(I)`
|
|
67
|
+
i {
|
|
68
|
+
margin: 0 ${(t) => {
|
|
69
|
+
var e;
|
|
70
|
+
return (e = t.theme.sizes) == null ? void 0 : e.medium;
|
|
71
|
+
}} 0 0;
|
|
72
|
+
display: flex;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
align-items: center;
|
|
75
|
+
}
|
|
76
|
+
`, k = c(S)`
|
|
77
|
+
padding: ${(t) => {
|
|
78
|
+
var e;
|
|
79
|
+
return (e = t.theme.sizes) == null ? void 0 : e.medium;
|
|
80
|
+
}};
|
|
81
|
+
i {
|
|
82
|
+
margin: 0 ${(t) => {
|
|
83
|
+
var e;
|
|
84
|
+
return (e = t.theme.sizes) == null ? void 0 : e.medium;
|
|
85
|
+
}} 0 0;
|
|
86
|
+
display: flex;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
align-items: center;
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
export {
|
|
92
|
+
P as default
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=contact-method-list.70f5e518.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-method-list.70f5e518.js","sources":["../src/ui/contact-method-list.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport {\n ContactList,\n ContactMethod as GenericContactMethod,\n} from '@telia-ace/knowledge-widget-adapters';\nimport { useContainer, useDispatch } from '@telia-ace/knowledge-widget-ui';\nimport React, { useMemo, useState } from 'react';\nimport { ActionItem } from '../types';\nimport ContactMethod from './contact-method';\n\ntype Props = {\n actions: ActionItem[];\n contactMethodIds?: string[];\n entryId: string;\n groupId: string;\n};\nconst ContactMethodList: React.FC<Props> = ({ actions, entryId, groupId }) => {\n const dispatch = useDispatch();\n const container = useContainer();\n const [expanded, setExpanded] = useState<string[]>([]);\n\n const items = useMemo<any[]>(() => {\n return actions.map((action) => {\n return {\n ...action.data,\n onClick: (_event: any, data: any) => {\n if (data.inline && !data.expanded) {\n setExpanded([...expanded, data.id]);\n } else {\n const { events } = container.get('$widget');\n events.dispatch('provider:open-contact-method', {\n entryId,\n contactMethod: data,\n actionKey: action.actionKey,\n });\n }\n },\n };\n });\n }, [actions, container, entryId, expanded]);\n\n if (!items.length) {\n return null;\n }\n\n return (\n <StyledContactList\n contactMethods={items}\n dispatch={dispatch}\n itemRenderer={(cm: any, props: any) => {\n const isExpanded = expanded.includes(cm.id) || cm.expanded;\n if (isExpanded && cm.inline) {\n return (\n <StyledContactMethod\n contactMethodId={cm.id}\n groupId={groupId}\n guideId={cm.body.guideId}\n />\n );\n }\n return <StyledGenericContactMethod {...cm} {...props} />;\n }}\n />\n );\n};\n\nexport default ContactMethodList;\n\nconst StyledContactList = styled(ContactList)`\n > ul > li {\n a {\n display: flex;\n align-items: center;\n outline-offset: -2px;\n }\n\n &:not(:last-child) {\n ${(p) => p.theme.border && `border-bottom: ${p.theme.border};`}\n }\n }\n`;\n\nconst StyledContactMethod = styled(ContactMethod)`\n i {\n margin: 0 ${(p) => p.theme.sizes?.medium} 0 0;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n`;\nconst StyledGenericContactMethod = styled(GenericContactMethod)`\n padding: ${(p) => p.theme.sizes?.medium};\n i {\n margin: 0 ${(p) => p.theme.sizes?.medium} 0 0;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n`;\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,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escriptors;
|
|
3
|
+
var $ = Object.getOwnPropertySymbols;
|
|
4
|
+
var T = Object.prototype.hasOwnProperty, _ = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var A = (e, t, o) => t in e ? z(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o, a = (e, t) => {
|
|
6
|
+
for (var o in t || (t = {}))
|
|
7
|
+
T.call(t, o) && A(e, o, t[o]);
|
|
8
|
+
if ($)
|
|
9
|
+
for (var o of $(t))
|
|
10
|
+
_.call(t, o) && A(e, o, t[o]);
|
|
11
|
+
return e;
|
|
12
|
+
}, m = (e, t) => B(e, D(t));
|
|
13
|
+
var y = (e, t, o) => new Promise((h, r) => {
|
|
14
|
+
var i = (n) => {
|
|
15
|
+
try {
|
|
16
|
+
l(o.next(n));
|
|
17
|
+
} catch (u) {
|
|
18
|
+
r(u);
|
|
19
|
+
}
|
|
20
|
+
}, d = (n) => {
|
|
21
|
+
try {
|
|
22
|
+
l(o.throw(n));
|
|
23
|
+
} catch (u) {
|
|
24
|
+
r(u);
|
|
25
|
+
}
|
|
26
|
+
}, l = (n) => n.done ? h(n.value) : Promise.resolve(n.value).then(i, d);
|
|
27
|
+
l((o = o.apply(e, t)).next());
|
|
28
|
+
});
|
|
29
|
+
import k from "@emotion/styled";
|
|
30
|
+
import { ContactMethod as G } from "@telia-ace/knowledge-widget-adapters";
|
|
31
|
+
import { DataType as V } from "@telia-ace/knowledge-widget-types-grid";
|
|
32
|
+
import { useContainer as j, useDispatch as q, useConversation as H } from "@telia-ace/knowledge-widget-ui";
|
|
33
|
+
import { FormBuilder as J } from "@telia-ace/widget-forms";
|
|
34
|
+
import K, { useState as L, useRef as N, useEffect as F, useCallback as O } from "react";
|
|
35
|
+
import { u as R } from "./index.a7a0d62d.js";
|
|
36
|
+
import "@telia-ace/widget-conversation";
|
|
37
|
+
import "@telia-ace/widget-services";
|
|
38
|
+
import "@telia-ace/widget-utilities";
|
|
39
|
+
const st = ({ contactMethodId: e, guideId: t, groupId: o, className: h }) => {
|
|
40
|
+
const [r, i] = L(), d = j(), l = q(), n = N(!0), u = H();
|
|
41
|
+
F(() => {
|
|
42
|
+
const { events: p } = d.get("$widget"), g = p.subscribe("bot-provider:form-submitted", (C, c) => y(void 0, null, function* () {
|
|
43
|
+
var E;
|
|
44
|
+
if (((E = c.form.meta) == null ? void 0 : E.groupId) !== o || c.id !== r.id)
|
|
45
|
+
return;
|
|
46
|
+
u && (c.form.meta || (c.form.meta = {}), c.form.meta.conversation = u);
|
|
47
|
+
const v = yield d.getAsync("contactMethods"), s = m(a({}, r), {
|
|
48
|
+
body: m(a({}, r.body), {
|
|
49
|
+
form: c.form
|
|
50
|
+
})
|
|
51
|
+
}), { errors: b, valid: M, errorTypes: Q } = yield v.validate(s);
|
|
52
|
+
if (!M) {
|
|
53
|
+
const S = new J(r.body.form);
|
|
54
|
+
i(void 0), S.setValidationErrors(b), s.body = m(a({}, s.body), {
|
|
55
|
+
form: S.get()
|
|
56
|
+
}), i(a({}, s));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const x = yield v.submit(s);
|
|
60
|
+
s.confirmation = x, i(s);
|
|
61
|
+
})), f = p.subscribe("bot-provider:evaluate", (C, c) => y(void 0, null, function* () {
|
|
62
|
+
if (c.id != e)
|
|
63
|
+
return;
|
|
64
|
+
const s = yield (yield d.getAsync("contactMethods")).evaluate(r);
|
|
65
|
+
let b = m(a({}, r), {
|
|
66
|
+
body: m(a({}, r.body), {
|
|
67
|
+
form: s
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
const M = R(b, {
|
|
71
|
+
submit: "Submit",
|
|
72
|
+
errors: {},
|
|
73
|
+
meta: { groupId: o }
|
|
74
|
+
});
|
|
75
|
+
b = m(a({}, b), {
|
|
76
|
+
body: M
|
|
77
|
+
}), i(b);
|
|
78
|
+
}));
|
|
79
|
+
return () => {
|
|
80
|
+
g(), f();
|
|
81
|
+
};
|
|
82
|
+
}, [d, r, i, u]);
|
|
83
|
+
const w = O(
|
|
84
|
+
(p) => y(void 0, null, function* () {
|
|
85
|
+
const f = yield (yield d.getAsync("dataClient")).fetch(V.ContactMethod, {
|
|
86
|
+
contactMethodId: p,
|
|
87
|
+
guideId: t
|
|
88
|
+
}), C = R(f, {
|
|
89
|
+
submit: "Submit",
|
|
90
|
+
errors: {},
|
|
91
|
+
meta: { groupId: o }
|
|
92
|
+
});
|
|
93
|
+
if (f.body = C, f.body.guideId = t, !n.current)
|
|
94
|
+
return null;
|
|
95
|
+
i(f);
|
|
96
|
+
}),
|
|
97
|
+
[n]
|
|
98
|
+
);
|
|
99
|
+
return F(() => (w(e), () => {
|
|
100
|
+
n.current = !1;
|
|
101
|
+
}), [e, w]), r ? /* @__PURE__ */ K.createElement(
|
|
102
|
+
P,
|
|
103
|
+
m(a({}, r), {
|
|
104
|
+
body: r.body,
|
|
105
|
+
inline: !0,
|
|
106
|
+
expanded: !0,
|
|
107
|
+
dispatch: l,
|
|
108
|
+
className: h
|
|
109
|
+
})
|
|
110
|
+
) : null;
|
|
111
|
+
}, P = k(G)`
|
|
112
|
+
padding: ${(e) => {
|
|
113
|
+
var t;
|
|
114
|
+
return (t = e.theme.sizes) == null ? void 0 : t.normal;
|
|
115
|
+
}} ${(e) => {
|
|
116
|
+
var t;
|
|
117
|
+
return (t = e.theme.sizes) == null ? void 0 : t.medium;
|
|
118
|
+
}};
|
|
119
|
+
`;
|
|
120
|
+
export {
|
|
121
|
+
st as default
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=contact-method.4b049dad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-method.4b049dad.js","sources":["../src/ui/contact-method.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport {\n ContactMethod as GenericContactMethod,\n ContactMethodPlatform,\n} from '@telia-ace/knowledge-widget-adapters';\nimport { DataType } from '@telia-ace/knowledge-widget-types-grid';\nimport { useContainer, useConversation, useDispatch } from '@telia-ace/knowledge-widget-ui';\nimport { FormBuilder } from '@telia-ace/widget-forms';\nimport { Widget } from '@webprovisions/platform';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { updateForm } from '../utils';\n\ntype Props = {\n contactMethodId: string;\n groupId: string;\n guideId?: string;\n className?: string;\n};\nconst ContactMethod: React.FC<Props> = ({ contactMethodId, guideId, groupId, className }) => {\n const [contactMethod, setContactMethod] = useState<any>();\n const container = useContainer();\n const dispatch = useDispatch();\n const mountedRef = useRef<boolean>(true);\n const currentConversation = useConversation();\n\n useEffect(() => {\n const { events } = container.get('$widget') as Widget;\n\n const unsubscribe = events.subscribe('bot-provider:form-submitted', async (_, data) => {\n // making sure that this is the form that is submitted\n if (data.form.meta?.groupId !== groupId || data.id !== contactMethod.id) {\n return;\n }\n\n if (currentConversation) {\n if (!data.form.meta) {\n data.form.meta = {};\n }\n\n data.form.meta.conversation = currentConversation;\n }\n\n const platform = (await container.getAsync('contactMethods')) as ContactMethodPlatform;\n\n const updatedMethod = {\n ...contactMethod,\n body: {\n ...contactMethod.body,\n form: data.form,\n },\n };\n\n const { errors, valid, errorTypes } = await platform.validate(updatedMethod);\n\n if (!valid) {\n const builder = new FormBuilder(contactMethod.body.form);\n setContactMethod(undefined);\n\n builder.setValidationErrors(errors);\n\n updatedMethod.body = {\n ...updatedMethod.body,\n form: builder.get(),\n };\n\n setContactMethod({ ...updatedMethod });\n return;\n }\n\n const result = await platform.submit(updatedMethod);\n\n updatedMethod.confirmation = result;\n setContactMethod(updatedMethod);\n });\n\n const unsubscribeEvaluate = events.subscribe('bot-provider:evaluate', async (_, data) => {\n if (data.id != contactMethodId) {\n return;\n }\n\n const platform = (await container.getAsync('contactMethods')) as ContactMethodPlatform;\n\n const updatedForm = await platform.evaluate(contactMethod);\n\n let updatedMethod = {\n ...contactMethod,\n body: {\n ...contactMethod.body,\n form: updatedForm,\n },\n };\n\n const updatedBody = updateForm(updatedMethod, {\n submit: 'Submit',\n errors: {},\n meta: { groupId },\n });\n\n updatedMethod = {\n ...updatedMethod,\n body: updatedBody,\n };\n\n setContactMethod(updatedMethod);\n });\n\n return () => {\n unsubscribe();\n unsubscribeEvaluate();\n };\n }, [container, contactMethod, setContactMethod, currentConversation]);\n\n const fetchContactMethod = useCallback(\n async (id: string) => {\n const dataClient = await container.getAsync('dataClient');\n\n const cm = await dataClient.fetch(DataType.ContactMethod, {\n contactMethodId: id,\n guideId,\n });\n\n const body = updateForm(cm, {\n submit: 'Submit',\n errors: {},\n meta: { groupId },\n });\n cm.body = body;\n cm.body.guideId = guideId;\n\n if (!mountedRef.current) {\n return null;\n }\n setContactMethod(cm);\n },\n [mountedRef]\n );\n\n useEffect(() => {\n fetchContactMethod(contactMethodId);\n return () => {\n mountedRef.current = false; // clean up\n };\n }, [contactMethodId, fetchContactMethod]);\n\n if (!contactMethod) {\n return null;\n }\n return (\n <StyledGenericContactMethod\n {...contactMethod}\n body={contactMethod.body}\n inline={true}\n expanded={true}\n dispatch={dispatch}\n className={className}\n />\n );\n};\n\nexport default ContactMethod;\n\nconst StyledGenericContactMethod = styled(GenericContactMethod)`\n padding: ${(p) => p.theme.sizes?.normal} ${(p) => p.theme.sizes?.medium};\n`;\n"],"names":["ContactMethod","contactMethodId","guideId","groupId","className","contactMethod","setContactMethod","useState","container","useContainer","dispatch","useDispatch","mountedRef","useRef","currentConversation","useConversation","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAMA,KAAiC,CAAC,EAAE,iBAAAC,GAAiB,SAAAC,GAAS,SAAAC,GAAS,WAAAC,QAAgB;AACzF,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAc,GAClDC,IAAYC,KACZC,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Q;AAAA,MACR,UAAU;AAAA,MACV,UAAAK;AAAA,MACA,WAAAN;AAAA,IAAA;AAAA,EAAA,IATG;AAYf,GAIMwC,IAA6BC,EAAOC,CAAoB;AAAA,eAC/C,CAACC,MAAM;;AAAA,UAAAzB,IAAAyB,EAAE,MAAM,UAAR,gBAAAzB,EAAe;AAAA,KAAU,CAACyB,MAAA;;AAAM,UAAAzB,IAAAyB,EAAE,MAAM,UAAR,gBAAAzB,EAAe;AAAA;AAAA;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import a from "@emotion/styled";
|
|
2
|
+
import { useDispatch as n, Icon as i, List as s, list as l, Button as c, buttonCss as m, invertedHoverButton as d } from "@telia-ace/knowledge-widget-ui";
|
|
3
|
+
import o from "react";
|
|
4
|
+
import { m as p } from "./styles.a00306c5.js";
|
|
5
|
+
import "@emotion/react";
|
|
6
|
+
const g = ({ actions: e }) => {
|
|
7
|
+
const t = n();
|
|
8
|
+
return /* @__PURE__ */ o.createElement(
|
|
9
|
+
f,
|
|
10
|
+
{
|
|
11
|
+
items: e,
|
|
12
|
+
"data-direction": "vertical",
|
|
13
|
+
renderItem: (r) => /* @__PURE__ */ o.createElement("li", { key: r.actionKey }, /* @__PURE__ */ o.createElement(
|
|
14
|
+
u,
|
|
15
|
+
{
|
|
16
|
+
className: "humany-feedback-button",
|
|
17
|
+
disabled: !1,
|
|
18
|
+
"aria-pressed": !0,
|
|
19
|
+
"data-selected": !0,
|
|
20
|
+
onClick: () => {
|
|
21
|
+
t("action", r.actionKey);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
/* @__PURE__ */ o.createElement(i, { faIcon: r.actionKey == "yes" ? "smile-o" : "frown-o" }),
|
|
25
|
+
/* @__PURE__ */ o.createElement("span", null, r.label)
|
|
26
|
+
))
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}, f = a(s)`
|
|
30
|
+
${(e) => l(e)}
|
|
31
|
+
${p}
|
|
32
|
+
display: flex;
|
|
33
|
+
gap: ${(e) => {
|
|
34
|
+
var t;
|
|
35
|
+
return (t = e.theme.sizes) == null ? void 0 : t.normal;
|
|
36
|
+
}};
|
|
37
|
+
flex-direction: ${(e) => e["data-direction"] === "horizontal" ? "row" : "column"};
|
|
38
|
+
> li {
|
|
39
|
+
flex: 1;
|
|
40
|
+
margin: 0;
|
|
41
|
+
}
|
|
42
|
+
`, u = a(c)`
|
|
43
|
+
${m}
|
|
44
|
+
font-size: ${(e) => {
|
|
45
|
+
var t;
|
|
46
|
+
return (t = e.theme.fonts) == null ? void 0 : t.normal;
|
|
47
|
+
}};
|
|
48
|
+
border-color: ${(e) => {
|
|
49
|
+
var t;
|
|
50
|
+
return (t = e.theme.colors) == null ? void 0 : t.primary;
|
|
51
|
+
}};
|
|
52
|
+
font-weight: 300;
|
|
53
|
+
display: block;
|
|
54
|
+
width: 100%;
|
|
55
|
+
|
|
56
|
+
${(e) => {
|
|
57
|
+
var t;
|
|
58
|
+
return d({
|
|
59
|
+
primaryColor: `${(t = e.theme.colors) == null ? void 0 : t.primary}`,
|
|
60
|
+
secondaryColor: "#FFFFFF",
|
|
61
|
+
theme: e.theme
|
|
62
|
+
});
|
|
63
|
+
}}
|
|
64
|
+
i {
|
|
65
|
+
margin: 0 ${(e) => {
|
|
66
|
+
var t;
|
|
67
|
+
return (t = e.theme.sizes) == null ? void 0 : t.small;
|
|
68
|
+
}} 0 0;
|
|
69
|
+
}
|
|
70
|
+
span {
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
export {
|
|
74
|
+
g as default
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=feedback-list.73d8aa69.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback-list.73d8aa69.js","sources":["../src/ui/feedback-list.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport {\n Button,\n buttonCss,\n Icon,\n invertedHoverButton,\n list,\n List,\n useDispatch,\n} from '@telia-ace/knowledge-widget-ui';\nimport React from 'react';\nimport { messageContentPadding } from './styles';\n\ntype Props = {\n actions: { [key: string]: string }[];\n};\nconst FeedbackList: React.FC<Props> = ({ actions }) => {\n const dispatch = useDispatch();\n return (\n <StyledButtonList\n items={actions}\n data-direction={'vertical'}\n renderItem={(item: any) => {\n return (\n <li key={item.actionKey}>\n <FeedbackButton\n className=\"humany-feedback-button\"\n disabled={false}\n aria-pressed={true}\n data-selected={true}\n onClick={() => {\n dispatch('action', item.actionKey);\n }}\n >\n <Icon faIcon={item.actionKey == 'yes' ? 'smile-o' : 'frown-o'} />\n <span>{item.label}</span>\n </FeedbackButton>\n </li>\n );\n }}\n />\n );\n};\n\nexport default FeedbackList;\n\nconst StyledButtonList = styled(List)<{ 'data-direction': 'horizontal' | 'vertical' } & any>`\n ${(p) => list(p)}\n ${messageContentPadding}\n display: flex;\n gap: ${(p) => p.theme.sizes?.normal};\n flex-direction: ${(p) => (p['data-direction'] === 'horizontal' ? 'row' : 'column')};\n > li {\n flex: 1;\n margin: 0;\n }\n`;\n\nconst FeedbackButton = styled(Button)<{\n 'data-selected': boolean;\n}>`\n ${buttonCss}\n font-size: ${(p) => p.theme.fonts?.normal};\n border-color: ${(p) => p.theme.colors?.primary};\n font-weight: 300;\n display: block;\n width: 100%;\n\n ${(p) =>\n invertedHoverButton({\n primaryColor: `${p.theme.colors?.primary}`,\n secondaryColor: '#FFFFFF',\n theme: p.theme,\n })}\n i {\n margin: 0 ${(p) => p.theme.sizes?.small} 0 0;\n }\n span {\n }\n`;\n"],"names":["FeedbackList","actions","dispatch","useDispatch","React","StyledButtonList","item","FeedbackButton","Icon","styled","List","p","list","messageContentPadding","_a","Button","buttonCss","invertedHoverButton"],"mappings":";;;;;AAgBA,MAAMA,IAAgC,CAAC,EAAE,SAAAC,QAAc;AACnD,QAAMC,IAAWC;AAEb,SAAA,gBAAAC,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,OAAOJ;AAAA,MACP,kBAAgB;AAAA,MAChB,Y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