@aleph-alpha/chat-kit 1.12.0 → 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.
Files changed (33) hide show
  1. package/dist/{CkInput.vue_vue_type_script_setup_true_lang-C1Jnn1fK.js → CkInput.vue_vue_type_script_setup_true_lang-DCZTSiBj.js} +371 -135
  2. package/dist/chat-kit.css +19 -0
  3. package/dist/components/base/CkFeedbackDialog/CkFeedbackDialog.stories.d.ts +30 -0
  4. package/dist/components/base/CkFeedbackDialog/CkFeedbackDialog.stories.d.ts.map +1 -0
  5. package/dist/components/base/CkFeedbackDialog/CkFeedbackDialog.vue.d.ts +13 -0
  6. package/dist/components/base/CkFeedbackDialog/CkFeedbackDialog.vue.d.ts.map +1 -0
  7. package/dist/components/base/CkFeedbackDialog/index.d.ts +3 -0
  8. package/dist/components/base/CkFeedbackDialog/index.d.ts.map +1 -0
  9. package/dist/components/base/CkFeedbackDialog/types.d.ts +152 -0
  10. package/dist/components/base/CkFeedbackDialog/types.d.ts.map +1 -0
  11. package/dist/components/base/index.d.ts +2 -0
  12. package/dist/components/base/index.d.ts.map +1 -1
  13. package/dist/components/index.d.ts +2 -2
  14. package/dist/components/index.d.ts.map +1 -1
  15. package/dist/components/index.js +16 -15
  16. package/dist/handlers/index.js +1 -1
  17. package/dist/handlers/useChatKitLabels.d.ts +18 -0
  18. package/dist/handlers/useChatKitLabels.d.ts.map +1 -1
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +17 -16
  22. package/dist/{useChatKitLabels-ftC52m7f.js → useChatKitLabels-DeHxZG2a.js} +9 -0
  23. package/package.json +5 -5
  24. package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.spec.ts +177 -0
  25. package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.stories.ts +258 -0
  26. package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.vue +288 -0
  27. package/src/components/base/CkFeedbackDialog/index.ts +2 -0
  28. package/src/components/base/CkFeedbackDialog/types.ts +155 -0
  29. package/src/components/base/index.ts +8 -0
  30. package/src/components/index.ts +6 -0
  31. package/src/handlers/useChatKitLabels.spec.ts +11 -0
  32. package/src/handlers/useChatKitLabels.ts +29 -0
  33. package/src/index.ts +6 -0
@@ -1,7 +1,7 @@
1
- import { defineComponent, openBlock, createElementBlock, createElementVNode, renderSlot, createCommentVNode, ref, onMounted, nextTick, onUnmounted, watch, Fragment, renderList, normalizeStyle, createBlock, unref, mergeProps, withCtx, createVNode, Transition, toDisplayString, computed, normalizeClass, useAttrs, useSlots, withModifiers, resolveDynamicComponent, toRefs, h, useId, useTemplateRef, createTextVNode, createSlots, normalizeProps, guardReactiveProps } from "vue";
2
- import { u as useChatKitLabels, d as defaultChatKitLabels, a as useMarkdownParser } from "./useChatKitLabels-ftC52m7f.js";
3
- import { UiButton, UiTooltip, UiIcon, UiFileItem, UiPopover, UiPopoverTrigger, UiFileType, UiPopoverContent, Primitive, UiAvatar, UiAvatarImage, UiSpinner, UiAvatarFallback, UiSidebarPopoverMenu, UiSidebarPopoverMenuItem } from "@aleph-alpha/ui-library";
4
- const _hoisted_1$a = {
1
+ import { defineComponent, openBlock, createElementBlock, createElementVNode, renderSlot, createCommentVNode, ref, onMounted, nextTick, onUnmounted, watch, Fragment, renderList, normalizeStyle, createBlock, unref, mergeProps, withCtx, createVNode, Transition, toDisplayString, computed, normalizeClass, toRefs, h, useId, createTextVNode, useAttrs, useSlots, withModifiers, resolveDynamicComponent, useTemplateRef, createSlots, normalizeProps, guardReactiveProps } from "vue";
2
+ import { u as useChatKitLabels, d as defaultChatKitLabels, a as useMarkdownParser } from "./useChatKitLabels-DeHxZG2a.js";
3
+ import { UiButton, UiTooltip, UiIcon, UiDialog, UiDialogContent, UiDialogDescription, UiFieldLabel, UiToggleGroup, UiToggleGroupItem, UiField, UiTextarea, UiFileItem, UiPopover, UiPopoverTrigger, UiFileType, UiPopoverContent, Primitive, UiAvatar, UiAvatarImage, UiSpinner, UiAvatarFallback, UiSidebarPopoverMenu, UiSidebarPopoverMenuItem } from "@aleph-alpha/ui-library";
4
+ const _hoisted_1$b = {
5
5
  xmlns: "http://www.w3.org/2000/svg",
6
6
  width: "16",
7
7
  height: "16",
@@ -12,31 +12,31 @@ const _hoisted_1$a = {
12
12
  "stroke-linecap": "round",
13
13
  "stroke-linejoin": "round"
14
14
  };
15
- const _sfc_main$j = /* @__PURE__ */ defineComponent({
15
+ const _sfc_main$k = /* @__PURE__ */ defineComponent({
16
16
  ...{ name: "CkSendIcon" },
17
17
  __name: "CkSendIcon",
18
18
  setup(__props) {
19
19
  return (_ctx, _cache) => {
20
- return openBlock(), createElementBlock("svg", _hoisted_1$a, [..._cache[0] || (_cache[0] = [
20
+ return openBlock(), createElementBlock("svg", _hoisted_1$b, [..._cache[0] || (_cache[0] = [
21
21
  createElementVNode("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" }, null, -1),
22
22
  createElementVNode("path", { d: "M6 12h16" }, null, -1)
23
23
  ])]);
24
24
  };
25
25
  }
26
26
  });
27
- const _hoisted_1$9 = {
27
+ const _hoisted_1$a = {
28
28
  xmlns: "http://www.w3.org/2000/svg",
29
29
  width: "16",
30
30
  height: "16",
31
31
  viewBox: "0 0 16 16",
32
32
  fill: "none"
33
33
  };
34
- const _sfc_main$i = /* @__PURE__ */ defineComponent({
34
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
35
35
  ...{ name: "CkStopIcon" },
36
36
  __name: "CkStopIcon",
37
37
  setup(__props) {
38
38
  return (_ctx, _cache) => {
39
- return openBlock(), createElementBlock("svg", _hoisted_1$9, [..._cache[0] || (_cache[0] = [
39
+ return openBlock(), createElementBlock("svg", _hoisted_1$a, [..._cache[0] || (_cache[0] = [
40
40
  createElementVNode("path", {
41
41
  d: "M13.3335 3.33301C13.3335 2.96482 13.035 2.66634 12.6668 2.66634H3.3335C2.96531 2.66634 2.66683 2.96482 2.66683 3.33301V12.6663C2.66683 13.0345 2.96531 13.333 3.3335 13.333H12.6668C13.035 13.333 13.3335 13.0345 13.3335 12.6663V3.33301ZM14.6668 12.6663C14.6668 13.7709 13.7714 14.6663 12.6668 14.6663H3.3335C2.22893 14.6663 1.3335 13.7709 1.3335 12.6663V3.33301C1.3335 2.22844 2.22893 1.33301 3.3335 1.33301H12.6668C13.7714 1.33301 14.6668 2.22844 14.6668 3.33301V12.6663Z",
42
42
  fill: "#1D1D1B"
@@ -45,13 +45,13 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
45
45
  };
46
46
  }
47
47
  });
48
- const _hoisted_1$8 = { class: "flex w-full items-start gap-2" };
49
- const _hoisted_2$5 = {
48
+ const _hoisted_1$9 = { class: "flex w-full items-start gap-2" };
49
+ const _hoisted_2$6 = {
50
50
  key: 0,
51
51
  class: "flex flex-shrink-0 items-center justify-center"
52
52
  };
53
- const _hoisted_3$4 = { class: "text-core-content-primary flex min-w-0 flex-1 flex-col gap-2" };
54
- const _hoisted_4$3 = {
53
+ const _hoisted_3$5 = { class: "text-core-content-primary flex min-w-0 flex-1 flex-col gap-2" };
54
+ const _hoisted_4$4 = {
55
55
  key: 0,
56
56
  class: "text-sm font-bold"
57
57
  };
@@ -59,17 +59,17 @@ const _hoisted_5$3 = {
59
59
  key: 1,
60
60
  class: "flex items-center"
61
61
  };
62
- const _sfc_main$h = /* @__PURE__ */ defineComponent({
62
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
63
63
  ...{ name: "CkAgentMessage" },
64
64
  __name: "CkAgentMessage",
65
65
  setup(__props) {
66
66
  return (_ctx, _cache) => {
67
- return openBlock(), createElementBlock("div", _hoisted_1$8, [
68
- _ctx.$slots.icon ? (openBlock(), createElementBlock("div", _hoisted_2$5, [
67
+ return openBlock(), createElementBlock("div", _hoisted_1$9, [
68
+ _ctx.$slots.icon ? (openBlock(), createElementBlock("div", _hoisted_2$6, [
69
69
  renderSlot(_ctx.$slots, "icon")
70
70
  ])) : createCommentVNode("", true),
71
- createElementVNode("div", _hoisted_3$4, [
72
- _ctx.$slots.header ? (openBlock(), createElementBlock("span", _hoisted_4$3, [
71
+ createElementVNode("div", _hoisted_3$5, [
72
+ _ctx.$slots.header ? (openBlock(), createElementBlock("span", _hoisted_4$4, [
73
73
  renderSlot(_ctx.$slots, "header")
74
74
  ])) : createCommentVNode("", true),
75
75
  createElementVNode("div", null, [
@@ -83,16 +83,16 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
83
83
  };
84
84
  }
85
85
  });
86
- const _hoisted_1$7 = ["data-message-row"];
87
- const _hoisted_2$4 = {
86
+ const _hoisted_1$8 = ["data-message-row"];
87
+ const _hoisted_2$5 = {
88
88
  key: 0,
89
89
  class: "flex justify-end"
90
90
  };
91
- const _hoisted_3$3 = {
91
+ const _hoisted_3$4 = {
92
92
  key: 1,
93
93
  class: "flex justify-start"
94
94
  };
95
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
95
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
96
96
  ...{ name: "CkConversationLayout" },
97
97
  __name: "CkConversationLayout",
98
98
  props: {
@@ -232,12 +232,12 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
232
232
  key: message.id,
233
233
  "data-message-row": message.role
234
234
  }, [
235
- message.role === "user" ? (openBlock(), createElementBlock("div", _hoisted_2$4, [
235
+ message.role === "user" ? (openBlock(), createElementBlock("div", _hoisted_2$5, [
236
236
  renderSlot(_ctx.$slots, "user-message", { message })
237
- ])) : (openBlock(), createElementBlock("div", _hoisted_3$3, [
237
+ ])) : (openBlock(), createElementBlock("div", _hoisted_3$4, [
238
238
  renderSlot(_ctx.$slots, "agent-message", { message })
239
239
  ]))
240
- ], 8, _hoisted_1$7);
240
+ ], 8, _hoisted_1$8);
241
241
  }), 128)),
242
242
  hasBottomSpacer.value ? (openBlock(), createElementBlock("div", {
243
243
  key: 0,
@@ -248,7 +248,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
248
248
  };
249
249
  }
250
250
  });
251
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
251
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
252
252
  ...{
253
253
  name: "CkMessageActionButton"
254
254
  },
@@ -272,11 +272,11 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
272
272
  };
273
273
  }
274
274
  });
275
- const _hoisted_1$6 = {
275
+ const _hoisted_1$7 = {
276
276
  class: "sr-only",
277
277
  "aria-live": "polite"
278
278
  };
279
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
279
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
280
280
  ...{
281
281
  name: "CkCopyMessageActionButton"
282
282
  },
@@ -333,7 +333,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
333
333
  "delay-duration": 0
334
334
  }, {
335
335
  default: withCtx(() => [
336
- createVNode(unref(_sfc_main$f), mergeProps({ ariaLabel: copied.value ? __props.ariaLabelCopied : __props.ariaLabelCopy }, {
336
+ createVNode(unref(_sfc_main$g), mergeProps({ ariaLabel: copied.value ? __props.ariaLabelCopied : __props.ariaLabelCopy }, {
337
337
  disabled: __props.disabled,
338
338
  onClick: handleClick
339
339
  }), {
@@ -360,7 +360,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
360
360
  ]),
361
361
  _: 1
362
362
  }, 16, ["disabled"]),
363
- createElementVNode("span", _hoisted_1$6, toDisplayString(copied.value ? __props.ariaLabelCopied : __props.ariaLabelCopy), 1)
363
+ createElementVNode("span", _hoisted_1$7, toDisplayString(copied.value ? __props.ariaLabelCopied : __props.ariaLabelCopy), 1)
364
364
  ]),
365
365
  _: 1
366
366
  }, 8, ["open", "content"]);
@@ -374,9 +374,9 @@ const _export_sfc = (sfc, props) => {
374
374
  }
375
375
  return target;
376
376
  };
377
- const CkCopyMessageActionButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-f77a1193"]]);
378
- const _hoisted_1$5 = ["aria-label"];
379
- const _sfc_main$d = /* @__PURE__ */ defineComponent({
377
+ const CkCopyMessageActionButton = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-f77a1193"]]);
378
+ const _hoisted_1$6 = ["aria-label"];
379
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
380
380
  ...{
381
381
  name: "CkFeedbackButton"
382
382
  },
@@ -431,7 +431,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
431
431
  "delay-duration": 0
432
432
  }, {
433
433
  default: withCtx(() => [
434
- createVNode(unref(_sfc_main$f), mergeProps({ ariaLabel: thumbsUpLabel.value }, {
434
+ createVNode(unref(_sfc_main$g), mergeProps({ ariaLabel: thumbsUpLabel.value }, {
435
435
  "aria-pressed": isUpSelected.value,
436
436
  "aria-disabled": __props.locked || void 0,
437
437
  disabled: isUpDisabled.value,
@@ -461,7 +461,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
461
461
  "delay-duration": 0
462
462
  }, {
463
463
  default: withCtx(() => [
464
- createVNode(unref(_sfc_main$f), mergeProps({ ariaLabel: thumbsDownLabel.value }, {
464
+ createVNode(unref(_sfc_main$g), mergeProps({ ariaLabel: thumbsDownLabel.value }, {
465
465
  "aria-pressed": isDownSelected.value,
466
466
  "aria-disabled": __props.locked || void 0,
467
467
  disabled: isDownDisabled.value,
@@ -484,12 +484,318 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
484
484
  ]),
485
485
  _: 1
486
486
  }, 8, ["content"])
487
- ], 8, _hoisted_1$5);
487
+ ], 8, _hoisted_1$6);
488
+ };
489
+ }
490
+ });
491
+ const CkFeedbackButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-245705b8"]]);
492
+ const defaultMarkdownClasses = {
493
+ p: "my-1 leading-7",
494
+ a: "underline underline-offset-4",
495
+ h1: "mt-4 mb-2 text-2xl font-bold",
496
+ h2: "mt-3 mb-2 text-xl font-semibold",
497
+ h3: "mt-3 mb-1 text-lg font-semibold",
498
+ ul: "my-1 ml-6 list-disc",
499
+ ol: "my-1 ml-6 list-decimal",
500
+ li: "my-0.5",
501
+ pre: "my-2 overflow-x-auto rounded-lg p-4",
502
+ code: "rounded px-1.5 py-0.5",
503
+ blockquote: "my-2 border-l-2 pl-4 italic",
504
+ table: "my-2 w-full border-collapse",
505
+ th: "border p-2 text-left font-semibold",
506
+ td: "border p-2",
507
+ hr: "my-4"
508
+ };
509
+ function domToVNode(node, slots, classes) {
510
+ if (node.nodeType === Node.TEXT_NODE) return node.textContent;
511
+ if (node.nodeType !== Node.ELEMENT_NODE) return null;
512
+ const el = node;
513
+ if (el.tagName === "PRE" && el.firstElementChild?.tagName === "CODE") {
514
+ const codeEl = el.firstElementChild;
515
+ const language = codeEl.className?.match(/language-(\S+)/)?.[1] ?? "";
516
+ const code = codeEl.textContent ?? "";
517
+ if (slots["code-block"]) {
518
+ return slots["code-block"]({ code, language });
519
+ }
520
+ }
521
+ const children = Array.from(node.childNodes).map((child) => domToVNode(child, slots, classes)).filter((c) => c != null);
522
+ const attrs = {};
523
+ for (const attr of el.attributes) {
524
+ attrs[attr.name] = attr.value;
525
+ }
526
+ const tag = el.tagName.toLowerCase();
527
+ const customClass = classes[tag];
528
+ if (customClass) {
529
+ attrs.class = attrs.class ? `${attrs.class} ${customClass}` : customClass;
530
+ }
531
+ return h(tag, attrs, children);
532
+ }
533
+ const _sfc_main$d = defineComponent({
534
+ name: "CkMarkdownRenderer",
535
+ props: {
536
+ content: { type: String, required: true },
537
+ classes: {
538
+ type: Object,
539
+ default: () => ({})
540
+ },
541
+ plugins: { type: Array, default: void 0 }
542
+ },
543
+ setup(props, { slots }) {
544
+ const { content, plugins } = toRefs(props);
545
+ const { html } = useMarkdownParser(content, plugins);
546
+ const parsedNodes = computed(() => {
547
+ const raw = html.value;
548
+ if (!raw) return [];
549
+ const doc = new DOMParser().parseFromString(raw, "text/html");
550
+ return Array.from(doc.body.childNodes);
551
+ });
552
+ const mergedClasses = computed(() => ({
553
+ ...defaultMarkdownClasses,
554
+ ...props.classes
555
+ }));
556
+ return () => {
557
+ const elementClasses = mergedClasses.value;
558
+ const children = parsedNodes.value.map((node) => domToVNode(node, slots, elementClasses)).filter((c) => c != null);
559
+ return h("div", { class: "markdown-renderer" }, children);
488
560
  };
489
561
  }
490
562
  });
491
- const CkFeedbackButton = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-245705b8"]]);
563
+ const _hoisted_1$5 = {
564
+ key: 0,
565
+ class: "flex min-h-0 flex-col gap-2"
566
+ };
567
+ const _hoisted_2$4 = { 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" };
568
+ const _hoisted_3$3 = { class: "flex min-h-0 flex-col gap-4" };
569
+ const _hoisted_4$3 = {
570
+ class: "self-end text-sm text-content-on-surface-muted tabular-nums",
571
+ "aria-live": "polite"
572
+ };
492
573
  const _sfc_main$c = /* @__PURE__ */ defineComponent({
574
+ ...{
575
+ name: "CkFeedbackDialog"
576
+ },
577
+ __name: "CkFeedbackDialog",
578
+ props: {
579
+ open: { type: Boolean, default: false },
580
+ sentiment: {},
581
+ responseText: { default: "" },
582
+ reasons: {},
583
+ maxFreeTextLength: { default: 250 },
584
+ submitting: { type: Boolean, default: false },
585
+ disabled: { type: Boolean, default: false },
586
+ titlePositive: {},
587
+ titleNegative: {},
588
+ responseHeading: {},
589
+ description: {},
590
+ otherLabel: {},
591
+ otherTooltip: {},
592
+ freeTextPlaceholder: {},
593
+ cancelLabel: {},
594
+ submitLabel: {}
595
+ },
596
+ emits: ["update:open", "submit", "cancel"],
597
+ setup(__props, { emit: __emit }) {
598
+ const emit = __emit;
599
+ const labels = useChatKitLabels();
600
+ const title = computed(() => {
601
+ if (__props.sentiment === "positive") {
602
+ return __props.titlePositive ?? labels.value.feedbackDialogTitlePositive ?? defaultChatKitLabels.feedbackDialogTitlePositive;
603
+ }
604
+ return __props.titleNegative ?? labels.value.feedbackDialogTitleNegative ?? defaultChatKitLabels.feedbackDialogTitleNegative;
605
+ });
606
+ const responseHeading = computed(
607
+ () => __props.responseHeading ?? labels.value.feedbackDialogResponseHeading ?? defaultChatKitLabels.feedbackDialogResponseHeading
608
+ );
609
+ const description = computed(
610
+ () => __props.description ?? labels.value.feedbackDialogDescription ?? defaultChatKitLabels.feedbackDialogDescription
611
+ );
612
+ const otherLabel = computed(
613
+ () => __props.otherLabel ?? labels.value.feedbackDialogOtherLabel ?? defaultChatKitLabels.feedbackDialogOtherLabel
614
+ );
615
+ const otherTooltip = computed(
616
+ () => __props.otherTooltip ?? labels.value.feedbackDialogOtherTooltip ?? defaultChatKitLabels.feedbackDialogOtherTooltip
617
+ );
618
+ const freeTextPlaceholder = computed(
619
+ () => __props.freeTextPlaceholder ?? labels.value.feedbackDialogFreeTextPlaceholder ?? defaultChatKitLabels.feedbackDialogFreeTextPlaceholder
620
+ );
621
+ const cancelLabel = computed(
622
+ () => __props.cancelLabel ?? labels.value.feedbackDialogCancelLabel ?? defaultChatKitLabels.feedbackDialogCancelLabel
623
+ );
624
+ const submitLabel = computed(
625
+ () => __props.submitLabel ?? labels.value.feedbackDialogSubmitLabel ?? defaultChatKitLabels.feedbackDialogSubmitLabel
626
+ );
627
+ const selectedReason = ref("");
628
+ const freeText = ref("");
629
+ const freeTextId = useId();
630
+ watch(
631
+ () => __props.open,
632
+ (isOpen, wasOpen) => {
633
+ if (isOpen && !wasOpen) {
634
+ selectedReason.value = "";
635
+ freeText.value = "";
636
+ }
637
+ }
638
+ );
639
+ const showResponseColumn = computed(
640
+ () => typeof __props.responseText === "string" && __props.responseText !== ""
641
+ );
642
+ const characterCount = computed(() => freeText.value.length);
643
+ const canSubmit = computed(
644
+ () => !__props.disabled && !__props.submitting && (selectedReason.value !== "" || freeText.value.trim() !== "")
645
+ );
646
+ function handleOpenChange(next) {
647
+ if (!next && (__props.submitting || __props.disabled)) {
648
+ return;
649
+ }
650
+ emit("update:open", next);
651
+ if (!next && __props.open) {
652
+ emit("cancel");
653
+ }
654
+ }
655
+ function handleCancel() {
656
+ if (__props.disabled || __props.submitting) {
657
+ return;
658
+ }
659
+ emit("cancel");
660
+ emit("update:open", false);
661
+ }
662
+ function handleSubmit() {
663
+ if (!canSubmit.value) {
664
+ return;
665
+ }
666
+ emit("submit", {
667
+ sentiment: __props.sentiment,
668
+ reason: selectedReason.value === "" ? null : selectedReason.value,
669
+ reasonText: freeText.value.trim()
670
+ });
671
+ }
672
+ return (_ctx, _cache) => {
673
+ return openBlock(), createBlock(unref(UiDialog), {
674
+ open: __props.open,
675
+ "onUpdate:open": handleOpenChange
676
+ }, {
677
+ default: withCtx(() => [
678
+ createVNode(unref(UiDialogContent), {
679
+ title: title.value,
680
+ "max-width": "max-w-4xl",
681
+ class: "ck-feedback-dialog",
682
+ "show-close-button": !(__props.submitting || __props.disabled)
683
+ }, {
684
+ actions: withCtx(() => [
685
+ createVNode(unref(UiButton), {
686
+ type: "button",
687
+ variant: "outline",
688
+ "aria-label": cancelLabel.value,
689
+ disabled: __props.disabled || __props.submitting,
690
+ onClick: handleCancel
691
+ }, {
692
+ default: withCtx(() => [
693
+ createTextVNode(toDisplayString(cancelLabel.value), 1)
694
+ ]),
695
+ _: 1
696
+ }, 8, ["aria-label", "disabled"]),
697
+ createVNode(unref(UiButton), {
698
+ type: "button",
699
+ variant: "default",
700
+ "aria-label": submitLabel.value,
701
+ loading: __props.submitting,
702
+ disabled: !canSubmit.value,
703
+ onClick: handleSubmit
704
+ }, {
705
+ default: withCtx(() => [
706
+ createTextVNode(toDisplayString(submitLabel.value), 1)
707
+ ]),
708
+ _: 1
709
+ }, 8, ["aria-label", "loading", "disabled"])
710
+ ]),
711
+ default: withCtx(() => [
712
+ createVNode(unref(UiDialogDescription), { class: "sr-only" }, {
713
+ default: withCtx(() => [
714
+ createTextVNode(toDisplayString(description.value), 1)
715
+ ]),
716
+ _: 1
717
+ }),
718
+ createElementVNode("div", {
719
+ class: normalizeClass([
720
+ "grid gap-12",
721
+ showResponseColumn.value ? "grid-cols-2" : "grid-cols-1"
722
+ ])
723
+ }, [
724
+ showResponseColumn.value ? (openBlock(), createElementBlock("section", _hoisted_1$5, [
725
+ createVNode(unref(UiFieldLabel), null, {
726
+ default: withCtx(() => [
727
+ createTextVNode(toDisplayString(responseHeading.value), 1)
728
+ ]),
729
+ _: 1
730
+ }),
731
+ createElementVNode("div", _hoisted_2$4, [
732
+ createVNode(unref(_sfc_main$d), { content: __props.responseText }, null, 8, ["content"])
733
+ ])
734
+ ])) : createCommentVNode("", true),
735
+ createElementVNode("section", _hoisted_3$3, [
736
+ createVNode(unref(UiToggleGroup), {
737
+ modelValue: selectedReason.value,
738
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectedReason.value = $event),
739
+ type: "single",
740
+ variant: "outline",
741
+ disabled: __props.disabled || __props.submitting,
742
+ class: "grid grid-cols-2 gap-4",
743
+ "aria-label": title.value
744
+ }, {
745
+ default: withCtx(() => [
746
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.reasons, (reason) => {
747
+ return openBlock(), createBlock(unref(UiToggleGroupItem), {
748
+ key: reason.code,
749
+ value: reason.code,
750
+ class: "ck-feedback-dialog__chip"
751
+ }, {
752
+ default: withCtx(() => [
753
+ createTextVNode(toDisplayString(reason.label), 1)
754
+ ]),
755
+ _: 2
756
+ }, 1032, ["value"]);
757
+ }), 128))
758
+ ]),
759
+ _: 1
760
+ }, 8, ["modelValue", "disabled", "aria-label"]),
761
+ createVNode(unref(UiField), null, {
762
+ default: withCtx(() => [
763
+ createVNode(unref(UiFieldLabel), {
764
+ for: unref(freeTextId),
765
+ tooltip: otherTooltip.value
766
+ }, {
767
+ default: withCtx(() => [
768
+ createTextVNode(toDisplayString(otherLabel.value), 1)
769
+ ]),
770
+ _: 1
771
+ }, 8, ["for", "tooltip"]),
772
+ createVNode(unref(UiTextarea), {
773
+ id: unref(freeTextId),
774
+ modelValue: freeText.value,
775
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => freeText.value = $event),
776
+ name: "ck-feedback-dialog-free-text",
777
+ placeholder: freeTextPlaceholder.value,
778
+ disabled: __props.disabled || __props.submitting,
779
+ maxlength: __props.maxFreeTextLength,
780
+ rows: "3"
781
+ }, null, 8, ["id", "modelValue", "placeholder", "disabled", "maxlength"]),
782
+ createElementVNode("div", _hoisted_4$3, toDisplayString(characterCount.value) + "/" + toDisplayString(__props.maxFreeTextLength), 1)
783
+ ]),
784
+ _: 1
785
+ })
786
+ ])
787
+ ], 2)
788
+ ]),
789
+ _: 1
790
+ }, 8, ["title", "show-close-button"])
791
+ ]),
792
+ _: 1
793
+ }, 8, ["open"]);
794
+ };
795
+ }
796
+ });
797
+ const CkFeedbackDialog = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-eaffd2d5"]]);
798
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
493
799
  ...{
494
800
  name: "CkFileItemRow",
495
801
  inheritAttrs: false
@@ -537,7 +843,7 @@ const _hoisted_2$3 = ["onClick"];
537
843
  const _hoisted_3$2 = ["disabled", "aria-label"];
538
844
  const _hoisted_4$2 = ["aria-label"];
539
845
  const _hoisted_5$2 = ["onClick"];
540
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
846
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
541
847
  ...{
542
848
  name: "CkFileItemsList"
543
849
  },
@@ -594,7 +900,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
594
900
  class: "min-w-0 max-w-64 flex-1 basis-0",
595
901
  onClick: ($event) => handleRowClick(file, $event)
596
902
  }, [
597
- createVNode(_sfc_main$c, {
903
+ createVNode(_sfc_main$b, {
598
904
  file,
599
905
  size: __props.size,
600
906
  "is-removable": __props.isRemovable,
@@ -658,7 +964,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
658
964
  class: "min-w-0 max-w-64",
659
965
  onClick: ($event) => handleRowClick(file, $event)
660
966
  }, [
661
- createVNode(_sfc_main$c, {
967
+ createVNode(_sfc_main$b, {
662
968
  file,
663
969
  size: __props.size,
664
970
  "is-removable": __props.isRemovable,
@@ -706,7 +1012,7 @@ const _hoisted_7$1 = {
706
1012
  const _hoisted_8 = ["aria-label"];
707
1013
  const _hoisted_9 = ["aria-label"];
708
1014
  const _hoisted_10 = ["aria-label"];
709
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
1015
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
710
1016
  ...{
711
1017
  name: "CkHistoryItem",
712
1018
  inheritAttrs: false
@@ -947,7 +1253,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
947
1253
  }
948
1254
  });
949
1255
  const baseClass = "flex w-full min-w-0 flex-col p-2";
950
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
1256
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
951
1257
  ...{
952
1258
  name: "CkHistoryWrapper",
953
1259
  inheritAttrs: false
@@ -977,77 +1283,6 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
977
1283
  };
978
1284
  }
979
1285
  });
980
- const defaultMarkdownClasses = {
981
- p: "my-1 leading-7",
982
- a: "underline underline-offset-4",
983
- h1: "mt-4 mb-2 text-2xl font-bold",
984
- h2: "mt-3 mb-2 text-xl font-semibold",
985
- h3: "mt-3 mb-1 text-lg font-semibold",
986
- ul: "my-1 ml-6 list-disc",
987
- ol: "my-1 ml-6 list-decimal",
988
- li: "my-0.5",
989
- pre: "my-2 overflow-x-auto rounded-lg p-4",
990
- code: "rounded px-1.5 py-0.5",
991
- blockquote: "my-2 border-l-2 pl-4 italic",
992
- table: "my-2 w-full border-collapse",
993
- th: "border p-2 text-left font-semibold",
994
- td: "border p-2",
995
- hr: "my-4"
996
- };
997
- function domToVNode(node, slots, classes) {
998
- if (node.nodeType === Node.TEXT_NODE) return node.textContent;
999
- if (node.nodeType !== Node.ELEMENT_NODE) return null;
1000
- const el = node;
1001
- if (el.tagName === "PRE" && el.firstElementChild?.tagName === "CODE") {
1002
- const codeEl = el.firstElementChild;
1003
- const language = codeEl.className?.match(/language-(\S+)/)?.[1] ?? "";
1004
- const code = codeEl.textContent ?? "";
1005
- if (slots["code-block"]) {
1006
- return slots["code-block"]({ code, language });
1007
- }
1008
- }
1009
- const children = Array.from(node.childNodes).map((child) => domToVNode(child, slots, classes)).filter((c) => c != null);
1010
- const attrs = {};
1011
- for (const attr of el.attributes) {
1012
- attrs[attr.name] = attr.value;
1013
- }
1014
- const tag = el.tagName.toLowerCase();
1015
- const customClass = classes[tag];
1016
- if (customClass) {
1017
- attrs.class = attrs.class ? `${attrs.class} ${customClass}` : customClass;
1018
- }
1019
- return h(tag, attrs, children);
1020
- }
1021
- const _sfc_main$8 = defineComponent({
1022
- name: "CkMarkdownRenderer",
1023
- props: {
1024
- content: { type: String, required: true },
1025
- classes: {
1026
- type: Object,
1027
- default: () => ({})
1028
- },
1029
- plugins: { type: Array, default: void 0 }
1030
- },
1031
- setup(props, { slots }) {
1032
- const { content, plugins } = toRefs(props);
1033
- const { html } = useMarkdownParser(content, plugins);
1034
- const parsedNodes = computed(() => {
1035
- const raw = html.value;
1036
- if (!raw) return [];
1037
- const doc = new DOMParser().parseFromString(raw, "text/html");
1038
- return Array.from(doc.body.childNodes);
1039
- });
1040
- const mergedClasses = computed(() => ({
1041
- ...defaultMarkdownClasses,
1042
- ...props.classes
1043
- }));
1044
- return () => {
1045
- const elementClasses = mergedClasses.value;
1046
- const children = parsedNodes.value.map((node) => domToVNode(node, slots, elementClasses)).filter((c) => c != null);
1047
- return h("div", { class: "markdown-renderer" }, children);
1048
- };
1049
- }
1050
- });
1051
1286
  const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1052
1287
  ...{ name: "CkPromptActionButton" },
1053
1288
  __name: "CkPromptActionButton",
@@ -1260,7 +1495,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1260
1495
  return message.content.filter((c) => c.type === "text").map((c) => c.text).join("");
1261
1496
  }
1262
1497
  return (_ctx, _cache) => {
1263
- return openBlock(), createBlock(_sfc_main$g, { messages: __props.messages }, {
1498
+ return openBlock(), createBlock(_sfc_main$h, { messages: __props.messages }, {
1264
1499
  "user-message": withCtx(({ message }) => [
1265
1500
  createElementVNode("div", {
1266
1501
  class: normalizeClass({ "ml-8": hasIcon.value })
@@ -1279,7 +1514,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1279
1514
  ]),
1280
1515
  "agent-message": withCtx(({ message }) => [
1281
1516
  renderSlot(_ctx.$slots, "agent-message", { message }, () => [
1282
- createVNode(_sfc_main$h, null, createSlots({
1517
+ createVNode(_sfc_main$i, null, createSlots({
1283
1518
  footer: withCtx(() => [
1284
1519
  renderSlot(_ctx.$slots, "agent-message-footer", { message }, () => [
1285
1520
  getMessageText(message) && !isLoading(message) ? (openBlock(), createBlock(CkCopyMessageActionButton, {
@@ -1292,7 +1527,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1292
1527
  ]),
1293
1528
  default: withCtx(() => [
1294
1529
  renderSlot(_ctx.$slots, "agent-message-content", { message }, () => [
1295
- createVNode(_sfc_main$8, {
1530
+ createVNode(_sfc_main$d, {
1296
1531
  content: getMessageText(message),
1297
1532
  classes: __props.agentMarkdownClasses
1298
1533
  }, createSlots({ _: 2 }, [
@@ -1400,7 +1635,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1400
1635
  emit("select", c, event);
1401
1636
  }
1402
1637
  return (_ctx, _cache) => {
1403
- return openBlock(), createBlock(_sfc_main$9, null, {
1638
+ return openBlock(), createBlock(_sfc_main$8, null, {
1404
1639
  default: withCtx(() => [
1405
1640
  (openBlock(true), createElementBlock(Fragment, null, renderList(props.conversations, (conversation) => {
1406
1641
  return renderSlot(_ctx.$slots, "item", {
@@ -1413,7 +1648,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1413
1648
  edit: () => emit("edit", conversation),
1414
1649
  delete: () => emit("delete", conversation)
1415
1650
  }, () => [
1416
- createVNode(_sfc_main$a, {
1651
+ createVNode(_sfc_main$9, {
1417
1652
  as: "a",
1418
1653
  href: hrefFor(conversation),
1419
1654
  "is-active": conversation.id === props.activeId,
@@ -1522,7 +1757,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1522
1757
  }, {
1523
1758
  default: withCtx(() => [
1524
1759
  renderSlot(_ctx.$slots, "stop-icon", {}, () => [
1525
- createVNode(_sfc_main$i)
1760
+ createVNode(_sfc_main$j)
1526
1761
  ])
1527
1762
  ]),
1528
1763
  _: 3
@@ -1532,7 +1767,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1532
1767
  }), {
1533
1768
  default: withCtx(() => [
1534
1769
  renderSlot(_ctx.$slots, "send-icon", {}, () => [
1535
- createVNode(_sfc_main$j)
1770
+ createVNode(_sfc_main$k)
1536
1771
  ])
1537
1772
  ]),
1538
1773
  _: 3
@@ -1562,22 +1797,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1562
1797
  });
1563
1798
  export {
1564
1799
  CkCopyMessageActionButton as C,
1565
- _sfc_main$h as _,
1800
+ _sfc_main$i as _,
1566
1801
  _sfc_main$2 as a,
1567
- _sfc_main$g as b,
1802
+ _sfc_main$h as b,
1568
1803
  CkFeedbackButton as c,
1569
- _sfc_main$b as d,
1570
- _sfc_main$1 as e,
1571
- _sfc_main$a as f,
1804
+ CkFeedbackDialog as d,
1805
+ _sfc_main$a as e,
1806
+ _sfc_main$1 as f,
1572
1807
  _sfc_main$9 as g,
1573
- _sfc_main as h,
1574
- _sfc_main$8 as i,
1575
- _sfc_main$f as j,
1576
- _sfc_main$7 as k,
1577
- _sfc_main$5 as l,
1578
- _sfc_main$4 as m,
1579
- _sfc_main$6 as n,
1580
- _sfc_main$j as o,
1581
- _sfc_main$i as p,
1582
- _sfc_main$3 as q
1808
+ _sfc_main$8 as h,
1809
+ _sfc_main as i,
1810
+ _sfc_main$d as j,
1811
+ _sfc_main$g as k,
1812
+ _sfc_main$7 as l,
1813
+ _sfc_main$5 as m,
1814
+ _sfc_main$4 as n,
1815
+ _sfc_main$6 as o,
1816
+ _sfc_main$k as p,
1817
+ _sfc_main$j as q,
1818
+ _sfc_main$3 as r
1583
1819
  };