@quidgest/chatbot 0.0.8 → 0.0.9
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/components/CBMessage.vue.d.ts +15 -2
- package/dist/components/ChatBot.vue.d.ts +17 -26
- package/dist/components/PulseDots.vue.d.ts +2 -0
- package/dist/index.js +6 -9
- package/dist/index.mjs +1307 -1258
- package/dist/style.css +1 -1
- package/dist/types/chatbot.type.d.ts +13 -0
- package/dist/types/message.type.d.ts +2 -1
- package/package.json +2 -2
- package/src/assets/styles/styles.scss +43 -13
- package/src/assets/user_avatar.png +0 -0
- package/src/components/CBMessage.vue +51 -42
- package/src/components/ChatBot.vue +333 -336
- package/src/components/PulseDots.vue +16 -0
- package/src/types/chatbot.type.ts +14 -0
- package/src/types/message.type.ts +3 -1
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.q-chatbot{width:100%;padding:1rem;display:flex;flex-direction:column;height:100%}.q-chatbot input{line-height:1.5rem}.q-chatbot .q-input-group .i-text__field{border-radius:0;flex:1}.q-chatbot__content{background-color:#fff;border:1px solid #eaebec;height:100%;width:100%;display:flex;gap:.75rem;flex-direction:column;overflow:hidden}.q-chatbot__footer-container{padding:.8rem}.q-chatbot__send-container{padding-bottom:.25rem;display:flex;justify-content:flex-end}.q-chatbot__send-container .q-chatbot__send{border-radius:1rem}.q-chatbot__footer{position:sticky;padding:0 .5rem;border:1px solid #eaebec;border-radius:.25rem;bottom:0;width:100%;display:flex;flex-direction:column;gap:.25rem}.q-chatbot__footer .q-chatbot__input{min-height:50px;max-height:100px;border-bottom:1px solid #eaebec;overflow-y:auto}.q-chatbot__footer .q-text-area{max-height:100%;overflow-y:auto}.q-chatbot__footer .q-text-area .q-field__control{border:none}.q-chatbot__messages-container{display:flex;flex-direction:column;flex-grow:1;padding:0 1rem 2rem;gap:1.5rem;overflow-y:auto}.q-chatbot__messages-wrapper{display:flex;max-width:100%;gap:.2rem}.q-chatbot__tools{display:flex;flex-direction:row;justify-content:end;max-width:100%}.q-chatbot__message-wrapper{display:flex;flex-direction:column;gap:.2rem}.q-chatbot__message-container{display:flex;flex-direction:
|
|
1
|
+
.q-chatbot{width:100%;padding:1rem;display:flex;flex-direction:column;height:100%}.q-chatbot input{line-height:1.5rem}.q-chatbot .q-input-group .i-text__field{border-radius:0;flex:1}.q-chatbot__content{background-color:#fff;border:1px solid #eaebec;height:100%;width:100%;display:flex;gap:.75rem;flex-direction:column;overflow:hidden}.q-chatbot__footer-container{padding:.8rem}.q-chatbot__send-container{padding-bottom:.25rem;display:flex;justify-content:flex-end}.q-chatbot__send-container .q-chatbot__send{border-radius:1rem}.q-chatbot__footer{position:sticky;padding:0 .5rem;border:1px solid #eaebec;border-radius:.25rem;bottom:0;width:100%;display:flex;flex-direction:column;gap:.25rem}.q-chatbot__footer-disabled{background-color:rgb(var(--q-theme-neutral-light-rgb)/.25);cursor:not-allowed}.q-chatbot__footer .q-chatbot__input{min-height:50px;max-height:100px;border-bottom:1px solid #eaebec;overflow-y:auto}.q-chatbot__footer .q-text-area{max-height:100%;overflow-y:auto}.q-chatbot__footer .q-text-area .q-field__control{border:none}.q-chatbot__messages-container{display:flex;flex-direction:column;flex-grow:1;padding:0 1rem 2rem;gap:1.5rem;overflow-y:auto}.q-chatbot__messages-wrapper{display:flex;max-width:100%;gap:.2rem}.q-chatbot__tools{display:flex;flex-direction:row;justify-content:end;max-width:100%}.q-chatbot__message-wrapper{display:flex;flex-direction:column;gap:.2rem}.q-chatbot__message-container{display:flex;flex-direction:column;gap:.25rem}.q-chatbot__messages-wrapper_right{justify-content:flex-end}.q-chatbot__messages-wrapper_right .q-chatbot__message-container{align-items:flex-end}.q-chatbot__messages-wrapper_right .q-chatbot__message-wrapper{display:flex;align-items:flex-end}.q-chatbot__profile.q-icon__img{border-radius:50%;height:2rem;width:2rem}.q-chatbot__message{display:flex;align-items:center;padding:.3rem .5rem;background-color:#eaebec;width:fit-content;white-space:normal;min-height:2rem;word-wrap:break-word;word-break:break-word;border-radius:0 .5rem .5rem}.q-chatbot__messages-wrapper_right .q-chatbot__message{background-color:#018bd233;border-radius:.5rem 0 .5rem .5rem}.q-chatbot__sender{white-space:nowrap;color:#7c858d;font-size:.7rem}.pulsing-dots{display:flex;align-items:center;justify-content:center;gap:.1rem}.dot{font-size:20px;line-height:1;animation:pulse 1s infinite;color:var(--q-theme-primary)}@keyframes pulse{0%,to{transform:scale(.8);opacity:.6}50%{transform:scale(1);opacity:1}}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ResourceStrings } from './texts.type';
|
|
2
|
+
|
|
3
|
+
export type ChatBotProps = {
|
|
4
|
+
apiEndpoint?: string;
|
|
5
|
+
texts?: ResourceStrings;
|
|
6
|
+
username: string;
|
|
7
|
+
projectPath: string;
|
|
8
|
+
userImage?: string;
|
|
9
|
+
chatbotImage?: string;
|
|
10
|
+
dateFormat?: string;
|
|
11
|
+
mode?: ChatBotMode;
|
|
12
|
+
};
|
|
13
|
+
export type ChatBotMode = 'chat' | 'agent';
|
|
@@ -2,9 +2,10 @@ export type ChatBotMessage = {
|
|
|
2
2
|
id: number;
|
|
3
3
|
message: string;
|
|
4
4
|
date: Date;
|
|
5
|
-
sender:
|
|
5
|
+
sender: ChatBotMessageSender;
|
|
6
6
|
};
|
|
7
7
|
export type ChatBotMessageContent = {
|
|
8
8
|
content: string;
|
|
9
9
|
type: string;
|
|
10
10
|
};
|
|
11
|
+
export type ChatBotMessageSender = 'bot' | 'user';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quidgest/chatbot",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"main": "dist/index.cjs",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"vue-tsc": "^1.8.25"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@quidgest/ui": "^0.14.
|
|
51
|
+
"@quidgest/ui": "^0.14.19",
|
|
52
52
|
"vue": "3.5.13"
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -52,6 +52,11 @@
|
|
|
52
52
|
display: flex;
|
|
53
53
|
flex-direction: column;
|
|
54
54
|
gap: .25rem;
|
|
55
|
+
|
|
56
|
+
&-disabled {
|
|
57
|
+
background-color: rgb(var(--q-theme-neutral-light-rgb) / 0.25);
|
|
58
|
+
cursor: not-allowed;
|
|
59
|
+
}
|
|
55
60
|
|
|
56
61
|
& .q-chatbot__input {
|
|
57
62
|
min-height: 50px;
|
|
@@ -103,33 +108,45 @@
|
|
|
103
108
|
|
|
104
109
|
&__message-container {
|
|
105
110
|
display: flex;
|
|
106
|
-
flex-direction:
|
|
107
|
-
|
|
108
|
-
gap: 0.5rem;
|
|
111
|
+
flex-direction: column;
|
|
112
|
+
gap: 0.25rem;
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
&__messages-wrapper_right {
|
|
112
116
|
justify-content: flex-end;
|
|
117
|
+
|
|
118
|
+
.q-chatbot__message-container {
|
|
119
|
+
align-items: flex-end;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.q-chatbot__message-wrapper {
|
|
123
|
+
display: flex;
|
|
124
|
+
align-items: flex-end;
|
|
125
|
+
}
|
|
113
126
|
}
|
|
114
127
|
|
|
115
|
-
&__profile {
|
|
128
|
+
&__profile.q-icon__img {
|
|
116
129
|
border-radius: 50%;
|
|
117
130
|
height: 2rem;
|
|
118
131
|
width: 2rem;
|
|
119
132
|
}
|
|
120
133
|
|
|
121
134
|
&__message {
|
|
122
|
-
min-width: 4rem;
|
|
123
135
|
display: flex;
|
|
124
136
|
align-items: center;
|
|
125
137
|
padding: 0.3rem 0.5rem;
|
|
126
138
|
background-color: #eaebec;
|
|
139
|
+
width: fit-content;
|
|
127
140
|
white-space: normal;
|
|
128
141
|
min-height: 2rem;
|
|
142
|
+
word-wrap: break-word;
|
|
143
|
+
word-break: break-word;
|
|
144
|
+
border-radius: 0 0.5rem 0.5rem .5rem;
|
|
129
145
|
}
|
|
130
146
|
|
|
131
147
|
&__messages-wrapper_right .q-chatbot__message {
|
|
132
148
|
background-color: rgba(#018bd2, 20%);
|
|
149
|
+
border-radius: 0.5rem 0 0.5rem .5rem;
|
|
133
150
|
}
|
|
134
151
|
|
|
135
152
|
&__sender {
|
|
@@ -139,14 +156,27 @@
|
|
|
139
156
|
}
|
|
140
157
|
}
|
|
141
158
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
159
|
+
.pulsing-dots {
|
|
160
|
+
display: flex;
|
|
161
|
+
align-items: center;
|
|
162
|
+
justify-content: center;
|
|
163
|
+
gap: 0.1rem;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.dot {
|
|
167
|
+
font-size: 20px;
|
|
168
|
+
line-height: 1;
|
|
169
|
+
animation: pulse 1s infinite;
|
|
170
|
+
color: var(--q-theme-primary);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@keyframes pulse {
|
|
174
|
+
0%, 100% {
|
|
175
|
+
transform: scale(0.8);
|
|
176
|
+
opacity: 0.6;
|
|
145
177
|
}
|
|
146
178
|
50% {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
100% {
|
|
150
|
-
opacity: 0.5;
|
|
179
|
+
transform: scale(1);
|
|
180
|
+
opacity: 1;
|
|
151
181
|
}
|
|
152
|
-
}
|
|
182
|
+
}
|
|
Binary file
|
|
@@ -1,13 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="q-chatbot__message-container">
|
|
3
|
+
<!-- Chatbot Image -->
|
|
4
|
+
<q-icon
|
|
5
|
+
type="img"
|
|
6
|
+
:icon="messageImage"
|
|
7
|
+
alt="Sender Image"
|
|
8
|
+
class="q-chatbot__profile" />
|
|
9
|
+
|
|
10
|
+
<div class="q-chatbot__message-wrapper">
|
|
11
|
+
<!-- Message body -->
|
|
12
|
+
<div class="q-chatbot__message">
|
|
13
|
+
<!-- When loading is true, show bouncing dots animation -->
|
|
14
|
+
<pulse-dots v-if="loading"/>
|
|
15
|
+
<template v-else>
|
|
16
|
+
<div
|
|
17
|
+
class="q-chatbot__text"
|
|
18
|
+
v-if="props.sender === 'bot'"
|
|
19
|
+
v-html="props.message"></div>
|
|
20
|
+
<div class="q-chatbot__text" v-else>
|
|
21
|
+
{{ props.message }}
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
</div>
|
|
25
|
+
<div
|
|
26
|
+
class="q-chatbot__sender">
|
|
27
|
+
{{ messageDate }}
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
1
33
|
<script setup lang="ts">
|
|
2
34
|
import { computed } from 'vue'
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
35
|
+
import { QIcon } from '@quidgest/ui/components'
|
|
36
|
+
import PulseDots from '@/components/PulseDots.vue'
|
|
37
|
+
import type { ChatBotMessageSender } from '@/types/message.type'
|
|
6
38
|
export interface CBMessageProps {
|
|
7
39
|
/*
|
|
8
40
|
* Sender of the message
|
|
9
41
|
*/
|
|
10
|
-
sender?:
|
|
42
|
+
sender?: ChatBotMessageSender
|
|
11
43
|
|
|
12
44
|
/*
|
|
13
45
|
* Message to be displayed
|
|
@@ -27,11 +59,22 @@
|
|
|
27
59
|
/**
|
|
28
60
|
* Project locale
|
|
29
61
|
*/
|
|
30
|
-
dateFormat?: string
|
|
62
|
+
dateFormat?: string,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* User image
|
|
66
|
+
*/
|
|
67
|
+
userImage: string
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Chatbot image
|
|
71
|
+
*/
|
|
72
|
+
chatbotImage: string
|
|
31
73
|
}
|
|
32
74
|
|
|
33
75
|
const props = withDefaults(defineProps<CBMessageProps>(), {
|
|
34
76
|
sender: 'user',
|
|
77
|
+
userImage: undefined,
|
|
35
78
|
date: () => new Date()
|
|
36
79
|
})
|
|
37
80
|
|
|
@@ -45,10 +88,12 @@
|
|
|
45
88
|
return formatDate(props.date, props.dateFormat)
|
|
46
89
|
})
|
|
47
90
|
|
|
48
|
-
const
|
|
91
|
+
const messageDate = computed(() => {
|
|
49
92
|
return `${senderName.value} ${getLocaleDate.value}`
|
|
50
93
|
})
|
|
51
94
|
|
|
95
|
+
const messageImage = computed(() => props.sender === 'bot' ? props.chatbotImage : props.userImage);
|
|
96
|
+
|
|
52
97
|
function formatDate(date: Date, format: string) {
|
|
53
98
|
const day = date.getDate().toString().padStart(2, '0')
|
|
54
99
|
const month = (date.getMonth() + 1).toString().padStart(2, '0')
|
|
@@ -66,39 +111,3 @@
|
|
|
66
111
|
.replace('ss', seconds)
|
|
67
112
|
}
|
|
68
113
|
</script>
|
|
69
|
-
|
|
70
|
-
<template>
|
|
71
|
-
<div class="q-chatbot__message-container">
|
|
72
|
-
<!-- Chatbot Image -->
|
|
73
|
-
<img
|
|
74
|
-
v-if="props.sender === 'bot'"
|
|
75
|
-
:src="ChatBotIcon"
|
|
76
|
-
alt="Chatbot"
|
|
77
|
-
class="q-chatbot__profile" />
|
|
78
|
-
|
|
79
|
-
<div class="q-chatbot__message-wrapper">
|
|
80
|
-
<!-- Message header -->
|
|
81
|
-
<div
|
|
82
|
-
v-if="!loading"
|
|
83
|
-
class="q-chatbot__sender">
|
|
84
|
-
{{ messageHeader }}
|
|
85
|
-
</div>
|
|
86
|
-
|
|
87
|
-
<!-- Message body -->
|
|
88
|
-
<div class="q-chatbot__message">
|
|
89
|
-
<QLineLoader v-if="loading" />
|
|
90
|
-
<template v-else>
|
|
91
|
-
<div
|
|
92
|
-
class="q-chatbot__text"
|
|
93
|
-
v-if="props.sender == 'bot'"
|
|
94
|
-
v-html="props.message"></div>
|
|
95
|
-
<div
|
|
96
|
-
class="q-chatbot__text"
|
|
97
|
-
v-else>
|
|
98
|
-
{{ props.message }}
|
|
99
|
-
</div>
|
|
100
|
-
</template>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
</template>
|