@n8n/chat 0.5.2 → 0.6.0
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/.eslintignore +2 -0
- package/.eslintrc.cjs +51 -0
- package/.np-config.json +5 -0
- package/.storybook/main.ts +27 -0
- package/.storybook/preview.scss +4 -0
- package/.storybook/preview.ts +16 -0
- package/.vscode/extensions.json +3 -0
- package/README.md +4 -21
- package/env.d.ts +1 -0
- package/index.html +13 -0
- package/package.json +2 -69
- package/resources/workflow.json +293 -0
- package/scripts/pack.js +11 -0
- package/scripts/postbuild.js +16 -0
- package/{App.vue → src/App.vue} +2 -2
- package/src/__stories__/App.stories.ts +43 -0
- package/src/__tests__/index.spec.ts +223 -0
- package/src/__tests__/utils/create.ts +16 -0
- package/src/__tests__/utils/fetch.ts +18 -0
- package/src/__tests__/utils/selectors.ts +53 -0
- package/src/api/generic.ts +64 -0
- package/src/api/message.ts +31 -0
- package/src/components/Button.vue +41 -0
- package/{components → src/components}/Chat.vue +15 -19
- package/src/components/ChatWindow.vue +125 -0
- package/src/components/GetStarted.vue +24 -0
- package/{components → src/components}/GetStartedFooter.vue +4 -4
- package/{components → src/components}/Input.vue +40 -35
- package/src/components/Layout.vue +82 -0
- package/src/components/Message.vue +97 -0
- package/src/components/MessageTyping.vue +109 -0
- package/{components → src/components}/MessagesList.vue +8 -8
- package/{components → src/components}/PoweredBy.vue +7 -6
- package/src/composables/useChat.ts +7 -0
- package/src/composables/useI18n.ts +16 -0
- package/src/composables/useOptions.ts +11 -0
- package/src/constants/defaults.ts +25 -0
- package/{constants/localStorage.mjs → src/constants/localStorage.ts} +1 -1
- package/src/constants/symbols.ts +8 -0
- package/src/event-buses/chatEventBus.ts +3 -0
- package/src/index.ts +42 -0
- package/src/main.scss +40 -0
- package/src/plugins/chat.ts +101 -0
- package/src/types/chat.ts +12 -0
- package/src/types/messages.ts +6 -0
- package/src/types/options.ts +23 -0
- package/src/types/webhook.ts +17 -0
- package/src/utils/event-bus.ts +51 -0
- package/src/utils/mount.ts +16 -0
- package/tsconfig.json +27 -0
- package/vite.config.ts +51 -0
- package/vitest.config.ts +20 -0
- package/__stories__/App.stories.d.ts +0 -16
- package/__stories__/App.stories.js +0 -38
- package/__stories__/App.stories.mjs +0 -32
- package/__tests__/index.spec.d.ts +0 -1
- package/__tests__/index.spec.js +0 -146
- package/__tests__/index.spec.mjs +0 -172
- package/__tests__/setup.js +0 -3
- package/__tests__/setup.mjs +0 -1
- package/__tests__/utils/create.d.ts +0 -5
- package/__tests__/utils/create.js +0 -16
- package/__tests__/utils/create.mjs +0 -10
- package/__tests__/utils/fetch.d.ts +0 -3
- package/__tests__/utils/fetch.js +0 -20
- package/__tests__/utils/fetch.mjs +0 -9
- package/__tests__/utils/index.js +0 -38
- package/__tests__/utils/index.mjs +0 -3
- package/__tests__/utils/selectors.d.ts +0 -12
- package/__tests__/utils/selectors.js +0 -58
- package/__tests__/utils/selectors.mjs +0 -41
- package/api/generic.d.ts +0 -6
- package/api/generic.js +0 -68
- package/api/generic.mjs +0 -54
- package/api/index.js +0 -27
- package/api/index.mjs +0 -2
- package/api/message.d.ts +0 -3
- package/api/message.js +0 -33
- package/api/message.mjs +0 -30
- package/chat.bundle.es.js +0 -10760
- package/chat.bundle.umd.js +0 -18
- package/components/Button.vue +0 -34
- package/components/ChatWindow.vue +0 -104
- package/components/GetStarted.vue +0 -24
- package/components/Layout.vue +0 -66
- package/components/Message.vue +0 -94
- package/components/MessageTyping.vue +0 -101
- package/components/index.js +0 -76
- package/components/index.mjs +0 -10
- package/composables/index.js +0 -38
- package/composables/index.mjs +0 -3
- package/composables/useChat.d.ts +0 -1
- package/composables/useChat.js +0 -11
- package/composables/useChat.mjs +0 -5
- package/composables/useI18n.d.ts +0 -4
- package/composables/useI18n.js +0 -23
- package/composables/useI18n.mjs +0 -12
- package/composables/useOptions.d.ts +0 -3
- package/composables/useOptions.js +0 -14
- package/composables/useOptions.mjs +0 -8
- package/constants/defaults.d.ts +0 -3
- package/constants/defaults.js +0 -32
- package/constants/defaults.mjs +0 -26
- package/constants/index.js +0 -38
- package/constants/index.mjs +0 -3
- package/constants/localStorage.d.ts +0 -2
- package/constants/localStorage.js +0 -8
- package/constants/symbols.d.ts +0 -3
- package/constants/symbols.js +0 -8
- package/constants/symbols.mjs +0 -2
- package/css/index.css +0 -31
- package/event-buses/chatEventBus.d.ts +0 -1
- package/event-buses/chatEventBus.js +0 -8
- package/event-buses/chatEventBus.mjs +0 -2
- package/event-buses/index.js +0 -16
- package/event-buses/index.mjs +0 -1
- package/index.d.ts +0 -3
- package/index.js +0 -43
- package/index.mjs +0 -36
- package/main.css +0 -151
- package/plugins/chat.d.ts +0 -3
- package/plugins/chat.js +0 -85
- package/plugins/chat.mjs +0 -83
- package/plugins/index.js +0 -16
- package/plugins/index.mjs +0 -1
- package/style.css +0 -1
- package/types/App.vue.d.ts +0 -8
- package/types/__stories__/App.stories.d.ts +0 -17
- package/types/__tests__/index.spec.d.ts +0 -1
- package/types/__tests__/setup.d.ts +0 -0
- package/types/__tests__/utils/create.d.ts +0 -5
- package/types/__tests__/utils/fetch.d.ts +0 -4
- package/types/__tests__/utils/index.d.ts +0 -3
- package/types/__tests__/utils/selectors.d.ts +0 -12
- package/types/api/generic.d.ts +0 -6
- package/types/api/index.d.ts +0 -2
- package/types/api/message.d.ts +0 -3
- package/types/chat.d.ts +0 -11
- package/types/chat.js +0 -1
- package/types/chat.mjs +0 -0
- package/types/components/Button.vue.d.ts +0 -9
- package/types/components/Chat.vue.d.ts +0 -2
- package/types/components/ChatWindow.vue.d.ts +0 -2
- package/types/components/GetStarted.vue.d.ts +0 -2
- package/types/components/GetStartedFooter.vue.d.ts +0 -2
- package/types/components/Input.vue.d.ts +0 -2
- package/types/components/Layout.vue.d.ts +0 -11
- package/types/components/Message.vue.d.ts +0 -21
- package/types/components/MessageTyping.vue.d.ts +0 -15
- package/types/components/MessagesList.vue.d.ts +0 -14
- package/types/components/PoweredBy.vue.d.ts +0 -2
- package/types/components/index.d.ts +0 -10
- package/types/composables/index.d.ts +0 -3
- package/types/composables/useChat.d.ts +0 -2
- package/types/composables/useI18n.d.ts +0 -4
- package/types/composables/useOptions.d.ts +0 -4
- package/types/constants/defaults.d.ts +0 -3
- package/types/constants/index.d.ts +0 -3
- package/types/constants/localStorage.d.ts +0 -2
- package/types/constants/symbols.d.ts +0 -4
- package/types/event-buses/chatEventBus.d.ts +0 -1
- package/types/event-buses/index.d.ts +0 -1
- package/types/index.js +0 -49
- package/types/index.mjs +0 -4
- package/types/messages.d.ts +0 -6
- package/types/messages.js +0 -1
- package/types/messages.mjs +0 -0
- package/types/options.d.ts +0 -25
- package/types/options.js +0 -1
- package/types/options.mjs +0 -0
- package/types/plugins/chat.d.ts +0 -3
- package/types/plugins/index.d.ts +0 -1
- package/types/src/App.vue.d.ts +0 -8
- package/types/src/__stories__/App.stories.d.ts +0 -17
- package/types/src/__tests__/index.spec.d.ts +0 -1
- package/types/src/__tests__/setup.d.ts +0 -0
- package/types/src/__tests__/utils/create.d.ts +0 -5
- package/types/src/__tests__/utils/fetch.d.ts +0 -4
- package/types/src/__tests__/utils/index.d.ts +0 -3
- package/types/src/__tests__/utils/selectors.d.ts +0 -12
- package/types/src/api/generic.d.ts +0 -6
- package/types/src/api/index.d.ts +0 -2
- package/types/src/api/message.d.ts +0 -3
- package/types/src/components/Button.vue.d.ts +0 -9
- package/types/src/components/Chat.vue.d.ts +0 -2
- package/types/src/components/ChatWindow.vue.d.ts +0 -2
- package/types/src/components/GetStarted.vue.d.ts +0 -2
- package/types/src/components/GetStartedFooter.vue.d.ts +0 -2
- package/types/src/components/Input.vue.d.ts +0 -2
- package/types/src/components/Layout.vue.d.ts +0 -11
- package/types/src/components/Message.vue.d.ts +0 -21
- package/types/src/components/MessageTyping.vue.d.ts +0 -15
- package/types/src/components/MessagesList.vue.d.ts +0 -14
- package/types/src/components/PoweredBy.vue.d.ts +0 -2
- package/types/src/components/index.d.ts +0 -10
- package/types/src/composables/index.d.ts +0 -3
- package/types/src/composables/useChat.d.ts +0 -2
- package/types/src/composables/useI18n.d.ts +0 -4
- package/types/src/composables/useOptions.d.ts +0 -4
- package/types/src/constants/defaults.d.ts +0 -3
- package/types/src/constants/index.d.ts +0 -3
- package/types/src/constants/localStorage.d.ts +0 -2
- package/types/src/constants/symbols.d.ts +0 -4
- package/types/src/event-buses/chatEventBus.d.ts +0 -1
- package/types/src/event-buses/index.d.ts +0 -1
- package/types/src/index.d.ts +0 -2
- package/types/src/plugins/chat.d.ts +0 -3
- package/types/src/plugins/index.d.ts +0 -1
- package/types/src/types/chat.d.ts +0 -11
- package/types/src/types/index.d.ts +0 -4
- package/types/src/types/messages.d.ts +0 -6
- package/types/src/types/options.d.ts +0 -25
- package/types/src/types/webhook.d.ts +0 -15
- package/types/src/utils/event-bus.d.ts +0 -8
- package/types/src/utils/mount.d.ts +0 -1
- package/types/types/chat.d.ts +0 -11
- package/types/types/index.d.ts +0 -4
- package/types/types/messages.d.ts +0 -6
- package/types/types/options.d.ts +0 -25
- package/types/types/webhook.d.ts +0 -15
- package/types/utils/event-bus.d.ts +0 -8
- package/types/utils/index.d.ts +0 -2
- package/types/utils/mount.d.ts +0 -1
- package/types/webhook.d.ts +0 -15
- package/types/webhook.js +0 -1
- package/types/webhook.mjs +0 -0
- package/utils/event-bus.d.ts +0 -8
- package/utils/event-bus.js +0 -38
- package/utils/event-bus.mjs +0 -32
- package/utils/index.d.ts +0 -2
- package/utils/index.js +0 -27
- package/utils/index.mjs +0 -2
- package/utils/mount.d.ts +0 -1
- package/utils/mount.js +0 -19
- package/utils/mount.mjs +0 -13
- /package/{favicon.ico → public/favicon.ico} +0 -0
- /package/{__tests__/setup.d.ts → src/__tests__/setup.ts} +0 -0
- /package/{__tests__/utils/index.d.ts → src/__tests__/utils/index.ts} +0 -0
- /package/{api/index.d.ts → src/api/index.ts} +0 -0
- /package/{components/index.d.ts → src/components/index.ts} +0 -0
- /package/{composables/index.d.ts → src/composables/index.ts} +0 -0
- /package/{constants/index.d.ts → src/constants/index.ts} +0 -0
- /package/{event-buses/index.d.ts → src/event-buses/index.ts} +0 -0
- /package/{plugins/index.d.ts → src/plugins/index.ts} +0 -0
- /package/{shims.d.ts → src/shims.d.ts} +0 -0
- /package/{types/index.d.ts → src/types/index.ts} +0 -0
- /package/{types/src/utils/index.d.ts → src/utils/index.ts} +0 -0
package/components/Button.vue
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<button class="chat-button">
|
|
3
|
-
<slot />
|
|
4
|
-
</button>
|
|
5
|
-
</template>
|
|
6
|
-
<style>
|
|
7
|
-
.chat-button {
|
|
8
|
-
display: inline-flex;
|
|
9
|
-
text-align: center;
|
|
10
|
-
vertical-align: middle;
|
|
11
|
-
user-select: none;
|
|
12
|
-
color: var(--chat--button--color, var(--chat--color-light));
|
|
13
|
-
background-color: var(--chat--button--background, var(--chat--color-primary));
|
|
14
|
-
border: 1px solid transparent;
|
|
15
|
-
padding: var(--chat--button--padding, calc(var(--chat--spacing) * 1 / 2) var(--chat--spacing));
|
|
16
|
-
font-size: 1rem;
|
|
17
|
-
line-height: 1.5;
|
|
18
|
-
border-radius: var(--chat--button--border-radius, var(--chat--border-radius));
|
|
19
|
-
transition: color var(--chat--transition-duration) ease-in-out, background-color var(--chat--transition-duration) ease-in-out, border-color var(--chat--transition-duration) ease-in-out, box-shadow var(--chat--transition-duration) ease-in-out;
|
|
20
|
-
cursor: pointer;
|
|
21
|
-
}
|
|
22
|
-
.chat-button:hover {
|
|
23
|
-
color: var(--chat--button--hover--color, var(--chat--color-light));
|
|
24
|
-
background-color: var(--chat--button--hover--background, var(--chat--color-primary-shade-50));
|
|
25
|
-
text-decoration: none;
|
|
26
|
-
}
|
|
27
|
-
.chat-button:focus {
|
|
28
|
-
outline: 0;
|
|
29
|
-
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
|
|
30
|
-
}
|
|
31
|
-
.chat-button:disabled {
|
|
32
|
-
opacity: 0.65;
|
|
33
|
-
}
|
|
34
|
-
</style>
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
// eslint-disable-next-line import/no-unresolved
|
|
3
|
-
import IconChat from 'virtual:icons/mdi/chat';
|
|
4
|
-
// eslint-disable-next-line import/no-unresolved
|
|
5
|
-
import IconChevronDown from 'virtual:icons/mdi/chevron-down';
|
|
6
|
-
import Chat from '@n8n/chat/components/Chat.vue';
|
|
7
|
-
import { nextTick, ref } from 'vue';
|
|
8
|
-
import { chatEventBus } from '@n8n/chat/event-buses';
|
|
9
|
-
|
|
10
|
-
const isOpen = ref(false);
|
|
11
|
-
|
|
12
|
-
function toggle() {
|
|
13
|
-
isOpen.value = !isOpen.value;
|
|
14
|
-
|
|
15
|
-
if (isOpen.value) {
|
|
16
|
-
void nextTick(() => {
|
|
17
|
-
chatEventBus.emit('scrollToBottom');
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<template>
|
|
24
|
-
<div class="chat-window-wrapper">
|
|
25
|
-
<Transition name="chat-window-transition">
|
|
26
|
-
<div class="chat-window" v-show="isOpen">
|
|
27
|
-
<Chat />
|
|
28
|
-
</div>
|
|
29
|
-
</Transition>
|
|
30
|
-
<div class="chat-window-toggle" @click="toggle">
|
|
31
|
-
<Transition name="chat-window-toggle-transition" mode="out-in">
|
|
32
|
-
<IconChat v-if="!isOpen" height="32" width="32" />
|
|
33
|
-
<IconChevronDown v-else height="32" width="32" />
|
|
34
|
-
</Transition>
|
|
35
|
-
</div>
|
|
36
|
-
</div>
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<style>
|
|
40
|
-
.chat-window-wrapper {
|
|
41
|
-
position: fixed;
|
|
42
|
-
display: flex;
|
|
43
|
-
flex-direction: column;
|
|
44
|
-
bottom: var(--chat--window--bottom, var(--chat--spacing));
|
|
45
|
-
right: var(--chat--window--right, var(--chat--spacing));
|
|
46
|
-
z-index: var(--chat--window--z-index, 9999);
|
|
47
|
-
max-width: calc(100% - var(--chat--window--right, var(--chat--spacing)) * 2);
|
|
48
|
-
max-height: calc(100% - var(--chat--window--bottom, var(--chat--spacing)) * 2);
|
|
49
|
-
}
|
|
50
|
-
.chat-window-wrapper .chat-window {
|
|
51
|
-
display: flex;
|
|
52
|
-
width: var(--chat--window--width);
|
|
53
|
-
height: var(--chat--window--height);
|
|
54
|
-
max-width: 100%;
|
|
55
|
-
max-height: 100%;
|
|
56
|
-
border: var(--chat--window--border, 1px solid var(--chat--color-light-shade-100));
|
|
57
|
-
border-radius: var(--chat--window--border-radius, var(--chat--border-radius));
|
|
58
|
-
margin-bottom: var(--chat--window--margin-bottom, var(--chat--spacing));
|
|
59
|
-
overflow: hidden;
|
|
60
|
-
transform-origin: bottom right;
|
|
61
|
-
}
|
|
62
|
-
.chat-window-wrapper .chat-window .chat-layout {
|
|
63
|
-
width: auto;
|
|
64
|
-
height: auto;
|
|
65
|
-
flex: 1;
|
|
66
|
-
}
|
|
67
|
-
.chat-window-wrapper .chat-window-toggle {
|
|
68
|
-
flex: 0 0 auto;
|
|
69
|
-
background: var(--chat--toggle--background);
|
|
70
|
-
color: var(--chat--toggle--color);
|
|
71
|
-
cursor: pointer;
|
|
72
|
-
width: var(--chat--toggle--width, var(--chat--toggle--size));
|
|
73
|
-
height: var(--chat--toggle--height, var(--chat--toggle--size));
|
|
74
|
-
border-radius: var(--chat--toggle--border-radius, 50%);
|
|
75
|
-
display: inline-flex;
|
|
76
|
-
align-items: center;
|
|
77
|
-
justify-content: center;
|
|
78
|
-
margin-left: auto;
|
|
79
|
-
transition: transform var(--chat--transition-duration) ease, background var(--chat--transition-duration) ease;
|
|
80
|
-
}
|
|
81
|
-
.chat-window-wrapper .chat-window-toggle:hover, .chat-window-wrapper .chat-window-toggle:focus {
|
|
82
|
-
transform: scale(1.05);
|
|
83
|
-
background: var(--chat--toggle--hover--background);
|
|
84
|
-
}
|
|
85
|
-
.chat-window-wrapper .chat-window-toggle:active {
|
|
86
|
-
transform: scale(0.95);
|
|
87
|
-
background: var(--chat--toggle--active--background);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.chat-window-transition-enter-active, .chat-window-transition-leave-active {
|
|
91
|
-
transition: transform var(--chat--transition-duration) ease, opacity var(--chat--transition-duration) ease;
|
|
92
|
-
}
|
|
93
|
-
.chat-window-transition-enter-from, .chat-window-transition-leave-to {
|
|
94
|
-
transform: scale(0);
|
|
95
|
-
opacity: 0;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.chat-window-toggle-transition-enter-active, .chat-window-toggle-transition-leave-active {
|
|
99
|
-
transition: opacity var(--chat--transition-duration) ease;
|
|
100
|
-
}
|
|
101
|
-
.chat-window-toggle-transition-enter-from, .chat-window-toggle-transition-leave-to {
|
|
102
|
-
opacity: 0;
|
|
103
|
-
}
|
|
104
|
-
</style>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import Button from '@n8n/chat/components/Button.vue';
|
|
3
|
-
import { useI18n } from '@n8n/chat/composables';
|
|
4
|
-
|
|
5
|
-
const { t } = useI18n();
|
|
6
|
-
</script>
|
|
7
|
-
<template>
|
|
8
|
-
<div class="chat-get-started">
|
|
9
|
-
<Button @click="$emit('click:button')">
|
|
10
|
-
{{ t('getStarted') }}
|
|
11
|
-
</Button>
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<style>
|
|
16
|
-
.chat-get-started {
|
|
17
|
-
padding-top: var(--chat--spacing);
|
|
18
|
-
padding-bottom: var(--chat--spacing);
|
|
19
|
-
display: flex;
|
|
20
|
-
justify-content: center;
|
|
21
|
-
align-items: center;
|
|
22
|
-
height: 100%;
|
|
23
|
-
}
|
|
24
|
-
</style>
|
package/components/Layout.vue
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
|
3
|
-
import { chatEventBus } from '@n8n/chat/event-buses';
|
|
4
|
-
|
|
5
|
-
const chatBodyRef = ref<HTMLElement | null>(null);
|
|
6
|
-
|
|
7
|
-
function scrollToBottom() {
|
|
8
|
-
const element = chatBodyRef.value as HTMLElement;
|
|
9
|
-
if (element) {
|
|
10
|
-
element.scrollTop = element.scrollHeight;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
onMounted(() => {
|
|
15
|
-
chatEventBus.on('scrollToBottom', scrollToBottom);
|
|
16
|
-
window.addEventListener('resize', scrollToBottom);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
onBeforeUnmount(() => {
|
|
20
|
-
chatEventBus.off('scrollToBottom', scrollToBottom);
|
|
21
|
-
window.removeEventListener('resize', scrollToBottom);
|
|
22
|
-
});
|
|
23
|
-
</script>
|
|
24
|
-
<template>
|
|
25
|
-
<main class="chat-layout">
|
|
26
|
-
<div v-if="$slots.header" class="chat-header">
|
|
27
|
-
<slot name="header" />
|
|
28
|
-
</div>
|
|
29
|
-
<div v-if="$slots.default" class="chat-body" ref="chatBodyRef">
|
|
30
|
-
<slot />
|
|
31
|
-
</div>
|
|
32
|
-
<div v-if="$slots.footer" class="chat-footer">
|
|
33
|
-
<slot name="footer" />
|
|
34
|
-
</div>
|
|
35
|
-
</main>
|
|
36
|
-
</template>
|
|
37
|
-
|
|
38
|
-
<style>
|
|
39
|
-
.chat-layout {
|
|
40
|
-
width: 100%;
|
|
41
|
-
height: 100%;
|
|
42
|
-
display: flex;
|
|
43
|
-
overflow-y: auto;
|
|
44
|
-
flex-direction: column;
|
|
45
|
-
font-family: var(--chat--font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif);
|
|
46
|
-
}
|
|
47
|
-
.chat-layout .chat-header {
|
|
48
|
-
padding: var(--chat--header--padding, var(--chat--spacing));
|
|
49
|
-
background: var(--chat--header--background, var(--chat--color-dark));
|
|
50
|
-
color: var(--chat--header--color, var(--chat--color-light));
|
|
51
|
-
}
|
|
52
|
-
.chat-layout .chat-body {
|
|
53
|
-
background: var(--chat--body--background, var(--chat--color-light));
|
|
54
|
-
flex: 1;
|
|
55
|
-
display: flex;
|
|
56
|
-
flex-direction: column;
|
|
57
|
-
overflow-y: auto;
|
|
58
|
-
position: relative;
|
|
59
|
-
min-height: 100px;
|
|
60
|
-
}
|
|
61
|
-
.chat-layout .chat-footer {
|
|
62
|
-
border-top: 1px solid var(--chat--color-light-shade-100);
|
|
63
|
-
background: var(--chat--footer--background, var(--chat--color-light));
|
|
64
|
-
color: var(--chat--footer--color, var(--chat--color-dark));
|
|
65
|
-
}
|
|
66
|
-
</style>
|
package/components/Message.vue
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
-
import type { ChatMessage } from '@n8n/chat/types';
|
|
4
|
-
import type { PropType } from 'vue';
|
|
5
|
-
import { computed, toRefs } from 'vue';
|
|
6
|
-
import VueMarkdown from 'vue-markdown-render';
|
|
7
|
-
import hljs from 'highlight.js/lib/core';
|
|
8
|
-
|
|
9
|
-
const props = defineProps({
|
|
10
|
-
message: {
|
|
11
|
-
type: Object as PropType<ChatMessage>,
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const { message } = toRefs(props);
|
|
17
|
-
|
|
18
|
-
const messageText = computed(() => {
|
|
19
|
-
return message.value.text || '<Empty response>';
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const classes = computed(() => {
|
|
23
|
-
return {
|
|
24
|
-
'chat-message-from-user': message.value.sender === 'user',
|
|
25
|
-
'chat-message-from-bot': message.value.sender === 'bot',
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const markdownOptions = {
|
|
30
|
-
highlight(str: string, lang: string) {
|
|
31
|
-
if (lang && hljs.getLanguage(lang)) {
|
|
32
|
-
try {
|
|
33
|
-
return hljs.highlight(str, { language: lang }).value;
|
|
34
|
-
} catch {}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return ''; // use external default escaping
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
</script>
|
|
41
|
-
<template>
|
|
42
|
-
<div class="chat-message" :class="classes">
|
|
43
|
-
<slot>
|
|
44
|
-
<vue-markdown
|
|
45
|
-
class="chat-message-markdown"
|
|
46
|
-
:source="messageText"
|
|
47
|
-
:options="markdownOptions"
|
|
48
|
-
/>
|
|
49
|
-
</slot>
|
|
50
|
-
</div>
|
|
51
|
-
</template>
|
|
52
|
-
|
|
53
|
-
<style>
|
|
54
|
-
.chat-message {
|
|
55
|
-
display: block;
|
|
56
|
-
max-width: 80%;
|
|
57
|
-
padding: var(--chat--message--padding, var(--chat--spacing));
|
|
58
|
-
border-radius: var(--chat--message--border-radius, var(--chat--border-radius));
|
|
59
|
-
}
|
|
60
|
-
.chat-message + .chat-message {
|
|
61
|
-
margin-top: var(--chat--message--margin-bottom, calc(var(--chat--spacing) * 0.5));
|
|
62
|
-
}
|
|
63
|
-
.chat-message.chat-message-from-bot {
|
|
64
|
-
background-color: var(--chat--message--bot--background);
|
|
65
|
-
color: var(--chat--message--bot--color);
|
|
66
|
-
border-bottom-left-radius: 0;
|
|
67
|
-
}
|
|
68
|
-
.chat-message.chat-message-from-user {
|
|
69
|
-
background-color: var(--chat--message--user--background);
|
|
70
|
-
color: var(--chat--message--user--color);
|
|
71
|
-
margin-left: auto;
|
|
72
|
-
border-bottom-right-radius: 0;
|
|
73
|
-
}
|
|
74
|
-
.chat-message > .chat-message-markdown {
|
|
75
|
-
display: block;
|
|
76
|
-
box-sizing: border-box;
|
|
77
|
-
}
|
|
78
|
-
.chat-message > .chat-message-markdown > *:first-child {
|
|
79
|
-
margin-top: 0;
|
|
80
|
-
}
|
|
81
|
-
.chat-message > .chat-message-markdown > *:last-child {
|
|
82
|
-
margin-bottom: 0;
|
|
83
|
-
}
|
|
84
|
-
.chat-message > .chat-message-markdown pre {
|
|
85
|
-
font-family: inherit;
|
|
86
|
-
font-size: inherit;
|
|
87
|
-
margin: 0;
|
|
88
|
-
white-space: pre-wrap;
|
|
89
|
-
box-sizing: border-box;
|
|
90
|
-
padding: var(--chat--spacing);
|
|
91
|
-
background: var(--chat--message--pre--background);
|
|
92
|
-
border-radius: var(--chat--border-radius);
|
|
93
|
-
}
|
|
94
|
-
</style>
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import type { ChatMessage } from '@n8n/chat/types';
|
|
3
|
-
import { Message } from './index';
|
|
4
|
-
import type { PropType } from 'vue';
|
|
5
|
-
import { computed } from 'vue';
|
|
6
|
-
|
|
7
|
-
const props = defineProps({
|
|
8
|
-
animation: {
|
|
9
|
-
type: String as PropType<'bouncing' | 'scaling'>,
|
|
10
|
-
default: 'bouncing',
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const message: ChatMessage = {
|
|
15
|
-
id: 'typing',
|
|
16
|
-
text: '',
|
|
17
|
-
sender: 'bot',
|
|
18
|
-
createdAt: '',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const classes = computed(() => {
|
|
22
|
-
return {
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
24
|
-
'chat-message-typing': true,
|
|
25
|
-
[`chat-message-typing-animation-${props.animation}`]: true,
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
</script>
|
|
29
|
-
<template>
|
|
30
|
-
<Message :class="classes" :message="message">
|
|
31
|
-
<div class="chat-message-typing-body">
|
|
32
|
-
<span class="chat-message-typing-circle"></span>
|
|
33
|
-
<span class="chat-message-typing-circle"></span>
|
|
34
|
-
<span class="chat-message-typing-circle"></span>
|
|
35
|
-
</div>
|
|
36
|
-
</Message>
|
|
37
|
-
</template>
|
|
38
|
-
<style>
|
|
39
|
-
.chat-message-typing {
|
|
40
|
-
max-width: 80px;
|
|
41
|
-
}
|
|
42
|
-
.chat-message-typing.chat-message-typing-animation-scaling .chat-message-typing-circle {
|
|
43
|
-
animation: chat-message-typing-animation-scaling 800ms ease-in-out infinite;
|
|
44
|
-
animation-delay: 3600ms;
|
|
45
|
-
}
|
|
46
|
-
.chat-message-typing.chat-message-typing-animation-bouncing .chat-message-typing-circle {
|
|
47
|
-
animation: chat-message-typing-animation-bouncing 800ms ease-in-out infinite;
|
|
48
|
-
animation-delay: 3600ms;
|
|
49
|
-
}
|
|
50
|
-
.chat-message-typing .chat-message-typing-body {
|
|
51
|
-
display: flex;
|
|
52
|
-
justify-content: center;
|
|
53
|
-
align-items: center;
|
|
54
|
-
}
|
|
55
|
-
.chat-message-typing .chat-message-typing-circle {
|
|
56
|
-
display: block;
|
|
57
|
-
height: 10px;
|
|
58
|
-
width: 10px;
|
|
59
|
-
border-radius: 50%;
|
|
60
|
-
background-color: var(--chat--color-typing);
|
|
61
|
-
margin: 3px;
|
|
62
|
-
}
|
|
63
|
-
.chat-message-typing .chat-message-typing-circle:nth-child(1) {
|
|
64
|
-
animation-delay: 0ms;
|
|
65
|
-
}
|
|
66
|
-
.chat-message-typing .chat-message-typing-circle:nth-child(2) {
|
|
67
|
-
animation-delay: 333ms;
|
|
68
|
-
}
|
|
69
|
-
.chat-message-typing .chat-message-typing-circle:nth-child(3) {
|
|
70
|
-
animation-delay: 666ms;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@keyframes chat-message-typing-animation-scaling {
|
|
74
|
-
0% {
|
|
75
|
-
transform: scale(1);
|
|
76
|
-
}
|
|
77
|
-
33% {
|
|
78
|
-
transform: scale(1);
|
|
79
|
-
}
|
|
80
|
-
50% {
|
|
81
|
-
transform: scale(1.4);
|
|
82
|
-
}
|
|
83
|
-
100% {
|
|
84
|
-
transform: scale(1);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
@keyframes chat-message-typing-animation-bouncing {
|
|
88
|
-
0% {
|
|
89
|
-
transform: translateY(0);
|
|
90
|
-
}
|
|
91
|
-
33% {
|
|
92
|
-
transform: translateY(0);
|
|
93
|
-
}
|
|
94
|
-
50% {
|
|
95
|
-
transform: translateY(-10px);
|
|
96
|
-
}
|
|
97
|
-
100% {
|
|
98
|
-
transform: translateY(0);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
</style>
|
package/components/index.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Button", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _Button.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "Chat", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _Chat.default;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "ChatWindow", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _ChatWindow.default;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "GetStarted", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _GetStarted.default;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "GetStartedFooter", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _GetStartedFooter.default;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "Input", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _Input.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(exports, "Layout", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _Layout.default;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(exports, "Message", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function () {
|
|
51
|
-
return _Message.default;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(exports, "MessagesList", {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _MessagesList.default;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
Object.defineProperty(exports, "PoweredBy", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
get: function () {
|
|
63
|
-
return _PoweredBy.default;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
var _Button = _interopRequireDefault(require("./Button.vue"));
|
|
67
|
-
var _Chat = _interopRequireDefault(require("./Chat.vue"));
|
|
68
|
-
var _ChatWindow = _interopRequireDefault(require("./ChatWindow.vue"));
|
|
69
|
-
var _GetStarted = _interopRequireDefault(require("./GetStarted.vue"));
|
|
70
|
-
var _GetStartedFooter = _interopRequireDefault(require("./GetStartedFooter.vue"));
|
|
71
|
-
var _Input = _interopRequireDefault(require("./Input.vue"));
|
|
72
|
-
var _Layout = _interopRequireDefault(require("./Layout.vue"));
|
|
73
|
-
var _Message = _interopRequireDefault(require("./Message.vue"));
|
|
74
|
-
var _MessagesList = _interopRequireDefault(require("./MessagesList.vue"));
|
|
75
|
-
var _PoweredBy = _interopRequireDefault(require("./PoweredBy.vue"));
|
|
76
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/components/index.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { default as Button } from "./Button.vue";
|
|
2
|
-
export { default as Chat } from "./Chat.vue";
|
|
3
|
-
export { default as ChatWindow } from "./ChatWindow.vue";
|
|
4
|
-
export { default as GetStarted } from "./GetStarted.vue";
|
|
5
|
-
export { default as GetStartedFooter } from "./GetStartedFooter.vue";
|
|
6
|
-
export { default as Input } from "./Input.vue";
|
|
7
|
-
export { default as Layout } from "./Layout.vue";
|
|
8
|
-
export { default as Message } from "./Message.vue";
|
|
9
|
-
export { default as MessagesList } from "./MessagesList.vue";
|
|
10
|
-
export { default as PoweredBy } from "./PoweredBy.vue";
|
package/composables/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _useChat = require("./useChat");
|
|
7
|
-
Object.keys(_useChat).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _useChat[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _useChat[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _useI18n = require("./useI18n");
|
|
18
|
-
Object.keys(_useI18n).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _useI18n[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _useI18n[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _useOptions = require("./useOptions");
|
|
29
|
-
Object.keys(_useOptions).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _useOptions[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _useOptions[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
package/composables/index.mjs
DELETED
package/composables/useChat.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useChat(): Chat;
|
package/composables/useChat.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useChat = useChat;
|
|
7
|
-
var _vue = require("vue");
|
|
8
|
-
var _constants = require("@n8n/chat/constants");
|
|
9
|
-
function useChat() {
|
|
10
|
-
return (0, _vue.inject)(_constants.ChatSymbol);
|
|
11
|
-
}
|
package/composables/useChat.mjs
DELETED
package/composables/useI18n.d.ts
DELETED
package/composables/useI18n.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useI18n = useI18n;
|
|
7
|
-
var _useOptions = require("@n8n/chat/composables/useOptions");
|
|
8
|
-
function useI18n() {
|
|
9
|
-
const {
|
|
10
|
-
options
|
|
11
|
-
} = (0, _useOptions.useOptions)();
|
|
12
|
-
const language = options?.defaultLanguage ?? "en";
|
|
13
|
-
function t(key) {
|
|
14
|
-
return options?.i18n?.[language]?.[key] ?? key;
|
|
15
|
-
}
|
|
16
|
-
function te(key) {
|
|
17
|
-
return !!options?.i18n?.[language]?.[key];
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
t,
|
|
21
|
-
te
|
|
22
|
-
};
|
|
23
|
-
}
|
package/composables/useI18n.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useOptions } from "@n8n/chat/composables/useOptions";
|
|
2
|
-
export function useI18n() {
|
|
3
|
-
const { options } = useOptions();
|
|
4
|
-
const language = options?.defaultLanguage ?? "en";
|
|
5
|
-
function t(key) {
|
|
6
|
-
return options?.i18n?.[language]?.[key] ?? key;
|
|
7
|
-
}
|
|
8
|
-
function te(key) {
|
|
9
|
-
return !!options?.i18n?.[language]?.[key];
|
|
10
|
-
}
|
|
11
|
-
return { t, te };
|
|
12
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useOptions = useOptions;
|
|
7
|
-
var _vue = require("vue");
|
|
8
|
-
var _constants = require("@n8n/chat/constants");
|
|
9
|
-
function useOptions() {
|
|
10
|
-
const options = (0, _vue.inject)(_constants.ChatOptionsSymbol);
|
|
11
|
-
return {
|
|
12
|
-
options
|
|
13
|
-
};
|
|
14
|
-
}
|
package/constants/defaults.d.ts
DELETED