@ibti-tech/chatbot 0.1.2 → 0.1.3
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/index.d.ts +2 -3
- package/dist/index.mjs +34 -67
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ declare module '@ibti-tech/chatbot/components/ChatbotDevice/styles' {
|
|
|
102
102
|
//# sourceMappingURL=styles.d.ts.map
|
|
103
103
|
}
|
|
104
104
|
declare module '@ibti-tech/chatbot/components/ChatbotDevice/styles.d.ts' {
|
|
105
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotDevice/styles.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,OAAO;aAAyB,OAAO;
|
|
105
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotDevice/styles.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,OAAO;aAAyB,OAAO;YAyBnD,CAAA"}
|
|
106
106
|
}
|
|
107
107
|
declare module '@ibti-tech/chatbot/components/ChatbotFooter/index' {
|
|
108
108
|
import React from 'react';
|
|
@@ -567,12 +567,11 @@ declare module '@ibti-tech/chatbot/services/chatbot-api' {
|
|
|
567
567
|
description?: string;
|
|
568
568
|
};
|
|
569
569
|
export const sendChatContext: ({ chatContext, locale, onReceiving, onDone, apiURL, onError, }: SendNewQuestionOptions) => Promise<void>;
|
|
570
|
-
export const getSuggestedQuestions: ({ chatContext, apiURL, locale, }: GetSuggestedQuestions) => Promise<string[]>;
|
|
571
570
|
export const sendUserChatFeedback: ({ apiURL, chatContext, locale, ratingScore, description, }: SendUserChatFeedbackParams) => Promise<Response>;
|
|
572
571
|
//# sourceMappingURL=chatbot-api.d.ts.map
|
|
573
572
|
}
|
|
574
573
|
declare module '@ibti-tech/chatbot/services/chatbot-api.d.ts' {
|
|
575
|
-
{"version":3,"file":"chatbot-api.d.ts","sourceRoot":"","sources":["../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/services/chatbot-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IACpE,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAEzC,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,eAAe,mEAOzB,sBAAsB,kBAsCnB,CAAA;
|
|
574
|
+
{"version":3,"file":"chatbot-api.d.ts","sourceRoot":"","sources":["../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/services/chatbot-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IACpE,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAEzC,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,eAAe,mEAOzB,sBAAsB,kBAsCnB,CAAA;AAyBN,eAAO,MAAM,oBAAoB,+DAM9B,0BAA0B,sBAYzB,CAAA"}
|
|
576
575
|
}
|
|
577
576
|
declare module '@ibti-tech/chatbot/themes/index' {
|
|
578
577
|
export const themes: {
|
package/dist/index.mjs
CHANGED
|
@@ -25,6 +25,39 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
25
25
|
|
|
26
26
|
// src/contexts/Chatbot/useChatbotSuggestedQuestions.ts
|
|
27
27
|
import { useState } from "react";
|
|
28
|
+
var useChatbotSuggestedQuestions = /* @__PURE__ */ __name(({
|
|
29
|
+
chatContext,
|
|
30
|
+
locale = "en",
|
|
31
|
+
apiURL
|
|
32
|
+
}) => {
|
|
33
|
+
const [loading, setLoading] = useState(false);
|
|
34
|
+
const [data, setData] = useState([]);
|
|
35
|
+
const fetchData = /* @__PURE__ */ __name(async () => {
|
|
36
|
+
if (chatContext.length === 0) return;
|
|
37
|
+
setLoading(true);
|
|
38
|
+
setLoading(false);
|
|
39
|
+
}, "fetchData");
|
|
40
|
+
const resetData = /* @__PURE__ */ __name(() => {
|
|
41
|
+
setData([]);
|
|
42
|
+
}, "resetData");
|
|
43
|
+
return {
|
|
44
|
+
loading,
|
|
45
|
+
data,
|
|
46
|
+
fetchData,
|
|
47
|
+
resetData
|
|
48
|
+
};
|
|
49
|
+
}, "useChatbotSuggestedQuestions");
|
|
50
|
+
|
|
51
|
+
// src/events/eventNames.ts
|
|
52
|
+
var CUSTOM_EVENT_NAMES = {
|
|
53
|
+
ASSISTANT_ANSWER_FINISHED: "ASSISTANT_ANSWER_FINISHED"
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/events/assistant-answer.ts
|
|
57
|
+
var dispatchAssitantAnswer = /* @__PURE__ */ __name(() => {
|
|
58
|
+
const evt = new CustomEvent(CUSTOM_EVENT_NAMES.ASSISTANT_ANSWER_FINISHED);
|
|
59
|
+
document.dispatchEvent(evt);
|
|
60
|
+
}, "dispatchAssitantAnswer");
|
|
28
61
|
|
|
29
62
|
// src/services/chatbot-api.ts
|
|
30
63
|
var sendChatContext = /* @__PURE__ */ __name(async ({
|
|
@@ -64,26 +97,6 @@ var sendChatContext = /* @__PURE__ */ __name(async ({
|
|
|
64
97
|
}).catch((err) => {
|
|
65
98
|
onError(err);
|
|
66
99
|
}), "sendChatContext");
|
|
67
|
-
var getSuggestedQuestions = /* @__PURE__ */ __name(async ({
|
|
68
|
-
chatContext,
|
|
69
|
-
apiURL,
|
|
70
|
-
locale = "en"
|
|
71
|
-
}) => {
|
|
72
|
-
const res = await fetch(
|
|
73
|
-
`${apiURL}/chat/suggested_questions?locale=${locale}`,
|
|
74
|
-
{
|
|
75
|
-
method: "POST",
|
|
76
|
-
headers: {
|
|
77
|
-
"Content-type": "application/json"
|
|
78
|
-
},
|
|
79
|
-
body: JSON.stringify({
|
|
80
|
-
context: chatContext
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
const data = await res.json();
|
|
85
|
-
return data;
|
|
86
|
-
}, "getSuggestedQuestions");
|
|
87
100
|
var sendUserChatFeedback = /* @__PURE__ */ __name(async ({
|
|
88
101
|
apiURL,
|
|
89
102
|
chatContext,
|
|
@@ -103,47 +116,6 @@ var sendUserChatFeedback = /* @__PURE__ */ __name(async ({
|
|
|
103
116
|
})
|
|
104
117
|
}), "sendUserChatFeedback");
|
|
105
118
|
|
|
106
|
-
// src/contexts/Chatbot/useChatbotSuggestedQuestions.ts
|
|
107
|
-
var useChatbotSuggestedQuestions = /* @__PURE__ */ __name(({
|
|
108
|
-
chatContext,
|
|
109
|
-
locale = "en",
|
|
110
|
-
apiURL
|
|
111
|
-
}) => {
|
|
112
|
-
const [loading, setLoading] = useState(false);
|
|
113
|
-
const [data, setData] = useState([]);
|
|
114
|
-
const fetchData = /* @__PURE__ */ __name(async () => {
|
|
115
|
-
if (chatContext.length === 0) return;
|
|
116
|
-
setLoading(true);
|
|
117
|
-
const suggestedData = await getSuggestedQuestions({
|
|
118
|
-
chatContext,
|
|
119
|
-
locale,
|
|
120
|
-
apiURL
|
|
121
|
-
});
|
|
122
|
-
setData(suggestedData);
|
|
123
|
-
setLoading(false);
|
|
124
|
-
}, "fetchData");
|
|
125
|
-
const resetData = /* @__PURE__ */ __name(() => {
|
|
126
|
-
setData([]);
|
|
127
|
-
}, "resetData");
|
|
128
|
-
return {
|
|
129
|
-
loading,
|
|
130
|
-
data,
|
|
131
|
-
fetchData,
|
|
132
|
-
resetData
|
|
133
|
-
};
|
|
134
|
-
}, "useChatbotSuggestedQuestions");
|
|
135
|
-
|
|
136
|
-
// src/events/eventNames.ts
|
|
137
|
-
var CUSTOM_EVENT_NAMES = {
|
|
138
|
-
ASSISTANT_ANSWER_FINISHED: "ASSISTANT_ANSWER_FINISHED"
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// src/events/assistant-answer.ts
|
|
142
|
-
var dispatchAssitantAnswer = /* @__PURE__ */ __name(() => {
|
|
143
|
-
const evt = new CustomEvent(CUSTOM_EVENT_NAMES.ASSISTANT_ANSWER_FINISHED);
|
|
144
|
-
document.dispatchEvent(evt);
|
|
145
|
-
}, "dispatchAssitantAnswer");
|
|
146
|
-
|
|
147
119
|
// src/contexts/Chatbot/useChatbotMessages.ts
|
|
148
120
|
var useChatbotMessages = /* @__PURE__ */ __name(({
|
|
149
121
|
apiURL,
|
|
@@ -322,15 +294,9 @@ import React13 from "react";
|
|
|
322
294
|
|
|
323
295
|
// src/components/ChatbotDevice/styles.ts
|
|
324
296
|
import { breakpoints, screens } from "@ibti-tech/ui";
|
|
325
|
-
import { mix } from "polished";
|
|
326
297
|
import { css, styled } from "styled-components";
|
|
327
298
|
var Wrapper = styled.div`
|
|
328
299
|
width: 100%;
|
|
329
|
-
/* background-color: ${(props) => mix(
|
|
330
|
-
0.05,
|
|
331
|
-
props.theme.colors.palette.primary.normal,
|
|
332
|
-
props.theme.colors.layers[0].background
|
|
333
|
-
)}; */
|
|
334
300
|
background-color: ${(props) => props.theme.colors.layers[1].background};
|
|
335
301
|
border: 1px solid ${(props) => props.theme.colors.layers[1].border};
|
|
336
302
|
display: flex;
|
|
@@ -341,6 +307,7 @@ var Wrapper = styled.div`
|
|
|
341
307
|
overflow: hidden;
|
|
342
308
|
pointer-events: all;
|
|
343
309
|
height: 100vh;
|
|
310
|
+
max-height: 100%;
|
|
344
311
|
position: relative;
|
|
345
312
|
|
|
346
313
|
${screens.tablet} {
|