@aleph-alpha/chat-kit 5.1.0 → 5.3.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/dist/{CkHistory.vue_vue_type_script_setup_true_lang-vlUZ_Tw1.js → CkHistory.vue_vue_type_script_setup_true_lang-BcYJmbCd.js} +154 -89
- package/dist/chat-kit.css +17 -14
- package/dist/components/base/CkEditableUserMessage/CkEditableUserMessage.stories.d.ts +12 -0
- package/dist/components/base/CkEditableUserMessage/CkEditableUserMessage.stories.d.ts.map +1 -0
- package/dist/components/base/CkEditableUserMessage/CkEditableUserMessage.vue.d.ts +22 -0
- package/dist/components/base/CkEditableUserMessage/CkEditableUserMessage.vue.d.ts.map +1 -0
- package/dist/components/base/CkEditableUserMessage/index.d.ts +3 -0
- package/dist/components/base/CkEditableUserMessage/index.d.ts.map +1 -0
- package/dist/components/base/CkEditableUserMessage/types.d.ts +30 -0
- package/dist/components/base/CkEditableUserMessage/types.d.ts.map +1 -0
- package/dist/components/base/CkPromptInput/CkPromptInput.vue.d.ts.map +1 -1
- package/dist/components/base/CkUserMessage/CkUserMessage.vue.d.ts.map +1 -1
- package/dist/components/base/CkUserMessage/types.d.ts +4 -1
- package/dist/components/base/CkUserMessage/types.d.ts.map +1 -1
- package/dist/components/base/index.d.ts +2 -0
- package/dist/components/base/index.d.ts.map +1 -1
- package/dist/components/composed/CkConversation/CkConversation.stories.d.ts +6 -0
- package/dist/components/composed/CkConversation/CkConversation.stories.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +21 -20
- package/dist/handlers/index.js +1 -1
- package/dist/handlers/useChatKitLabels.d.ts +4 -0
- package/dist/handlers/useChatKitLabels.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -22
- package/dist/{useChatKitLabels-zMFV7aEz.js → useChatKitLabels-DLy0BFx8.js} +2 -0
- package/package.json +4 -4
- package/src/components/base/CkEditableUserMessage/CkEditableUserMessage.spec.ts +53 -0
- package/src/components/base/CkEditableUserMessage/CkEditableUserMessage.stories.ts +53 -0
- package/src/components/base/CkEditableUserMessage/CkEditableUserMessage.vue +58 -0
- package/src/components/base/CkEditableUserMessage/index.ts +5 -0
- package/src/components/base/CkEditableUserMessage/types.ts +30 -0
- package/src/components/base/CkPromptInput/CkPromptInput.vue +9 -5
- package/src/components/base/CkUserMessage/CkUserMessage.vue +19 -30
- package/src/components/base/CkUserMessage/types.ts +4 -1
- package/src/components/base/index.ts +5 -0
- package/src/components/composed/CkConversation/CkConversation.stories.ts +72 -0
- package/src/components/index.ts +3 -0
- package/src/handlers/useChatKitLabels.ts +6 -0
- package/src/index.ts +3 -0
|
@@ -160,11 +160,11 @@ defineExpose({ focus, submit });
|
|
|
160
160
|
<div class="ck-prompt-root flex flex-col gap-2">
|
|
161
161
|
<form
|
|
162
162
|
:class="[
|
|
163
|
-
'border-border-surface-default bg-background-input-strong
|
|
163
|
+
'ck-prompt-form border-border-surface-default bg-background-input-strong grid items-center gap-x-0 gap-y-5 border transition-[border-radius] duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] ',
|
|
164
164
|
hasMultipleRows ? 'rounded-2xl' : 'rounded-3xl',
|
|
165
165
|
isKeyboardFocused
|
|
166
166
|
? 'border-border-surface-focus-ring ring-border-surface-focus-ring/40 ring-2'
|
|
167
|
-
: 'ck-prompt-
|
|
167
|
+
: 'ck-prompt-shadow',
|
|
168
168
|
]"
|
|
169
169
|
:style="{
|
|
170
170
|
gridTemplateColumns: 'auto 1fr auto',
|
|
@@ -222,14 +222,18 @@ defineExpose({ focus, submit });
|
|
|
222
222
|
container-type: inline-size;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
/* Solea two-layer drop shadow — warm grey + subtle orange tint. Matches the
|
|
226
|
-
`shadow/md/{1,2}` tokens from the design system; the generic `shadow-md`
|
|
227
|
-
utility from preset-wind4 uses a cold black-based shadow instead. */
|
|
228
225
|
.ck-prompt-form {
|
|
229
226
|
/* 8px (mobile) → 16px (desktop) */
|
|
230
227
|
padding: clamp(8px, calc(8px + (100cqw - 320px) * 8 / 448), 16px);
|
|
231
228
|
/* 52px → 68px (= 36px button + 2× padding) */
|
|
232
229
|
min-height: clamp(52px, calc(52px + (100cqw - 320px) * 16 / 448), 68px);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/* Solea two-layer drop shadow — warm grey + subtle orange tint. Matches the
|
|
233
|
+
`shadow/md/{1,2}` tokens from the design system; the generic `shadow-md`
|
|
234
|
+
utility from preset-wind4 uses a cold black-based shadow instead. Applied
|
|
235
|
+
only when the field is not keyboard-focused; the focus ring replaces it. */
|
|
236
|
+
.ck-prompt-shadow {
|
|
233
237
|
box-shadow:
|
|
234
238
|
0 4px 6px -2px rgba(112, 95, 90, 0.1),
|
|
235
239
|
0 6px 14px -2px rgba(248, 94, 43, 0.05);
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
defaultChatKitLabels,
|
|
4
|
-
useChatKitLabels,
|
|
5
|
-
} from '../../../handlers/useChatKitLabels';
|
|
2
|
+
import { useChatKitLabels } from '../../../handlers/useChatKitLabels';
|
|
6
3
|
import type { CkUserMessageProps } from './types';
|
|
7
|
-
import {
|
|
8
|
-
computed,
|
|
9
|
-
nextTick,
|
|
10
|
-
onBeforeUnmount,
|
|
11
|
-
onMounted,
|
|
12
|
-
ref,
|
|
13
|
-
watch,
|
|
14
|
-
} from 'vue';
|
|
4
|
+
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
|
15
5
|
|
|
16
6
|
defineOptions({ name: 'CkUserMessage' });
|
|
17
7
|
|
|
@@ -22,17 +12,8 @@ const props = withDefaults(defineProps<CkUserMessageProps>(), {
|
|
|
22
12
|
|
|
23
13
|
const labels = useChatKitLabels();
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
() =>
|
|
28
|
-
labels.value.userMessageShowMore ??
|
|
29
|
-
defaultChatKitLabels.userMessageShowMore!,
|
|
30
|
-
);
|
|
31
|
-
const showLessLabel = computed(
|
|
32
|
-
() =>
|
|
33
|
-
labels.value.userMessageShowLess ??
|
|
34
|
-
defaultChatKitLabels.userMessageShowLess!,
|
|
35
|
-
);
|
|
15
|
+
const showMoreLabel = computed(() => labels.value.userMessageShowMore);
|
|
16
|
+
const showLessLabel = computed(() => labels.value.userMessageShowLess);
|
|
36
17
|
|
|
37
18
|
/** Clamping is opt-in: only active when a positive `collapsedLines` is given. */
|
|
38
19
|
const clampEnabled = computed(() => (props.collapsedLines ?? 0) > 0);
|
|
@@ -53,13 +34,21 @@ function toggle() {
|
|
|
53
34
|
|
|
54
35
|
let resizeObserver: ResizeObserver | undefined;
|
|
55
36
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
37
|
+
function observeContent(el: HTMLElement | null) {
|
|
38
|
+
if (typeof ResizeObserver === 'undefined') return;
|
|
39
|
+
if (!resizeObserver) resizeObserver = new ResizeObserver(() => measure());
|
|
40
|
+
resizeObserver.disconnect();
|
|
41
|
+
if (el) resizeObserver.observe(el);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
watch(
|
|
45
|
+
contentRef,
|
|
46
|
+
(el) => {
|
|
47
|
+
observeContent(el);
|
|
48
|
+
nextTick(measure);
|
|
49
|
+
},
|
|
50
|
+
{ flush: 'post' },
|
|
51
|
+
);
|
|
63
52
|
|
|
64
53
|
onBeforeUnmount(() => resizeObserver?.disconnect());
|
|
65
54
|
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
* default slot for custom inline content. When `collapsedLines` is set, long
|
|
5
5
|
* messages are clamped with a fade and a "Show more" / "Show less" toggle.
|
|
6
6
|
*
|
|
7
|
+
* For an editable variant (hover/focus edit toolbar), see
|
|
8
|
+
* {@link CkEditableUserMessage}, which wraps this component.
|
|
9
|
+
*
|
|
7
10
|
* @category Messages
|
|
8
11
|
* @useCases render user message, conversation turn from user, chat input preview, right-aligned message, collapsible long message
|
|
9
12
|
* @keywords user, message, chat, conversation, turn, collapse, show more
|
|
10
|
-
* @related CkAgentMessage, CkConversation
|
|
13
|
+
* @related CkEditableUserMessage, CkAgentMessage, CkConversation
|
|
11
14
|
*/
|
|
12
15
|
export interface CkUserMessageProps {
|
|
13
16
|
/** Text content of the user message. Rendered inside the bubble when no default slot is provided. */
|
|
@@ -73,3 +73,8 @@ export { CkPromptInputDisclaimer } from './CkPromptInputDisclaimer';
|
|
|
73
73
|
export { CkRegenerateMessageButton } from './CkRegenerateMessageButton';
|
|
74
74
|
export { CkUserMessage } from './CkUserMessage';
|
|
75
75
|
export type { CkUserMessageProps } from './CkUserMessage';
|
|
76
|
+
export { CkEditableUserMessage } from './CkEditableUserMessage';
|
|
77
|
+
export type {
|
|
78
|
+
CkEditableUserMessageEmits,
|
|
79
|
+
CkEditableUserMessageProps,
|
|
80
|
+
} from './CkEditableUserMessage';
|
|
@@ -116,6 +116,34 @@ const sampleMessages: BaseMessage[] = [
|
|
|
116
116
|
},
|
|
117
117
|
];
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
* A conversation whose final assistant turn is still being generated. The
|
|
121
|
+
* message `status` of `'sending'` (or `'started'`) drives the loading icon —
|
|
122
|
+
* a spinner by default, or `agentLoadingImage` when provided.
|
|
123
|
+
*/
|
|
124
|
+
const loadingMessages: BaseMessage[] = [
|
|
125
|
+
{
|
|
126
|
+
id: '1',
|
|
127
|
+
role: 'user',
|
|
128
|
+
content: [
|
|
129
|
+
text(
|
|
130
|
+
"Find the lessons learned from the 'Digital Transformation Phase 1' project.",
|
|
131
|
+
),
|
|
132
|
+
],
|
|
133
|
+
createdAt: now,
|
|
134
|
+
status: 'completed',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: '2',
|
|
138
|
+
role: 'assistant',
|
|
139
|
+
content: [
|
|
140
|
+
{ type: 'text', id: 'a-loading', text: '', status: 'in_progress' },
|
|
141
|
+
],
|
|
142
|
+
createdAt: now,
|
|
143
|
+
status: 'sending',
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
|
|
119
147
|
const meta: Meta<typeof CkConversation> = {
|
|
120
148
|
title: 'Composed/CkConversation',
|
|
121
149
|
component: CkConversation,
|
|
@@ -248,6 +276,33 @@ const messages: BaseMessage[] = [/* ... */];
|
|
|
248
276
|
</CkConversation>
|
|
249
277
|
</template>`;
|
|
250
278
|
|
|
279
|
+
const withLoadingIconTemplateSource = `<script setup lang="ts">
|
|
280
|
+
import { CkConversation } from '@aleph-alpha/chat-kit';
|
|
281
|
+
import type { BaseMessage } from '@aleph-alpha/chat-kit';
|
|
282
|
+
|
|
283
|
+
const messages: BaseMessage[] = [
|
|
284
|
+
{
|
|
285
|
+
id: '1',
|
|
286
|
+
role: 'user',
|
|
287
|
+
content: [{ type: 'text', id: 't1', text: 'Find the lessons learned.', status: 'completed' }],
|
|
288
|
+
createdAt: new Date(),
|
|
289
|
+
status: 'completed',
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
id: '2',
|
|
293
|
+
role: 'assistant',
|
|
294
|
+
// A 'sending' / 'started' status renders the loading icon (spinner by default).
|
|
295
|
+
content: [{ type: 'text', id: 't2', text: '', status: 'in_progress' }],
|
|
296
|
+
createdAt: new Date(),
|
|
297
|
+
status: 'sending',
|
|
298
|
+
},
|
|
299
|
+
];
|
|
300
|
+
</script>
|
|
301
|
+
|
|
302
|
+
<template>
|
|
303
|
+
<CkConversation :messages="messages" agent-avatar-fallback="AI" style="height: 100%;" />
|
|
304
|
+
</template>`;
|
|
305
|
+
|
|
251
306
|
const withFooterActionsTemplateSource = `<script setup lang="ts">
|
|
252
307
|
import { ref } from 'vue';
|
|
253
308
|
import {
|
|
@@ -522,6 +577,23 @@ export const WithCustomIcon: Story = {
|
|
|
522
577
|
parameters: { docs: { source: { code: withCustomIconTemplateSource } } },
|
|
523
578
|
};
|
|
524
579
|
|
|
580
|
+
/**
|
|
581
|
+
* A conversation with an in-flight assistant reply. The final message's
|
|
582
|
+
* `status: 'sending'` swaps its avatar for the loading icon (a spinner by
|
|
583
|
+
* default; set `agent-loading-image` to show a custom loading avatar instead).
|
|
584
|
+
*/
|
|
585
|
+
export const WithLoadingIcon: Story = {
|
|
586
|
+
render: () => ({
|
|
587
|
+
components: { CkConversation },
|
|
588
|
+
setup() {
|
|
589
|
+
return { messages: loadingMessages };
|
|
590
|
+
},
|
|
591
|
+
template:
|
|
592
|
+
'<CkConversation :messages="messages" agent-avatar-fallback="AI" style="height: 100%;" />',
|
|
593
|
+
}),
|
|
594
|
+
parameters: { docs: { source: { code: withLoadingIconTemplateSource } } },
|
|
595
|
+
};
|
|
596
|
+
|
|
525
597
|
/**
|
|
526
598
|
* Overrides `#agent-message-footer` to add real action buttons next to each
|
|
527
599
|
* assistant reply: `CkCopyMessageButton` for clipboard copy and
|
package/src/components/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ export {
|
|
|
25
25
|
CkSendIcon,
|
|
26
26
|
CkStopIcon,
|
|
27
27
|
CkUserMessage,
|
|
28
|
+
CkEditableUserMessage,
|
|
28
29
|
} from './base';
|
|
29
30
|
export type {
|
|
30
31
|
CkAgentMessageHeaderProps,
|
|
@@ -61,6 +62,8 @@ export type {
|
|
|
61
62
|
CkModelSelectorEmits,
|
|
62
63
|
CkPromptMenuButtonProps,
|
|
63
64
|
CkUserMessageProps,
|
|
65
|
+
CkEditableUserMessageProps,
|
|
66
|
+
CkEditableUserMessageEmits,
|
|
64
67
|
} from './base';
|
|
65
68
|
|
|
66
69
|
// Composed (pattern) components
|
|
@@ -71,6 +71,10 @@ export type ChatKitLabels = {
|
|
|
71
71
|
userMessageShowMore?: string;
|
|
72
72
|
/** Label for the `CkUserMessage` toggle when the message is expanded. */
|
|
73
73
|
userMessageShowLess?: string;
|
|
74
|
+
/** Accessible label for the `CkEditableUserMessage` floating actions toolbar. */
|
|
75
|
+
userMessageActions?: string;
|
|
76
|
+
/** Accessible label / tooltip for the edit action in the `CkEditableUserMessage` toolbar. */
|
|
77
|
+
userMessageEditAction?: string;
|
|
74
78
|
/** Accessible label for the `CkModelSelector` trigger button. */
|
|
75
79
|
modelSelectorAriaLabel?: string;
|
|
76
80
|
/** Accessible label for the `CkModelSelector` options list. */
|
|
@@ -133,6 +137,8 @@ export const defaultChatKitLabels: ChatKitLabels = {
|
|
|
133
137
|
feedbackDialogSubmitLabel: 'Submit',
|
|
134
138
|
userMessageShowMore: 'Show more',
|
|
135
139
|
userMessageShowLess: 'Show less',
|
|
140
|
+
userMessageActions: 'Message actions',
|
|
141
|
+
userMessageEditAction: 'Edit message',
|
|
136
142
|
modelSelectorAriaLabel: 'Select model',
|
|
137
143
|
modelSelectorListAriaLabel: 'Models',
|
|
138
144
|
modelSelectorPlaceholder: 'Select model',
|
package/src/index.ts
CHANGED
|
@@ -89,6 +89,7 @@ export {
|
|
|
89
89
|
CkSendIcon,
|
|
90
90
|
CkStopIcon,
|
|
91
91
|
CkUserMessage,
|
|
92
|
+
CkEditableUserMessage,
|
|
92
93
|
} from './components';
|
|
93
94
|
export type {
|
|
94
95
|
CkAgentMessageHeaderProps,
|
|
@@ -128,6 +129,8 @@ export type {
|
|
|
128
129
|
CkModelSelectorEmits,
|
|
129
130
|
CkPromptMenuButtonProps,
|
|
130
131
|
CkUserMessageProps,
|
|
132
|
+
CkEditableUserMessageProps,
|
|
133
|
+
CkEditableUserMessageEmits,
|
|
131
134
|
} from './components';
|
|
132
135
|
|
|
133
136
|
// Helpers
|