@aleph-alpha/chat-kit 4.0.0 → 5.0.1
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/{CkInput.vue_vue_type_script_setup_true_lang-DJN-nZ2-.js → CkHistory.vue_vue_type_script_setup_true_lang-CtQUc3m3.js} +435 -378
- package/dist/chat-kit.css +28 -6
- package/dist/components/base/CkAgentMessage/CkAgentMessage.stories.d.ts +14 -13
- package/dist/components/base/CkAgentMessage/CkAgentMessage.stories.d.ts.map +1 -1
- package/dist/components/base/CkAgentMessage/CkAgentMessage.vue.d.ts +8 -7
- package/dist/components/base/CkAgentMessage/CkAgentMessage.vue.d.ts.map +1 -1
- package/dist/components/base/CkAgentMessage/types.d.ts +16 -5
- package/dist/components/base/CkAgentMessage/types.d.ts.map +1 -1
- package/dist/components/base/CkAgentMessageHeader/CkAgentMessageHeader.stories.d.ts +16 -0
- package/dist/components/base/CkAgentMessageHeader/CkAgentMessageHeader.stories.d.ts.map +1 -0
- package/dist/components/base/CkAgentMessageHeader/CkAgentMessageHeader.vue.d.ts +21 -0
- package/dist/components/base/CkAgentMessageHeader/CkAgentMessageHeader.vue.d.ts.map +1 -0
- package/dist/components/base/CkAgentMessageHeader/index.d.ts +3 -0
- package/dist/components/base/CkAgentMessageHeader/index.d.ts.map +1 -0
- package/dist/components/base/CkAgentMessageHeader/types.d.ts +22 -0
- package/dist/components/base/CkAgentMessageHeader/types.d.ts.map +1 -0
- package/dist/components/base/CkCitation/CkCitation.stories.d.ts +6 -0
- package/dist/components/base/CkCitation/CkCitation.stories.d.ts.map +1 -1
- package/dist/components/base/CkCitation/CkCitation.vue.d.ts.map +1 -1
- package/dist/components/base/CkCitationCard/CkCitationCard.stories.d.ts +10 -6
- package/dist/components/base/CkCitationCard/CkCitationCard.stories.d.ts.map +1 -1
- package/dist/components/base/CkCitationCard/CkCitationCard.vue.d.ts.map +1 -1
- package/dist/components/base/CkFileItemsList/CkFileItemsList.stories.d.ts +15 -4
- package/dist/components/base/CkFileItemsList/CkFileItemsList.stories.d.ts.map +1 -1
- package/dist/components/base/CkFileItemsList/CkFileItemsList.vue.d.ts +2 -1
- package/dist/components/base/CkFileItemsList/CkFileItemsList.vue.d.ts.map +1 -1
- package/dist/components/base/CkFileItemsList/types.d.ts +17 -4
- package/dist/components/base/CkFileItemsList/types.d.ts.map +1 -1
- package/dist/components/base/CkHeaderActivityButton/CkHeaderActivityButton.stories.d.ts +19 -0
- package/dist/components/base/CkHeaderActivityButton/CkHeaderActivityButton.stories.d.ts.map +1 -0
- package/dist/components/base/CkHeaderActivityButton/CkHeaderActivityButton.vue.d.ts +22 -0
- package/dist/components/base/CkHeaderActivityButton/CkHeaderActivityButton.vue.d.ts.map +1 -0
- package/dist/components/base/CkHeaderActivityButton/index.d.ts +3 -0
- package/dist/components/base/CkHeaderActivityButton/index.d.ts.map +1 -0
- package/dist/components/base/CkHeaderActivityButton/types.d.ts +36 -0
- package/dist/components/base/CkHeaderActivityButton/types.d.ts.map +1 -0
- package/dist/components/base/CkPromptInput/CkPromptInput.stories.d.ts +6 -6
- package/dist/components/base/CkPromptInput/CkPromptInput.vue.d.ts.map +1 -1
- package/dist/components/base/CkPromptInput/types.d.ts +4 -4
- package/dist/components/base/CkPromptInputDisclaimer/CkPromptInputDisclaimer.vue.d.ts.map +1 -1
- package/dist/components/base/CkPromptInputDisclaimer/types.d.ts +1 -1
- package/dist/components/base/CkPromptSendButton/CkPromptSendButton.vue.d.ts +1 -1
- package/dist/components/base/CkPromptSendButton/types.d.ts +1 -1
- package/dist/components/base/CkPromptStopButton/types.d.ts +1 -1
- package/dist/components/base/index.d.ts +4 -0
- package/dist/components/base/index.d.ts.map +1 -1
- package/dist/components/composed/CkConversation/CkConversation.vue.d.ts +13 -1
- package/dist/components/composed/CkConversation/CkConversation.vue.d.ts.map +1 -1
- package/dist/components/composed/CkConversation/types.d.ts +1 -1
- package/dist/components/composed/index.d.ts +0 -1
- package/dist/components/composed/index.d.ts.map +1 -1
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +26 -25
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -26
- package/package.json +1 -1
- package/src/components/base/CkAgentMessage/CkAgentMessage.spec.ts +12 -17
- package/src/components/base/CkAgentMessage/CkAgentMessage.stories.ts +124 -113
- package/src/components/base/CkAgentMessage/CkAgentMessage.vue +18 -16
- package/src/components/base/CkAgentMessage/types.ts +16 -5
- package/src/components/base/CkAgentMessageHeader/CkAgentMessageHeader.spec.ts +64 -0
- package/src/components/base/CkAgentMessageHeader/CkAgentMessageHeader.stories.ts +90 -0
- package/src/components/base/CkAgentMessageHeader/CkAgentMessageHeader.vue +47 -0
- package/src/components/base/CkAgentMessageHeader/index.ts +2 -0
- package/src/components/base/CkAgentMessageHeader/types.ts +21 -0
- package/src/components/base/CkCitation/CkCitation.stories.ts +12 -0
- package/src/components/base/CkCitation/CkCitation.vue +34 -9
- package/src/components/base/CkCitationCard/CkCitationCard.spec.ts +9 -0
- package/src/components/base/CkCitationCard/CkCitationCard.stories.ts +11 -7
- package/src/components/base/CkCitationCard/CkCitationCard.vue +5 -3
- package/src/components/base/CkConversationLayout/CkConversationLayout.vue +1 -1
- package/src/components/base/CkFileItemsList/CkFileItemsList.spec.ts +88 -13
- package/src/components/base/CkFileItemsList/CkFileItemsList.stories.ts +61 -13
- package/src/components/base/CkFileItemsList/CkFileItemsList.vue +153 -110
- package/src/components/base/CkFileItemsList/types.ts +17 -4
- package/src/components/base/CkHeaderActivityButton/CkHeaderActivityButton.spec.ts +50 -0
- package/src/components/base/CkHeaderActivityButton/CkHeaderActivityButton.stories.ts +102 -0
- package/src/components/base/CkHeaderActivityButton/CkHeaderActivityButton.vue +39 -0
- package/src/components/base/CkHeaderActivityButton/index.ts +2 -0
- package/src/components/base/CkHeaderActivityButton/types.ts +36 -0
- package/src/components/base/CkPromptInput/CkPromptInput.spec.ts +88 -0
- package/src/components/base/CkPromptInput/CkPromptInput.stories.ts +6 -6
- package/src/components/base/CkPromptInput/CkPromptInput.vue +63 -12
- package/src/components/base/CkPromptInput/types.ts +4 -4
- package/src/components/base/CkPromptInputDisclaimer/CkPromptInputDisclaimer.spec.ts +1 -1
- package/src/components/base/CkPromptInputDisclaimer/CkPromptInputDisclaimer.vue +1 -1
- package/src/components/base/CkPromptInputDisclaimer/types.ts +1 -1
- package/src/components/base/CkPromptSendButton/types.ts +1 -1
- package/src/components/base/CkPromptStopButton/types.ts +1 -1
- package/src/components/base/index.ts +7 -0
- package/src/components/composed/CkConversation/CkConversation.spec.ts +81 -6
- package/src/components/composed/CkConversation/CkConversation.vue +78 -35
- package/src/components/composed/CkConversation/types.ts +1 -1
- package/src/components/composed/index.ts +0 -1
- package/src/components/index.ts +6 -1
- package/src/index.ts +5 -1
- package/dist/components/composed/CkInput/CkInput.stories.d.ts +0 -43
- package/dist/components/composed/CkInput/CkInput.stories.d.ts.map +0 -1
- package/dist/components/composed/CkInput/CkInput.vue.d.ts +0 -50
- package/dist/components/composed/CkInput/CkInput.vue.d.ts.map +0 -1
- package/dist/components/composed/CkInput/index.d.ts +0 -3
- package/dist/components/composed/CkInput/index.d.ts.map +0 -1
- package/dist/components/composed/CkInput/types.d.ts +0 -55
- package/dist/components/composed/CkInput/types.d.ts.map +0 -1
- package/src/components/composed/CkInput/CkInput.spec.ts +0 -191
- package/src/components/composed/CkInput/CkInput.stories.ts +0 -434
- package/src/components/composed/CkInput/CkInput.vue +0 -106
- package/src/components/composed/CkInput/index.ts +0 -2
- package/src/components/composed/CkInput/types.ts +0 -55
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
import CkInput from './CkInput.vue';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
3
|
-
import { ref } from 'vue';
|
|
4
|
-
|
|
5
|
-
const DISCLAIMER =
|
|
6
|
-
'Assistant Chat may occasionally make mistakes. Please, make sure to double-check important information.';
|
|
7
|
-
|
|
8
|
-
const meta: Meta<typeof CkInput> = {
|
|
9
|
-
title: 'Composed/CkInput',
|
|
10
|
-
component: CkInput,
|
|
11
|
-
tags: ['autodocs'],
|
|
12
|
-
argTypes: {
|
|
13
|
-
modelValue: {
|
|
14
|
-
control: 'text',
|
|
15
|
-
description: 'Current value of the input. Use with `v-model`.',
|
|
16
|
-
},
|
|
17
|
-
placeholder: {
|
|
18
|
-
control: 'text',
|
|
19
|
-
description: 'Placeholder shown when empty.',
|
|
20
|
-
},
|
|
21
|
-
disabled: {
|
|
22
|
-
control: 'boolean',
|
|
23
|
-
description: 'Disables the input and send button.',
|
|
24
|
-
},
|
|
25
|
-
loading: {
|
|
26
|
-
control: 'boolean',
|
|
27
|
-
description:
|
|
28
|
-
'Shows a spinner in the send button and blocks further input.',
|
|
29
|
-
},
|
|
30
|
-
ariaLabel: {
|
|
31
|
-
control: 'text',
|
|
32
|
-
description: 'Accessible label for the textarea.',
|
|
33
|
-
},
|
|
34
|
-
disclaimer: {
|
|
35
|
-
control: 'text',
|
|
36
|
-
description: 'Optional disclaimer text rendered below the input.',
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
decorators: [
|
|
40
|
-
() => ({
|
|
41
|
-
template:
|
|
42
|
-
'<div style="max-width: 640px; margin: 0 auto; padding: 24px;"><story /></div>',
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default meta;
|
|
48
|
-
type Story = StoryObj<typeof meta>;
|
|
49
|
-
|
|
50
|
-
const defaultTemplateSource = `<script setup lang="ts">
|
|
51
|
-
import { CkInput } from '@aleph-alpha/chat-kit';
|
|
52
|
-
import { ref } from 'vue';
|
|
53
|
-
|
|
54
|
-
const text = ref('');
|
|
55
|
-
const disclaimer = 'Assistant Chat may occasionally make mistakes. Please double-check.';
|
|
56
|
-
</script>
|
|
57
|
-
|
|
58
|
-
<template>
|
|
59
|
-
<CkInput v-model="text" :disclaimer="disclaimer" />
|
|
60
|
-
</template>`;
|
|
61
|
-
|
|
62
|
-
const withModeToggleTemplateSource = `<script setup lang="ts">
|
|
63
|
-
import { CkInput } from '@aleph-alpha/chat-kit';
|
|
64
|
-
import { ref } from 'vue';
|
|
65
|
-
|
|
66
|
-
const text = ref('');
|
|
67
|
-
const mode = ref<'express' | 'smart'>('smart');
|
|
68
|
-
</script>
|
|
69
|
-
|
|
70
|
-
<template>
|
|
71
|
-
<CkInput v-model="text">
|
|
72
|
-
<template #toolbar-left>
|
|
73
|
-
<div class="flex items-center gap-1">
|
|
74
|
-
<button @click="mode = 'express'">Express</button>
|
|
75
|
-
<button @click="mode = 'smart'">Smart</button>
|
|
76
|
-
</div>
|
|
77
|
-
</template>
|
|
78
|
-
</CkInput>
|
|
79
|
-
</template>`;
|
|
80
|
-
|
|
81
|
-
const fullExampleTemplateSource = `<script setup lang="ts">
|
|
82
|
-
import { CkInput } from '@aleph-alpha/chat-kit';
|
|
83
|
-
import { ref } from 'vue';
|
|
84
|
-
|
|
85
|
-
const text = ref('');
|
|
86
|
-
const attachmentCount = ref(3);
|
|
87
|
-
const disclaimer = 'Assistant Chat may occasionally make mistakes. Please double-check.';
|
|
88
|
-
function onSubmit() { text.value = ''; }
|
|
89
|
-
</script>
|
|
90
|
-
|
|
91
|
-
<template>
|
|
92
|
-
<CkInput v-model="text" :disclaimer="disclaimer" @submit="onSubmit">
|
|
93
|
-
<template #toolbar-left>
|
|
94
|
-
<button>Mode</button>
|
|
95
|
-
</template>
|
|
96
|
-
<template #toolbar-right="{ submit, disabled }">
|
|
97
|
-
<button aria-label="Attach file">Attach ({{ attachmentCount }})</button>
|
|
98
|
-
<button type="submit" :disabled="disabled" @click="submit" aria-label="Send message">Send</button>
|
|
99
|
-
</template>
|
|
100
|
-
</CkInput>
|
|
101
|
-
</template>`;
|
|
102
|
-
|
|
103
|
-
const disabledTemplateSource = `<script setup lang="ts">
|
|
104
|
-
import { CkInput } from '@aleph-alpha/chat-kit';
|
|
105
|
-
import { ref } from 'vue';
|
|
106
|
-
|
|
107
|
-
const text = ref('');
|
|
108
|
-
</script>
|
|
109
|
-
|
|
110
|
-
<template>
|
|
111
|
-
<CkInput v-model="text" disabled placeholder="Input is disabled" />
|
|
112
|
-
</template>`;
|
|
113
|
-
|
|
114
|
-
const loadingTemplateSource = `<script setup lang="ts">
|
|
115
|
-
import { CkInput } from '@aleph-alpha/chat-kit';
|
|
116
|
-
import { ref } from 'vue';
|
|
117
|
-
|
|
118
|
-
const text = ref('Generating a response...');
|
|
119
|
-
</script>
|
|
120
|
-
|
|
121
|
-
<template>
|
|
122
|
-
<CkInput v-model="text" loading />
|
|
123
|
-
</template>`;
|
|
124
|
-
|
|
125
|
-
const withLongTextTemplateSource = `<script setup lang="ts">
|
|
126
|
-
import { CkInput } from '@aleph-alpha/chat-kit';
|
|
127
|
-
import { ref } from 'vue';
|
|
128
|
-
|
|
129
|
-
const text = ref('This is a long multi-line message that demonstrates auto-grow behavior.');
|
|
130
|
-
</script>
|
|
131
|
-
|
|
132
|
-
<template>
|
|
133
|
-
<CkInput v-model="text" />
|
|
134
|
-
</template>`;
|
|
135
|
-
|
|
136
|
-
const mobileWidthTemplateSource = `<script setup lang="ts">
|
|
137
|
-
import { CkInput } from '@aleph-alpha/chat-kit';
|
|
138
|
-
import { ref } from 'vue';
|
|
139
|
-
|
|
140
|
-
const text = ref('');
|
|
141
|
-
</script>
|
|
142
|
-
|
|
143
|
-
<template>
|
|
144
|
-
<div style="max-width: 320px;">
|
|
145
|
-
<CkInput v-model="text" />
|
|
146
|
-
</div>
|
|
147
|
-
</template>`;
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Default chat input with disclaimer and the built-in send button.
|
|
151
|
-
* Use as the primary way to let users submit a prompt to the assistant.
|
|
152
|
-
*/
|
|
153
|
-
export const Default: Story = {
|
|
154
|
-
render: () => ({
|
|
155
|
-
components: { CkInput },
|
|
156
|
-
setup() {
|
|
157
|
-
const text = ref('');
|
|
158
|
-
return { text, DISCLAIMER };
|
|
159
|
-
},
|
|
160
|
-
template: `
|
|
161
|
-
<CkInput
|
|
162
|
-
v-model="text"
|
|
163
|
-
:disclaimer="DISCLAIMER"
|
|
164
|
-
/>
|
|
165
|
-
`,
|
|
166
|
-
}),
|
|
167
|
-
parameters: { docs: { source: { code: defaultTemplateSource } } },
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Adds a mode toggle (Express/Smart) to the left side of the toolbar via
|
|
172
|
-
* `#toolbar-left`. Use when the user needs to switch between assistant
|
|
173
|
-
* presets or capabilities before submitting.
|
|
174
|
-
*/
|
|
175
|
-
export const WithModeToggle: Story = {
|
|
176
|
-
render: () => ({
|
|
177
|
-
components: { CkInput },
|
|
178
|
-
setup() {
|
|
179
|
-
const text = ref('');
|
|
180
|
-
const mode = ref<'express' | 'smart'>('smart');
|
|
181
|
-
return { text, mode };
|
|
182
|
-
},
|
|
183
|
-
template: `
|
|
184
|
-
<CkInput v-model="text">
|
|
185
|
-
<template #toolbar-left>
|
|
186
|
-
<div class="flex items-center">
|
|
187
|
-
<button
|
|
188
|
-
class="flex items-center justify-center rounded-l-md border border-solid h-9 px-2 text-sm font-medium shadow-sm transition-all duration-300 ease-in-out"
|
|
189
|
-
:style="mode === 'express'
|
|
190
|
-
? 'background-color: #2888b8; border-color: rgba(183,180,164,0.3); color: #daf2f6;'
|
|
191
|
-
: 'background-color: #ebebe5; border-color: rgba(183,180,164,0.3); color: #1d1d1b;'"
|
|
192
|
-
@click="mode = 'express'"
|
|
193
|
-
>
|
|
194
|
-
<svg class="shrink-0" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/></svg>
|
|
195
|
-
<span
|
|
196
|
-
class="overflow-hidden whitespace-nowrap transition-all duration-300 ease-in-out"
|
|
197
|
-
:style="mode === 'express'
|
|
198
|
-
? 'max-width: 70px; opacity: 1; padding-left: 8px;'
|
|
199
|
-
: 'max-width: 0; opacity: 0; padding-left: 0;'"
|
|
200
|
-
>Express</span>
|
|
201
|
-
</button>
|
|
202
|
-
<button
|
|
203
|
-
class="flex items-center justify-center rounded-r-md border-t border-r border-b border-solid h-9 px-2 text-sm font-medium shadow-sm transition-all duration-300 ease-in-out"
|
|
204
|
-
:style="mode === 'smart'
|
|
205
|
-
? 'background-color: #2888b8; border-color: rgba(183,180,164,0.3); color: #daf2f6;'
|
|
206
|
-
: 'background-color: #ebebe5; border-color: rgba(183,180,164,0.3); color: #1d1d1b;'"
|
|
207
|
-
@click="mode = 'smart'"
|
|
208
|
-
>
|
|
209
|
-
<svg class="shrink-0" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/></svg>
|
|
210
|
-
<span
|
|
211
|
-
class="overflow-hidden whitespace-nowrap transition-all duration-300 ease-in-out"
|
|
212
|
-
:style="mode === 'smart'
|
|
213
|
-
? 'max-width: 70px; opacity: 1; padding-left: 8px;'
|
|
214
|
-
: 'max-width: 0; opacity: 0; padding-left: 0;'"
|
|
215
|
-
>Smart</span>
|
|
216
|
-
</button>
|
|
217
|
-
</div>
|
|
218
|
-
</template>
|
|
219
|
-
</CkInput>
|
|
220
|
-
`,
|
|
221
|
-
}),
|
|
222
|
-
parameters: { docs: { source: { code: withModeToggleTemplateSource } } },
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* End-to-end example: mode toggle on the left, attachment button + custom
|
|
227
|
-
* send button on the right, and a disclaimer underneath. Use as a reference
|
|
228
|
-
* for a production-ready chat compose UI.
|
|
229
|
-
*/
|
|
230
|
-
export const FullExample: Story = {
|
|
231
|
-
render: () => ({
|
|
232
|
-
components: { CkInput },
|
|
233
|
-
setup() {
|
|
234
|
-
const text = ref('');
|
|
235
|
-
const mode = ref<'express' | 'smart'>('smart');
|
|
236
|
-
const attachmentCount = ref(3);
|
|
237
|
-
const onSubmit = () => {
|
|
238
|
-
text.value = '';
|
|
239
|
-
};
|
|
240
|
-
return { text, mode, attachmentCount, onSubmit, DISCLAIMER };
|
|
241
|
-
},
|
|
242
|
-
template: `
|
|
243
|
-
<CkInput
|
|
244
|
-
v-model="text"
|
|
245
|
-
:disclaimer="DISCLAIMER"
|
|
246
|
-
@submit="onSubmit"
|
|
247
|
-
>
|
|
248
|
-
<template #toolbar-left>
|
|
249
|
-
<div class="flex items-center">
|
|
250
|
-
<button
|
|
251
|
-
class="flex items-center justify-center rounded-l-md border border-solid h-9 px-2 text-sm font-medium shadow-sm transition-all duration-300 ease-in-out"
|
|
252
|
-
:style="mode === 'express'
|
|
253
|
-
? 'background-color: #2888b8; border-color: rgba(183,180,164,0.3); color: #daf2f6;'
|
|
254
|
-
: 'background-color: #ebebe5; border-color: rgba(183,180,164,0.3); color: #1d1d1b;'"
|
|
255
|
-
@click="mode = 'express'"
|
|
256
|
-
>
|
|
257
|
-
<svg class="shrink-0" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/></svg>
|
|
258
|
-
<span
|
|
259
|
-
class="overflow-hidden whitespace-nowrap transition-all duration-300 ease-in-out"
|
|
260
|
-
:style="mode === 'express'
|
|
261
|
-
? 'max-width: 70px; opacity: 1; padding-left: 8px;'
|
|
262
|
-
: 'max-width: 0; opacity: 0; padding-left: 0;'"
|
|
263
|
-
>Express</span>
|
|
264
|
-
</button>
|
|
265
|
-
<button
|
|
266
|
-
class="flex items-center justify-center rounded-r-md border-t border-r border-b border-solid h-9 px-2 text-sm font-medium shadow-sm transition-all duration-300 ease-in-out"
|
|
267
|
-
:style="mode === 'smart'
|
|
268
|
-
? 'background-color: #2888b8; border-color: rgba(183,180,164,0.3); color: #daf2f6;'
|
|
269
|
-
: 'background-color: #ebebe5; border-color: rgba(183,180,164,0.3); color: #1d1d1b;'"
|
|
270
|
-
@click="mode = 'smart'"
|
|
271
|
-
>
|
|
272
|
-
<svg class="shrink-0" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/></svg>
|
|
273
|
-
<span
|
|
274
|
-
class="overflow-hidden whitespace-nowrap transition-all duration-300 ease-in-out"
|
|
275
|
-
:style="mode === 'smart'
|
|
276
|
-
? 'max-width: 70px; opacity: 1; padding-left: 8px;'
|
|
277
|
-
: 'max-width: 0; opacity: 0; padding-left: 0;'"
|
|
278
|
-
>Smart</span>
|
|
279
|
-
</button>
|
|
280
|
-
</div>
|
|
281
|
-
</template>
|
|
282
|
-
<template #toolbar-right="{ submit, disabled }">
|
|
283
|
-
<div class="flex items-center gap-2">
|
|
284
|
-
<button
|
|
285
|
-
type="button"
|
|
286
|
-
class="flex items-center gap-2 rounded-md border border-solid px-4 py-2 h-9"
|
|
287
|
-
style="border-color: rgba(183, 180, 164, 0.3);"
|
|
288
|
-
aria-label="Attach file"
|
|
289
|
-
>
|
|
290
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>
|
|
291
|
-
<span
|
|
292
|
-
v-if="attachmentCount > 0"
|
|
293
|
-
class="flex items-center justify-center rounded-full min-w-5 h-4 px-1 text-xs"
|
|
294
|
-
style="background-color: #c9e400; color: #252422;"
|
|
295
|
-
>
|
|
296
|
-
{{ attachmentCount }}
|
|
297
|
-
</span>
|
|
298
|
-
</button>
|
|
299
|
-
<button
|
|
300
|
-
type="submit"
|
|
301
|
-
:disabled="disabled"
|
|
302
|
-
class="flex items-center justify-center size-9 rounded-md disabled:opacity-50"
|
|
303
|
-
style="background-color: #c9e400; color: #1d1d1b;"
|
|
304
|
-
aria-label="Send message"
|
|
305
|
-
@click="submit"
|
|
306
|
-
>
|
|
307
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z"/><path d="M6 12h16"/></svg>
|
|
308
|
-
</button>
|
|
309
|
-
</div>
|
|
310
|
-
</template>
|
|
311
|
-
</CkInput>
|
|
312
|
-
`,
|
|
313
|
-
}),
|
|
314
|
-
decorators: [
|
|
315
|
-
() => ({
|
|
316
|
-
template:
|
|
317
|
-
'<div style="max-width: 640px; margin: 0 auto; padding: 24px; background: #ebebe5; min-height: 300px; border-radius: 12px;"><story /></div>',
|
|
318
|
-
}),
|
|
319
|
-
],
|
|
320
|
-
parameters: { docs: { source: { code: fullExampleTemplateSource } } },
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Disabled state — the textarea is read-only and the send button is inactive.
|
|
325
|
-
* Use while waiting for an upstream action to resolve.
|
|
326
|
-
*/
|
|
327
|
-
export const Disabled: Story = {
|
|
328
|
-
render: () => ({
|
|
329
|
-
components: { CkInput },
|
|
330
|
-
setup() {
|
|
331
|
-
const text = ref('');
|
|
332
|
-
return { text, DISCLAIMER };
|
|
333
|
-
},
|
|
334
|
-
template: `
|
|
335
|
-
<CkInput
|
|
336
|
-
v-model="text"
|
|
337
|
-
disabled
|
|
338
|
-
placeholder="Input is disabled"
|
|
339
|
-
:disclaimer="DISCLAIMER"
|
|
340
|
-
/>
|
|
341
|
-
`,
|
|
342
|
-
}),
|
|
343
|
-
parameters: { docs: { source: { code: disabledTemplateSource } } },
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Loading state — shown while the assistant is generating a reply. The
|
|
348
|
-
* send button displays a spinner and the input is blocked.
|
|
349
|
-
*/
|
|
350
|
-
export const Loading: Story = {
|
|
351
|
-
render: () => ({
|
|
352
|
-
components: { CkInput },
|
|
353
|
-
setup() {
|
|
354
|
-
const text = ref('Generating a response...');
|
|
355
|
-
const loading = ref(true);
|
|
356
|
-
function onSubmit() {
|
|
357
|
-
text.value = 'Generating a response...';
|
|
358
|
-
loading.value = true;
|
|
359
|
-
}
|
|
360
|
-
function onStop() {
|
|
361
|
-
text.value = 'Response stopped';
|
|
362
|
-
loading.value = false;
|
|
363
|
-
}
|
|
364
|
-
return { text, loading, DISCLAIMER, onSubmit, onStop };
|
|
365
|
-
},
|
|
366
|
-
template: `
|
|
367
|
-
<CkInput
|
|
368
|
-
v-model="text"
|
|
369
|
-
:loading="loading"
|
|
370
|
-
:disclaimer="DISCLAIMER"
|
|
371
|
-
@submit="onSubmit"
|
|
372
|
-
@stop="onStop"
|
|
373
|
-
/>
|
|
374
|
-
`,
|
|
375
|
-
}),
|
|
376
|
-
parameters: { docs: { source: { code: loadingTemplateSource } } },
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Demonstrates the textarea's auto-grow behavior with multi-paragraph content.
|
|
381
|
-
* Use when validating how the input handles long prompts.
|
|
382
|
-
*/
|
|
383
|
-
export const WithLongText: Story = {
|
|
384
|
-
render: () => ({
|
|
385
|
-
components: { CkInput },
|
|
386
|
-
setup() {
|
|
387
|
-
const text = ref(
|
|
388
|
-
'This is a long message that demonstrates the auto-grow behavior of the textarea. ' +
|
|
389
|
-
'As the content grows, the textarea expands up to the maximum height. ' +
|
|
390
|
-
'Once the max height is reached, the content becomes scrollable.\n\n' +
|
|
391
|
-
'Here is a second paragraph to show how multi-line content works. ' +
|
|
392
|
-
'The component handles newlines naturally with Shift+Enter.\n\n' +
|
|
393
|
-
'And a third paragraph for good measure. The auto-grow logic recalculates ' +
|
|
394
|
-
'the height on every input event and when the modelValue changes externally.',
|
|
395
|
-
);
|
|
396
|
-
return { text, DISCLAIMER };
|
|
397
|
-
},
|
|
398
|
-
template: `
|
|
399
|
-
<CkInput
|
|
400
|
-
v-model="text"
|
|
401
|
-
:disclaimer="DISCLAIMER"
|
|
402
|
-
/>
|
|
403
|
-
`,
|
|
404
|
-
}),
|
|
405
|
-
parameters: { docs: { source: { code: withLongTextTemplateSource } } },
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Narrow viewport preview (≈320px). Use to verify the input stays usable on
|
|
410
|
-
* small screens.
|
|
411
|
-
*/
|
|
412
|
-
export const MobileWidth: Story = {
|
|
413
|
-
render: () => ({
|
|
414
|
-
components: { CkInput },
|
|
415
|
-
setup() {
|
|
416
|
-
const text = ref('');
|
|
417
|
-
return { text, DISCLAIMER };
|
|
418
|
-
},
|
|
419
|
-
template: `
|
|
420
|
-
<div style="max-width: 320px;">
|
|
421
|
-
<CkInput
|
|
422
|
-
v-model="text"
|
|
423
|
-
:disclaimer="DISCLAIMER"
|
|
424
|
-
/>
|
|
425
|
-
</div>
|
|
426
|
-
`,
|
|
427
|
-
}),
|
|
428
|
-
decorators: [
|
|
429
|
-
() => ({
|
|
430
|
-
template: '<div style="padding: 16px;"><story /></div>',
|
|
431
|
-
}),
|
|
432
|
-
],
|
|
433
|
-
parameters: { docs: { source: { code: mobileWidthTemplateSource } } },
|
|
434
|
-
};
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import CkPromptSendButton from '../../base/CkPromptSendButton/CkPromptSendButton.vue';
|
|
3
|
-
import CkPromptStopButton from '../../base/CkPromptStopButton/CkPromptStopButton.vue';
|
|
4
|
-
import CkPromptInput from '../../base/CkPromptInput/CkPromptInput.vue';
|
|
5
|
-
import CkPromptInputDisclaimer from '../../base/CkPromptInputDisclaimer/CkPromptInputDisclaimer.vue';
|
|
6
|
-
import CkSendIcon from '../../base/icons/CkSendIcon.vue';
|
|
7
|
-
import CkStopIcon from '../../base/icons/CkStopIcon.vue';
|
|
8
|
-
import type { CkInputProps } from './types';
|
|
9
|
-
import { computed, useTemplateRef } from 'vue';
|
|
10
|
-
|
|
11
|
-
defineOptions({ name: 'CkInput' });
|
|
12
|
-
|
|
13
|
-
const props = withDefaults(defineProps<CkInputProps>(), {
|
|
14
|
-
modelValue: '',
|
|
15
|
-
placeholder: 'Ask me anything',
|
|
16
|
-
disabled: false,
|
|
17
|
-
loading: false,
|
|
18
|
-
ariaLabel: 'Chat message input',
|
|
19
|
-
stopAriaLabel: 'Stop generating',
|
|
20
|
-
disclaimer: undefined,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const emit = defineEmits<{
|
|
24
|
-
(e: 'update:modelValue', value: string): void;
|
|
25
|
-
(e: 'submit', value: string): void;
|
|
26
|
-
(e: 'stop'): void;
|
|
27
|
-
}>();
|
|
28
|
-
|
|
29
|
-
const promptInputRef =
|
|
30
|
-
useTemplateRef<InstanceType<typeof CkPromptInput>>('promptInputRef');
|
|
31
|
-
|
|
32
|
-
const isDisabled = computed(() => props.disabled || props.loading);
|
|
33
|
-
|
|
34
|
-
function onUpdateModelValue(value: string): void {
|
|
35
|
-
emit('update:modelValue', value);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function onSubmit(value: string): void {
|
|
39
|
-
emit('submit', value);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function onStop(): void {
|
|
43
|
-
emit('stop');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function focus(): void {
|
|
47
|
-
promptInputRef.value?.focus();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function submit(): void {
|
|
51
|
-
promptInputRef.value?.submit();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
defineExpose({ focus, submit });
|
|
55
|
-
</script>
|
|
56
|
-
|
|
57
|
-
<template>
|
|
58
|
-
<CkPromptInput
|
|
59
|
-
ref="promptInputRef"
|
|
60
|
-
:model-value="modelValue"
|
|
61
|
-
:placeholder="placeholder"
|
|
62
|
-
:disabled="isDisabled"
|
|
63
|
-
:aria-label="ariaLabel"
|
|
64
|
-
@update:model-value="onUpdateModelValue"
|
|
65
|
-
@submit="onSubmit"
|
|
66
|
-
>
|
|
67
|
-
<template v-if="$slots['toolbar-top']" #toolbar-top>
|
|
68
|
-
<slot name="toolbar-top" />
|
|
69
|
-
</template>
|
|
70
|
-
|
|
71
|
-
<template v-if="$slots['toolbar-left']" #toolbar-left>
|
|
72
|
-
<slot name="toolbar-left" />
|
|
73
|
-
</template>
|
|
74
|
-
|
|
75
|
-
<template #toolbar-right="scope">
|
|
76
|
-
<slot name="toolbar-right" v-bind="scope">
|
|
77
|
-
<CkPromptStopButton
|
|
78
|
-
v-if="loading"
|
|
79
|
-
:aria-label="stopAriaLabel"
|
|
80
|
-
:disabled="disabled"
|
|
81
|
-
@click="onStop"
|
|
82
|
-
>
|
|
83
|
-
<slot name="stop-icon">
|
|
84
|
-
<CkStopIcon />
|
|
85
|
-
</slot>
|
|
86
|
-
</CkPromptStopButton>
|
|
87
|
-
<CkPromptSendButton
|
|
88
|
-
v-else
|
|
89
|
-
v-bind="{ ariaLabel: 'Send message' }"
|
|
90
|
-
type="submit"
|
|
91
|
-
:disabled="scope.disabled"
|
|
92
|
-
>
|
|
93
|
-
<slot name="send-icon">
|
|
94
|
-
<CkSendIcon />
|
|
95
|
-
</slot>
|
|
96
|
-
</CkPromptSendButton>
|
|
97
|
-
</slot>
|
|
98
|
-
</template>
|
|
99
|
-
|
|
100
|
-
<template #footer>
|
|
101
|
-
<slot name="footer">
|
|
102
|
-
<CkPromptInputDisclaimer v-if="disclaimer" :text="disclaimer" />
|
|
103
|
-
</slot>
|
|
104
|
-
</template>
|
|
105
|
-
</CkPromptInput>
|
|
106
|
-
</template>
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Drop-in chat input: combines `CkPromptInput`, a `CkPromptSendButton` send
|
|
3
|
-
* button, and a `CkPromptInputDisclaimer`. Supports `v-model`, loading and
|
|
4
|
-
* disabled states, and slots to customize the toolbar and footer.
|
|
5
|
-
*
|
|
6
|
-
* @category Form Inputs
|
|
7
|
-
* @useCases chat compose input, prompt box with send button, llm input with disclaimer, quick-start chat input, turnkey chat input
|
|
8
|
-
* @keywords input, prompt, chat, send, compose, disclaimer, loading, v-model, textarea
|
|
9
|
-
* @related CkPromptInput, CkPromptSendButton, CkPromptInputDisclaimer, CkConversation
|
|
10
|
-
*/
|
|
11
|
-
export interface CkInputProps {
|
|
12
|
-
/**
|
|
13
|
-
* Current value of the input. Supports `v-model`.
|
|
14
|
-
* @default ''
|
|
15
|
-
*/
|
|
16
|
-
modelValue?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Placeholder shown when the input is empty.
|
|
19
|
-
* @default 'Ask me anything'
|
|
20
|
-
*/
|
|
21
|
-
placeholder?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Whether the input is disabled. Also implied when `loading` is `true`.
|
|
24
|
-
* @default false
|
|
25
|
-
*/
|
|
26
|
-
disabled?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Shows a spinner in the send button and disables the input while a reply
|
|
29
|
-
* is being generated.
|
|
30
|
-
* @default false
|
|
31
|
-
*/
|
|
32
|
-
loading?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Accessible label for the input.
|
|
35
|
-
* @default 'Chat message input'
|
|
36
|
-
*/
|
|
37
|
-
ariaLabel?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Accessible label for the stop generating button.
|
|
40
|
-
* @default 'Stop generating'
|
|
41
|
-
*/
|
|
42
|
-
stopAriaLabel?: string;
|
|
43
|
-
/**
|
|
44
|
-
* Optional disclaimer text rendered below the input via
|
|
45
|
-
* `CkPromptInputDisclaimer`. Omit to render no disclaimer.
|
|
46
|
-
*/
|
|
47
|
-
disclaimer?: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface CkInputEmits {
|
|
51
|
-
/** Emitted on every keystroke. */
|
|
52
|
-
(e: 'update:modelValue', value: string): void;
|
|
53
|
-
/** Emitted when the user submits via Enter or the send button. */
|
|
54
|
-
(e: 'submit', value: string): void;
|
|
55
|
-
}
|