@quidgest/chatbot 0.0.7 → 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/style.css CHANGED
@@ -1 +1 @@
1
- .q-chatbot{width:100%;height:100%;padding:1rem}.q-chatbot input{line-height:1.5rem}.q-chatbot .q-input-group .i-text__field{border-radius:0;flex:1}.q-chatbot__input{flex:1}.q-chatbot__content{background-color:#fff;border:1px solid #eaebec;height:100%;width:100%;display:flex;flex-direction:column;gap:.75rem}.q-chatbot__messages-container{display:flex;flex-direction:column;padding:0 1rem 2rem;gap:1.5rem;overflow: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:row;align-items:center;gap:.5rem}.q-chatbot__messages-wrapper_right{justify-content:flex-end}.q-chatbot__profile{border-radius:50%;height:2rem;width:2rem}.q-chatbot__message{min-width:4rem;display:flex;align-items:center;padding:.3rem .5rem;background-color:#eaebec;white-space:normal;min-height:2rem}.q-chatbot__messages-wrapper_right .q-chatbot__message{background-color:#018bd233}.q-chatbot__sender{white-space:nowrap;color:#7c858d;font-size:.7rem}@keyframes dotPulse{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}
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: 'bot' | 'user';
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.7",
4
+ "version": "0.0.9",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
7
7
  "main": "dist/index.cjs",
@@ -32,8 +32,7 @@
32
32
  "lint:fix": "eslint . --fix && prettier --write --list-different src"
33
33
  },
34
34
  "dependencies": {
35
- "axios": "^1.6.7",
36
- "vue": "^3.3.11"
35
+ "axios": "^1.6.7"
37
36
  },
38
37
  "devDependencies": {
39
38
  "@types/node": "^20.11.13",
@@ -49,6 +48,7 @@
49
48
  "vue-tsc": "^1.8.25"
50
49
  },
51
50
  "peerDependencies": {
52
- "@quidgest/ui": "^0.14.1"
51
+ "@quidgest/ui": "^0.14.19",
52
+ "vue": "3.5.13"
53
53
  }
54
54
  }
@@ -2,6 +2,9 @@
2
2
  width: 100%;
3
3
  height: 100%;
4
4
  padding: 1rem;
5
+ display: flex;
6
+ flex-direction: column;
7
+ height: 100%;
5
8
 
6
9
  input {
7
10
  line-height: 1.5rem;
@@ -12,10 +15,6 @@
12
15
  flex: 1;
13
16
  }
14
17
 
15
- &__input {
16
- flex: 1;
17
- }
18
-
19
18
  &__content {
20
19
  background-color: white;
21
20
  border: 1px solid #eaebec;
@@ -24,14 +23,64 @@
24
23
  display: flex;
25
24
  flex-direction: column;
26
25
  gap: 0.75rem;
26
+ flex-direction: column;
27
+ overflow: hidden;
27
28
  }
28
29
 
30
+
31
+ &__footer-container {
32
+ padding: 0.8rem;
33
+ }
34
+
35
+ &__send-container {
36
+ padding-bottom: .25rem;
37
+ display: flex;
38
+ justify-content: flex-end;
39
+
40
+ & .q-chatbot__send {
41
+ border-radius: 1rem;
42
+ }
43
+ }
44
+
45
+ &__footer {
46
+ position: sticky;
47
+ padding: 0 .5rem;
48
+ border: 1px solid #eaebec;
49
+ border-radius: .25rem;
50
+ bottom: 0;
51
+ width: 100%;
52
+ display: flex;
53
+ flex-direction: column;
54
+ gap: .25rem;
55
+
56
+ &-disabled {
57
+ background-color: rgb(var(--q-theme-neutral-light-rgb) / 0.25);
58
+ cursor: not-allowed;
59
+ }
60
+
61
+ & .q-chatbot__input {
62
+ min-height: 50px;
63
+ max-height: 100px;
64
+ border-bottom: 1px solid #eaebec;
65
+ overflow-y: auto;
66
+ }
67
+
68
+ & .q-text-area {
69
+ max-height: 100%;
70
+ overflow-y: auto;
71
+
72
+ & .q-field__control {
73
+ border: none;
74
+ }
75
+ }
76
+ }
29
77
  &__messages-container {
30
78
  display: flex;
31
79
  flex-direction: column;
80
+ flex-grow: 1;
32
81
  padding: 0 1rem 2rem 1rem;
33
82
  gap: 1.5rem;
34
- overflow: auto;
83
+ overflow-y: auto;
35
84
  }
36
85
 
37
86
  &__messages-wrapper {
@@ -59,33 +108,45 @@
59
108
 
60
109
  &__message-container {
61
110
  display: flex;
62
- flex-direction: row;
63
- align-items: center;
64
- gap: 0.5rem;
111
+ flex-direction: column;
112
+ gap: 0.25rem;
65
113
  }
66
114
 
67
115
  &__messages-wrapper_right {
68
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
+ }
69
126
  }
70
127
 
71
- &__profile {
128
+ &__profile.q-icon__img {
72
129
  border-radius: 50%;
73
130
  height: 2rem;
74
131
  width: 2rem;
75
132
  }
76
133
 
77
134
  &__message {
78
- min-width: 4rem;
79
135
  display: flex;
80
136
  align-items: center;
81
137
  padding: 0.3rem 0.5rem;
82
138
  background-color: #eaebec;
139
+ width: fit-content;
83
140
  white-space: normal;
84
141
  min-height: 2rem;
142
+ word-wrap: break-word;
143
+ word-break: break-word;
144
+ border-radius: 0 0.5rem 0.5rem .5rem;
85
145
  }
86
146
 
87
147
  &__messages-wrapper_right .q-chatbot__message {
88
148
  background-color: rgba(#018bd2, 20%);
149
+ border-radius: 0.5rem 0 0.5rem .5rem;
89
150
  }
90
151
 
91
152
  &__sender {
@@ -95,14 +156,27 @@
95
156
  }
96
157
  }
97
158
 
98
- @keyframes dotPulse {
99
- 0% {
100
- opacity: 0.5;
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;
101
177
  }
102
178
  50% {
103
- opacity: 1;
179
+ transform: scale(1);
180
+ opacity: 1;
104
181
  }
105
- 100% {
106
- opacity: 0.5;
107
- }
108
- }
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 ChatBotIcon from '@/assets/chatbot.png'
4
- import { QLineLoader } from '@quidgest/ui/components'
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?: 'bot' | 'user'
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 messageHeader = computed(() => {
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>