@aleph-alpha/chat-kit 1.11.1 → 1.13.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/{CkInput.vue_vue_type_script_setup_true_lang-C1Jnn1fK.js → CkInput.vue_vue_type_script_setup_true_lang-DCZTSiBj.js} +371 -135
- package/dist/adapters/responses-api.d.ts +54 -5
- package/dist/adapters/responses-api.d.ts.map +1 -1
- package/dist/adapters/responses-api.js +43 -9
- package/dist/chat-kit.css +19 -0
- package/dist/components/base/CkFeedbackDialog/CkFeedbackDialog.stories.d.ts +30 -0
- package/dist/components/base/CkFeedbackDialog/CkFeedbackDialog.stories.d.ts.map +1 -0
- package/dist/components/base/CkFeedbackDialog/CkFeedbackDialog.vue.d.ts +13 -0
- package/dist/components/base/CkFeedbackDialog/CkFeedbackDialog.vue.d.ts.map +1 -0
- package/dist/components/base/CkFeedbackDialog/index.d.ts +3 -0
- package/dist/components/base/CkFeedbackDialog/index.d.ts.map +1 -0
- package/dist/components/base/CkFeedbackDialog/types.d.ts +152 -0
- package/dist/components/base/CkFeedbackDialog/types.d.ts.map +1 -0
- package/dist/components/base/index.d.ts +2 -0
- package/dist/components/base/index.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 +16 -15
- package/dist/composables/index.js +1 -1
- package/dist/handlers/index.js +2 -2
- package/dist/handlers/useChatKitLabels.d.ts +18 -0
- package/dist/handlers/useChatKitLabels.d.ts.map +1 -1
- package/dist/handlers/useMessageHandler.d.ts +6 -2
- package/dist/handlers/useMessageHandler.d.ts.map +1 -1
- package/dist/helpers/conversationTree.d.ts +10 -1
- package/dist/helpers/conversationTree.d.ts.map +1 -1
- package/dist/{index-BLq6_Lt2.js → index-Ct5hD214.js} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -18
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/{useChatKitLabels-ftC52m7f.js → useChatKitLabels-DeHxZG2a.js} +9 -0
- package/dist/{useMessageHandler-ZRC-gIOJ.js → useMessageHandler-CMdy-lm0.js} +36 -9
- package/package.json +5 -5
- package/src/adapters/responses-api.spec.ts +70 -0
- package/src/adapters/responses-api.ts +123 -12
- package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.spec.ts +177 -0
- package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.stories.ts +258 -0
- package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.vue +288 -0
- package/src/components/base/CkFeedbackDialog/index.ts +2 -0
- package/src/components/base/CkFeedbackDialog/types.ts +155 -0
- package/src/components/base/index.ts +8 -0
- package/src/components/index.ts +6 -0
- package/src/handlers/useChatKitLabels.spec.ts +11 -0
- package/src/handlers/useChatKitLabels.ts +29 -0
- package/src/handlers/useMessageHandler.spec.ts +214 -0
- package/src/handlers/useMessageHandler.ts +28 -3
- package/src/helpers/conversationTree.spec.ts +134 -0
- package/src/helpers/conversationTree.ts +32 -1
- package/src/index.ts +7 -0
- package/src/types.ts +15 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
defaultChatKitLabels,
|
|
4
|
+
useChatKitLabels,
|
|
5
|
+
} from '../../../handlers/useChatKitLabels';
|
|
6
|
+
import { CkMarkdownRenderer } from '../CkMarkdownRenderer';
|
|
7
|
+
import type {
|
|
8
|
+
CkFeedbackDialogProps,
|
|
9
|
+
CkFeedbackDialogSubmitPayload,
|
|
10
|
+
} from './types';
|
|
11
|
+
import {
|
|
12
|
+
UiButton,
|
|
13
|
+
UiDialog,
|
|
14
|
+
UiDialogContent,
|
|
15
|
+
UiDialogDescription,
|
|
16
|
+
UiField,
|
|
17
|
+
UiFieldLabel,
|
|
18
|
+
UiTextarea,
|
|
19
|
+
UiToggleGroup,
|
|
20
|
+
UiToggleGroupItem,
|
|
21
|
+
} from '@aleph-alpha/ui-library';
|
|
22
|
+
import { computed, ref, useId, watch } from 'vue';
|
|
23
|
+
|
|
24
|
+
defineOptions({
|
|
25
|
+
name: 'CkFeedbackDialog',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
open = false,
|
|
30
|
+
sentiment,
|
|
31
|
+
responseText = '',
|
|
32
|
+
reasons,
|
|
33
|
+
maxFreeTextLength = 250,
|
|
34
|
+
submitting = false,
|
|
35
|
+
disabled = false,
|
|
36
|
+
titlePositive,
|
|
37
|
+
titleNegative,
|
|
38
|
+
responseHeading: responseHeadingProp,
|
|
39
|
+
description: descriptionProp,
|
|
40
|
+
otherLabel: otherLabelProp,
|
|
41
|
+
otherTooltip: otherTooltipProp,
|
|
42
|
+
freeTextPlaceholder: freeTextPlaceholderProp,
|
|
43
|
+
cancelLabel: cancelLabelProp,
|
|
44
|
+
submitLabel: submitLabelProp,
|
|
45
|
+
} = defineProps<CkFeedbackDialogProps>();
|
|
46
|
+
|
|
47
|
+
const emit = defineEmits<{
|
|
48
|
+
'update:open': [open: boolean];
|
|
49
|
+
submit: [payload: CkFeedbackDialogSubmitPayload];
|
|
50
|
+
cancel: [];
|
|
51
|
+
}>();
|
|
52
|
+
|
|
53
|
+
const labels = useChatKitLabels();
|
|
54
|
+
|
|
55
|
+
const title = computed(() => {
|
|
56
|
+
if (sentiment === 'positive') {
|
|
57
|
+
return (
|
|
58
|
+
titlePositive ??
|
|
59
|
+
labels.value.feedbackDialogTitlePositive ??
|
|
60
|
+
defaultChatKitLabels.feedbackDialogTitlePositive!
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return (
|
|
64
|
+
titleNegative ??
|
|
65
|
+
labels.value.feedbackDialogTitleNegative ??
|
|
66
|
+
defaultChatKitLabels.feedbackDialogTitleNegative!
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
const responseHeading = computed(
|
|
70
|
+
() =>
|
|
71
|
+
responseHeadingProp ??
|
|
72
|
+
labels.value.feedbackDialogResponseHeading ??
|
|
73
|
+
defaultChatKitLabels.feedbackDialogResponseHeading!,
|
|
74
|
+
);
|
|
75
|
+
const description = computed(
|
|
76
|
+
() =>
|
|
77
|
+
descriptionProp ??
|
|
78
|
+
labels.value.feedbackDialogDescription ??
|
|
79
|
+
defaultChatKitLabels.feedbackDialogDescription!,
|
|
80
|
+
);
|
|
81
|
+
const otherLabel = computed(
|
|
82
|
+
() =>
|
|
83
|
+
otherLabelProp ??
|
|
84
|
+
labels.value.feedbackDialogOtherLabel ??
|
|
85
|
+
defaultChatKitLabels.feedbackDialogOtherLabel!,
|
|
86
|
+
);
|
|
87
|
+
const otherTooltip = computed(
|
|
88
|
+
() =>
|
|
89
|
+
otherTooltipProp ??
|
|
90
|
+
labels.value.feedbackDialogOtherTooltip ??
|
|
91
|
+
defaultChatKitLabels.feedbackDialogOtherTooltip!,
|
|
92
|
+
);
|
|
93
|
+
const freeTextPlaceholder = computed(
|
|
94
|
+
() =>
|
|
95
|
+
freeTextPlaceholderProp ??
|
|
96
|
+
labels.value.feedbackDialogFreeTextPlaceholder ??
|
|
97
|
+
defaultChatKitLabels.feedbackDialogFreeTextPlaceholder!,
|
|
98
|
+
);
|
|
99
|
+
const cancelLabel = computed(
|
|
100
|
+
() =>
|
|
101
|
+
cancelLabelProp ??
|
|
102
|
+
labels.value.feedbackDialogCancelLabel ??
|
|
103
|
+
defaultChatKitLabels.feedbackDialogCancelLabel!,
|
|
104
|
+
);
|
|
105
|
+
const submitLabel = computed(
|
|
106
|
+
() =>
|
|
107
|
+
submitLabelProp ??
|
|
108
|
+
labels.value.feedbackDialogSubmitLabel ??
|
|
109
|
+
defaultChatKitLabels.feedbackDialogSubmitLabel!,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const selectedReason = ref('');
|
|
113
|
+
const freeText = ref('');
|
|
114
|
+
|
|
115
|
+
// Per-instance id so the label/textarea association stays correct even when
|
|
116
|
+
// several dialogs are mounted at once.
|
|
117
|
+
const freeTextId = useId();
|
|
118
|
+
|
|
119
|
+
watch(
|
|
120
|
+
() => open,
|
|
121
|
+
(isOpen, wasOpen) => {
|
|
122
|
+
if (isOpen && !wasOpen) {
|
|
123
|
+
selectedReason.value = '';
|
|
124
|
+
freeText.value = '';
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const showResponseColumn = computed(
|
|
130
|
+
() => typeof responseText === 'string' && responseText !== '',
|
|
131
|
+
);
|
|
132
|
+
const characterCount = computed(() => freeText.value.length);
|
|
133
|
+
const canSubmit = computed(
|
|
134
|
+
() =>
|
|
135
|
+
!disabled &&
|
|
136
|
+
!submitting &&
|
|
137
|
+
(selectedReason.value !== '' || freeText.value.trim() !== ''),
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
function handleOpenChange(next: boolean): void {
|
|
141
|
+
// While submitting/disabled the dialog is non-interactive, so ignore
|
|
142
|
+
// reka-ui's close requests (ESC / outside-click / close icon). `open` is
|
|
143
|
+
// controlled, so not emitting keeps it open until the host closes it.
|
|
144
|
+
if (!next && (submitting || disabled)) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
emit('update:open', next);
|
|
148
|
+
// reka-ui emits update:open(false) on ESC / outside-click / close icon —
|
|
149
|
+
// surface those as `cancel` too.
|
|
150
|
+
if (!next && open) {
|
|
151
|
+
emit('cancel');
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function handleCancel(): void {
|
|
156
|
+
if (disabled || submitting) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
emit('cancel');
|
|
160
|
+
emit('update:open', false);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function handleSubmit(): void {
|
|
164
|
+
if (!canSubmit.value) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
emit('submit', {
|
|
168
|
+
sentiment,
|
|
169
|
+
reason: selectedReason.value === '' ? null : selectedReason.value,
|
|
170
|
+
reasonText: freeText.value.trim(),
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
</script>
|
|
174
|
+
|
|
175
|
+
<template>
|
|
176
|
+
<UiDialog :open="open" @update:open="handleOpenChange">
|
|
177
|
+
<UiDialogContent
|
|
178
|
+
:title="title"
|
|
179
|
+
max-width="max-w-4xl"
|
|
180
|
+
class="ck-feedback-dialog"
|
|
181
|
+
:show-close-button="!(submitting || disabled)"
|
|
182
|
+
>
|
|
183
|
+
<UiDialogDescription class="sr-only">
|
|
184
|
+
{{ description }}
|
|
185
|
+
</UiDialogDescription>
|
|
186
|
+
<div
|
|
187
|
+
:class="[
|
|
188
|
+
'grid gap-12',
|
|
189
|
+
showResponseColumn ? 'grid-cols-2' : 'grid-cols-1',
|
|
190
|
+
]"
|
|
191
|
+
>
|
|
192
|
+
<section v-if="showResponseColumn" class="flex min-h-0 flex-col gap-2">
|
|
193
|
+
<UiFieldLabel>{{ responseHeading }}</UiFieldLabel>
|
|
194
|
+
<div
|
|
195
|
+
class="ck-feedback-dialog__response min-h-0 flex-1 overflow-y-auto rounded-md border border-input bg-background-input-default px-3 py-2 shadow-xs"
|
|
196
|
+
>
|
|
197
|
+
<CkMarkdownRenderer :content="responseText" />
|
|
198
|
+
</div>
|
|
199
|
+
</section>
|
|
200
|
+
|
|
201
|
+
<section class="flex min-h-0 flex-col gap-4">
|
|
202
|
+
<UiToggleGroup
|
|
203
|
+
v-model="selectedReason"
|
|
204
|
+
type="single"
|
|
205
|
+
variant="outline"
|
|
206
|
+
:disabled="disabled || submitting"
|
|
207
|
+
class="grid grid-cols-2 gap-4"
|
|
208
|
+
:aria-label="title"
|
|
209
|
+
>
|
|
210
|
+
<UiToggleGroupItem
|
|
211
|
+
v-for="reason in reasons"
|
|
212
|
+
:key="reason.code"
|
|
213
|
+
:value="reason.code"
|
|
214
|
+
class="ck-feedback-dialog__chip"
|
|
215
|
+
>
|
|
216
|
+
{{ reason.label }}
|
|
217
|
+
</UiToggleGroupItem>
|
|
218
|
+
</UiToggleGroup>
|
|
219
|
+
|
|
220
|
+
<UiField>
|
|
221
|
+
<UiFieldLabel :for="freeTextId" :tooltip="otherTooltip">
|
|
222
|
+
{{ otherLabel }}
|
|
223
|
+
</UiFieldLabel>
|
|
224
|
+
<UiTextarea
|
|
225
|
+
:id="freeTextId"
|
|
226
|
+
v-model="freeText"
|
|
227
|
+
name="ck-feedback-dialog-free-text"
|
|
228
|
+
:placeholder="freeTextPlaceholder"
|
|
229
|
+
:disabled="disabled || submitting"
|
|
230
|
+
:maxlength="maxFreeTextLength"
|
|
231
|
+
rows="3"
|
|
232
|
+
/>
|
|
233
|
+
<div
|
|
234
|
+
class="self-end text-sm text-content-on-surface-muted tabular-nums"
|
|
235
|
+
aria-live="polite"
|
|
236
|
+
>
|
|
237
|
+
{{ characterCount }}/{{ maxFreeTextLength }}
|
|
238
|
+
</div>
|
|
239
|
+
</UiField>
|
|
240
|
+
</section>
|
|
241
|
+
</div>
|
|
242
|
+
|
|
243
|
+
<template #actions>
|
|
244
|
+
<UiButton
|
|
245
|
+
type="button"
|
|
246
|
+
variant="outline"
|
|
247
|
+
:aria-label="cancelLabel"
|
|
248
|
+
:disabled="disabled || submitting"
|
|
249
|
+
@click="handleCancel"
|
|
250
|
+
>
|
|
251
|
+
{{ cancelLabel }}
|
|
252
|
+
</UiButton>
|
|
253
|
+
<UiButton
|
|
254
|
+
type="button"
|
|
255
|
+
variant="default"
|
|
256
|
+
:aria-label="submitLabel"
|
|
257
|
+
:loading="submitting"
|
|
258
|
+
:disabled="!canSubmit"
|
|
259
|
+
@click="handleSubmit"
|
|
260
|
+
>
|
|
261
|
+
{{ submitLabel }}
|
|
262
|
+
</UiButton>
|
|
263
|
+
</template>
|
|
264
|
+
</UiDialogContent>
|
|
265
|
+
</UiDialog>
|
|
266
|
+
</template>
|
|
267
|
+
|
|
268
|
+
<style scoped>
|
|
269
|
+
.ck-feedback-dialog__chip {
|
|
270
|
+
width: 100%;
|
|
271
|
+
min-height: 36px;
|
|
272
|
+
height: auto;
|
|
273
|
+
justify-content: center;
|
|
274
|
+
text-align: center;
|
|
275
|
+
line-height: 1rem;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.ck-feedback-dialog__response :deep(p),
|
|
279
|
+
.ck-feedback-dialog__response :deep(li) {
|
|
280
|
+
line-height: 1.5rem;
|
|
281
|
+
}
|
|
282
|
+
.ck-feedback-dialog__response :deep(p) {
|
|
283
|
+
margin: 0 0 0.5rem 0;
|
|
284
|
+
}
|
|
285
|
+
.ck-feedback-dialog__response :deep(p:last-child) {
|
|
286
|
+
margin-bottom: 0;
|
|
287
|
+
}
|
|
288
|
+
</style>
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modal dialog for collecting qualitative feedback on an assistant response.
|
|
3
|
+
* Opened after a binary thumbs-up / thumbs-down click (see `CkFeedbackButton`),
|
|
4
|
+
* it lets the user pick a single reason code and add an optional free-text
|
|
5
|
+
* comment, then submit both alongside the original sentiment.
|
|
6
|
+
*
|
|
7
|
+
* One reason per submission: the backend (feedback-kit) stores a single
|
|
8
|
+
* `reason` enum per response, so the dialog is single-select by design.
|
|
9
|
+
*
|
|
10
|
+
* Fully prop-driven: the host application owns `open`, the list of reasons to
|
|
11
|
+
* show (fetched from `GET /feedback/config`), the response text to display, and
|
|
12
|
+
* the submission handler. The component only manages transient form state (the
|
|
13
|
+
* selected reason and free-text value) until the user submits or cancels.
|
|
14
|
+
*
|
|
15
|
+
* @category Feedback
|
|
16
|
+
* @useCases collect qualitative feedback, gather a reason code for a response,
|
|
17
|
+
* capture a free-text comment, drive a two-step rating flow
|
|
18
|
+
* @keywords feedback, dialog, modal, reason codes, free text, qualitative,
|
|
19
|
+
* rating, comment
|
|
20
|
+
* @related CkFeedbackButton, CkMessageActionButton, CkAgentMessage,
|
|
21
|
+
* CkConversation, UiDialog, UiToggleGroup
|
|
22
|
+
*/
|
|
23
|
+
export type CkFeedbackSentiment = 'positive' | 'negative';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A selectable reason: `code` is the stable machine value submitted to the
|
|
27
|
+
* backend; `label` is the human-readable string shown on the chip. Both come
|
|
28
|
+
* from the backend's `GET /feedback/config` so the UI never drifts from what
|
|
29
|
+
* the backend accepts.
|
|
30
|
+
*/
|
|
31
|
+
export interface CkFeedbackReason {
|
|
32
|
+
code: string;
|
|
33
|
+
label: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface CkFeedbackDialogSubmitPayload {
|
|
37
|
+
/** The sentiment the dialog was opened for. */
|
|
38
|
+
sentiment: CkFeedbackSentiment;
|
|
39
|
+
/** The selected reason `code`, or `null` if the user only left free text. */
|
|
40
|
+
reason: string | null;
|
|
41
|
+
/** Free-text comment, trimmed. Empty string when the user typed nothing. */
|
|
42
|
+
reasonText: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface CkFeedbackDialogProps {
|
|
46
|
+
/**
|
|
47
|
+
* Controlled open state. Use with `v-model:open`. When `true` the dialog is
|
|
48
|
+
* visible and form state is editable; when `false` the dialog is closed.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
open?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Which sentiment the user gave before this dialog opened. Drives the title
|
|
54
|
+
* ("Give positive feedback" vs "Give negative feedback") and is echoed back
|
|
55
|
+
* on submit.
|
|
56
|
+
*/
|
|
57
|
+
sentiment: CkFeedbackSentiment;
|
|
58
|
+
/**
|
|
59
|
+
* The assistant response being rated. Rendered as markdown in the left
|
|
60
|
+
* column so the user can see what they're giving feedback on. Omit (or pass
|
|
61
|
+
* an empty string) to hide the response column entirely.
|
|
62
|
+
* @default undefined
|
|
63
|
+
*/
|
|
64
|
+
responseText?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Available reasons to render as single-select chips. The host fetches the
|
|
67
|
+
* appropriate per-sentiment list from `GET /feedback/config` and passes it
|
|
68
|
+
* here. The chip shows `label`; the selected `code` is emitted on submit.
|
|
69
|
+
*/
|
|
70
|
+
reasons: CkFeedbackReason[];
|
|
71
|
+
/**
|
|
72
|
+
* Maximum length for the free-text input. The browser will hard-limit the
|
|
73
|
+
* field via the native `maxlength` attribute, and a "x/max" counter is
|
|
74
|
+
* shown beneath the textarea.
|
|
75
|
+
* @default 250
|
|
76
|
+
*/
|
|
77
|
+
maxFreeTextLength?: number;
|
|
78
|
+
/**
|
|
79
|
+
* When `true`, the Submit button shows a busy state and clicks are ignored.
|
|
80
|
+
* Use while the parent is awaiting the backend POST.
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
submitting?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* When `true`, both Submit and Cancel are non-interactive. Primarily used
|
|
86
|
+
* to keep the dialog frozen while showing a confirmation or error state
|
|
87
|
+
* before the host closes it.
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
disabled?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Overrides the injected dialog title for positive feedback. Defaults to
|
|
93
|
+
* `useChatKitLabels().feedbackDialogTitlePositive`.
|
|
94
|
+
*/
|
|
95
|
+
titlePositive?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Overrides the injected dialog title for negative feedback. Defaults to
|
|
98
|
+
* `useChatKitLabels().feedbackDialogTitleNegative`.
|
|
99
|
+
*/
|
|
100
|
+
titleNegative?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Overrides the injected "Response" heading shown above the response
|
|
103
|
+
* preview column. Defaults to `useChatKitLabels().feedbackDialogResponseHeading`.
|
|
104
|
+
*/
|
|
105
|
+
responseHeading?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Screen-reader description for the dialog (sets `aria-describedby`; not
|
|
108
|
+
* shown visually). Defaults to `useChatKitLabels().feedbackDialogDescription`.
|
|
109
|
+
*/
|
|
110
|
+
description?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Overrides the injected "Other" label above the free-text input.
|
|
113
|
+
* Defaults to `useChatKitLabels().feedbackDialogOtherLabel`.
|
|
114
|
+
*/
|
|
115
|
+
otherLabel?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Tooltip text shown when the user hovers the (i) icon next to the "Other"
|
|
118
|
+
* label. Defaults to `useChatKitLabels().feedbackDialogOtherTooltip`.
|
|
119
|
+
*/
|
|
120
|
+
otherTooltip?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Placeholder text for the free-text input. Defaults to
|
|
123
|
+
* `useChatKitLabels().feedbackDialogFreeTextPlaceholder`.
|
|
124
|
+
*/
|
|
125
|
+
freeTextPlaceholder?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Label for the Cancel button. Defaults to
|
|
128
|
+
* `useChatKitLabels().feedbackDialogCancelLabel`.
|
|
129
|
+
*/
|
|
130
|
+
cancelLabel?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Label for the Submit button. Defaults to
|
|
133
|
+
* `useChatKitLabels().feedbackDialogSubmitLabel`.
|
|
134
|
+
*/
|
|
135
|
+
submitLabel?: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface CkFeedbackDialogEmits {
|
|
139
|
+
/**
|
|
140
|
+
* Two-way binding for the `open` prop. Emitted when the dialog requests to
|
|
141
|
+
* be closed (Cancel button, close icon, ESC, or outside click).
|
|
142
|
+
*/
|
|
143
|
+
(e: 'update:open', open: boolean): void;
|
|
144
|
+
/**
|
|
145
|
+
* Emitted when the user clicks Submit. The host should persist the payload
|
|
146
|
+
* (e.g. POST to `/feedback/`) then close the dialog by setting `open` to
|
|
147
|
+
* `false`. Not emitted while `submitting` or `disabled`.
|
|
148
|
+
*/
|
|
149
|
+
(e: 'submit', payload: CkFeedbackDialogSubmitPayload): void;
|
|
150
|
+
/**
|
|
151
|
+
* Emitted when the user clicks Cancel or otherwise dismisses the dialog
|
|
152
|
+
* without submitting (close icon, ESC, outside click).
|
|
153
|
+
*/
|
|
154
|
+
(e: 'cancel'): void;
|
|
155
|
+
}
|
|
@@ -8,6 +8,14 @@ export type {
|
|
|
8
8
|
CkFeedbackButtonProps,
|
|
9
9
|
CkFeedbackValue,
|
|
10
10
|
} from './CkFeedbackButton';
|
|
11
|
+
export { CkFeedbackDialog } from './CkFeedbackDialog';
|
|
12
|
+
export type {
|
|
13
|
+
CkFeedbackDialogProps,
|
|
14
|
+
CkFeedbackDialogEmits,
|
|
15
|
+
CkFeedbackDialogSubmitPayload,
|
|
16
|
+
CkFeedbackReason,
|
|
17
|
+
CkFeedbackSentiment,
|
|
18
|
+
} from './CkFeedbackDialog';
|
|
11
19
|
export { CkFileItemsList } from './CkFileItemsList';
|
|
12
20
|
export type {
|
|
13
21
|
CkFileEntry,
|
package/src/components/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export {
|
|
|
4
4
|
CkConversationLayout,
|
|
5
5
|
CkCopyMessageActionButton,
|
|
6
6
|
CkFeedbackButton,
|
|
7
|
+
CkFeedbackDialog,
|
|
7
8
|
CkFileItemsList,
|
|
8
9
|
CkHistoryItem,
|
|
9
10
|
CkHistoryWrapper,
|
|
@@ -20,6 +21,11 @@ export {
|
|
|
20
21
|
export type {
|
|
21
22
|
CkConversationLayoutProps,
|
|
22
23
|
CkFeedbackButtonProps,
|
|
24
|
+
CkFeedbackDialogEmits,
|
|
25
|
+
CkFeedbackDialogProps,
|
|
26
|
+
CkFeedbackDialogSubmitPayload,
|
|
27
|
+
CkFeedbackReason,
|
|
28
|
+
CkFeedbackSentiment,
|
|
23
29
|
CkFeedbackValue,
|
|
24
30
|
CkFileEntry,
|
|
25
31
|
CkFileItemsListEmits,
|
|
@@ -43,6 +43,17 @@ describe('useChatKitLabels', () => {
|
|
|
43
43
|
feedbackThumbsUp: 'Gute Antwort',
|
|
44
44
|
feedbackThumbsDown: 'Schlechte Antwort',
|
|
45
45
|
feedbackGroup: 'Antwort bewerten',
|
|
46
|
+
feedbackDialogTitlePositive: 'Positives Feedback geben',
|
|
47
|
+
feedbackDialogTitleNegative: 'Negatives Feedback geben',
|
|
48
|
+
feedbackDialogResponseHeading: 'Antwort',
|
|
49
|
+
feedbackDialogDescription:
|
|
50
|
+
'Wählen Sie einen Grund und fügen Sie optional einen Kommentar hinzu.',
|
|
51
|
+
feedbackDialogOtherLabel: 'Sonstiges',
|
|
52
|
+
feedbackDialogOtherTooltip:
|
|
53
|
+
'Teilen Sie weitere Details zu dieser Antwort mit.',
|
|
54
|
+
feedbackDialogFreeTextPlaceholder: 'Zusätzliche Details eingeben',
|
|
55
|
+
feedbackDialogCancelLabel: 'Abbrechen',
|
|
56
|
+
feedbackDialogSubmitLabel: 'Senden',
|
|
46
57
|
historyItemUntitled: 'Unbenannte Konversation',
|
|
47
58
|
historyItemActionAriaLabel: 'Konversationsoptionen',
|
|
48
59
|
historyItemEditAction: 'Bearbeiten',
|
|
@@ -47,6 +47,24 @@ export type ChatKitLabels = {
|
|
|
47
47
|
* `defaultChatKitLabels.feedbackGroup` when omitted.
|
|
48
48
|
*/
|
|
49
49
|
feedbackGroup?: string;
|
|
50
|
+
/** `CkFeedbackDialog` title when sentiment is `'positive'`. */
|
|
51
|
+
feedbackDialogTitlePositive?: string;
|
|
52
|
+
/** `CkFeedbackDialog` title when sentiment is `'negative'`. */
|
|
53
|
+
feedbackDialogTitleNegative?: string;
|
|
54
|
+
/** Heading above the response preview in `CkFeedbackDialog`. */
|
|
55
|
+
feedbackDialogResponseHeading?: string;
|
|
56
|
+
/** Screen-reader description for `CkFeedbackDialog` (sets `aria-describedby`). */
|
|
57
|
+
feedbackDialogDescription?: string;
|
|
58
|
+
/** "Other" label above the free-text input in `CkFeedbackDialog`. */
|
|
59
|
+
feedbackDialogOtherLabel?: string;
|
|
60
|
+
/** Tooltip on the (i) icon next to "Other" in `CkFeedbackDialog`. */
|
|
61
|
+
feedbackDialogOtherTooltip?: string;
|
|
62
|
+
/** Placeholder for the free-text input in `CkFeedbackDialog`. */
|
|
63
|
+
feedbackDialogFreeTextPlaceholder?: string;
|
|
64
|
+
/** Cancel button label in `CkFeedbackDialog`. */
|
|
65
|
+
feedbackDialogCancelLabel?: string;
|
|
66
|
+
/** Submit button label in `CkFeedbackDialog`. */
|
|
67
|
+
feedbackDialogSubmitLabel?: string;
|
|
50
68
|
/** Fallback title used by `CkHistory` when a conversation has no `title`. */
|
|
51
69
|
historyItemUntitled: string;
|
|
52
70
|
/** Accessible name for the trailing kebab trigger on each `CkHistory` row. */
|
|
@@ -67,6 +85,17 @@ export const defaultChatKitLabels: ChatKitLabels = {
|
|
|
67
85
|
feedbackThumbsUp: 'Good response',
|
|
68
86
|
feedbackThumbsDown: 'Bad response',
|
|
69
87
|
feedbackGroup: 'Rate this response',
|
|
88
|
+
feedbackDialogTitlePositive: 'Give positive feedback',
|
|
89
|
+
feedbackDialogTitleNegative: 'Give negative feedback',
|
|
90
|
+
feedbackDialogResponseHeading: 'Response',
|
|
91
|
+
feedbackDialogDescription:
|
|
92
|
+
'Select a reason and optionally add a comment, then submit your feedback.',
|
|
93
|
+
feedbackDialogOtherLabel: 'Other',
|
|
94
|
+
feedbackDialogOtherTooltip:
|
|
95
|
+
'Add anything else you want to share about this response.',
|
|
96
|
+
feedbackDialogFreeTextPlaceholder: 'Write down some additional details',
|
|
97
|
+
feedbackDialogCancelLabel: 'Cancel',
|
|
98
|
+
feedbackDialogSubmitLabel: 'Submit',
|
|
70
99
|
historyItemUntitled: 'Untitled conversation',
|
|
71
100
|
historyItemActionAriaLabel: 'Conversation options',
|
|
72
101
|
historyItemEditAction: 'Edit',
|